17#ifndef LLVM_IR_PASSMANAGERINTERNAL_H
18#define LLVM_IR_PASSMANAGERINTERNAL_H
29template <
typename IRUnitT>
class AllAnalysesOn;
30template <
typename IRUnitT,
typename... ExtraArgTs>
class AnalysisManager;
31class PreservedAnalyses;
38template <
typename IRUnitT,
typename AnalysisManagerT,
typename... ExtraArgTs>
49 ExtraArgTs... ExtraArgs) = 0;
69template <
typename IRUnitT,
typename PassT,
typename AnalysisManagerT,
70 typename... ExtraArgTs>
89 ExtraArgTs... ExtraArgs)
override {
90 return Pass.run(
IR, AM, ExtraArgs...);
96 Pass.printPipeline(
OS, MapClassName2PassName);
101 template <
typename T>
104 template <
typename T>
105 static std::enable_if_t<is_detected<has_required_t, T>::value,
bool>
107 return T::isRequired();
109 template <
typename T>
110 static std::enable_if_t<!is_detected<has_required_t, T>::value,
bool>
115 bool isRequired()
const override {
return passIsRequiredImpl<PassT>(); }
124template <
typename IRUnitT,
typename Inval
idatorT>
144 InvalidatorT &Inv) = 0;
151 struct DisabledType {
159 template <
typename T>
160 static typename Nonce<decltype(std::declval<T>().invalidate(
161 std::declval<IRUnitT &>(), std::declval<PreservedAnalyses>()))>::Type
168 template <
typename T,
typename U>
static DisabledType NonceFunction(
T U::*);
169 struct CheckerBase {
int invalidate; };
170 template <
typename T>
struct Checker : CheckerBase,
T {};
171 template <
typename T>
172 static decltype(NonceFunction(&Checker<T>::invalidate)) check(
rank<1>);
176 template <
typename T>
189template <
typename IRUnitT,
typename PassT,
typename ResultT,
190 typename InvalidatorT,
191 bool HasInvalidateHandler =
197template <
typename IRUnitT,
typename PassT,
typename ResultT,
198 typename InvalidatorT>
206 : Result(
std::
move(Arg.Result)) {}
210 swap(
LHS.Result,
RHS.Result);
224 InvalidatorT &)
override {
225 auto PAC = PA.template getChecker<PassT>();
226 return !PAC.preserved() &&
227 !PAC.template preservedSet<AllAnalysesOn<IRUnitT>>();
235template <
typename IRUnitT,
typename PassT,
typename ResultT,
236 typename InvalidatorT>
244 : Result(
std::
move(Arg.Result)) {}
248 swap(
LHS.Result,
RHS.Result);
258 InvalidatorT &Inv)
override {
259 return Result.invalidate(
IR, PA, Inv);
269template <
typename IRUnitT,
typename InvalidatorT,
typename... ExtraArgTs>
276 virtual std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
278 ExtraArgTs... ExtraArgs) = 0;
289template <
typename IRUnitT,
typename PassT,
typename InvalidatorT,
290 typename... ExtraArgTs>
316 std::unique_ptr<AnalysisResultConcept<IRUnitT, InvalidatorT>>
318 ExtraArgTs... ExtraArgs)
override {
319 return std::make_unique<ResultModelT>(
320 Pass.run(
IR, AM, std::forward<ExtraArgTs>(ExtraArgs)...));
Legalize the Machine IR a function s Machine IR
A container for analyses that lazily runs them and caches their results.
Pass interface - Implemented by all 'passes'.
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.
LLVM Value Representation.
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.
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
Wrapper to model the analysis pass concept.
AnalysisPassModel(const AnalysisPassModel &Arg)
StringRef name() const override
The model delegates to a static PassT::name method.
AnalysisPassModel(PassT Pass)
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
A template wrapper used to implement the polymorphic API.
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
static std::enable_if_t<!is_detected< has_required_t, T >::value, bool > passIsRequiredImpl()
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)
static std::enable_if_t< is_detected< has_required_t, T >::value, bool > passIsRequiredImpl()
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.