namespace llvm {
+/// FunctionPassManager and PassManager, two top level managers, serve
+/// as the public interface of pass manager infrastructure.
+enum TopLevelManagerType {
+ TLM_Function, // FunctionPassManager
+ TLM_Pass // PassManager
+};
+
//===----------------------------------------------------------------------===//
// PMTopLevelManager
//
/// then return NULL.
Pass *findAnalysisPass(AnalysisID AID);
+ PMTopLevelManager(enum TopLevelManagerType t);
virtual ~PMTopLevelManager();
/// Add immutable pass and initialize it.
public PMTopLevelManager {
public:
- FunctionPassManagerImpl(int Depth) : PMDataManager(Depth) { }
+ FunctionPassManagerImpl(int Depth) : PMDataManager(Depth),
+ PMTopLevelManager(TLM_Function) { }
/// 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
addImmutablePass(IP);
recordAvailableAnalysis(IP);
} else {
- // Assign manager
- if (activeStack.empty()) {
- FPPassManager *FPP = new FPPassManager(getDepth() + 1);
- FPP->setTopLevelManager(this->getTopLevelManager());
- addPassManager(FPP);
- activeStack.push(FPP);
- }
P->assignPassManager(activeStack);
}
public:
- PassManagerImpl(int Depth) : PMDataManager(Depth) { }
+ PassManagerImpl(int Depth) : 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
addImmutablePass(IP);
recordAvailableAnalysis(IP);
} else {
-
- // Assign manager
- if (activeStack.empty()) {
- MPPassManager *MPP = new MPPassManager(getDepth() + 1);
- MPP->setTopLevelManager(this->getTopLevelManager());
- addPassManager(MPP);
- activeStack.push(MPP);
- }
-
P->assignPassManager(activeStack);
}
//===----------------------------------------------------------------------===//
// PMTopLevelManager implementation
+/// Initialize top level manager. Create first pass manager.
+PMTopLevelManager::PMTopLevelManager (enum TopLevelManagerType t) {
+
+ if (t == TLM_Pass) {
+ MPPassManager *MPP = new MPPassManager(1);
+ MPP->setTopLevelManager(this);
+ addPassManager(MPP);
+ activeStack.push(MPP);
+ }
+ else if (t == TLM_Function) {
+ FPPassManager *FPP = new FPPassManager(1);
+ FPP->setTopLevelManager(this);
+ addPassManager(FPP);
+ activeStack.push(FPP);
+ }
+}
+
/// Set pass P as the last user of the given analysis passes.
void PMTopLevelManager::setLastUser(std::vector<Pass *> &AnalysisPasses,
Pass *P) {