diff options
author | Devang Patel <dpatel@apple.com> | 2007-02-22 23:30:07 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-02-22 23:30:07 +0000 |
commit | de7d49053fcd4ba9bf323bd0cdf17f2ce28aa2da (patch) | |
tree | ee975f7fb3a5ff33b8ff0f2aa4565d728eec4939 /llvm/lib/Analysis/LoopPass.cpp | |
parent | cc607daac10984696aa6c4a1298e8335ef56bf9d (diff) | |
download | bcm5719-llvm-de7d49053fcd4ba9bf323bd0cdf17f2ce28aa2da.tar.gz bcm5719-llvm-de7d49053fcd4ba9bf323bd0cdf17f2ce28aa2da.zip |
Add LoopQueue. This is used by loop pass manager to manage loop nest.
llvm-svn: 34504
Diffstat (limited to 'llvm/lib/Analysis/LoopPass.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopPass.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index ee18ed57333..2e3df71c87c 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -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) { |