28 delete unwrap(passManager);
33 return wrap(static_cast<OpPassManager *>(
unwrap(passManager)));
42 return unwrap(passManager)->enableIRPrinting();
46 unwrap(passManager)->enableVerifier(enable);
60 unwrap(passManager)->addPass(std::unique_ptr<Pass>(
unwrap(pass)));
65 unwrap(passManager)->addPass(std::unique_ptr<Pass>(
unwrap(pass)));
71 unwrap(passManager)->printAsTextualPipeline(stream);
99 :
Pass(passID, opName), id(passID), name(name), argument(argument),
100 description(description), dependentDialects(dependentDialects),
101 callbacks(callbacks), userData(userData) {
107 StringRef
getName()
const override {
return name; }
112 MlirDialectRegistry cRegistry =
wrap(®istry);
137 void *clonedUserData = callbacks.
clone(userData);
138 return std::make_unique<ExternalPass>(id, name, argument, description,
140 callbacks, clonedUserData);
146 std::string argument;
147 std::string description;
148 std::vector<MlirDialectHandle> dependentDialects;
157 intptr_t nDependentDialects,
164 {dependentDialects,
static_cast<size_t>(nDependentDialects)}, callbacks,
169 unwrap(pass)->signalPassFailure();
Include the generated interface declarations.
This pass class wraps external passes defined in other languages using the MLIR C-interface.
MlirLogicalResult mlirParsePassPipeline(MlirOpPassManager passManager, MlirStringRef pipeline)
Parse a textual MLIR pass pipeline and add it to the provided OpPassManager.
#define DEFINE_C_API_PTR_METHODS(name, cpptype)
MlirOpPassManager mlirOpPassManagerGetNestedUnder(MlirOpPassManager passManager, MlirStringRef operationName)
Nest an OpPassManager under the provided OpPassManager, the nested passmanager will only run on opera...
ExternalPass(TypeID passID, StringRef name, StringRef argument, StringRef description, Optional< StringRef > opName, ArrayRef< MlirDialectHandle > dependentDialects, MlirExternalPassCallbacks callbacks, void *userData)
The main pass manager and pipeline builder.
void *(* clone)(void *userData)
This callback is called when the pass is cloned.
MlirOpPassManager mlirPassManagerGetNestedUnder(MlirPassManager passManager, MlirStringRef operationName)
Nest an OpPassManager under the top-level PassManager, the nested passmanager will only run on operat...
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...
void mlirPassManagerDestroy(MlirPassManager passManager)
Destroy the provided PassManager.
MlirLogicalResult(* initialize)(MlirContext ctx, void *userData)
This callback is optional.
void mlirExternalPassSignalFailure(MlirExternalPass pass)
This signals that the pass has failed.
void runOnOperation() override
The polymorphic API that runs the pass over the currently held operation.
A simple raw ostream subclass that forwards write_impl calls to the user-supplied callback together w...
void mlirPassManagerEnableIRPrinting(MlirPassManager passManager)
Enable mlir-print-ir-after-all.
This class provides an efficient unique identifier for a specific C++ type.
void signalPassFailure()
Signal that some invariant was broken when running.
StringRef getStringRef() const
Return the name of this operation. This always succeeds.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
This class represents an efficient way to signal success or failure.
StringRef getName() const override
Returns the derived pass name.
std::unique_ptr< Pass > clonePass() const override
Create a copy of this pass, ignoring statistics and options.
void mlirPassManagerEnableVerifier(MlirPassManager passManager, bool enable)
Enable / disable verify-each.
A logical result value, essentially a boolean with named states.
Optional< StringRef > getOpName() const
Returns the name of the operation that this pass operates on, or None if this is a generic OperationP...
void(* run)(MlirOperation op, MlirExternalPass pass, void *userData)
This callback is called when the pass is run.
StringRef getArgument() const override
Return the command line argument used when registering this pass.
size_t length
Length of the fragment.
Structure of external MlirPass callbacks.
A pointer to a sized fragment of a string, not necessarily null-terminated.
void getDependentDialects(DialectRegistry ®istry) const override
Register dependent dialects for the current pass.
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Operation * getOperation()
Return the current operation being transformed.
void(* MlirStringCallback)(MlirStringRef, void *)
A callback for returning string references.
void(* destruct)(void *userData)
This callback is called when the pass is destroyed This is analogous to a C++ pass destructor...
LogicalResult parsePassPipeline(StringRef pipeline, OpPassManager &pm, raw_ostream &errorStream=llvm::errs())
Parse the textual representation of a pass pipeline, adding the result to 'pm' on success...
bool canScheduleOn(RegisteredOperationName opName) const override
Indicate if the current pass can be scheduled on the given operation type.
StringRef getDescription() const override
Return the command line description used when registering this pass.
The abstract base pass class.
MLIRContext is the top-level object for a collection of MLIR operations.
void mlirPrintPassPipeline(MlirOpPassManager passManager, MlirStringCallback callback, void *userData)
Print a textual MLIR pass pipeline by sending chunks of the string representation and forwarding user...
void mlirOpPassManagerAddOwnedPass(MlirOpPassManager passManager, MlirPass pass)
Add a pass and transfer ownership to the provided mlirOpPassManager.
MlirOpPassManager mlirPassManagerGetAsOpPassManager(MlirPassManager passManager)
Cast a top-level PassManager to a generic OpPassManager.
LogicalResult initialize(MLIRContext *ctx) override
Initialize any complex state necessary for running this pass.
void mlirPassManagerAddOwnedPass(MlirPassManager passManager, MlirPass pass)
Add a pass and transfer ownership to the provided top-level mlirPassManager.
void(* construct)(void *userData)
This callback is called from the pass is created.
This is a "type erased" representation of a registered operation.
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
MlirPassManager mlirPassManagerCreate(MlirContext ctx)
Create a new top-level PassManager.
MlirLogicalResult mlirPassManagerRun(MlirPassManager passManager, MlirModule module)
Run the provided passManager on the given module.
MLIR_CAPI_EXPORTED void mlirDialectHandleInsertDialect(MlirDialectHandle, MlirDialectRegistry)
Inserts the dialect associated with the provided dialect handle into the provided dialect registry...