18 #ifndef LLVM_IR_PASSMANAGERINTERNAL_H
19 #define LLVM_IR_PASSMANAGERINTERNAL_H
26 template <
typename IRUnitT>
class AnalysisManager;
27 class PreservedAnalyses;
51 template <
typename IRUnitT,
typename PassT,
typename ResultT>
53 typedef char SmallType;
58 template <
typename T, ResultT (T::*)(IRUnitT &, AnalysisManager<IRUnitT> *)>
61 template <
typename T>
static SmallType f(Checker<T, &T::run> *);
62 template <
typename T>
static BigType f(...);
65 enum {
Value =
sizeof(f<PassT>(
nullptr)) ==
sizeof(SmallType) };
74 template <
typename IRUnitT,
typename PassT,
77 IRUnitT, PassT, PreservedAnalysesT>
::Value>
82 template <
typename IRUnitT,
typename PassT,
typename PreservedAnalysesT>
92 swap(LHS.Pass, RHS.Pass);
100 return Pass.run(IR, AM);
108 template <
typename IRUnitT,
typename PassT,
typename PreservedAnalysesT>
118 swap(LHS.Pass, RHS.Pass);
155 typedef char SmallType;
160 template <
typename T,
bool (T::*)(IRUnitT &, const PreservedAnalyses &)>
163 template <
typename T>
static SmallType f(Checker<T, &T::invalidate> *);
164 template <
typename T>
static BigType f(...);
167 enum {
Value =
sizeof(f<ResultT>(
nullptr)) ==
sizeof(SmallType) };
176 template <
typename IRUnitT,
typename PassT,
typename ResultT,
178 bool HasInvalidateHandler =
184 template <
typename IRUnitT,
typename PassT,
typename ResultT,
185 typename PreservedAnalysesT>
193 : Result(std::move(Arg.Result)) {}
196 swap(LHS.Result, RHS.Result);
208 bool invalidate(IRUnitT &,
const PreservedAnalysesT &PA)
override {
217 template <
typename IRUnitT,
typename PassT,
typename ResultT,
218 typename PreservedAnalysesT>
226 : Result(std::move(Arg.Result)) {}
229 swap(LHS.Result, RHS.Result);
238 return Result.invalidate(IR, PA);
254 virtual std::unique_ptr<AnalysisResultConcept<IRUnitT>>
266 template <
typename IRUnitT,
typename PassT,
267 bool AcceptsAnalysisManager = PassRunAcceptsAnalysisManager<
268 IRUnitT, PassT,
typename PassT::Result>
::Value>
273 template <
typename IRUnitT,
typename PassT>
282 swap(LHS.Pass, RHS.Pass);
296 std::unique_ptr<AnalysisResultConcept<IRUnitT>>
298 return make_unique<ResultModelT>(
Pass.run(IR, AM));
311 template <
typename IRUnitT,
typename PassT>
320 swap(LHS.Pass, RHS.Pass);
334 std::unique_ptr<AnalysisResultConcept<IRUnitT>>
336 return make_unique<ResultModelT>(
Pass.run(IR));
Pass interface - Implemented by all 'passes'.
Wrapper to model the analysis pass concept.
friend void swap(AnalysisResultModel &LHS, AnalysisResultModel &RHS)
PassModel & operator=(PassModel RHS)
virtual StringRef name()=0
Polymorphic method to access the name of a pass.
AnalysisPassModel(const AnalysisPassModel &Arg)
AnalysisResultModel< IRUnitT, PassT, typename PassT::Result > ResultModelT
Template for the abstract base class used to dispatch polymorphically over pass objects.
SFINAE metafunction for computing whether ResultT provides an invalidate member function.
AnalysisPassModel & operator=(AnalysisPassModel RHS)
Abstract concept of an analysis pass.
PassModel(PassModel &&Arg)
friend void swap(AnalysisPassModel &LHS, AnalysisPassModel &RHS)
SFINAE metafunction for computing whether PassT has a run method accepting an AnalysisManager<IRUnitT...
AnalysisResultModel(AnalysisResultModel &&Arg)
virtual PreservedAnalyses run(IRUnitT &IR, AnalysisManager< IRUnitT > *AM)=0
The polymorphic API which runs the pass over a given IR entity.
PassModel(PassModel &&Arg)
bool invalidate(IRUnitT &, const PreservedAnalysesT &PA) override
The model bases invalidation solely on being in the preserved set.
AnalysisResultModel(const AnalysisResultModel &Arg)
friend void swap(PassModel &LHS, PassModel &RHS)
std::unique_ptr< AnalysisResultConcept< IRUnitT > > run(IRUnitT &IR, AnalysisManager< IRUnitT > *) override
The model delegates to the PassT::run method.
friend void swap(PassModel &LHS, PassModel &RHS)
friend void swap(AnalysisPassModel &LHS, AnalysisPassModel &RHS)
AnalysisResultModel(ResultT Result)
An abstract set of preserved analyses following a transformation pass run.
AnalysisResultModel(ResultT Result)
Wrapper to model the analysis result concept.
AnalysisPassModel & operator=(AnalysisPassModel RHS)
bool invalidate(IRUnitT &IR, const PreservedAnalysesT &PA) override
The model delegates to the ResultT method.
PreservedAnalysesT run(IRUnitT &IR, AnalysisManager< IRUnitT > *AM) override
The polymorphic API which runs the pass over a given IR entity.
AnalysisPassModel(PassT Pass)
A template wrapper used to implement the polymorphic API.
virtual ~AnalysisResultConcept()
std::unique_ptr< AnalysisResultConcept< IRUnitT > > run(IRUnitT &IR, AnalysisManager< IRUnitT > *AM) override
The model delegates to the PassT::run method.
Abstract concept of an analysis result.
StringRef name() override
The model delegates to a static PassT::name method.
AnalysisPassModel(const AnalysisPassModel &Arg)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
AnalysisResultModel(const AnalysisResultModel &Arg)
AnalysisPassModel(AnalysisPassModel &&Arg)
StringRef name() override
The model delegates to a static PassT::name method.
AnalysisResultModel< IRUnitT, PassT, typename PassT::Result > ResultModelT
StringRef name() override
Polymorphic method to access the name of a pass.
AnalysisResultModel & operator=(AnalysisResultModel RHS)
AnalysisPassModel(AnalysisPassModel &&Arg)
PassModel(const PassModel &Arg)
virtual ~AnalysisPassConcept()
AnalysisResultModel(AnalysisResultModel &&Arg)
PassModel(const PassModel &Arg)
LLVM Value Representation.
AnalysisResultModel & operator=(AnalysisResultModel RHS)
StringRef - Represent a constant reference to a string, i.e.
A generic analysis pass manager with lazy running and caching of results.
PassModel & operator=(PassModel RHS)
friend void swap(AnalysisResultModel &LHS, AnalysisResultModel &RHS)
PreservedAnalysesT run(IRUnitT &IR, AnalysisManager< IRUnitT > *AM) override
The polymorphic API which runs the pass over a given IR entity.
Statically lint checks LLVM IR
AnalysisPassModel(PassT Pass)
StringRef name() override
Polymorphic method to access the name of a pass.