diff options
| author | Mehdi Amini <joker.eph@gmail.com> | 2020-11-04 00:08:35 +0000 |
|---|---|---|
| committer | Mehdi Amini <joker.eph@gmail.com> | 2020-11-04 17:29:49 +0000 |
| commit | aeb4b1a9d8c9f9c4a4530cd3f2394b52c2187d51 (patch) | |
| tree | 737ce2923b7e1123378cd69c3ccdcc6342b64829 /mlir/lib/CAPI/IR/Pass.cpp | |
| parent | ecbd0413af5abdb08046b50f526da4722aafff2b (diff) | |
Add facilities to print/parse a pass pipeline through the C API
This also includes and exercise a register function for individual
passes.
Differential Revision: https://reviews.llvm.org/D90728
Diffstat (limited to 'mlir/lib/CAPI/IR/Pass.cpp')
| -rw-r--r-- | mlir/lib/CAPI/IR/Pass.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mlir/lib/CAPI/IR/Pass.cpp b/mlir/lib/CAPI/IR/Pass.cpp index 7d35875d28a6..c67cd474abbe 100644 --- a/mlir/lib/CAPI/IR/Pass.cpp +++ b/mlir/lib/CAPI/IR/Pass.cpp @@ -28,6 +28,11 @@ void mlirPassManagerDestroy(MlirPassManager passManager) { delete unwrap(passManager); } +MlirOpPassManager +mlirPassManagerGetAsOpPassManager(MlirPassManager passManager) { + return wrap(static_cast<OpPassManager *>(unwrap(passManager))); +} + MlirLogicalResult mlirPassManagerRun(MlirPassManager passManager, MlirModule module) { return wrap(unwrap(passManager)->run(unwrap(module))); @@ -51,3 +56,16 @@ void mlirOpPassManagerAddOwnedPass(MlirOpPassManager passManager, MlirPass pass) { unwrap(passManager)->addPass(std::unique_ptr<Pass>(unwrap(pass))); } + +void mlirPrintPassPipeline(MlirOpPassManager passManager, + MlirStringCallback callback, void *userData) { + detail::CallbackOstream stream(callback, userData); + unwrap(passManager)->printAsTextualPipeline(stream); +} + +MlirLogicalResult mlirParsePassPipeline(MlirOpPassManager passManager, + MlirStringRef pipeline) { + // TODO: errors are sent to std::errs() at the moment, we should pass in a + // stream and redirect to a diagnostic. + return wrap(mlir::parsePassPipeline(unwrap(pipeline), *unwrap(passManager))); +} |
