diff options
author | Devang Patel <dpatel@apple.com> | 2007-02-23 00:36:57 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-02-23 00:36:57 +0000 |
commit | bfd59055842311a0358f667177c736252d59a7c9 (patch) | |
tree | e5223a17f02f46e6652e82b3b2422506de916fcf /lib/Analysis/LoopPass.cpp | |
parent | 8ded5852fe0dd317d9903809b49060248003d365 (diff) |
Teach LoopPass to assign itself one Loop Pass Manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34510 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopPass.cpp')
-rw-r--r-- | lib/Analysis/LoopPass.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp index dc5c5683fb..425e46e6e0 100644 --- a/lib/Analysis/LoopPass.cpp +++ b/lib/Analysis/LoopPass.cpp @@ -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); +} + |