MLIR  20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
mlir::OpPassManager Class Reference

This class represents a pass manager that runs passes on either a specific operation type, or any isolated operation. More...

#include "mlir/Pass/PassManager.h"

+ Inheritance diagram for mlir::OpPassManager:

Public Types

enum class  Nesting { Implicit , Explicit }
 This enum represents the nesting behavior of the pass manager. More...
 
using pass_iterator = llvm::pointee_iterator< MutableArrayRef< std::unique_ptr< Pass > >::iterator >
 Iterator over the passes in this pass manager. More...
 
using const_pass_iterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< Pass > >::const_iterator >
 

Public Member Functions

 OpPassManager (Nesting nesting=Nesting::Explicit)
 Construct a new op-agnostic ("any") pass manager with the given operation type and nesting behavior. More...
 
 OpPassManager (StringRef name, Nesting nesting=Nesting::Explicit)
 Construct a new pass manager with the given anchor operation type and nesting behavior. More...
 
 OpPassManager (OperationName name, Nesting nesting=Nesting::Explicit)
 
 OpPassManager (OpPassManager &&rhs)
 
 OpPassManager (const OpPassManager &rhs)
 
 ~OpPassManager ()
 
OpPassManageroperator= (const OpPassManager &rhs)
 
OpPassManageroperator= (OpPassManager &&rhs)
 
pass_iterator begin ()
 
pass_iterator end ()
 
iterator_range< pass_iteratorgetPasses ()
 
const_pass_iterator begin () const
 
const_pass_iterator end () const
 
iterator_range< const_pass_iteratorgetPasses () const
 
bool empty () const
 Returns true if the pass manager has no passes. More...
 
OpPassManagernest (OperationName nestedName)
 Nest a new operation pass manager for the given operation kind under this pass manager. More...
 
OpPassManagernest (StringRef nestedName)
 
template<typename OpT >
OpPassManagernest ()
 
OpPassManagernestAny ()
 Nest a new op-agnostic ("any") pass manager under this pass manager. More...
 
void addPass (std::unique_ptr< Pass > pass)
 Add the given pass to this pass manager. More...
 
void clear ()
 Clear the pipeline, but not the other options set on this OpPassManager. More...
 
template<typename OpT >
void addNestedPass (std::unique_ptr< Pass > pass)
 Add the given pass to a nested pass manager for the given operation kind OpT. More...
 
size_t size () const
 Returns the number of passes held by this manager. More...
 
std::optional< OperationNamegetOpName (MLIRContext &context) const
 Return the operation name that this pass manager operates on, or std::nullopt if this is an op-agnostic pass manager. More...
 
std::optional< StringRef > getOpName () const
 Return the operation name that this pass manager operates on, or std::nullopt if this is an op-agnostic pass manager. More...
 
StringRef getOpAnchorName () const
 Return the name used to anchor this pass manager. More...
 
detail::OpPassManagerImplgetImpl ()
 Returns the internal implementation instance. More...
 
void printAsTextualPipeline (raw_ostream &os) const
 Prints out the passes of the pass manager as the textual representation of pipelines. More...
 
void dump ()
 Raw dump of the pass manager to llvm::errs(). More...
 
void mergeStatisticsInto (OpPassManager &other)
 Merge the pass statistics of this class into 'other'. More...
 
void getDependentDialects (DialectRegistry &dialects) const
 Register dependent dialects for the current pass manager. More...
 
void setNesting (Nesting nesting)
 Enable or disable the implicit nesting on this particular PassManager. More...
 
Nesting getNesting ()
 Return the current nesting mode. More...
 

Static Public Member Functions

static StringRef getAnyOpAnchorName ()
 Return the string name used to anchor op-agnostic pass managers that operate generically on any viable operation. More...
 

Friends

class PassManager
 Allow access to the constructor. More...
 
class Pass
 

Detailed Description

This class represents a pass manager that runs passes on either a specific operation type, or any isolated operation.

This pass manager can not be run on an operation directly, but must be run either as part of a top-level PassManager(e.g. when constructed via nest calls), or dynamically within a pass by using the Pass::runPipeline API.

Definition at line 47 of file PassManager.h.

Member Typedef Documentation

◆ const_pass_iterator

using mlir::OpPassManager::const_pass_iterator = llvm::pointee_iterator<ArrayRef<std::unique_ptr<Pass> >::const_iterator>

Definition at line 82 of file PassManager.h.

◆ pass_iterator

using mlir::OpPassManager::pass_iterator = llvm::pointee_iterator<MutableArrayRef<std::unique_ptr<Pass> >::iterator>

Iterator over the passes in this pass manager.

Definition at line 76 of file PassManager.h.

Member Enumeration Documentation

◆ Nesting

This enum represents the nesting behavior of the pass manager.

Enumerator
Implicit 

Implicit nesting behavior.

This allows for adding passes operating on operations different from this pass manager, in which case a new pass manager is implicitly nested for the operation type of the new pass.

Explicit 

Explicit nesting behavior.

This requires that any passes added to this pass manager support its operation type.

Definition at line 50 of file PassManager.h.

Constructor & Destructor Documentation

◆ OpPassManager() [1/5]

OpPassManager::OpPassManager ( Nesting  nesting = Nesting::Explicit)

Construct a new op-agnostic ("any") pass manager with the given operation type and nesting behavior.

This is the same as invoking: OpPassManager(getAnyOpAnchorName(), nesting).

Definition at line 318 of file Pass.cpp.

◆ OpPassManager() [2/5]

OpPassManager::OpPassManager ( StringRef  name,
Nesting  nesting = Nesting::Explicit 
)

Construct a new pass manager with the given anchor operation type and nesting behavior.

Definition at line 320 of file Pass.cpp.

◆ OpPassManager() [3/5]

OpPassManager::OpPassManager ( OperationName  name,
Nesting  nesting = Nesting::Explicit 
)

Definition at line 322 of file Pass.cpp.

◆ OpPassManager() [4/5]

OpPassManager::OpPassManager ( OpPassManager &&  rhs)

Definition at line 324 of file Pass.cpp.

◆ OpPassManager() [5/5]

OpPassManager::OpPassManager ( const OpPassManager rhs)

Definition at line 325 of file Pass.cpp.

◆ ~OpPassManager()

OpPassManager::~OpPassManager ( )
default

Member Function Documentation

◆ addNestedPass()

template<typename OpT >
void mlir::OpPassManager::addNestedPass ( std::unique_ptr< Pass pass)
inline

Add the given pass to a nested pass manager for the given operation kind OpT.

Definition at line 116 of file PassManager.h.

Referenced by mlir::tosa::addTosaToLinalgPasses(), mlir::tosa::addTosaToSCFPasses(), mlir::sparse_tensor::buildSparsifier(), and mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation().

◆ addPass()

void OpPassManager::addPass ( std::unique_ptr< Pass pass)

Add the given pass to this pass manager.

If this pass has a concrete operation type, it must be the same type as this pass manager.

Definition at line 363 of file Pass.cpp.

Referenced by mlir::tosa::addTosaToLinalgPasses(), mlir::bufferization::buildBufferDeallocationPipeline(), buildDefaultRegistryFn(), mlir::sparse_tensor::buildSparsifier(), defaultInlinerOptPipeline(), and mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation().

◆ begin() [1/2]

OpPassManager::pass_iterator OpPassManager::begin ( )

Definition at line 337 of file Pass.cpp.

Referenced by empty(), and getPasses().

◆ begin() [2/2]

OpPassManager::const_pass_iterator OpPassManager::begin ( ) const

Definition at line 344 of file Pass.cpp.

◆ clear()

void OpPassManager::clear ( )

Clear the pipeline, but not the other options set on this OpPassManager.

Definition at line 367 of file Pass.cpp.

◆ dump()

void OpPassManager::dump ( )

Raw dump of the pass manager to llvm::errs().

Definition at line 409 of file Pass.cpp.

References printAsTextualPipeline().

◆ empty()

bool mlir::OpPassManager::empty ( ) const
inline

Returns true if the pass manager has no passes.

Definition at line 91 of file PassManager.h.

References begin(), and end().

◆ end() [1/2]

OpPassManager::pass_iterator OpPassManager::end ( )

Definition at line 340 of file Pass.cpp.

Referenced by empty(), and getPasses().

◆ end() [2/2]

OpPassManager::const_pass_iterator OpPassManager::end ( ) const

Definition at line 347 of file Pass.cpp.

◆ getAnyOpAnchorName()

static StringRef mlir::OpPassManager::getAnyOpAnchorName ( )
inlinestatic

Return the string name used to anchor op-agnostic pass managers that operate generically on any viable operation.

Definition at line 138 of file PassManager.h.

Referenced by mlir::detail::OpPassManagerImpl::getOpAnchorName(), and performActions().

◆ getDependentDialects()

void OpPassManager::getDependentDialects ( DialectRegistry dialects) const

Register dependent dialects for the current pass manager.

This is forwarding to every pass in this PassManager, see the documentation for the same method on the Pass class.

Definition at line 421 of file Pass.cpp.

References registerDialectsForPipeline().

Referenced by mlir::detail::OpToOpPassAdaptor::getDependentDialects(), and mlir::PassManager::run().

◆ getImpl()

OpPassManagerImpl & OpPassManager::getImpl ( )

Returns the internal implementation instance.

Definition at line 373 of file Pass.cpp.

Referenced by findPassManagerFor(), mlir::PassManager::run(), and mlir::detail::OpToOpPassAdaptor::tryMergeInto().

◆ getNesting()

OpPassManager::Nesting OpPassManager::getNesting ( )

Return the current nesting mode.

Definition at line 427 of file Pass.cpp.

Referenced by buildDefaultRegistryFn().

◆ getOpAnchorName()

StringRef OpPassManager::getOpAnchorName ( ) const

Return the name used to anchor this pass manager.

This is either the name of an operation, or the result of getAnyOpAnchorName() in the case of an op-agnostic pass manager.

Definition at line 386 of file Pass.cpp.

Referenced by buildDefaultRegistryFn(), findPassManagerWithAnchor(), mlir::detail::OpToOpPassAdaptor::getAdaptorName(), printAsTextualPipeline(), mlir::PassManager::run(), and mlir::detail::OpToOpPassAdaptor::tryMergeInto().

◆ getOpName() [1/2]

std::optional< StringRef > OpPassManager::getOpName ( ) const

Return the operation name that this pass manager operates on, or std::nullopt if this is an op-agnostic pass manager.

Return the operation name that this pass manager operates on.

Definition at line 376 of file Pass.cpp.

Referenced by mlir::PassManager::run().

◆ getOpName() [2/2]

std::optional< OperationName > OpPassManager::getOpName ( MLIRContext context) const

Return the operation name that this pass manager operates on, or std::nullopt if this is an op-agnostic pass manager.

Return the operation name that this pass manager operates on.

Definition at line 382 of file Pass.cpp.

Referenced by buildDefaultRegistryFn(), and mlir::detail::OpToOpPassAdaptor::tryMergeInto().

◆ getPasses() [1/2]

iterator_range<pass_iterator> mlir::OpPassManager::getPasses ( )
inline

◆ getPasses() [2/2]

iterator_range<const_pass_iterator> mlir::OpPassManager::getPasses ( ) const
inline

Definition at line 86 of file PassManager.h.

References begin(), and end().

◆ mergeStatisticsInto()

void OpPassManager::mergeStatisticsInto ( OpPassManager other)

Merge the pass statistics of this class into 'other'.

Definition at line 194 of file PassStatistics.cpp.

References getPasses().

◆ nest() [1/3]

template<typename OpT >
OpPassManager& mlir::OpPassManager::nest ( )
inline

Definition at line 98 of file PassManager.h.

◆ nest() [2/3]

OpPassManager & OpPassManager::nest ( OperationName  nestedName)

Nest a new operation pass manager for the given operation kind under this pass manager.

Definition at line 353 of file Pass.cpp.

◆ nest() [3/3]

OpPassManager & OpPassManager::nest ( StringRef  nestedName)

Definition at line 356 of file Pass.cpp.

◆ nestAny()

OpPassManager & OpPassManager::nestAny ( )

Nest a new op-agnostic ("any") pass manager under this pass manager.

Note: This is the same as invoking nest(getAnyOpAnchorName()).

Definition at line 359 of file Pass.cpp.

◆ operator=() [1/2]

OpPassManager & OpPassManager::operator= ( const OpPassManager rhs)

Definition at line 326 of file Pass.cpp.

◆ operator=() [2/2]

OpPassManager & OpPassManager::operator= ( OpPassManager &&  rhs)

Definition at line 330 of file Pass.cpp.

◆ printAsTextualPipeline()

void OpPassManager::printAsTextualPipeline ( raw_ostream &  os) const

Prints out the passes of the pass manager as the textual representation of pipelines.

Note: The quality of the string representation depends entirely on the the correctness of per-pass overrides of Pass::printAsTextualPipeline.

Definition at line 401 of file Pass.cpp.

References getOpAnchorName().

Referenced by dump().

◆ setNesting()

void OpPassManager::setNesting ( Nesting  nesting)

Enable or disable the implicit nesting on this particular PassManager.

This will also apply to any newly nested PassManager built from this instance.

Definition at line 425 of file Pass.cpp.

◆ size()

size_t OpPassManager::size ( ) const

Returns the number of passes held by this manager.

Definition at line 370 of file Pass.cpp.

Friends And Related Function Documentation

◆ Pass

friend class Pass
friend

Definition at line 186 of file PassManager.h.

◆ PassManager

friend class PassManager
friend

Allow access to the constructor.

Definition at line 185 of file PassManager.h.

Referenced by mlir::PassManager::on().


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