Finally commit Saem's 'patch #3' to refactor the pass manager

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25063 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-01-03 07:05:17 +00:00
parent 4983cf7321
commit 505b0701dd

View File

@ -630,18 +630,6 @@ public:
// into a single unit. // into a single unit.
// //
class BasicBlockPassManager { class BasicBlockPassManager {
//TODO:Start absorbing PassManagerTraits<BasicBlock>
};
//===----------------------------------------------------------------------===//
// PassManagerTraits<BasicBlock> Specialization
//
// This pass manager is used to group together all of the BasicBlockPass's
// into a single unit.
//
template<> class PassManagerTraits<BasicBlock> : public BasicBlockPass,
public BasicBlockPassManager {
public: public:
// PassClass - The type of passes tracked by this PassManager // PassClass - The type of passes tracked by this PassManager
typedef BasicBlockPass PassClass; typedef BasicBlockPass PassClass;
@ -664,17 +652,31 @@ public:
// PMType - The type of the passmanager that subclasses this class // PMType - The type of the passmanager that subclasses this class
typedef PassManagerT<BasicBlock> PMType; typedef PassManagerT<BasicBlock> PMType;
// getPMName() - Return the name of the unit the PassManager operates on for
// debugging.
virtual const char *getPMName() const { return "BasicBlock"; }
virtual const char *getPassName() const { return "BasicBlock Pass Manager"; }
// TODO:Start absorbing PassManagerTraits<BasicBlock>
};
//===----------------------------------------------------------------------===//
// PassManagerTraits<BasicBlock> Specialization
//
// This pass manager is used to group together all of the BasicBlockPass's
// into a single unit.
//
template<> class PassManagerTraits<BasicBlock> : public BasicBlockPass,
public BasicBlockPassManager {
public:
// runPass - Specify how the pass should be run on the UnitType // runPass - Specify how the pass should be run on the UnitType
static bool runPass(PassClass *P, BasicBlock *M) { static bool runPass(PassClass *P, BasicBlock *M) {
// todo, init and finalize // todo, init and finalize
return P->runOnBasicBlock(*M); return P->runOnBasicBlock(*M);
} }
// getPMName() - Return the name of the unit the PassManager operates on for
// debugging.
const char *getPMName() const { return "BasicBlock"; }
virtual const char *getPassName() const { return "BasicBlock Pass Manager"; }
// Implement the BasicBlockPass interface... // Implement the BasicBlockPass interface...
virtual bool doInitialization(Module &M); virtual bool doInitialization(Module &M);
virtual bool doInitialization(Function &F); virtual bool doInitialization(Function &F);
@ -682,9 +684,15 @@ public:
virtual bool doFinalization(Function &F); virtual bool doFinalization(Function &F);
virtual bool doFinalization(Module &M); virtual bool doFinalization(Module &M);
// Forwarded
virtual const char *getPassName() const {
return BasicBlockPassManager::getPassName();
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll(); AU.setPreservesAll();
} }
}; };
@ -695,18 +703,6 @@ public:
// into a single unit. // into a single unit.
// //
class FunctionPassManagerT { class FunctionPassManagerT {
//TODO:Start absorbing PassManagerTraits<Function>
};
//===----------------------------------------------------------------------===//
// PassManagerTraits<Function> Specialization
//
// This pass manager is used to group together all of the FunctionPass's
// into a single unit.
//
template<> class PassManagerTraits<Function> : public FunctionPass,
public FunctionPassManagerT {
public: public:
// PassClass - The type of passes tracked by this PassManager // PassClass - The type of passes tracked by this PassManager
typedef FunctionPass PassClass; typedef FunctionPass PassClass;
@ -723,16 +719,30 @@ public:
// PMType - The type of the passmanager that subclasses this class // PMType - The type of the passmanager that subclasses this class
typedef PassManagerT<Function> PMType; typedef PassManagerT<Function> PMType;
// getPMName() - Return the name of the unit the PassManager operates on for
// debugging.
virtual const char *getPMName() const { return "Function"; }
virtual const char *getPassName() const { return "Function Pass Manager"; }
// TODO:Start absorbing PassManagerTraits<Function>
};
//===----------------------------------------------------------------------===//
// PassManagerTraits<Function> Specialization
//
// This pass manager is used to group together all of the FunctionPass's
// into a single unit.
//
template<> class PassManagerTraits<Function> : public FunctionPass,
public FunctionPassManagerT {
public:
// runPass - Specify how the pass should be run on the UnitType // runPass - Specify how the pass should be run on the UnitType
static bool runPass(PassClass *P, Function *F) { static bool runPass(PassClass *P, Function *F) {
return P->runOnFunction(*F); return P->runOnFunction(*F);
} }
// getPMName() - Return the name of the unit the PassManager operates on for
// debugging.
const char *getPMName() const { return "Function"; }
virtual const char *getPassName() const { return "Function Pass Manager"; }
// Implement the FunctionPass interface... // Implement the FunctionPass interface...
virtual bool doInitialization(Module &M); virtual bool doInitialization(Module &M);
virtual bool runOnFunction(Function &F); virtual bool runOnFunction(Function &F);
@ -741,6 +751,11 @@ public:
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll(); AU.setPreservesAll();
} }
// Forwarded
virtual const char *getPassName() const {
return FunctionPassManagerT::getPassName();
}
}; };
@ -750,17 +765,6 @@ public:
// This is the top level PassManager implementation that holds generic passes. // This is the top level PassManager implementation that holds generic passes.
// //
class ModulePassManager { class ModulePassManager {
//TODO:Start absorbing PassManagerTraits<Module>
};
//===----------------------------------------------------------------------===//
// PassManagerTraits<Module> Specialization
//
// This is the top level PassManager implementation that holds generic passes.
//
template<> class PassManagerTraits<Module> : public ModulePass,
public ModulePassManager {
public: public:
// PassClass - The type of passes tracked by this PassManager // PassClass - The type of passes tracked by this PassManager
typedef ModulePass PassClass; typedef ModulePass PassClass;
@ -774,18 +778,39 @@ public:
// ParentClass - The type of the parent PassManager... // ParentClass - The type of the parent PassManager...
typedef AnalysisResolver ParentClass; typedef AnalysisResolver ParentClass;
// runPass - Specify how the pass should be run on the UnitType // getPMName() - Return the name of the unit the PassManager operates on for
static bool runPass(PassClass *P, Module *M) { return P->runOnModule(*M); } // debugging.
virtual const char *getPassName() const { return "Module Pass Manager"; }
// getPMName() - Return the name of the unit the PassManager operates on for // getPMName() - Return the name of the unit the PassManager operates on for
// debugging. // debugging.
const char *getPMName() const { return "Module"; } virtual const char *getPMName() const { return "Module"; }
virtual const char *getPassName() const { return "Module Pass Manager"; }
// TODO:Start absorbing PassManagerTraits<Module>
};
//===----------------------------------------------------------------------===//
// PassManagerTraits<Module> Specialization
//
// This is the top level PassManager implementation that holds generic passes.
//
template<> class PassManagerTraits<Module> : public ModulePass,
public ModulePassManager {
public:
// runPass - Specify how the pass should be run on the UnitType
static bool runPass(PassClass *P, Module *M) { return P->runOnModule(*M); }
// runOnModule - Implement the PassManager interface. // runOnModule - Implement the PassManager interface.
bool runOnModule(Module &M) { bool runOnModule(Module &M) {
return ((PassManagerT<Module>*)this)->runOnUnit(&M); return ((PassManagerT<Module>*)this)->runOnUnit(&M);
} }
// Forwarded
virtual const char *getPassName() const {
return ModulePassManager::getPassName();
}
}; };