diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -153,7 +153,7 @@ builder.getIntegerAttr(builder.getIndexType(), 0)); return builder.create( loc, LLVM::LLVMType::getInt8PtrTy(llvmDialect), globalPtr, - ArrayRef({cst0, cst0})); + {cst0, cst0}); } }; } // end anonymous namespace diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -153,7 +153,7 @@ builder.getIntegerAttr(builder.getIndexType(), 0)); return builder.create( loc, LLVM::LLVMType::getInt8PtrTy(llvmDialect), globalPtr, - ArrayRef({cst0, cst0})); + {cst0, cst0}); } }; } // end anonymous namespace diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -307,9 +307,8 @@ "unsigned alignment = 0", [{ if (alignment == 0) - return build(b, result, ArrayRef{}, value, addr, IntegerAttr()); - build(b, result, ArrayRef{}, value, addr, - b.getI64IntegerAttr(alignment)); + return build(b, result, {}, value, addr, IntegerAttr()); + build(b, result, {}, value, addr, b.getI64IntegerAttr(alignment)); }] >]; let parser = [{ return parseStoreOp(parser, result); }]; @@ -389,7 +388,7 @@ Variadic)>, Results<(outs Variadic)> { let builders = [OpBuilder< - "OpBuilder &builder, OperationState &result, LLVMFuncOp func," + "OpBuilder &builder, OperationState &result, LLVMFuncOp func, " "ValueRange operands, ArrayRef attributes = {}", [{ LLVMType resultType = func.getType().getFunctionResultType(); diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td @@ -188,7 +188,7 @@ (ins "OpBuilder &":$builder, "Location":$loc, "ValueRange":$operands, "ArrayRef":$attributes), [{ - return builder.create(loc, ArrayRef{}, operands, + return builder.create(loc, {}, operands, attributes); }] >, diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -677,19 +677,19 @@ let results = (outs Variadic); let builders = [OpBuilder< - "OpBuilder &builder, OperationState &result, FuncOp callee," + "OpBuilder &builder, OperationState &result, FuncOp callee, " "ValueRange operands = {}", [{ result.addOperands(operands); result.addAttribute("callee", builder.getSymbolRefAttr(callee)); result.addTypes(callee.getType().getResults()); }]>, OpBuilder< - "OpBuilder &builder, OperationState &result, SymbolRefAttr callee," + "OpBuilder &builder, OperationState &result, SymbolRefAttr callee, " "ArrayRef results, ValueRange operands = {}", [{ result.addOperands(operands); result.addAttribute("callee", callee); result.addTypes(results); }]>, OpBuilder< - "OpBuilder &builder, OperationState &result, StringRef callee," + "OpBuilder &builder, OperationState &result, StringRef callee, " "ArrayRef results, ValueRange operands = {}", [{ build(builder, result, builder.getSymbolRefAttr(callee), results, operands); diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -13,6 +13,128 @@ namespace mlir { +namespace detail { + +// Provides specializations for Derived::createImpl template member function. +template +class CreateSpecializations { +public: + using Types = ArrayRef; + using Values = ArrayRef; + + // Basic + template + auto create(PrefixArgs... prefixArgs, Args &&... args) { + return this->derived().template createImpl( + std::forward(prefixArgs)..., std::forward(args)...); + } + + template + auto create(PrefixArgs... prefixArgs, Types resultTypes, Args &&... args) { + return this->derived().template createImpl( + std::forward(prefixArgs)..., resultTypes, + std::forward(args)...); + } + + template + auto create(PrefixArgs... prefixArgs, Types resultTypes, Values operands, + Args &&... args) { + return this->derived().template createImpl( + std::forward(prefixArgs)..., resultTypes, operands, + std::forward(args)...); + } + + template + auto create(PrefixArgs... prefixArgs, Type resultType, Value arg0, + Values rest, Args &&... args) { + return this->derived().template createImpl( + std::forward(prefixArgs)..., resultType, arg0, rest, + std::forward(args)...); + } + + template + auto create(PrefixArgs... prefixArgs, FlatSymbolRefAttr sym, + Types resultTypes, Values operands, Args &&... args) { + return this->derived().template createImpl( + std::forward(prefixArgs)..., sym, resultTypes, operands, + std::forward(args)...); + } + + template + auto create(PrefixArgs... prefixArgs, StringRef sym, Types resultTypes, + Values operands, Args &&... args) { + return this->derived().template createImpl( + std::forward(prefixArgs)..., sym, resultTypes, operands, + std::forward(args)...); + } + +private: + Derived &derived() { return *static_cast(this); } +}; + +template +class ReplaceOpWithNewOpSpecializations { +public: + using Types = ArrayRef; + using Values = ArrayRef; + + // Basic + template + auto replaceOpWithNewOp(PrefixArgs... prefixArgs, Args &&... args) { + return this->derived().template replaceOpWithNewOpImpl( + std::forward(prefixArgs)..., std::forward(args)...); + } + + template + auto replaceOpWithNewOp(PrefixArgs... prefixArgs, Types resultTypes, + Args &&... args) { + return this->derived().template replaceOpWithNewOpImpl( + std::forward(prefixArgs)..., resultTypes, + std::forward(args)...); + } + + template + auto replaceOpWithNewOp(PrefixArgs... prefixArgs, Types resultTypes, + Values operands, Args &&... args) { + return this->derived().template replaceOpWithNewOpImpl( + std::forward(prefixArgs)..., resultTypes, operands, + std::forward(args)...); + } + + template + auto replaceOpWithNewOp(PrefixArgs... prefixArgs, Type resultType, Value arg0, + Values rest, Args &&... args) { + return this->derived().template replaceOpWithNewOpImpl( + std::forward(prefixArgs)..., resultType, arg0, rest, + std::forward(args)...); + } + + template + auto replaceOpWithNewOp(PrefixArgs... prefixArgs, FlatSymbolRefAttr sym, + Types resultTypes, Values operands, Args &&... args) { + return this->derived().template replaceOpWithNewOpImpl( + std::forward(prefixArgs)..., sym, resultTypes, operands, + std::forward(args)...); + } + + template + auto replaceOpWithNewOp(PrefixArgs... prefixArgs, StringRef sym, + Types resultTypes, Values operands, Args &&... args) { + return this->derived().template replaceOpWithNewOpImpl( + std::forward(prefixArgs)..., sym, resultTypes, operands, + std::forward(args)...); + } + +private: + Derived &derived() { return *static_cast(this); } +}; + +} // namespace detail + +} // namespace mlir + +namespace mlir { + class AffineExpr; class BlockAndValueMapping; class ModuleOp; @@ -174,7 +296,8 @@ /// This class helps build Operations. Operations that are created are /// automatically inserted at an insertion point. The builder is copyable. -class OpBuilder : public Builder { +class OpBuilder : public Builder, + public detail::CreateSpecializations { public: struct Listener; @@ -371,21 +494,6 @@ /// Creates an operation given the fields represented as an OperationState. Operation *createOperation(const OperationState &state); - /// Create an operation of specific op type at the current insertion point. - template - OpTy create(Location location, Args &&... args) { - OperationState state(location, OpTy::getOperationName()); - if (!state.name.getAbstractOperation()) - llvm::report_fatal_error("Building op `" + - state.name.getStringRef().str() + - "` but it isn't registered in this MLIRContext"); - OpTy::build(*this, state, std::forward(args)...); - auto *op = createOperation(state); - auto result = dyn_cast(op); - assert(result && "builder didn't return the right type"); - return result; - } - /// Create an operation of specific op type at the current insertion point, /// and immediately try to fold it. This functions populates 'results' with /// the results after folding the operation. @@ -469,6 +577,22 @@ Block::iterator insertPoint; /// The optional listener for events of this builder. Listener *listener; + +public: + /// Create an operation of specific op type at the current insertion point. + template + OpTy createImpl(Location location, Args &&... args) { + OperationState state(location, OpTy::getOperationName()); + if (!state.name.getAbstractOperation()) + llvm::report_fatal_error("Building op `" + + state.name.getStringRef().str() + + "` but it isn't registered in this MLIRContext"); + OpTy::build(*this, state, std::forward(args)...); + auto *op = createOperation(state); + auto result = dyn_cast(op); + assert(result && "builder didn't return the right type"); + return result; + } }; } // namespace mlir diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -113,7 +113,7 @@ /// or nullptr if this is a top-level operation. Operation *getParentOp(); - /// Return the closest surrounding parent operation that is of type 'OpTy'. + /// Return the closest surrounding parent operation that is of type `OpTy`. template OpTy getParentOfType() { auto *op = this; while ((op = op->getParentOp())) diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -245,19 +245,14 @@ /// to apply patterns and observe their effects (e.g. to keep worklists or /// other data structures up to date). /// -class PatternRewriter : public OpBuilder, public OpBuilder::Listener { +class PatternRewriter + : public OpBuilder, + public OpBuilder::Listener, + public detail::CreateSpecializations, + public detail::ReplaceOpWithNewOpSpecializations { public: - /// Create operation of specific op type at the current insertion point - /// without verifying to see if it is valid. - template - OpTy create(Location location, Args... args) { - OperationState state(location, OpTy::getOperationName()); - OpTy::build(*this, state, args...); - auto *op = createOperation(state); - auto result = dyn_cast(op); - assert(result && "Builder didn't return the right type"); - return result; - } + using detail::CreateSpecializations::create; /// Creates an operation of specific op type at the current insertion point. /// If the result is an invalid op (the verifier hook fails), emit an error @@ -305,14 +300,6 @@ /// values. virtual void replaceOp(Operation *op, ValueRange newValues); - /// Replaces the result op with a new op that is created without verification. - /// The result values of the two ops must be the same types. - template - void replaceOpWithNewOp(Operation *op, Args &&... args) { - auto newOp = create(op->getLoc(), std::forward(args)...); - replaceOpWithResultsOfAnotherOp(op, newOp.getOperation()); - } - /// This method erases an operation that is known to have no uses. virtual void eraseOp(Operation *op); @@ -412,6 +399,27 @@ /// 'op' and 'newOp' are known to have the same number of results, replace the /// uses of op with uses of newOp. void replaceOpWithResultsOfAnotherOp(Operation *op, Operation *newOp); + +public: + /// Create operation of specific op type at the current insertion point + /// without verifying to see if it is valid. + template + OpTy createImpl(Location location, Args... args) { + OperationState state(location, OpTy::getOperationName()); + OpTy::build(*this, state, args...); + auto *op = createOperation(state); + auto result = dyn_cast(op); + assert(result && "Builder didn't return the right type"); + return result; + } + + /// Replaces the result op with a new op that is created without verification. + /// The result values of the two ops must be the same types. + template + void replaceOpWithNewOpImpl(Operation *op, Args &&... args) { + auto newOp = create(op->getLoc(), std::forward(args)...); + replaceOpWithResultsOfAnotherOp(op, newOp.getOperation()); + } }; //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp --- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp +++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp @@ -265,8 +265,8 @@ auto index = builder.create(loc, getInt32Type(), builder.getI32IntegerAttr(pos)); - auto gep = builder.create(loc, getPointerPointerType(), list, - ArrayRef{index}); + auto gep = + builder.create(loc, getPointerPointerType(), list, {index}); builder.create(loc, casted, gep); } @@ -408,9 +408,10 @@ auto gpuModule = allocatePointer(builder, loc); auto gpuModuleLoad = getOperation().lookupSymbol(kGpuModuleLoadName); - builder.create(loc, ArrayRef{getGpuRuntimeResultType()}, + builder.create(loc, {getGpuRuntimeResultType()}, builder.getSymbolRefAttr(gpuModuleLoad), ArrayRef{gpuModule, data}); + TypeRange{getGpuRuntimeResultType()}; // Get the function from the module. The name corresponds to the name of // the kernel function. auto gpuOwningModuleRef = @@ -421,15 +422,15 @@ auto gpuModuleGetFunction = getOperation().lookupSymbol(kGpuModuleGetFunctionName); builder.create( - loc, ArrayRef{getGpuRuntimeResultType()}, + loc, {getGpuRuntimeResultType()}, builder.getSymbolRefAttr(gpuModuleGetFunction), ArrayRef{gpuFunction, gpuOwningModuleRef, kernelName}); // Grab the global stream needed for execution. auto gpuGetStreamHelper = getOperation().lookupSymbol(kGpuGetStreamHelperName); auto gpuStream = builder.create( - loc, ArrayRef{getPointerType()}, - builder.getSymbolRefAttr(gpuGetStreamHelper), ArrayRef{}); + loc, {getPointerType()}, builder.getSymbolRefAttr(gpuGetStreamHelper), + ArrayRef{}); // Invoke the function with required arguments. auto gpuLaunchKernel = getOperation().lookupSymbol(kGpuLaunchKernelName); @@ -443,7 +444,7 @@ auto nullpointer = builder.create(loc, getPointerPointerType(), zero); builder.create( - loc, ArrayRef{getGpuRuntimeResultType()}, + loc, {getGpuRuntimeResultType()}, builder.getSymbolRefAttr(gpuLaunchKernel), ArrayRef{gpuFunctionRef, launchOp.getOperand(0), launchOp.getOperand(1), launchOp.getOperand(2), @@ -455,9 +456,9 @@ // Sync on the stream to make it synchronous. auto gpuStreamSync = getOperation().lookupSymbol(kGpuStreamSynchronizeName); - builder.create(loc, ArrayRef{getGpuRuntimeResultType()}, + builder.create(loc, {getGpuRuntimeResultType()}, builder.getSymbolRefAttr(gpuStreamSync), - ArrayRef(gpuStream.getResult(0))); + (gpuStream.getResult(0))); launchOp.erase(); } diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h @@ -101,7 +101,7 @@ auto elementType = global.getType().getArrayElementType(); Value memory = rewriter.create( loc, elementType.getPointerTo(global.addr_space().getZExtValue()), - address, ArrayRef{zero, zero}); + address, {zero, zero}); // Build a memref descriptor pointing to the buffer to plug with the // existing memref infrastructure. This may use more registers than diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp --- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp @@ -172,8 +172,7 @@ // Create vulkan launch call op. auto vulkanLaunchCallOp = builder.create( - loc, ArrayRef{}, builder.getSymbolRefAttr(kVulkanLaunch), - vulkanLaunchOperands); + loc, {}, builder.getSymbolRefAttr(kVulkanLaunch), vulkanLaunchOperands); // Set SPIR-V binary shader data as an attribute. vulkanLaunchCallOp.setAttr( diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp --- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp @@ -255,7 +255,7 @@ } // Create call to `bindMemRef`. builder.create( - loc, ArrayRef{getVoidType()}, + loc, {getVoidType()}, builder.getSymbolRefAttr( StringRef(symbolName.data(), symbolName.size())), ArrayRef{vulkanRuntime, descriptorSet, descriptorBinding, @@ -382,8 +382,8 @@ Location loc = cInterfaceVulkanLaunchCallOp.getLoc(); // Create call to `initVulkan`. auto initVulkanCall = builder.create( - loc, ArrayRef{getPointerType()}, - builder.getSymbolRefAttr(kInitVulkan), ArrayRef{}); + loc, {getPointerType()}, builder.getSymbolRefAttr(kInitVulkan), + ArrayRef{}); // 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); @@ -405,33 +405,31 @@ // 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), + loc, {getVoidType()}, builder.getSymbolRefAttr(kSetBinaryShader), ArrayRef{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, {getVoidType()}, builder.getSymbolRefAttr(kSetEntryPoint), ArrayRef{vulkanRuntime, entryPointName}); // Create number of local workgroup for each dimension. builder.create( - loc, ArrayRef{getVoidType()}, - builder.getSymbolRefAttr(kSetNumWorkGroups), + loc, {getVoidType()}, builder.getSymbolRefAttr(kSetNumWorkGroups), ArrayRef{vulkanRuntime, cInterfaceVulkanLaunchCallOp.getOperand(0), cInterfaceVulkanLaunchCallOp.getOperand(1), cInterfaceVulkanLaunchCallOp.getOperand(2)}); // Create call to `runOnVulkan` runtime function. - builder.create(loc, ArrayRef{getVoidType()}, + builder.create(loc, {getVoidType()}, builder.getSymbolRefAttr(kRunOnVulkan), ArrayRef{vulkanRuntime}); // Create call to 'deinitVulkan' runtime function. - builder.create(loc, ArrayRef{getVoidType()}, + builder.create(loc, {getVoidType()}, builder.getSymbolRefAttr(kDeinitVulkan), ArrayRef{vulkanRuntime}); diff --git a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp --- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp +++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp @@ -151,7 +151,7 @@ return failure(); rewriter.replaceOpWithNewOp( - op, libraryCallName.getValue(), ArrayRef{}, + op, {}, libraryCallName.getValue(), createTypeCanonicalizedMemRefOperands(rewriter, op.getLoc(), op.getOperands())); return success(); diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp @@ -561,8 +561,7 @@ LogicalResult matchAndRewrite(spirv::ReturnOp returnOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(returnOp, ArrayRef(), - ArrayRef()); + rewriter.replaceOpWithNewOp(returnOp, {}, {}); return success(); } }; @@ -574,8 +573,7 @@ LogicalResult matchAndRewrite(spirv::ReturnValueOp returnValueOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(returnValueOp, ArrayRef(), - operands); + rewriter.replaceOpWithNewOp(returnValueOp, operands); return success(); } }; diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -857,10 +857,10 @@ Value linearized = indices.front(); for (int i = 1, nSizes = allocSizes.size(); i < nSizes; ++i) { - linearized = builder.create( - loc, this->getIndexType(), ArrayRef{linearized, allocSizes[i]}); - linearized = builder.create( - loc, this->getIndexType(), ArrayRef{linearized, indices[i]}); + linearized = builder.create(loc, this->getIndexType(), + linearized, allocSizes[i]); + linearized = builder.create(loc, this->getIndexType(), + linearized, indices[i]); } return linearized; } @@ -1647,8 +1647,8 @@ Value offset = createBumpToAlign(loc, rewriter, intVal, accessAlignment); Value aligned = rewriter.create( loc, allocatedBytePtr.getType(), allocatedBytePtr, offset); - alignedBytePtr = rewriter.create( - loc, elementPtrType, ArrayRef(aligned)); + alignedBytePtr = + rewriter.create(loc, elementPtrType, aligned); } memRefDescriptor.setAlignedPtr(rewriter, loc, alignedBytePtr); @@ -1705,8 +1705,8 @@ // Compute the total number of memref elements. cumulativeSize = sizes.front(); for (unsigned i = 1, e = sizes.size(); i < e; ++i) - cumulativeSize = rewriter.create( - loc, getIndexType(), ArrayRef{cumulativeSize, sizes[i]}); + cumulativeSize = rewriter.create(loc, getIndexType(), + cumulativeSize, sizes[i]); // Compute the size of an individual element. This emits the MLIR equivalent // of the following sizeof(...) implementation in LLVM IR: @@ -1719,12 +1719,12 @@ .getPointerTo(); auto nullPtr = rewriter.create(loc, convertedPtrType); one = createIndexConstant(rewriter, loc, 1); - auto gep = rewriter.create(loc, convertedPtrType, - ArrayRef{nullPtr, one}); + auto gep = + rewriter.create(loc, convertedPtrType, nullPtr, {one}); auto elementSize = rewriter.create(loc, getIndexType(), gep); - cumulativeSize = rewriter.create( - loc, getIndexType(), ArrayRef{cumulativeSize, elementSize}); + cumulativeSize = rewriter.create(loc, getIndexType(), + cumulativeSize, elementSize); } /// Returns the type of a pointer to an element of the memref. @@ -2135,7 +2135,7 @@ op->getLoc(), getVoidPtrType(), memref.allocatedPtr(rewriter, op->getLoc())); rewriter.replaceOpWithNewOp( - op, ArrayRef(), rewriter.getSymbolRefAttr(freeFunc), casted); + op, {}, rewriter.getSymbolRefAttr(freeFunc), casted); return success(); } }; @@ -2575,13 +2575,12 @@ // 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, {}, {}, op->getAttrs()); return success(); } if (numArguments == 1) { - rewriter.replaceOpWithNewOp( - op, ArrayRef(), updatedOperands, op->getAttrs()); + rewriter.replaceOpWithNewOp(op, {}, updatedOperands, + op->getAttrs()); return success(); } @@ -2596,8 +2595,7 @@ op->getLoc(), packedType, packed, updatedOperands[i], rewriter.getI64ArrayAttr(i)); } - rewriter.replaceOpWithNewOp(op, ArrayRef(), packed, - op->getAttrs()); + rewriter.replaceOpWithNewOp(op, {}, packed, op->getAttrs()); return success(); } }; diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2003,9 +2003,8 @@ Value cst0 = builder.create( loc, LLVM::LLVMType::getInt64Ty(llvmDialect), builder.getIntegerAttr(builder.getIndexType(), 0)); - return builder.create(loc, - LLVM::LLVMType::getInt8PtrTy(llvmDialect), - globalPtr, ArrayRef({cst0, cst0})); + return builder.create( + loc, LLVM::LLVMType::getInt8PtrTy(llvmDialect), globalPtr, {cst0, cst0}); } bool mlir::LLVM::satisfiesLLVMModule(Operation *op) { diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -804,7 +804,7 @@ OpBuilder::InsertionGuard guard(builder); Region *bodyRegion = result.addRegion(); - Block *body = builder.createBlock(bodyRegion, {}, ArrayRef{type, type}); + Block *body = builder.createBlock(bodyRegion, {}, {type, type}); if (bodyBuilderFn) bodyBuilderFn(builder, result.location, body->getArgument(0), body->getArgument(1));