Update assignPassManager() signature to allow selection of preferred

pass manager type. This allows new FPPassManager to select Call Graph
Pass Manager (if available) as its parent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33306 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2007-01-17 20:30:17 +00:00
parent 32b169114e
commit be1ffc6b8d
2 changed files with 35 additions and 20 deletions

View File

@ -57,6 +57,20 @@ class PMDataManager;
// AnalysisID - Use the PassInfo to identify a pass...
typedef const PassInfo* AnalysisID;
/// Different types of internal pass managers. External pass managers
/// (PassManager and FunctionPassManager) are not represented here.
/// Ordering of pass manager types is important here.
enum PassManagerType {
PMT_Unknown = 0,
PMT_ModulePassManager = 1, /// MPPassManager
PMT_CallGraphPassManager, /// CGPassManager
PMT_FunctionPassManager, /// FPPassManager
PMT_LoopPassManager, /// LPPassManager
PMT_BasicBlockPassManager /// BBPassManager
};
typedef enum PassManagerType PassManagerType;
//===----------------------------------------------------------------------===//
/// Pass interface - Implemented by all 'passes'. Subclass this if you are an
/// interprocedural optimization or you do not fit into any of the more
@ -107,7 +121,8 @@ public:
void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); }
void dump() const; // dump - call print(std::cerr, 0);
virtual void assignPassManager(PMStack &PMS) {}
virtual void assignPassManager(PMStack &PMS,
PassManagerType T = PMT_Unknown) {}
// Access AnalysisResolver
inline void setResolver(AnalysisResolver *AR) { Resolver = AR; }
inline AnalysisResolver *getResolver() { return Resolver; }
@ -200,7 +215,8 @@ public:
virtual bool runPass(Module &M) { return runOnModule(M); }
virtual bool runPass(BasicBlock&) { return false; }
virtual void assignPassManager(PMStack &PMS);
virtual void assignPassManager(PMStack &PMS,
PassManagerType T = PMT_ModulePassManager);
// Force out-of-line virtual method.
virtual ~ModulePass();
};
@ -266,7 +282,8 @@ public:
///
bool run(Function &F);
virtual void assignPassManager(PMStack &PMS);
virtual void assignPassManager(PMStack &PMS,
PassManagerType T = PMT_FunctionPassManager);
};
@ -320,19 +337,8 @@ public:
virtual bool runPass(Module &M) { return false; }
virtual bool runPass(BasicBlock &BB);
virtual void assignPassManager(PMStack &PMS);
};
/// Different types of internal pass managers. External pass managers
/// (PassManager and FunctionPassManager) are not represented here.
/// Ordering of pass manager types is important here.
enum PassManagerType {
PMT_Unknown = 0,
PMT_ModulePassManager = 1, /// MPPassManager
PMT_CallGraphPassManager, /// CGPassManager
PMT_FunctionPassManager, /// FPPassManager
PMT_LoopPassManager, /// LPPassManager
PMT_BasicBlockPassManager /// BBPassManager
virtual void assignPassManager(PMStack &PMS,
PassManagerType T = PMT_BasicBlockPassManager);
};
/// PMStack

View File

@ -1202,7 +1202,8 @@ void PMStack::handleLastUserOverflow() {
/// Find appropriate Module Pass Manager in the PM Stack and
/// add self into that manager.
void ModulePass::assignPassManager(PMStack &PMS) {
void ModulePass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
// Find Module Pass Manager
while(!PMS.empty()) {
@ -1219,7 +1220,8 @@ void ModulePass::assignPassManager(PMStack &PMS) {
/// Find appropriate Function Pass Manager or Call Graph Pass Manager
/// in the PM Stack and add self into that manager.
void FunctionPass::assignPassManager(PMStack &PMS) {
void FunctionPass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
// Find Module Pass Manager (TODO : Or Call Graph Pass Manager)
while(!PMS.empty()) {
@ -1245,6 +1247,12 @@ void FunctionPass::assignPassManager(PMStack &PMS) {
// [3] Assign manager to manage this new manager. This may create
// and push new managers into PMS
Pass *P = dynamic_cast<Pass *>(FPP);
// If Call Graph Pass Manager is active then use it to manage
// this new Function Pass manager.
if (PMD->getPassManagerType() == PMT_CallGraphPassManager)
P->assignPassManager(PMS, PMT_CallGraphPassManager);
else
P->assignPassManager(PMS);
// [4] Push new manager into PMS
@ -1257,7 +1265,8 @@ void FunctionPass::assignPassManager(PMStack &PMS) {
/// Find appropriate Basic Pass Manager or Call Graph Pass Manager
/// in the PM Stack and add self into that manager.
void BasicBlockPass::assignPassManager(PMStack &PMS) {
void BasicBlockPass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
BBPassManager *BBP = NULL;