[PATCH] D79004: [mlir][assemblyFormat] Fix bug when using AttrSizedOperandSegments trait with only non-buildable operand types

Jean-Michel Gorius via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 09:39:45 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGedb77864ef78: [mlir][assemblyFormat] Fix bug when using AttrSizedOperandSegments trait with… (authored by maerhart, committed by Kayjukh).

Repository:
  rG LLVM Github Monorepo

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
@@ -1258,6 +1258,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.260670.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200428/260377bb/attachment.bin>


More information about the llvm-commits mailing list