[Mlir-commits] [mlir] [mlir][PDL] PDLToPDLInterp: Use the pdl pattern name in the generated rewriter. (PR #149481)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jul 18 02:01:18 PDT 2025


https://github.com/jumerckx created https://github.com/llvm/llvm-project/pull/149481

Before, the rewriters generated by `convert-pdl-to-pdl-interp` had a generic `"pdl_generated_rewriter"` name. With this change, the name from the original pdl pattern is kept for the rewriter. This makes it easier to relate the two.

>From 2462896361bab852fe8ebda0ebc6d78708c0a0c1 Mon Sep 17 00:00:00 2001
From: jumerckx <31353884+jumerckx at users.noreply.github.com>
Date: Fri, 18 Jul 2025 10:54:52 +0200
Subject: [PATCH] PDLToPDLInterp: Use the pdl pattern name in the generated
 rewriter.

---
 mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
index 7d20109b3db59..3a1c1fd2d57af 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
@@ -632,8 +632,14 @@ void PatternLowering::generate(SuccessNode *successNode, Block *&currentBlock) {
 SymbolRefAttr PatternLowering::generateRewriter(
     pdl::PatternOp pattern, SmallVectorImpl<Position *> &usedMatchValues) {
   builder.setInsertionPointToEnd(rewriterModule.getBody());
+  // Get the pattern name if available, otherwise use default
+  StringRef rewriterName = "pdl_generated_rewriter";
+  if (auto symName = pattern.getSymName()) {
+    rewriterName = symName.value();
+  }
+  
   auto rewriterFunc = builder.create<pdl_interp::FuncOp>(
-      pattern.getLoc(), "pdl_generated_rewriter",
+      pattern.getLoc(), rewriterName,
       builder.getFunctionType({}, {}));
   rewriterSymbolTable.insert(rewriterFunc);
 



More information about the Mlir-commits mailing list