diff options
| author | Devang Patel <dpatel@apple.com> | 2007-01-16 02:00:38 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2007-01-16 02:00:38 +0000 |
| commit | 4268fc08d383522016587b05f2809e422da58472 (patch) | |
| tree | 89fa96c368fd44b31cb1b8c3e2421e607e0d0947 | |
| parent | 6975b6ec09527c26d9a22a26583474ba28f5d9d2 (diff) | |
| download | bcm5719-llvm-4268fc08d383522016587b05f2809e422da58472.tar.gz bcm5719-llvm-4268fc08d383522016587b05f2809e422da58472.zip | |
Code refactoring.
llvm-svn: 33245
| -rw-r--r-- | llvm/include/llvm/PassManagers.h | 8 | ||||
| -rw-r--r-- | llvm/lib/VMCore/PassManager.cpp | 39 |
2 files changed, 29 insertions, 18 deletions
diff --git a/llvm/include/llvm/PassManagers.h b/llvm/include/llvm/PassManagers.h index 170b992c85f..c4b3eed7f8a 100644 --- a/llvm/include/llvm/PassManagers.h +++ b/llvm/include/llvm/PassManagers.h @@ -86,6 +86,13 @@ class llvm::PMStack; namespace llvm { +/// FunctionPassManager and PassManager, two top level managers, serve +/// as the public interface of pass manager infrastructure. +enum TopLevelManagerType { + TLM_Function, // FunctionPassManager + TLM_Pass // PassManager +}; + //===----------------------------------------------------------------------===// // PMTopLevelManager // @@ -118,6 +125,7 @@ public: /// then return NULL. Pass *findAnalysisPass(AnalysisID AID); + PMTopLevelManager(enum TopLevelManagerType t); virtual ~PMTopLevelManager(); /// Add immutable pass and initialize it. diff --git a/llvm/lib/VMCore/PassManager.cpp b/llvm/lib/VMCore/PassManager.cpp index db03842bcea..1e3b48ee686 100644 --- a/llvm/lib/VMCore/PassManager.cpp +++ b/llvm/lib/VMCore/PassManager.cpp @@ -112,7 +112,8 @@ class FunctionPassManagerImpl : public Pass, public PMTopLevelManager { public: - FunctionPassManagerImpl(int Depth) : PMDataManager(Depth) { } + FunctionPassManagerImpl(int Depth) : PMDataManager(Depth), + PMTopLevelManager(TLM_Function) { } /// add - Add a pass to the queue of passes to run. This passes ownership of /// the Pass to the PassManager. When the PassManager is destroyed, the pass @@ -151,13 +152,6 @@ public: addImmutablePass(IP); recordAvailableAnalysis(IP); } else { - // Assign manager - if (activeStack.empty()) { - FPPassManager *FPP = new FPPassManager(getDepth() + 1); - FPP->setTopLevelManager(this->getTopLevelManager()); - addPassManager(FPP); - activeStack.push(FPP); - } P->assignPassManager(activeStack); } @@ -220,7 +214,8 @@ class PassManagerImpl : public Pass, public: - PassManagerImpl(int Depth) : PMDataManager(Depth) { } + PassManagerImpl(int Depth) : PMDataManager(Depth), + PMTopLevelManager(TLM_Pass) { } /// add - Add a pass to the queue of passes to run. This passes ownership of /// the Pass to the PassManager. When the PassManager is destroyed, the pass @@ -251,15 +246,6 @@ public: addImmutablePass(IP); recordAvailableAnalysis(IP); } else { - - // Assign manager - if (activeStack.empty()) { - MPPassManager *MPP = new MPPassManager(getDepth() + 1); - MPP->setTopLevelManager(this->getTopLevelManager()); - addPassManager(MPP); - activeStack.push(MPP); - } - P->assignPassManager(activeStack); } @@ -331,6 +317,23 @@ static TimingInfo *TheTimeInfo; //===----------------------------------------------------------------------===// // PMTopLevelManager implementation +/// Initialize top level manager. Create first pass manager. +PMTopLevelManager::PMTopLevelManager (enum TopLevelManagerType t) { + + if (t == TLM_Pass) { + MPPassManager *MPP = new MPPassManager(1); + MPP->setTopLevelManager(this); + addPassManager(MPP); + activeStack.push(MPP); + } + else if (t == TLM_Function) { + FPPassManager *FPP = new FPPassManager(1); + FPP->setTopLevelManager(this); + addPassManager(FPP); + activeStack.push(FPP); + } +} + /// Set pass P as the last user of the given analysis passes. void PMTopLevelManager::setLastUser(std::vector<Pass *> &AnalysisPasses, Pass *P) { |

