MLIR  15.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  Nesting { Nesting::Implicit, Nesting::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)
 
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...
 
Optional< OperationNamegetOpName (MLIRContext &context) const
 Return the operation name that this pass manager operates on, or None if this is an op-agnostic pass manager. More...
 
Optional< StringRef > getOpName () const
 Return the operation name that this pass manager operates on, or None 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 52 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 87 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 81 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 55 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 292 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 294 of file Pass.cpp.

◆ OpPassManager() [3/5]

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

Definition at line 296 of file Pass.cpp.

◆ OpPassManager() [4/5]

OpPassManager::OpPassManager ( OpPassManager &&  rhs)

Definition at line 298 of file Pass.cpp.

◆ OpPassManager() [5/5]

OpPassManager::OpPassManager ( const OpPassManager rhs)

Definition at line 299 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 118 of file PassManager.h.

Referenced by mlir::tosa::addTosaToLinalgPasses(), mlir::tosa::addTosaToSCFPasses(), and mlir::sparse_tensor::buildSparseCompiler().

◆ addPass()

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

◆ begin() [1/2]

OpPassManager::pass_iterator OpPassManager::begin ( )

Definition at line 307 of file Pass.cpp.

◆ begin() [2/2]

OpPassManager::const_pass_iterator OpPassManager::begin ( ) const

Definition at line 314 of file Pass.cpp.

◆ clear()

void OpPassManager::clear ( )

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

Definition at line 337 of file Pass.cpp.

◆ dump()

void OpPassManager::dump ( )

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

Definition at line 376 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 95 of file PassManager.h.

◆ end() [1/2]

OpPassManager::pass_iterator OpPassManager::end ( )

Definition at line 310 of file Pass.cpp.

◆ end() [2/2]

OpPassManager::const_pass_iterator OpPassManager::end ( ) const

Definition at line 317 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 140 of file PassManager.h.

References printAsTextualPipeline().

Referenced by mlir::detail::OpPassManagerImpl::getOpAnchorName().

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

Referenced by findPassManagerFor(), getNesting(), and mlir::PassManager::run().

◆ getNesting()

OpPassManager::Nesting OpPassManager::getNesting ( )

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

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

◆ getOpName() [1/2]

Optional< OperationName > OpPassManager::getOpName ( MLIRContext context) const

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

Return the operation name that this pass manager operates on.

Definition at line 351 of file Pass.cpp.

Referenced by buildDefaultRegistryFn(), and getNesting().

◆ getOpName() [2/2]

Optional< StringRef > OpPassManager::getOpName ( ) const

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

Return the operation name that this pass manager operates on.

Definition at line 346 of file Pass.cpp.

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

◆ 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 90 of file PassManager.h.

◆ mergeStatisticsInto()

void OpPassManager::mergeStatisticsInto ( OpPassManager other)

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

Definition at line 195 of file PassStatistics.cpp.

References getPasses().

◆ nest() [1/3]

OpPassManager & OpPassManager::nest ( OperationName  nestedName)

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

Definition at line 323 of file Pass.cpp.

◆ nest() [2/3]

OpPassManager & OpPassManager::nest ( StringRef  nestedName)

Definition at line 326 of file Pass.cpp.

◆ nest() [3/3]

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

Definition at line 101 of file PassManager.h.

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

◆ operator=()

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

Definition at line 300 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 372 of file Pass.cpp.

Referenced by dump(), and inlineCallsInSCC().

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

Referenced by mlir::PassPipelineCLParser::addToPipeline().

◆ size()

size_t OpPassManager::size ( ) const

Returns the number of passes held by this manager.

Definition at line 340 of file Pass.cpp.

Friends And Related Function Documentation

◆ Pass

friend class Pass
friend

Definition at line 184 of file PassManager.h.

◆ PassManager

friend class PassManager
friend

Allow access to the constructor.

Definition at line 183 of file PassManager.h.


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