[llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp

Devang Patel dpatel at apple.com
Thu Feb 22 15:30:23 PST 2007



Changes in directory llvm/lib/Analysis:

LoopPass.cpp updated: 1.1 -> 1.2
---
Log message:

Add LoopQueue. This is used by loop pass manager to manage loop nest.


---
Diffs of the changes:  (+36 -0)

 LoopPass.cpp |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+)


Index: llvm/lib/Analysis/LoopPass.cpp
diff -u llvm/lib/Analysis/LoopPass.cpp:1.1 llvm/lib/Analysis/LoopPass.cpp:1.2
--- llvm/lib/Analysis/LoopPass.cpp:1.1	Thu Feb 22 02:56:17 2007
+++ llvm/lib/Analysis/LoopPass.cpp	Thu Feb 22 17:30:07 2007
@@ -14,13 +14,49 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/LoopPass.h"
+#include <queue>
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
+// LoopQueue
+
+namespace llvm {
+
+// Compare Two loops based on their depth in loop nest.
+class LoopCompare {
+public:
+  bool operator()( Loop *L1, Loop *L2) const {
+    return L1->getLoopDepth() > L2->getLoopDepth();
+  }
+};
+
+// Loop queue used by Loop Pass Manager. This is a wrapper class
+// that hides implemenation detail (use of priority_queue) inside .cpp file.
+class LoopQueue {
+
+  inline void push(Loop *L) { LPQ.push(L); }
+  inline void pop() { LPQ.pop(); }
+  inline Loop *top() { return LPQ.top(); }
+
+private:
+  std::priority_queue<Loop *, std::vector<Loop *>, LoopCompare> LPQ;
+};
+
+} // End of LLVM namespace
+
+//===----------------------------------------------------------------------===//
 // LPPassManager
 //
 /// LPPassManager manages FPPassManagers and CalLGraphSCCPasses.
 
+LPPassManager::LPPassManager(int Depth) : PMDataManager(Depth) { 
+  LQ = new LoopQueue(); 
+}
+
+LPPassManager::~LPPassManager() {
+  delete LQ;
+}
+
 /// run - Execute all of the passes scheduled for execution.  Keep track of
 /// whether any of the passes modifies the function, and if so, return true.
 bool LPPassManager::runOnFunction(Function &F) {






More information about the llvm-commits mailing list