89068d6bb791521d137a96a8d2b53d91aee54a50
[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 <map>
12 class BasicBlock;
13 class Method;
14 namespace cfg {class Interval; }
15
16 class LoopDepthCalculator {
17   std::map<const BasicBlock*, unsigned> LoopDepth;
18   inline void AddBB(const BasicBlock *BB);    // Increment count for this block
19   inline void ProcessInterval(cfg::Interval *I);
20 public:
21   LoopDepthCalculator(Method *M);
22
23   inline unsigned getLoopDepth(const BasicBlock *BB) const { 
24     std::map<const BasicBlock*,unsigned>::const_iterator I = LoopDepth.find(BB);
25     return I != LoopDepth.end() ? I->second : 0;
26   }
27 };
28
29 #endif