llvm-6502/lib/Analysis/LoopDepth.cpp
Chris Lattner 0f0fc3253d Implement loop depth calculation in terms of dominators instead of intervals
No problems with irreducibility now


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1602 91177308-0d34-0410-b5e6-96231b3b80d8
2002-01-31 00:42:06 +00:00

46 lines
1.4 KiB
C++

//===- LoopDepth.cpp - Loop Depth Calculation --------------------*- C++ -*--=//
//
// This file provides a simple class to calculate the loop depth of a
// BasicBlock.
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/LoopDepth.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Method.h"
#include <algorithm>
AnalysisID cfg::LoopDepthCalculator::ID(AnalysisID::create<cfg::LoopDepthCalculator>());
bool cfg::LoopDepthCalculator::runOnMethod(Method *M) {
calculate(M, getAnalysis<LoopInfo>());
return false;
}
void cfg::LoopDepthCalculator::calculate(Method *M, LoopInfo &Loops) {
for (Method::iterator I = M->begin(), E = M->end(); I != E; ++I)
LoopDepth[*I] = Loops.getLoopDepth(*I);
}
// getAnalysisUsageInfo - Provide loop depth, require loop info
//
void cfg::LoopDepthCalculator::getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
Pass::AnalysisSet &Destroyed,
Pass::AnalysisSet &Provided) {
Provided.push_back(ID);
Requires.push_back(LoopInfo::ID);
}
#if 1 /// FIXME, REMOVE EVENTUALLY
#include "llvm/PassManager.h"
cfg::LoopDepthCalculator::LoopDepthCalculator(Method *M) {
PassManagerT<Method> PassMgr;
LoopInfo *LI = new LoopInfo(LoopInfo::ID);
PassMgr.add(LI);
PassMgr.run(M);
calculate(M, *LI);
}
#endif