From 72a8e79d53f3ec5c4a49a1d8df6686803849552e Mon Sep 17 00:00:00 2001 From: Lorenzo Chelini Date: Sat, 23 Nov 2024 16:28:09 +0100 Subject: [PATCH 1/2] [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 8d2e15a941370..03929eaaf55ff 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()) { From f7097b2c71baa2bbeaa2fe661fdde6ef21998fc3 Mon Sep 17 00:00:00 2001 From: lorenzo chelini Date: Mon, 25 Nov 2024 15:49:14 +0100 Subject: [PATCH 2/2] clang-format --- mlir/tools/mlir-tblgen/OpFormatGen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp index 03929eaaf55ff..097a578cb2025 100644 --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -2034,7 +2034,8 @@ static void genPropDictPrinter(OperationFormat &fmt, Operator &op, body << " elidedProps.push_back(\"" << namedAttr->name << "\");\n"; // Add code to check attributes for equality with their default values. - // Default-valued attributes will not be printed when their value matches the default. + // 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,9 +2081,10 @@ 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 their default values. - // Default-valued attributes will not be printed when their value matches the default. + // 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()) {