17#ifndef POLLY_SCOP_PASS_H
18#define POLLY_SCOP_PASS_H
21#include "llvm/ADT/PriorityWorklist.h"
22#include "llvm/Analysis/RegionPass.h"
23#include "llvm/Analysis/TargetTransformInfo.h"
24#include "llvm/IR/PassManager.h"
25#include "llvm/IR/PassManagerImpl.h"
28using llvm::AllAnalysesOn;
29using llvm::AnalysisManager;
30using llvm::DominatorTreeAnalysis;
31using llvm::InnerAnalysisManagerProxy;
32using llvm::LoopAnalysis;
33using llvm::OuterAnalysisManagerProxy;
34using llvm::PassManager;
35using llvm::RegionInfoAnalysis;
36using llvm::ScalarEvolutionAnalysis;
37using llvm::SmallPriorityWorklist;
38using llvm::TargetIRAnalysis;
39using llvm::TargetTransformInfo;
46 AnalysisManager<Scop, ScopStandardAnalysisResults &>;
48 InnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
50 OuterAnalysisManagerProxy<FunctionAnalysisManager,
Scop,
66 : InnerAM(&InnerAM), SI(&SI) {}
73 RHS.InnerAM =
nullptr;
84 bool invalidate(Function &F,
const PreservedAnalyses &PA,
85 FunctionAnalysisManager::Invalidator &Inv);
94template <
typename AnalysisT>
95struct RequireAnalysisPass<AnalysisT,
Scop, ScopAnalysisManager,
98 RequireAnalysisPass<AnalysisT,
Scop, ScopAnalysisManager,
100 PreservedAnalyses
run(
Scop &L, ScopAnalysisManager &AM,
102 (void)AM.template getResult<AnalysisT>(L, AR);
103 return PreservedAnalyses::all();
109InnerAnalysisManagerProxy<ScopAnalysisManager, Function>::run(
110 Function &F, FunctionAnalysisManager &FAM);
117extern template class PassManager<
Scop, ScopAnalysisManager,
119extern template class InnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
120extern template class OuterAnalysisManagerProxy<FunctionAnalysisManager,
Scop,
126template <
typename AnalysisManagerT,
typename IRUnitT,
typename... ExtraArgTs>
128 :
public InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT> {
131 : InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT>(
InnerAM) {}
132 using Result =
typename InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT,
134 Result run(IRUnitT &IR, AnalysisManager<IRUnitT, ExtraArgTs...> &AM,
148 Function &F, FunctionAnalysisManager &FAM);
165 explicit ScopPass(
char &ID) : RegionPass(ID),
S(nullptr) {}
181 bool runOnRegion(Region *R, RGPassManager &RGM)
override;
182 void print(raw_ostream &OS,
const Module *)
const override;
207 SAM.clear(
S,
S.getName());
218template <
typename ScopPassT>
220 : PassInfoMixin<FunctionToScopPassAdaptor<ScopPassT>> {
223 PreservedAnalyses
run(Function &F, FunctionAnalysisManager &AM) {
231 PreservedAnalyses PA = PreservedAnalyses::all();
234 AM.invalidate(F, PA);
235 return PreservedAnalyses::all();
238 SmallPriorityWorklist<Region *, 4> Worklist;
241 Worklist.insert(
S.first);
245 AM.getResult<ScalarEvolutionAnalysis>(F),
246 AM.getResult<LoopAnalysis>(F),
247 AM.getResult<RegionInfoAnalysis>(F),
248 AM.getResult<TargetIRAnalysis>(F)};
255 while (!Worklist.empty()) {
256 Region *R = Worklist.pop_back_val();
262 Updater.CurrentScop =
scop;
263 Updater.InvalidateCurrentScop =
false;
264 PreservedAnalyses PassPA =
Pass.run(*
scop, SAM, AR, Updater);
266 SAM.invalidate(*
scop, PassPA);
267 if (Updater.invalidateCurrentScop())
278 return PreservedAnalyses::none();
285template <
typename ScopPassT>
polly dump Polly Dump Function
polly scop functions based on how much of the function is a scop
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
ScopAnalysisManager * InnerAM
Result & operator=(Result &&RHS)
ScopAnalysisManager & getManager()
Result(ScopAnalysisManager &InnerAM, ScopInfo &SI)
typename InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Result Result
Result run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs...)
OwningInnerAnalysisManagerProxy()
AnalysisManagerT & getManager()
ScopAnalysisManager & SAM
void invalidateScop(Scop &S)
bool InvalidateCurrentScop
bool invalidateCurrentScop() const
SPMUpdater(SmallPriorityWorklist< Region *, 4 > &Worklist, ScopAnalysisManager &SAM)
SmallPriorityWorklist< Region *, 4 > & Worklist
Pass to detect the maximal static control parts (Scops) of a function.
bool isMaxRegionInScop(const Region &R, bool Verify=true)
Is the region is the maximum region of a Scop?
ScopPass - This class adapts the RegionPass interface to allow convenient creation of passes that ope...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void print(raw_ostream &OS, const Module *) const override
bool runOnRegion(Region *R, RGPassManager &RGM) override
virtual bool runOnScop(Scop &S)=0
runOnScop - This method must be overloaded to perform the desired Polyhedral transformation or analys...
virtual void printScop(raw_ostream &OS, Scop &S) const
Print method for SCoPs.
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
InnerAnalysisManagerProxy< ScopAnalysisManager, Function > ScopAnalysisManagerFunctionProxy
FunctionToScopPassAdaptor< ScopPassT > createFunctionToScopPassAdaptor(ScopPassT Pass)
PassManager< Scop, ScopAnalysisManager, ScopStandardAnalysisResults &, SPMUpdater & > ScopPassManager
AnalysisManager< Scop, ScopStandardAnalysisResults & > ScopAnalysisManager
OuterAnalysisManagerProxy< FunctionAnalysisManager, Scop, ScopStandardAnalysisResults & > FunctionAnalysisManagerScopProxy
PreservedAnalyses run(Scop &L, ScopAnalysisManager &AM, ScopStandardAnalysisResults &AR, SPMUpdater &)
FunctionToScopPassAdaptor(ScopPassT Pass)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
TargetTransformInfo & TTI