summaryrefslogtreecommitdiff
path: root/mlir/lib/CAPI/IR/Pass.cpp
AgeCommit message (Collapse)Author
2025-10-09[MLIR][Python] Expose `PassManager::enableStatistics` to CAPI and Python ↵Twice
(#162591) `PassManager::enableStatistics` seems currently missing in both C API and Python bindings. So here we added them in this PR, which includes the `PassDisplayMode` enum type and the `EnableStatistics` method.
2025-09-08[MLIR][Python] Support Python-defined passes in MLIR (#156000)Twice
It closes #155996. This PR added a method `add(callable, ..)` to `mlir.passmanager.PassManager` to accept a callable object for defining passes in the Python side. This is a simple example of a Python-defined pass. ```python from mlir.passmanager import PassManager def demo_pass_1(op): # do something with op pass class DemoPass: def __init__(self, ...): pass def __call__(op): # do something pass demo_pass_2 = DemoPass(..) pm = PassManager('any', ctx) pm.add(demo_pass_1) pm.add(demo_pass_2) pm.add("registered-passes") pm.run(..) ``` --------- Co-authored-by: cnb.bsD2OPwAgEA <QejD2DJ2eEahUVy6Zg0aZI+cnb.bsD2OPwAgEA@noreply.cnb.cool> Co-authored-by: Maksim Levental <maksim.levental@gmail.com>
2025-07-16[mlir] Add Python bindings to enable default passmanager timing (#149087)Martin Erhart
2024-12-05[MLIR][Python] enhance python ir printing with pringing flags (#117836)Yuanqiang Liu
Close https://github.com/llvm/llvm-project/pull/65854
2024-11-23[MLIR][Python] Add the `--mlir-print-ir-tree-dir` to the C and Python API ↵Mehdi Amini
(#117339)
2024-09-18[MLIR] [Python] align python ir printing with mlir-print-ir-after-all (#107522)Bimo
When using the `enable_ir_printing` API from Python, it invokes IR printing with default args, printing the IR before each pass and printing IR after pass only if there have been changes. This PR attempts to align the `enable_ir_printing` API with the documentation
2023-03-01[mlir][CAPI] Allow running pass manager on any operationrkayaith
`mlirPassManagerRun` is currently restricted to running on `builtin.module` ops, but this restriction doesn't exist on the C++ side. This renames it to `mlirPassManagerRunOnOp` and updates it to take `MlirOperation` instead of `MlirModule`. Depends on D143352 Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D143354
2023-01-14[mlir] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-13[mlir] Add #include <optional> (NFC)Kazu Hirata
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-03[mlir] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-03[mlir][CAPI] Include anchor op in mlirParsePassPipelinerkayaith
The pipeline string must now include the pass manager's anchor op. This makes the parse API properly roundtrip the printed form of a pass manager. Since this is already an API break, I also added an extra callback argument which is used for reporting errors. The old functionality of appending to an existing pass manager is available through `mlirOpPassManagerAddPipeline`. Reviewed By: mehdi_amini, ftynse Differential Revision: https://reviews.llvm.org/D136403
2022-10-27[mlir][CAPI] Allow specifying pass manager anchorrkayaith
This adds a new function for creating pass managers that takes an argument for the anchor string. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D136404
2022-10-27[mlir][python] Include pipeline parse errors in exception messagerkayaith
Currently any errors during pipeline parsing are reported to stderr. This adds a new pipeline parsing function to the C api that reports errors through a callback, and updates the python bindings to use it. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D136402
2022-04-04[mlir][capi] Add external pass creation to MLIR C-APIDaniel Resnick
Adds the ability to create external passes using the C-API. This allows passes to be written in C or languages that use the C-bindings. Differential Revision: https://reviews.llvm.org/D121866
2021-04-16[mlir][python] Add simple debugging and printing helpersNicolas Vasilache
Differential Revision: https://reviews.llvm.org/D100643
2020-11-04Switch from C-style comments `/* ... */` to C++ style `//` (NFC)Mehdi Amini
This is mostly a scripted update, it may not be perfect. function replace() { FROM=$1 TO=$2 git grep "$FROM" $REPO_PATH |cut -f 1 -d : | sort -u | \ while read file; do sed -i "s#$FROM#$TO#" $file ; done } replace '|\*===----------------------------------------------------------------------===\*|$' '//===----------------------------------------------------------------------===//' replace '^/\* =' '//==' replace '^/\*=' '//=' replace '^\\\*=' '//=' replace '^|\*' '//' replace ' \*|$' '' replace '=\*\\$' '=//' replace '== \*/$' '===//' replace '==\*/$' '==//' replace '^/\*\*\(.*\)\*/$' '///\1' replace '^/\*\(.*\)\*/$' '//\1' replace '//============================================================================//' '//===----------------------------------------------------------------------===//' Differential Revision: https://reviews.llvm.org/D90732
2020-11-04Add facilities to print/parse a pass pipeline through the C APIMehdi Amini
This also includes and exercise a register function for individual passes. Differential Revision: https://reviews.llvm.org/D90728
2020-11-04Add a basic C API for the MLIR PassManager as well as a basic TableGen ↵Mehdi Amini
backend for creating passes This is exposing the basic functionalities (create, nest, addPass, run) of the PassManager through the C API in the new header: `include/mlir-c/Pass.h`. In order to exercise it in the unit-test, a basic TableGen backend is also provided to generate a simple C wrapper around the pass constructor. It is used to expose the libTransforms passes to the C API. Reviewed By: stellaraccident, ftynse Differential Revision: https://reviews.llvm.org/D90667