mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Add LoopQueue. This is used by loop pass manager to manage loop nest.
llvm-svn: 34504
This commit is contained in:
parent
68e7fe47f6
commit
b170ebf833
@ -25,6 +25,7 @@ namespace llvm {
|
||||
class LPPassManager;
|
||||
class Loop;
|
||||
class Function;
|
||||
class LoopQueue;
|
||||
|
||||
class LoopPass : public Pass {
|
||||
|
||||
@ -41,7 +42,8 @@ class LoopPass : public Pass {
|
||||
class LPPassManager : public FunctionPass, public PMDataManager {
|
||||
|
||||
public:
|
||||
LPPassManager(int Depth) : PMDataManager(Depth) { }
|
||||
LPPassManager(int Depth);
|
||||
~LPPassManager();
|
||||
|
||||
/// run - Execute all of the passes scheduled for execution. Keep track of
|
||||
/// whether any of the passes modifies the module, and if so, return true.
|
||||
@ -79,6 +81,9 @@ public:
|
||||
return PMT_LoopPassManager;
|
||||
}
|
||||
|
||||
private:
|
||||
LoopQueue *LQ;
|
||||
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user