diff options
author | Devang Patel <dpatel@apple.com> | 2006-12-13 02:36:01 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-12-13 02:36:01 +0000 |
commit | 3162691f69f85f740bc28f3ddca39b166d35187c (patch) | |
tree | d8dd3d9007184cba80f467720eaf827c05c91999 /include/llvm | |
parent | 21c362d3240d0ba9ff98b7f36e54f25936d1a201 (diff) | |
download | external_llvm-3162691f69f85f740bc28f3ddca39b166d35187c.zip external_llvm-3162691f69f85f740bc28f3ddca39b166d35187c.tar.gz external_llvm-3162691f69f85f740bc28f3ddca39b166d35187c.tar.bz2 |
Add #ifdef switch toggle between old and new pass manager. However,
continue to use old pass manager at the moment. To use new manager
remove #define USE_OLD_PASSMANAGER 1 from Pass.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Pass.h | 10 | ||||
-rw-r--r-- | include/llvm/PassAnalysisSupport.h | 28 | ||||
-rw-r--r-- | include/llvm/PassManager.h | 28 |
3 files changed, 53 insertions, 13 deletions
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index fc13a3a..15381ac 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -36,6 +36,8 @@ #include <typeinfo> #include <cassert> +#define USE_OLD_PASSMANAGER 1 + namespace llvm { class Value; @@ -203,7 +205,9 @@ public: virtual bool runPass(Module &M) { return runOnModule(M); } virtual bool runPass(BasicBlock&) { return false; } +#ifdef USE_OLD_PASSMANAGER virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU); +#endif }; @@ -226,10 +230,12 @@ public: /// virtual bool runOnModule(Module &M) { return false; } +#ifdef USE_OLD_PASSMANAGER private: template<typename Trait> friend class PassManagerT; friend class ModulePassManager; virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU); +#endif }; //===----------------------------------------------------------------------===// @@ -269,6 +275,7 @@ public: /// bool run(Function &F); +#ifdef USE_OLD_PASSMANAGER protected: template<typename Trait> friend class PassManagerT; friend class ModulePassManager; @@ -276,6 +283,7 @@ protected: friend class BasicBlockPassManager; virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU); virtual void addToPassManager(FunctionPassManagerT *PM, AnalysisUsage &AU); +#endif }; @@ -329,6 +337,7 @@ public: virtual bool runPass(Module &M) { return false; } virtual bool runPass(BasicBlock &BB); +#ifdef USE_OLD_PASSMANAGER private: template<typename Trait> friend class PassManagerT; friend class FunctionPassManagerT; @@ -338,6 +347,7 @@ private: } virtual void addToPassManager(FunctionPassManagerT *PM, AnalysisUsage &AU); virtual void addToPassManager(BasicBlockPassManager *PM,AnalysisUsage &AU); +#endif }; /// If the user specifies the -time-passes argument on an LLVM tool command line diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index d2aec0b..1575d56 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -189,10 +189,19 @@ protected: /// template<typename AnalysisType> AnalysisType *Pass::getAnalysisToUpdate() const { +#ifdef USE_OLD_PASSMANAGER assert(Resolver && "Pass not resident in a PassManager object!"); +#else + assert(Resolver_New && "Pass not resident in a PassManager object!"); +#endif const PassInfo *PI = getClassPassInfo<AnalysisType>(); if (PI == 0) return 0; +#ifdef USE_OLD_PASSMANAGER return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI)); +#else + return dynamic_cast<AnalysisType*> + (Resolver_New->getAnalysisToUpdate(PI, true)); +#endif } /// getAnalysis<AnalysisType>() - This function is used by subclasses to get @@ -201,15 +210,20 @@ AnalysisType *Pass::getAnalysisToUpdate() const { /// template<typename AnalysisType> AnalysisType &Pass::getAnalysis() const { +#ifdef USE_OLD_PASSMANAGER assert(Resolver && "Pass has not been inserted into a PassManager object!"); +#else + assert(Resolver_New && "Pass has not been inserted into a PassManager object!"); +#endif const PassInfo *PI = getClassPassInfo<AnalysisType>(); return getAnalysisID<AnalysisType>(PI); } template<typename AnalysisType> AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const { - assert(Resolver && "Pass has not been inserted into a PassManager object!"); assert(PI && "getAnalysis for unregistered pass!"); +#ifdef USE_OLD_PASSMANAGER + assert(Resolver && "Pass has not been inserted into a PassManager object!"); // PI *must* appear in AnalysisImpls. Because the number of passes used // should be a small number, we just do a linear search over a (dense) @@ -224,7 +238,17 @@ AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const { break; } } - +#else + assert(Resolver_New && "Pass has not been inserted into a PassManager object!"); + // PI *must* appear in AnalysisImpls. Because the number of passes used + // should be a small number, we just do a linear search over a (dense) + // vector. + Pass *ResultPass = Resolver_New->findImplPass(PI); + assert (ResultPass && + "getAnalysis*() called on an analysis that was not " + "'required' by pass!"); + +#endif // Because the AnalysisType may not be a subclass of pass (for // AnalysisGroups), we must use dynamic_cast here to potentially adjust the // return pointer (because the class may multiply inherit, once from pass, diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index 1f0fa1a..1e4f554 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -25,6 +25,9 @@ class Pass; class ModulePass; class Module; class ModuleProvider; + +#ifdef USE_OLD_PASSMANAGER + class ModulePassManager; class FunctionPassManagerT; class BasicBlockPassManager; @@ -87,17 +90,19 @@ public: bool doFinalization(); }; -class ModulePassManager_New; +#else + +class ModulePassManager; class PassManagerImpl_New; class FunctionPassManagerImpl_New; -/// PassManager_New manages ModulePassManagers -class PassManager_New { +/// PassManager manages ModulePassManagers +class PassManager { public: - PassManager_New(); - ~PassManager_New(); + PassManager(); + ~PassManager(); /// 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 @@ -111,18 +116,18 @@ public: private: - /// PassManagerImpl_New is the actual class. PassManager_New is just the + /// PassManagerImpl_New is the actual class. PassManager is just the /// wraper to publish simple pass manager interface PassManagerImpl_New *PM; }; -/// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers. -class FunctionPassManager_New { +/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers. +class FunctionPassManager { public: - FunctionPassManager_New(ModuleProvider *P); - FunctionPassManager_New(); - ~FunctionPassManager_New(); + FunctionPassManager(ModuleProvider *P); + FunctionPassManager(); + ~FunctionPassManager(); /// add - Add a pass to the queue of passes to run. This passes /// ownership of the Pass to the PassManager. When the @@ -150,6 +155,7 @@ private: ModuleProvider *MP; }; +#endif } // End llvm namespace |