00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef LLVM_ANALYSIS_LOOPS_IN_REGION_ANALYSIS_H
00016 #define LLVM_ANALYSIS_LOOPS_IN_REGION_ANALYSIS_H
00017
00018 #include "llvm/Analysis/LoopInfo.h"
00019 #include "llvm/Analysis/RegionInfo.h"
00020 #include "llvm/Analysis/RegionIterator.h"
00021
00022 #include "llvm/Analysis/RegionPass.h"
00023
00024
00025 #include <map>
00026
00027 namespace llvm {
00028
00029 class LoopsInRegionAnalysis : public FunctionPass {
00030
00031 std::multimap<Region*, Loop*> RMap;
00032
00033 public:
00034 static char ID;
00035 explicit LoopsInRegionAnalysis() : FunctionPass(&ID){}
00036
00037 virtual void releaseMemory() {
00038 RMap.clear();
00039 }
00040
00042 typedef std::multimap<Region*, Loop*>::iterator iterator;
00043 typedef std::multimap<Region*, Loop*>::const_iterator const_iterator;
00044
00045 iterator begin(Region* R) { return RMap.lower_bound(R); }
00046 iterator end(Region* R) { return RMap.upper_bound(R); }
00047
00048 const_iterator begin(Region* R) const { return RMap.lower_bound(R); }
00049 const_iterator end(Region* R) const { return RMap.upper_bound(R); }
00050
00052 virtual bool runOnFunction(Function &F) {
00053 LoopInfo &LI = getAnalysis<LoopInfo>();
00054
00055 for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I)
00056 runOnLoop(*I);
00057
00058 return false;
00059 }
00060
00061 void runOnLoop(Loop *L);
00062
00063 virtual const char *getPassName() const {
00064 return "'LoopsInRegionAnalysisPass' Printer";
00065 }
00066
00067 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
00068
00069 AU.addRequired<LoopInfo>();
00070 AU.addRequired<RegionInfo>();
00071
00072 AU.setPreservesAll();
00073 }
00074
00075 void verifyMap(Loop *L, Region *R) const;
00076
00077 virtual void print(raw_ostream &OS, const Module *) const {
00078 for (std::multimap<Region*, Loop*>::const_iterator I = RMap.begin(),
00079 E = RMap.end(); I != E; ++I)
00080 OS << I->first->getName() << " -> "
00081 << I->second->getHeader()->getName() << "\n";
00082
00083 OS << "End\n";
00084 }
00085
00086 virtual void verifyAnalysis() const {
00087 for (std::multimap<Region*, Loop*>::const_iterator I = RMap.begin(),
00088 E = RMap.end(); I != E; ++I)
00089 verifyMap(I->second, I->first);
00090 }
00091 };
00092
00093
00094
00095
00096
00097 FunctionPass* createLIRAnalysisPass();
00098
00099
00105
00106 struct PollyFilter : RegionPass {
00107 static char ID;
00108
00109 explicit PollyFilter() : RegionPass(&ID) {}
00110
00111 virtual bool runOnRegion(Region *R, RGPassManager &RGM);
00112
00113 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
00114 AU.addRequired<LoopsInRegionAnalysis>();
00115 AU.setPreservesCFG();
00116 }
00117
00118 };
00119
00120
00121
00122 }
00123
00124 #endif