1 //===- LoopDepth.cpp - Loop Depth Calculation --------------------*- C++ -*--=//
3 // This file provides a simple class to calculate the loop depth of a
6 //===----------------------------------------------------------------------===//
8 #include "llvm/Analysis/LoopDepth.h"
9 #include "llvm/Analysis/LoopInfo.h"
10 #include "llvm/Method.h"
13 AnalysisID cfg::LoopDepthCalculator::ID(AnalysisID::create<cfg::LoopDepthCalculator>());
15 bool cfg::LoopDepthCalculator::runOnMethod(Method *M) {
16 calculate(M, getAnalysis<LoopInfo>());
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);
25 // getAnalysisUsageInfo - Provide loop depth, require loop info
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);