PMT_Last
};
+// Different types of passes.
+enum PassKind {
+ PT_BasicBlock,
+ PT_Loop,
+ PT_Function,
+ PT_CallGraphSCC,
+ PT_Module,
+ PT_PassManager
+};
+
//===----------------------------------------------------------------------===//
/// Pass interface - Implemented by all 'passes'. Subclass this if you are an
/// interprocedural optimization or you do not fit into any of the more
class Pass {
AnalysisResolver *Resolver; // Used to resolve analysis
intptr_t PassID;
-
+ PassKind Kind;
void operator=(const Pass&); // DO NOT IMPLEMENT
Pass(const Pass &); // DO NOT IMPLEMENT
public:
- explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) {
+ explicit Pass(PassKind K, intptr_t pid) : Resolver(0), PassID(pid), Kind(K) {
assert(pid && "pid cannot be 0");
}
- explicit Pass(const void *pid) : Resolver(0), PassID((intptr_t)pid) {
+ explicit Pass(PassKind K, const void *pid)
+ : Resolver(0), PassID((intptr_t)pid), Kind(K) {
assert(pid && "pid cannot be 0");
}
virtual ~Pass();
+
+ PassKind getPassKind() const { return Kind; }
+
/// getPassName - Return a nice clean name for a pass. This usually
/// implemented in terms of the name that is registered by one of the
/// Registration templates, but can be overloaded directly.
// Access AnalysisResolver
inline void setResolver(AnalysisResolver *AR) {
- assert (!Resolver && "Resolver is already set");
+ assert(!Resolver && "Resolver is already set");
Resolver = AR;
}
inline AnalysisResolver *getResolver() {
/// Return what kind of Pass Manager can manage this pass.
virtual PassManagerType getPotentialPassManagerType() const;
- explicit ModulePass(intptr_t pid) : Pass(pid) {}
- explicit ModulePass(const void *pid) : Pass(pid) {}
+ explicit ModulePass(intptr_t pid) : Pass(PT_Module, pid) {}
+ explicit ModulePass(const void *pid) : Pass(PT_Module, pid) {}
// Force out-of-line virtual method.
virtual ~ModulePass();
};
///
class FunctionPass : public Pass {
public:
- explicit FunctionPass(intptr_t pid) : Pass(pid) {}
- explicit FunctionPass(const void *pid) : Pass(pid) {}
+ explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {}
+ explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {}
/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.
///
class BasicBlockPass : public Pass {
public:
- explicit BasicBlockPass(intptr_t pid) : Pass(pid) {}
- explicit BasicBlockPass(const void *pid) : Pass(pid) {}
+ explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {}
+ explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {}
/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.
public:
static char ID;
explicit FunctionPassManagerImpl(int Depth) :
- Pass(&ID), PMDataManager(Depth),
+ Pass(PT_PassManager, &ID), PMDataManager(Depth),
PMTopLevelManager(TLM_Function), wasRun(false) { }
/// add - Add a pass to the queue of passes to run. This passes ownership of
public:
static char ID;
explicit MPPassManager(int Depth) :
- Pass(&ID), PMDataManager(Depth) { }
+ Pass(PT_PassManager, &ID), PMDataManager(Depth) { }
// Delete on the fly managers.
virtual ~MPPassManager() {
public:
static char ID;
explicit PassManagerImpl(int Depth) :
- Pass(&ID), PMDataManager(Depth), PMTopLevelManager(TLM_Pass) { }
+ Pass(PT_PassManager, &ID), 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
addPass(Passes, P);
if (AnalyzeOnly) {
- if (dynamic_cast<BasicBlockPass*>(P))
+ switch (P->getPassKind()) {
+ case PT_BasicBlock:
Passes.add(new BasicBlockPassPrinter(PassInf));
- else if (dynamic_cast<LoopPass*>(P))
+ break;
+ case PT_Loop:
Passes.add(new LoopPassPrinter(PassInf));
- else if (dynamic_cast<FunctionPass*>(P))
+ break;
+ case PT_Function:
Passes.add(new FunctionPassPrinter(PassInf));
- else if (dynamic_cast<CallGraphSCCPass*>(P))
+ break;
+ case PT_CallGraphSCC:
Passes.add(new CallGraphSCCPassPrinter(PassInf));
- else
+ break;
+ default:
Passes.add(new ModulePassPrinter(PassInf));
+ break;
+ }
}
}