@@ -45,6 +45,32 @@ static bool runCodePreprationImpl(Function &F, DominatorTree *DT, LoopInfo *LI,
4545 return true ;
4646}
4747
48+ namespace {
49+
50+ // / Prepare the IR for the scop detection.
51+ // /
52+ class CodePreparation final : public FunctionPass {
53+ CodePreparation (const CodePreparation &) = delete ;
54+ const CodePreparation &operator =(const CodePreparation &) = delete ;
55+
56+ void clear ();
57+
58+ public:
59+ static char ID;
60+
61+ explicit CodePreparation () : FunctionPass(ID) {}
62+ ~CodePreparation ();
63+
64+ // / @name FunctionPass interface.
65+ // @{
66+ void getAnalysisUsage (AnalysisUsage &AU) const override ;
67+ void releaseMemory () override ;
68+ bool runOnFunction (Function &F) override ;
69+ void print (raw_ostream &OS, const Module *) const override ;
70+ // @}
71+ };
72+ } // namespace
73+
4874PreservedAnalyses CodePreparationPass::run (Function &F,
4975 FunctionAnalysisManager &FAM) {
5076 auto &DT = FAM.getResult <DominatorTreeAnalysis>(F);
@@ -59,7 +85,43 @@ PreservedAnalyses CodePreparationPass::run(Function &F,
5985 return PA;
6086}
6187
62- bool polly::runCodePreparation (Function &F, DominatorTree *DT, LoopInfo *LI,
63- RegionInfo *RI) {
64- return runCodePreprationImpl (F, DT, LI, RI);
88+ void CodePreparation::clear () {}
89+
90+ CodePreparation::~CodePreparation () { clear (); }
91+
92+ void CodePreparation::getAnalysisUsage (AnalysisUsage &AU) const {
93+ AU.addRequired <LoopInfoWrapperPass>();
94+
95+ AU.addPreserved <LoopInfoWrapperPass>();
96+ AU.addPreserved <RegionInfoPass>();
97+ AU.addPreserved <DominatorTreeWrapperPass>();
98+ AU.addPreserved <DominanceFrontierWrapperPass>();
6599}
100+
101+ bool CodePreparation::runOnFunction (Function &F) {
102+ if (skipFunction (F))
103+ return false ;
104+
105+ DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree ();
106+ LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo ();
107+ RegionInfo *RI = &getAnalysis<RegionInfoPass>().getRegionInfo ();
108+
109+ runCodePreprationImpl (F, DT, LI, RI);
110+
111+ return true ;
112+ }
113+
114+ void CodePreparation::releaseMemory () { clear (); }
115+
116+ void CodePreparation::print (raw_ostream &OS, const Module *) const {}
117+
118+ char CodePreparation::ID = 0 ;
119+ char &polly::CodePreparationID = CodePreparation::ID;
120+
121+ Pass *polly::createCodePreparationPass () { return new CodePreparation (); }
122+
123+ INITIALIZE_PASS_BEGIN (CodePreparation, " polly-prepare" ,
124+ " Polly - Prepare code for polly" , false , false )
125+ INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
126+ INITIALIZE_PASS_END(CodePreparation, " polly-prepare" ,
127+ " Polly - Prepare code for polly" , false , false )
0 commit comments