17#ifndef LLVM_IR_PASSMANAGERINTERNAL_H
18#define LLVM_IR_PASSMANAGERINTERNAL_H
31template <
typename IRUnitT,
typename... ExtraArgTs>
class AnalysisManager;
39template <
typename IRUnitT,
typename AnalysisManagerT,
typename... ExtraArgTs>
56 ExtraArgTs... ExtraArgs) = 0;
78template <
typename IRUnitT,
typename PassT,
typename AnalysisManagerT,
79 typename... ExtraArgTs>
84 ExtraArgTs... ExtraArgs)
override {
85 return Pass.run(
IR, AM, ExtraArgs...);
91 Pass.printPipeline(OS, MapClassName2PassName);
96 bool isRequired()
const override {
return PassT::isRequired(); }
105template <
typename IRUnitT,
typename Inval
idatorT>
125 InvalidatorT &Inv) = 0;
131 using EnabledType =
char;
132 struct DisabledType {
139 template <
typename T>
struct Nonce {
using Type = EnabledType; };
140 template <
typename T>
141 static typename Nonce<decltype(std::declval<T>().invalidate(
142 std::declval<IRUnitT &>(), std::declval<PreservedAnalyses>()))>
::Type
149 template <
typename T,
typename U>
static DisabledType NonceFunction(
T U::*);
150 struct CheckerBase {
int invalidate; };
151 template <
typename T>
struct Checker : CheckerBase, std::remove_cv_t<T> {};
152 template <
typename T>
153 static decltype(NonceFunction(&Checker<T>::invalidate)) check(
rank<1>);
157 template <
typename T>
158 static EnabledType check(
rank<0>);
161 enum {
Value =
sizeof(check<ResultT>(
rank<2>())) ==
sizeof(EnabledType) };
170template <
typename IRUnitT,
typename PassT,
typename ResultT,
171 typename InvalidatorT,
172 bool HasInvalidateHandler =
178template <
typename IRUnitT,
typename PassT,
typename ResultT,
179 typename InvalidatorT>
205 InvalidatorT &)
override {
206 auto PAC = PA.template getChecker<PassT>();
207 return !PAC.preserved() &&
208 !PAC.template preservedSet<AllAnalysesOn<IRUnitT>>();
216template <
typename IRUnitT,
typename PassT,
typename ResultT,
217 typename InvalidatorT>
239 InvalidatorT &Inv)
override {
240 return Result.invalidate(
IR, PA, Inv);
250template <
typename IRUnitT,
typename InvalidatorT,
typename... ExtraArgTs>
257 virtual std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
259 ExtraArgTs... ExtraArgs) = 0;
270template <
typename IRUnitT,
typename PassT,
typename InvalidatorT,
271 typename... ExtraArgTs>
297 std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
299 ExtraArgTs... ExtraArgs)
override {
300 return std::make_unique<ResultModelT>(
301 Pass.run(
IR, AM, std::forward<ExtraArgTs>(ExtraArgs)...));
Legalize the Machine IR a function s Machine IR
This templated class represents "all analyses that operate over <aparticular IR unit>" (e....
A container for analyses that lazily runs them and caches their results.
A set of analyses that are preserved following a run of a transformation pass.
Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
SFINAE metafunction for computing whether ResultT provides an invalidate member function.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Pass manager infrastructure for declaring and invalidating analyses.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Abstract concept of an analysis pass.
virtual StringRef name() const =0
Polymorphic method to access the name of a pass.
virtual std::unique_ptr< AnalysisResultConcept< IRUnitT, InvalidatorT > > run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs... ExtraArgs)=0
Method to run this analysis over a unit of IR.
virtual ~AnalysisPassConcept()=default
AnalysisPassModel(const AnalysisPassModel &Arg)
StringRef name() const override
The model delegates to a static PassT::name method.
AnalysisPassModel(PassT Pass)
AnalysisResultModel< IRUnitT, PassT, typename PassT::Result, InvalidatorT > ResultModelT
std::unique_ptr< AnalysisResultConcept< IRUnitT, InvalidatorT > > run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs... ExtraArgs) override
The model delegates to the PassT::run method.
friend void swap(AnalysisPassModel &LHS, AnalysisPassModel &RHS)
AnalysisPassModel & operator=(AnalysisPassModel RHS)
AnalysisPassModel(AnalysisPassModel &&Arg)
Abstract concept of an analysis result.
virtual ~AnalysisResultConcept()=default
virtual bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA, InvalidatorT &Inv)=0
Method to try and mark a result as invalid.
AnalysisResultModel & operator=(AnalysisResultModel RHS)
AnalysisResultModel(const AnalysisResultModel &Arg)
AnalysisResultModel(ResultT Result)
bool invalidate(IRUnitT &, const PreservedAnalyses &PA, InvalidatorT &) override
The model bases invalidation solely on being in the preserved set.
AnalysisResultModel(AnalysisResultModel &&Arg)
friend void swap(AnalysisResultModel &LHS, AnalysisResultModel &RHS)
AnalysisResultModel(ResultT Result)
AnalysisResultModel & operator=(AnalysisResultModel RHS)
AnalysisResultModel(AnalysisResultModel &&Arg)
AnalysisResultModel(const AnalysisResultModel &Arg)
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA, InvalidatorT &Inv) override
The model delegates to the ResultT method.
friend void swap(AnalysisResultModel &LHS, AnalysisResultModel &RHS)
Wrapper to model the analysis result concept.
PassConcept(const PassConcept &)=delete
virtual StringRef name() const =0
Polymorphic method to access the name of a pass.
PassConcept & operator=(const PassConcept &)=delete
virtual void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)=0
virtual bool isRequired() const =0
Polymorphic method to let a pass optionally exempted from skipping by PassInstrumentation.
virtual PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs)=0
The polymorphic API which runs the pass over a given IR entity.
virtual ~PassConcept()=default
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName) override
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs) override
The polymorphic API which runs the pass over a given IR entity.
bool isRequired() const override
Polymorphic method to let a pass optionally exempted from skipping by PassInstrumentation.
StringRef name() const override
Polymorphic method to access the name of a pass.
Utility type to build an inheritance chain that makes it easy to rank overload candidates.