17#ifndef LLVM_IR_PASSMANAGERINTERNAL_H
18#define LLVM_IR_PASSMANAGERINTERNAL_H
28template <
typename IRUnitT>
class AllAnalysesOn;
29template <
typename IRUnitT,
typename... ExtraArgTs>
class AnalysisManager;
30class PreservedAnalyses;
37template <
typename IRUnitT,
typename AnalysisManagerT,
typename... ExtraArgTs>
48 ExtraArgTs... ExtraArgs) = 0;
68template <
typename IRUnitT,
typename PassT,
typename PreservedAnalysesT,
69 typename AnalysisManagerT,
typename... ExtraArgTs>
87 PreservedAnalysesT
run(IRUnitT &
IR, AnalysisManagerT &AM,
88 ExtraArgTs... ExtraArgs)
override {
89 return Pass.run(
IR, AM, ExtraArgs...);
95 Pass.printPipeline(
OS, MapClassName2PassName);
100 template <
typename T>
103 template <
typename T>
104 static std::enable_if_t<is_detected<has_required_t, T>::value,
bool>
106 return T::isRequired();
108 template <
typename T>
109 static std::enable_if_t<!is_detected<has_required_t, T>::value,
bool>
114 bool isRequired()
const override {
return passIsRequiredImpl<PassT>(); }
123template <
typename IRUnitT,
typename PreservedAnalysesT,
typename Inval
idatorT>
143 InvalidatorT &Inv) = 0;
150 struct DisabledType {
158 template <
typename T>
159 static typename Nonce<decltype(std::declval<T>().invalidate(
160 std::declval<IRUnitT &>(), std::declval<PreservedAnalyses>()))>::Type
167 template <
typename T,
typename U>
static DisabledType NonceFunction(
T U::*);
168 struct CheckerBase {
int invalidate; };
169 template <
typename T>
struct Checker : CheckerBase,
T {};
170 template <
typename T>
171 static decltype(NonceFunction(&Checker<T>::invalidate)) check(
rank<1>);
175 template <
typename T>
188template <
typename IRUnitT,
typename PassT,
typename ResultT,
189 typename PreservedAnalysesT,
typename InvalidatorT,
190 bool HasInvalidateHandler =
196template <
typename IRUnitT,
typename PassT,
typename ResultT,
197 typename PreservedAnalysesT,
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 PreservedAnalysesT,
typename InvalidatorT>
245 : Result(
std::
move(Arg.Result)) {}
249 swap(
LHS.Result,
RHS.Result);
259 InvalidatorT &Inv)
override {
260 return Result.invalidate(
IR, PA, Inv);
270template <
typename IRUnitT,
typename PreservedAnalysesT,
typename InvalidatorT,
271 typename... ExtraArgTs>
278 virtual std::unique_ptr<
281 ExtraArgTs... ExtraArgs) = 0;
292template <
typename IRUnitT,
typename PassT,
typename PreservedAnalysesT,
293 typename InvalidatorT,
typename... ExtraArgTs>
295 InvalidatorT, ExtraArgTs...> {
315 PreservedAnalysesT, InvalidatorT>;
323 ExtraArgTs... ExtraArgs)
override {
324 return std::make_unique<ResultModelT>(
325 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.
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 ~AnalysisPassConcept()=default
virtual std::unique_ptr< AnalysisResultConcept< IRUnitT, PreservedAnalysesT, InvalidatorT > > run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs... ExtraArgs)=0
Method to run this analysis over a unit of IR.
Wrapper to model the analysis pass concept.
AnalysisPassModel(const AnalysisPassModel &Arg)
AnalysisPassModel(PassT Pass)
std::unique_ptr< AnalysisResultConcept< IRUnitT, PreservedAnalysesT, InvalidatorT > > run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs... ExtraArgs) override
The model delegates to the PassT::run method.
StringRef name() const override
The model delegates to a static PassT::name method.
AnalysisPassModel(AnalysisPassModel &&Arg)
AnalysisPassModel & operator=(AnalysisPassModel RHS)
friend void swap(AnalysisPassModel &LHS, AnalysisPassModel &RHS)
Abstract concept of an analysis result.
virtual ~AnalysisResultConcept()=default
virtual bool invalidate(IRUnitT &IR, const PreservedAnalysesT &PA, InvalidatorT &Inv)=0
Method to try and mark a result as invalid.
bool invalidate(IRUnitT &IR, const PreservedAnalysesT &PA, InvalidatorT &Inv) override
The model delegates to the ResultT method.
AnalysisResultModel(AnalysisResultModel &&Arg)
AnalysisResultModel(const AnalysisResultModel &Arg)
AnalysisResultModel(ResultT Result)
AnalysisResultModel & operator=(AnalysisResultModel RHS)
friend void swap(AnalysisResultModel &LHS, AnalysisResultModel &RHS)
bool invalidate(IRUnitT &, const PreservedAnalysesT &PA, InvalidatorT &) override
The model bases invalidation solely on being in the preserved set.
AnalysisResultModel(ResultT Result)
AnalysisResultModel(AnalysisResultModel &&Arg)
AnalysisResultModel(const AnalysisResultModel &Arg)
AnalysisResultModel & operator=(AnalysisResultModel RHS)
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
PassModel(const PassModel &Arg)
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()
PassModel & operator=(PassModel RHS)
PassModel(PassModel &&Arg)
PreservedAnalysesT run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs) override
The polymorphic API which runs the pass over a given IR entity.
StringRef name() const override
Polymorphic method to access the name of a pass.
bool isRequired() const override
Polymorphic method to let a pass optionally exempted from skipping by PassInstrumentation.
static std::enable_if_t< is_detected< has_required_t, T >::value, bool > passIsRequiredImpl()
Utility type to build an inheritance chain that makes it easy to rank overload candidates.