[mlir] More changes to avoid args now inserted.NFC
authorJacques Pienaar <jpienaar@google.com>
Wed, 14 Oct 2020 17:28:51 +0000 (10:28 -0700)
committerJacques Pienaar <jpienaar@google.com>
Wed, 14 Oct 2020 17:47:45 +0000 (10:47 -0700)
Migrates a bit more from the old/to be deprecated form.

12 files changed:
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
mlir/include/mlir/Dialect/SCF/SCFOps.td
mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/Dialect/Vector/VectorOps.td
mlir/include/mlir/IR/OpBase.td
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp

index 2382253..56bb73f 100644 (file)
@@ -116,8 +116,7 @@ def Async_AwaitOp : Async_Op<"await", [NoSideEffect]> {
   let skipDefaultBuilders = 1;
 
   let builders = [
-    OpBuilder<"mlir::OpBuilder &builder, OperationState &result,"
-              "Value operand, ArrayRef<NamedAttribute> attrs = {}">,
+    OpBuilder<"Value operand, ArrayRef<NamedAttribute> attrs = {}">,
   ];
 
   let extraClassDeclaration = [{
index 5d4443e..1542241 100644 (file)
@@ -537,7 +537,7 @@ def GPU_ReturnOp : GPU_Op<"return", [HasParent<"GPUFuncOp">, NoSideEffect,
     by an invocation of the `gpu.func`.
   }];
 
-  let builders = [OpBuilder<"OpBuilder &builder, OperationState &result", " // empty">];
+  let builders = [OpBuilder<"", " // empty">];
 
   let parser = [{ return parseReturnOp(parser, result); }];
   let printer = [{ p << getOperationName(); }];
index 5b29154..68e2105 100644 (file)
@@ -48,11 +48,10 @@ def Linalg_RangeOp :
     ````
   }];
   let builders = [OpBuilder<
-    "OpBuilder &builder, OperationState &result, Value min, Value max, "
-    "Value step",
+    "Value min, Value max, Value step",
     [{
-      auto rangeType = RangeType::get(builder.getContext());
-      build(builder, result, rangeType, min, max, step);
+      auto rangeType = RangeType::get($_builder.getContext());
+      build($_builder, $_state, rangeType, min, max, step);
     }]>];
 
   // Fully specified by traits.
@@ -65,28 +64,28 @@ class Linalg_ReshapeLikeOp<string mnemonic, list<OpTrait> traits = []> :
   let builders = [
     // Builders for a contracting reshape whose result type is computed from
     // `src` and `reassociation`.
-    OpBuilder<"OpBuilder &b, OperationState &result, Value src, "
+    OpBuilder<"Value src, "
               "ArrayRef<ReassociationExprs> reassociation, "
               "ArrayRef<NamedAttribute> attrs = {}">,
-    OpBuilder<"OpBuilder &b, OperationState &result, Value src, "
+    OpBuilder<"Value src, "
               "ArrayRef<ReassociationIndices> reassociation, "
               "ArrayRef<NamedAttribute> attrs = {}", [{
       auto reassociationMaps =
-          convertReassociationIndicesToMaps(b, reassociation);
-      build(b, result, src, reassociationMaps, attrs);
+          convertReassociationIndicesToMaps($_builder, reassociation);
+      build($_builder, $_state, src, reassociationMaps, attrs);
     }]>,
 
     // Builders for a reshape whose result type is passed explicitly. This may
     // be either a contracting or expanding reshape.
-    OpBuilder<"OpBuilder &b, OperationState &result, Type resultType, "
-              "Value src, ArrayRef<ReassociationExprs> reassociation, "
+    OpBuilder<"Type resultType, Value src, "
+              "ArrayRef<ReassociationExprs> reassociation, "
               "ArrayRef<NamedAttribute> attrs = {}">,
-    OpBuilder<"OpBuilder &b, OperationState &result, Type resultType, "
-              "Value src, ArrayRef<ReassociationIndices> reassociation, "
+    OpBuilder<"Type resultType, Value src, "
+              "ArrayRef<ReassociationIndices> reassociation, "
               "ArrayRef<NamedAttribute> attrs = {}", [{
       auto reassociationMaps =
-          convertReassociationIndicesToMaps(b, reassociation);
-      build(b, result, src, reassociationMaps, attrs);
+          convertReassociationIndicesToMaps($_builder, reassociation);
+      build($_builder, $_state, src, reassociationMaps, attrs);
     }]>
   ];
 
@@ -259,9 +258,7 @@ def Linalg_SliceOp : Linalg_Op<"slice", [
       ```
   }];
 
-  let builders = [OpBuilder<
-    "OpBuilder &b, OperationState &result, Value base, "
-    "ValueRange indexings">];
+  let builders = [OpBuilder<"Value base, ValueRange indexings">];
 
   let extraClassDeclaration = [{
     enum { FirstIndexingOperand = 1 };
index 55df0bc..ba8fa64 100644 (file)
@@ -129,9 +129,9 @@ def CopyOp : LinalgStructured_Op<"copy", [
   // TODO: this should go away once the usage of OptionalAttr triggers emission
   // of builders with default arguments left unspecified.
   let builders = [OpBuilder<
-    "OpBuilder &builder, OperationState &result, Value input, Value output", [{
+    "Value input, Value output", [{
     return build(
-      builder, result, input, output, AffineMapAttr(), AffineMapAttr());
+      $_builder, $_state, input, output, AffineMapAttr(), AffineMapAttr());
   }]>];
 
   let extraClassDeclaration = libraryCallName # [{
@@ -663,24 +663,23 @@ def GenericOp : GenericOpBase<"generic"> {
 
   let builders = [
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
+      "TypeRange resultTensorTypes,"
       "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
       "ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
       "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
       "function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr">,
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, "
       "ValueRange inputs, ValueRange outputBuffers, "
       "ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
       "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
       "function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr">,
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
+      "TypeRange resultTensorTypes,"
       "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
       "ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
       "function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr">,
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, ValueRange inputs, "
+      "ValueRange inputs, "
       "ValueRange outputBuffers, ArrayRef<AffineMap> indexingMaps, "
       "ArrayRef<StringRef> iteratorTypes, "
       "function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr">
@@ -842,24 +841,23 @@ def IndexedGenericOp : GenericOpBase<"indexed_generic"> {
 
   let builders = [
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
+      "TypeRange resultTensorTypes,"
       "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
       "ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
       "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
       "function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> = nullptr">,
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, "
       "ValueRange inputs, ValueRange outputBuffers, "
       "ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
       "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
       "function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> = nullptr">,
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
+      "TypeRange resultTensorTypes,"
       "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
       "ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
       "function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> = nullptr">,
     OpBuilder<
-      "OpBuilder &builder, OperationState &result, ValueRange inputs, "
+      "ValueRange inputs, "
       "ValueRange outputBuffers, ArrayRef<AffineMap> indexingMaps, "
       "ArrayRef<StringRef> iteratorTypes, "
       "function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> = nullptr">
index c217d9a..24dc01d 100644 (file)
@@ -391,8 +391,7 @@ def OpenACC_YieldOp : OpenACC_Op<"yield", [Terminator,
   let arguments = (ins Variadic<AnyType>:$operands);
 
   let builders = [
-    OpBuilder<"OpBuilder &builder, OperationState &result",
-              [{ /* nothing to do */ }]>
+    OpBuilder<"", [{ /* nothing to do */ }]>
   ];
 
   let verifier = ?;
index 476898a..3e7623c 100644 (file)
@@ -238,13 +238,12 @@ def IfOp : SCF_Op<"if",
     OpBuilder<"Value cond, bool withElseRegion">,
     OpBuilder<"TypeRange resultTypes, Value cond, bool withElseRegion">,
     OpBuilder<
-        "OpBuilder &builder, OperationState &result, TypeRange resultTypes, "
-        "Value cond, "
+        "TypeRange resultTypes, Value cond, "
         "function_ref<void(OpBuilder &, Location)> thenBuilder "
         "    = buildTerminatedBody, "
         "function_ref<void(OpBuilder &, Location)> elseBuilder = nullptr">,
     OpBuilder<
-        "OpBuilder &builder, OperationState &result, Value cond, "
+        "Value cond, "
         "function_ref<void(OpBuilder &, Location)> thenBuilder "
         "    = buildTerminatedBody, "
         "function_ref<void(OpBuilder &, Location)> elseBuilder = nullptr">
@@ -431,8 +430,7 @@ def YieldOp : SCF_Op<"yield", [NoSideEffect, ReturnLike, Terminator,
 
   let arguments = (ins Variadic<AnyType>:$results);
   let builders = [
-    OpBuilder<"OpBuilder &builder, OperationState &result",
-              [{ /* nothing to do */ }]>
+    OpBuilder<"", [{ /* nothing to do */ }]>
   ];
   // Override default verifier (defined in SCF_Op), no custom verification
   // needed.
index c3a8679..953fc50 100644 (file)
@@ -163,8 +163,7 @@ def SPV_CompositeInsertOp : SPV_Op<"CompositeInsert", [NoSideEffect]> {
   );
 
   let builders = [
-    OpBuilder<[{OpBuilder &builder, OperationState &state, Value object,
-                Value composite, ArrayRef<int32_t> indices}]>
+    OpBuilder<[{Value object, Value composite, ArrayRef<int32_t> indices}]>
   ];
 }
 
index 235a22a..c6c52f2 100644 (file)
@@ -483,9 +483,9 @@ def Shape_YieldOp : Shape_Op<"yield",
 
   let arguments = (ins Variadic<AnyType>:$operands);
 
-  let builders = [OpBuilder<
-    "OpBuilder &b, OperationState &result", [{ build(b, result, llvm::None); }]
-  >];
+  let builders = [
+    OpBuilder<"", [{ build($_builder, $_state, llvm::None); }]>
+  ];
 
   let verifier = [{ return ::verify(*this); }];
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
@@ -660,8 +660,7 @@ def Shape_AssumingYieldOp : Shape_Op<"assuming_yield",
   let arguments = (ins Variadic<AnyType>:$operands);
 
   let builders = [
-    OpBuilder<"OpBuilder &builder, OperationState &result",
-    [{ /* nothing to do */ }]>
+    OpBuilder<"", [{ /* nothing to do */ }]>
   ];
 
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
index 798df5e..6b60c2f 100644 (file)
@@ -3062,21 +3062,19 @@ def SubViewOp : BaseOpWithOffsetSizesAndStrides<
       "ArrayRef<NamedAttribute> attrs = {}">,
     // Build a SubViewOp with all dynamic entries.
     OpBuilder<
-      "OpBuilder &b, OperationState &result, Value source, "
-      "ValueRange offsets, ValueRange sizes, ValueRange strides, "
+      "Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, "
       "ArrayRef<NamedAttribute> attrs = {}">,
     // Build a SubViewOp with mixed static and dynamic entries
     // and custom result type.
     OpBuilder<
-      "OpBuilder &b, OperationState &result, MemRefType resultType, "
-      "Value source, ArrayRef<int64_t> staticOffsets, "
+      "MemRefType resultType, Value source, ArrayRef<int64_t> staticOffsets, "
       "ArrayRef<int64_t> staticSizes, ArrayRef<int64_t> staticStrides, "
       "ValueRange offsets, ValueRange sizes, "
       "ValueRange strides, ArrayRef<NamedAttribute> attrs = {}">,
     // Build a SubViewOp with all dynamic entries and custom result type.
     OpBuilder<
-      "OpBuilder &b, OperationState &result, MemRefType resultType, "
-      "Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, "
+      "MemRefType resultType, Value source, ValueRange offsets, "
+      "ValueRange sizes, ValueRange strides, "
       "ArrayRef<NamedAttribute> attrs = {}">
   ];
 
@@ -3450,8 +3448,8 @@ def TransposeOp : Std_Op<"transpose", [NoSideEffect]>,
   }];
 
   let builders = [OpBuilder<
-    "OpBuilder &b, OperationState &result, Value in, "
-    "AffineMapAttr permutation, ArrayRef<NamedAttribute> attrs = {}">];
+    "Value in, AffineMapAttr permutation, "
+    "ArrayRef<NamedAttribute> attrs = {}">];
 
   let extraClassDeclaration = [{
     static StringRef getPermutationAttrName() { return "permutation"; }
index 11a8cf7..cc6bc2c 100644 (file)
@@ -504,7 +504,6 @@ def Vector_ExtractMapOp :
     ```
   }];
   let builders = [OpBuilder<
-    "OpBuilder &builder, OperationState &result, " #
     "Value vector, Value id, int64_t multiplicity">];
   let extraClassDeclaration = [{
     VectorType getSourceVectorType() {
@@ -718,7 +717,6 @@ def Vector_InsertMapOp :
     ```
   }];
   let builders = [OpBuilder<
-    "OpBuilder &builder, OperationState &result, " #
     "Value vector, Value id, int64_t multiplicity">];
   let extraClassDeclaration = [{
     VectorType getSourceVectorType() {
index bf27724..82dc6a4 100644 (file)
@@ -1936,7 +1936,7 @@ def successor;
 // }
 // ```
 //
-// To define a custom builder, the parameter list (*including* the `Builder
+// To define a custom builder, the parameter list (*excluding* the `Builder
 // *builder, OperationState &state` part) and body should be passed in
 // as separate template arguments to this class. This is because we generate
 // op declaration and definition into separate files. If an empty string is
index 02f7dd3..b0e38ef 100644 (file)
@@ -1462,51 +1462,51 @@ void TCParser::printODS(llvm::raw_ostream &os, StringRef cppOpName,
 
       let skipDefaultBuilders = 1;
       let builders = [ OpBuilder<
-        "OpBuilder &b, OperationState &result, "
         "ValueRange inputs, ValueRange outputBuffers",
         [{{
-          result.addOperands(inputs);
-          result.addOperands(outputBuffers);
-          result.addAttribute(
+          $_state.addOperands(inputs);
+          $_state.addOperands(outputBuffers);
+          $_state.addAttribute(
             "operand_segment_sizes",
-            b.getI32VectorAttr({{static_cast<int32_t>(inputs.size()),
-                                static_cast<int32_t>(outputBuffers.size()),
-                                static_cast<int32_t>(0)}));
+            $_builder.getI32VectorAttr({{
+              static_cast<int32_t>(inputs.size()),
+              static_cast<int32_t>(outputBuffers.size()),
+              static_cast<int32_t>(0)}));
           buildNamedStructuredOpRegionAndAttributes<{0}>(
-            b,
-            result,
+            $_builder,
+            $_state,
             TypeRange(inputs),
             TypeRange(outputBuffers),
             TypeRange(),
             TypeRange());
         }]>, OpBuilder<
-        "OpBuilder &b, OperationState &result, TypeRange resultTensorTypes,"
-        "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors",
+        "TypeRange resultTensorTypes, ValueRange inputs, "
+        "ValueRange outputBuffers, ValueRange initTensors",
         [{{
-          result.addOperands(inputs);
-          result.addOperands(outputBuffers);
-          result.addOperands(initTensors);
-          result.addTypes(resultTensorTypes);
-          result.addAttribute(
+          $_state.addOperands(inputs);
+          $_state.addOperands(outputBuffers);
+          $_state.addOperands(initTensors);
+          $_state.addTypes(resultTensorTypes);
+          $_state.addAttribute(
             "operand_segment_sizes",
-            b.getI32VectorAttr({{static_cast<int32_t>(inputs.size()),
-                                static_cast<int32_t>(outputBuffers.size()),
-                                static_cast<int32_t>(initTensors.size())}));
+            $_builder.getI32VectorAttr({{
+              static_cast<int32_t>(inputs.size()),
+              static_cast<int32_t>(outputBuffers.size()),
+              static_cast<int32_t>(initTensors.size())}));
           buildNamedStructuredOpRegionAndAttributes<{0}>(
-            b,
-            result,
+            $_builder,
+            $_state,
             TypeRange(inputs),
             TypeRange(outputBuffers),
             TypeRange(initTensors),
             resultTensorTypes);
         }]>, OpBuilder<
-        "OpBuilder &b, OperationState &result, TypeRange resultTensorTypes,"
-        "ValueRange operands, ArrayRef<NamedAttribute> attributes = {{}",
+        "TypeRange resultTensorTypes, ValueRange operands, ArrayRef<NamedAttribute> attributes = {{}",
         [{{
-          result.addOperands(operands);
-          result.addAttributes(attributes);
-          result.addTypes(resultTensorTypes);
-          (void)result.addRegion();
+          $_state.addOperands(operands);
+          $_state.addAttributes(attributes);
+          $_state.addTypes(resultTensorTypes);
+          (void)$_state.addRegion();
         }]>
       ];
       let printer = [{{ return ::printNamedStructuredOp(p, *this); }];