diff options
author | Devang Patel <dpatel@apple.com> | 2006-12-07 19:21:29 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-12-07 19:21:29 +0000 |
commit | 3f5d2b58b84cb12a9520dd33921ca556d539eb4d (patch) | |
tree | ec16e3e3f8a0ab24a13c1c8143da6be076459474 /lib/VMCore/PassManager.cpp | |
parent | 4045af1175509c81d6a4708df233f0b1abe888fc (diff) |
Add PMTopLevelManager. It is not used yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32314 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/PassManager.cpp')
-rw-r--r-- | lib/VMCore/PassManager.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index f46f4456b2..d4db1d1453 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -86,6 +86,82 @@ using namespace llvm; namespace llvm { +//===----------------------------------------------------------------------===// +// PMTopLevelManager +// +/// PMTopLevelManager manages LastUser info and collects common APIs used by +/// top level pass managers. +class PMTopLevelManager { + +public: + + inline std::vector<Pass *>::iterator passManagersBegin() { + return PassManagers.begin(); + } + + inline std::vector<Pass *>::iterator passManagersEnd() { + return PassManagers.end(); + } + + /// Schedule pass P for execution. Make sure that passes required by + /// P are run before P is run. Update analysis info maintained by + /// the manager. Remove dead passes. This is a recursive function. + void schedulePass(Pass *P, Pass *PM); + + /// This is implemented by top level pass manager and used by + /// schedulePass() to add analysis info passes that are not available. + virtual void addTopLevelPass(Pass *P) = 0; + + /// Set pass P as the last user of the given analysis passes. + void setLastUser(std::vector<Pass *> &AnalysisPasses, Pass *P); + + /// Collect passes whose last user is P + void collectLastUses(std::vector<Pass *> &LastUses, Pass *P); + + virtual ~PMTopLevelManager() { + PassManagers.clear(); + } + +private: + + /// Collection of pass managers + std::vector<Pass *> PassManagers; + + // Map to keep track of last user of the analysis pass. + // LastUser->second is the last user of Lastuser->first. + std::map<Pass *, Pass *> LastUser; +}; + +/// Set pass P as the last user of the given analysis passes. +void PMTopLevelManager::setLastUser(std::vector<Pass *> &AnalysisPasses, + Pass *P) { + + for (std::vector<Pass *>::iterator I = AnalysisPasses.begin(), + E = AnalysisPasses.end(); I != E; ++I) { + Pass *AP = *I; + LastUser[AP] = P; + // If AP is the last user of other passes then make P last user of + // such passes. + for (std::map<Pass *, Pass *>::iterator LUI = LastUser.begin(), + LUE = LastUser.end(); LUI != LUE; ++LUI) { + if (LUI->second == AP) + LastUser[LUI->first] = P; + } + } + +} + +/// Collect passes whose last user is P +void PMTopLevelManager::collectLastUses(std::vector<Pass *> &LastUses, + Pass *P) { + for (std::map<Pass *, Pass *>::iterator LUI = LastUser.begin(), + LUE = LastUser.end(); LUI != LUE; ++LUI) + if (LUI->second == P) + LastUses.push_back(LUI->first); +} + + + /// PMDataManager provides the common place to manage the analysis data /// used by pass managers. class PMDataManager { |