@@ -339,10 +339,8 @@ struct OperationFormat {
339339 Optional
340340 };
341341
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()) {
346344 operandTypes.resize (op.getNumOperands (), TypeResolution ());
347345 resultTypes.resize (op.getNumResults (), TypeResolution ());
348346
@@ -397,7 +395,7 @@ struct OperationFormat {
397395 // / A flag indicating if this operation has the SingleBlock trait.
398396 bool hasSingleBlockTrait;
399397
400- // / Indicate whether attribute are stored in properties.
398+ // / Indicate whether we need to use properties for the current operator .
401399 bool useProperties;
402400
403401 // / Indicate whether prop-dict is used in the format
@@ -1275,8 +1273,8 @@ static void genAttrParser(AttributeVariable *attr, MethodBody &body,
12751273// 'prop-dict' dictionary attr.
12761274static void genParsedAttrPropertiesSetter (OperationFormat &fmt, Operator &op,
12771275 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 )
12801278 return ;
12811279
12821280 SmallVector<MethodParameter> paramList;
@@ -1621,8 +1619,10 @@ void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
16211619 body.unindent () << " }\n " ;
16221620 body.unindent ();
16231621 } 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+ }
16261626 } else if (auto *customDir = dyn_cast<CustomDirective>(element)) {
16271627 genCustomDirectiveParser (customDir, body, useProperties, opCppClassName);
16281628 } else if (isa<OperandsDirective>(element)) {
@@ -2047,9 +2047,11 @@ static void genPropDictPrinter(OperationFormat &fmt, Operator &op,
20472047 }
20482048 }
20492049
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+ }
20532055}
20542056
20552057// / Generate the printer for the 'attr-dict' directive.
@@ -3771,7 +3773,8 @@ LogicalResult OpFormatParser::verifyOptionalGroupElement(SMLoc loc,
37713773// Interface
37723774// ===----------------------------------------------------------------------===//
37733775
3774- void mlir::tblgen::generateOpFormat (const Operator &constOp, OpClass &opClass) {
3776+ void mlir::tblgen::generateOpFormat (const Operator &constOp, OpClass &opClass,
3777+ bool hasProperties) {
37753778 // TODO: Operator doesn't expose all necessary functionality via
37763779 // the const interface.
37773780 Operator &op = const_cast <Operator &>(constOp);
@@ -3782,7 +3785,7 @@ void mlir::tblgen::generateOpFormat(const Operator &constOp, OpClass &opClass) {
37823785 llvm::SourceMgr mgr;
37833786 mgr.AddNewSourceBuffer (
37843787 llvm::MemoryBuffer::getMemBuffer (op.getAssemblyFormat ()), SMLoc ());
3785- OperationFormat format (op);
3788+ OperationFormat format (op, hasProperties );
37863789 OpFormatParser parser (mgr, format, op);
37873790 FailureOr<std::vector<FormatElement *>> elements = parser.parse ();
37883791 if (failed (elements)) {
0 commit comments