MLIR  16.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...
 
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 287 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 289 of file Pass.cpp.

◆ OpPassManager() [3/5]

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

Definition at line 291 of file Pass.cpp.

◆ OpPassManager() [4/5]

OpPassManager::OpPassManager ( OpPassManager &&  rhs)

Definition at line 293 of file Pass.cpp.

◆ OpPassManager() [5/5]

OpPassManager::OpPassManager ( const OpPassManager rhs)

Definition at line 294 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 121 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)

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

Referenced by mlir::detail::OpPassManagerImpl::addPass(), buildDefaultRegistryFn(), mlir::sparse_tensor::buildSparseCompiler(), convertPDLToPDLInterp(), and defaultInlinerOptPipeline().

◆ begin() [1/2]

OpPassManager::pass_iterator OpPassManager::begin ( )

Definition at line 306 of file Pass.cpp.

Referenced by empty(), and getPasses().

◆ begin() [2/2]

OpPassManager::const_pass_iterator OpPassManager::begin ( ) const

Definition at line 313 of file Pass.cpp.

◆ clear()

void OpPassManager::clear ( )

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

Definition at line 336 of file Pass.cpp.

◆ dump()

void OpPassManager::dump ( )

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

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

References begin(), and end().

◆ end() [1/2]

OpPassManager::pass_iterator OpPassManager::end ( )

Definition at line 309 of file Pass.cpp.

Referenced by empty(), and getPasses().

◆ end() [2/2]

OpPassManager::const_pass_iterator OpPassManager::end ( ) const

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

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

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

◆ getNesting()

OpPassManager::Nesting OpPassManager::getNesting ( )

Return the current nesting mode.

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

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

◆ getOpName() [1/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 345 of file Pass.cpp.

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

◆ getOpName() [2/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 350 of file Pass.cpp.

Referenced by buildDefaultRegistryFn().

◆ 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 91 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 103 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 322 of file Pass.cpp.

◆ nest() [3/3]

OpPassManager & OpPassManager::nest ( StringRef  nestedName)

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

◆ operator=() [1/2]

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

Definition at line 295 of file Pass.cpp.

◆ operator=() [2/2]

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

Definition at line 299 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 360 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 387 of file Pass.cpp.

◆ size()

size_t OpPassManager::size ( ) const

Returns the number of passes held by this manager.

Definition at line 339 of file Pass.cpp.

Friends And Related Function Documentation

◆ Pass

friend class Pass
friend

Definition at line 187 of file PassManager.h.

◆ PassManager

friend class PassManager
friend

Allow access to the constructor.

Definition at line 186 of file PassManager.h.


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