Switch register allocator over to using LoopInfo directly instead of indirectly throu...
[oota-llvm.git] / include / llvm / Analysis / LoopDepth.h
1 //===- llvm/Analysis/LoopDepth.h - 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 #ifndef LLVM_ANALYSIS_LOOP_DEPTH_H
9 #define LLVM_ANALYSIS_LOOP_DEPTH_H
10
11 #include "llvm/Pass.h"
12 namespace cfg {
13   class LoopInfo;
14
15 class LoopDepthCalculator : public MethodPass {
16   std::map<const BasicBlock*, unsigned> LoopDepth;
17   void calculate(Method *M, LoopInfo &Loops);
18 public:
19   static AnalysisID ID;            // cfg::LoopDepth Analysis ID 
20
21   LoopDepthCalculator(AnalysisID id) { assert(id == ID); }
22
23   // This is a pass...
24   bool runOnMethod(Method *M);
25
26   inline unsigned getLoopDepth(const BasicBlock *BB) const { 
27     std::map<const BasicBlock*,unsigned>::const_iterator I = LoopDepth.find(BB);
28     return I != LoopDepth.end() ? I->second : 0;
29   }
30
31   // getAnalysisUsageInfo - Provide loop depth, require loop info
32   //
33   virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
34                                     Pass::AnalysisSet &Destroyed,
35                                     Pass::AnalysisSet &Provided);
36 };
37
38 }  // end namespace cfg
39
40 #endif