Added Pass::createPass(ID) to handle pass configuration by ID

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150092 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick 2012-02-08 21:22:34 +00:00
parent d2a7bedbc9
commit ebe18ef5c2
4 changed files with 18 additions and 3 deletions

View File

@ -135,7 +135,7 @@ protected:
///
/// Add a target-independent CodeGen pass at this point in the pipeline.
void addCommonPass(char &ID);
void addPass(char &ID);
/// printNoVerify - Add a pass to dump the machine function, if debugging is
/// enabled.

View File

@ -175,6 +175,10 @@ public:
// argument string, or null if it is not known.
static const PassInfo *lookupPassInfo(StringRef Arg);
// createPass - Create a object for the specified pass class,
// or null if it is not known.
static Pass *createPass(char &TI);
/// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to
/// get analysis information that might be around, for example to update it.
/// This is different than getAnalysis in that it can fail (if the analysis

View File

@ -103,8 +103,12 @@ TargetPassConfig::TargetPassConfig()
llvm_unreachable("TargetPassConfig should not be constructed on-the-fly");
}
void TargetPassConfig::addCommonPass(char &ID) {
// FIXME: about to be implemented.
void TargetPassConfig::addPass(char &ID) {
// FIXME: check user overrides
Pass *P = Pass::createPass(ID);
if (!P)
llvm_unreachable("Pass ID not registered");
PM.add(P);
}
void TargetPassConfig::printNoVerify(const char *Banner) const {

View File

@ -189,6 +189,13 @@ const PassInfo *Pass::lookupPassInfo(StringRef Arg) {
return PassRegistry::getPassRegistry()->getPassInfo(Arg);
}
Pass *Pass::createPass(char &TI) {
const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(&TI);
if (!PI)
return NULL;
return PI->createPass();
}
Pass *PassInfo::createPass() const {
assert((!isAnalysisGroup() || NormalCtor) &&
"No default implementation found for analysis group!");