1 //===- llvm/Analysis/LoopDepth.h - Loop Depth Calculation --------*- C++ -*--=//
3 // This file provides a simple class to calculate the loop depth of a
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_ANALYSIS_LOOP_DEPTH_H
9 #define LLVM_ANALYSIS_LOOP_DEPTH_H
11 #include "llvm/Pass.h"
15 class LoopDepthCalculator : public MethodPass {
16 std::map<const BasicBlock*, unsigned> LoopDepth;
17 void calculate(Method *M, LoopInfo &Loops);
19 static AnalysisID ID; // cfg::LoopDepth Analysis ID
21 LoopDepthCalculator(AnalysisID id) { assert(id == ID); }
24 bool runOnMethod(Method *M);
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;
31 // getAnalysisUsageInfo - Provide loop depth, require loop info
33 virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
34 Pass::AnalysisSet &Destroyed,
35 Pass::AnalysisSet &Provided);
38 } // end namespace cfg