[PATCH] D79004: [mlir][assemblyFormat] Fix bug when using AttrSizedOperandSegments trait with only non-buildable operand types
Martin Erhart via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 08:02:06 PDT 2020
maerhart updated this revision to Diff 260639.
maerhart added a comment.
Updated the diff to use `parser.getBuilder()` directly instead of creating a fragile local variable.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79004/new/
https://reviews.llvm.org/D79004
Files:
mlir/test/lib/Dialect/Test/TestOps.td
mlir/tools/mlir-tblgen/OpFormatGen.cpp
Index: mlir/tools/mlir-tblgen/OpFormatGen.cpp
===================================================================
--- mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -741,10 +741,8 @@
// Initialize the set of buildable types.
if (!buildableTypes.empty()) {
- body << " Builder &builder = parser.getBuilder();\n";
-
FmtContext typeBuilderCtx;
- typeBuilderCtx.withBuilder("builder");
+ typeBuilderCtx.withBuilder("parser.getBuilder()");
for (auto &it : buildableTypes)
body << " Type odsBuildableType" << it.second << " = "
<< tgfmt(it.first, &typeBuilderCtx) << ";\n";
@@ -867,7 +865,7 @@
OpMethodBody &body) {
if (!allOperands && op.getTrait("OpTrait::AttrSizedOperandSegments")) {
body << " result.addAttribute(\"operand_segment_sizes\", "
- << "builder.getI32VectorAttr({";
+ << "parser.getBuilder().getI32VectorAttr({";
auto interleaveFn = [&](const NamedTypeConstraint &operand) {
// If the operand is variadic emit the parsed size.
if (operand.isVariableLength())
Index: mlir/test/lib/Dialect/Test/TestOps.td
===================================================================
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -1270,6 +1270,16 @@
(`[` $variadic^ `]`)? attr-dict
}]>;
+def FormatTwoVariadicOperandsNoBuildableTypeOp
+ : TEST_Op<"format_two_variadic_operands_no_buildable_type_op",
+ [AttrSizedOperandSegments]> {
+ let arguments = (ins Variadic<AnyType>:$a,
+ Variadic<AnyType>:$b);
+ let assemblyFormat = [{
+ `(` $a `:` type($a) `)` `->` `(` $b `:` type($b) `)` attr-dict
+ }];
+}
+
//===----------------------------------------------------------------------===//
// Test SideEffects
//===----------------------------------------------------------------------===//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79004.260639.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200428/f3e45706/attachment.bin>
More information about the llvm-commits
mailing list