mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-30 15:45:26 +00:00
Teach LoopPass to assign itself one Loop Pass Manager.
llvm-svn: 34510
This commit is contained in:
parent
9a7b18fa3d
commit
46cad14ab8
@ -37,6 +37,10 @@ class LoopPass : public Pass {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Assign pass manager to manager this pass
|
||||
virtual void assignPassManager(PMStack &PMS,
|
||||
PassManagerType PMT = PMT_LoopPassManager);
|
||||
|
||||
};
|
||||
|
||||
class LPPassManager : public FunctionPass, public PMDataManager {
|
||||
|
@ -143,3 +143,44 @@ bool LPPassManager::runOnFunction(Function &F) {
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// LoopPass
|
||||
|
||||
/// Assign pass manager to manage this pass.
|
||||
void LoopPass::assignPassManager(PMStack &PMS,
|
||||
PassManagerType PreferredType) {
|
||||
// Find LPPassManager
|
||||
while (!PMS.empty()) {
|
||||
if (PMS.top()->getPassManagerType() > PMT_LoopPassManager)
|
||||
PMS.pop();
|
||||
else;
|
||||
break;
|
||||
}
|
||||
|
||||
LPPassManager *LPPM = dynamic_cast<LPPassManager *>(PMS.top());
|
||||
|
||||
// Create new Loop Pass Manager if it does not exist.
|
||||
if (!LPPM) {
|
||||
|
||||
assert (!PMS.empty() && "Unable to create Loop Pass Manager");
|
||||
PMDataManager *PMD = PMS.top();
|
||||
|
||||
// [1] Create new Call Graph Pass Manager
|
||||
LPPM = new LPPassManager(PMD->getDepth() + 1);
|
||||
|
||||
// [2] Set up new manager's top level manager
|
||||
PMTopLevelManager *TPM = PMD->getTopLevelManager();
|
||||
TPM->addIndirectPassManager(LPPM);
|
||||
|
||||
// [3] Assign manager to manage this new manager. This may create
|
||||
// and push new managers into PMS
|
||||
Pass *P = dynamic_cast<Pass *>(LPPM);
|
||||
P->assignPassManager(PMS);
|
||||
|
||||
// [4] Push new manager into PMS
|
||||
PMS.push(LPPM);
|
||||
}
|
||||
|
||||
LPPM->add(this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user