@@ -2008,18 +2008,25 @@ static void genNonDefaultValueCheck(MethodBody &body, const Operator &op,
2008
2008
<< " () != " << propElement.getVar ()->prop .getDefaultValue ();
2009
2009
}
2010
2010
2011
+ // / Elide the variadic segment size properties if necessary.
2012
+ // / Pushes elided attribute names in `elidedStorage`.
2013
+ static void genVariadicSegmentElision (OperationFormat &fmt, Operator &op,
2014
+ MethodBody &body,
2015
+ const char *elidedStorage) {
2016
+ if (!fmt.allOperands &&
2017
+ op.getTrait (" ::mlir::OpTrait::AttrSizedOperandSegments" ))
2018
+ body << " " << elidedStorage << " .push_back(\" operandSegmentSizes\" );\n " ;
2019
+ if (!fmt.allResultTypes &&
2020
+ op.getTrait (" ::mlir::OpTrait::AttrSizedResultSegments" ))
2021
+ body << " " << elidedStorage << " .push_back(\" resultSegmentSizes\" );\n " ;
2022
+ }
2023
+
2011
2024
// / Generate the printer for the 'prop-dict' directive.
2012
2025
static void genPropDictPrinter (OperationFormat &fmt, Operator &op,
2013
2026
MethodBody &body) {
2014
2027
body << " ::llvm::SmallVector<::llvm::StringRef, 2> elidedProps;\n " ;
2015
2028
2016
- // Elide the variadic segment size properties if necessary.
2017
- if (!fmt.allOperands &&
2018
- op.getTrait (" ::mlir::OpTrait::AttrSizedOperandSegments" ))
2019
- body << " elidedProps.push_back(\" operandSegmentSizes\" );\n " ;
2020
- if (!fmt.allResultTypes &&
2021
- op.getTrait (" ::mlir::OpTrait::AttrSizedResultSegments" ))
2022
- body << " elidedProps.push_back(\" resultSegmentSizes\" );\n " ;
2029
+ genVariadicSegmentElision (fmt, op, body, " elidedProps" );
2023
2030
2024
2031
for (const NamedProperty *namedProperty : fmt.usedProperties )
2025
2032
body << " elidedProps.push_back(\" " << namedProperty->name << " \" );\n " ;
@@ -2066,13 +2073,9 @@ static void genPropDictPrinter(OperationFormat &fmt, Operator &op,
2066
2073
static void genAttrDictPrinter (OperationFormat &fmt, Operator &op,
2067
2074
MethodBody &body, bool withKeyword) {
2068
2075
body << " ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;\n " ;
2069
- // Elide the variadic segment size attributes if necessary.
2070
- if (!fmt.allOperands &&
2071
- op.getTrait (" ::mlir::OpTrait::AttrSizedOperandSegments" ))
2072
- body << " elidedAttrs.push_back(\" operandSegmentSizes\" );\n " ;
2073
- if (!fmt.allResultTypes &&
2074
- op.getTrait (" ::mlir::OpTrait::AttrSizedResultSegments" ))
2075
- body << " elidedAttrs.push_back(\" resultSegmentSizes\" );\n " ;
2076
+
2077
+ genVariadicSegmentElision (fmt, op, body, " elidedAttrs" );
2078
+
2076
2079
for (const StringRef key : fmt.inferredAttributes .keys ())
2077
2080
body << " elidedAttrs.push_back(\" " << key << " \" );\n " ;
2078
2081
for (const NamedAttribute *attr : fmt.usedAttributes )
0 commit comments