[Mlir-commits] [mlir] [mlir] Improve doc in `OpFormatGen.cpp` (NFC) (PR #117564)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Nov 25 06:42:11 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: lorenzo chelini (chelini)

<details>
<summary>Changes</summary>

The comment is misleading because attributes do not have `elidePrintingDefaultValue` bit. It appears that `elidePrintingDefaultValue` was never merged upstream (see: https://reviews.llvm.org/D135398 ), but the comment was likely introduced by mistake in a later revision (https://reviews.llvm.org/D135993.).

---
Full diff: https://github.com/llvm/llvm-project/pull/117564.diff


1 Files Affected:

- (modified) mlir/tools/mlir-tblgen/OpFormatGen.cpp (+5-4) 


``````````diff
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 8d2e15a941370c..03929eaaf55ff1 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -2033,8 +2033,8 @@ static void genPropDictPrinter(OperationFormat &fmt, Operator &op,
   for (const NamedAttribute *namedAttr : fmt.usedAttributes)
     body << "  elidedProps.push_back(\"" << namedAttr->name << "\");\n";
 
-  // Add code to check attributes for equality with the default value
-  // for attributes with the elidePrintingDefaultValue bit set.
+  // Add code to check attributes for equality with their default values.
+  // Default-valued attributes will not be printed when their value matches the default.
   for (const NamedAttribute &namedAttr : op.getAttributes()) {
     const Attribute &attr = namedAttr.attr;
     if (!attr.isDerivedAttr() && attr.hasDefaultValue()) {
@@ -2080,8 +2080,9 @@ static void genAttrDictPrinter(OperationFormat &fmt, Operator &op,
     body << "  elidedAttrs.push_back(\"" << key << "\");\n";
   for (const NamedAttribute *attr : fmt.usedAttributes)
     body << "  elidedAttrs.push_back(\"" << attr->name << "\");\n";
-  // Add code to check attributes for equality with the default value
-  // for attributes with the elidePrintingDefaultValue bit set.
+  
+  // Add code to check attributes for equality with their default values.
+  // Default-valued attributes will not be printed when their value matches the default.
   for (const NamedAttribute &namedAttr : op.getAttributes()) {
     const Attribute &attr = namedAttr.attr;
     if (!attr.isDerivedAttr() && attr.hasDefaultValue()) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/117564


More information about the Mlir-commits mailing list