MLIR
20.0.0git
|
The abstract base pass class. More...
#include "mlir/Pass/Pass.h"
Classes | |
struct | ListOption |
This class represents a specific pass option that contains a list of values of the provided data type. More... | |
struct | Option |
This class represents a specific pass option, with a provided data type. More... | |
class | Statistic |
This class represents a single pass statistic. More... | |
Public Member Functions | |
virtual | ~Pass ()=default |
TypeID | getTypeID () const |
Returns the unique identifier that corresponds to this pass. More... | |
const PassInfo * | lookupPassInfo () const |
Returns the pass info for this pass, or null if unknown. More... | |
virtual StringRef | getName () const =0 |
Returns the derived pass name. More... | |
virtual void | getDependentDialects (DialectRegistry ®istry) const |
Register dependent dialects for the current pass. More... | |
virtual StringRef | getArgument () const |
Return the command line argument used when registering this pass. More... | |
virtual StringRef | getDescription () const |
Return the command line description used when registering this pass. More... | |
std::optional< StringRef > | getOpName () const |
Returns the name of the operation that this pass operates on, or std::nullopt if this is a generic OperationPass. More... | |
virtual LogicalResult | initializeOptions (StringRef options, function_ref< LogicalResult(const Twine &)> errorHandler) |
Attempt to initialize the options of this pass from the given string. More... | |
void | printAsTextualPipeline (raw_ostream &os) |
Prints out the pass in the textual representation of pipelines. More... | |
ArrayRef< Statistic * > | getStatistics () const |
Returns the main statistics for this pass instance. More... | |
MutableArrayRef< Statistic * > | getStatistics () |
const Pass * | getThreadingSibling () const |
Returns the thread sibling of this pass. More... | |
const Pass * | getThreadingSiblingOrThis () const |
Returns the thread sibling of this pass, or the pass itself it has no sibling. More... | |
Protected Member Functions | |
Pass (TypeID passID, std::optional< StringRef > opName=std::nullopt) | |
Pass (const Pass &other) | |
Pass & | operator= (const Pass &)=delete |
Pass (Pass &&)=delete | |
Pass & | operator= (Pass &&)=delete |
detail::PassExecutionState & | getPassState () |
Returns the current pass state. More... | |
MLIRContext & | getContext () |
Return the MLIR context for the current operation being transformed. More... | |
virtual void | runOnOperation ()=0 |
The polymorphic API that runs the pass over the currently held operation. More... | |
virtual LogicalResult | initialize (MLIRContext *context) |
Initialize any complex state necessary for running this pass. More... | |
virtual bool | canScheduleOn (RegisteredOperationName opName) const =0 |
Indicate if the current pass can be scheduled on the given operation type. More... | |
LogicalResult | runPipeline (OpPassManager &pipeline, Operation *op) |
Schedule an arbitrary pass pipeline on the provided operation. More... | |
std::unique_ptr< Pass > | clone () const |
A clone method to create a copy of this pass. More... | |
Operation * | getOperation () |
Return the current operation being transformed. More... | |
void | signalPassFailure () |
Signal that some invariant was broken when running. More... | |
template<typename AnalysisT > | |
AnalysisT & | getAnalysis () |
Query an analysis for the current ir unit. More... | |
template<typename AnalysisT , typename OpT > | |
AnalysisT & | getAnalysis () |
Query an analysis for the current ir unit of a specific derived operation type. More... | |
template<typename AnalysisT > | |
std::optional< std::reference_wrapper< AnalysisT > > | getCachedAnalysis () |
Query a cached instance of an analysis for the current ir unit if one exists. More... | |
void | markAllAnalysesPreserved () |
Mark all analyses as preserved. More... | |
template<typename... AnalysesT> | |
void | markAnalysesPreserved () |
Mark the provided analyses as preserved. More... | |
void | markAnalysesPreserved (TypeID id) |
template<typename AnalysisT > | |
std::optional< std::reference_wrapper< AnalysisT > > | getCachedParentAnalysis (Operation *parent) |
Returns the analysis for the given parent operation if it exists. More... | |
template<typename AnalysisT > | |
std::optional< std::reference_wrapper< AnalysisT > > | getCachedParentAnalysis () |
Returns the analysis for the parent operation if it exists. More... | |
template<typename AnalysisT > | |
std::optional< std::reference_wrapper< AnalysisT > > | getCachedChildAnalysis (Operation *child) |
Returns the analysis for the given child operation if it exists. More... | |
template<typename AnalysisT > | |
AnalysisT & | getChildAnalysis (Operation *child) |
Returns the analysis for the given child operation, or creates it if it doesn't exist. More... | |
template<typename AnalysisT , typename OpTy > | |
AnalysisT & | getChildAnalysis (OpTy child) |
Returns the analysis for the given child operation of specific derived operation type, or creates it if it doesn't exist. More... | |
AnalysisManager | getAnalysisManager () |
Returns the current analysis manager. More... | |
virtual std::unique_ptr< Pass > | clonePass () const =0 |
Create a copy of this pass, ignoring statistics and options. More... | |
void | copyOptionValuesFrom (const Pass *other) |
Copy the option values from 'other', which is another instance of this pass. More... | |
Friends | |
class | OpPassManager |
Allow access to 'clone'. More... | |
class | PassInfo |
Allow access to 'passOptions'. More... | |
The abstract base pass class.
This class contains information describing the derived pass object, e.g its kind and abstract TypeID.
|
virtualdefault |
|
inlineexplicitprotected |
|
protecteddelete |
|
protectedpure virtual |
Indicate if the current pass can be scheduled on the given operation type.
This is useful for generic operation passes to add restrictions on the operations they operate on.
Implemented in mlir::ExternalPass, mlir::OperationPass< void >, mlir::InterfacePass< InterfaceT >, and mlir::OperationPass< OpT >.
|
inlineprotected |
A clone method to create a copy of this pass.
Definition at line 204 of file Pass.h.
References clonePass().
|
protectedpure virtual |
Create a copy of this pass, ignoring statistics and options.
Implemented in mlir::ExternalPass, and mlir::PassWrapper< OpToOpPassAdaptor, OperationPass<> >.
Referenced by clone().
|
protected |
Copy the option values from 'other', which is another instance of this pass.
Definition at line 76 of file Pass.cpp.
References mlir::detail::PassOptions::copyOptionValuesFrom().
|
inlineprotected |
Query an analysis for the current ir unit.
Definition at line 221 of file Pass.h.
References mlir::AnalysisManager::getAnalysis(), and getAnalysisManager().
|
inlineprotected |
Query an analysis for the current ir unit of a specific derived operation type.
Definition at line 228 of file Pass.h.
References mlir::AnalysisManager::getAnalysis(), and getAnalysisManager().
|
inlineprotected |
Returns the current analysis manager.
Definition at line 289 of file Pass.h.
References mlir::detail::PassExecutionState::analysisManager, and getPassState().
Referenced by getAnalysis(), getCachedAnalysis(), getCachedChildAnalysis(), getCachedParentAnalysis(), and getChildAnalysis().
|
inlinevirtual |
Return the command line argument used when registering this pass.
Return an empty string if one does not exist.
Reimplemented in mlir::ExternalPass.
Definition at line 75 of file Pass.h.
Referenced by lookupPassInfo(), and printAsTextualPipeline().
|
inlineprotected |
Query a cached instance of an analysis for the current ir unit if one exists.
Definition at line 235 of file Pass.h.
References getAnalysisManager(), and mlir::AnalysisManager::getCachedAnalysis().
|
inlineprotected |
Returns the analysis for the given child operation if it exists.
Definition at line 270 of file Pass.h.
References getAnalysisManager(), and mlir::AnalysisManager::getCachedChildAnalysis().
|
inlineprotected |
Returns the analysis for the parent operation if it exists.
Definition at line 262 of file Pass.h.
References getAnalysisManager(), mlir::AnalysisManager::getCachedParentAnalysis(), getOperation(), and mlir::Operation::getParentOp().
|
inlineprotected |
Returns the analysis for the given parent operation if it exists.
Definition at line 256 of file Pass.h.
References getAnalysisManager(), and mlir::AnalysisManager::getCachedParentAnalysis().
|
inlineprotected |
Returns the analysis for the given child operation, or creates it if it doesn't exist.
Definition at line 277 of file Pass.h.
References getAnalysisManager(), and mlir::AnalysisManager::getChildAnalysis().
|
inlineprotected |
Returns the analysis for the given child operation of specific derived operation type, or creates it if it doesn't exist.
Definition at line 284 of file Pass.h.
References getAnalysisManager(), and mlir::AnalysisManager::getChildAnalysis().
|
inlineprotected |
Return the MLIR context for the current operation being transformed.
Definition at line 176 of file Pass.h.
References mlir::Operation::getContext(), and getOperation().
|
inlinevirtual |
Register dependent dialects for the current pass.
A pass is expected to register the dialects it will create entities for (Operations, Types, Attributes), other than dialect that exists in the input. For example, a pass that converts from Linalg to Affine would register the Affine dialect but does not need to register Linalg.
Reimplemented in mlir::ExternalPass, and mlir::detail::OpToOpPassAdaptor.
|
inlinevirtual |
Return the command line description used when registering this pass.
Return an empty string if one does not exist.
Reimplemented in mlir::ExternalPass.
|
pure virtual |
Returns the derived pass name.
Implemented in mlir::ExternalPass, and mlir::PassWrapper< OpToOpPassAdaptor, OperationPass<> >.
Referenced by mlir::PassExecutionAction::print(), and printAsTextualPipeline().
|
inlineprotected |
Return the current operation being transformed.
Definition at line 211 of file Pass.h.
References getPassState(), and mlir::detail::PassExecutionState::irAndPassFailed.
Referenced by getCachedParentAnalysis(), getContext(), mlir::OperationPass< OpT >::getOperation(), mlir::InterfacePass< InterfaceT >::getOperation(), and mlir::ExternalPass::runOnOperation().
|
inline |
Returns the name of the operation that this pass operates on, or std::nullopt if this is a generic OperationPass.
Definition at line 83 of file Pass.h.
Referenced by mlir::OperationPass< OpT >::canScheduleOn(), mlir::ExternalPass::canScheduleOn(), mlir::OperationPass< OpT >::classof(), mlir::ExternalPass::clonePass(), and mlir::detail::OpToOpPassAdaptor::tryMergeInto().
|
inlineprotected |
Returns the current pass state.
Definition at line 170 of file Pass.h.
Referenced by getAnalysisManager(), getOperation(), markAllAnalysesPreserved(), markAnalysesPreserved(), and signalPassFailure().
|
inline |
|
inline |
|
inline |
Returns the thread sibling of this pass.
If this pass was cloned by the pass manager for the sake of multi-threading, this function returns the original pass it was cloned from. This is useful for diagnostic purposes to distinguish passes that were replicated for threading purposes from passes instantiated by the user. Used to collapse passes in timing statistics.
|
inline |
Returns the thread sibling of this pass, or the pass itself it has no sibling.
See getThreadingSibling()
for details.
|
inline |
Returns the unique identifier that corresponds to this pass.
Definition at line 56 of file Pass.h.
Referenced by mlir::PassWrapper< PassT, BaseT >::classof().
|
inlineprotectedvirtual |
Initialize any complex state necessary for running this pass.
This hook should not rely on any state accessible during the execution of a pass. For example, getContext
/getOperation
/getAnalysis
/etc. should not be invoked within this hook. This method is invoked after all dependent dialects for the pipeline are loaded, and is not allowed to load any further dialects (override the getDependentDialects()
for this purpose instead). Returns a LogicalResult to indicate failure, in which case the pass pipeline won't execute.
Reimplemented in mlir::ExternalPass.
|
virtual |
Attempt to initialize the options of this pass from the given string.
Derived classes may override this method to hook into the point at which options are initialized, but should generally always invoke this base class variant.
Definition at line 63 of file Pass.cpp.
References options, and mlir::detail::PassOptions::parseFromString().
|
inline |
Returns the pass info for this pass, or null if unknown.
Definition at line 59 of file Pass.h.
References getArgument(), and mlir::PassInfo::lookup().
|
inlineprotected |
Mark all analyses as preserved.
Definition at line 240 of file Pass.h.
References getPassState(), mlir::detail::PreservedAnalyses::preserveAll(), and mlir::detail::PassExecutionState::preservedAnalyses.
|
inlineprotected |
Mark the provided analyses as preserved.
Definition at line 246 of file Pass.h.
References getPassState(), mlir::detail::PreservedAnalyses::preserve(), and mlir::detail::PassExecutionState::preservedAnalyses.
|
inlineprotected |
Definition at line 249 of file Pass.h.
References getPassState(), mlir::detail::PreservedAnalyses::preserve(), and mlir::detail::PassExecutionState::preservedAnalyses.
void Pass::printAsTextualPipeline | ( | raw_ostream & | os | ) |
Prints out the pass in the textual representation of pipelines.
If this is an adaptor pass, print its pass managers.
Definition at line 82 of file Pass.cpp.
References getArgument(), getName(), and mlir::detail::PassOptions::print().
Referenced by mlir::detail::PassCrashReproducerGenerator::prepareReproducerFor(), and printAsTextualPipeline().
|
protectedpure virtual |
The polymorphic API that runs the pass over the currently held operation.
Implemented in mlir::detail::OpToOpPassAdaptor, and mlir::ExternalPass.
|
inlineprotected |
|
inlineprotected |
Signal that some invariant was broken when running.
The IR is allowed to be in an invalid state.
Definition at line 217 of file Pass.h.
References getPassState(), and mlir::detail::PassExecutionState::irAndPassFailed.
Referenced by mlir::ExternalPass::signalPassFailure().
|
friend |