diff options
author | Andrew Trick <atrick@apple.com> | 2012-02-08 21:22:34 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-02-08 21:22:34 +0000 |
commit | ebe18ef5c286bb7c33f6c43f1963a7d22cd73f40 (patch) | |
tree | 12f4475c878f26c4df8b576e9bc411c10ee7d886 | |
parent | d2a7bedbc9d3db35ff424a6a2d257c72341af224 (diff) |
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
-rw-r--r-- | include/llvm/CodeGen/Passes.h | 2 | ||||
-rw-r--r-- | include/llvm/Pass.h | 4 | ||||
-rw-r--r-- | lib/CodeGen/Passes.cpp | 8 | ||||
-rw-r--r-- | lib/VMCore/Pass.cpp | 7 |
4 files changed, 18 insertions, 3 deletions
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 2585aebc1c..8849571731 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -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. diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 104b272d09..a0cbca121d 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -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 diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index eb56734983..2877cf165b 100644 --- a/lib/CodeGen/Passes.cpp +++ b/lib/CodeGen/Passes.cpp @@ -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 { diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 05d2efa850..07ac3c35c1 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -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!"); |