[Mlir-commits] [mlir] [MLIR][Python] Add bindings for PDL constraint function registering (PR #160520)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Sep 24 23:11:09 PDT 2025
PragmaTwice wrote:
> Cool this looks great. Just wondering - have you noticed any other missing functionality for writing diverse rewrites using PDL?
I think the current Python-side PDL capabilities already make it possible to express most rewrite patterns. One possible future extension would be to expose some of the `PatternRewriter` APIs to enhance the expressiveness of native constraint/rewrite functions (e.g. expose the insertion point of the current `PatternRewriter`?).
Take a simple example: suppose we want to rewrite a constant with value `1` into `op1`, and a constant with value `2` into `op2`. Right now in PDL this can be done by defining two separate patterns—one that matches constant `1` and another that matches constant `2`. But if we were able to create new ops directly in native rewrite functions, we could handle this with a single pattern: inside the native rewrite function, we could branch on the constant’s value and create different ops accordingly.
In short, the current PDL covers most patterns well, but some more complex logic still needs to be “expanded” into multiple patterns. That’s an area we might consider enhancing in the future.
https://github.com/llvm/llvm-project/pull/160520
More information about the Mlir-commits
mailing list