[Mlir-commits] [mlir] [MLIR][LLVM] Cleanup custom attr-dict printing (PR #115765)

Tobias Gysi llvmlistbot at llvm.org
Mon Nov 11 23:10:26 PST 2024


https://github.com/gysit updated https://github.com/llvm/llvm-project/pull/115765

>From 54750b1197b5f2d8564a7cc75cda26e0ea17cc6a Mon Sep 17 00:00:00 2001
From: Tobias Gysi <tobias.gysi at nextsilicon.com>
Date: Mon, 11 Nov 2024 20:41:43 +0000
Subject: [PATCH] [MLIR][LLVM] Cleanup attr-dict printing (NFC)

This commit simplifies the custom attribute dictionary printing
and uses it only for printing ops that have fast math flags.
---
 mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td |  5 ++---
 mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp  | 10 +---------
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 81e9f69f15acf6..34f3e4b33b8295 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -69,8 +69,7 @@ class LLVM_IntArithmeticOpWithOverflowFlag<string mnemonic, string instName,
     $res = op;
   }];
   let assemblyFormat = [{
-    $lhs `,` $rhs `` custom<OverflowFlags>($overflowFlags)
-    `` custom<LLVMOpAttrs>(attr-dict) `:` type($res)
+    $lhs `,` $rhs `` custom<OverflowFlags>($overflowFlags) attr-dict `:` type($res)
   }];
   string llvmBuilder =
     "$res = builder.Create" # instName #
@@ -88,7 +87,7 @@ class LLVM_IntArithmeticOpWithExactFlag<string mnemonic, string instName,
     $res = op;
   }];
   let assemblyFormat = [{
-    (`exact` $isExact^)? $lhs `,` $rhs custom<LLVMOpAttrs>(attr-dict) `:` type($res)
+    (`exact` $isExact^)? $lhs `,` $rhs attr-dict `:` type($res)
   }];
   string llvmBuilder =
     "$res = builder.Create" # instName #
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 6b2d8943bf4885..d4f8c4c1faf956 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -140,15 +140,7 @@ static ParseResult parseLLVMOpAttrs(OpAsmParser &parser,
 static void printLLVMOpAttrs(OpAsmPrinter &printer, Operation *op,
                              DictionaryAttr attrs) {
   auto filteredAttrs = processFMFAttr(attrs.getValue());
-  if (auto iface = dyn_cast<IntegerOverflowFlagsInterface>(op)) {
-    printer.printOptionalAttrDict(
-        filteredAttrs, /*elidedAttrs=*/{iface.getOverflowFlagsAttrName()});
-  } else if (auto iface = dyn_cast<ExactFlagInterface>(op)) {
-    printer.printOptionalAttrDict(filteredAttrs,
-                                  /*elidedAttrs=*/{iface.getIsExactName()});
-  } else {
-    printer.printOptionalAttrDict(filteredAttrs);
-  }
+  printer.printOptionalAttrDict(filteredAttrs);
 }
 
 /// Verifies `symbol`'s use in `op` to ensure the symbol is a valid and



More information about the Mlir-commits mailing list