[Mlir-commits] [mlir] [MLIR][Python] Add bindings for PDL native rewrite function registering (PR #159926)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Sep 20 23:29:20 PDT 2025
================
@@ -76,10 +118,27 @@ class PyFrozenRewritePatternSet {
/// Create the `mlir.rewrite` here.
void mlir::python::populateRewriteSubmodule(nb::module_ &m) {
+ nb::class_<MlirPatternRewriter>(m, "PatternRewriter");
//----------------------------------------------------------------------------
- // Mapping of the top-level PassManager
+ // Mapping of the PDLResultList and PDLModule
//----------------------------------------------------------------------------
#if MLIR_ENABLE_PDL_IN_PATTERNMATCH
+ nb::class_<MlirPDLResultList>(m, "PDLResultList")
+ .def("push_back",
+ [](MlirPDLResultList results, const PyValue &value) {
+ mlirPDLResultListPushBackValue(results, value);
+ })
+ .def("push_back",
+ [](MlirPDLResultList results, const PyOperation &op) {
+ mlirPDLResultListPushBackOperation(results, op);
+ })
+ .def("push_back",
+ [](MlirPDLResultList results, const PyType &type) {
+ mlirPDLResultListPushBackType(results, type);
+ })
+ .def("push_back", [](MlirPDLResultList results, const PyAttribute &attr) {
+ mlirPDLResultListPushBackAttribute(results, attr);
+ });
----------------
PragmaTwice wrote:
Done in https://github.com/llvm/llvm-project/pull/159926/commits/bf7940966941de09273a170c98fa5e6ffbdaf867.
https://github.com/llvm/llvm-project/pull/159926
More information about the Mlir-commits
mailing list