[Mlir-commits] [mlir] [MLIR][Python] Support Python-defined rewrite patterns (PR #162699)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Oct 10 19:55:11 PDT 2025
================
@@ -332,6 +333,86 @@ MlirRewriterBase mlirPatternRewriterAsBase(MlirPatternRewriter rewriter) {
return wrap(static_cast<mlir::RewriterBase *>(unwrap(rewriter)));
}
+//===----------------------------------------------------------------------===//
+/// RewritePattern API
+//===----------------------------------------------------------------------===//
+
+inline const mlir::RewritePattern *unwrap(MlirRewritePattern pattern) {
+ assert(pattern.ptr && "expected non-null pattern");
+ return static_cast<const mlir::RewritePattern *>(pattern.ptr);
+}
+
+inline MlirRewritePattern wrap(const mlir::RewritePattern *pattern) {
+ return {pattern};
+}
----------------
PragmaTwice wrote:
Ahhh great thanks! It solved my question that some of these wrap/unwrap is generated (i cannot find its definition) but in this file (Rewrite.cpp) it seems all manually defined. Finally know how and where to generate them.
https://github.com/llvm/llvm-project/pull/162699
More information about the Mlir-commits
mailing list