From 08e4f078523b528f1e699543275f1d6299886a99 Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Tue, 22 Sep 2020 21:00:11 -0700 Subject: [PATCH] [MLIR][NFC] Adopt use of TypeRange in build() methods. - Use TypeRange instead of ArrayRef where possible. - Change some of the custom builders to also use TypeRange Differential Revision: https://reviews.llvm.org/D87944 --- mlir/include/mlir/Dialect/Affine/IR/AffineOps.td | 6 +- mlir/include/mlir/Dialect/GPU/GPUOps.td | 4 +- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 4 +- .../mlir/Dialect/Linalg/IR/LinalgStructuredOps.td | 8 +-- .../Linalg/IR/LinalgStructuredOpsInterface.td | 2 +- mlir/include/mlir/Dialect/StandardOps/IR/Ops.td | 6 +- .../ConvertGPULaunchFuncToVulkanLaunchFunc.cpp | 2 +- .../GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp | 35 ++++++------ .../LinalgToStandard/LinalgToStandard.cpp | 6 +- mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp | 4 +- .../Conversion/StandardToLLVM/StandardToLLVM.cpp | 10 ++-- .../VectorToLLVM/ConvertVectorToLLVM.cpp | 2 +- mlir/lib/Dialect/Affine/IR/AffineOps.cpp | 6 +- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 4 +- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 4 +- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 24 ++++---- mlir/test/lib/Dialect/Test/TestDialect.cpp | 2 +- mlir/unittests/TableGen/OpBuildGen.cpp | 64 +++++++++++----------- 18 files changed, 93 insertions(+), 100 deletions(-) diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td index 353f8c9..4294b88 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 resultTypes, " + "TypeRange resultTypes, " "ArrayRef reductions, " "ArrayRef ranges">, OpBuilder<"OpBuilder &builder, OperationState &result, " - "ArrayRef resultTypes, " + "TypeRange resultTypes, " "ArrayRef reductions, " "AffineMap lbMap, ValueRange lbArgs, " "AffineMap ubMap, ValueRange ubArgs">, OpBuilder<"OpBuilder &builder, OperationState &result, " - "ArrayRef resultTypes, " + "TypeRange resultTypes, " "ArrayRef 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 39c091a..d3d8cba 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 workgroupAttributions = {}, " - "ArrayRef privateAttributions = {}, " + "FunctionType type, TypeRange workgroupAttributions = {}, " + "TypeRange privateAttributions = {}, " "ArrayRef attrs = {}"> ]; diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 626bc4b..39f2285 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 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 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 65df012..b5e7471 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 resultTensorTypes," + "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes," "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, " "ArrayRef indexingMaps, ArrayRef iteratorTypes, " "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, " @@ -656,7 +656,7 @@ def GenericOp : GenericOpBase<"generic"> { "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, " "function_ref = nullptr">, OpBuilder< - "OpBuilder &builder, OperationState &result, ArrayRef resultTensorTypes," + "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes," "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, " "ArrayRef indexingMaps, ArrayRef iteratorTypes, " "function_ref = nullptr">, @@ -823,7 +823,7 @@ def IndexedGenericOp : GenericOpBase<"indexed_generic"> { let builders = [ OpBuilder< - "OpBuilder &builder, OperationState &result, ArrayRef resultTensorTypes," + "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes," "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, " "ArrayRef indexingMaps, ArrayRef iteratorTypes, " "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, " @@ -835,7 +835,7 @@ def IndexedGenericOp : GenericOpBase<"indexed_generic"> { "StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, " "function_ref = nullptr">, OpBuilder< - "OpBuilder &builder, OperationState &result, ArrayRef resultTensorTypes," + "OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes," "ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, " "ArrayRef indexingMaps, ArrayRef iteratorTypes, " "function_ref = nullptr">, diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td index 1e0e85f..17e16a1 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":$attributes), [{ - return builder.create(loc, ArrayRef{}, operands, + return builder.create(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 6eabc00..dd49635 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 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 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 staticOffsets, ArrayRef staticSizes," diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp index 4267393..bfc8b6d 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( - loc, ArrayRef{}, 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 8099bec..1b6f019 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( - loc, ArrayRef{getVoidType()}, + loc, TypeRange{getVoidType()}, builder.getSymbolRefAttr( StringRef(symbolName.data(), symbolName.size())), - ArrayRef{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( - loc, ArrayRef{getPointerType()}, - builder.getSymbolRefAttr(kInitVulkan), ArrayRef{}); + 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( - loc, ArrayRef{getVoidType()}, - builder.getSymbolRefAttr(kSetBinaryShader), - ArrayRef{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(loc, ArrayRef{getVoidType()}, + builder.create(loc, TypeRange{getVoidType()}, builder.getSymbolRefAttr(kSetEntryPoint), - ArrayRef{vulkanRuntime, entryPointName}); + ValueRange{vulkanRuntime, entryPointName}); // Create number of local workgroup for each dimension. builder.create( - loc, ArrayRef{getVoidType()}, + loc, TypeRange{getVoidType()}, builder.getSymbolRefAttr(kSetNumWorkGroups), - ArrayRef{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(loc, ArrayRef{getVoidType()}, + builder.create(loc, TypeRange{getVoidType()}, builder.getSymbolRefAttr(kRunOnVulkan), - ArrayRef{vulkanRuntime}); + ValueRange{vulkanRuntime}); // Create call to 'deinitVulkan' runtime function. - builder.create(loc, ArrayRef{getVoidType()}, + builder.create(loc, TypeRange{getVoidType()}, builder.getSymbolRefAttr(kDeinitVulkan), - ArrayRef{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 93b7764..29b5f9c 100644 --- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp +++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp @@ -123,7 +123,7 @@ public: return failure(); rewriter.replaceOpWithNewOp( - op, libraryCallName.getValue(), ArrayRef{}, + op, libraryCallName.getValue(), TypeRange(), createTypeCanonicalizedMemRefOperands(rewriter, op.getLoc(), op.getOperands())); return success(); @@ -151,7 +151,7 @@ public: return failure(); rewriter.replaceOpWithNewOp( - op, libraryCallName.getValue(), ArrayRef{}, + op, libraryCallName.getValue(), TypeRange(), createTypeCanonicalizedMemRefOperands(rewriter, op.getLoc(), op.getOperands())); return success(); @@ -185,7 +185,7 @@ public: for (auto operand : op.getOperands()) operands.push_back(operand); rewriter.replaceOpWithNewOp( - op, libraryCallName.getValue(), ArrayRef{}, + 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 41c8ac1..419d4be 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 operands, ConversionPatternRewriter &rewriter) const override { auto curOp = cast(op); - auto newOp = rewriter.create( - curOp.getLoc(), ArrayRef(), operands, curOp.getAttrs()); + auto newOp = rewriter.create(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 814a255..186c8ec 100644 --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -2189,7 +2189,7 @@ struct DeallocOpLowering : public ConvertOpToLLVMPattern { op->getLoc(), getVoidPtrType(), memref.allocatedPtr(rewriter, op->getLoc())); rewriter.replaceOpWithNewOp( - op, ArrayRef(), rewriter.getSymbolRefAttr(freeFunc), casted); + op, TypeRange(), rewriter.getSymbolRefAttr(freeFunc), casted); return success(); } }; @@ -2714,13 +2714,13 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern { // If ReturnOp has 0 or 1 operand, create it and return immediately. if (numArguments == 0) { - rewriter.replaceOpWithNewOp( - op, ArrayRef(), ArrayRef(), op->getAttrs()); + rewriter.replaceOpWithNewOp(op, TypeRange(), ValueRange(), + op->getAttrs()); return success(); } if (numArguments == 1) { rewriter.replaceOpWithNewOp( - op, ArrayRef(), updatedOperands, op->getAttrs()); + op, TypeRange(), updatedOperands, op->getAttrs()); return success(); } @@ -2735,7 +2735,7 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern { op->getLoc(), packedType, packed, updatedOperands[i], rewriter.getI64ArrayAttr(i)); } - rewriter.replaceOpWithNewOp(op, ArrayRef(), packed, + rewriter.replaceOpWithNewOp(op, TypeRange(), packed, op->getAttrs()); return success(); } diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index cbc4c12..6ad17d7 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1382,7 +1382,7 @@ private: // Helper to emit a call. static void emitCall(ConversionPatternRewriter &rewriter, Location loc, Operation *ref, ValueRange params = ValueRange()) { - rewriter.create(loc, ArrayRef{}, + rewriter.create(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 440875d..bd45c8d 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 cstOperands, //===----------------------------------------------------------------------===// void AffineParallelOp::build(OpBuilder &builder, OperationState &result, - ArrayRef resultTypes, + TypeRange resultTypes, ArrayRef reductions, ArrayRef ranges) { SmallVector lbExprs(ranges.size(), @@ -2475,7 +2475,7 @@ void AffineParallelOp::build(OpBuilder &builder, OperationState &result, } void AffineParallelOp::build(OpBuilder &builder, OperationState &result, - ArrayRef resultTypes, + TypeRange resultTypes, ArrayRef 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 resultTypes, + TypeRange resultTypes, ArrayRef 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 7dc74f2..d754177 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 workgroupAttributions, - ArrayRef privateAttributions, + TypeRange workgroupAttributions, + TypeRange privateAttributions, ArrayRef 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 63bd10c..e1f7aed 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{}); + 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(loc, LLVM::LLVMType::getInt8PtrTy(ctx), - globalPtr, ArrayRef({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 d036fe5..ca22608 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 resultTensorTypes, ValueRange inputs, - ValueRange outputBuffers, ValueRange initTensors, + OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes, + ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, ArrayRef indexingMaps, ArrayRef iteratorTypes, StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, function_ref bodyBuild) { @@ -130,7 +129,7 @@ void GenericOp::build( ArrayRef iteratorTypes, StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, function_ref bodyBuild) { - build(builder, result, ArrayRef{}, 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 resultTensorTypes, ValueRange inputs, - ValueRange outputBuffers, ValueRange initTensors, + OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes, + ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, ArrayRef indexingMaps, ArrayRef iteratorTypes, function_ref bodyBuild) { build(builder, result, resultTensorTypes, inputs, outputBuffers, initTensors, @@ -159,9 +157,8 @@ void GenericOp::build( } void IndexedGenericOp::build( - OpBuilder &builder, OperationState &result, - ArrayRef resultTensorTypes, ValueRange inputs, - ValueRange outputBuffers, ValueRange initTensors, + OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes, + ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, ArrayRef indexingMaps, ArrayRef iteratorTypes, StringRef doc, StringRef libraryCall, IntegerAttr symbolSource, function_ref @@ -196,7 +193,7 @@ void IndexedGenericOp::build( IntegerAttr symbolSource, function_ref bodyBuild) { - build(builder, result, ArrayRef{}, 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 resultTensorTypes, ValueRange inputs, - ValueRange outputBuffers, ValueRange initTensors, + OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes, + ValueRange inputs, ValueRange outputBuffers, ValueRange initTensors, ArrayRef indexingMaps, ArrayRef iteratorTypes, function_ref bodyBuild) { diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 6602060..7bdd0fd 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 { LogicalResult matchAndRewrite(FoldToCallOp op, PatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(op, ArrayRef(), op.calleeAttr(), + rewriter.replaceOpWithNewOp(op, TypeRange(), op.calleeAttr(), ValueRange()); return success(); } diff --git a/mlir/unittests/TableGen/OpBuildGen.cpp b/mlir/unittests/TableGen/OpBuildGen.cpp index 0f08930..09a02b4 100644 --- a/mlir/unittests/TableGen/OpBuildGen.cpp +++ b/mlir/unittests/TableGen/OpBuildGen.cpp @@ -73,20 +73,20 @@ protected: template void testSingleVariadicInputInferredType() { // Test separate arg, separate param build method. - auto op = builder.create(loc, i32Ty, ArrayRef{cstI32, cstI32}); + auto op = builder.create(loc, i32Ty, ValueRange{cstI32, cstI32}); verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, noAttrs); // Test collective params build method. - op = builder.create(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32, cstI32}); + op = + builder.create(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(loc, ArrayRef{cstI32, cstI32}); + op = builder.create(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(loc, ArrayRef{cstI32, cstI32}, attrs); + op = builder.create(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(loc, ArrayRef{i32Ty}, cstI32); + op = builder.create(loc, TypeRange{i32Ty}, cstI32); verifyOp(op, {i32Ty}, {cstI32}, noAttrs); // Test collective args, collective params build method. - op = builder.create(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32}); + op = builder.create(loc, TypeRange{i32Ty}, + ValueRange{cstI32}); verifyOp(op, {i32Ty}, {cstI32}, noAttrs); // Test collective args, collective results, non-empty attributes - op = builder.create(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32}, attrs); + op = builder.create(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(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32}); + auto op = builder.create(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(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32}, attrs); + op = builder.create(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(loc, ArrayRef{i32Ty, f32Ty}, - ArrayRef{cstI32, cstF32}); + op = builder.create(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(loc, ArrayRef{i32Ty, f32Ty}, - ArrayRef{cstI32, cstF32}, attrs); + op = builder.create(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(loc, i32Ty, ArrayRef{cstI32}); + auto op = builder.create(loc, i32Ty, ValueRange{cstI32}); verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs); // Test collective params build method, no attributes. - op = builder.create(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32}); + op = builder.create(loc, TypeRange{i32Ty}, + ValueRange{cstI32}); verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs); // Test collective params build method no attributes, 2 inputs. - op = builder.create(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32, cstF32}); + op = builder.create(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(loc, ArrayRef{i32Ty}, - ArrayRef{cstI32, cstF32}, attrs); + op = builder.create(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(loc, ArrayRef{i32Ty}, - ArrayRef{f32Ty}, - ArrayRef{cstI32}); + auto op = builder.create( + 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(loc, ArrayRef{i32Ty, f32Ty}, - ArrayRef{cstI32}); + op = builder.create(loc, TypeRange{i32Ty, f32Ty}, + ValueRange{cstI32}); verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, noAttrs); // Test collective params build method, with attributes. - op = builder.create(loc, ArrayRef{i32Ty, f32Ty}, - ArrayRef{cstI32}, attrs); + op = builder.create(loc, TypeRange{i32Ty, f32Ty}, + ValueRange{cstI32}, attrs); verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, attrs); } -- 2.7.4