MLIR 22.0.0git
Pass.h File Reference
#include "mlir-c/IR.h"
#include "mlir-c/Support.h"

Go to the source code of this file.

Macros

#define DEFINE_C_API_STRUCT(name, storage)

Enumerations

enum  MlirPassDisplayMode { MLIR_PASS_DISPLAY_MODE_LIST , MLIR_PASS_DISPLAY_MODE_PIPELINE }
 Enumerated type of pass display modes. More...

Functions

 DEFINE_C_API_STRUCT (MlirPass, void)
 DEFINE_C_API_STRUCT (MlirExternalPass, void)
 DEFINE_C_API_STRUCT (MlirPassManager, void)
 DEFINE_C_API_STRUCT (MlirOpPassManager, void)
MLIR_CAPI_EXPORTED MlirPassManager mlirPassManagerCreate (MlirContext ctx)
 Create a new top-level PassManager with the default anchor.
MLIR_CAPI_EXPORTED MlirPassManager mlirPassManagerCreateOnOperation (MlirContext ctx, MlirStringRef anchorOp)
 Create a new top-level PassManager anchored on anchorOp.
MLIR_CAPI_EXPORTED void mlirPassManagerDestroy (MlirPassManager passManager)
 Destroy the provided PassManager.
static bool mlirPassManagerIsNull (MlirPassManager passManager)
 Checks if a PassManager is null.
MLIR_CAPI_EXPORTED MlirOpPassManager mlirPassManagerGetAsOpPassManager (MlirPassManager passManager)
 Cast a top-level PassManager to a generic OpPassManager.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirPassManagerRunOnOp (MlirPassManager passManager, MlirOperation op)
 Run the provided passManager on the given op.
MLIR_CAPI_EXPORTED void mlirPassManagerEnableIRPrinting (MlirPassManager passManager, bool printBeforeAll, bool printAfterAll, bool printModuleScope, bool printAfterOnlyOnChange, bool printAfterOnlyOnFailure, MlirOpPrintingFlags flags, MlirStringRef treePrintingPath)
 Enable IR printing.
MLIR_CAPI_EXPORTED void mlirPassManagerEnableVerifier (MlirPassManager passManager, bool enable)
 Enable / disable verify-each.
MLIR_CAPI_EXPORTED void mlirPassManagerEnableTiming (MlirPassManager passManager)
 Enable pass timing.
MLIR_CAPI_EXPORTED void mlirPassManagerEnableStatistics (MlirPassManager passManager, MlirPassDisplayMode displayMode)
 Enable pass statistics.
MLIR_CAPI_EXPORTED MlirOpPassManager mlirPassManagerGetNestedUnder (MlirPassManager passManager, MlirStringRef operationName)
 Nest an OpPassManager under the top-level PassManager, the nested passmanager will only run on operations matching the provided name.
MLIR_CAPI_EXPORTED MlirOpPassManager mlirOpPassManagerGetNestedUnder (MlirOpPassManager passManager, MlirStringRef operationName)
 Nest an OpPassManager under the provided OpPassManager, the nested passmanager will only run on operations matching the provided name.
MLIR_CAPI_EXPORTED void mlirPassManagerAddOwnedPass (MlirPassManager passManager, MlirPass pass)
 Add a pass and transfer ownership to the provided top-level mlirPassManager.
MLIR_CAPI_EXPORTED void mlirOpPassManagerAddOwnedPass (MlirOpPassManager passManager, MlirPass pass)
 Add a pass and transfer ownership to the provided mlirOpPassManager.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirOpPassManagerAddPipeline (MlirOpPassManager passManager, MlirStringRef pipelineElements, MlirStringCallback callback, void *userData)
 Parse a sequence of textual MLIR pass pipeline elements and add them to the provided OpPassManager.
MLIR_CAPI_EXPORTED void mlirExternalPassSignalFailure (MlirExternalPass pass)
 Print a textual MLIR pass pipeline by sending chunks of the string representation and forwarding userData to callback`.

Macro Definition Documentation

◆ DEFINE_C_API_STRUCT

#define DEFINE_C_API_STRUCT ( name,
storage )
Value:
struct name { \
storage *ptr; \
}; \
typedef struct name name

Definition at line 37 of file Pass.h.

Enumeration Type Documentation

◆ MlirPassDisplayMode

Enumerated type of pass display modes.

Mainly used in mlirPassManagerEnableStatistics.

Enumerator
MLIR_PASS_DISPLAY_MODE_LIST 
MLIR_PASS_DISPLAY_MODE_PIPELINE 

Definition at line 97 of file Pass.h.

Function Documentation

◆ DEFINE_C_API_STRUCT() [1/4]

DEFINE_C_API_STRUCT ( MlirExternalPass ,
void  )

◆ DEFINE_C_API_STRUCT() [2/4]

DEFINE_C_API_STRUCT ( MlirOpPassManager ,
void  )

References MLIR_CAPI_EXPORTED.

◆ DEFINE_C_API_STRUCT() [3/4]

DEFINE_C_API_STRUCT ( MlirPass ,
void  )

◆ DEFINE_C_API_STRUCT() [4/4]

DEFINE_C_API_STRUCT ( MlirPassManager ,
void  )

◆ mlirExternalPassSignalFailure()

MLIR_CAPI_EXPORTED void mlirExternalPassSignalFailure ( MlirExternalPass pass)

Print a textual MLIR pass pipeline by sending chunks of the string representation and forwarding userData to callback`.

Note that the / callback may be called several times with consecutive chunks of the string. MLIR_CAPI_EXPORTED void mlirPrintPassPipeline(MlirOpPassManager passManager, MlirStringCallback callback, void *userData);

/ Parse a textual MLIR pass pipeline and assign it to the provided / OpPassManager. If parsing fails an error message is reported using the / provided callback. MLIR_CAPI_EXPORTED MlirLogicalResult mlirParsePassPipeline(MlirOpPassManager passManager, MlirStringRef pipeline, MlirStringCallback callback, void *userData);

===-------------------------------------------------------------------—===// External Pass API.

This API allows to define passes outside of MLIR, not necessarily in C++, and register them with the MLIR pass management infrastructure.

===-------------------------------------------------------------------—===//

/ Structure of external MlirPass callbacks. / All callbacks are required to be set unless otherwise specified. struct MlirExternalPassCallbacks { / This callback is called from the pass is created. / This is analogous to a C++ pass constructor. void (*construct)(void *userData);

/ This callback is called when the pass is destroyed / This is analogous to a C++ pass destructor. void (*destruct)(void *userData);

/ This callback is optional. / The callback is called before the pass is run, allowing a chance to / initialize any complex state necessary for running the pass. / See Pass::initialize(MLIRContext *). MlirLogicalResult (*initialize)(MlirContext ctx, void *userData);

/ This callback is called when the pass is cloned. / See Pass::clonePass(). void *(*clone)(void *userData);

/ This callback is called when the pass is run. / See Pass::runOnOperation(). void (*run)(MlirOperation op, MlirExternalPass pass, void *userData); }; typedef struct MlirExternalPassCallbacks MlirExternalPassCallbacks;

/ Creates an external MlirPass that calls the supplied callbacks using the / supplied userData. If opName is empty, the pass is a generic operation / pass. Otherwise it is an operation pass specific to the specified pass name. MLIR_CAPI_EXPORTED MlirPass mlirCreateExternalPass( MlirTypeID passID, MlirStringRef name, MlirStringRef argument, MlirStringRef description, MlirStringRef opName, intptr_t nDependentDialects, MlirDialectHandle *dependentDialects, MlirExternalPassCallbacks callbacks, void *userData);

/ This signals that the pass has failed. This is only valid to call during / the run callback of MlirExternalPassCallbacks. See Pass::signalPassFailure().

Definition at line 234 of file Pass.cpp.

References unwrap().

◆ mlirOpPassManagerAddOwnedPass()

MLIR_CAPI_EXPORTED void mlirOpPassManagerAddOwnedPass ( MlirOpPassManager passManager,
MlirPass pass )

Add a pass and transfer ownership to the provided mlirOpPassManager.

If the pass is not a generic operation pass or matching the type of the provided PassManager, a new OpPassManager is implicitly nested under the provided PassManager.

Definition at line 111 of file Pass.cpp.

References unwrap().

◆ mlirOpPassManagerAddPipeline()

MLIR_CAPI_EXPORTED MlirLogicalResult mlirOpPassManagerAddPipeline ( MlirOpPassManager passManager,
MlirStringRef pipelineElements,
MlirStringCallback callback,
void * userData )

Parse a sequence of textual MLIR pass pipeline elements and add them to the provided OpPassManager.

If parsing fails an error message is reported using the provided callback.

Definition at line 116 of file Pass.cpp.

References mlir::parsePassPipeline(), unwrap(), and wrap().

◆ mlirOpPassManagerGetNestedUnder()

MLIR_CAPI_EXPORTED MlirOpPassManager mlirOpPassManagerGetNestedUnder ( MlirOpPassManager passManager,
MlirStringRef operationName )

Nest an OpPassManager under the provided OpPassManager, the nested passmanager will only run on operations matching the provided name.

The returned OpPassManager will be destroyed when the parent is destroyed.

Definition at line 102 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerAddOwnedPass()

MLIR_CAPI_EXPORTED void mlirPassManagerAddOwnedPass ( MlirPassManager passManager,
MlirPass pass )

Add a pass and transfer ownership to the provided top-level mlirPassManager.

If the pass is not a generic operation pass or a ModulePass, a new OpPassManager is implicitly nested under the provided PassManager.

Definition at line 107 of file Pass.cpp.

References unwrap().

◆ mlirPassManagerCreate()

MLIR_CAPI_EXPORTED MlirPassManager mlirPassManagerCreate ( MlirContext ctx)

Create a new top-level PassManager with the default anchor.

Definition at line 25 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerCreateOnOperation()

MLIR_CAPI_EXPORTED MlirPassManager mlirPassManagerCreateOnOperation ( MlirContext ctx,
MlirStringRef anchorOp )

Create a new top-level PassManager anchored on anchorOp.

Definition at line 29 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerDestroy()

MLIR_CAPI_EXPORTED void mlirPassManagerDestroy ( MlirPassManager passManager)

Destroy the provided PassManager.

Definition at line 34 of file Pass.cpp.

References unwrap().

◆ mlirPassManagerEnableIRPrinting()

MLIR_CAPI_EXPORTED void mlirPassManagerEnableIRPrinting ( MlirPassManager passManager,
bool printBeforeAll,
bool printAfterAll,
bool printModuleScope,
bool printAfterOnlyOnChange,
bool printAfterOnlyOnFailure,
MlirOpPrintingFlags flags,
MlirStringRef treePrintingPath )

Enable IR printing.

The treePrintingPath argument is an optional path to a directory where the dumps will be produced. If it isn't provided then dumps are produced to stderr.

Definition at line 48 of file Pass.cpp.

References unwrap().

◆ mlirPassManagerEnableStatistics()

MLIR_CAPI_EXPORTED void mlirPassManagerEnableStatistics ( MlirPassManager passManager,
MlirPassDisplayMode displayMode )

Enable pass statistics.

Definition at line 83 of file Pass.cpp.

References mlir::List, MLIR_PASS_DISPLAY_MODE_LIST, MLIR_PASS_DISPLAY_MODE_PIPELINE, mlir::Pipeline, and unwrap().

◆ mlirPassManagerEnableTiming()

MLIR_CAPI_EXPORTED void mlirPassManagerEnableTiming ( MlirPassManager passManager)

Enable pass timing.

Definition at line 79 of file Pass.cpp.

References unwrap().

◆ mlirPassManagerEnableVerifier()

MLIR_CAPI_EXPORTED void mlirPassManagerEnableVerifier ( MlirPassManager passManager,
bool enable )

Enable / disable verify-each.

Definition at line 75 of file Pass.cpp.

References unwrap().

◆ mlirPassManagerGetAsOpPassManager()

MLIR_CAPI_EXPORTED MlirOpPassManager mlirPassManagerGetAsOpPassManager ( MlirPassManager passManager)

Cast a top-level PassManager to a generic OpPassManager.

Definition at line 39 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerGetNestedUnder()

MLIR_CAPI_EXPORTED MlirOpPassManager mlirPassManagerGetNestedUnder ( MlirPassManager passManager,
MlirStringRef operationName )

Nest an OpPassManager under the top-level PassManager, the nested passmanager will only run on operations matching the provided name.

The returned OpPassManager will be destroyed when the parent is destroyed. To further nest more OpPassManager under the newly returned one, see mlirOpPassManagerNest below.

Definition at line 97 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerIsNull()

bool mlirPassManagerIsNull ( MlirPassManager passManager)
inlinestatic

Checks if a PassManager is null.

Definition at line 65 of file Pass.h.

Referenced by pybind11::detail::type_caster< MlirPassManager >::load().

◆ mlirPassManagerRunOnOp()

MLIR_CAPI_EXPORTED MlirLogicalResult mlirPassManagerRunOnOp ( MlirPassManager passManager,
MlirOperation op )

Run the provided passManager on the given op.

Definition at line 43 of file Pass.cpp.

References unwrap(), and wrap().