Teach LoopPass to assign itself one Loop Pass Manager.

llvm-svn: 34510
This commit is contained in:
Devang Patel 2007-02-23 00:36:57 +00:00
parent 9a7b18fa3d
commit 46cad14ab8
2 changed files with 45 additions and 0 deletions

View File

@ -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 {

View File

@ -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);
}