MLIR  19.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
mlir::PassManager Class Reference

The main pass manager and pipeline builder. More...

#include "mlir/Pass/PassManager.h"

+ Inheritance diagram for mlir::PassManager:

Classes

class  IRPrinterConfig
 A configuration struct provided to the IR printer instrumentation. More...
 

Public Member Functions

 PassManager (MLIRContext *ctx, StringRef operationName=PassManager::getAnyOpAnchorName(), Nesting nesting=Nesting::Explicit)
 Create a new pass manager under the given context with a specific nesting style. More...
 
 PassManager (OperationName operationName, Nesting nesting=Nesting::Explicit)
 
 ~PassManager ()
 
LogicalResult run (Operation *op)
 Run the passes within this manager on the provided operation. More...
 
MLIRContextgetContext () const
 Return an instance of the context. More...
 
void enableCrashReproducerGeneration (StringRef outputFile, bool genLocalReproducer=false)
 Enable support for the pass manager to generate a reproducer on the event of a crash or a pass failure. More...
 
void enableCrashReproducerGeneration (ReproducerStreamFactory factory, bool genLocalReproducer=false)
 Enable support for the pass manager to generate a reproducer on the event of a crash or a pass failure. More...
 
void enableVerifier (bool enabled=true)
 Runs the verifier after each individual pass. More...
 
void addInstrumentation (std::unique_ptr< PassInstrumentation > pi)
 Add the provided instrumentation to the pass manager. More...
 
void enableIRPrinting (std::unique_ptr< IRPrinterConfig > config)
 Add an instrumentation to print the IR before and after pass execution, using the provided configuration. More...
 
void enableIRPrinting (std::function< bool(Pass *, Operation *)> shouldPrintBeforePass=[](Pass *, Operation *) { return true;}, std::function< bool(Pass *, Operation *)> shouldPrintAfterPass=[](Pass *, Operation *) { return true;}, bool printModuleScope=true, bool printAfterOnlyOnChange=true, bool printAfterOnlyOnFailure=false, raw_ostream &out=llvm::errs(), OpPrintingFlags opPrintingFlags=OpPrintingFlags())
 Add an instrumentation to print the IR before and after pass execution, using the provided fields to generate a default configuration: More...
 
void enableTiming (TimingScope &timingScope)
 Add an instrumentation to time the execution of passes and the computation of analyses. More...
 
void enableTiming (std::unique_ptr< TimingManager > tm)
 Add an instrumentation to time the execution of passes and the computation of analyses. More...
 
void enableTiming ()
 Add an instrumentation to time the execution of passes and the computation of analyses. More...
 
void enableStatistics (PassDisplayMode displayMode=PassDisplayMode::Pipeline)
 Prompts the pass manager to print the statistics collected for each of the held passes after each call to 'run'. More...
 
- Public Member Functions inherited from mlir::OpPassManager
 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

template<typename OperationTy >
static PassManager on (MLIRContext *ctx, Nesting nesting=Nesting::Explicit)
 Create a new pass manager under the given context with a specific nesting style. More...
 
- Static Public Member Functions inherited from mlir::OpPassManager
static StringRef getAnyOpAnchorName ()
 Return the string name used to anchor op-agnostic pass managers that operate generically on any viable operation. More...
 

Additional Inherited Members

- Public Types inherited from mlir::OpPassManager
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 >
 

Detailed Description

The main pass manager and pipeline builder.

Definition at line 232 of file PassManager.h.

Constructor & Destructor Documentation

◆ PassManager() [1/2]

PassManager::PassManager ( MLIRContext ctx,
StringRef  operationName = PassManager::getAnyOpAnchorName(),
Nesting  nesting = Nesting::Explicit 
)

Create a new pass manager under the given context with a specific nesting style.

The created pass manager can schedule operations that match operationName.

Definition at line 831 of file Pass.cpp.

◆ PassManager() [2/2]

PassManager::PassManager ( OperationName  operationName,
Nesting  nesting = Nesting::Explicit 
)

Definition at line 836 of file Pass.cpp.

◆ ~PassManager()

PassManager::~PassManager ( )
default

Member Function Documentation

◆ addInstrumentation()

void PassManager::addInstrumentation ( std::unique_ptr< PassInstrumentation pi)

Add the provided instrumentation to the pass manager.

Definition at line 896 of file Pass.cpp.

References mlir::PassInstrumentor::addInstrumentation().

Referenced by enableIRPrinting().

◆ enableCrashReproducerGeneration() [1/2]

void PassManager::enableCrashReproducerGeneration ( ReproducerStreamFactory  factory,
bool  genLocalReproducer = false 
)

Enable support for the pass manager to generate a reproducer on the event of a crash or a pass failure.

factory is used to construct the streams to write the generated reproducer to. If genLocalReproducer is true, the pass manager will attempt to generate a local reproducer that contains the smallest pipeline.

Definition at line 468 of file PassCrashRecovery.cpp.

References getContext().

◆ enableCrashReproducerGeneration() [2/2]

void PassManager::enableCrashReproducerGeneration ( StringRef  outputFile,
bool  genLocalReproducer = false 
)

Enable support for the pass manager to generate a reproducer on the event of a crash or a pass failure.

outputFile is a .mlir filename used to write the generated reproducer. If genLocalReproducer is true, the pass manager will attempt to generate a local reproducer that contains the smallest pipeline.

Definition at line 462 of file PassCrashRecovery.cpp.

References makeReproducerStreamFactory().

Referenced by mlir::applyPassManagerCLOptions().

◆ enableIRPrinting() [1/2]

void PassManager::enableIRPrinting ( std::function< bool(Pass *, Operation *)>  shouldPrintBeforePass = [](Pass *, Operation *) { return true; },
std::function< bool(Pass *, Operation *)>  shouldPrintAfterPass = [](Pass *, Operation *) { return true; },
bool  printModuleScope = true,
bool  printAfterOnlyOnChange = true,
bool  printAfterOnlyOnFailure = false,
raw_ostream &  out = llvm::errs(),
OpPrintingFlags  opPrintingFlags = OpPrintingFlags() 
)

Add an instrumentation to print the IR before and after pass execution, using the provided fields to generate a default configuration:

Add an instrumentation to print the IR before and after pass execution.

  • 'shouldPrintBeforePass' and 'shouldPrintAfterPass' correspond to filter functions that take a 'Pass *' and Operation *. These function should return true if the IR should be printed or not.
  • 'printModuleScope' signals if the module IR should be printed, even for non module passes.
  • 'printAfterOnlyOnChange' signals that when printing the IR after a pass, in the case of a non-failure, we should first check if any potential mutations were made.
  • 'printAfterOnlyOnFailure' signals that when printing the IR after a pass, we only print in the case of a failure.
    • This option should not be used with the other printAfter flags above.
  • 'out' corresponds to the stream to output the printed IR to.
  • 'opPrintingFlags' sets up the printing flags to use when printing the IR.

Definition at line 215 of file IRPrinting.cpp.

References enableIRPrinting().

◆ enableIRPrinting() [2/2]

void PassManager::enableIRPrinting ( std::unique_ptr< IRPrinterConfig config)

Add an instrumentation to print the IR before and after pass execution, using the provided configuration.

Definition at line 205 of file IRPrinting.cpp.

References addInstrumentation(), and getContext().

Referenced by enableIRPrinting().

◆ enableStatistics()

void PassManager::enableStatistics ( PassDisplayMode  displayMode = PassDisplayMode::Pipeline)

Prompts the pass manager to print the statistics collected for each of the held passes after each call to 'run'.

Dump the statistics for each pass after running.

Definition at line 250 of file PassStatistics.cpp.

Referenced by mlir::applyPassManagerCLOptions().

◆ enableTiming() [1/3]

void PassManager::enableTiming ( )

Add an instrumentation to time the execution of passes and the computation of analyses.

Creates a temporary TimingManager owned by this PassManager which will be used to report timing.

Note: Timing should be enabled after all other instrumentations to avoid any potential "ghost" timing from other instrumentations being unintentionally included in the timing results.

Definition at line 164 of file PassTiming.cpp.

◆ enableTiming() [2/3]

void PassManager::enableTiming ( std::unique_ptr< TimingManager tm)

Add an instrumentation to time the execution of passes and the computation of analyses.

The pass manager will take ownership of the timing manager passed to the function and timing will be reported by nesting timers into the timing manager's root scope.

Note: Timing should be enabled after all other instrumentations to avoid any potential "ghost" timing from other instrumentations being unintentionally included in the timing results.

Definition at line 156 of file PassTiming.cpp.

◆ enableTiming() [3/3]

void PassManager::enableTiming ( TimingScope timingScope)

Add an instrumentation to time the execution of passes and the computation of analyses.

Timing will be reported by nesting timers into the provided timingScope.

Note: Timing should be enabled after all other instrumentations to avoid any potential "ghost" timing from other instrumentations being unintentionally included in the timing results.

Definition at line 148 of file PassTiming.cpp.

Referenced by mlir::applyDefaultTimingPassManagerCLOptions().

◆ enableVerifier()

void PassManager::enableVerifier ( bool  enabled = true)

Runs the verifier after each individual pass.

Definition at line 843 of file Pass.cpp.

Referenced by mlir::PassReproducerOptions::apply().

◆ getContext()

MLIRContext* mlir::PassManager::getContext ( ) const
inline

Return an instance of the context.

Definition at line 257 of file PassManager.h.

Referenced by mlir::PassReproducerOptions::apply(), mlir::applyPassManagerCLOptions(), and enableIRPrinting().

◆ on()

template<typename OperationTy >
static PassManager mlir::PassManager::on ( MLIRContext ctx,
Nesting  nesting = Nesting::Explicit 
)
inlinestatic

Create a new pass manager under the given context with a specific nesting style.

The created pass manager can schedule operations that match OperationTy.

Definition at line 247 of file PassManager.h.

References mlir::OpPassManager::PassManager.

◆ run()

LogicalResult PassManager::run ( Operation op)

Run the passes within this manager on the provided operation.

The specified operation must have the same name as the one provided the pass manager on construction.

Definition at line 846 of file Pass.cpp.


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