Maintain level(or depth) of pass manager in pass manager food chain.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32339 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2006-12-07 23:24:58 +00:00
parent c17bbb6da7
commit f72d29c540

View File

@ -209,7 +209,7 @@ class PMDataManager {
public: public:
PMDataManager() : TPM(NULL) { PMDataManager(int D) : TPM(NULL), Depth(D) {
initializeAnalysisInfo(); initializeAnalysisInfo();
} }
@ -275,6 +275,8 @@ public:
PMTopLevelManager *getTopLevelManager() { return TPM; } PMTopLevelManager *getTopLevelManager() { return TPM; }
void setTopLevelManager(PMTopLevelManager *T) { TPM = T; } void setTopLevelManager(PMTopLevelManager *T) { TPM = T; }
unsigned getDepth() { return Depth; }
private: private:
// Set of available Analysis. This information is used while scheduling // Set of available Analysis. This information is used while scheduling
// pass. If a pass requires an analysis which is not not available then // pass. If a pass requires an analysis which is not not available then
@ -288,6 +290,8 @@ private:
// Top level manager. // Top level manager.
// TODO : Make it a reference. // TODO : Make it a reference.
PMTopLevelManager *TPM; PMTopLevelManager *TPM;
unsigned Depth;
}; };
/// BasicBlockPassManager_New manages BasicBlockPass. It batches all the /// BasicBlockPassManager_New manages BasicBlockPass. It batches all the
@ -297,7 +301,7 @@ class BasicBlockPassManager_New : public PMDataManager,
public FunctionPass { public FunctionPass {
public: public:
BasicBlockPassManager_New() { } BasicBlockPassManager_New(int D) : PMDataManager(D) { }
/// Add a pass into a passmanager queue. /// Add a pass into a passmanager queue.
bool addPass(Pass *p); bool addPass(Pass *p);
@ -326,8 +330,9 @@ class FunctionPassManagerImpl_New : public ModulePass,
public PMDataManager, public PMDataManager,
public PMTopLevelManager { public PMTopLevelManager {
public: public:
FunctionPassManagerImpl_New(ModuleProvider *P) { /* TODO */ } FunctionPassManagerImpl_New(ModuleProvider *P, int D) :
FunctionPassManagerImpl_New() { PMDataManager(D) { /* TODO */ }
FunctionPassManagerImpl_New(int D) : PMDataManager(D) {
activeBBPassManager = NULL; activeBBPassManager = NULL;
} }
~FunctionPassManagerImpl_New() { /* TODO */ }; ~FunctionPassManagerImpl_New() { /* TODO */ };
@ -382,7 +387,9 @@ private:
class ModulePassManager_New : public PMDataManager { class ModulePassManager_New : public PMDataManager {
public: public:
ModulePassManager_New() { activeFunctionPassManager = NULL; } ModulePassManager_New(int D) : PMDataManager(D) {
activeFunctionPassManager = NULL;
}
/// Add a pass into a passmanager queue. /// Add a pass into a passmanager queue.
bool addPass(Pass *p); bool addPass(Pass *p);
@ -412,6 +419,8 @@ class PassManagerImpl_New : public Pass,
public: public:
PassManagerImpl_New(int D) : PMDataManager(D) {}
/// add - Add a pass to the queue of passes to run. This passes ownership of /// 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 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
/// will be destroyed as well, so there is no need to delete the pass. This /// will be destroyed as well, so there is no need to delete the pass. This
@ -615,7 +624,7 @@ Pass * BasicBlockPassManager_New::getAnalysisPassFromManager(AnalysisID AID) {
/// Create new Function pass manager /// Create new Function pass manager
FunctionPassManager_New::FunctionPassManager_New() { FunctionPassManager_New::FunctionPassManager_New() {
FPM = new FunctionPassManagerImpl_New(); FPM = new FunctionPassManagerImpl_New(0);
} }
/// add - Add a pass to the queue of passes to run. This passes /// add - Add a pass to the queue of passes to run. This passes
@ -679,7 +688,8 @@ FunctionPassManagerImpl_New::addPass(Pass *P) {
activeBBPassManager->initializeAnalysisInfo(); activeBBPassManager->initializeAnalysisInfo();
// Create and add new manager // Create and add new manager
activeBBPassManager = new BasicBlockPassManager_New(); activeBBPassManager =
new BasicBlockPassManager_New(getDepth() + 1);
addPassToManager(activeBBPassManager, false); addPassToManager(activeBBPassManager, false);
// Add pass into new manager. This time it must succeed. // Add pass into new manager. This time it must succeed.
@ -818,7 +828,8 @@ ModulePassManager_New::addPass(Pass *P) {
activeFunctionPassManager->initializeAnalysisInfo(); activeFunctionPassManager->initializeAnalysisInfo();
// Create and add new manager // Create and add new manager
activeFunctionPassManager = new FunctionPassManagerImpl_New(); activeFunctionPassManager =
new FunctionPassManagerImpl_New(getDepth() + 1);
addPassToManager(activeFunctionPassManager, false); addPassToManager(activeFunctionPassManager, false);
// Add pass into new manager. This time it must succeed. // Add pass into new manager. This time it must succeed.
@ -905,7 +916,7 @@ Pass *PassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) {
bool PassManagerImpl_New::addPass(Pass *P) { bool PassManagerImpl_New::addPass(Pass *P) {
if (!activeManager || !activeManager->addPass(P)) { if (!activeManager || !activeManager->addPass(P)) {
activeManager = new ModulePassManager_New(); activeManager = new ModulePassManager_New(getDepth() + 1);
PassManagers.push_back(activeManager); PassManagers.push_back(activeManager);
return activeManager->addPass(P); return activeManager->addPass(P);
} }
@ -930,7 +941,7 @@ bool PassManagerImpl_New::run(Module &M) {
/// Create new pass manager /// Create new pass manager
PassManager_New::PassManager_New() { PassManager_New::PassManager_New() {
PM = new PassManagerImpl_New(); PM = new PassManagerImpl_New(0);
} }
/// add - Add a pass to the queue of passes to run. This passes ownership of /// add - Add a pass to the queue of passes to run. This passes ownership of