MLIR  20.0.0git
Classes | Namespaces | Functions
Pass.cpp File Reference
#include "mlir-c/Pass.h"
#include "mlir/CAPI/IR.h"
#include "mlir/CAPI/Pass.h"
#include "mlir/CAPI/Support.h"
#include "mlir/CAPI/Utils.h"
#include "mlir/Pass/PassManager.h"
#include <optional>

Go to the source code of this file.

Classes

class  mlir::ExternalPass
 This pass class wraps external passes defined in other languages using the MLIR C-interface. More...
 

Namespaces

 mlir
 Include the generated interface declarations.
 

Functions

MlirPassManager mlirPassManagerCreate (MlirContext ctx)
 Create a new top-level PassManager with the default anchor. More...
 
MlirPassManager mlirPassManagerCreateOnOperation (MlirContext ctx, MlirStringRef anchorOp)
 Create a new top-level PassManager anchored on anchorOp. More...
 
void mlirPassManagerDestroy (MlirPassManager passManager)
 Destroy the provided PassManager. More...
 
MlirOpPassManager mlirPassManagerGetAsOpPassManager (MlirPassManager passManager)
 Cast a top-level PassManager to a generic OpPassManager. More...
 
MlirLogicalResult mlirPassManagerRunOnOp (MlirPassManager passManager, MlirOperation op)
 Run the provided passManager on the given op. More...
 
void mlirPassManagerEnableIRPrinting (MlirPassManager passManager, bool printBeforeAll, bool printAfterAll, bool printModuleScope, bool printAfterOnlyOnChange, bool printAfterOnlyOnFailure, MlirOpPrintingFlags flags, MlirStringRef treePrintingPath)
 Enable IR printing. More...
 
void mlirPassManagerEnableVerifier (MlirPassManager passManager, bool enable)
 Enable / disable verify-each. More...
 
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. More...
 
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. More...
 
void mlirPassManagerAddOwnedPass (MlirPassManager passManager, MlirPass pass)
 Add a pass and transfer ownership to the provided top-level mlirPassManager. More...
 
void mlirOpPassManagerAddOwnedPass (MlirOpPassManager passManager, MlirPass pass)
 Add a pass and transfer ownership to the provided mlirOpPassManager. More...
 
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. More...
 
void mlirPrintPassPipeline (MlirOpPassManager passManager, MlirStringCallback callback, void *userData)
 Print a textual MLIR pass pipeline by sending chunks of the string representation and forwarding userData tocallback`. More...
 
MlirLogicalResult mlirParsePassPipeline (MlirOpPassManager passManager, MlirStringRef pipeline, MlirStringCallback callback, void *userData)
 Parse a textual MLIR pass pipeline and assign it to the provided OpPassManager. More...
 
MlirPass mlirCreateExternalPass (MlirTypeID passID, MlirStringRef name, MlirStringRef argument, MlirStringRef description, MlirStringRef opName, intptr_t nDependentDialects, MlirDialectHandle *dependentDialects, MlirExternalPassCallbacks callbacks, void *userData)
 Creates an external MlirPass that calls the supplied callbacks using the supplied userData. More...
 
void mlirExternalPassSignalFailure (MlirExternalPass pass)
 This signals that the pass has failed. More...
 

Function Documentation

◆ mlirCreateExternalPass()

MlirPass mlirCreateExternalPass ( MlirTypeID  passID,
MlirStringRef  name,
MlirStringRef  argument,
MlirStringRef  description,
MlirStringRef  opName,
intptr_t  nDependentDialects,
MlirDialectHandle dependentDialects,
MlirExternalPassCallbacks  callbacks,
void *  userData 
)

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.

Definition at line 196 of file Pass.cpp.

References MlirStringRef::length, unwrap(), and wrap().

◆ mlirExternalPassSignalFailure()

void mlirExternalPassSignalFailure ( MlirExternalPass  pass)

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

References unwrap().

◆ mlirOpPassManagerAddOwnedPass()

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

References unwrap().

◆ mlirOpPassManagerAddPipeline()

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

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

◆ mlirOpPassManagerGetNestedUnder()

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

References unwrap(), and wrap().

◆ mlirParsePassPipeline()

MlirLogicalResult mlirParsePassPipeline ( MlirOpPassManager  passManager,
MlirStringRef  pipeline,
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.

Definition at line 112 of file Pass.cpp.

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

◆ mlirPassManagerAddOwnedPass()

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

References unwrap().

◆ mlirPassManagerCreate()

MlirPassManager mlirPassManagerCreate ( MlirContext  ctx)

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

Definition at line 24 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerCreateOnOperation()

MlirPassManager mlirPassManagerCreateOnOperation ( MlirContext  ctx,
MlirStringRef  anchorOp 
)

Create a new top-level PassManager anchored on anchorOp.

Definition at line 28 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerDestroy()

void mlirPassManagerDestroy ( MlirPassManager  passManager)

Destroy the provided PassManager.

Definition at line 33 of file Pass.cpp.

References unwrap().

◆ mlirPassManagerEnableIRPrinting()

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

References unwrap().

◆ mlirPassManagerEnableVerifier()

void mlirPassManagerEnableVerifier ( MlirPassManager  passManager,
bool  enable 
)

Enable / disable verify-each.

Definition at line 74 of file Pass.cpp.

References unwrap().

◆ mlirPassManagerGetAsOpPassManager()

MlirOpPassManager mlirPassManagerGetAsOpPassManager ( MlirPassManager  passManager)

Cast a top-level PassManager to a generic OpPassManager.

Definition at line 38 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPassManagerGetNestedUnder()

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

References unwrap(), and wrap().

◆ mlirPassManagerRunOnOp()

MlirLogicalResult mlirPassManagerRunOnOp ( MlirPassManager  passManager,
MlirOperation  op 
)

Run the provided passManager on the given op.

Definition at line 42 of file Pass.cpp.

References unwrap(), and wrap().

◆ mlirPrintPassPipeline()

void mlirPrintPassPipeline ( MlirOpPassManager  passManager,
MlirStringCallback  callback,
void *  userData 
)

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

Note that the callback may be called several times with consecutive chunks of the string.

Definition at line 106 of file Pass.cpp.

References unwrap().