//===- PassManager internal APIs and implementation details -----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// /// This header provides internal APIs and implementation details used by the /// pass management interfaces exposed in PassManager.h. To understand more /// context of why these particular interfaces are needed, see that header /// file. None of these APIs should be used elsewhere. /// //===----------------------------------------------------------------------===// #ifndef LLVM_IR_PASSMANAGERINTERNAL_H #define LLVM_IR_PASSMANAGERINTERNAL_H #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/Analysis.h" #include "llvm/Support/raw_ostream.h" #include <memory> #include <utility> namespace llvm { template <typename IRUnitT> class AllAnalysesOn; template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager; class PreservedAnalyses; // Implementation details of the pass manager interfaces. namespace detail { /// Template for the abstract base class used to dispatch /// polymorphically over pass objects. template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs> struct PassConcept { … }; /// A template wrapper used to implement the polymorphic API. /// /// Can be instantiated for any object which provides a \c run method accepting /// an \c IRUnitT& and an \c AnalysisManager<IRUnit>&. It requires the pass to /// be a copyable object. template <typename IRUnitT, typename PassT, typename AnalysisManagerT, typename... ExtraArgTs> struct PassModel : PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...> { … }; /// Abstract concept of an analysis result. /// /// This concept is parameterized over the IR unit that this result pertains /// to. template <typename IRUnitT, typename InvalidatorT> struct AnalysisResultConcept { … }; /// SFINAE metafunction for computing whether \c ResultT provides an /// \c invalidate member function. template <typename IRUnitT, typename ResultT> class ResultHasInvalidateMethod { … }; /// Wrapper to model the analysis result concept. /// /// By default, this will implement the invalidate method with a trivial /// implementation so that the actual analysis result doesn't need to provide /// an invalidation handler. It is only selected when the invalidation handler /// is not part of the ResultT's interface. template <typename IRUnitT, typename PassT, typename ResultT, typename InvalidatorT, bool HasInvalidateHandler = ResultHasInvalidateMethod<IRUnitT, ResultT>::Value> struct AnalysisResultModel; /// Specialization of \c AnalysisResultModel which provides the default /// invalidate functionality. AnalysisResultModel<IRUnitT, PassT, ResultT, InvalidatorT, false>; /// Specialization of \c AnalysisResultModel which delegates invalidate /// handling to \c ResultT. AnalysisResultModel<IRUnitT, PassT, ResultT, InvalidatorT, true>; /// Abstract concept of an analysis pass. /// /// This concept is parameterized over the IR unit that it can run over and /// produce an analysis result. template <typename IRUnitT, typename InvalidatorT, typename... ExtraArgTs> struct AnalysisPassConcept { … }; /// Wrapper to model the analysis pass concept. /// /// Can wrap any type which implements a suitable \c run method. The method /// must accept an \c IRUnitT& and an \c AnalysisManager<IRUnitT>& as arguments /// and produce an object which can be wrapped in a \c AnalysisResultModel. template <typename IRUnitT, typename PassT, typename InvalidatorT, typename... ExtraArgTs> struct AnalysisPassModel : AnalysisPassConcept<IRUnitT, InvalidatorT, ExtraArgTs...> { … }; } // end namespace detail } // end namespace llvm #endif // LLVM_IR_PASSMANAGERINTERNAL_H