varSuccessors.append(2, varSuccessor);
return success();
}
+static ParseResult parseCustomDirectiveAttributes(OpAsmParser &parser,
+ IntegerAttr &attr,
+ IntegerAttr &optAttr) {
+ if (parser.parseAttribute(attr))
+ return failure();
+ if (succeeded(parser.parseOptionalComma())) {
+ if (parser.parseAttribute(optAttr))
+ return failure();
+ }
+ return success();
+}
//===----------------------------------------------------------------------===//
// Printing
if (!varSuccessors.empty())
printer << ", " << varSuccessors.front();
}
+static void printCustomDirectiveAttributes(OpAsmPrinter &printer,
+ Attribute attribute,
+ Attribute optAttribute) {
+ printer << attribute;
+ if (optAttribute)
+ printer << ", " << optAttribute;
+}
//===----------------------------------------------------------------------===//
// Test IsolatedRegionOp - parse passthrough region arguments.
}];
}
+def FormatCustomDirectiveAttributes
+ : TEST_Op<"format_custom_directive_attributes"> {
+ let arguments = (ins I64Attr:$attr, OptionalAttr<I64Attr>:$optAttr);
+ let assemblyFormat = [{
+ custom<CustomDirectiveAttributes>(
+ $attr, $optAttr
+ )
+ attr-dict
+ }];
+}
+
//===----------------------------------------------------------------------===//
// AllTypesMatch type inference
// CHECK: test.format_custom_directive_operands_and_types %[[I64]] -> (%[[I64]]) : i64 -> (i64)
test.format_custom_directive_operands_and_types %i64 -> (%i64) : i64 -> (i64)
+// CHECK: test.format_custom_directive_attributes 54 : i64
+test.format_custom_directive_attributes 54 : i64
+
+// CHECK: test.format_custom_directive_attributes 54 : i64, 46 : i64
+test.format_custom_directive_attributes 54 : i64, 46 : i64
+
// CHECK: test.format_custom_directive_regions {
// CHECK-NEXT: test.return
// CHECK-NEXT: }
if (var->attr.isOptional())
body << llvm::formatv(" if ({0}Attr)\n ", var->name);
- body << llvm::formatv(
- " result.attributes.addAttribute(\"{0}\", {0}Attr);", var->name);
+ body << llvm::formatv(" result.addAttribute(\"{0}\", {0}Attr);\n",
+ var->name);
} else if (auto *operand = dyn_cast<OperandVariable>(¶m)) {
const NamedTypeConstraint *var = operand->getVar();
if (!var->isOptional())