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;
70template <
typename IRUnitT,
typename PassT,
typename AnalysisManagerT,
71 typename... ExtraArgTs>
90 ExtraArgTs... ExtraArgs)
override {
91 return Pass.run(
IR, AM, ExtraArgs...);
97 Pass.printPipeline(OS, MapClassName2PassName);
102 template <
typename T>
107 return T::isRequired();
120template <
typename IRUnitT,
typename Inval
idatorT>
140 InvalidatorT &Inv) = 0;
146 using EnabledType =
char;
147 struct DisabledType {
154 template <
typename T>
struct Nonce {
using Type = EnabledType; };
155 template <
typename T>
156 static typename Nonce<decltype(std::declval<T>().invalidate(
157 std::declval<IRUnitT &>(), std::declval<PreservedAnalyses>()))>
::Type
164 template <
typename T,
typename U>
static DisabledType NonceFunction(
T U::*);
165 struct CheckerBase {
int invalidate; };
166 template <
typename T>
struct Checker : CheckerBase, std::remove_cv_t<T> {};
167 template <
typename T>
168 static decltype(NonceFunction(&Checker<T>::invalidate)) check(
rank<1>);
172 template <
typename T>
173 static EnabledType check(
rank<0>);
176 enum {
Value =
sizeof(check<ResultT>(
rank<2>())) ==
sizeof(EnabledType) };
185template <
typename IRUnitT,
typename PassT,
typename ResultT,
186 typename InvalidatorT,
187 bool HasInvalidateHandler =
193template <
typename IRUnitT,
typename PassT,
typename ResultT,
194 typename InvalidatorT>
220 InvalidatorT &)
override {
221 auto PAC = PA.template getChecker<PassT>();
222 return !PAC.preserved() &&
223 !PAC.template preservedSet<AllAnalysesOn<IRUnitT>>();
231template <
typename IRUnitT,
typename PassT,
typename ResultT,
232 typename InvalidatorT>
254 InvalidatorT &Inv)
override {
255 return Result.invalidate(
IR, PA, Inv);
265template <
typename IRUnitT,
typename InvalidatorT,
typename... ExtraArgTs>
272 virtual std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
274 ExtraArgTs... ExtraArgs) = 0;
285template <
typename IRUnitT,
typename PassT,
typename InvalidatorT,
286 typename... ExtraArgTs>
312 std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
314 ExtraArgTs... ExtraArgs)
override {
315 return std::make_unique<ResultModelT>(
316 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.
StringRef - 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.
These are wrappers over isa* function that allow them to be used in generic algorithms such as llvm:a...
This is an optimization pass for GlobalISel generic memory operations.
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
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)
decltype(std::declval< T & >().isRequired()) has_required_t
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)
static bool passIsRequiredImpl()
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.