summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-02-23 00:36:57 +0000
committerDevang Patel <dpatel@apple.com>2007-02-23 00:36:57 +0000
commitbfd59055842311a0358f667177c736252d59a7c9 (patch)
treee5223a17f02f46e6652e82b3b2422506de916fcf
parent8ded5852fe0dd317d9903809b49060248003d365 (diff)
downloadllvm-bfd59055842311a0358f667177c736252d59a7c9.tar.gz
llvm-bfd59055842311a0358f667177c736252d59a7c9.tar.bz2
llvm-bfd59055842311a0358f667177c736252d59a7c9.tar.xz
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
-rw-r--r--include/llvm/Analysis/LoopPass.h4
-rw-r--r--lib/Analysis/LoopPass.cpp41
2 files changed, 45 insertions, 0 deletions
diff --git a/include/llvm/Analysis/LoopPass.h b/include/llvm/Analysis/LoopPass.h
index b3d4c6e897..2fd14f2dad 100644
--- a/include/llvm/Analysis/LoopPass.h
+++ b/include/llvm/Analysis/LoopPass.h
@@ -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 {
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);
+}
+