[Mlir-commits] [mlir] [mlir] Improve doc in `OpFormatGen.cpp` (NFC) (PR #117564)
lorenzo chelini
llvmlistbot at llvm.org
Mon Nov 25 06:41:31 PST 2024
https://github.com/chelini created https://github.com/llvm/llvm-project/pull/117564
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.).
>From e5a29ce13f5b89f3c292b9697325091ab3274afb Mon Sep 17 00:00:00 2001
From: Lorenzo Chelini <l.chelini at icloud.com>
Date: Sat, 23 Nov 2024 16:28:09 +0100
Subject: [PATCH] [mlir] Improve doc in `OpFormatGen.cpp` (NFC)
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.).
---
mlir/tools/mlir-tblgen/OpFormatGen.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
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()) {
More information about the Mlir-commits
mailing list