MLIR  20.0.0git
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
mlir::Pass Class Referenceabstract

The abstract base pass class. More...

#include "mlir/Pass/Pass.h"

+ Inheritance diagram for mlir::Pass:

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 PassInfolookupPassInfo () 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 &registry) 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 PassgetThreadingSibling () const
 Returns the thread sibling of this pass. More...
 
const PassgetThreadingSiblingOrThis () 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)
 
Passoperator= (const Pass &)=delete
 
 Pass (Pass &&)=delete
 
Passoperator= (Pass &&)=delete
 
detail::PassExecutionStategetPassState ()
 Returns the current pass state. More...
 
MLIRContextgetContext ()
 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< Passclone () const
 A clone method to create a copy of this pass. More...
 
OperationgetOperation ()
 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< PassclonePass () 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...
 

Detailed Description

The abstract base pass class.

This class contains information describing the derived pass object, e.g its kind and abstract TypeID.

Definition at line 51 of file Pass.h.

Constructor & Destructor Documentation

◆ ~Pass()

virtual mlir::Pass::~Pass ( )
virtualdefault

◆ Pass() [1/3]

mlir::Pass::Pass ( TypeID  passID,
std::optional< StringRef >  opName = std::nullopt 
)
inlineexplicitprotected

Definition at line 162 of file Pass.h.

◆ Pass() [2/3]

mlir::Pass::Pass ( const Pass other)
inlineprotected

Definition at line 164 of file Pass.h.

◆ Pass() [3/3]

mlir::Pass::Pass ( Pass &&  )
protecteddelete

Member Function Documentation

◆ canScheduleOn()

virtual bool mlir::Pass::canScheduleOn ( RegisteredOperationName  opName) const
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 >.

◆ clone()

std::unique_ptr<Pass> mlir::Pass::clone ( ) const
inlineprotected

A clone method to create a copy of this pass.

Definition at line 204 of file Pass.h.

References clonePass().

◆ clonePass()

virtual std::unique_ptr<Pass> mlir::Pass::clonePass ( ) const
protectedpure virtual

Create a copy of this pass, ignoring statistics and options.

Implemented in mlir::ExternalPass, and mlir::PassWrapper< OpToOpPassAdaptor, OperationPass<> >.

Referenced by clone().

◆ copyOptionValuesFrom()

void Pass::copyOptionValuesFrom ( const Pass other)
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().

◆ getAnalysis() [1/2]

template<typename AnalysisT >
AnalysisT& mlir::Pass::getAnalysis ( )
inlineprotected

Query an analysis for the current ir unit.

Definition at line 221 of file Pass.h.

References mlir::AnalysisManager::getAnalysis(), and getAnalysisManager().

◆ getAnalysis() [2/2]

template<typename AnalysisT , typename OpT >
AnalysisT& mlir::Pass::getAnalysis ( )
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().

◆ getAnalysisManager()

AnalysisManager mlir::Pass::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().

◆ getArgument()

StringRef Pass::getArgument ( ) const
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().

◆ getCachedAnalysis()

template<typename AnalysisT >
std::optional<std::reference_wrapper<AnalysisT> > mlir::Pass::getCachedAnalysis ( )
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().

◆ getCachedChildAnalysis()

template<typename AnalysisT >
std::optional<std::reference_wrapper<AnalysisT> > mlir::Pass::getCachedChildAnalysis ( Operation child)
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().

◆ getCachedParentAnalysis() [1/2]

template<typename AnalysisT >
std::optional<std::reference_wrapper<AnalysisT> > mlir::Pass::getCachedParentAnalysis ( )
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().

◆ getCachedParentAnalysis() [2/2]

template<typename AnalysisT >
std::optional<std::reference_wrapper<AnalysisT> > mlir::Pass::getCachedParentAnalysis ( Operation parent)
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().

◆ getChildAnalysis() [1/2]

template<typename AnalysisT >
AnalysisT& mlir::Pass::getChildAnalysis ( Operation child)
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().

◆ getChildAnalysis() [2/2]

template<typename AnalysisT , typename OpTy >
AnalysisT& mlir::Pass::getChildAnalysis ( OpTy  child)
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().

◆ getContext()

MLIRContext& mlir::Pass::getContext ( )
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().

◆ getDependentDialects()

virtual void mlir::Pass::getDependentDialects ( DialectRegistry registry) const
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.

Definition at line 71 of file Pass.h.

◆ getDescription()

StringRef Pass::getDescription ( ) const
inlinevirtual

Return the command line description used when registering this pass.

Return an empty string if one does not exist.

Reimplemented in mlir::ExternalPass.

Definition at line 79 of file Pass.h.

◆ getName()

virtual StringRef mlir::Pass::getName ( ) const
pure virtual

◆ getOperation()

Operation* mlir::Pass::getOperation ( )
inlineprotected

◆ getOpName()

std::optional<StringRef> mlir::Pass::getOpName ( ) const
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().

◆ getPassState()

detail::PassExecutionState& mlir::Pass::getPassState ( )
inlineprotected

Returns the current pass state.

Definition at line 170 of file Pass.h.

Referenced by getAnalysisManager(), getOperation(), markAllAnalysesPreserved(), markAnalysesPreserved(), and signalPassFailure().

◆ getStatistics() [1/2]

MutableArrayRef<Statistic *> mlir::Pass::getStatistics ( )
inline

Definition at line 144 of file Pass.h.

◆ getStatistics() [2/2]

ArrayRef< PassStatistic > Pass::getStatistics ( ) const
inline

Returns the main statistics for this pass instance.

Definition at line 143 of file Pass.h.

◆ getThreadingSibling()

const Pass* mlir::Pass::getThreadingSibling ( ) const
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.

Definition at line 153 of file Pass.h.

◆ getThreadingSiblingOrThis()

const Pass* mlir::Pass::getThreadingSiblingOrThis ( ) const
inline

Returns the thread sibling of this pass, or the pass itself it has no sibling.

See getThreadingSibling() for details.

Definition at line 157 of file Pass.h.

◆ getTypeID()

TypeID mlir::Pass::getTypeID ( ) const
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().

◆ initialize()

virtual LogicalResult mlir::Pass::initialize ( MLIRContext context)
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.

Definition at line 189 of file Pass.h.

◆ initializeOptions()

LogicalResult Pass::initializeOptions ( StringRef  options,
function_ref< LogicalResult(const Twine &)>  errorHandler 
)
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().

◆ lookupPassInfo()

const PassInfo* mlir::Pass::lookupPassInfo ( ) const
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().

◆ markAllAnalysesPreserved()

void mlir::Pass::markAllAnalysesPreserved ( )
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.

◆ markAnalysesPreserved() [1/2]

template<typename... AnalysesT>
void mlir::Pass::markAnalysesPreserved ( )
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.

◆ markAnalysesPreserved() [2/2]

void mlir::Pass::markAnalysesPreserved ( TypeID  id)
inlineprotected

◆ operator=() [1/2]

Pass& mlir::Pass::operator= ( const Pass )
protecteddelete

◆ operator=() [2/2]

Pass& mlir::Pass::operator= ( Pass &&  )
protecteddelete

◆ printAsTextualPipeline()

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().

◆ runOnOperation()

virtual void mlir::Pass::runOnOperation ( )
protectedpure virtual

The polymorphic API that runs the pass over the currently held operation.

Implemented in mlir::detail::OpToOpPassAdaptor, and mlir::ExternalPass.

◆ runPipeline()

LogicalResult mlir::Pass::runPipeline ( OpPassManager pipeline,
Operation op 
)
inlineprotected

Schedule an arbitrary pass pipeline on the provided operation.

This can be invoke any time in a pass to dynamic schedule more passes. The provided operation must be the current one or one nested below.

Definition at line 199 of file Pass.h.

◆ signalPassFailure()

void mlir::Pass::signalPassFailure ( )
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().

Friends And Related Function Documentation

◆ OpPassManager

friend class OpPassManager
friend

Allow access to 'clone'.

Definition at line 326 of file Pass.h.

◆ PassInfo

friend class PassInfo
friend

Allow access to 'passOptions'.

Definition at line 335 of file Pass.h.


The documentation for this class was generated from the following files: