mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Add ModulePassManager_New.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31517 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4d0c1a04bc
commit
92c45eebf7
@ -143,6 +143,29 @@ private:
|
|||||||
BasicBlockPassManager_New *activeBBPassManager;
|
BasicBlockPassManager_New *activeBBPassManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// FunctionPassManager_New manages FunctionPasses.
|
||||||
|
/// It batches all Module passes passes and function pass managers together and
|
||||||
|
/// sequence them to process one module.
|
||||||
|
class ModulePassManager_New: public Pass {
|
||||||
|
|
||||||
|
public:
|
||||||
|
ModulePassManager_New() { activeFunctionPassManager = NULL; }
|
||||||
|
|
||||||
|
/// Add a pass into a passmanager queue.
|
||||||
|
bool addPass(Pass *p);
|
||||||
|
|
||||||
|
/// run - Execute all of the passes scheduled for execution. Keep track of
|
||||||
|
/// whether any of the passes modifies the module, and if so, return true.
|
||||||
|
bool runOnModule(Module &M);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Collection of pass that are not yet scheduled
|
||||||
|
std::vector<Pass *> PassVector;
|
||||||
|
|
||||||
|
// Active Pass Manager
|
||||||
|
FunctionPassManager_New *activeFunctionPassManager;
|
||||||
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -85,7 +85,7 @@ FunctionPassManager_New::addPass (Pass *P) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO: Check if it suitable to manage P using this FunctionPassManager
|
// TODO: Check if it suitable to manage P using this FunctionPassManager
|
||||||
// or we need another instance of BasicBlockPassManager
|
// or we need another instance of FunctionPassManager
|
||||||
|
|
||||||
PassVector.push_back(FP);
|
PassVector.push_back(FP);
|
||||||
activeBBPassManager = NULL;
|
activeBBPassManager = NULL;
|
||||||
@ -110,3 +110,56 @@ FunctionPassManager_New::runOnModule(Module &M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ModulePassManager implementation
|
||||||
|
|
||||||
|
/// Add P into pass vector if it is manageble. If P is a FunctionPass
|
||||||
|
/// then use FunctionPassManager_New to manage it. Return FALSE if P
|
||||||
|
/// is not manageable by this manager.
|
||||||
|
bool
|
||||||
|
ModulePassManager_New::addPass (Pass *P) {
|
||||||
|
|
||||||
|
// If P is FunctionPass then use function pass maanager.
|
||||||
|
if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P)) {
|
||||||
|
|
||||||
|
activeFunctionPassManager = NULL;
|
||||||
|
|
||||||
|
if (!activeFunctionPassManager
|
||||||
|
|| !activeFunctionPassManager->addPass(P)) {
|
||||||
|
|
||||||
|
activeFunctionPassManager = new FunctionPassManager_New();
|
||||||
|
|
||||||
|
PassVector.push_back(activeFunctionPassManager);
|
||||||
|
assert (!activeFunctionPassManager->addPass(FP) &&
|
||||||
|
"Unable to add Pass");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModulePass *MP = dynamic_cast<ModulePass *>(P);
|
||||||
|
if (!MP)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// TODO: Check if it suitable to manage P using this ModulePassManager
|
||||||
|
// or we need another instance of ModulePassManager
|
||||||
|
|
||||||
|
PassVector.push_back(MP);
|
||||||
|
activeFunctionPassManager = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Execute all of the passes scheduled for execution by invoking
|
||||||
|
/// runOnModule method. Keep track of whether any of the passes modifies
|
||||||
|
/// the module, and if so, return true.
|
||||||
|
bool
|
||||||
|
ModulePassManager_New::runOnModule(Module &M) {
|
||||||
|
bool Changed = false;
|
||||||
|
for (std::vector<Pass *>::iterator itr = PassVector.begin(),
|
||||||
|
e = PassVector.end(); itr != e; ++itr) {
|
||||||
|
Pass *P = *itr;
|
||||||
|
ModulePass *MP = dynamic_cast<ModulePass*>(P);
|
||||||
|
Changed |= MP->runOnModule(M);
|
||||||
|
}
|
||||||
|
return Changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user