[Mlir-commits] [mlir] 08e4f07 - [MLIR][NFC] Adopt use of TypeRange in build() methods.
Rahul Joshi
llvmlistbot at llvm.org
Wed Sep 23 09:08:23 PDT 2020
Author: Rahul Joshi
Date: 2020-09-23T09:07:57-07:00
New Revision: 08e4f078523b528f1e699543275f1d6299886a99
URL: https://github.com/llvm/llvm-project/commit/08e4f078523b528f1e699543275f1d6299886a99
DIFF: https://github.com/llvm/llvm-project/commit/08e4f078523b528f1e699543275f1d6299886a99.diff
LOG: [MLIR][NFC] Adopt use of TypeRange in build() methods.
- Use TypeRange instead of ArrayRef<Type> where possible.
- Change some of the custom builders to also use TypeRange
Differential Revision: https://reviews.llvm.org/D87944
Added:
Modified:
mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/unittests/TableGen/OpBuildGen.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
index 353f8c956b70..4294b88553f4 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
@@ -657,16 +657,16 @@ def AffineParallelOp : Affine_Op<"parallel",
let builders = [
OpBuilder<"OpBuilder &builder, OperationState &result, "
- "ArrayRef<Type> resultTypes, "
+ "TypeRange resultTypes, "
"ArrayRef<AtomicRMWKind> reductions, "
"ArrayRef<int64_t> ranges">,
OpBuilder<"OpBuilder &builder, OperationState &result, "
- "ArrayRef<Type> resultTypes, "
+ "TypeRange resultTypes, "
"ArrayRef<AtomicRMWKind> reductions, "
"AffineMap lbMap, ValueRange lbArgs, "
"AffineMap ubMap, ValueRange ubArgs">,
OpBuilder<"OpBuilder &builder, OperationState &result, "
- "ArrayRef<Type> resultTypes, "
+ "TypeRange resultTypes, "
"ArrayRef<AtomicRMWKind> reductions, "
"AffineMap lbMap, ValueRange lbArgs, "
"AffineMap ubMap, ValueRange ubArgs, "
diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index 39c091ac4d1c..d3d8cbac72b2 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -205,8 +205,8 @@ def GPU_GPUFuncOp : GPU_Op<"func", [HasParent<"GPUModuleOp">,
let builders = [
OpBuilder<"OpBuilder &builder, OperationState &result, StringRef name, "
- "FunctionType type, ArrayRef<Type> workgroupAttributions = {}, "
- "ArrayRef<Type> privateAttributions = {}, "
+ "FunctionType type, TypeRange workgroupAttributions = {}, "
+ "TypeRange privateAttributions = {}, "
"ArrayRef<NamedAttribute> attrs = {}">
];
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 626bc4b88989..39f22855e80e 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -383,7 +383,7 @@ def LLVM_InvokeOp : LLVM_Op<"invoke", [
AnySuccessor:$unwindDest);
let builders = [OpBuilder<
- "OpBuilder &b, OperationState &result, ArrayRef<Type> tys, "
+ "OpBuilder &b, OperationState &result, TypeRange tys, "
"FlatSymbolRefAttr callee, ValueRange ops, Block* normal, "
"ValueRange normalOps, Block* unwind, ValueRange unwindOps",
[{
@@ -391,7 +391,7 @@ def LLVM_InvokeOp : LLVM_Op<"invoke", [
build(b, result, tys, ops, normal, normalOps, unwind, unwindOps);
}]>,
OpBuilder<
- "OpBuilder &b, OperationState &result, ArrayRef<Type> tys, "
+ "OpBuilder &b, OperationState &result, TypeRange tys, "
"ValueRange ops, Block* normal, "
"ValueRange normalOps, Block* unwind, ValueRange unwindOps",
[{
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
index 65df012724a6..b5e7471d1e50 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
@@ -644,7 +644,7 @@ def GenericOp : GenericOpBase<"generic"> {
let builders = [
OpBuilder<
- "OpBuilder &builder, OperationState &result, ArrayRef<Type> resultTensorTypes,"
+ "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
"ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
"ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
"StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
@@ -656,7 +656,7 @@ def GenericOp : GenericOpBase<"generic"> {
"StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
"function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr">,
OpBuilder<
- "OpBuilder &builder, OperationState &result, ArrayRef<Type> resultTensorTypes,"
+ "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
"ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
"ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
"function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr">,
@@ -823,7 +823,7 @@ def IndexedGenericOp : GenericOpBase<"indexed_generic"> {
let builders = [
OpBuilder<
- "OpBuilder &builder, OperationState &result, ArrayRef<Type> resultTensorTypes,"
+ "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
"ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
"ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
"StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
@@ -835,7 +835,7 @@ def IndexedGenericOp : GenericOpBase<"indexed_generic"> {
"StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, "
"function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> = nullptr">,
OpBuilder<
- "OpBuilder &builder, OperationState &result, ArrayRef<Type> resultTensorTypes,"
+ "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,"
"ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, "
"ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, "
"function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> = nullptr">,
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
index 1e0e85f82c7f..17e16a15d39a 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
@@ -531,7 +531,7 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
(ins "OpBuilder &":$builder, "Location":$loc,
"ValueRange":$operands,
"ArrayRef<NamedAttribute>":$attributes), [{
- return builder.create<ConcreteOp>(loc, ArrayRef<Type>{}, operands,
+ return builder.create<ConcreteOp>(loc, TypeRange{}, operands,
attributes);
}]
>,
diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index 6eabc00d412d..dd49635ed8fc 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -721,13 +721,13 @@ def CallOp : Std_Op<"call", [CallOpInterface, MemRefsNormalizable]> {
result.addTypes(callee.getType().getResults());
}]>, OpBuilder<
"OpBuilder &builder, OperationState &result, SymbolRefAttr callee,"
- "ArrayRef<Type> results, ValueRange operands = {}", [{
+ "TypeRange results, ValueRange operands = {}", [{
result.addOperands(operands);
result.addAttribute("callee", callee);
result.addTypes(results);
}]>, OpBuilder<
"OpBuilder &builder, OperationState &result, StringRef callee,"
- "ArrayRef<Type> results, ValueRange operands = {}", [{
+ "TypeRange results, ValueRange operands = {}", [{
build(builder, result, builder.getSymbolRefAttr(callee), results,
operands);
}]>];
@@ -2812,7 +2812,7 @@ def SubViewOp : Std_Op<"subview", [
let results = (outs AnyMemRef:$result);
let builders = [
- // Build a SubViewOp with mized static and dynamic entries.
+ // Build a SubViewOp with mixed static and dynamic entries.
OpBuilder<
"OpBuilder &b, OperationState &result, Value source, "
"ArrayRef<int64_t> staticOffsets, ArrayRef<int64_t> staticSizes,"
diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
index 42673936b878..bfc8b6d6dec4 100644
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
+++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
@@ -173,7 +173,7 @@ void ConvertGpuLaunchFuncToVulkanLaunchFunc::convertGpuLaunchFunc(
// Create vulkan launch call op.
auto vulkanLaunchCallOp = builder.create<CallOp>(
- loc, ArrayRef<Type>{}, builder.getSymbolRefAttr(kVulkanLaunch),
+ loc, TypeRange{}, builder.getSymbolRefAttr(kVulkanLaunch),
vulkanLaunchOperands);
// Set SPIR-V binary shader data as an attribute.
diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
index 8099bec63f2d..1b6f0194a55d 100644
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
+++ b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
@@ -247,11 +247,11 @@ void VulkanLaunchFuncToVulkanCallsPass::createBindMemRefCalls(
}
// Create call to `bindMemRef`.
builder.create<LLVM::CallOp>(
- loc, ArrayRef<Type>{getVoidType()},
+ loc, TypeRange{getVoidType()},
builder.getSymbolRefAttr(
StringRef(symbolName.data(), symbolName.size())),
- ArrayRef<Value>{vulkanRuntime, descriptorSet, descriptorBinding,
- ptrToMemRefDescriptor});
+ ValueRange{vulkanRuntime, descriptorSet, descriptorBinding,
+ ptrToMemRefDescriptor});
}
}
@@ -373,8 +373,8 @@ void VulkanLaunchFuncToVulkanCallsPass::translateVulkanLaunchCall(
Location loc = cInterfaceVulkanLaunchCallOp.getLoc();
// Create call to `initVulkan`.
auto initVulkanCall = builder.create<LLVM::CallOp>(
- loc, ArrayRef<Type>{getPointerType()},
- builder.getSymbolRefAttr(kInitVulkan), ArrayRef<Value>{});
+ loc, TypeRange{getPointerType()}, builder.getSymbolRefAttr(kInitVulkan),
+ ValueRange{});
// The result of `initVulkan` function is a pointer to Vulkan runtime, we
// need to pass that pointer to each Vulkan runtime call.
auto vulkanRuntime = initVulkanCall.getResult(0);
@@ -396,35 +396,34 @@ void VulkanLaunchFuncToVulkanCallsPass::translateVulkanLaunchCall(
// Create call to `setBinaryShader` runtime function with the given pointer to
// SPIR-V binary and binary size.
builder.create<LLVM::CallOp>(
- loc, ArrayRef<Type>{getVoidType()},
- builder.getSymbolRefAttr(kSetBinaryShader),
- ArrayRef<Value>{vulkanRuntime, ptrToSPIRVBinary, binarySize});
+ loc, TypeRange{getVoidType()}, builder.getSymbolRefAttr(kSetBinaryShader),
+ ValueRange{vulkanRuntime, ptrToSPIRVBinary, binarySize});
// Create LLVM global with entry point name.
Value entryPointName = createEntryPointNameConstant(
spirvAttributes.second.getValue(), loc, builder);
// Create call to `setEntryPoint` runtime function with the given pointer to
// entry point name.
- builder.create<LLVM::CallOp>(loc, ArrayRef<Type>{getVoidType()},
+ builder.create<LLVM::CallOp>(loc, TypeRange{getVoidType()},
builder.getSymbolRefAttr(kSetEntryPoint),
- ArrayRef<Value>{vulkanRuntime, entryPointName});
+ ValueRange{vulkanRuntime, entryPointName});
// Create number of local workgroup for each dimension.
builder.create<LLVM::CallOp>(
- loc, ArrayRef<Type>{getVoidType()},
+ loc, TypeRange{getVoidType()},
builder.getSymbolRefAttr(kSetNumWorkGroups),
- ArrayRef<Value>{vulkanRuntime, cInterfaceVulkanLaunchCallOp.getOperand(0),
- cInterfaceVulkanLaunchCallOp.getOperand(1),
- cInterfaceVulkanLaunchCallOp.getOperand(2)});
+ ValueRange{vulkanRuntime, cInterfaceVulkanLaunchCallOp.getOperand(0),
+ cInterfaceVulkanLaunchCallOp.getOperand(1),
+ cInterfaceVulkanLaunchCallOp.getOperand(2)});
// Create call to `runOnVulkan` runtime function.
- builder.create<LLVM::CallOp>(loc, ArrayRef<Type>{getVoidType()},
+ builder.create<LLVM::CallOp>(loc, TypeRange{getVoidType()},
builder.getSymbolRefAttr(kRunOnVulkan),
- ArrayRef<Value>{vulkanRuntime});
+ ValueRange{vulkanRuntime});
// Create call to 'deinitVulkan' runtime function.
- builder.create<LLVM::CallOp>(loc, ArrayRef<Type>{getVoidType()},
+ builder.create<LLVM::CallOp>(loc, TypeRange{getVoidType()},
builder.getSymbolRefAttr(kDeinitVulkan),
- ArrayRef<Value>{vulkanRuntime});
+ ValueRange{vulkanRuntime});
// Declare runtime functions.
declareVulkanFunctions(loc);
diff --git a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
index 93b7764a6a77..29b5f9cc996e 100644
--- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
+++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
@@ -123,7 +123,7 @@ class LinalgOpConversion : public OpRewritePattern<LinalgOp> {
return failure();
rewriter.replaceOpWithNewOp<mlir::CallOp>(
- op, libraryCallName.getValue(), ArrayRef<Type>{},
+ op, libraryCallName.getValue(), TypeRange(),
createTypeCanonicalizedMemRefOperands(rewriter, op.getLoc(),
op.getOperands()));
return success();
@@ -151,7 +151,7 @@ class LinalgOpConversion<CopyOp> : public OpRewritePattern<CopyOp> {
return failure();
rewriter.replaceOpWithNewOp<mlir::CallOp>(
- op, libraryCallName.getValue(), ArrayRef<Type>{},
+ op, libraryCallName.getValue(), TypeRange(),
createTypeCanonicalizedMemRefOperands(rewriter, op.getLoc(),
op.getOperands()));
return success();
@@ -185,7 +185,7 @@ class LinalgOpConversion<IndexedGenericOp>
for (auto operand : op.getOperands())
operands.push_back(operand);
rewriter.replaceOpWithNewOp<mlir::CallOp>(
- op, libraryCallName.getValue(), ArrayRef<Type>{},
+ op, libraryCallName.getValue(), TypeRange(),
createTypeCanonicalizedMemRefOperands(rewriter, op.getLoc(), operands));
return success();
}
diff --git a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
index 41c8ac1ec390..419d4bea30bd 100644
--- a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
@@ -26,8 +26,8 @@ struct ParallelOpConversion : public ConvertToLLVMPattern {
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto curOp = cast<omp::ParallelOp>(op);
- auto newOp = rewriter.create<omp::ParallelOp>(
- curOp.getLoc(), ArrayRef<Type>(), operands, curOp.getAttrs());
+ auto newOp = rewriter.create<omp::ParallelOp>(curOp.getLoc(), TypeRange(),
+ operands, curOp.getAttrs());
rewriter.inlineRegionBefore(curOp.region(), newOp.region(),
newOp.region().end());
if (failed(rewriter.convertRegionTypes(&newOp.region(), typeConverter)))
diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 814a2550015d..186c8ec48fa5 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -2189,7 +2189,7 @@ struct DeallocOpLowering : public ConvertOpToLLVMPattern<DeallocOp> {
op->getLoc(), getVoidPtrType(),
memref.allocatedPtr(rewriter, op->getLoc()));
rewriter.replaceOpWithNewOp<LLVM::CallOp>(
- op, ArrayRef<Type>(), rewriter.getSymbolRefAttr(freeFunc), casted);
+ op, TypeRange(), rewriter.getSymbolRefAttr(freeFunc), casted);
return success();
}
};
@@ -2714,13 +2714,13 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
// If ReturnOp has 0 or 1 operand, create it and return immediately.
if (numArguments == 0) {
- rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(
- op, ArrayRef<Type>(), ArrayRef<Value>(), op->getAttrs());
+ rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(op, TypeRange(), ValueRange(),
+ op->getAttrs());
return success();
}
if (numArguments == 1) {
rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(
- op, ArrayRef<Type>(), updatedOperands, op->getAttrs());
+ op, TypeRange(), updatedOperands, op->getAttrs());
return success();
}
@@ -2735,7 +2735,7 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
op->getLoc(), packedType, packed, updatedOperands[i],
rewriter.getI64ArrayAttr(i));
}
- rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(op, ArrayRef<Type>(), packed,
+ rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(op, TypeRange(), packed,
op->getAttrs());
return success();
}
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index cbc4c12c1ba1..6ad17d77069c 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -1382,7 +1382,7 @@ class VectorPrintOpConversion : public ConvertToLLVMPattern {
// Helper to emit a call.
static void emitCall(ConversionPatternRewriter &rewriter, Location loc,
Operation *ref, ValueRange params = ValueRange()) {
- rewriter.create<LLVM::CallOp>(loc, ArrayRef<Type>{},
+ rewriter.create<LLVM::CallOp>(loc, TypeRange(),
rewriter.getSymbolRefAttr(ref), params);
}
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 440875db3918..bd45c8d667f9 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -2460,7 +2460,7 @@ LogicalResult AffinePrefetchOp::fold(ArrayRef<Attribute> cstOperands,
//===----------------------------------------------------------------------===//
void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
- ArrayRef<Type> resultTypes,
+ TypeRange resultTypes,
ArrayRef<AtomicRMWKind> reductions,
ArrayRef<int64_t> ranges) {
SmallVector<AffineExpr, 8> lbExprs(ranges.size(),
@@ -2475,7 +2475,7 @@ void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
}
void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
- ArrayRef<Type> resultTypes,
+ TypeRange resultTypes,
ArrayRef<AtomicRMWKind> reductions,
AffineMap lbMap, ValueRange lbArgs,
AffineMap ubMap, ValueRange ubArgs) {
@@ -2490,7 +2490,7 @@ void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
}
void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
- ArrayRef<Type> resultTypes,
+ TypeRange resultTypes,
ArrayRef<AtomicRMWKind> reductions,
AffineMap lbMap, ValueRange lbArgs,
AffineMap ubMap, ValueRange ubArgs,
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 7dc74f21e2fb..d754177cc8bc 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -475,8 +475,8 @@ BlockArgument GPUFuncOp::addPrivateAttribution(Type type) {
void GPUFuncOp::build(OpBuilder &builder, OperationState &result,
StringRef name, FunctionType type,
- ArrayRef<Type> workgroupAttributions,
- ArrayRef<Type> privateAttributions,
+ TypeRange workgroupAttributions,
+ TypeRange privateAttributions,
ArrayRef<NamedAttribute> attrs) {
result.addAttribute(SymbolTable::getSymbolAttrName(),
builder.getStringAttr(name));
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 63bd10c2e6f1..e1f7aede782d 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -247,7 +247,7 @@ void StoreOp::build(OpBuilder &builder, OperationState &result, Value value,
Value addr, unsigned alignment, bool isVolatile,
bool isNonTemporal) {
result.addOperands({value, addr});
- result.addTypes(ArrayRef<Type>{});
+ result.addTypes({});
if (isVolatile)
result.addAttribute(kVolatileAttrName, builder.getUnitAttr());
if (isNonTemporal)
@@ -1787,7 +1787,7 @@ Value mlir::LLVM::createGlobalString(Location loc, OpBuilder &builder,
loc, LLVM::LLVMType::getInt64Ty(ctx),
builder.getIntegerAttr(builder.getIndexType(), 0));
return builder.create<LLVM::GEPOp>(loc, LLVM::LLVMType::getInt8PtrTy(ctx),
- globalPtr, ArrayRef<Value>({cst0, cst0}));
+ globalPtr, ValueRange{cst0, cst0});
}
bool mlir::LLVM::satisfiesLLVMModule(Operation *op) {
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index d036fe5fdebd..ca2260836d9f 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -98,9 +98,8 @@ static LogicalResult foldMemRefCast(Operation *op) {
// GenericOps
//===----------------------------------------------------------------------===//
void GenericOp::build(
- OpBuilder &builder, OperationState &result,
- ArrayRef<Type> resultTensorTypes, ValueRange inputs,
- ValueRange outputBuffers, ValueRange initTensors,
+ OpBuilder &builder, OperationState &result, 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)> bodyBuild) {
@@ -130,7 +129,7 @@ void GenericOp::build(
ArrayRef<StringRef> iteratorTypes, StringRef doc, StringRef libraryCall,
IntegerAttr symbolSource,
function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuild) {
- build(builder, result, ArrayRef<Type>{}, inputs, outputBuffers, ValueRange{},
+ build(builder, result, TypeRange{}, inputs, outputBuffers, ValueRange{},
indexingMaps, iteratorTypes, doc, libraryCall, symbolSource, bodyBuild);
}
@@ -146,9 +145,8 @@ void GenericOp::build(
}
void GenericOp::build(
- OpBuilder &builder, OperationState &result,
- ArrayRef<Type> resultTensorTypes, ValueRange inputs,
- ValueRange outputBuffers, ValueRange initTensors,
+ OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,
+ ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors,
ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes,
function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuild) {
build(builder, result, resultTensorTypes, inputs, outputBuffers, initTensors,
@@ -159,9 +157,8 @@ void GenericOp::build(
}
void IndexedGenericOp::build(
- OpBuilder &builder, OperationState &result,
- ArrayRef<Type> resultTensorTypes, ValueRange inputs,
- ValueRange outputBuffers, ValueRange initTensors,
+ OpBuilder &builder, OperationState &result, 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)>
@@ -196,7 +193,7 @@ void IndexedGenericOp::build(
IntegerAttr symbolSource,
function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)>
bodyBuild) {
- build(builder, result, ArrayRef<Type>{}, inputs, outputBuffers, ValueRange{},
+ build(builder, result, TypeRange{}, inputs, outputBuffers, ValueRange{},
indexingMaps, iteratorTypes, doc, libraryCall, symbolSource, bodyBuild);
}
@@ -213,9 +210,8 @@ void IndexedGenericOp::build(
}
void IndexedGenericOp::build(
- OpBuilder &builder, OperationState &result,
- ArrayRef<Type> resultTensorTypes, ValueRange inputs,
- ValueRange outputBuffers, ValueRange initTensors,
+ OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,
+ ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors,
ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes,
function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)>
bodyBuild) {
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index 6602060db8dc..7bdd0fd3815b 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -255,7 +255,7 @@ struct FoldToCallOpPattern : public OpRewritePattern<FoldToCallOp> {
LogicalResult matchAndRewrite(FoldToCallOp op,
PatternRewriter &rewriter) const override {
- rewriter.replaceOpWithNewOp<CallOp>(op, ArrayRef<Type>(), op.calleeAttr(),
+ rewriter.replaceOpWithNewOp<CallOp>(op, TypeRange(), op.calleeAttr(),
ValueRange());
return success();
}
diff --git a/mlir/unittests/TableGen/OpBuildGen.cpp b/mlir/unittests/TableGen/OpBuildGen.cpp
index 0f089302358d..09a02b4f90fd 100644
--- a/mlir/unittests/TableGen/OpBuildGen.cpp
+++ b/mlir/unittests/TableGen/OpBuildGen.cpp
@@ -73,20 +73,20 @@ class OpBuildGenTest : public ::testing::Test {
template <typename OpTy>
void testSingleVariadicInputInferredType() {
// Test separate arg, separate param build method.
- auto op = builder.create<OpTy>(loc, i32Ty, ArrayRef<Value>{cstI32, cstI32});
+ auto op = builder.create<OpTy>(loc, i32Ty, ValueRange{cstI32, cstI32});
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, noAttrs);
// Test collective params build method.
- op = builder.create<OpTy>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32, cstI32});
+ op =
+ builder.create<OpTy>(loc, TypeRange{i32Ty}, ValueRange{cstI32, cstI32});
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, noAttrs);
// Test build method with no result types, default value of attributes.
- op = builder.create<OpTy>(loc, ArrayRef<Value>{cstI32, cstI32});
+ op = builder.create<OpTy>(loc, ValueRange{cstI32, cstI32});
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, noAttrs);
// Test build method with no result types and supplied attributes.
- op = builder.create<OpTy>(loc, ArrayRef<Value>{cstI32, cstI32}, attrs);
+ op = builder.create<OpTy>(loc, ValueRange{cstI32, cstI32}, attrs);
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, attrs);
}
@@ -111,17 +111,17 @@ TEST_F(OpBuildGenTest, BasicBuildMethods) {
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
// Test separate args, collective results build method.
- op = builder.create<TableGenBuildOp0>(loc, ArrayRef<Type>{i32Ty}, cstI32);
+ op = builder.create<TableGenBuildOp0>(loc, TypeRange{i32Ty}, cstI32);
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
// Test collective args, collective params build method.
- op = builder.create<TableGenBuildOp0>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32});
+ op = builder.create<TableGenBuildOp0>(loc, TypeRange{i32Ty},
+ ValueRange{cstI32});
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
// Test collective args, collective results, non-empty attributes
- op = builder.create<TableGenBuildOp0>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32}, attrs);
+ op = builder.create<TableGenBuildOp0>(loc, TypeRange{i32Ty},
+ ValueRange{cstI32}, attrs);
verifyOp(op, {i32Ty}, {cstI32}, attrs);
}
@@ -138,25 +138,25 @@ TEST_F(OpBuildGenTest, BasicBuildMethods) {
/// variadic result.
TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgAndResult) {
// Test collective args, collective results method, building a unary op.
- auto op = builder.create<TableGenBuildOp1>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32});
+ auto op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
+ ValueRange{cstI32});
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
// Test collective args, collective results method, building a unary op with
// named attributes.
- op = builder.create<TableGenBuildOp1>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32}, attrs);
+ op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
+ ValueRange{cstI32}, attrs);
verifyOp(std::move(op), {i32Ty}, {cstI32}, attrs);
// Test collective args, collective results method, building a binary op.
- op = builder.create<TableGenBuildOp1>(loc, ArrayRef<Type>{i32Ty, f32Ty},
- ArrayRef<Value>{cstI32, cstF32});
+ op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty, f32Ty},
+ ValueRange{cstI32, cstF32});
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32, cstF32}, noAttrs);
// Test collective args, collective results method, building a binary op with
// named attributes.
- op = builder.create<TableGenBuildOp1>(loc, ArrayRef<Type>{i32Ty, f32Ty},
- ArrayRef<Value>{cstI32, cstF32}, attrs);
+ op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty, f32Ty},
+ ValueRange{cstI32, cstF32}, attrs);
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32, cstF32}, attrs);
}
@@ -164,23 +164,22 @@ TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgAndResult) {
/// result.
TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgNonVariadicResults) {
// Test separate arg, separate param build method.
- auto op =
- builder.create<TableGenBuildOp1>(loc, i32Ty, ArrayRef<Value>{cstI32});
+ auto op = builder.create<TableGenBuildOp1>(loc, i32Ty, ValueRange{cstI32});
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
// Test collective params build method, no attributes.
- op = builder.create<TableGenBuildOp1>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32});
+ op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
+ ValueRange{cstI32});
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
// Test collective params build method no attributes, 2 inputs.
- op = builder.create<TableGenBuildOp1>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32, cstF32});
+ op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
+ ValueRange{cstI32, cstF32});
verifyOp(std::move(op), {i32Ty}, {cstI32, cstF32}, noAttrs);
// Test collective params build method, non-empty attributes.
- op = builder.create<TableGenBuildOp1>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Value>{cstI32, cstF32}, attrs);
+ op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
+ ValueRange{cstI32, cstF32}, attrs);
verifyOp(std::move(op), {i32Ty}, {cstI32, cstF32}, attrs);
}
@@ -189,19 +188,18 @@ TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgNonVariadicResults) {
TEST_F(OpBuildGenTest,
BuildMethodsSingleVariadicArgAndMultipleVariadicResults) {
// Test separate arg, separate param build method.
- auto op = builder.create<TableGenBuildOp3>(loc, ArrayRef<Type>{i32Ty},
- ArrayRef<Type>{f32Ty},
- ArrayRef<Value>{cstI32});
+ auto op = builder.create<TableGenBuildOp3>(
+ loc, TypeRange{i32Ty}, TypeRange{f32Ty}, ValueRange{cstI32});
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, noAttrs);
// Test collective params build method, no attributes.
- op = builder.create<TableGenBuildOp3>(loc, ArrayRef<Type>{i32Ty, f32Ty},
- ArrayRef<Value>{cstI32});
+ op = builder.create<TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
+ ValueRange{cstI32});
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, noAttrs);
// Test collective params build method, with attributes.
- op = builder.create<TableGenBuildOp3>(loc, ArrayRef<Type>{i32Ty, f32Ty},
- ArrayRef<Value>{cstI32}, attrs);
+ op = builder.create<TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
+ ValueRange{cstI32}, attrs);
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, attrs);
}
More information about the Mlir-commits
mailing list