@@ -339,10 +339,8 @@ struct OperationFormat {
339
339
Optional
340
340
};
341
341
342
- OperationFormat (const Operator &op)
343
- : useProperties(op.getDialect().usePropertiesForAttributes() &&
344
- !op.getAttributes().empty()),
345
- opCppClassName (op.getCppClassName()) {
342
+ OperationFormat (const Operator &op, bool hasProperties)
343
+ : useProperties(hasProperties), opCppClassName(op.getCppClassName()) {
346
344
operandTypes.resize (op.getNumOperands (), TypeResolution ());
347
345
resultTypes.resize (op.getNumResults (), TypeResolution ());
348
346
@@ -397,7 +395,7 @@ struct OperationFormat {
397
395
// / A flag indicating if this operation has the SingleBlock trait.
398
396
bool hasSingleBlockTrait;
399
397
400
- // / Indicate whether attribute are stored in properties.
398
+ // / Indicate whether we need to use properties for the current operator .
401
399
bool useProperties;
402
400
403
401
// / Indicate whether prop-dict is used in the format
@@ -1275,8 +1273,8 @@ static void genAttrParser(AttributeVariable *attr, MethodBody &body,
1275
1273
// 'prop-dict' dictionary attr.
1276
1274
static void genParsedAttrPropertiesSetter (OperationFormat &fmt, Operator &op,
1277
1275
OpClass &opClass) {
1278
- // Not required unless 'prop-dict' is present.
1279
- if (!fmt.hasPropDict )
1276
+ // Not required unless 'prop-dict' is present or we are not using properties .
1277
+ if (!fmt.hasPropDict || !fmt. useProperties )
1280
1278
return ;
1281
1279
1282
1280
SmallVector<MethodParameter> paramList;
@@ -1621,8 +1619,10 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
1621
1619
body.unindent () << " }\n " ;
1622
1620
body.unindent ();
1623
1621
} else if (isa<PropDictDirective>(element)) {
1624
- body << " if (parseProperties(parser, result))\n "
1625
- << " return ::mlir::failure();\n " ;
1622
+ if (useProperties) {
1623
+ body << " if (parseProperties(parser, result))\n "
1624
+ << " return ::mlir::failure();\n " ;
1625
+ }
1626
1626
} else if (auto *customDir = dyn_cast<CustomDirective>(element)) {
1627
1627
genCustomDirectiveParser (customDir, body, useProperties, opCppClassName);
1628
1628
} else if (isa<OperandsDirective>(element)) {
@@ -2047,9 +2047,11 @@ static void genPropDictPrinter(OperationFormat &fmt, Operator &op,
2047
2047
}
2048
2048
}
2049
2049
2050
- body << " _odsPrinter << \" \" ;\n "
2051
- << " printProperties(this->getContext(), _odsPrinter, "
2052
- " getProperties(), elidedProps);\n " ;
2050
+ if (fmt.useProperties ) {
2051
+ body << " _odsPrinter << \" \" ;\n "
2052
+ << " printProperties(this->getContext(), _odsPrinter, "
2053
+ " getProperties(), elidedProps);\n " ;
2054
+ }
2053
2055
}
2054
2056
2055
2057
// / Generate the printer for the 'attr-dict' directive.
@@ -3771,7 +3773,8 @@ LogicalResult OpFormatParser::verifyOptionalGroupElement(SMLoc loc,
3771
3773
// Interface
3772
3774
// ===----------------------------------------------------------------------===//
3773
3775
3774
- void mlir::tblgen::generateOpFormat (const Operator &constOp, OpClass &opClass) {
3776
+ void mlir::tblgen::generateOpFormat (const Operator &constOp, OpClass &opClass,
3777
+ bool hasProperties) {
3775
3778
// TODO: Operator doesn't expose all necessary functionality via
3776
3779
// the const interface.
3777
3780
Operator &op = const_cast <Operator &>(constOp);
@@ -3782,7 +3785,7 @@ void mlir::tblgen::generateOpFormat(const Operator &constOp, OpClass &opClass) {
3782
3785
llvm::SourceMgr mgr;
3783
3786
mgr.AddNewSourceBuffer (
3784
3787
llvm::MemoryBuffer::getMemBuffer (op.getAssemblyFormat ()), SMLoc ());
3785
- OperationFormat format (op);
3788
+ OperationFormat format (op, hasProperties );
3786
3789
OpFormatParser parser (mgr, format, op);
3787
3790
FailureOr<std::vector<FormatElement *>> elements = parser.parse ();
3788
3791
if (failed (elements)) {
0 commit comments