[Mlir-commits] [mlir] f4ad76d - [mlir] More changes to avoid args now inserted.NFC
Jacques Pienaar
llvmlistbot at llvm.org
Wed Oct 14 10:48:14 PDT 2020
Author: Jacques Pienaar
Date: 2020-10-14T10:47:45-07:00
New Revision: f4ad76deb8a78d841bf57c50a91b6c13f50cc158
URL: https://github.com/llvm/llvm-project/commit/f4ad76deb8a78d841bf57c50a91b6c13f50cc158
DIFF: https://github.com/llvm/llvm-project/commit/f4ad76deb8a78d841bf57c50a91b6c13f50cc158.diff
LOG: [mlir] More changes to avoid args now inserted.NFC
Migrates a bit more from the old/to be deprecated form.
Added:
Modified:
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
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
index 2382253eff17..56bb73f61272 100644
--- a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
+++ b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
@@ -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 = [{
diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index 5d4443e1d8ff..1542241b5b02 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -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(); }];
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
index 5b29154e0a03..68e210582d66 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
@@ -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 };
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
index 55df0bccbb64..ba8fa644c1fb 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
@@ -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">
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index c217d9a4d0a8..24dc01d7e3e9 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -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 = ?;
diff --git a/mlir/include/mlir/Dialect/SCF/SCFOps.td b/mlir/include/mlir/Dialect/SCF/SCFOps.td
index 476898ab2072..3e7623cda0a0 100644
--- a/mlir/include/mlir/Dialect/SCF/SCFOps.td
+++ b/mlir/include/mlir/Dialect/SCF/SCFOps.td
@@ -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.
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
index c3a867977b3e..953fc50209b3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
@@ -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}]>
];
}
diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index 235a22a2ce3d..c6c52f2eb6ee 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -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))?";
diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index 798df5e24237..6b60c2f79b01 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -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"; }
diff --git a/mlir/include/mlir/Dialect/Vector/VectorOps.td b/mlir/include/mlir/Dialect/Vector/VectorOps.td
index 11a8cf74ddd5..cc6bc2c8c77b 100644
--- a/mlir/include/mlir/Dialect/Vector/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/VectorOps.td
@@ -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() {
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index bf27724088fd..82dc6a456f29 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -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
diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
index 02f7dd304519..b0e38ef83dae 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
@@ -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); }];
More information about the Mlir-commits
mailing list