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>
50 ExtraArgTs... ExtraArgs) = 0;
72template <
typename IRUnitT,
typename PassT,
typename AnalysisManagerT,
73 typename... ExtraArgTs>
92 ExtraArgTs... ExtraArgs)
override {
93 return Pass.run(
IR, AM, ExtraArgs...);
99 Pass.printPipeline(OS, MapClassName2PassName);
104 bool isRequired()
const override {
return PassT::isRequired(); }
113template <
typename IRUnitT,
typename Inval
idatorT>
133 InvalidatorT &Inv) = 0;
139 using EnabledType =
char;
140 struct DisabledType {
147 template <
typename T>
struct Nonce {
using Type = EnabledType; };
148 template <
typename T>
149 static typename Nonce<decltype(std::declval<T>().invalidate(
150 std::declval<IRUnitT &>(), std::declval<PreservedAnalyses>()))>
::Type
157 template <
typename T,
typename U>
static DisabledType NonceFunction(
T U::*);
158 struct CheckerBase {
int invalidate; };
159 template <
typename T>
struct Checker : CheckerBase, std::remove_cv_t<T> {};
160 template <
typename T>
161 static decltype(NonceFunction(&Checker<T>::invalidate)) check(
rank<1>);
165 template <
typename T>
166 static EnabledType check(
rank<0>);
169 enum {
Value =
sizeof(check<ResultT>(
rank<2>())) ==
sizeof(EnabledType) };
178template <
typename IRUnitT,
typename PassT,
typename ResultT,
179 typename InvalidatorT,
180 bool HasInvalidateHandler =
186template <
typename IRUnitT,
typename PassT,
typename ResultT,
187 typename InvalidatorT>
213 InvalidatorT &)
override {
214 auto PAC = PA.template getChecker<PassT>();
215 return !PAC.preserved() &&
216 !PAC.template preservedSet<AllAnalysesOn<IRUnitT>>();
224template <
typename IRUnitT,
typename PassT,
typename ResultT,
225 typename InvalidatorT>
247 InvalidatorT &Inv)
override {
248 return Result.invalidate(
IR, PA, Inv);
258template <
typename IRUnitT,
typename InvalidatorT,
typename... ExtraArgTs>
265 virtual std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
267 ExtraArgTs... ExtraArgs) = 0;
278template <
typename IRUnitT,
typename PassT,
typename InvalidatorT,
279 typename... ExtraArgTs>
305 std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
307 ExtraArgTs... ExtraArgs)
override {
308 return std::make_unique<ResultModelT>(
309 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.
Template for the abstract base class used to dispatch polymorphically over pass objects.
virtual StringRef name() const =0
Polymorphic method to access the name of a pass.
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
friend void swap(PassModel &LHS, PassModel &RHS)
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.
PassModel & operator=(PassModel RHS)
bool isRequired() const override
Polymorphic method to let a pass optionally exempted from skipping by PassInstrumentation.
PassModel(const PassModel &Arg)
PassModel(PassModel &&Arg)
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.