Switch register allocator over to using LoopInfo directly instead of indirectly throu...
[oota-llvm.git] / lib / Analysis / LoopDepth.cpp
1 //===- LoopDepth.cpp - Loop Depth Calculation --------------------*- C++ -*--=//
2 //
3 // This file provides a simple class to calculate the loop depth of a 
4 // BasicBlock.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #include "llvm/Analysis/LoopDepth.h"
9 #include "llvm/Analysis/LoopInfo.h"
10 #include "llvm/Method.h"
11 #include <algorithm>
12
13 AnalysisID cfg::LoopDepthCalculator::ID(AnalysisID::create<cfg::LoopDepthCalculator>());
14
15 bool cfg::LoopDepthCalculator::runOnMethod(Method *M) {
16   calculate(M, getAnalysis<LoopInfo>());
17   return false;
18 }
19
20 void cfg::LoopDepthCalculator::calculate(Method *M, LoopInfo &Loops) {
21   for (Method::iterator I = M->begin(), E = M->end(); I != E; ++I)
22     LoopDepth[*I] = Loops.getLoopDepth(*I);
23 }
24
25 // getAnalysisUsageInfo - Provide loop depth, require loop info
26 //
27 void cfg::LoopDepthCalculator::getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
28                                                   Pass::AnalysisSet &Destroyed,
29                                                   Pass::AnalysisSet &Provided) {
30   Provided.push_back(ID);
31   Requires.push_back(LoopInfo::ID);
32 }
33