MLIR  16.0.0git
Classes | Public Member Functions | Static 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...
 
Optional< StringRef > getOpName () const
 Returns the name of the operation that this pass operates on, or None if this is a generic OperationPass. More...
 
virtual LogicalResult initializeOptions (StringRef options)
 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...
 

Static Public Member Functions

static const PassInfolookupPassInfo (StringRef passArg)
 Returns the pass info for the specified pass class or null if unknown. More...
 

Protected Member Functions

 Pass (TypeID passID, Optional< StringRef > opName=llvm::None)
 
 Pass (const Pass &other)
 
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 >
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 >
Optional< std::reference_wrapper< AnalysisT > > getCachedParentAnalysis (Operation *parent)
 Returns the analysis for the given parent operation if it exists. More...
 
template<typename AnalysisT >
Optional< std::reference_wrapper< AnalysisT > > getCachedParentAnalysis ()
 Returns the analysis for the parent operation if it exists. More...
 
template<typename AnalysisT >
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 50 of file Pass.h.

Constructor & Destructor Documentation

◆ ~Pass()

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

◆ Pass() [1/2]

mlir::Pass::Pass ( TypeID  passID,
Optional< StringRef >  opName = llvm::None 
)
inlineexplicitprotected

Definition at line 162 of file Pass.h.

◆ Pass() [2/2]

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

Definition at line 164 of file Pass.h.

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 >, mlir::OperationPass< OpT >, and mlir::OperationPass< gpu::GPUModuleOp >.

◆ clone()

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

A clone method to create a copy of this pass.

Definition at line 199 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, mlir::PassWrapper< OpToOpPassAdaptor, OperationPass<> >, and mlir::PassWrapper< BufferizeDenseOpsPass, OperationPass< ModuleOp > >.

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 48 of file Pass.cpp.

◆ getAnalysis() [1/2]

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

Query an analysis for the current ir unit.

Definition at line 216 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 223 of file Pass.h.

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

◆ getAnalysisManager()

AnalysisManager mlir::Pass::getAnalysisManager ( )
inlineprotected

Returns the current analysis manager.

Definition at line 284 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 77 of file Pass.h.

Referenced by lookupPassInfo().

◆ getCachedAnalysis()

template<typename AnalysisT >
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 230 of file Pass.h.

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

◆ getCachedChildAnalysis()

template<typename AnalysisT >
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 265 of file Pass.h.

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

◆ getCachedParentAnalysis() [1/2]

template<typename AnalysisT >
Optional<std::reference_wrapper<AnalysisT> > mlir::Pass::getCachedParentAnalysis ( )
inlineprotected

Returns the analysis for the parent operation if it exists.

Definition at line 257 of file Pass.h.

References getAnalysisManager(), mlir::AnalysisManager::getCachedParentAnalysis(), getOperation(), and mlir::Operation::getParentOp().

◆ getCachedParentAnalysis() [2/2]

template<typename AnalysisT >
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 251 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 272 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 279 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 173 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, mlir::gpu::SerializeToBlobPass, and mlir::detail::OpToOpPassAdaptor.

Definition at line 73 of file Pass.h.

Referenced by mlir::gpu::SerializeToBlobPass::getDependentDialects().

◆ 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 81 of file Pass.h.

◆ getName()

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

◆ getOperation()

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

◆ getOpName()

Optional<StringRef> mlir::Pass::getOpName ( ) const
inline

Returns the name of the operation that this pass operates on, or None if this is a generic OperationPass.

Definition at line 85 of file Pass.h.

Referenced by mlir::OperationPass< OpT >::canScheduleOn(), mlir::ExternalPass::canScheduleOn(), mlir::OperationPass< OpT >::classof(), and mlir::ExternalPass::clonePass().

◆ getPassState()

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

Returns the current pass state.

Definition at line 167 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 55 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. Returns a LogicalResult to indicate failure, in which case the pass pipeline won't execute.

Reimplemented in mlir::ExternalPass.

Definition at line 184 of file Pass.h.

References mlir::success().

◆ initializeOptions()

LogicalResult Pass::initializeOptions ( StringRef  options)
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 42 of file Pass.cpp.

References options.

◆ lookupPassInfo() [1/2]

const PassInfo* mlir::Pass::lookupPassInfo ( ) const
inline

Returns the pass info for this pass, or null if unknown.

Definition at line 61 of file Pass.h.

References getArgument().

◆ lookupPassInfo() [2/2]

const PassInfo * mlir::Pass::lookupPassInfo ( StringRef  passArg)
static

Returns the pass info for the specified pass class or null if unknown.

Returns the pass info for the specified pass argument or null if unknown.

Definition at line 141 of file PassRegistry.cpp.

References passRegistry.

◆ markAllAnalysesPreserved()

void mlir::Pass::markAllAnalysesPreserved ( )
inlineprotected

Mark all analyses as preserved.

Definition at line 235 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 241 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

◆ 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 54 of file Pass.cpp.

Referenced by mlir::detail::PassCrashReproducerGenerator::prepareReproducerFor().

◆ 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, mlir::sparse_tensor::BufferizeDenseOpsPass, mlir::ExternalPass, and mlir::gpu::SerializeToBlobPass.

◆ 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 194 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 212 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 321 of file Pass.h.

◆ PassInfo

friend class PassInfo
friend

Allow access to 'passOptions'.

Definition at line 330 of file Pass.h.


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