aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Analysis/LoopDepth.h
blob: 89068d6bb791521d137a96a8d2b53d91aee54a50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//===- llvm/Analysis/LoopDepth.h - Loop Depth Calculation --------*- C++ -*--=//
//
// This file provides a simple class to calculate the loop depth of a 
// BasicBlock.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ANALYSIS_LOOP_DEPTH_H
#define LLVM_ANALYSIS_LOOP_DEPTH_H

#include <map>
class BasicBlock;
class Method;
namespace cfg {class Interval; }

class LoopDepthCalculator {
  std::map<const BasicBlock*, unsigned> LoopDepth;
  inline void AddBB(const BasicBlock *BB);    // Increment count for this block
  inline void ProcessInterval(cfg::Interval *I);
public:
  LoopDepthCalculator(Method *M);

  inline unsigned getLoopDepth(const BasicBlock *BB) const { 
    std::map<const BasicBlock*,unsigned>::const_iterator I = LoopDepth.find(BB);
    return I != LoopDepth.end() ? I->second : 0;
  }
};

#endif