2001-06-25 03:54:14 +00:00
|
|
|
//===- 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
|
|
|
|
|
2002-01-31 00:41:01 +00:00
|
|
|
#include "llvm/Pass.h"
|
|
|
|
namespace cfg {
|
|
|
|
class LoopInfo;
|
2001-06-25 03:54:14 +00:00
|
|
|
|
2002-01-31 00:41:01 +00:00
|
|
|
class LoopDepthCalculator : public MethodPass {
|
2002-01-20 22:54:45 +00:00
|
|
|
std::map<const BasicBlock*, unsigned> LoopDepth;
|
2002-01-31 00:41:01 +00:00
|
|
|
void calculate(Method *M, LoopInfo &Loops);
|
2001-06-25 03:54:14 +00:00
|
|
|
public:
|
2002-01-31 00:41:01 +00:00
|
|
|
static AnalysisID ID; // cfg::LoopDepth Analysis ID
|
|
|
|
|
|
|
|
LoopDepthCalculator(AnalysisID id) { assert(id == ID); }
|
2001-06-25 03:54:14 +00:00
|
|
|
LoopDepthCalculator(Method *M);
|
|
|
|
|
2002-01-31 00:41:01 +00:00
|
|
|
// This is a pass...
|
|
|
|
bool runOnMethod(Method *M);
|
|
|
|
|
2001-06-25 03:54:14 +00:00
|
|
|
inline unsigned getLoopDepth(const BasicBlock *BB) const {
|
2002-01-20 22:54:45 +00:00
|
|
|
std::map<const BasicBlock*,unsigned>::const_iterator I = LoopDepth.find(BB);
|
2001-06-25 03:54:14 +00:00
|
|
|
return I != LoopDepth.end() ? I->second : 0;
|
|
|
|
}
|
2002-01-31 00:41:01 +00:00
|
|
|
|
|
|
|
// getAnalysisUsageInfo - Provide loop depth, require loop info
|
|
|
|
//
|
|
|
|
virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
|
|
|
|
Pass::AnalysisSet &Destroyed,
|
|
|
|
Pass::AnalysisSet &Provided);
|
2001-06-25 03:54:14 +00:00
|
|
|
};
|
|
|
|
|
2002-01-31 00:41:01 +00:00
|
|
|
} // end namespace cfg
|
|
|
|
|
2001-06-25 03:54:14 +00:00
|
|
|
#endif
|