diff --git a/mlir/docs/BufferDeallocationInternals.md b/mlir/docs/BufferDeallocationInternals.md --- a/mlir/docs/BufferDeallocationInternals.md +++ b/mlir/docs/BufferDeallocationInternals.md @@ -779,8 +779,8 @@ ## Known Limitations BufferDeallocation introduces additional copies using allocations from the -“std” dialect (“std.alloc”). Analogous, all deallocations use the “std” -dialect-free operation “std.dealloc”. The actual copy process is realized using -“linalg.copy”. Furthermore, buffers are essentially immutable after their -creation in a block. Another limitations are known in the case using -unstructered control flow. +“memref” dialect (“memref.alloc”). Analogous, all deallocations use the +“memref” dialect-free operation “memref.dealloc”. The actual copy process is +realized using “linalg.copy”. Furthermore, buffers are essentially immutable +after their creation in a block. Another limitations are known in the case +using unstructered control flow. diff --git a/mlir/docs/Dialects/Linalg.md b/mlir/docs/Dialects/Linalg.md --- a/mlir/docs/Dialects/Linalg.md +++ b/mlir/docs/Dialects/Linalg.md @@ -406,9 +406,9 @@ #map0 = affine_map<(d0, d1)[s0, s1, s2] -> (d0 * s1 + s0 + d1 * s2)> func @example(%arg0: memref, %arg1: memref, %arg2: memref) { - %0 = memref_cast %arg0 : memref to memref - %1 = memref_cast %arg1 : memref to memref - %2 = memref_cast %arg2 : memref to memref + %0 = memref.cast %arg0 : memref to memref + %1 = memref.cast %arg1 : memref to memref + %2 = memref.cast %arg2 : memref to memref call @pointwise_add(%0, %1, %2) : (memref, memref, memref) -> () return } @@ -518,9 +518,9 @@ generally alias the operand `view`. At the moment the existing ops are: ``` -* `std.view`, +* `memref.view`, * `std.subview`, -* `std.transpose`. +* `memref.transpose`. * `linalg.range`, * `linalg.slice`, * `linalg.reshape`, diff --git a/mlir/docs/Traits.md b/mlir/docs/Traits.md --- a/mlir/docs/Traits.md +++ b/mlir/docs/Traits.md @@ -211,7 +211,7 @@ This trait is carried by region holding operations that define a new scope for automatic allocation. Such allocations are automatically freed when control is transferred back from the regions of such operations. As an example, allocations -performed by [`std.alloca`](Dialects/Standard.md#stdalloca-allocaop) are +performed by [`memref.alloca`](Dialects/Standard.md#stdalloca-allocaop) are automatically freed when control leaves the region of its closest surrounding op that has the trait AutomaticAllocationScope. diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -16,6 +16,7 @@ #include "toy/Passes.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -36,7 +37,7 @@ /// Insert an allocation and deallocation for the given MemRefType. static Value insertAllocAndDealloc(MemRefType type, Location loc, PatternRewriter &rewriter) { - auto alloc = rewriter.create(loc, type); + auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. auto *parentBlock = alloc->getBlock(); @@ -44,7 +45,7 @@ // Make sure to deallocate this alloc at the end of the block. This is fine // as toy functions have no control flow. - auto dealloc = rewriter.create(loc, alloc); + auto dealloc = rewriter.create(loc, alloc); dealloc->moveBefore(&parentBlock->back()); return alloc; } @@ -152,8 +153,8 @@ if (!valueShape.empty()) { for (auto i : llvm::seq( - 0, *std::max_element(valueShape.begin(), valueShape.end()))) - constantIndices.push_back(rewriter.create(loc, i)); + 0, *std::max_element(valueShape.begin(), valueShape.end()))) + constantIndices.push_back(rewriter.create(loc, i)); } else { // This is the case of a tensor of rank 0. constantIndices.push_back(rewriter.create(loc, 0)); @@ -284,7 +285,8 @@ // We define the specific operations, or dialects, that are legal targets for // this lowering. In our case, we are lowering to a combination of the // `Affine` and `Standard` dialects. - target.addLegalDialect(); + target.addLegalDialect(); // We also define the Toy dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. Given that we actually want diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -16,6 +16,7 @@ #include "toy/Passes.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -36,7 +37,7 @@ /// Insert an allocation and deallocation for the given MemRefType. static Value insertAllocAndDealloc(MemRefType type, Location loc, PatternRewriter &rewriter) { - auto alloc = rewriter.create(loc, type); + auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. auto *parentBlock = alloc->getBlock(); @@ -44,7 +45,7 @@ // Make sure to deallocate this alloc at the end of the block. This is fine // as toy functions have no control flow. - auto dealloc = rewriter.create(loc, alloc); + auto dealloc = rewriter.create(loc, alloc); dealloc->moveBefore(&parentBlock->back()); return alloc; } @@ -152,8 +153,8 @@ if (!valueShape.empty()) { for (auto i : llvm::seq( - 0, *std::max_element(valueShape.begin(), valueShape.end()))) - constantIndices.push_back(rewriter.create(loc, i)); + 0, *std::max_element(valueShape.begin(), valueShape.end()))) + constantIndices.push_back(rewriter.create(loc, i)); } else { // This is the case of a tensor of rank 0. constantIndices.push_back(rewriter.create(loc, 0)); @@ -283,7 +284,8 @@ // We define the specific operations, or dialects, that are legal targets for // this lowering. In our case, we are lowering to a combination of the // `Affine` and `Standard` dialects. - target.addLegalDialect(); + target.addLegalDialect(); // We also define the Toy dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. Given that we actually want diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -16,6 +16,7 @@ #include "toy/Passes.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/DialectConversion.h" @@ -36,7 +37,7 @@ /// Insert an allocation and deallocation for the given MemRefType. static Value insertAllocAndDealloc(MemRefType type, Location loc, PatternRewriter &rewriter) { - auto alloc = rewriter.create(loc, type); + auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. auto *parentBlock = alloc->getBlock(); @@ -44,7 +45,7 @@ // Make sure to deallocate this alloc at the end of the block. This is fine // as toy functions have no control flow. - auto dealloc = rewriter.create(loc, alloc); + auto dealloc = rewriter.create(loc, alloc); dealloc->moveBefore(&parentBlock->back()); return alloc; } @@ -152,8 +153,8 @@ if (!valueShape.empty()) { for (auto i : llvm::seq( - 0, *std::max_element(valueShape.begin(), valueShape.end()))) - constantIndices.push_back(rewriter.create(loc, i)); + 0, *std::max_element(valueShape.begin(), valueShape.end()))) + constantIndices.push_back(rewriter.create(loc, i)); } else { // This is the case of a tensor of rank 0. constantIndices.push_back(rewriter.create(loc, 0)); @@ -284,7 +285,8 @@ // We define the specific operations, or dialects, that are legal targets for // this lowering. In our case, we are lowering to a combination of the // `Affine` and `Standard` dialects. - target.addLegalDialect(); + target.addLegalDialect(); // We also define the Toy dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. Given that we actually want diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -72,7 +72,8 @@ /// Creates a pass to convert the Standard dialect into the LLVMIR dialect. /// stdlib malloc/free is used by default for allocating memrefs allocated with -/// std.alloc, while LLVM's alloca is used for those allocated with std.alloca. +/// memref.alloc, while LLVM's alloca is used for those allocated with +/// memref.alloca. std::unique_ptr> createLowerToLLVMPass(const LowerToLLVMOptions &options = LowerToLLVMOptions::getDefaultOptions()); diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(Math) add_subdirectory(Linalg) add_subdirectory(LLVMIR) +add_subdirectory(MemRef) add_subdirectory(OpenACC) add_subdirectory(OpenMP) add_subdirectory(PDL) diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -812,7 +812,7 @@ let summary = "GPU memory allocation operation."; let description = [{ The `gpu.alloc` operation allocates a region of memory on the GPU. It is - similar to the `std.alloc` op, but supports asynchronous GPU execution. + similar to the `memref.alloc` op, but supports asynchronous GPU execution. The op does not execute before all async dependencies have finished executing. @@ -850,7 +850,7 @@ let description = [{ The `gpu.dealloc` operation frees the region of memory referenced by a memref which was originally created by the `gpu.alloc` operation. It is - similar to the `std.dealloc` op, but supports asynchronous GPU execution. + similar to the `memref.dealloc` op, but supports asynchronous GPU execution. The op does not execute before all async dependencies have finished executing. diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h --- a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h @@ -35,6 +35,9 @@ }; using folded_math_tanh = FoldedValueBuilder; +using folded_memref_alloc = FoldedValueBuilder; +using folded_memref_cast = FoldedValueBuilder; +using folded_memref_view = FoldedValueBuilder; using folded_std_constant_index = FoldedValueBuilder; using folded_std_constant_float = FoldedValueBuilder; using folded_std_constant_int = FoldedValueBuilder; @@ -43,7 +46,6 @@ using folded_std_muli = FoldedValueBuilder; using folded_std_addi = FoldedValueBuilder; using folded_std_addf = FoldedValueBuilder; -using folded_std_alloc = FoldedValueBuilder; using folded_std_constant = FoldedValueBuilder; using folded_std_constant_float = FoldedValueBuilder; using folded_std_constant_index = FoldedValueBuilder; @@ -52,13 +54,11 @@ using folded_std_index_cast = FoldedValueBuilder; using folded_std_muli = FoldedValueBuilder; using folded_std_mulf = FoldedValueBuilder; -using folded_std_memref_cast = FoldedValueBuilder; using folded_std_select = FoldedValueBuilder; using folded_std_load = FoldedValueBuilder; using folded_std_subi = FoldedValueBuilder; using folded_std_sub_view = FoldedValueBuilder; using folded_std_tensor_load = FoldedValueBuilder; -using folded_std_view = FoldedValueBuilder; using folded_std_zero_extendi = FoldedValueBuilder; using folded_std_sign_extendi = FoldedValueBuilder; using folded_tensor_extract = FoldedValueBuilder; diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -34,11 +34,11 @@ std::unique_ptr> createLinalgPromotionPass(); /// Create a pass to convert Linalg operations to scf.for loops and -/// std.load/std.store accesses. +/// std.load/memref.store accesses. std::unique_ptr> createConvertLinalgToLoopsPass(); /// Create a pass to convert Linalg operations to scf.parallel loops and -/// std.load/std.store accesses. +/// std.load/memref.store accesses. std::unique_ptr> createConvertLinalgToParallelLoopsPass(); /// Create a pass to convert Linalg operations to affine.for loops and diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -822,7 +822,7 @@ /// Match and rewrite for the pattern: /// ``` /// %alloc = ... -/// [optional] %view = std.view %alloc ... +/// [optional] %view = memref.view %alloc ... /// %subView = subview %allocOrView ... /// [optional] linalg.fill(%allocOrView, %cst) ... /// ... @@ -832,7 +832,7 @@ /// into /// ``` /// [unchanged] %alloc = ... -/// [unchanged] [optional] %view = std.view %alloc ... +/// [unchanged] [optional] %view = memref.view %alloc ... /// [unchanged] [unchanged] %subView = subview %allocOrView ... /// ... /// vector.transfer_read %in[...], %cst ... @@ -853,7 +853,7 @@ /// Match and rewrite for the pattern: /// ``` /// %alloc = ... -/// [optional] %view = std.view %alloc ... +/// [optional] %view = memref.view %alloc ... /// %subView = subview %allocOrView... /// ... /// vector.transfer_write %..., %allocOrView[...] @@ -862,7 +862,7 @@ /// into /// ``` /// [unchanged] %alloc = ... -/// [unchanged] [optional] %view = std.view %alloc ... +/// [unchanged] [optional] %view = memref.view %alloc ... /// [unchanged] %subView = subview %allocOrView... /// ... /// vector.transfer_write %..., %out[...] diff --git a/mlir/include/mlir/Dialect/MemRef/CMakeLists.txt b/mlir/include/mlir/Dialect/MemRef/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/MemRef/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(IR) diff --git a/mlir/include/mlir/Dialect/MemRef/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/MemRef/IR/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/MemRef/IR/CMakeLists.txt @@ -0,0 +1,2 @@ +add_mlir_dialect(MemRefOps memref) +add_mlir_doc(MemRefOps -gen-dialect-doc MemRefOps Dialects/) diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h b/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h @@ -0,0 +1,34 @@ +//===- MemRef.h - MemRef dialect --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_MEMREF_IR_MEMREF_H_ +#define MLIR_DIALECT_MEMREF_IR_MEMREF_H_ + +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/CallInterfaces.h" +#include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "mlir/Interfaces/ViewLikeInterface.h" + +//===----------------------------------------------------------------------===// +// MemRef Dialect +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/MemRef/IR/MemRefOpsDialect.h.inc" + +//===----------------------------------------------------------------------===// +// MemRef Dialect Operations +//===----------------------------------------------------------------------===// + +#define GET_OP_CLASSES +#include "mlir/Dialect/MemRef/IR/MemRefOps.h.inc" + +#endif // MLIR_DIALECT_MEMREF_IR_MEMREF_H_ diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefBase.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefBase.td new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefBase.td @@ -0,0 +1,24 @@ +//===- MemRefBase.td - Base definitions for memref dialect -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MEMREF_BASE +#define MEMREF_BASE + +include "mlir/IR/OpBase.td" + +def MemRef_Dialect : Dialect { + let name = "memref"; + let cppNamespace = "::mlir::memref"; + let description = [{ + The `memref` dialect is intended to hold core memref creation and + manipulation ops, which are not strongly associated with any particular + other dialect or domain abstraction. + }]; +} + +#endif // MEMREF_BASE diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td @@ -0,0 +1,681 @@ +//===- MemRefOps.td - MemRef op definitions ----------------*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MEMREF_OPS +#define MEMREF_OPS + +include "mlir/Dialect/MemRef/IR/MemRefBase.td" +include "mlir/Interfaces/CastInterfaces.td" +include "mlir/Interfaces/SideEffectInterfaces.td" +include "mlir/Interfaces/ViewLikeInterface.td" +include "mlir/IR/SymbolInterfaces.td" + +class MemRef_Op traits = []> + : Op { + let printer = [{ return ::print(p, *this); }]; + let verifier = [{ return ::verify(*this); }]; + let parser = [{ return ::parse$cppClass(parser, result); }]; +} + +//===----------------------------------------------------------------------===// +// AllocLikeOp +//===----------------------------------------------------------------------===// + +// Base class for memref allocating ops: alloca and alloc. +// +// %0 = alloclike(%m)[%s] : memref<8x?xf32, (d0, d1)[s0] -> ((d0 + s0), d1)> +// +class AllocLikeOp traits = []> : + MemRef_Op { + + let arguments = (ins Variadic:$dynamicSizes, + // The symbolic operands (the ones in square brackets) bind + // to the symbols of the memref's layout map. + Variadic:$symbolOperands, + Confined, [IntMinValue<0>]>:$alignment); + let results = (outs Res]>:$memref); + + let builders = [ + OpBuilderDAG<(ins "MemRefType":$memrefType, + CArg<"IntegerAttr", "IntegerAttr()">:$alignment), [{ + return build($_builder, $_state, memrefType, {}, alignment); + }]>, + OpBuilderDAG<(ins "MemRefType":$memrefType, "ValueRange":$dynamicSizes, + CArg<"IntegerAttr", "IntegerAttr()">:$alignment), [{ + return build($_builder, $_state, memrefType, dynamicSizes, {}, alignment); + }]>, + OpBuilderDAG<(ins "MemRefType":$memrefType, "ValueRange":$dynamicSizes, + "ValueRange":$symbolOperands, + CArg<"IntegerAttr", "{}">:$alignment), [{ + $_state.types.push_back(memrefType); + $_state.addOperands(dynamicSizes); + $_state.addOperands(symbolOperands); + $_state.addAttribute(getOperandSegmentSizeAttr(), + $_builder.getI32VectorAttr({ + static_cast(dynamicSizes.size()), + static_cast(symbolOperands.size())})); + if (alignment) + $_state.addAttribute(getAlignmentAttrName(), alignment); + }]>]; + + let extraClassDeclaration = [{ + static StringRef getAlignmentAttrName() { return "alignment"; } + + MemRefType getType() { return getResult().getType().cast(); } + + /// Returns the dynamic sizes for this alloc operation if specified. + operand_range getDynamicSizes() { return dynamicSizes(); } + }]; + + let assemblyFormat = [{ + `(`$dynamicSizes`)` (`` `[` $symbolOperands^ `]`)? attr-dict `:` type($memref) + }]; + + let hasCanonicalizer = 1; +} + +//===----------------------------------------------------------------------===// +// BaseCastOp +//===----------------------------------------------------------------------===// + +// Base class for standard cast operations. Requires single operand and result, +// but does not constrain them to specific types. +class CastOp traits = []> : + MemRef_Op + ]> { + let results = (outs AnyType); + + let builders = [ + OpBuilderDAG<(ins "Value":$source, "Type":$destType), [{ + impl::buildCastOp($_builder, $_state, source, destType); + }]> + ]; + + let parser = [{ + return impl::parseCastOp(parser, result); + }]; + let printer = [{ + return printStandardCastOp(this->getOperation(), p); + }]; + + // Cast operations are fully verified by its traits. + let verifier = ?; +} + +//===----------------------------------------------------------------------===// +// AllocOp +//===----------------------------------------------------------------------===// + +def MemRef_AllocOp : AllocLikeOp<"alloc", DefaultResource> { + let summary = "memory allocation operation"; + let description = [{ + The `alloc` operation allocates a region of memory, as specified by its + memref type. + + Example: + + ```mlir + %0 = memref.alloc() : memref<8x64xf32, 1> + ``` + + The optional list of dimension operands are bound to the dynamic dimensions + specified in its memref type. In the example below, the ssa value '%d' is + bound to the second dimension of the memref (which is dynamic). + + ```mlir + %0 = memref.alloc(%d) : memref<8x?xf32, 1> + ``` + + The optional list of symbol operands are bound to the symbols of the + memrefs affine map. In the example below, the ssa value '%s' is bound to + the symbol 's0' in the affine map specified in the allocs memref type. + + ```mlir + %0 = memref.alloc()[%s] : memref<8x64xf32, + affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> + ``` + + This operation returns a single ssa value of memref type, which can be used + by subsequent load and store operations. + + The optional `alignment` attribute may be specified to ensure that the + region of memory that will be indexed is aligned at the specified byte + boundary. + + ```mlir + %0 = memref.alloc()[%s] {alignment = 8} : + memref<8x64xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> + ``` + }]; +} + +//===----------------------------------------------------------------------===// +// AllocaOp +//===----------------------------------------------------------------------===// + +def MemRef_AllocaOp : AllocLikeOp<"alloca", AutomaticAllocationScopeResource> { + let summary = "stack memory allocation operation"; + let description = [{ + The `alloca` operation allocates memory on the stack, to be automatically + released when control transfers back from the region of its closest + surrounding operation with an + [`AutomaticAllocationScope`](../Traits.md#automaticallocationscope) trait. + The amount of memory allocated is specified by its memref and additional + operands. For example: + + ```mlir + %0 = memref.alloca() : memref<8x64xf32> + ``` + + The optional list of dimension operands are bound to the dynamic dimensions + specified in its memref type. In the example below, the SSA value '%d' is + bound to the second dimension of the memref (which is dynamic). + + ```mlir + %0 = memref.alloca(%d) : memref<8x?xf32> + ``` + + The optional list of symbol operands are bound to the symbols of the + memref's affine map. In the example below, the SSA value '%s' is bound to + the symbol 's0' in the affine map specified in the allocs memref type. + + ```mlir + %0 = memref.alloca()[%s] : memref<8x64xf32, + affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>> + ``` + + This operation returns a single SSA value of memref type, which can be used + by subsequent load and store operations. An optional alignment attribute, if + specified, guarantees alignment at least to that boundary. If not specified, + an alignment on any convenient boundary compatible with the type will be + chosen. + }]; +} + +//===----------------------------------------------------------------------===// +// CastOp +//===----------------------------------------------------------------------===// + +def MemRef_CastOp : CastOp<"cast", [NoSideEffect]> { + let summary = "memref cast operation"; + let description = [{ + Syntax: + + ``` + operation ::= ssa-id `=` `memref.cast` ssa-use `:` type `to` type + ``` + + The `memref.cast` operation converts a memref from one type to an equivalent + type with a compatible shape. The source and destination types are + compatible if: + + a. Both are ranked memref types with the same element type, address space, + and rank and: + 1. Both have the same layout or both have compatible strided layouts. + 2. The individual sizes (resp. offset and strides in the case of strided + memrefs) may convert constant dimensions to dynamic dimensions and + vice-versa. + + If the cast converts any dimensions from an unknown to a known size, then it + acts as an assertion that fails at runtime if the dynamic dimensions + disagree with resultant destination size. + + Example: + + ```mlir + // Assert that the input dynamic shape matches the destination static shape. + %2 = memref.cast %1 : memref to memref<4x4xf32> + // Erase static shape information, replacing it with dynamic information. + %3 = memref.cast %1 : memref<4xf32> to memref + + // The same holds true for offsets and strides. + + // Assert that the input dynamic shape matches the destination static stride. + %4 = memref.cast %1 : memref<12x4xf32, offset:?, strides: [?, ?]> to + memref<12x4xf32, offset:5, strides: [4, 1]> + // Erase static offset and stride information, replacing it with + // dynamic information. + %5 = memref.cast %1 : memref<12x4xf32, offset:5, strides: [4, 1]> to + memref<12x4xf32, offset:?, strides: [?, ?]> + ``` + + b. Either or both memref types are unranked with the same element type, and + address space. + + Example: + + ```mlir + Cast to concrete shape. + %4 = memref.cast %1 : memref<*xf32> to memref<4x?xf32> + + Erase rank information. + %5 = memref.cast %1 : memref<4x?xf32> to memref<*xf32> + ``` + }]; + + let arguments = (ins AnyRankedOrUnrankedMemRef:$source); + let results = (outs AnyRankedOrUnrankedMemRef:$dest); + let assemblyFormat = "$source attr-dict `:` type($source) `to` type($dest)"; + let verifier = "return impl::verifyCastOp(*this, areCastCompatible);"; + let builders = [ + OpBuilderDAG<(ins "Value":$source, "Type":$destType), [{ + impl::buildCastOp($_builder, $_state, source, destType); + }]> + ]; + + let extraClassDeclaration = [{ + /// Fold the given CastOp into consumer op. + static bool canFoldIntoConsumerOp(CastOp castOp); + }]; + + let hasFolder = 1; +} + +//===----------------------------------------------------------------------===// +// DeallocOp +//===----------------------------------------------------------------------===// + +def MemRef_DeallocOp : MemRef_Op<"dealloc", [MemRefsNormalizable]> { + let summary = "memory deallocation operation"; + let description = [{ + The `dealloc` operation frees the region of memory referenced by a memref + which was originally created by the `alloc` operation. + The `dealloc` operation should not be called on memrefs which alias an + alloc'd memref (e.g. memrefs returned by `view` operations). + + Example: + + ```mlir + %0 = memref.alloc() : memref<8x64xf32, (d0, d1) -> (d0, d1), 1> + memref.dealloc %0 : memref<8x64xf32, (d0, d1) -> (d0, d1), 1> + ``` + }]; + + let arguments = (ins Arg:$memref); + + let hasCanonicalizer = 1; + let hasFolder = 1; + let assemblyFormat = "$memref attr-dict `:` type($memref)"; +} + +//===----------------------------------------------------------------------===// +// GetGlobalOp +//===----------------------------------------------------------------------===// + +def MemRef_GetGlobalOp : MemRef_Op<"get_global", + [NoSideEffect, DeclareOpInterfaceMethods]> { + let summary = "get the memref pointing to a global variable"; + let description = [{ + The `memref.get_global` operation retrieves the memref pointing to a + named global variable. If the global variable is marked constant, writing + to the result memref (such as through a `memref.store` operation) is + undefined. + + Example: + + ```mlir + %x = memref.get_global @foo : memref<2xf32> + ``` + }]; + + let arguments = (ins FlatSymbolRefAttr:$name); + let results = (outs AnyStaticShapeMemRef:$result); + let assemblyFormat = "$name `:` type($result) attr-dict"; + + // `GetGlobalOp` is fully verified by its traits. + let verifier = ?; +} + +//===----------------------------------------------------------------------===// +// GlobalOp +//===----------------------------------------------------------------------===// + +def MemRef_GlobalOp : MemRef_Op<"global", [Symbol]> { + let summary = "declare or define a global memref variable"; + let description = [{ + The `memref.global` operation declares or defines a named global variable. + The backing memory for the variable is allocated statically and is described + by the type of the variable (which should be a statically shaped memref + type). The operation is a declaration if no `inital_value` is specified, + else it is a definition. The `initial_value` can either be a unit attribute + to represent a definition of an uninitialized global variable, or an + elements attribute to represent the definition of a global variable with an + initial value. The global variable can also be marked constant using the + `constant` unit attribute. Writing to such constant global variables is + undefined. + + The global variable can be accessed by using the `memref.get_global` to + retrieve the memref for the global variable. Note that the memref + for such global variable itself is immutable (i.e., memref.get_global for a + given global variable will always return the same memref descriptor). + + Example: + + ```mlir + // Private variable with an initial value. + memref.global "private" @x : memref<2xf32> = dense<0.0,2.0> + + // Declaration of an external variable. + memref.global "private" @y : memref<4xi32> + + // Uninitialized externally visible variable. + memref.global @z : memref<3xf16> = uninitialized + + // Externally visible constant variable. + memref.global constant @c : memref<2xi32> = dense<1, 4> + ``` + }]; + + let arguments = (ins + SymbolNameAttr:$sym_name, + OptionalAttr:$sym_visibility, + TypeAttr:$type, + OptionalAttr:$initial_value, + UnitAttr:$constant + ); + + let assemblyFormat = [{ + ($sym_visibility^)? + (`constant` $constant^)? + $sym_name `:` + custom($type, $initial_value) + attr-dict + }]; + + let extraClassDeclaration = [{ + bool isExternal() { return !initial_value(); } + bool isUninitialized() { + return !isExternal() && initial_value().getValue().isa(); + } + }]; +} + +//===----------------------------------------------------------------------===// +// PrefetchOp +//===----------------------------------------------------------------------===// + +def MemRef_PrefetchOp : MemRef_Op<"prefetch"> { + let summary = "prefetch operation"; + let description = [{ + The "prefetch" op prefetches data from a memref location described with + subscript indices similar to std.load, and with three attributes: a + read/write specifier, a locality hint, and a cache type specifier as shown + below: + + ```mlir + memref.prefetch %0[%i, %j], read, locality<3>, data : memref<400x400xi32> + ``` + + The read/write specifier is either 'read' or 'write', the locality hint + ranges from locality<0> (no locality) to locality<3> (extremely local keep + in cache). The cache type specifier is either 'data' or 'instr' + and specifies whether the prefetch is performed on data cache or on + instruction cache. + }]; + + let arguments = (ins AnyMemRef:$memref, Variadic:$indices, + BoolAttr:$isWrite, + Confined, + IntMaxValue<3>]>:$localityHint, + BoolAttr:$isDataCache); + + let extraClassDeclaration = [{ + MemRefType getMemRefType() { + return memref().getType().cast(); + } + static StringRef getLocalityHintAttrName() { return "localityHint"; } + static StringRef getIsWriteAttrName() { return "isWrite"; } + static StringRef getIsDataCacheAttrName() { return "isDataCache"; } + }]; + + let hasFolder = 1; +} + +//===----------------------------------------------------------------------===// +// ReshapeOp +//===----------------------------------------------------------------------===// + +def MemRef_ReshapeOp: MemRef_Op<"reshape", [ + ViewLikeOpInterface, NoSideEffect]> { + let summary = "memref reshape operation"; + let description = [{ + The `reshape` operation converts a memref from one type to an + equivalent type with a provided shape. The data is never copied or + modified. The source and destination types are compatible if both have the + same element type, same number of elements, address space and identity + layout map. The following combinations are possible: + + a. Source type is ranked or unranked. Shape argument has static size. + Result type is ranked. + + ```mlir + // Reshape statically-shaped memref. + %dst = memref.reshape %src(%shape) + : (memref<4x1xf32>, memref<1xi32>) to memref<4xf32> + %dst0 = memref.reshape %src(%shape0) + : (memref<4x1xf32>, memref<2xi32>) to memref<2x2xf32> + // Flatten unranked memref. + %dst = memref.reshape %src(%shape) + : (memref<*xf32>, memref<1xi32>) to memref + ``` + + b. Source type is ranked or unranked. Shape argument has dynamic size. + Result type is unranked. + + ```mlir + // Reshape dynamically-shaped 1D memref. + %dst = memref.reshape %src(%shape) + : (memref, memref) to memref<*xf32> + // Reshape unranked memref. + %dst = memref.reshape %src(%shape) + : (memref<*xf32>, memref) to memref<*xf32> + ``` + }]; + + let arguments = (ins + AnyRankedOrUnrankedMemRef:$source, + MemRefRankOf<[AnySignlessInteger, Index], [1]>:$shape + ); + let results = (outs AnyRankedOrUnrankedMemRef:$result); + + let builders = [OpBuilderDAG< + (ins "MemRefType":$resultType, "Value":$operand, "Value":$shape), [{ + $_state.addOperands(operand); + $_state.addOperands(shape); + $_state.addTypes(resultType); + }]>]; + + let extraClassDeclaration = [{ + MemRefType getType() { return getResult().getType().cast(); } + Value getViewSource() { return source(); } + }]; + + let assemblyFormat = [{ + $source `(` $shape `)` attr-dict `:` functional-type(operands, results) + }]; +} + +//===----------------------------------------------------------------------===// +// StoreOp +//===----------------------------------------------------------------------===// + +def MemRef_StoreOp : MemRef_Op<"store", + [TypesMatchWith<"type of 'value' matches element type of 'memref'", + "memref", "value", + "$_self.cast().getElementType()">, + MemRefsNormalizable]> { + let summary = "store operation"; + let description = [{ + Store a value to a memref location given by indices. The value stored should + have the same type as the elemental type of the memref. The number of + arguments provided within brackets need to match the rank of the memref. + + In an affine context, the indices of a store are restricted to SSA values + bound to surrounding loop induction variables, + [symbols](Affine.md#restrictions-on-dimensions-and-symbols), results of a + [`constant` operation](#stdconstant-constantop), or the result of an + [`affine.apply`](Affine.md#affineapply-affineapplyop) operation that can in + turn take as arguments all of the aforementioned SSA values or the + recursively result of such an `affine.apply` operation. + + Example: + + ```mlir + memref.store %100, %A[%1, 1023] : memref<4x?xf32, #layout, memspace0> + ``` + + **Context:** The `load` and `store` operations are specifically crafted to + fully resolve a reference to an element of a memref, and (in polyhedral + `affine.if` and `affine.for` operations) the compiler can follow use-def + chains (e.g. through [`affine.apply`](Affine.md#affineapply-affineapplyop) + operations) to precisely analyze references at compile-time using polyhedral + techniques. This is possible because of the + [restrictions on dimensions and symbols](Affine.md#restrictions-on-dimensions-and-symbols) + in these contexts. + }]; + + let arguments = (ins AnyType:$value, + Arg:$memref, + Variadic:$indices); + + let builders = [ + OpBuilderDAG<(ins "Value":$valueToStore, "Value":$memref), [{ + $_state.addOperands(valueToStore); + $_state.addOperands(memref); + }]>]; + + let extraClassDeclaration = [{ + Value getValueToStore() { return getOperand(0); } + + Value getMemRef() { return getOperand(1); } + void setMemRef(Value value) { setOperand(1, value); } + MemRefType getMemRefType() { + return getMemRef().getType().cast(); + } + + operand_range getIndices() { + return {operand_begin() + 2, operand_end()}; + } + }]; + + let hasFolder = 1; + + let assemblyFormat = [{ + $value `,` $memref `[` $indices `]` attr-dict `:` type($memref) + }]; +} + +//===----------------------------------------------------------------------===// +// TransposeOp +//===----------------------------------------------------------------------===// + +def MemRef_TransposeOp : MemRef_Op<"transpose", [NoSideEffect]>, + Arguments<(ins AnyStridedMemRef:$in, AffineMapAttr:$permutation)>, + Results<(outs AnyStridedMemRef)> { + let summary = "`transpose` produces a new strided memref (metadata-only)"; + let description = [{ + The `transpose` op produces a strided memref whose sizes and strides + are a permutation of the original `in` memref. This is purely a metadata + transformation. + + Example: + + ```mlir + %1 = memref.transpose %0 (i, j) -> (j, i) : memref to memref (d1 * s0 + d0)>> + ``` + }]; + + let builders = [ + OpBuilderDAG<(ins "Value":$in, "AffineMapAttr":$permutation, + CArg<"ArrayRef", "{}">:$attrs)>]; + + let extraClassDeclaration = [{ + static StringRef getPermutationAttrName() { return "permutation"; } + ShapedType getShapedType() { return in().getType().cast(); } + }]; + + let hasFolder = 1; +} + +//===----------------------------------------------------------------------===// +// ViewOp +//===----------------------------------------------------------------------===// + +def MemRef_ViewOp : MemRef_Op<"view", [ + DeclareOpInterfaceMethods, NoSideEffect]> { + let summary = "memref view operation"; + let description = [{ + The "view" operation extracts an N-D contiguous memref with empty layout map + with arbitrary element type from a 1-D contiguous memref with empty layout + map of i8 element type. The ViewOp supports the following arguments: + + * A single dynamic byte-shift operand must be specified which represents a + a shift of the base 1-D memref pointer from which to create the resulting + contiguous memref view with identity layout. + * A dynamic size operand that must be specified for each dynamic dimension + in the resulting view memref type. + + The "view" operation gives a structured indexing form to a flat 1-D buffer. + Unlike "subview" it can perform a type change. The type change behavior + requires the op to have special semantics because, e.g. a byte shift of 3 + cannot be represented as an offset on f64. + For now, a "view" op: + + 1. Only takes a contiguous source memref with 0 offset and empty layout. + 2. Must specify a byte_shift operand (in the future, a special integer + attribute may be added to support the folded case). + 3. Returns a contiguous memref with 0 offset and empty layout. + + Example: + + ```mlir + // Allocate a flat 1D/i8 memref. + %0 = memref.alloc() : memref<2048xi8> + + // ViewOp with dynamic offset and static sizes. + %1 = memref.view %0[%offset_1024][] : memref<2048xi8> to memref<64x4xf32> + + // ViewOp with dynamic offset and two dynamic size. + %2 = memref.view %0[%offset_1024][%size0, %size1] : + memref<2048xi8> to memref + ``` + }]; + + let arguments = (ins MemRefRankOf<[I8], [1]>:$source, + Index:$byte_shift, + Variadic:$sizes); + let results = (outs AnyMemRef); + + let extraClassDeclaration = [{ + /// The result of a view is always a memref. + MemRefType getType() { return getResult().getType().cast(); } + + /// Returns the dynamic sizes for this view operation. This is redundant + /// with `sizes` but needed in template implementations. More specifically: + /// ``` + /// template + /// bool isMemRefSizeValidSymbol(AnyMemRefDefOp memrefDefOp, unsigned index, + /// Region *region) + /// ``` + operand_range getDynamicSizes() { + return {sizes().begin(), sizes().end()}; + } + }]; + + let hasCanonicalizer = 1; +} + +#endif // MEMREF_OPS diff --git a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h --- a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h +++ b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h @@ -8,6 +8,7 @@ #ifndef MLIR_DIALECT_STANDARDOPS_EDSC_INTRINSICS_H_ #define MLIR_DIALECT_STANDARDOPS_EDSC_INTRINSICS_H_ +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/EDSC/Builders.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" @@ -15,16 +16,19 @@ namespace edsc { namespace intrinsics { +using memref_alloc = ValueBuilder; +using memref_alloca = ValueBuilder; +using memref_cast = ValueBuilder; +using memref_dealloc = OperationBuilder; +using memref_store = OperationBuilder; +using memref_view = ValueBuilder; using std_addi = ValueBuilder; using std_addf = ValueBuilder; -using std_alloc = ValueBuilder; -using std_alloca = ValueBuilder; using std_call = OperationBuilder; using std_constant = ValueBuilder; using std_constant_float = ValueBuilder; using std_constant_index = ValueBuilder; using std_constant_int = ValueBuilder; -using std_dealloc = OperationBuilder; using std_divis = ValueBuilder; using std_diviu = ValueBuilder; using std_dim = ValueBuilder; @@ -33,19 +37,16 @@ using std_index_cast = ValueBuilder; using std_muli = ValueBuilder; using std_mulf = ValueBuilder; -using std_memref_cast = ValueBuilder; using std_ret = OperationBuilder; using std_select = ValueBuilder; using std_load = ValueBuilder; using std_sign_extendi = ValueBuilder; using std_splat = ValueBuilder; -using std_store = OperationBuilder; using std_subf = ValueBuilder; using std_subi = ValueBuilder; using std_sub_view = ValueBuilder; using std_tensor_load = ValueBuilder; using std_tensor_store = OperationBuilder; -using std_view = ValueBuilder; using std_zero_extendi = ValueBuilder; using tensor_extract = ValueBuilder; @@ -70,7 +71,7 @@ /// Provide an index notation around sdt_load and std_store. using StdIndexedValue = - TemplatedIndexedValue; + TemplatedIndexedValue; } // namespace intrinsics } // namespace edsc } // namespace mlir diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h @@ -316,45 +316,6 @@ computeRankReductionMask(ArrayRef originalShape, ArrayRef reducedShape); -/// Determines whether MemRefCastOp casts to a more dynamic version of the -/// source memref. This is useful to to fold a memref_cast into a consuming op -/// and implement canonicalization patterns for ops in different dialects that -/// may consume the results of memref_cast operations. Such foldable memref_cast -/// operations are typically inserted as `view` and `subview` ops and are -/// canonicalized, to preserve the type compatibility of their uses. -/// -/// Returns true when all conditions are met: -/// 1. source and result are ranked memrefs with strided semantics and same -/// element type and rank. -/// 2. each of the source's size, offset or stride has more static information -/// than the corresponding result's size, offset or stride. -/// -/// Example 1: -/// ```mlir -/// %1 = memref_cast %0 : memref<8x16xf32> to memref -/// %2 = consumer %1 ... : memref ... -/// ``` -/// -/// may fold into: -/// -/// ```mlir -/// %2 = consumer %0 ... : memref<8x16xf32> ... -/// ``` -/// -/// Example 2: -/// ``` -/// %1 = memref_cast %0 : memref(16 * i + j)>> -/// to memref -/// consumer %1 : memref ... -/// ``` -/// -/// may fold into: -/// -/// ``` -/// consumer %0 ... : memref(16 * i + j)>> -/// ``` -bool canFoldIntoConsumerOp(MemRefCastOp castOp); - /// Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer /// comparison predicates. bool applyCmpPredicate(CmpIPredicate predicate, const APInt &lhs, 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 @@ -43,10 +43,12 @@ let parser = [{ return ::parse$cppClass(parser, result); }]; } -// Base class for standard cast operations. Requires single operand and result, -// but does not constrain them to specific types. -class CastOp traits = []> : +// Base class for arithmetic cast operations. Requires single operand and +// result, but does not constrain them to specific types. +class ArithmeticCastOp traits = []> : Std_Op, NoSideEffect, SameOperandsAndResultShape, DeclareOpInterfaceMethods ]> { @@ -69,13 +71,6 @@ let verifier = ?; } -// Base class for arithmetic cast operations. -class ArithmeticCastOp traits = []> : - CastOp])> { -} - // Base class for unary ops. Requires single operand and result. Individual // classes will have `operand` accessor. class UnaryOp traits = []> : @@ -192,64 +187,6 @@ [DeclareOpInterfaceMethods])>, Arguments<(ins FloatLike:$a, FloatLike:$b, FloatLike:$c)>; -// Base class for memref allocating ops: alloca and alloc. -// -// %0 = alloclike(%m)[%s] : memref<8x?xf32, (d0, d1)[s0] -> ((d0 + s0), d1)> -// -class AllocLikeOp traits = []> : - Std_Op { - - let arguments = (ins Variadic:$dynamicSizes, - // The symbolic operands (the ones in square brackets) bind - // to the symbols of the memref's layout map. - Variadic:$symbolOperands, - Confined, [IntMinValue<0>]>:$alignment); - let results = (outs Res]>:$memref); - - let builders = [ - OpBuilderDAG<(ins "MemRefType":$memrefType, - CArg<"IntegerAttr", "IntegerAttr()">:$alignment), [{ - return build($_builder, $_state, memrefType, {}, alignment); - }]>, - OpBuilderDAG<(ins "MemRefType":$memrefType, "ValueRange":$dynamicSizes, - CArg<"IntegerAttr", "IntegerAttr()">:$alignment), [{ - return build($_builder, $_state, memrefType, dynamicSizes, {}, alignment); - }]>, - OpBuilderDAG<(ins "MemRefType":$memrefType, "ValueRange":$dynamicSizes, - "ValueRange":$symbolOperands, - CArg<"IntegerAttr", "{}">:$alignment), [{ - $_state.types.push_back(memrefType); - $_state.addOperands(dynamicSizes); - $_state.addOperands(symbolOperands); - $_state.addAttribute(getOperandSegmentSizeAttr(), - $_builder.getI32VectorAttr({ - static_cast(dynamicSizes.size()), - static_cast(symbolOperands.size())})); - if (alignment) - $_state.addAttribute(getAlignmentAttrName(), alignment); - }]>]; - - let extraClassDeclaration = [{ - static StringRef getAlignmentAttrName() { return "alignment"; } - - MemRefType getType() { return getResult().getType().cast(); } - - /// Returns the dynamic sizes for this alloc operation if specified. - operand_range getDynamicSizes() { return dynamicSizes(); } - }]; - - let assemblyFormat = [{ - `(`$dynamicSizes`)` (`` `[` $symbolOperands^ `]`)? attr-dict `:` type($memref) - }]; - - let hasCanonicalizer = 1; -} - // Base class for ops with static/dynamic offset, sizes and strides // attributes/arguments. class BaseOpWithOffsetSizesAndStrides traits = []> : @@ -365,96 +302,6 @@ let hasFolder = 1; } -//===----------------------------------------------------------------------===// -// AllocOp -//===----------------------------------------------------------------------===// - -def AllocOp : AllocLikeOp<"alloc", DefaultResource> { - let summary = "memory allocation operation"; - let description = [{ - The `alloc` operation allocates a region of memory, as specified by its - memref type. - - Example: - - ```mlir - %0 = alloc() : memref<8x64xf32, 1> - ``` - - The optional list of dimension operands are bound to the dynamic dimensions - specified in its memref type. In the example below, the ssa value '%d' is - bound to the second dimension of the memref (which is dynamic). - - ```mlir - %0 = alloc(%d) : memref<8x?xf32, 1> - ``` - - The optional list of symbol operands are bound to the symbols of the - memrefs affine map. In the example below, the ssa value '%s' is bound to - the symbol 's0' in the affine map specified in the allocs memref type. - - ```mlir - %0 = alloc()[%s] : memref<8x64xf32, - affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> - ``` - - This operation returns a single ssa value of memref type, which can be used - by subsequent load and store operations. - - The optional `alignment` attribute may be specified to ensure that the - region of memory that will be indexed is aligned at the specified byte - boundary. - - ```mlir - %0 = alloc()[%s] {alignment = 8} : - memref<8x64xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> - ``` - }]; -} - -//===----------------------------------------------------------------------===// -// AllocaOp -//===----------------------------------------------------------------------===// - -def AllocaOp : AllocLikeOp<"alloca", AutomaticAllocationScopeResource> { - let summary = "stack memory allocation operation"; - let description = [{ - The `alloca` operation allocates memory on the stack, to be automatically - released when control transfers back from the region of its closest - surrounding operation with an - [`AutomaticAllocationScope`](../Traits.md#automaticallocationscope) trait. - The amount of memory allocated is specified by its memref and additional - operands. For example: - - ```mlir - %0 = alloca() : memref<8x64xf32> - ``` - - The optional list of dimension operands are bound to the dynamic dimensions - specified in its memref type. In the example below, the SSA value '%d' is - bound to the second dimension of the memref (which is dynamic). - - ```mlir - %0 = alloca(%d) : memref<8x?xf32> - ``` - - The optional list of symbol operands are bound to the symbols of the - memref's affine map. In the example below, the SSA value '%s' is bound to - the symbol 's0' in the affine map specified in the allocs memref type. - - ```mlir - %0 = alloca()[%s] : memref<8x64xf32, - affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>> - ``` - - This operation returns a single SSA value of memref type, which can be used - by subsequent load and store operations. An optional alignment attribute, if - specified, guarantees alignment at least to that boundary. If not specified, - an alignment on any convenient boundary compatible with the type will be - chosen. - }]; -} - //===----------------------------------------------------------------------===// // AndOp //===----------------------------------------------------------------------===// @@ -1340,33 +1187,6 @@ }]; } -//===----------------------------------------------------------------------===// -// DeallocOp -//===----------------------------------------------------------------------===// - -def DeallocOp : Std_Op<"dealloc", [MemRefsNormalizable]> { - let summary = "memory deallocation operation"; - let description = [{ - The `dealloc` operation frees the region of memory referenced by a memref - which was originally created by the `alloc` operation. - The `dealloc` operation should not be called on memrefs which alias an - alloc'd memref (e.g. memrefs returned by `view` operations). - - Example: - - ```mlir - %0 = alloc() : memref<8x64xf32, (d0, d1) -> (d0, d1), 1> - dealloc %0 : memref<8x64xf32, (d0, d1) -> (d0, d1), 1> - ``` - }]; - - let arguments = (ins Arg:$memref); - - let hasCanonicalizer = 1; - let hasFolder = 1; - let assemblyFormat = "$memref attr-dict `:` type($memref)"; -} - //===----------------------------------------------------------------------===// // DimOp //===----------------------------------------------------------------------===// @@ -1519,98 +1339,6 @@ }]; } -//===----------------------------------------------------------------------===// -// GlobalMemrefOp -//===----------------------------------------------------------------------===// - -def GlobalMemrefOp : Std_Op<"global_memref", [Symbol]> { - let summary = "declare or define a global memref variable"; - let description = [{ - The `global_memref` operation declares or defines a named global variable. - The backing memory for the variable is allocated statically and is described - by the type of the variable (which should be a statically shaped memref - type). The operation is a declaration if no `inital_value` is specified, - else it is a definition. The `initial_value` can either be a unit attribute - to represent a definition of an uninitialized global variable, or an - elements attribute to represent the definition of a global variable with an - initial value. The global variable can also be marked constant using the - `constant` unit attribute. Writing to such constant global variables is - undefined. - - The global variable can be accessed by using the `get_global_memref` to - retrieve the memref for the global variable. Note that the memref - for such global variable itself is immutable (i.e., get_global_memref for a - given global variable will always return the same memref descriptor). - - Example: - - ```mlir - // Private variable with an initial value. - global_memref "private" @x : memref<2xf32> = dense<0.0,2.0> - - // Declaration of an external variable. - global_memref "private" @y : memref<4xi32> - - // Uninitialized externally visible variable. - global_memref @z : memref<3xf16> = uninitialized - - // Externally visible constant variable. - global_memref constant @c : memref<2xi32> = dense<1, 4> - ``` - }]; - - let arguments = (ins - SymbolNameAttr:$sym_name, - OptionalAttr:$sym_visibility, - TypeAttr:$type, - OptionalAttr:$initial_value, - UnitAttr:$constant - ); - - let assemblyFormat = [{ - ($sym_visibility^)? - (`constant` $constant^)? - $sym_name `:` - custom($type, $initial_value) - attr-dict - }]; - - let extraClassDeclaration = [{ - bool isExternal() { return !initial_value(); } - bool isUninitialized() { - return !isExternal() && initial_value().getValue().isa(); - } - }]; -} - -//===----------------------------------------------------------------------===// -// GetGlobalMemrefOp -//===----------------------------------------------------------------------===// - -def GetGlobalMemrefOp : Std_Op<"get_global_memref", - [NoSideEffect, DeclareOpInterfaceMethods]> { - let summary = "get the memref pointing to a global variable"; - let description = [{ - The `get_global_memref` operation retrieves the memref pointing to a - named global variable. If the global variable is marked constant, writing - to the result memref (such as through a `std.store` operation) is - undefined. - - Example: - - ```mlir - %x = get_global_memref @foo : memref<2xf32> - ``` - }]; - - let arguments = (ins FlatSymbolRefAttr:$name); - let results = (outs AnyStaticShapeMemRef:$result); - let assemblyFormat = "$name `:` type($result) attr-dict"; - - // `GetGlobalMemrefOp` is fully verified by its traits. - let verifier = ?; -} - //===----------------------------------------------------------------------===// // IndexCastOp //===----------------------------------------------------------------------===// @@ -1702,76 +1430,6 @@ let assemblyFormat = "$memref `[` $indices `]` attr-dict `:` type($memref)"; } -//===----------------------------------------------------------------------===// -// MemRefCastOp -//===----------------------------------------------------------------------===// - -def MemRefCastOp : CastOp<"memref_cast", [ - DeclareOpInterfaceMethods - ]> { - let summary = "memref cast operation"; - let description = [{ - Syntax: - - ``` - operation ::= ssa-id `=` `std.memref_cast` ssa-use `:` type `to` type - ``` - - The `memref_cast` operation converts a memref from one type to an equivalent - type with a compatible shape. The source and destination types are - compatible if: - - a. Both are ranked memref types with the same element type, address space, - and rank and: - 1. Both have the same layout or both have compatible strided layouts. - 2. The individual sizes (resp. offset and strides in the case of strided - memrefs) may convert constant dimensions to dynamic dimensions and - vice-versa. - - If the cast converts any dimensions from an unknown to a known size, then it - acts as an assertion that fails at runtime if the dynamic dimensions - disagree with resultant destination size. - - Example: - - ```mlir - // Assert that the input dynamic shape matches the destination static shape. - %2 = memref_cast %1 : memref to memref<4x4xf32> - // Erase static shape information, replacing it with dynamic information. - %3 = memref_cast %1 : memref<4xf32> to memref - - // The same holds true for offsets and strides. - - // Assert that the input dynamic shape matches the destination static stride. - %4 = memref_cast %1 : memref<12x4xf32, offset:?, strides: [?, ?]> to - memref<12x4xf32, offset:5, strides: [4, 1]> - // Erase static offset and stride information, replacing it with - // dynamic information. - %5 = memref_cast %1 : memref<12x4xf32, offset:5, strides: [4, 1]> to - memref<12x4xf32, offset:?, strides: [?, ?]> - ``` - - b. Either or both memref types are unranked with the same element type, and - address space. - - Example: - - ```mlir - Cast to concrete shape. - %4 = memref_cast %1 : memref<*xf32> to memref<4x?xf32> - - Erase rank information. - %5 = memref_cast %1 : memref<4x?xf32> to memref<*xf32> - ``` - }]; - - let arguments = (ins AnyRankedOrUnrankedMemRef:$source); - let results = (outs AnyRankedOrUnrankedMemRef); - - let hasFolder = 1; -} - - //===----------------------------------------------------------------------===// // MemRefReinterpretCastOp //===----------------------------------------------------------------------===// @@ -2042,47 +1700,6 @@ let hasFolder = 1; } -//===----------------------------------------------------------------------===// -// PrefetchOp -//===----------------------------------------------------------------------===// - -def PrefetchOp : Std_Op<"prefetch"> { - let summary = "prefetch operation"; - let description = [{ - The "prefetch" op prefetches data from a memref location described with - subscript indices similar to std.load, and with three attributes: a - read/write specifier, a locality hint, and a cache type specifier as shown - below: - - ```mlir - prefetch %0[%i, %j], read, locality<3>, data : memref<400x400xi32> - ``` - - The read/write specifier is either 'read' or 'write', the locality hint - ranges from locality<0> (no locality) to locality<3> (extremely local keep - in cache). The cache type specifier is either 'data' or 'instr' - and specifies whether the prefetch is performed on data cache or on - instruction cache. - }]; - - let arguments = (ins AnyMemRef:$memref, Variadic:$indices, - BoolAttr:$isWrite, - Confined, - IntMaxValue<3>]>:$localityHint, - BoolAttr:$isDataCache); - - let extraClassDeclaration = [{ - MemRefType getMemRefType() { - return memref().getType().cast(); - } - static StringRef getLocalityHintAttrName() { return "localityHint"; } - static StringRef getIsWriteAttrName() { return "isWrite"; } - static StringRef getIsDataCacheAttrName() { return "isDataCache"; } - }]; - - let hasFolder = 1; -} - //===----------------------------------------------------------------------===// // RankOp //===----------------------------------------------------------------------===// @@ -2492,77 +2109,6 @@ let assemblyFormat = "$input attr-dict `:` type($aggregate)"; } -//===----------------------------------------------------------------------===// -// StoreOp -//===----------------------------------------------------------------------===// - -def StoreOp : Std_Op<"store", - [TypesMatchWith<"type of 'value' matches element type of 'memref'", - "memref", "value", - "$_self.cast().getElementType()">, - MemRefsNormalizable]> { - let summary = "store operation"; - let description = [{ - Store a value to a memref location given by indices. The value stored should - have the same type as the elemental type of the memref. The number of - arguments provided within brackets need to match the rank of the memref. - - In an affine context, the indices of a store are restricted to SSA values - bound to surrounding loop induction variables, - [symbols](Affine.md#restrictions-on-dimensions-and-symbols), results of a - [`constant` operation](#stdconstant-constantop), or the result of an - [`affine.apply`](Affine.md#affineapply-affineapplyop) operation that can in turn - take as arguments all of the aforementioned SSA values or the recursively - result of such an `affine.apply` operation. - - Example: - - ```mlir - store %100, %A[%1, 1023] : memref<4x?xf32, #layout, memspace0> - ``` - - **Context:** The `load` and `store` operations are specifically crafted to - fully resolve a reference to an element of a memref, and (in polyhedral - `affine.if` and `affine.for` operations) the compiler can follow use-def - chains (e.g. through [`affine.apply`](Affine.md#affineapply-affineapplyop) - operations) to precisely analyze references at compile-time using polyhedral - techniques. This is possible because of the - [restrictions on dimensions and symbols](Affine.md#restrictions-on-dimensions-and-symbols) - in these contexts. - }]; - - let arguments = (ins AnyType:$value, - Arg:$memref, - Variadic:$indices); - - let builders = [ - OpBuilderDAG<(ins "Value":$valueToStore, "Value":$memref), [{ - $_state.addOperands(valueToStore); - $_state.addOperands(memref); - }]>]; - - let extraClassDeclaration = [{ - Value getValueToStore() { return getOperand(0); } - - Value getMemRef() { return getOperand(1); } - void setMemRef(Value value) { setOperand(1, value); } - MemRefType getMemRefType() { - return getMemRef().getType().cast(); - } - - operand_range getIndices() { - return {operand_begin() + 2, operand_end()}; - } - }]; - - let hasFolder = 1; - - let assemblyFormat = [{ - $value `,` $memref `[` $indices `]` attr-dict `:` type($memref) - }]; -} - //===----------------------------------------------------------------------===// // SubFOp //===----------------------------------------------------------------------===// @@ -3160,38 +2706,6 @@ let hasCanonicalizer = 1; } -//===----------------------------------------------------------------------===// -// TransposeOp -//===----------------------------------------------------------------------===// - -def TransposeOp : Std_Op<"transpose", [NoSideEffect]>, - Arguments<(ins AnyStridedMemRef:$in, AffineMapAttr:$permutation)>, - Results<(outs AnyStridedMemRef)> { - let summary = "`transpose` produces a new strided memref (metadata-only)"; - let description = [{ - The `transpose` op produces a strided memref whose sizes and strides - are a permutation of the original `in` memref. This is purely a metadata - transformation. - - Example: - - ```mlir - %1 = transpose %0 (i, j) -> (j, i) : memref to memref (d1 * s0 + d0)>> - ``` - }]; - - let builders = [ - OpBuilderDAG<(ins "Value":$in, "AffineMapAttr":$permutation, - CArg<"ArrayRef", "{}">:$attrs)>]; - - let extraClassDeclaration = [{ - static StringRef getPermutationAttrName() { return "permutation"; } - ShapedType getShapedType() { return in().getType().cast(); } - }]; - - let hasFolder = 1; -} - //===----------------------------------------------------------------------===// // TruncateIOp //===----------------------------------------------------------------------===// @@ -3339,74 +2853,6 @@ }]; } -//===----------------------------------------------------------------------===// -// ViewOp -//===----------------------------------------------------------------------===// - -def ViewOp : Std_Op<"view", [ - DeclareOpInterfaceMethods, NoSideEffect]> { - let summary = "memref view operation"; - let description = [{ - The "view" operation extracts an N-D contiguous memref with empty layout map - with arbitrary element type from a 1-D contiguous memref with empty layout - map of i8 element type. The ViewOp supports the following arguments: - - * A single dynamic byte-shift operand must be specified which represents a - a shift of the base 1-D memref pointer from which to create the resulting - contiguous memref view with identity layout. - * A dynamic size operand that must be specified for each dynamic dimension - in the resulting view memref type. - - The "view" operation gives a structured indexing form to a flat 1-D buffer. - Unlike "subview" it can perform a type change. The type change behavior - requires the op to have special semantics because, e.g. a byte shift of 3 - cannot be represented as an offset on f64. - For now, a "view" op: - - 1. Only takes a contiguous source memref with 0 offset and empty layout. - 2. Must specify a byte_shift operand (in the future, a special integer - attribute may be added to support the folded case). - 3. Returns a contiguous memref with 0 offset and empty layout. - - Example: - - ```mlir - // Allocate a flat 1D/i8 memref. - %0 = alloc() : memref<2048xi8> - - // ViewOp with dynamic offset and static sizes. - %1 = view %0[%offset_1024][] : memref<2048xi8> to memref<64x4xf32> - - // ViewOp with dynamic offset and two dynamic size. - %2 = view %0[%offset_1024][%size0, %size1] : - memref<2048xi8> to memref - ``` - }]; - - let arguments = (ins MemRefRankOf<[I8], [1]>:$source, - Index:$byte_shift, - Variadic:$sizes); - let results = (outs AnyMemRef); - - let extraClassDeclaration = [{ - /// The result of a view is always a memref. - MemRefType getType() { return getResult().getType().cast(); } - - /// Returns the dynamic sizes for this view operation. This is redundant - /// with `sizes` but needed in template implementations. More specifically: - /// ``` - /// template - /// bool isMemRefSizeValidSymbol(AnyMemRefDefOp memrefDefOp, unsigned index, - /// Region *region) - /// ``` - operand_range getDynamicSizes() { - return {sizes().begin(), sizes().end()}; - } - }]; - - let hasCanonicalizer = 1; -} - //===----------------------------------------------------------------------===// // XOrOp //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td b/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.td @@ -44,7 +44,7 @@ implement the `ReturnLike` trait are not rewritten in general, as they require that the corresponding parent operation is also rewritten. Finally, this pass fails for unknown terminators, as we cannot decide - whether they need rewriting. + whether they need rewriting. }]; let constructor = "mlir::createFuncBufferizePass()"; } @@ -54,7 +54,7 @@ let description = [{ This pass bufferizes tensor constants. - This pass needs to be a module pass because it inserts std.global_memref + This pass needs to be a module pass because it inserts memref.global ops into the module, which cannot be done safely from a function pass due to multi-threading. Most other bufferization passes can run in parallel at function granularity. diff --git a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h --- a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h @@ -180,11 +180,11 @@ /// ``` /// %1:3 = scf.if (%inBounds) { /// // fastpath, direct cast -/// memref_cast %A: memref to compatibleMemRefType +/// memref.cast %A: memref to compatibleMemRefType /// scf.yield %view : compatibleMemRefType, index, index /// } else { /// // slowpath, masked vector.transfer or linalg.copy. -/// memref_cast %alloc: memref to compatibleMemRefType +/// memref.cast %alloc: memref to compatibleMemRefType /// scf.yield %4 : compatibleMemRefType, index, index // } /// %0 = vector.transfer_read %1#0[%1#1, %1#2] {masked = [false ... false]} diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -1126,7 +1126,7 @@ /// A trait of region holding operations that define a new scope for automatic /// allocations, i.e., allocations that are freed when control is transferred /// back from the operation's region. Any operations performing such allocations -/// (for eg. std.alloca) will have their allocations automatically freed at +/// (for eg. memref.alloca) will have their allocations automatically freed at /// their closest enclosing operation with this trait. template class AutomaticAllocationScope diff --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h --- a/mlir/include/mlir/InitAllDialects.h +++ b/mlir/include/mlir/InitAllDialects.h @@ -29,6 +29,7 @@ #include "mlir/Dialect/LLVMIR/ROCDLDialect.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Math/IR/Math.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/OpenACC/OpenACC.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "mlir/Dialect/PDL/IR/PDL.h" @@ -62,6 +63,7 @@ LLVM::LLVMArmSVEDialect, linalg::LinalgDialect, math::MathDialect, + memref::MemRefDialect, scf::SCFDialect, omp::OpenMPDialect, pdl::PDLDialect, diff --git a/mlir/include/mlir/Transforms/Passes.td b/mlir/include/mlir/Transforms/Passes.td --- a/mlir/include/mlir/Transforms/Passes.td +++ b/mlir/include/mlir/Transforms/Passes.td @@ -535,7 +535,7 @@ contained in the op. Operations marked with the [MemRefsNormalizable] (https://mlir.llvm.org/docs/Traits/#memrefsnormalizable) trait are expected to be normalizable. Supported operations include affine - operations, std.alloc, std.dealloc, and std.return. + operations, memref.alloc, memref.dealloc, and std.return. Given an appropriate layout map specified in the code, this transformation can express tiled or linearized access to multi-dimensional data diff --git a/mlir/include/mlir/Transforms/Utils.h b/mlir/include/mlir/Transforms/Utils.h --- a/mlir/include/mlir/Transforms/Utils.h +++ b/mlir/include/mlir/Transforms/Utils.h @@ -16,6 +16,7 @@ #ifndef MLIR_TRANSFORMS_UTILS_H #define MLIR_TRANSFORMS_UTILS_H +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineMap.h" #include "llvm/ADT/ArrayRef.h" @@ -88,7 +89,7 @@ /// Rewrites the memref defined by this alloc op to have an identity layout map /// and updates all its indexing uses. Returns failure if any of its uses /// escape (while leaving the IR in a valid state). -LogicalResult normalizeMemRef(AllocOp op); +LogicalResult normalizeMemRef(memref::AllocOp op); /// Uses the old memref type map layout and computes the new memref type to have /// a new shape and a layout map, where the old layout map has been normalized diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -15,6 +15,7 @@ #include "../PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/VectorOps.h" @@ -44,7 +45,8 @@ : builder(builder), dimValues(dimValues), symbolValues(symbolValues), loc(loc) {} - template Value buildBinaryExpr(AffineBinaryOpExpr expr) { + template + Value buildBinaryExpr(AffineBinaryOpExpr expr) { auto lhs = visit(expr.getLHS()); auto rhs = visit(expr.getRHS()); if (!lhs || !rhs) @@ -586,7 +588,7 @@ }; /// Apply the affine map from an 'affine.prefetch' operation to its operands, -/// and feed the results to a newly created 'std.prefetch' operation (which +/// and feed the results to a newly created 'memref.prefetch' operation (which /// replaces the original 'affine.prefetch'). class AffinePrefetchLowering : public OpRewritePattern { public: @@ -601,16 +603,16 @@ if (!resultOperands) return failure(); - // Build std.prefetch memref[expandedMap.results]. - rewriter.replaceOpWithNewOp(op, op.memref(), *resultOperands, - op.isWrite(), op.localityHint(), - op.isDataCache()); + // Build memref.prefetch memref[expandedMap.results]. + rewriter.replaceOpWithNewOp( + op, op.memref(), *resultOperands, op.isWrite(), op.localityHint(), + op.isDataCache()); return success(); } }; /// Apply the affine map from an 'affine.store' operation to its operands, and -/// feed the results to a newly created 'std.store' operation (which replaces +/// feed the results to a newly created 'memref.store' operation (which replaces /// the original 'affine.store'). class AffineStoreLowering : public OpRewritePattern { public: @@ -625,8 +627,8 @@ if (!maybeExpandedMap) return failure(); - // Build std.store valueToStore, memref[expandedMap.results]. - rewriter.replaceOpWithNewOp( + // Build memref.store valueToStore, memref[expandedMap.results]. + rewriter.replaceOpWithNewOp( op, op.getValueToStore(), op.getMemRef(), *maybeExpandedMap); return success(); } @@ -777,8 +779,8 @@ populateAffineToStdConversionPatterns(patterns, &getContext()); populateAffineToVectorConversionPatterns(patterns, &getContext()); ConversionTarget target(getContext()); - target - .addLegalDialect(); + target.addLegalDialect(); if (failed(applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); 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 @@ -93,7 +93,7 @@ continue; } Value cast = - b.create(loc, eraseStridedLayout(memrefType), op); + b.create(loc, eraseStridedLayout(memrefType), op); res.push_back(cast); } return res; @@ -143,12 +143,12 @@ // If either inputPerm or outputPerm are non-identities, insert transposes. auto inputPerm = op.inputPermutation(); if (inputPerm.hasValue() && !inputPerm->isIdentity()) - in = rewriter.create(op.getLoc(), in, - AffineMapAttr::get(*inputPerm)); + in = rewriter.create(op.getLoc(), in, + AffineMapAttr::get(*inputPerm)); auto outputPerm = op.outputPermutation(); if (outputPerm.hasValue() && !outputPerm->isIdentity()) - out = rewriter.create(op.getLoc(), out, - AffineMapAttr::get(*outputPerm)); + out = rewriter.create(op.getLoc(), out, + AffineMapAttr::get(*outputPerm)); // If nothing was transposed, fail and let the conversion kick in. if (in == op.input() && out == op.output()) @@ -213,7 +213,8 @@ void ConvertLinalgToStandardPass::runOnOperation() { auto module = getOperation(); ConversionTarget target(getContext()); - target.addLegalDialect(); + target.addLegalDialect(); target.addLegalOp(); target.addLegalOp(); OwningRewritePatternList patterns; diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp @@ -18,6 +18,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/ParallelLoopMapper.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/AffineExpr.h" @@ -647,6 +648,7 @@ } void mlir::configureParallelLoopToGPULegality(ConversionTarget &target) { + target.addLegalDialect(); target.addDynamicallyLegalOp([](scf::ParallelOp parallelOp) { return !parallelOp->getAttr(gpu::getMappingAttrName()); }); 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 @@ -17,6 +17,7 @@ #include "mlir/Dialect/LLVMIR/FunctionCallUtils.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/Math/IR/Math.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/BlockAndValueMapping.h" @@ -1860,13 +1861,13 @@ struct AllocOpLowering : public AllocLikeOpLowering { AllocOpLowering(LLVMTypeConverter &converter) - : AllocLikeOpLowering(AllocOp::getOperationName(), converter) {} + : AllocLikeOpLowering(memref::AllocOp::getOperationName(), converter) {} std::tuple allocateBuffer(ConversionPatternRewriter &rewriter, Location loc, Value sizeBytes, Operation *op) const override { // Heap allocations. - AllocOp allocOp = cast(op); + memref::AllocOp allocOp = cast(op); MemRefType memRefType = allocOp.getType(); Value alignment; @@ -1913,7 +1914,7 @@ struct AlignedAllocOpLowering : public AllocLikeOpLowering { AlignedAllocOpLowering(LLVMTypeConverter &converter) - : AllocLikeOpLowering(AllocOp::getOperationName(), converter) {} + : AllocLikeOpLowering(memref::AllocOp::getOperationName(), converter) {} /// Returns the memref's element size in bytes. // TODO: there are other places where this is used. Expose publicly? @@ -1946,7 +1947,7 @@ /// Returns the alignment to be used for the allocation call itself. /// aligned_alloc requires the allocation size to be a power of two, and the /// allocation size to be a multiple of alignment, - int64_t getAllocationAlignment(AllocOp allocOp) const { + int64_t getAllocationAlignment(memref::AllocOp allocOp) const { if (Optional alignment = allocOp.alignment()) return *alignment; @@ -1962,7 +1963,7 @@ Location loc, Value sizeBytes, Operation *op) const override { // Heap allocations. - AllocOp allocOp = cast(op); + memref::AllocOp allocOp = cast(op); MemRefType memRefType = allocOp.getType(); int64_t alignment = getAllocationAlignment(allocOp); Value allocAlignment = createIndexConstant(rewriter, loc, alignment); @@ -1993,7 +1994,7 @@ struct AllocaOpLowering : public AllocLikeOpLowering { AllocaOpLowering(LLVMTypeConverter &converter) - : AllocLikeOpLowering(AllocaOp::getOperationName(), converter) {} + : AllocLikeOpLowering(memref::AllocaOp::getOperationName(), converter) {} /// Allocates the underlying buffer using the right call. `allocatedBytePtr` /// is set to null for stack allocations. `accessAlignment` is set if @@ -2004,7 +2005,7 @@ // With alloca, one gets a pointer to the element type right away. // For stack allocations. - auto allocaOp = cast(op); + auto allocaOp = cast(op); auto elementPtrType = this->getElementPtrType(allocaOp.getType()); auto allocatedElementPtr = rewriter.create( @@ -2176,17 +2177,17 @@ // A `dealloc` is converted into a call to `free` on the underlying data buffer. // The memref descriptor being an SSA value, there is no need to clean it up // in any way. -struct DeallocOpLowering : public ConvertOpToLLVMPattern { - using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; +struct DeallocOpLowering : public ConvertOpToLLVMPattern { + using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; explicit DeallocOpLowering(LLVMTypeConverter &converter) - : ConvertOpToLLVMPattern(converter) {} + : ConvertOpToLLVMPattern(converter) {} LogicalResult - matchAndRewrite(DeallocOp op, ArrayRef operands, + matchAndRewrite(memref::DeallocOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { assert(operands.size() == 1 && "dealloc takes one operand"); - DeallocOp::Adaptor transformed(operands); + memref::DeallocOp::Adaptor transformed(operands); // Insert the `free` declaration if it is not already present. auto freeFunc = LLVM::lookupOrCreateFreeFn(op->getParentOfType()); @@ -2205,7 +2206,7 @@ LLVMTypeConverter &typeConverter) { // LLVM type for a global memref will be a multi-dimension array. For // declarations or uninitialized global memrefs, we can potentially flatten - // this to a 1D array. However, for global_memref's with an initial value, + // this to a 1D array. However, for memref.global's with an initial value, // we do not intend to flatten the ElementsAttribute when going from std -> // LLVM dialect, so the LLVM type needs to me a multi-dimension array. Type elementType = unwrap(typeConverter.convertType(type.getElementType())); @@ -2217,11 +2218,12 @@ } /// GlobalMemrefOp is lowered to a LLVM Global Variable. -struct GlobalMemrefOpLowering : public ConvertOpToLLVMPattern { - using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; +struct GlobalMemrefOpLowering + : public ConvertOpToLLVMPattern { + using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; LogicalResult - matchAndRewrite(GlobalMemrefOp global, ArrayRef operands, + matchAndRewrite(memref::GlobalOp global, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { MemRefType type = global.type().cast(); if (!isConvertibleAndHasIdentityMaps(type)) @@ -2255,14 +2257,15 @@ /// `AllocLikeOpLowering` to reuse the Memref descriptor construction. struct GetGlobalMemrefOpLowering : public AllocLikeOpLowering { GetGlobalMemrefOpLowering(LLVMTypeConverter &converter) - : AllocLikeOpLowering(GetGlobalMemrefOp::getOperationName(), converter) {} + : AllocLikeOpLowering(memref::GetGlobalOp::getOperationName(), + converter) {} - /// Buffer "allocation" for get_global_memref op is getting the address of + /// Buffer "allocation" for memref.get_global op is getting the address of /// the global variable referenced. std::tuple allocateBuffer(ConversionPatternRewriter &rewriter, Location loc, Value sizeBytes, Operation *op) const override { - auto getGlobalOp = cast(op); + auto getGlobalOp = cast(op); MemRefType type = getGlobalOp.result().getType().cast(); unsigned memSpace = type.getMemorySpace(); @@ -2281,7 +2284,7 @@ createIndexConstant(rewriter, loc, 0)); auto gep = rewriter.create(loc, elementPtrType, operands); - // We do not expect the memref obtained using `get_global_memref` to be + // We do not expect the memref obtained using `memref.get_global` to be // ever deallocated. Set the allocated pointer to be known bad value to // help debug if that ever happens. auto intPtrType = getIntPtrType(memSpace); @@ -2350,17 +2353,17 @@ } }; -struct MemRefCastOpLowering : public ConvertOpToLLVMPattern { - using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; +struct MemRefCastOpLowering : public ConvertOpToLLVMPattern { + using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; - LogicalResult match(MemRefCastOp memRefCastOp) const override { + LogicalResult match(memref::CastOp memRefCastOp) const override { Type srcType = memRefCastOp.getOperand().getType(); Type dstType = memRefCastOp.getType(); - // MemRefCastOp reduce to bitcast in the ranked MemRef case and can be used - // for type erasure. For now they must preserve underlying element type and - // require source and result type to have the same rank. Therefore, perform - // a sanity check that the underlying structs are the same. Once op + // memref::CastOp reduce to bitcast in the ranked MemRef case and can be + // used for type erasure. For now they must preserve underlying element type + // and require source and result type to have the same rank. Therefore, + // perform a sanity check that the underlying structs are the same. Once op // semantics are relaxed we can revisit. if (srcType.isa() && dstType.isa()) return success(typeConverter->convertType(srcType) == @@ -2377,9 +2380,9 @@ : failure(); } - void rewrite(MemRefCastOp memRefCastOp, ArrayRef operands, + void rewrite(memref::CastOp memRefCastOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - MemRefCastOp::Adaptor transformed(operands); + memref::CastOp::Adaptor transformed(operands); auto srcType = memRefCastOp.getOperand().getType(); auto dstType = memRefCastOp.getType(); @@ -2864,14 +2867,14 @@ // Store operation is lowered to obtaining a pointer to the indexed element, // and storing the given value to it. -struct StoreOpLowering : public LoadStoreOpLowering { +struct StoreOpLowering : public LoadStoreOpLowering { using Base::Base; LogicalResult - matchAndRewrite(StoreOp op, ArrayRef operands, + matchAndRewrite(memref::StoreOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto type = op.getMemRefType(); - StoreOp::Adaptor transformed(operands); + memref::StoreOp::Adaptor transformed(operands); Value dataPtr = getStridedElementPtr(op.getLoc(), type, transformed.memref(), @@ -2884,13 +2887,13 @@ // The prefetch operation is lowered in a way similar to the load operation // except that the llvm.prefetch operation is used for replacement. -struct PrefetchOpLowering : public LoadStoreOpLowering { +struct PrefetchOpLowering : public LoadStoreOpLowering { using Base::Base; LogicalResult - matchAndRewrite(PrefetchOp prefetchOp, ArrayRef operands, + matchAndRewrite(memref::PrefetchOp prefetchOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - PrefetchOp::Adaptor transformed(operands); + memref::PrefetchOp::Adaptor transformed(operands); auto type = prefetchOp.getMemRefType(); auto loc = prefetchOp.getLoc(); @@ -3372,15 +3375,15 @@ /// and stride. Size and stride are permutations of the original values. /// 4. A store of the resulting ViewDescriptor to the alloca'ed pointer. /// The transpose op is replaced by the alloca'ed pointer. -class TransposeOpLowering : public ConvertOpToLLVMPattern { +class TransposeOpLowering : public ConvertOpToLLVMPattern { public: - using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; + using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; LogicalResult - matchAndRewrite(TransposeOp transposeOp, ArrayRef operands, + matchAndRewrite(memref::TransposeOp transposeOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = transposeOp.getLoc(); - TransposeOpAdaptor adaptor(operands); + memref::TransposeOpAdaptor adaptor(operands); MemRefDescriptor viewMemRef(adaptor.in()); // No permutation, early exit. @@ -3420,8 +3423,8 @@ /// 2. Updates to the descriptor to introduce the data ptr, offset, size /// and stride. /// The view op is replaced by the descriptor. -struct ViewOpLowering : public ConvertOpToLLVMPattern { - using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; +struct ViewOpLowering : public ConvertOpToLLVMPattern { + using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; // Build and return the value for the idx^th shape dimension, either by // returning the constant shape dimension or counting the proper dynamic size. @@ -3457,10 +3460,10 @@ } LogicalResult - matchAndRewrite(ViewOp viewOp, ArrayRef operands, + matchAndRewrite(memref::ViewOp viewOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto loc = viewOp.getLoc(); - ViewOpAdaptor adaptor(operands); + memref::ViewOpAdaptor adaptor(operands); auto viewMemRefType = viewOp.getType(); auto targetElementTy = diff --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp --- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp @@ -14,6 +14,7 @@ #include "../PassDetail.h" #include "mlir/Conversion/StandardToSPIRV/StandardToSPIRV.h" #include "mlir/Conversion/StandardToSPIRV/StandardToSPIRVPass.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/VectorOps.h" @@ -27,7 +28,7 @@ static Value getMemRefOperand(vector::TransferReadOp op) { return op.source(); } -static Value getMemRefOperand(StoreOp op) { return op.memref(); } +static Value getMemRefOperand(memref::StoreOp op) { return op.memref(); } static Value getMemRefOperand(vector::TransferWriteOp op) { return op.source(); @@ -83,11 +84,11 @@ } template <> -void StoreOpOfSubViewFolder::replaceOp( - StoreOp storeOp, SubViewOp subViewOp, ArrayRef sourceIndices, +void StoreOpOfSubViewFolder::replaceOp( + memref::StoreOp storeOp, SubViewOp subViewOp, ArrayRef sourceIndices, PatternRewriter &rewriter) const { - rewriter.replaceOpWithNewOp(storeOp, storeOp.value(), - subViewOp.source(), sourceIndices); + rewriter.replaceOpWithNewOp( + storeOp, storeOp.value(), subViewOp.source(), sourceIndices); } template <> @@ -195,7 +196,7 @@ MLIRContext *context, OwningRewritePatternList &patterns) { patterns.insert, LoadOpOfSubViewFolder, - StoreOpOfSubViewFolder, + StoreOpOfSubViewFolder, StoreOpOfSubViewFolder>(context); } diff --git a/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp --- a/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Math/IR/Math.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/Dialect/SPIRV/IR/SPIRVOps.h" #include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h" @@ -235,12 +236,12 @@ /// to Workgroup memory when the size is constant. Note that this pattern needs /// to be applied in a pass that runs at least at spv.module scope since it wil /// ladd global variables into the spv.module. -class AllocOpPattern final : public OpConversionPattern { +class AllocOpPattern final : public OpConversionPattern { public: - using OpConversionPattern::OpConversionPattern; + using OpConversionPattern::OpConversionPattern; LogicalResult - matchAndRewrite(AllocOp operation, ArrayRef operands, + matchAndRewrite(memref::AllocOp operation, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { MemRefType allocType = operation.getType(); if (!isAllocationSupported(allocType)) @@ -277,12 +278,12 @@ /// Removed a deallocation if it is a supported allocation. Currently only /// removes deallocation if the memory space is workgroup memory. -class DeallocOpPattern final : public OpConversionPattern { +class DeallocOpPattern final : public OpConversionPattern { public: - using OpConversionPattern::OpConversionPattern; + using OpConversionPattern::OpConversionPattern; LogicalResult - matchAndRewrite(DeallocOp operation, ArrayRef operands, + matchAndRewrite(memref::DeallocOp operation, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { MemRefType deallocType = operation.memref().getType().cast(); if (!isAllocationSupported(deallocType)) @@ -468,23 +469,23 @@ ConversionPatternRewriter &rewriter) const override; }; -/// Converts std.store to spv.Store on integers. -class IntStoreOpPattern final : public OpConversionPattern { +/// Converts memref.store to spv.Store on integers. +class IntStoreOpPattern final : public OpConversionPattern { public: - using OpConversionPattern::OpConversionPattern; + using OpConversionPattern::OpConversionPattern; LogicalResult - matchAndRewrite(StoreOp storeOp, ArrayRef operands, + matchAndRewrite(memref::StoreOp storeOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; -/// Converts std.store to spv.Store. -class StoreOpPattern final : public OpConversionPattern { +/// Converts memref.store to spv.Store. +class StoreOpPattern final : public OpConversionPattern { public: - using OpConversionPattern::OpConversionPattern; + using OpConversionPattern::OpConversionPattern; LogicalResult - matchAndRewrite(StoreOp storeOp, ArrayRef operands, + matchAndRewrite(memref::StoreOp storeOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; }; @@ -1038,9 +1039,10 @@ //===----------------------------------------------------------------------===// LogicalResult -IntStoreOpPattern::matchAndRewrite(StoreOp storeOp, ArrayRef operands, +IntStoreOpPattern::matchAndRewrite(memref::StoreOp storeOp, + ArrayRef operands, ConversionPatternRewriter &rewriter) const { - StoreOpAdaptor storeOperands(operands); + memref::StoreOpAdaptor storeOperands(operands); auto memrefType = storeOp.memref().getType().cast(); if (!memrefType.getElementType().isSignlessInteger()) return failure(); @@ -1117,9 +1119,10 @@ } LogicalResult -StoreOpPattern::matchAndRewrite(StoreOp storeOp, ArrayRef operands, +StoreOpPattern::matchAndRewrite(memref::StoreOp storeOp, + ArrayRef operands, ConversionPatternRewriter &rewriter) const { - StoreOpAdaptor storeOperands(operands); + memref::StoreOpAdaptor storeOperands(operands); auto memrefType = storeOp.memref().getType().cast(); if (memrefType.getElementType().isSignlessInteger()) return failure(); diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -250,7 +250,7 @@ op->getParentWithTrait(); assert(scope && "Expected op to be inside automatic allocation scope"); b.setInsertionPointToStart(&scope->getRegion(0).front()); - Value res = std_alloca(memRefMinorVectorType); + Value res = memref_alloca(memRefMinorVectorType); return res; } @@ -312,7 +312,7 @@ return {vector}; } // 3.b. Otherwise, just go through the temporary `alloc`. - std_store(vector, alloc, majorIvs); + memref_store(vector, alloc, majorIvs); return {}; }, [&]() -> scf::ValueVector { @@ -324,7 +324,7 @@ return {vector}; } // 3.d. Otherwise, just go through the temporary `alloc`. - std_store(vector, alloc, majorIvs); + memref_store(vector, alloc, majorIvs); return {}; }); @@ -339,7 +339,7 @@ result = vector_insert(loaded1D, result, majorIvs); // 5.b. Otherwise, just go through the temporary `alloc`. else - std_store(loaded1D, alloc, majorIvs); + memref_store(loaded1D, alloc, majorIvs); } }); @@ -357,8 +357,8 @@ Value alloc; if (!options.unroll) { alloc = setAllocAtFunctionEntry(memRefMinorVectorType, op); - std_store(xferOp.vector(), - vector_type_cast(MemRefType::get({}, vectorType), alloc)); + memref_store(xferOp.vector(), + vector_type_cast(MemRefType::get({}, vectorType), alloc)); } emitLoops([&](ValueRange majorIvs, ValueRange leadingOffsets, @@ -665,7 +665,7 @@ Value tmp = setAllocAtFunctionEntry(tmpMemRefType(transfer), transfer); StdIndexedValue local(tmp); Value vec = vector_type_cast(tmp); - std_store(vectorValue, vec); + memref_store(vectorValue, vec); loopNestBuilder(lbs, ubs, steps, [&](ValueRange loopIvs) { auto ivsStorage = llvm::to_vector<8>(loopIvs); // Swap the ivsStorage which will reorder memory accesses. diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -8,6 +8,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/BuiltinOps.h" @@ -335,7 +336,7 @@ "expect only `dim` operations with a constant index"); int64_t i = index.getValue(); return TypeSwitch(dimOp.memrefOrTensor().getDefiningOp()) - .Case( + .Case( [&](auto op) { return isMemRefSizeValidSymbol(op, i, region); }) .Default([](Operation *) { return false; }); } @@ -915,12 +916,12 @@ //===----------------------------------------------------------------------===// /// This is a common class used for patterns of the form -/// "someop(memrefcast) -> someop". It folds the source of any memref_cast +/// "someop(memrefcast) -> someop". It folds the source of any memref.cast /// into the root operation directly. static LogicalResult foldMemRefCast(Operation *op) { bool folded = false; for (OpOperand &operand : op->getOpOperands()) { - auto cast = operand.get().getDefiningOp(); + auto cast = operand.get().getDefiningOp(); if (cast && !cast.getOperand().getType().isa()) { operand.set(cast.getOperand()); folded = true; diff --git a/mlir/lib/Dialect/CMakeLists.txt b/mlir/lib/Dialect/CMakeLists.txt --- a/mlir/lib/Dialect/CMakeLists.txt +++ b/mlir/lib/Dialect/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(Linalg) add_subdirectory(LLVMIR) add_subdirectory(Math) +add_subdirectory(MemRef) add_subdirectory(OpenACC) add_subdirectory(OpenMP) add_subdirectory(PDL) diff --git a/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp b/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp --- a/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp @@ -13,6 +13,7 @@ #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/GPU/Passes.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/IR/Builders.h" @@ -107,7 +108,7 @@ createPredicatedBlock(isFirstLane, [&] { Value subgroupId = getDivideBySubgroupSize(invocationIdx); Value index = create(indexType, subgroupId); - create(subgroupReduce, buffer, index); + create(subgroupReduce, buffer, index); }); create(); @@ -127,7 +128,7 @@ Value value = create(valueType, buffer, index); Value result = createSubgroupReduce(numSubgroups, laneId, value, accumFactory); - create(result, buffer, zero); + create(result, buffer, zero); }); // Synchronize workgroup and load result from workgroup memory. @@ -139,12 +140,14 @@ private: // Shortcut to create an op from rewriter using loc as the first argument. - template T create(Args... args) { + template + T create(Args... args) { return rewriter.create(loc, std::forward(args)...); } // Creates dimension op of type T, with the result casted to int32. - template Value getDimOp(StringRef dimension) { + template + Value getDimOp(StringRef dimension) { Value dim = create(indexType, rewriter.getStringAttr(dimension)); return create(int32Type, dim); } @@ -236,7 +239,8 @@ } /// Returns an accumulator factory that creates an op of type T. - template AccumulatorFactory getFactory() { + template + AccumulatorFactory getFactory() { return [&](Value lhs, Value rhs) { return create(lhs.getType(), lhs, rhs); }; diff --git a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt @@ -17,5 +17,6 @@ MLIRSideEffectInterfaces MLIRViewLikeInterface MLIRStandard + MLIRMemRef MLIRTensor ) diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -108,12 +108,12 @@ /// ``` /// someop(memrefcast) -> someop /// ``` -/// It folds the source of the memref_cast into the root operation directly. +/// It folds the source of the memref.cast into the root operation directly. static LogicalResult foldMemRefCast(Operation *op) { bool folded = false; for (OpOperand &operand : op->getOpOperands()) { - auto castOp = operand.get().getDefiningOp(); - if (castOp && canFoldIntoConsumerOp(castOp)) { + auto castOp = operand.get().getDefiningOp(); + if (castOp && memref::CastOp::canFoldIntoConsumerOp(castOp)) { operand.set(castOp.getOperand()); folded = true; } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp @@ -25,8 +25,8 @@ static Value cloneMemref(Location loc, Value memref, OpBuilder &b) { auto memrefType = memref.getType().cast(); - auto alloc = - b.create(loc, memrefType, getDynOperands(loc, memref, b)); + auto alloc = b.create(loc, memrefType, + getDynOperands(loc, memref, b)); b.create(loc, memref, alloc); return alloc; } @@ -60,17 +60,17 @@ continue; } - if (auto alloc = resultTensor.getDefiningOp()) { + if (auto alloc = resultTensor.getDefiningOp()) { resultBuffers.push_back(resultTensor); continue; } // Allocate buffers for statically-shaped results. if (memrefType.hasStaticShape()) { - resultBuffers.push_back(b.create(loc, memrefType)); + resultBuffers.push_back(b.create(loc, memrefType)); continue; } - resultBuffers.push_back(b.create( + resultBuffers.push_back(b.create( loc, memrefType, getDynOperands(loc, resultTensor, b))); } return success(); @@ -148,7 +148,7 @@ matchAndRewrite(InitTensorOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { linalg::InitTensorOpAdaptor adaptor(operands, op->getAttrDictionary()); - rewriter.replaceOpWithNewOp( + rewriter.replaceOpWithNewOp( op, getTypeConverter()->convertType(op.getType()).cast(), adaptor.sizes()); return success(); @@ -231,8 +231,8 @@ // op.sizes() capture exactly the dynamic alloc operands matching the // subviewMemRefType thanks to subview/subtensor canonicalization and // verification. - Value alloc = - rewriter.create(op.getLoc(), subviewMemRefType, op.sizes()); + Value alloc = rewriter.create( + op.getLoc(), subviewMemRefType, op.sizes()); Value subView = rewriter.create( op.getLoc(), sourceMemref, op.getMixedOffsets(), op.getMixedSizes(), op.getMixedStrides()); @@ -295,7 +295,7 @@ // Mark all Standard operations legal. target.addLegalDialect(); + memref::MemRefDialect, StandardOpsDialect>(); target.addIllegalOp(); // Mark all Linalg operations illegal as long as they work on tensors. diff --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp @@ -14,6 +14,7 @@ #include "mlir/Dialect/Linalg/Transforms/Hoisting.h" #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Utils.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" @@ -40,7 +41,7 @@ while (changed) { changed = false; func.walk([&changed](Operation *op) { - if (!isa(op)) + if (!isa(op)) return; LLVM_DEBUG(DBGS() << "Candidate for hoisting: " << *op << "\n"); @@ -66,14 +67,15 @@ v = op->getResult(0); } if (v && !llvm::all_of(v.getUses(), [&](OpOperand &operand) { - return isa(operand.getOwner()); + return isa( + operand.getOwner()); })) { LLVM_DEBUG(DBGS() << "Found non view-like or dealloc use: bail\n"); return; } // Move AllocOp before the loop. - if (isa(op)) + if (isa(op)) (void)loop.moveOutOfLoop({op}); else // Move DeallocOp outside of the loop. op->moveAfter(loop); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -40,7 +40,7 @@ using folded_linalg_range = FoldedValueBuilder; using folded_std_dim = FoldedValueBuilder; using folded_std_subview = FoldedValueBuilder; -using folded_std_view = FoldedValueBuilder; +using folded_memref_view = FoldedValueBuilder; #define DEBUG_TYPE "linalg-promotion" @@ -59,22 +59,22 @@ if (!dynamicBuffers) if (auto cst = size.getDefiningOp()) return options.useAlloca - ? std_alloca(MemRefType::get(width * cst.getValue(), - IntegerType::get(ctx, 8)), - ValueRange{}, alignment_attr) + ? memref_alloca(MemRefType::get(width * cst.getValue(), + IntegerType::get(ctx, 8)), + ValueRange{}, alignment_attr) .value - : std_alloc(MemRefType::get(width * cst.getValue(), - IntegerType::get(ctx, 8)), - ValueRange{}, alignment_attr) + : memref_alloc(MemRefType::get(width * cst.getValue(), + IntegerType::get(ctx, 8)), + ValueRange{}, alignment_attr) .value; Value mul = folded_std_muli(folder, folded_std_constant_index(folder, width), size); return options.useAlloca - ? std_alloca(MemRefType::get(-1, IntegerType::get(ctx, 8)), mul, - alignment_attr) + ? memref_alloca(MemRefType::get(-1, IntegerType::get(ctx, 8)), mul, + alignment_attr) .value - : std_alloc(MemRefType::get(-1, IntegerType::get(ctx, 8)), mul, - alignment_attr) + : memref_alloc(MemRefType::get(-1, IntegerType::get(ctx, 8)), mul, + alignment_attr) .value; } @@ -100,7 +100,7 @@ dynamicBuffers, folder, alignment); SmallVector dynSizes(boundingSubViewSize.size(), ShapedType::kDynamicSize); - Value view = folded_std_view( + Value view = folded_memref_view( folder, MemRefType::get(dynSizes, viewType.getElementType()), buffer, zero, boundingSubViewSize); return view; @@ -112,10 +112,10 @@ static LogicalResult defaultDeallocBufferCallBack(const LinalgPromotionOptions &options, OpBuilder &b, Value fullLocalView) { - auto viewOp = fullLocalView.getDefiningOp(); + auto viewOp = fullLocalView.getDefiningOp(); assert(viewOp && "expected full local view to be a ViewOp"); if (!options.useAlloca) - std_dealloc(viewOp.source()); + memref_dealloc(viewOp.source()); return success(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp @@ -546,7 +546,7 @@ // introduces a dense initialization component that may negatively // impact the running complexity of the sparse kernel. Value init = rewriter.create(loc, denseTp, tensor); - Value alloc = rewriter.create(loc, denseTp, args); + Value alloc = rewriter.create(loc, denseTp, args); rewriter.create(loc, init, alloc); return alloc; } @@ -737,7 +737,7 @@ if (codegen.curVecLength > 1) genVectorStore(codegen, rewriter, rhs, ptr, args); else - rewriter.create(loc, rhs, ptr, args); + rewriter.create(loc, rhs, ptr, args); } /// Generates a pointer/index load from the sparse storage scheme. diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -566,7 +566,7 @@ SubTensorOp::getCanonicalizationPatterns(patterns, ctx); SubViewOp::getCanonicalizationPatterns(patterns, ctx); tensor::CastOp::getCanonicalizationPatterns(patterns, ctx); - ViewOp::getCanonicalizationPatterns(patterns, ctx); + memref::ViewOp::getCanonicalizationPatterns(patterns, ctx); CanonicalizationPatternList< #define GET_OP_LIST #include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -110,7 +110,7 @@ value = vector_broadcast(vectorType, value); write = vector_transfer_write(value, dest, indices); } else { - write = std_store(value, dest); + write = memref_store(value, dest); } LLVM_DEBUG(dbgs() << "\n[" DEBUG_TYPE "]: vectorized op: " << *write); if (!write->getResults().empty()) @@ -543,7 +543,7 @@ rewriter.getAffineMapArrayAttr(indexingMaps), rewriter.getStrArrayAttr(iteratorTypes)); - rewriter.create(loc, result, output, ValueRange(zeros)); + rewriter.create(loc, result, output, ValueRange(zeros)); rewriter.eraseOp(op); return success(); } @@ -685,8 +685,8 @@ // Transfer into `view`. Value viewOrAlloc = xferOp.source(); - if (!viewOrAlloc.getDefiningOp() && - !viewOrAlloc.getDefiningOp()) + if (!viewOrAlloc.getDefiningOp() && + !viewOrAlloc.getDefiningOp()) return failure(); LLVM_DEBUG(llvm::dbgs() << "\n[" DEBUG_TYPE "]: " << viewOrAlloc); @@ -764,8 +764,8 @@ vector::TransferWriteOp xferOp, PatternRewriter &rewriter) const { // Transfer into `viewOrAlloc`. Value viewOrAlloc = xferOp.source(); - if (!viewOrAlloc.getDefiningOp() && - !viewOrAlloc.getDefiningOp()) + if (!viewOrAlloc.getDefiningOp() && + !viewOrAlloc.getDefiningOp()) return failure(); // Ensure there is exactly one subview of `viewOrAlloc` defining `subView`. diff --git a/mlir/lib/Dialect/MemRef/CMakeLists.txt b/mlir/lib/Dialect/MemRef/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/MemRef/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(IR) diff --git a/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt b/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/MemRef/IR/CMakeLists.txt @@ -0,0 +1,17 @@ +add_mlir_dialect_library(MLIRMemRef + MemRefDialect.cpp + MemRefOps.cpp + + ADDITIONAL_HEADER_DIRS + ${PROJECT_SOURCE_DIR}/inlude/mlir/Dialect/MemRefDialect + + DEPENDS + MLIRMemRefOpsIncGen + + LINK_COMPONENTS + Core + + LINK_LIBS PUBLIC + MLIRIR + MLIRSupport +) diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/MemRef/IR/MemRef.h" +#include "mlir/Transforms/InliningUtils.h" + +using namespace mlir; +using namespace mlir::memref; + +//===----------------------------------------------------------------------===// +// MemRefDialect Dialect Interfaces +//===----------------------------------------------------------------------===// + +namespace { +struct MemRefInlinerInterface : public DialectInlinerInterface { + using DialectInlinerInterface::DialectInlinerInterface; + bool isLegalToInline(Region *dest, Region *src, bool wouldBeCloned, + BlockAndValueMapping &valueMapping) const final { + return true; + } + bool isLegalToInline(Operation *, Region *, bool wouldBeCloned, + BlockAndValueMapping &) const final { + return true; + } +}; +} // end anonymous namespace + +void MemRefDialect::initialize() { + addOperations< +#define GET_OP_LIST +#include "mlir/Dialect/MemRef/IR/MemRefOps.cpp.inc" + >(); + addInterfaces(); +} diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp @@ -0,0 +1,878 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/MemRef/IR/MemRef.h" +#include "mlir/Dialect/StandardOps/IR/Ops.h" +#include "mlir/IR/AffineMap.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Matchers.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/IR/TypeUtilities.h" +#include "llvm/ADT/STLExtras.h" + +using namespace mlir; +using namespace mlir::memref; + +/// Matches a ConstantIndexOp. +/// TODO: This should probably just be a general matcher that uses m_Constant +/// and checks the operation for an index type. +static detail::op_matcher m_ConstantIndex() { + return detail::op_matcher(); +} + +//===----------------------------------------------------------------------===// +// Common canonicalization pattern support logic +//===----------------------------------------------------------------------===// + +/// This is a common class used for patterns of the form +/// "someop(memrefcast) -> someop". It folds the source of any memref.cast +/// into the root operation directly. +static LogicalResult foldMemRefCast(Operation *op) { + bool folded = false; + for (OpOperand &operand : op->getOpOperands()) { + auto cast = operand.get().getDefiningOp(); + if (cast && !cast.getOperand().getType().isa()) { + operand.set(cast.getOperand()); + folded = true; + } + } + return success(folded); +} + +//===----------------------------------------------------------------------===// +// Helpers for Tensor[Load|Store]Op, TensorToMemrefOp, and GlobalOp +//===----------------------------------------------------------------------===// + +static Type getTensorTypeFromMemRefType(Type type) { + if (auto memref = type.dyn_cast()) + return RankedTensorType::get(memref.getShape(), memref.getElementType()); + if (auto memref = type.dyn_cast()) + return UnrankedTensorType::get(memref.getElementType()); + return NoneType::get(type.getContext()); +} + +//===----------------------------------------------------------------------===// +// AllocOp / AllocaOp +//===----------------------------------------------------------------------===// + +template +static LogicalResult verifyAllocLikeOp(AllocLikeOp op) { + static_assert(llvm::is_one_of::value, + "applies to only alloc or alloca"); + auto memRefType = op.getResult().getType().template dyn_cast(); + if (!memRefType) + return op.emitOpError("result must be a memref"); + + if (static_cast(op.dynamicSizes().size()) != + memRefType.getNumDynamicDims()) + return op.emitOpError("dimension operand count does not equal memref " + "dynamic dimension count"); + + unsigned numSymbols = 0; + if (!memRefType.getAffineMaps().empty()) + numSymbols = memRefType.getAffineMaps().front().getNumSymbols(); + if (op.symbolOperands().size() != numSymbols) + return op.emitOpError( + "symbol operand count does not equal memref symbol count"); + + return success(); +} + +static LogicalResult verify(AllocOp op) { return verifyAllocLikeOp(op); } + +static LogicalResult verify(AllocaOp op) { + // An alloca op needs to have an ancestor with an allocation scope trait. + if (!op->getParentWithTrait()) + return op.emitOpError( + "requires an ancestor op with AutomaticAllocationScope trait"); + + return verifyAllocLikeOp(op); +} + +namespace { +/// Fold constant dimensions into an alloc like operation. +template +struct SimplifyAllocConst : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(AllocLikeOp alloc, + PatternRewriter &rewriter) const override { + // Check to see if any dimensions operands are constants. If so, we can + // substitute and drop them. + if (llvm::none_of(alloc.getOperands(), [](Value operand) { + return matchPattern(operand, m_ConstantIndex()); + })) + return failure(); + + auto memrefType = alloc.getType(); + + // Ok, we have one or more constant operands. Collect the non-constant ones + // and keep track of the resultant memref type to build. + SmallVector newShapeConstants; + newShapeConstants.reserve(memrefType.getRank()); + SmallVector newOperands; + + unsigned dynamicDimPos = 0; + for (unsigned dim = 0, e = memrefType.getRank(); dim < e; ++dim) { + int64_t dimSize = memrefType.getDimSize(dim); + // If this is already static dimension, keep it. + if (dimSize != -1) { + newShapeConstants.push_back(dimSize); + continue; + } + auto *defOp = alloc.getOperand(dynamicDimPos).getDefiningOp(); + if (auto constantIndexOp = dyn_cast_or_null(defOp)) { + // Dynamic shape dimension will be folded. + newShapeConstants.push_back(constantIndexOp.getValue()); + } else { + // Dynamic shape dimension not folded; copy operand from old memref. + newShapeConstants.push_back(-1); + newOperands.push_back(alloc.getOperand(dynamicDimPos)); + } + dynamicDimPos++; + } + + // Create new memref type (which will have fewer dynamic dimensions). + MemRefType newMemRefType = + MemRefType::Builder(memrefType).setShape(newShapeConstants); + assert(static_cast(newOperands.size()) == + newMemRefType.getNumDynamicDims()); + + // Create and insert the alloc op for the new memref. + auto newAlloc = rewriter.create(alloc.getLoc(), newMemRefType, + newOperands, IntegerAttr()); + // Insert a cast so we have the same type as the old alloc. + auto resultCast = + rewriter.create(alloc.getLoc(), newAlloc, alloc.getType()); + + rewriter.replaceOp(alloc, {resultCast}); + return success(); + } +}; + +/// Fold alloc operations with no uses. Alloc has side effects on the heap, +/// but can still be deleted if it has zero uses. +struct SimplifyDeadAlloc : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(AllocOp alloc, + PatternRewriter &rewriter) const override { + if (alloc.use_empty()) { + rewriter.eraseOp(alloc); + return success(); + } + return failure(); + } +}; +} // end anonymous namespace. + +void AllocOp::getCanonicalizationPatterns(OwningRewritePatternList &results, + MLIRContext *context) { + results.insert, SimplifyDeadAlloc>(context); +} + +void AllocaOp::getCanonicalizationPatterns(OwningRewritePatternList &results, + MLIRContext *context) { + results.insert>(context); +} + +//===----------------------------------------------------------------------===// +// CastOp +//===----------------------------------------------------------------------===// + +/// Determines whether MemRef_CastOp casts to a more dynamic version of the +/// source memref. This is useful to to fold a memref.cast into a consuming op +/// and implement canonicalization patterns for ops in different dialects that +/// may consume the results of memref.cast operations. Such foldable memref.cast +/// operations are typically inserted as `view` and `subview` ops are +/// canonicalized, to preserve the type compatibility of their uses. +/// +/// Returns true when all conditions are met: +/// 1. source and result are ranked memrefs with strided semantics and same +/// element type and rank. +/// 2. each of the source's size, offset or stride has more static information +/// than the corresponding result's size, offset or stride. +/// +/// Example 1: +/// ```mlir +/// %1 = memref.cast %0 : memref<8x16xf32> to memref +/// %2 = consumer %1 ... : memref ... +/// ``` +/// +/// may fold into: +/// +/// ```mlir +/// %2 = consumer %0 ... : memref<8x16xf32> ... +/// ``` +/// +/// Example 2: +/// ``` +/// %1 = memref.cast %0 : memref(16 * i + j)>> +/// to memref +/// consumer %1 : memref ... +/// ``` +/// +/// may fold into: +/// +/// ``` +/// consumer %0 ... : memref(16 * i + j)>> +/// ``` +bool CastOp::canFoldIntoConsumerOp(CastOp castOp) { + MemRefType sourceType = castOp.source().getType().dyn_cast(); + MemRefType resultType = castOp.getType().dyn_cast(); + + // Requires ranked MemRefType. + if (!sourceType || !resultType) + return false; + + // Requires same elemental type. + if (sourceType.getElementType() != resultType.getElementType()) + return false; + + // Requires same rank. + if (sourceType.getRank() != resultType.getRank()) + return false; + + // Only fold casts between strided memref forms. + int64_t sourceOffset, resultOffset; + SmallVector sourceStrides, resultStrides; + if (failed(getStridesAndOffset(sourceType, sourceStrides, sourceOffset)) || + failed(getStridesAndOffset(resultType, resultStrides, resultOffset))) + return false; + + // If cast is towards more static sizes along any dimension, don't fold. + for (auto it : llvm::zip(sourceType.getShape(), resultType.getShape())) { + auto ss = std::get<0>(it), st = std::get<1>(it); + if (ss != st) + if (MemRefType::isDynamic(ss) && !MemRefType::isDynamic(st)) + return false; + } + + // If cast is towards more static offset along any dimension, don't fold. + if (sourceOffset != resultOffset) + if (MemRefType::isDynamicStrideOrOffset(sourceOffset) && + !MemRefType::isDynamicStrideOrOffset(resultOffset)) + return false; + + // If cast is towards more static strides along any dimension, don't fold. + for (auto it : llvm::zip(sourceStrides, resultStrides)) { + auto ss = std::get<0>(it), st = std::get<1>(it); + if (ss != st) + if (MemRefType::isDynamicStrideOrOffset(ss) && + !MemRefType::isDynamicStrideOrOffset(st)) + return false; + } + + return true; +} + +bool CastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) { + if (inputs.size() != 1 || outputs.size() != 1) + return false; + Type a = inputs.front(), b = outputs.front(); + auto aT = a.dyn_cast(); + auto bT = b.dyn_cast(); + + auto uaT = a.dyn_cast(); + auto ubT = b.dyn_cast(); + + if (aT && bT) { + if (aT.getElementType() != bT.getElementType()) + return false; + if (aT.getAffineMaps() != bT.getAffineMaps()) { + int64_t aOffset, bOffset; + SmallVector aStrides, bStrides; + if (failed(getStridesAndOffset(aT, aStrides, aOffset)) || + failed(getStridesAndOffset(bT, bStrides, bOffset)) || + aStrides.size() != bStrides.size()) + return false; + + // Strides along a dimension/offset are compatible if the value in the + // source memref is static and the value in the target memref is the + // same. They are also compatible if either one is dynamic (see + // description of MemRefCastOp for details). + auto checkCompatible = [](int64_t a, int64_t b) { + return (a == MemRefType::getDynamicStrideOrOffset() || + b == MemRefType::getDynamicStrideOrOffset() || a == b); + }; + if (!checkCompatible(aOffset, bOffset)) + return false; + for (auto aStride : enumerate(aStrides)) + if (!checkCompatible(aStride.value(), bStrides[aStride.index()])) + return false; + } + if (aT.getMemorySpace() != bT.getMemorySpace()) + return false; + + // They must have the same rank, and any specified dimensions must match. + if (aT.getRank() != bT.getRank()) + return false; + + for (unsigned i = 0, e = aT.getRank(); i != e; ++i) { + int64_t aDim = aT.getDimSize(i), bDim = bT.getDimSize(i); + if (aDim != -1 && bDim != -1 && aDim != bDim) + return false; + } + return true; + } else { + if (!aT && !uaT) + return false; + if (!bT && !ubT) + return false; + // Unranked to unranked casting is unsupported + if (uaT && ubT) + return false; + + auto aEltType = (aT) ? aT.getElementType() : uaT.getElementType(); + auto bEltType = (bT) ? bT.getElementType() : ubT.getElementType(); + if (aEltType != bEltType) + return false; + + auto aMemSpace = (aT) ? aT.getMemorySpace() : uaT.getMemorySpace(); + auto bMemSpace = (bT) ? bT.getMemorySpace() : ubT.getMemorySpace(); + if (aMemSpace != bMemSpace) + return false; + + return true; + } + + return false; +} + +OpFoldResult CastOp::fold(ArrayRef operands) { + return succeeded(foldMemRefCast(*this)) ? getResult() : Value(); +} + +//===----------------------------------------------------------------------===// +// DeallocOp +//===----------------------------------------------------------------------===// +namespace { +/// Fold Dealloc operations that are deallocating an AllocOp that is only used +/// by other Dealloc operations. +struct SimplifyDeadDealloc : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(DeallocOp dealloc, + PatternRewriter &rewriter) const override { + // Check that the memref operand's defining operation is an AllocOp. + Value memref = dealloc.memref(); + if (!isa_and_nonnull(memref.getDefiningOp())) + return failure(); + + // Check that all of the uses of the AllocOp are other DeallocOps. + for (auto *user : memref.getUsers()) + if (!isa(user)) + return failure(); + + // Erase the dealloc operation. + rewriter.eraseOp(dealloc); + return success(); + } +}; +} // end anonymous namespace. + +static LogicalResult verify(DeallocOp op) { + if (!op.memref().getType().isa()) + return op.emitOpError("operand must be a memref"); + return success(); +} + +void DeallocOp::getCanonicalizationPatterns(OwningRewritePatternList &results, + MLIRContext *context) { + results.insert(context); +} + +LogicalResult DeallocOp::fold(ArrayRef cstOperands, + SmallVectorImpl &results) { + /// dealloc(memrefcast) -> dealloc + return foldMemRefCast(*this); +} + +//===----------------------------------------------------------------------===// +// GlobalOp +//===----------------------------------------------------------------------===// + +static void printGlobalMemrefOpTypeAndInitialValue(OpAsmPrinter &p, GlobalOp op, + TypeAttr type, + Attribute initialValue) { + p << type; + if (!op.isExternal()) { + p << " = "; + if (op.isUninitialized()) + p << "uninitialized"; + else + p.printAttributeWithoutType(initialValue); + } +} + +static ParseResult +parseGlobalMemrefOpTypeAndInitialValue(OpAsmParser &parser, TypeAttr &typeAttr, + Attribute &initialValue) { + Type type; + if (parser.parseType(type)) + return failure(); + + auto memrefType = type.dyn_cast(); + if (!memrefType || !memrefType.hasStaticShape()) + return parser.emitError(parser.getNameLoc()) + << "type should be static shaped memref, but got " << type; + typeAttr = TypeAttr::get(type); + + if (parser.parseOptionalEqual()) + return success(); + + if (succeeded(parser.parseOptionalKeyword("uninitialized"))) { + initialValue = UnitAttr::get(parser.getBuilder().getContext()); + return success(); + } + + Type tensorType = getTensorTypeFromMemRefType(memrefType); + if (parser.parseAttribute(initialValue, tensorType)) + return failure(); + if (!initialValue.isa()) + return parser.emitError(parser.getNameLoc()) + << "initial value should be a unit or elements attribute"; + return success(); +} + +static LogicalResult verify(GlobalOp op) { + auto memrefType = op.type().dyn_cast(); + if (!memrefType || !memrefType.hasStaticShape()) + return op.emitOpError("type should be static shaped memref, but got ") + << op.type(); + + // Verify that the initial value, if present, is either a unit attribute or + // an elements attribute. + if (op.initial_value().hasValue()) { + Attribute initValue = op.initial_value().getValue(); + if (!initValue.isa() && !initValue.isa()) + return op.emitOpError("initial value should be a unit or elements " + "attribute, but got ") + << initValue; + + // Check that the type of the initial value is compatible with the type of + // the global variable. + if (initValue.isa()) { + Type initType = initValue.getType(); + Type tensorType = getTensorTypeFromMemRefType(memrefType); + if (initType != tensorType) + return op.emitOpError("initial value expected to be of type ") + << tensorType << ", but was of type " << initType; + } + } + + // TODO: verify visibility for declarations. + return success(); +} + +//===----------------------------------------------------------------------===// +// GetGlobalOp +//===----------------------------------------------------------------------===// + +LogicalResult +GetGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) { + // Verify that the result type is same as the type of the referenced + // memref.global op. + auto global = + symbolTable.lookupNearestSymbolFrom(*this, nameAttr()); + if (!global) + return emitOpError("'") + << name() << "' does not reference a valid global memref"; + + Type resultType = result().getType(); + if (global.type() != resultType) + return emitOpError("result type ") + << resultType << " does not match type " << global.type() + << " of the global memref @" << name(); + return success(); +} + +//===----------------------------------------------------------------------===// +// PrefetchOp +//===----------------------------------------------------------------------===// + +static void print(OpAsmPrinter &p, PrefetchOp op) { + p << PrefetchOp::getOperationName() << " " << op.memref() << '['; + p.printOperands(op.indices()); + p << ']' << ", " << (op.isWrite() ? "write" : "read"); + p << ", locality<" << op.localityHint(); + p << ">, " << (op.isDataCache() ? "data" : "instr"); + p.printOptionalAttrDict( + op.getAttrs(), + /*elidedAttrs=*/{"localityHint", "isWrite", "isDataCache"}); + p << " : " << op.getMemRefType(); +} + +static ParseResult parsePrefetchOp(OpAsmParser &parser, + OperationState &result) { + OpAsmParser::OperandType memrefInfo; + SmallVector indexInfo; + IntegerAttr localityHint; + MemRefType type; + StringRef readOrWrite, cacheType; + + auto indexTy = parser.getBuilder().getIndexType(); + auto i32Type = parser.getBuilder().getIntegerType(32); + if (parser.parseOperand(memrefInfo) || + parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) || + parser.parseComma() || parser.parseKeyword(&readOrWrite) || + parser.parseComma() || parser.parseKeyword("locality") || + parser.parseLess() || + parser.parseAttribute(localityHint, i32Type, "localityHint", + result.attributes) || + parser.parseGreater() || parser.parseComma() || + parser.parseKeyword(&cacheType) || parser.parseColonType(type) || + parser.resolveOperand(memrefInfo, type, result.operands) || + parser.resolveOperands(indexInfo, indexTy, result.operands)) + return failure(); + + if (!readOrWrite.equals("read") && !readOrWrite.equals("write")) + return parser.emitError(parser.getNameLoc(), + "rw specifier has to be 'read' or 'write'"); + result.addAttribute( + PrefetchOp::getIsWriteAttrName(), + parser.getBuilder().getBoolAttr(readOrWrite.equals("write"))); + + if (!cacheType.equals("data") && !cacheType.equals("instr")) + return parser.emitError(parser.getNameLoc(), + "cache type has to be 'data' or 'instr'"); + + result.addAttribute( + PrefetchOp::getIsDataCacheAttrName(), + parser.getBuilder().getBoolAttr(cacheType.equals("data"))); + + return success(); +} + +static LogicalResult verify(PrefetchOp op) { + if (op.getNumOperands() != 1 + op.getMemRefType().getRank()) + return op.emitOpError("too few indices"); + + return success(); +} + +LogicalResult PrefetchOp::fold(ArrayRef cstOperands, + SmallVectorImpl &results) { + // prefetch(memrefcast) -> prefetch + return foldMemRefCast(*this); +} + +//===----------------------------------------------------------------------===// +// ReshapeOp +//===----------------------------------------------------------------------===// + +static LogicalResult verify(ReshapeOp op) { + Type operandType = op.source().getType(); + Type resultType = op.result().getType(); + + Type operandElementType = operandType.cast().getElementType(); + Type resultElementType = resultType.cast().getElementType(); + if (operandElementType != resultElementType) + return op.emitOpError("element types of source and destination memref " + "types should be the same"); + + if (auto operandMemRefType = operandType.dyn_cast()) + if (!operandMemRefType.getAffineMaps().empty()) + return op.emitOpError( + "source memref type should have identity affine map"); + + int64_t shapeSize = op.shape().getType().cast().getDimSize(0); + auto resultMemRefType = resultType.dyn_cast(); + if (resultMemRefType) { + if (!resultMemRefType.getAffineMaps().empty()) + return op.emitOpError( + "result memref type should have identity affine map"); + if (shapeSize == ShapedType::kDynamicSize) + return op.emitOpError("cannot use shape operand with dynamic length to " + "reshape to statically-ranked memref type"); + if (shapeSize != resultMemRefType.getRank()) + return op.emitOpError( + "length of shape operand differs from the result's memref rank"); + } + return success(); +} + +//===----------------------------------------------------------------------===// +// StoreOp +//===----------------------------------------------------------------------===// + +static LogicalResult verify(StoreOp op) { + if (op.getNumOperands() != 2 + op.getMemRefType().getRank()) + return op.emitOpError("store index operand count not equal to memref rank"); + + return success(); +} + +LogicalResult StoreOp::fold(ArrayRef cstOperands, + SmallVectorImpl &results) { + /// store(memrefcast) -> store + return foldMemRefCast(*this); +} + +//===----------------------------------------------------------------------===// +// TransposeOp +//===----------------------------------------------------------------------===// + +/// Build a strided memref type by applying `permutationMap` tp `memRefType`. +static MemRefType inferTransposeResultType(MemRefType memRefType, + AffineMap permutationMap) { + auto rank = memRefType.getRank(); + auto originalSizes = memRefType.getShape(); + // Compute permuted sizes. + SmallVector sizes(rank, 0); + for (auto en : llvm::enumerate(permutationMap.getResults())) + sizes[en.index()] = + originalSizes[en.value().cast().getPosition()]; + + // Compute permuted strides. + int64_t offset; + SmallVector strides; + auto res = getStridesAndOffset(memRefType, strides, offset); + assert(succeeded(res) && strides.size() == static_cast(rank)); + (void)res; + auto map = + makeStridedLinearLayoutMap(strides, offset, memRefType.getContext()); + map = permutationMap ? map.compose(permutationMap) : map; + return MemRefType::Builder(memRefType).setShape(sizes).setAffineMaps(map); +} + +void TransposeOp::build(OpBuilder &b, OperationState &result, Value in, + AffineMapAttr permutation, + ArrayRef attrs) { + auto permutationMap = permutation.getValue(); + assert(permutationMap); + + auto memRefType = in.getType().cast(); + // Compute result type. + MemRefType resultType = inferTransposeResultType(memRefType, permutationMap); + + build(b, result, resultType, in, attrs); + result.addAttribute(TransposeOp::getPermutationAttrName(), permutation); +} + +// transpose $in $permutation attr-dict : type($in) `to` type(results) +static void print(OpAsmPrinter &p, TransposeOp op) { + p << "transpose " << op.in() << " " << op.permutation(); + p.printOptionalAttrDict(op.getAttrs(), + {TransposeOp::getPermutationAttrName()}); + p << " : " << op.in().getType() << " to " << op.getType(); +} + +static ParseResult parseTransposeOp(OpAsmParser &parser, + OperationState &result) { + OpAsmParser::OperandType in; + AffineMap permutation; + MemRefType srcType, dstType; + if (parser.parseOperand(in) || parser.parseAffineMap(permutation) || + parser.parseOptionalAttrDict(result.attributes) || + parser.parseColonType(srcType) || + parser.resolveOperand(in, srcType, result.operands) || + parser.parseKeywordType("to", dstType) || + parser.addTypeToList(dstType, result.types)) + return failure(); + + result.addAttribute(TransposeOp::getPermutationAttrName(), + AffineMapAttr::get(permutation)); + return success(); +} + +static LogicalResult verify(TransposeOp op) { + if (!op.permutation().isPermutation()) + return op.emitOpError("expected a permutation map"); + if (op.permutation().getNumDims() != op.getShapedType().getRank()) + return op.emitOpError( + "expected a permutation map of same rank as the input"); + + auto srcType = op.in().getType().cast(); + auto dstType = op.getType().cast(); + auto transposedType = inferTransposeResultType(srcType, op.permutation()); + if (dstType != transposedType) + return op.emitOpError("output type ") + << dstType << " does not match transposed input type " << srcType + << ", " << transposedType; + return success(); +} + +OpFoldResult TransposeOp::fold(ArrayRef) { + if (succeeded(foldMemRefCast(*this))) + return getResult(); + return {}; +} + +//===----------------------------------------------------------------------===// +// ViewOp +//===----------------------------------------------------------------------===// + +static ParseResult parseViewOp(OpAsmParser &parser, OperationState &result) { + OpAsmParser::OperandType srcInfo; + SmallVector offsetInfo; + SmallVector sizesInfo; + auto indexType = parser.getBuilder().getIndexType(); + Type srcType, dstType; + llvm::SMLoc offsetLoc; + if (parser.parseOperand(srcInfo) || parser.getCurrentLocation(&offsetLoc) || + parser.parseOperandList(offsetInfo, OpAsmParser::Delimiter::Square)) + return failure(); + + if (offsetInfo.size() != 1) + return parser.emitError(offsetLoc) << "expects 1 offset operand"; + + return failure( + parser.parseOperandList(sizesInfo, OpAsmParser::Delimiter::Square) || + parser.parseOptionalAttrDict(result.attributes) || + parser.parseColonType(srcType) || + parser.resolveOperand(srcInfo, srcType, result.operands) || + parser.resolveOperands(offsetInfo, indexType, result.operands) || + parser.resolveOperands(sizesInfo, indexType, result.operands) || + parser.parseKeywordType("to", dstType) || + parser.addTypeToList(dstType, result.types)); +} + +static void print(OpAsmPrinter &p, ViewOp op) { + p << op.getOperationName() << ' ' << op.getOperand(0) << '['; + p.printOperand(op.byte_shift()); + p << "][" << op.sizes() << ']'; + p.printOptionalAttrDict(op.getAttrs()); + p << " : " << op.getOperand(0).getType() << " to " << op.getType(); +} + +static LogicalResult verify(ViewOp op) { + auto baseType = op.getOperand(0).getType().cast(); + auto viewType = op.getType(); + + // The base memref should have identity layout map (or none). + if (baseType.getAffineMaps().size() > 1 || + (baseType.getAffineMaps().size() == 1 && + !baseType.getAffineMaps()[0].isIdentity())) + return op.emitError("unsupported map for base memref type ") << baseType; + + // The result memref should have identity layout map (or none). + if (viewType.getAffineMaps().size() > 1 || + (viewType.getAffineMaps().size() == 1 && + !viewType.getAffineMaps()[0].isIdentity())) + return op.emitError("unsupported map for result memref type ") << viewType; + + // The base memref and the view memref should be in the same memory space. + if (baseType.getMemorySpace() != viewType.getMemorySpace()) + return op.emitError("different memory spaces specified for base memref " + "type ") + << baseType << " and view memref type " << viewType; + + // Verify that we have the correct number of sizes for the result type. + unsigned numDynamicDims = viewType.getNumDynamicDims(); + if (op.sizes().size() != numDynamicDims) + return op.emitError("incorrect number of size operands for type ") + << viewType; + + return success(); +} + +Value ViewOp::getViewSource() { return source(); } + +namespace { + +struct ViewOpShapeFolder : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(ViewOp viewOp, + PatternRewriter &rewriter) const override { + // Return if none of the operands are constants. + if (llvm::none_of(viewOp.getOperands(), [](Value operand) { + return matchPattern(operand, m_ConstantIndex()); + })) + return failure(); + + // Get result memref type. + auto memrefType = viewOp.getType(); + + // Get offset from old memref view type 'memRefType'. + int64_t oldOffset; + SmallVector oldStrides; + if (failed(getStridesAndOffset(memrefType, oldStrides, oldOffset))) + return failure(); + assert(oldOffset == 0 && "Expected 0 offset"); + + SmallVector newOperands; + + // Offset cannot be folded into result type. + + // Fold any dynamic dim operands which are produced by a constant. + SmallVector newShapeConstants; + newShapeConstants.reserve(memrefType.getRank()); + + unsigned dynamicDimPos = 0; + unsigned rank = memrefType.getRank(); + for (unsigned dim = 0, e = rank; dim < e; ++dim) { + int64_t dimSize = memrefType.getDimSize(dim); + // If this is already static dimension, keep it. + if (!ShapedType::isDynamic(dimSize)) { + newShapeConstants.push_back(dimSize); + continue; + } + auto *defOp = viewOp.sizes()[dynamicDimPos].getDefiningOp(); + if (auto constantIndexOp = dyn_cast_or_null(defOp)) { + // Dynamic shape dimension will be folded. + newShapeConstants.push_back(constantIndexOp.getValue()); + } else { + // Dynamic shape dimension not folded; copy operand from old memref. + newShapeConstants.push_back(dimSize); + newOperands.push_back(viewOp.sizes()[dynamicDimPos]); + } + dynamicDimPos++; + } + + // Create new memref type with constant folded dims. + MemRefType newMemRefType = + MemRefType::Builder(memrefType).setShape(newShapeConstants); + // Nothing new, don't fold. + if (newMemRefType == memrefType) + return failure(); + + // Create new ViewOp. + auto newViewOp = rewriter.create(viewOp.getLoc(), newMemRefType, + viewOp.getOperand(0), + viewOp.byte_shift(), newOperands); + // Insert a cast so we have the same type as the old memref type. + rewriter.replaceOpWithNewOp(viewOp, newViewOp, viewOp.getType()); + return success(); + } +}; + +struct ViewOpMemrefCastFolder : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(ViewOp viewOp, + PatternRewriter &rewriter) const override { + Value memrefOperand = viewOp.getOperand(0); + CastOp memrefCastOp = memrefOperand.getDefiningOp(); + if (!memrefCastOp) + return failure(); + Value allocOperand = memrefCastOp.getOperand(); + AllocOp allocOp = allocOperand.getDefiningOp(); + if (!allocOp) + return failure(); + rewriter.replaceOpWithNewOp(viewOp, viewOp.getType(), allocOperand, + viewOp.byte_shift(), viewOp.sizes()); + return success(); + } +}; + +} // end anonymous namespace + +void ViewOp::getCanonicalizationPatterns(OwningRewritePatternList &results, + MLIRContext *context) { + results.insert(context); +} + +//===----------------------------------------------------------------------===// +// TableGen'd op method definitions +//===----------------------------------------------------------------------===// + +#define GET_OP_CLASSES +#include "mlir/Dialect/MemRef/IR/MemRefOps.cpp.inc" diff --git a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp --- a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" @@ -52,7 +53,7 @@ ParallelOp firstPloop, ParallelOp secondPloop, const BlockAndValueMapping &firstToSecondPloopIndices) { DenseMap> bufferStores; - firstPloop.getBody()->walk([&](StoreOp store) { + firstPloop.getBody()->walk([&](memref::StoreOp store) { bufferStores[store.getMemRef()].push_back(store.indices()); }); auto walkResult = secondPloop.getBody()->walk([&](LoadOp load) { diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -9,6 +9,7 @@ #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/CommonFolders.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" @@ -194,6 +195,7 @@ } void StandardOpsDialect::initialize() { + getContext()->loadDialect(); getContext()->loadDialect(); addOperations someop". It folds the source of any memref_cast +/// "someop(memrefcast) -> someop". It folds the source of any memref.cast /// into the root operation directly. static LogicalResult foldMemRefCast(Operation *op) { bool folded = false; for (OpOperand &operand : op->getOpOperands()) { - auto cast = operand.get().getDefiningOp(); + auto cast = operand.get().getDefiningOp(); if (cast && !cast.getOperand().getType().isa()) { operand.set(cast.getOperand()); folded = true; @@ -299,131 +301,6 @@ })); } -//===----------------------------------------------------------------------===// -// AllocOp / AllocaOp -//===----------------------------------------------------------------------===// - -template -static LogicalResult verifyAllocLikeOp(AllocLikeOp op) { - static_assert(llvm::is_one_of::value, - "applies to only alloc or alloca"); - auto memRefType = op.getResult().getType().template dyn_cast(); - if (!memRefType) - return op.emitOpError("result must be a memref"); - - if (static_cast(op.dynamicSizes().size()) != - memRefType.getNumDynamicDims()) - return op.emitOpError("dimension operand count does not equal memref " - "dynamic dimension count"); - - unsigned numSymbols = 0; - if (!memRefType.getAffineMaps().empty()) - numSymbols = memRefType.getAffineMaps().front().getNumSymbols(); - if (op.symbolOperands().size() != numSymbols) - return op.emitOpError( - "symbol operand count does not equal memref symbol count"); - - return success(); -} - -static LogicalResult verify(AllocOp op) { return verifyAllocLikeOp(op); } - -static LogicalResult verify(AllocaOp op) { - // An alloca op needs to have an ancestor with an allocation scope trait. - if (!op->getParentWithTrait()) - return op.emitOpError( - "requires an ancestor op with AutomaticAllocationScope trait"); - - return verifyAllocLikeOp(op); -} - -namespace { -/// Fold constant dimensions into an alloc like operation. -template -struct SimplifyAllocConst : public OpRewritePattern { - using OpRewritePattern::OpRewritePattern; - - LogicalResult matchAndRewrite(AllocLikeOp alloc, - PatternRewriter &rewriter) const override { - // Check to see if any dimensions operands are constants. If so, we can - // substitute and drop them. - if (llvm::none_of(alloc.getOperands(), [](Value operand) { - return matchPattern(operand, m_ConstantIndex()); - })) - return failure(); - - auto memrefType = alloc.getType(); - - // Ok, we have one or more constant operands. Collect the non-constant ones - // and keep track of the resultant memref type to build. - SmallVector newShapeConstants; - newShapeConstants.reserve(memrefType.getRank()); - SmallVector newOperands; - - unsigned dynamicDimPos = 0; - for (unsigned dim = 0, e = memrefType.getRank(); dim < e; ++dim) { - int64_t dimSize = memrefType.getDimSize(dim); - // If this is already static dimension, keep it. - if (dimSize != -1) { - newShapeConstants.push_back(dimSize); - continue; - } - auto *defOp = alloc.getOperand(dynamicDimPos).getDefiningOp(); - if (auto constantIndexOp = dyn_cast_or_null(defOp)) { - // Dynamic shape dimension will be folded. - newShapeConstants.push_back(constantIndexOp.getValue()); - } else { - // Dynamic shape dimension not folded; copy operand from old memref. - newShapeConstants.push_back(-1); - newOperands.push_back(alloc.getOperand(dynamicDimPos)); - } - dynamicDimPos++; - } - - // Create new memref type (which will have fewer dynamic dimensions). - MemRefType newMemRefType = - MemRefType::Builder(memrefType).setShape(newShapeConstants); - assert(static_cast(newOperands.size()) == - newMemRefType.getNumDynamicDims()); - - // Create and insert the alloc op for the new memref. - auto newAlloc = rewriter.create(alloc.getLoc(), newMemRefType, - newOperands, IntegerAttr()); - // Insert a cast so we have the same type as the old alloc. - auto resultCast = rewriter.create(alloc.getLoc(), newAlloc, - alloc.getType()); - - rewriter.replaceOp(alloc, {resultCast}); - return success(); - } -}; - -/// Fold alloc operations with no uses. Alloc has side effects on the heap, -/// but can still be deleted if it has zero uses. -struct SimplifyDeadAlloc : public OpRewritePattern { - using OpRewritePattern::OpRewritePattern; - - LogicalResult matchAndRewrite(AllocOp alloc, - PatternRewriter &rewriter) const override { - if (alloc.use_empty()) { - rewriter.eraseOp(alloc); - return success(); - } - return failure(); - } -}; -} // end anonymous namespace. - -void AllocOp::getCanonicalizationPatterns(OwningRewritePatternList &results, - MLIRContext *context) { - results.insert, SimplifyDeadAlloc>(context); -} - -void AllocaOp::getCanonicalizationPatterns(OwningRewritePatternList &results, - MLIRContext *context) { - results.insert>(context); -} - //===----------------------------------------------------------------------===// // AndOp //===----------------------------------------------------------------------===// @@ -1327,51 +1204,6 @@ ConstantOp::build(builder, result, type, builder.getIntegerAttr(type, value)); } -//===----------------------------------------------------------------------===// -// DeallocOp -//===----------------------------------------------------------------------===// -namespace { -/// Fold Dealloc operations that are deallocating an AllocOp that is only used -/// by other Dealloc operations. -struct SimplifyDeadDealloc : public OpRewritePattern { - using OpRewritePattern::OpRewritePattern; - - LogicalResult matchAndRewrite(DeallocOp dealloc, - PatternRewriter &rewriter) const override { - // Check that the memref operand's defining operation is an AllocOp. - Value memref = dealloc.memref(); - if (!isa_and_nonnull(memref.getDefiningOp())) - return failure(); - - // Check that all of the uses of the AllocOp are other DeallocOps. - for (auto *user : memref.getUsers()) - if (!isa(user)) - return failure(); - - // Erase the dealloc operation. - rewriter.eraseOp(dealloc); - return success(); - } -}; -} // end anonymous namespace. - -static LogicalResult verify(DeallocOp op) { - if (!op.memref().getType().isa()) - return op.emitOpError("operand must be a memref"); - return success(); -} - -void DeallocOp::getCanonicalizationPatterns(OwningRewritePatternList &results, - MLIRContext *context) { - results.insert(context); -} - -LogicalResult DeallocOp::fold(ArrayRef cstOperands, - SmallVectorImpl &results) { - /// dealloc(memrefcast) -> dealloc - return foldMemRefCast(*this); -} - //===----------------------------------------------------------------------===// // DimOp //===----------------------------------------------------------------------===// @@ -1477,11 +1309,11 @@ if (!memrefType) return {}; - if (auto alloc = dyn_cast_or_null(definingOp)) + if (auto alloc = dyn_cast_or_null(definingOp)) return *(alloc.getDynamicSizes().begin() + memrefType.getDynamicDimIndex(unsignedIndex)); - if (auto view = dyn_cast_or_null(definingOp)) + if (auto view = dyn_cast_or_null(definingOp)) return *(view.getDynamicSizes().begin() + memrefType.getDynamicDimIndex(unsignedIndex)); @@ -1856,106 +1688,6 @@ return areVectorCastSimpleCompatible(a, b, areCastCompatible); } -//===----------------------------------------------------------------------===// -// GlobalMemrefOp -//===----------------------------------------------------------------------===// - -static void printGlobalMemrefOpTypeAndInitialValue(OpAsmPrinter &p, - GlobalMemrefOp op, - TypeAttr type, - Attribute initialValue) { - p << type; - if (!op.isExternal()) { - p << " = "; - if (op.isUninitialized()) - p << "uninitialized"; - else - p.printAttributeWithoutType(initialValue); - } -} - -static ParseResult -parseGlobalMemrefOpTypeAndInitialValue(OpAsmParser &parser, TypeAttr &typeAttr, - Attribute &initialValue) { - Type type; - if (parser.parseType(type)) - return failure(); - - auto memrefType = type.dyn_cast(); - if (!memrefType || !memrefType.hasStaticShape()) - return parser.emitError(parser.getNameLoc()) - << "type should be static shaped memref, but got " << type; - typeAttr = TypeAttr::get(type); - - if (parser.parseOptionalEqual()) - return success(); - - if (succeeded(parser.parseOptionalKeyword("uninitialized"))) { - initialValue = UnitAttr::get(parser.getBuilder().getContext()); - return success(); - } - - Type tensorType = getTensorTypeFromMemRefType(memrefType); - if (parser.parseAttribute(initialValue, tensorType)) - return failure(); - if (!initialValue.isa()) - return parser.emitError(parser.getNameLoc()) - << "initial value should be a unit or elements attribute"; - return success(); -} - -static LogicalResult verify(GlobalMemrefOp op) { - auto memrefType = op.type().dyn_cast(); - if (!memrefType || !memrefType.hasStaticShape()) - return op.emitOpError("type should be static shaped memref, but got ") - << op.type(); - - // Verify that the initial value, if present, is either a unit attribute or - // an elements attribute. - if (op.initial_value().hasValue()) { - Attribute initValue = op.initial_value().getValue(); - if (!initValue.isa() && !initValue.isa()) - return op.emitOpError("initial value should be a unit or elements " - "attribute, but got ") - << initValue; - - // Check that the type of the initial value is compatible with the type of - // the global variable. - if (initValue.isa()) { - Type initType = initValue.getType(); - Type tensorType = getTensorTypeFromMemRefType(memrefType); - if (initType != tensorType) - return op.emitOpError("initial value expected to be of type ") - << tensorType << ", but was of type " << initType; - } - } - - // TODO: verify visibility for declarations. - return success(); -} - -//===----------------------------------------------------------------------===// -// GetGlobalMemrefOp -//===----------------------------------------------------------------------===// - -LogicalResult -GetGlobalMemrefOp::verifySymbolUses(SymbolTableCollection &symbolTable) { - // Verify that the result type is same as the type of the referenced - // global_memref op. - auto global = - symbolTable.lookupNearestSymbolFrom(*this, nameAttr()); - if (!global) - return emitOpError("'") - << name() << "' does not reference a valid global memref"; - - Type resultType = result().getType(); - if (global.type() != resultType) - return emitOpError("result type ") - << resultType << " does not match type " << global.type() - << " of the global memref @" << name(); - return success(); -} - //===----------------------------------------------------------------------===// // IndexCastOp //===----------------------------------------------------------------------===// @@ -2034,89 +1766,6 @@ results.insert(context); } -//===----------------------------------------------------------------------===// -// MemRefCastOp -//===----------------------------------------------------------------------===// - -Value MemRefCastOp::getViewSource() { return source(); } - -bool MemRefCastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) { - if (inputs.size() != 1 || outputs.size() != 1) - return false; - Type a = inputs.front(), b = outputs.front(); - auto aT = a.dyn_cast(); - auto bT = b.dyn_cast(); - - auto uaT = a.dyn_cast(); - auto ubT = b.dyn_cast(); - - if (aT && bT) { - if (aT.getElementType() != bT.getElementType()) - return false; - if (aT.getAffineMaps() != bT.getAffineMaps()) { - int64_t aOffset, bOffset; - SmallVector aStrides, bStrides; - if (failed(getStridesAndOffset(aT, aStrides, aOffset)) || - failed(getStridesAndOffset(bT, bStrides, bOffset)) || - aStrides.size() != bStrides.size()) - return false; - - // Strides along a dimension/offset are compatible if the value in the - // source memref is static and the value in the target memref is the - // same. They are also compatible if either one is dynamic (see - // description of MemRefCastOp for details). - auto checkCompatible = [](int64_t a, int64_t b) { - return (a == MemRefType::getDynamicStrideOrOffset() || - b == MemRefType::getDynamicStrideOrOffset() || a == b); - }; - if (!checkCompatible(aOffset, bOffset)) - return false; - for (auto aStride : enumerate(aStrides)) - if (!checkCompatible(aStride.value(), bStrides[aStride.index()])) - return false; - } - if (aT.getMemorySpace() != bT.getMemorySpace()) - return false; - - // They must have the same rank, and any specified dimensions must match. - if (aT.getRank() != bT.getRank()) - return false; - - for (unsigned i = 0, e = aT.getRank(); i != e; ++i) { - int64_t aDim = aT.getDimSize(i), bDim = bT.getDimSize(i); - if (aDim != -1 && bDim != -1 && aDim != bDim) - return false; - } - return true; - } else { - if (!aT && !uaT) - return false; - if (!bT && !ubT) - return false; - // Unranked to unranked casting is unsupported - if (uaT && ubT) - return false; - - auto aEltType = (aT) ? aT.getElementType() : uaT.getElementType(); - auto bEltType = (bT) ? bT.getElementType() : ubT.getElementType(); - if (aEltType != bEltType) - return false; - - auto aMemSpace = (aT) ? aT.getMemorySpace() : uaT.getMemorySpace(); - auto bMemSpace = (bT) ? bT.getMemorySpace() : ubT.getMemorySpace(); - if (aMemSpace != bMemSpace) - return false; - - return true; - } - - return false; -} - -OpFoldResult MemRefCastOp::fold(ArrayRef operands) { - return succeeded(foldMemRefCast(*this)) ? getResult() : Value(); -} - //===----------------------------------------------------------------------===// // MemRefReinterpretCastOp //===----------------------------------------------------------------------===// @@ -2305,76 +1954,6 @@ [](APInt a, APInt b) { return a | b; }); } -//===----------------------------------------------------------------------===// -// PrefetchOp -//===----------------------------------------------------------------------===// - -static void print(OpAsmPrinter &p, PrefetchOp op) { - p << PrefetchOp::getOperationName() << " " << op.memref() << '['; - p.printOperands(op.indices()); - p << ']' << ", " << (op.isWrite() ? "write" : "read"); - p << ", locality<" << op.localityHint(); - p << ">, " << (op.isDataCache() ? "data" : "instr"); - p.printOptionalAttrDict( - op.getAttrs(), - /*elidedAttrs=*/{"localityHint", "isWrite", "isDataCache"}); - p << " : " << op.getMemRefType(); -} - -static ParseResult parsePrefetchOp(OpAsmParser &parser, - OperationState &result) { - OpAsmParser::OperandType memrefInfo; - SmallVector indexInfo; - IntegerAttr localityHint; - MemRefType type; - StringRef readOrWrite, cacheType; - - auto indexTy = parser.getBuilder().getIndexType(); - auto i32Type = parser.getBuilder().getIntegerType(32); - if (parser.parseOperand(memrefInfo) || - parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) || - parser.parseComma() || parser.parseKeyword(&readOrWrite) || - parser.parseComma() || parser.parseKeyword("locality") || - parser.parseLess() || - parser.parseAttribute(localityHint, i32Type, "localityHint", - result.attributes) || - parser.parseGreater() || parser.parseComma() || - parser.parseKeyword(&cacheType) || parser.parseColonType(type) || - parser.resolveOperand(memrefInfo, type, result.operands) || - parser.resolveOperands(indexInfo, indexTy, result.operands)) - return failure(); - - if (!readOrWrite.equals("read") && !readOrWrite.equals("write")) - return parser.emitError(parser.getNameLoc(), - "rw specifier has to be 'read' or 'write'"); - result.addAttribute( - PrefetchOp::getIsWriteAttrName(), - parser.getBuilder().getBoolAttr(readOrWrite.equals("write"))); - - if (!cacheType.equals("data") && !cacheType.equals("instr")) - return parser.emitError(parser.getNameLoc(), - "cache type has to be 'data' or 'instr'"); - - result.addAttribute( - PrefetchOp::getIsDataCacheAttrName(), - parser.getBuilder().getBoolAttr(cacheType.equals("data"))); - - return success(); -} - -static LogicalResult verify(PrefetchOp op) { - if (op.getNumOperands() != 1 + op.getMemRefType().getRank()) - return op.emitOpError("too few indices"); - - return success(); -} - -LogicalResult PrefetchOp::fold(ArrayRef cstOperands, - SmallVectorImpl &results) { - // prefetch(memrefcast) -> prefetch - return foldMemRefCast(*this); -} - //===----------------------------------------------------------------------===// // RankOp //===----------------------------------------------------------------------===// @@ -2713,23 +2292,6 @@ return SplatElementsAttr::get(shapedType, {constOperand}); } -//===----------------------------------------------------------------------===// -// StoreOp -//===----------------------------------------------------------------------===// - -static LogicalResult verify(StoreOp op) { - if (op.getNumOperands() != 2 + op.getMemRefType().getRank()) - return op.emitOpError("store index operand count not equal to memref rank"); - - return success(); -} - -LogicalResult StoreOp::fold(ArrayRef cstOperands, - SmallVectorImpl &results) { - /// store(memrefcast) -> store - return foldMemRefCast(*this); -} - //===----------------------------------------------------------------------===// // SubFOp //===----------------------------------------------------------------------===// @@ -3217,7 +2779,7 @@ static void replaceWithNewOp(PatternRewriter &rewriter, SubViewOp op, SubViewOp newOp) { - rewriter.replaceOpWithNewOp(op, newOp, op.getType()); + rewriter.replaceOpWithNewOp(op, newOp, op.getType()); } static void replaceWithNewOp(PatternRewriter &rewriter, SubTensorOp op, @@ -3261,107 +2823,21 @@ } // end anonymous namespace -/// Determines whether MemRefCastOp casts to a more dynamic version of the -/// source memref. This is useful to to fold a memref_cast into a consuming op -/// and implement canonicalization patterns for ops in different dialects that -/// may consume the results of memref_cast operations. Such foldable memref_cast -/// operations are typically inserted as `view` and `subview` ops are -/// canonicalized, to preserve the type compatibility of their uses. -/// -/// Returns true when all conditions are met: -/// 1. source and result are ranked memrefs with strided semantics and same -/// element type and rank. -/// 2. each of the source's size, offset or stride has more static information -/// than the corresponding result's size, offset or stride. -/// -/// Example 1: -/// ```mlir -/// %1 = memref_cast %0 : memref<8x16xf32> to memref -/// %2 = consumer %1 ... : memref ... -/// ``` -/// -/// may fold into: -/// -/// ```mlir -/// %2 = consumer %0 ... : memref<8x16xf32> ... -/// ``` -/// -/// Example 2: -/// ``` -/// %1 = memref_cast %0 : memref(16 * i + j)>> -/// to memref -/// consumer %1 : memref ... -/// ``` -/// -/// may fold into: -/// -/// ``` -/// consumer %0 ... : memref(16 * i + j)>> -/// ``` -bool mlir::canFoldIntoConsumerOp(MemRefCastOp castOp) { - MemRefType sourceType = castOp.source().getType().dyn_cast(); - MemRefType resultType = castOp.getType().dyn_cast(); - - // Requires ranked MemRefType. - if (!sourceType || !resultType) - return false; - - // Requires same elemental type. - if (sourceType.getElementType() != resultType.getElementType()) - return false; - - // Requires same rank. - if (sourceType.getRank() != resultType.getRank()) - return false; - - // Only fold casts between strided memref forms. - int64_t sourceOffset, resultOffset; - SmallVector sourceStrides, resultStrides; - if (failed(getStridesAndOffset(sourceType, sourceStrides, sourceOffset)) || - failed(getStridesAndOffset(resultType, resultStrides, resultOffset))) - return false; - - // If cast is towards more static sizes along any dimension, don't fold. - for (auto it : llvm::zip(sourceType.getShape(), resultType.getShape())) { - auto ss = std::get<0>(it), st = std::get<1>(it); - if (ss != st) - if (MemRefType::isDynamic(ss) && !MemRefType::isDynamic(st)) - return false; - } - - // If cast is towards more static offset along any dimension, don't fold. - if (sourceOffset != resultOffset) - if (MemRefType::isDynamicStrideOrOffset(sourceOffset) && - !MemRefType::isDynamicStrideOrOffset(resultOffset)) - return false; - - // If cast is towards more static strides along any dimension, don't fold. - for (auto it : llvm::zip(sourceStrides, resultStrides)) { - auto ss = std::get<0>(it), st = std::get<1>(it); - if (ss != st) - if (MemRefType::isDynamicStrideOrOffset(ss) && - !MemRefType::isDynamicStrideOrOffset(st)) - return false; - } - - return true; -} - namespace { /// Pattern to rewrite a subview op with MemRefCast arguments. -/// This essentially pushes memref_cast past its consuming subview when +/// This essentially pushes memref.cast past its consuming subview when /// `canFoldIntoConsumerOp` is true. /// /// Example: /// ``` -/// %0 = memref_cast %V : memref<16x16xf32> to memref +/// %0 = memref.cast %V : memref<16x16xf32> to memref /// %1 = subview %0[0, 0][3, 4][1, 1] : /// memref to memref<3x4xf32, offset:?, strides:[?, 1]> /// ``` /// is rewritten into: /// ``` /// %0 = subview %V: memref<16x16xf32> to memref<3x4xf32, #[[map0]]> -/// %1 = memref_cast %0: memref<3x4xf32, offset:0, strides:[16, 1]> to +/// %1 = memref.cast %0: memref<3x4xf32, offset:0, strides:[16, 1]> to /// memref<3x4xf32, offset:?, strides:[?, 1]> /// ``` class SubViewOpMemRefCastFolder final : public OpRewritePattern { @@ -3376,11 +2852,11 @@ })) return failure(); - auto castOp = subViewOp.source().getDefiningOp(); + auto castOp = subViewOp.source().getDefiningOp(); if (!castOp) return failure(); - if (!canFoldIntoConsumerOp(castOp)) + if (!memref::CastOp::canFoldIntoConsumerOp(castOp)) return failure(); /// Deduce the resultType of the SubViewOp using `inferSubViewResultType` on @@ -3413,8 +2889,8 @@ subViewOp.getLoc(), resultType, castOp.source(), subViewOp.offsets(), subViewOp.sizes(), subViewOp.strides(), subViewOp.static_offsets(), subViewOp.static_sizes(), subViewOp.static_strides()); - rewriter.replaceOpWithNewOp(subViewOp, subViewOp.getType(), - newSubView); + rewriter.replaceOpWithNewOp(subViewOp, subViewOp.getType(), + newSubView); return success(); } }; @@ -3637,8 +3113,8 @@ srcTensorType.getElementType()); Value memref = rewriter.create( tensorToMemRef.getLoc(), memrefType, tensorCastOperand.getOperand()); - rewriter.replaceOpWithNewOp(tensorToMemRef, - tensorToMemRef.getType(), memref); + rewriter.replaceOpWithNewOp( + tensorToMemRef, tensorToMemRef.getType(), memref); return success(); } }; @@ -3649,96 +3125,6 @@ results.insert(context); } -//===----------------------------------------------------------------------===// -// TransposeOp -//===----------------------------------------------------------------------===// - -/// Build a strided memref type by applying `permutationMap` tp `memRefType`. -static MemRefType inferTransposeResultType(MemRefType memRefType, - AffineMap permutationMap) { - auto rank = memRefType.getRank(); - auto originalSizes = memRefType.getShape(); - // Compute permuted sizes. - SmallVector sizes(rank, 0); - for (auto en : llvm::enumerate(permutationMap.getResults())) - sizes[en.index()] = - originalSizes[en.value().cast().getPosition()]; - - // Compute permuted strides. - int64_t offset; - SmallVector strides; - auto res = getStridesAndOffset(memRefType, strides, offset); - assert(succeeded(res) && strides.size() == static_cast(rank)); - (void)res; - auto map = - makeStridedLinearLayoutMap(strides, offset, memRefType.getContext()); - map = permutationMap ? map.compose(permutationMap) : map; - return MemRefType::Builder(memRefType).setShape(sizes).setAffineMaps(map); -} - -void TransposeOp::build(OpBuilder &b, OperationState &result, Value in, - AffineMapAttr permutation, - ArrayRef attrs) { - auto permutationMap = permutation.getValue(); - assert(permutationMap); - - auto memRefType = in.getType().cast(); - // Compute result type. - MemRefType resultType = inferTransposeResultType(memRefType, permutationMap); - - build(b, result, resultType, in, attrs); - result.addAttribute(TransposeOp::getPermutationAttrName(), permutation); -} - -// transpose $in $permutation attr-dict : type($in) `to` type(results) -static void print(OpAsmPrinter &p, TransposeOp op) { - p << "transpose " << op.in() << " " << op.permutation(); - p.printOptionalAttrDict(op.getAttrs(), - {TransposeOp::getPermutationAttrName()}); - p << " : " << op.in().getType() << " to " << op.getType(); -} - -static ParseResult parseTransposeOp(OpAsmParser &parser, - OperationState &result) { - OpAsmParser::OperandType in; - AffineMap permutation; - MemRefType srcType, dstType; - if (parser.parseOperand(in) || parser.parseAffineMap(permutation) || - parser.parseOptionalAttrDict(result.attributes) || - parser.parseColonType(srcType) || - parser.resolveOperand(in, srcType, result.operands) || - parser.parseKeywordType("to", dstType) || - parser.addTypeToList(dstType, result.types)) - return failure(); - - result.addAttribute(TransposeOp::getPermutationAttrName(), - AffineMapAttr::get(permutation)); - return success(); -} - -static LogicalResult verify(TransposeOp op) { - if (!op.permutation().isPermutation()) - return op.emitOpError("expected a permutation map"); - if (op.permutation().getNumDims() != op.getShapedType().getRank()) - return op.emitOpError( - "expected a permutation map of same rank as the input"); - - auto srcType = op.in().getType().cast(); - auto dstType = op.getType().cast(); - auto transposedType = inferTransposeResultType(srcType, op.permutation()); - if (dstType != transposedType) - return op.emitOpError("output type ") - << dstType << " does not match transposed input type " << srcType - << ", " << transposedType; - return success(); -} - -OpFoldResult TransposeOp::fold(ArrayRef) { - if (succeeded(foldMemRefCast(*this))) - return getResult(); - return {}; -} - //===----------------------------------------------------------------------===// // TruncateIOp //===----------------------------------------------------------------------===// @@ -3815,172 +3201,6 @@ return IntegerAttr::get(lhs.getType(), lhs.getValue().urem(rhsValue)); } -//===----------------------------------------------------------------------===// -// ViewOp -//===----------------------------------------------------------------------===// - -static ParseResult parseViewOp(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType srcInfo; - SmallVector offsetInfo; - SmallVector sizesInfo; - auto indexType = parser.getBuilder().getIndexType(); - Type srcType, dstType; - llvm::SMLoc offsetLoc; - if (parser.parseOperand(srcInfo) || parser.getCurrentLocation(&offsetLoc) || - parser.parseOperandList(offsetInfo, OpAsmParser::Delimiter::Square)) - return failure(); - - if (offsetInfo.size() != 1) - return parser.emitError(offsetLoc) << "expects 1 offset operand"; - - return failure( - parser.parseOperandList(sizesInfo, OpAsmParser::Delimiter::Square) || - parser.parseOptionalAttrDict(result.attributes) || - parser.parseColonType(srcType) || - parser.resolveOperand(srcInfo, srcType, result.operands) || - parser.resolveOperands(offsetInfo, indexType, result.operands) || - parser.resolveOperands(sizesInfo, indexType, result.operands) || - parser.parseKeywordType("to", dstType) || - parser.addTypeToList(dstType, result.types)); -} - -static void print(OpAsmPrinter &p, ViewOp op) { - p << op.getOperationName() << ' ' << op.getOperand(0) << '['; - p.printOperand(op.byte_shift()); - p << "][" << op.sizes() << ']'; - p.printOptionalAttrDict(op.getAttrs()); - p << " : " << op.getOperand(0).getType() << " to " << op.getType(); -} - -static LogicalResult verify(ViewOp op) { - auto baseType = op.getOperand(0).getType().cast(); - auto viewType = op.getType(); - - // The base memref should have identity layout map (or none). - if (baseType.getAffineMaps().size() > 1 || - (baseType.getAffineMaps().size() == 1 && - !baseType.getAffineMaps()[0].isIdentity())) - return op.emitError("unsupported map for base memref type ") << baseType; - - // The result memref should have identity layout map (or none). - if (viewType.getAffineMaps().size() > 1 || - (viewType.getAffineMaps().size() == 1 && - !viewType.getAffineMaps()[0].isIdentity())) - return op.emitError("unsupported map for result memref type ") << viewType; - - // The base memref and the view memref should be in the same memory space. - if (baseType.getMemorySpace() != viewType.getMemorySpace()) - return op.emitError("different memory spaces specified for base memref " - "type ") - << baseType << " and view memref type " << viewType; - - // Verify that we have the correct number of sizes for the result type. - unsigned numDynamicDims = viewType.getNumDynamicDims(); - if (op.sizes().size() != numDynamicDims) - return op.emitError("incorrect number of size operands for type ") - << viewType; - - return success(); -} - -Value ViewOp::getViewSource() { return source(); } - -namespace { - -struct ViewOpShapeFolder : public OpRewritePattern { - using OpRewritePattern::OpRewritePattern; - - LogicalResult matchAndRewrite(ViewOp viewOp, - PatternRewriter &rewriter) const override { - // Return if none of the operands are constants. - if (llvm::none_of(viewOp.getOperands(), [](Value operand) { - return matchPattern(operand, m_ConstantIndex()); - })) - return failure(); - - // Get result memref type. - auto memrefType = viewOp.getType(); - - // Get offset from old memref view type 'memRefType'. - int64_t oldOffset; - SmallVector oldStrides; - if (failed(getStridesAndOffset(memrefType, oldStrides, oldOffset))) - return failure(); - assert(oldOffset == 0 && "Expected 0 offset"); - - SmallVector newOperands; - - // Offset cannot be folded into result type. - - // Fold any dynamic dim operands which are produced by a constant. - SmallVector newShapeConstants; - newShapeConstants.reserve(memrefType.getRank()); - - unsigned dynamicDimPos = 0; - unsigned rank = memrefType.getRank(); - for (unsigned dim = 0, e = rank; dim < e; ++dim) { - int64_t dimSize = memrefType.getDimSize(dim); - // If this is already static dimension, keep it. - if (!ShapedType::isDynamic(dimSize)) { - newShapeConstants.push_back(dimSize); - continue; - } - auto *defOp = viewOp.sizes()[dynamicDimPos].getDefiningOp(); - if (auto constantIndexOp = dyn_cast_or_null(defOp)) { - // Dynamic shape dimension will be folded. - newShapeConstants.push_back(constantIndexOp.getValue()); - } else { - // Dynamic shape dimension not folded; copy operand from old memref. - newShapeConstants.push_back(dimSize); - newOperands.push_back(viewOp.sizes()[dynamicDimPos]); - } - dynamicDimPos++; - } - - // Create new memref type with constant folded dims. - MemRefType newMemRefType = - MemRefType::Builder(memrefType).setShape(newShapeConstants); - // Nothing new, don't fold. - if (newMemRefType == memrefType) - return failure(); - - // Create new ViewOp. - auto newViewOp = rewriter.create(viewOp.getLoc(), newMemRefType, - viewOp.getOperand(0), - viewOp.byte_shift(), newOperands); - // Insert a cast so we have the same type as the old memref type. - rewriter.replaceOpWithNewOp(viewOp, newViewOp, - viewOp.getType()); - return success(); - } -}; - -struct ViewOpMemrefCastFolder : public OpRewritePattern { - using OpRewritePattern::OpRewritePattern; - - LogicalResult matchAndRewrite(ViewOp viewOp, - PatternRewriter &rewriter) const override { - Value memrefOperand = viewOp.getOperand(0); - MemRefCastOp memrefCastOp = memrefOperand.getDefiningOp(); - if (!memrefCastOp) - return failure(); - Value allocOperand = memrefCastOp.getOperand(); - AllocOp allocOp = allocOperand.getDefiningOp(); - if (!allocOp) - return failure(); - rewriter.replaceOpWithNewOp(viewOp, viewOp.getType(), allocOperand, - viewOp.byte_shift(), viewOp.sizes()); - return success(); - } -}; - -} // end anonymous namespace - -void ViewOp::getCanonicalizationPatterns(OwningRewritePatternList &results, - MLIRContext *context) { - results.insert(context); -} - //===----------------------------------------------------------------------===// // XOrOp //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp b/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/StandardOps/Transforms/Passes.h" #include "mlir/IR/BlockAndValueMapping.h" @@ -26,13 +27,13 @@ class GlobalCreator { public: explicit GlobalCreator(ModuleOp module); - GlobalMemrefOp getGlobalFor(Attribute attr) { + memref::GlobalOp getGlobalFor(Attribute attr) { assert(globals.find(attr) != globals.end() && "unknown constant attr"); return globals[attr]; } private: - DenseMap globals; + DenseMap globals; }; GlobalCreator::GlobalCreator(ModuleOp module) { @@ -58,7 +59,7 @@ interleave(type.getShape(), os, "x"); os << "x" << type.getElementType(); - auto global = globalBuilder.create( + auto global = globalBuilder.create( op.getLoc(), (Twine("__constant_") + os.str()).str(), /*sym_visibility=*/globalBuilder.getStringAttr("private"), /*type=*/ @@ -89,8 +90,8 @@ return failure(); auto globalMemref = globals.getGlobalFor(op.value()); - rewriter.replaceOpWithNewOp(op, globalMemref.type(), - globalMemref.getName()); + rewriter.replaceOpWithNewOp(op, globalMemref.type(), + globalMemref.getName()); return success(); } GlobalCreator &globals; diff --git a/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp @@ -12,6 +12,7 @@ #include "mlir/Transforms/Bufferize.h" #include "PassDetail.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" @@ -28,7 +29,7 @@ matchAndRewrite(tensor::CastOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { auto resultType = getTypeConverter()->convertType(op.getType()); - rewriter.replaceOpWithNewOp(op, resultType, operands[0]); + rewriter.replaceOpWithNewOp(op, resultType, operands[0]); return success(); } }; @@ -60,11 +61,12 @@ int numberOfElements = op.elements().size(); auto resultType = MemRefType::get( {numberOfElements}, op.getType().cast().getElementType()); - Value result = rewriter.create(op.getLoc(), resultType); + Value result = rewriter.create(op.getLoc(), resultType); for (auto element : llvm::enumerate(op.elements())) { Value index = rewriter.create(op.getLoc(), element.index()); - rewriter.create(op.getLoc(), element.value(), result, index); + rewriter.create(op.getLoc(), element.value(), result, + index); } rewriter.replaceOp(op, {result}); return success(); @@ -86,8 +88,8 @@ RankedTensorType tensorType = op.getType().cast(); MemRefType memrefType = MemRefType::get(tensorType.getShape(), tensorType.getElementType()); - Value result = - rewriter.create(loc, memrefType, transformed.dynamicExtents()); + Value result = rewriter.create( + loc, memrefType, transformed.dynamicExtents()); // Collect loop bounds. int64_t rank = tensorType.getRank(); @@ -125,9 +127,9 @@ // about creating that. Operation *elementYield = parallelBody->getTerminator()->getPrevNode(); rewriter.setInsertionPointAfter(elementYield); - rewriter.replaceOpWithNewOp(elementYield, - elementYield->getOperands()[0], result, - parallelBody->getArguments()); + rewriter.replaceOpWithNewOp( + elementYield, elementYield->getOperands()[0], result, + parallelBody->getArguments()); rewriter.replaceOp(op, {result}); return success(); @@ -155,6 +157,7 @@ populateTensorBufferizePatterns(context, typeConverter, patterns); target.addIllegalOp(); + target.addLegalDialect(); target.addLegalDialect(); target.addLegalDialect(); diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Vector/VectorOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Utils/StructuredOpsUtils.h" #include "mlir/Dialect/Vector/VectorUtils.h" @@ -2395,12 +2396,12 @@ /// ``` /// someop(memrefcast) -> someop /// ``` -/// It folds the source of the memref_cast into the root operation directly. +/// It folds the source of the memref.cast into the root operation directly. static LogicalResult foldMemRefCast(Operation *op) { bool folded = false; for (OpOperand &operand : op->getOpOperands()) { - auto castOp = operand.get().getDefiningOp(); - if (castOp && canFoldIntoConsumerOp(castOp)) { + auto castOp = operand.get().getDefiningOp(); + if (castOp && memref::CastOp::canFoldIntoConsumerOp(castOp)) { operand.set(castOp.getOperand()); folded = true; } diff --git a/mlir/lib/Dialect/Vector/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/VectorTransforms.cpp --- a/mlir/lib/Dialect/Vector/VectorTransforms.cpp +++ b/mlir/lib/Dialect/Vector/VectorTransforms.cpp @@ -16,6 +16,7 @@ #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/EDSC/Intrinsics.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" @@ -2316,7 +2317,7 @@ /// b. using a dynamic shape and/or stride for the dimensions that don't /// agree. static MemRefType getCastCompatibleMemRefType(MemRefType aT, MemRefType bT) { - if (MemRefCastOp::areCastCompatible(aT, bT)) + if (memref::CastOp::areCastCompatible(aT, bT)) return aT; if (aT.getRank() != bT.getRank()) return MemRefType(); @@ -2387,13 +2388,13 @@ /// Produce IR resembling: /// ``` /// %1:3 = scf.if (%inBounds) { -/// memref_cast %A: memref to compatibleMemRefType +/// memref.cast %A: memref to compatibleMemRefType /// scf.yield %view, ... : compatibleMemRefType, index, index /// } else { /// %2 = linalg.fill(%alloc, %pad) /// %3 = subview %view [...][...][...] /// linalg.copy(%3, %alloc) -/// memref_cast %alloc: memref to compatibleMemRefType +/// memref.cast %alloc: memref to compatibleMemRefType /// scf.yield %4, ... : compatibleMemRefType, index, index /// } /// ``` @@ -2411,7 +2412,7 @@ [&]() -> scf::ValueVector { Value res = memref; if (compatibleMemRefType != xferOp.getShapedType()) - res = std_memref_cast(memref, compatibleMemRefType); + res = memref_cast(memref, compatibleMemRefType); scf::ValueVector viewAndIndices{res}; viewAndIndices.insert(viewAndIndices.end(), xferOp.indices().begin(), xferOp.indices().end()); @@ -2424,7 +2425,7 @@ Value memRefSubView = createScopedSubViewIntersection( cast(xferOp.getOperation()), alloc); linalg_copy(memRefSubView, alloc); - Value casted = std_memref_cast(alloc, compatibleMemRefType); + Value casted = memref_cast(alloc, compatibleMemRefType); scf::ValueVector viewAndIndices{casted}; viewAndIndices.insert(viewAndIndices.end(), xferOp.getTransferRank(), zero); @@ -2440,14 +2441,14 @@ /// Produce IR resembling: /// ``` /// %1:3 = scf.if (%inBounds) { -/// memref_cast %A: memref to compatibleMemRefType +/// memref.cast %A: memref to compatibleMemRefType /// scf.yield %view, ... : compatibleMemRefType, index, index /// } else { /// %2 = vector.transfer_read %view[...], %pad : memref, vector<...> /// %3 = vector.type_cast %extra_alloc : /// memref<...> to memref> /// store %2, %3[] : memref> -/// %4 = memref_cast %alloc: memref to compatibleMemRefType +/// %4 = memref.cast %alloc: memref to compatibleMemRefType /// scf.yield %4, ... : compatibleMemRefType, index, index /// } /// ``` @@ -2465,7 +2466,7 @@ [&]() -> scf::ValueVector { Value res = memref; if (compatibleMemRefType != xferOp.getShapedType()) - res = std_memref_cast(memref, compatibleMemRefType); + res = memref_cast(memref, compatibleMemRefType); scf::ValueVector viewAndIndices{res}; viewAndIndices.insert(viewAndIndices.end(), xferOp.indices().begin(), xferOp.indices().end()); @@ -2475,10 +2476,10 @@ Operation *newXfer = ScopedContext::getBuilderRef().clone(*xferOp.getOperation()); Value vector = cast(newXfer).vector(); - std_store(vector, vector_type_cast( - MemRefType::get({}, vector.getType()), alloc)); + memref_store(vector, vector_type_cast( + MemRefType::get({}, vector.getType()), alloc)); - Value casted = std_memref_cast(alloc, compatibleMemRefType); + Value casted = memref_cast(alloc, compatibleMemRefType); scf::ValueVector viewAndIndices{casted}; viewAndIndices.insert(viewAndIndices.end(), xferOp.getTransferRank(), zero); @@ -2505,11 +2506,11 @@ /// ``` /// %1:3 = scf.if (%inBounds) { /// // fastpath, direct cast -/// memref_cast %A: memref to compatibleMemRefType +/// memref.cast %A: memref to compatibleMemRefType /// scf.yield %view : compatibleMemRefType, index, index /// } else { /// // slowpath, masked vector.transfer or linalg.copy. -/// memref_cast %alloc: memref to compatibleMemRefType +/// memref.cast %alloc: memref to compatibleMemRefType /// scf.yield %4 : compatibleMemRefType, index, index // } /// %0 = vector.transfer_read %1#0[%1#1, %1#2] {masked = [false ... false]} @@ -2564,8 +2565,8 @@ b.setInsertionPointToStart(&funcOp.getRegion().front()); auto shape = xferOp.getVectorType().getShape(); Type elementType = xferOp.getVectorType().getElementType(); - alloc = std_alloca(MemRefType::get(shape, elementType), ValueRange{}, - b.getI64IntegerAttr(32)); + alloc = memref_alloca(MemRefType::get(shape, elementType), ValueRange{}, + b.getI64IntegerAttr(32)); } MemRefType compatibleMemRefType = diff --git a/mlir/lib/Transforms/BufferDeallocation.cpp b/mlir/lib/Transforms/BufferDeallocation.cpp --- a/mlir/lib/Transforms/BufferDeallocation.cpp +++ b/mlir/lib/Transforms/BufferDeallocation.cpp @@ -53,6 +53,7 @@ #include "PassDetail.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/StandardOps/Utils/Utils.h" #include "mlir/IR/Operation.h" @@ -425,8 +426,8 @@ // TODO: provide a generic interface to create dialect-specific // Alloc and CopyOp nodes. - auto alloc = builder.create(terminator->getLoc(), memRefType, - dynamicOperands); + auto alloc = builder.create(terminator->getLoc(), + memRefType, dynamicOperands); // Create a new copy operation that copies to contents of the old // allocation to the new one. @@ -499,7 +500,7 @@ continue; // If there is no dealloc node, insert one in the right place. OpBuilder builder(nextOp); - builder.create(alloc.getLoc(), alloc); + builder.create(alloc.getLoc(), alloc); } } } diff --git a/mlir/lib/Transforms/BufferOptimizations.cpp b/mlir/lib/Transforms/BufferOptimizations.cpp --- a/mlir/lib/Transforms/BufferOptimizations.cpp +++ b/mlir/lib/Transforms/BufferOptimizations.cpp @@ -12,6 +12,7 @@ // convert heap-based allocations to stack-based allocations, if possible. #include "PassDetail.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/IR/Operation.h" #include "mlir/Interfaces/LoopLikeInterface.h" #include "mlir/Pass/Pass.h" @@ -33,7 +34,7 @@ unsigned bitwidthOfIndexType, unsigned maxRankOfAllocatedMemRef) { auto type = alloc.getType().dyn_cast(); - if (!type || !alloc.getDefiningOp()) + if (!type || !alloc.getDefiningOp()) return false; if (!type.hasStaticShape()) { // Check if the dynamic shape dimension of the alloc is produced by RankOp. @@ -317,7 +318,7 @@ // `AutomaticAllocationScope` determined during the initialization phase. OpBuilder builder(startOperation); Operation *allocOp = alloc.getDefiningOp(); - Operation *alloca = builder.create( + Operation *alloca = builder.create( alloc.getLoc(), alloc.getType().cast(), allocOp->getOperands()); diff --git a/mlir/lib/Transforms/BufferResultsToOutParams.cpp b/mlir/lib/Transforms/BufferResultsToOutParams.cpp --- a/mlir/lib/Transforms/BufferResultsToOutParams.cpp +++ b/mlir/lib/Transforms/BufferResultsToOutParams.cpp @@ -8,6 +8,7 @@ #include "PassDetail.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Operation.h" #include "mlir/Pass/Pass.h" @@ -99,7 +100,7 @@ didFail = true; return; } - Value outParam = builder.create( + Value outParam = builder.create( op.getLoc(), memref.getType().cast()); memref.replaceAllUsesWith(outParam); outParams.push_back(outParam); diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -16,6 +16,7 @@ #include "mlir/Analysis/LoopAnalysis.h" #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/Builders.h" @@ -925,7 +926,7 @@ // consumer loop nests to reduce their live range. Currently they are added // at the beginning of the function, because loop nests can be reordered // during the fusion pass. - Value newMemRef = top.create(forOp.getLoc(), newMemRefType); + Value newMemRef = top.create(forOp.getLoc(), newMemRefType); // Build an AffineMap to remap access functions based on lower bound offsets. SmallVector remapExprs; @@ -1895,7 +1896,7 @@ continue; // Use list expected to match the dep graph info. auto *op = memref.getDefiningOp(); - if (isa_and_nonnull(op)) + if (isa_and_nonnull(op)) op->erase(); } } diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -17,6 +17,7 @@ #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/Dominance.h" #include "mlir/Transforms/Passes.h" @@ -168,7 +169,7 @@ // Perform the actual store to load forwarding. Value storeVal = - cast(lastWriteStoreOp).getValueToStore(); + cast(lastWriteStoreOp).getValueToStore(); loadOp.getValue().replaceAllUsesWith(storeVal); // Record the memref for a later sweep to optimize away. memrefsToErase.insert(loadOp.getMemRef()); @@ -203,12 +204,12 @@ for (auto memref : memrefsToErase) { // If the memref hasn't been alloc'ed in this function, skip. Operation *defOp = memref.getDefiningOp(); - if (!defOp || !isa(defOp)) + if (!defOp || !isa(defOp)) // TODO: if the memref was returned by a 'call' operation, we // could still erase it if the call had no side-effects. continue; if (llvm::any_of(memref.getUsers(), [&](Operation *ownerOp) { - return !isa(ownerOp); + return !isa(ownerOp); })) continue; diff --git a/mlir/lib/Transforms/NormalizeMemRefs.cpp b/mlir/lib/Transforms/NormalizeMemRefs.cpp --- a/mlir/lib/Transforms/NormalizeMemRefs.cpp +++ b/mlir/lib/Transforms/NormalizeMemRefs.cpp @@ -13,6 +13,7 @@ #include "PassDetail.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Transforms/Passes.h" #include "mlir/Transforms/Utils.h" #include "llvm/ADT/SmallSet.h" @@ -152,7 +153,7 @@ return true; if (funcOp - .walk([&](AllocOp allocOp) -> WalkResult { + .walk([&](memref::AllocOp allocOp) -> WalkResult { Value oldMemRef = allocOp.getResult(); if (!isMemRefNormalizable(oldMemRef.getUsers())) return WalkResult::interrupt(); @@ -326,9 +327,9 @@ // Turn memrefs' non-identity layouts maps into ones with identity. Collect // alloc ops first and then process since normalizeMemRef replaces/erases ops // during memref rewriting. - SmallVector allocOps; - funcOp.walk([&](AllocOp op) { allocOps.push_back(op); }); - for (AllocOp allocOp : allocOps) + SmallVector allocOps; + funcOp.walk([&](memref::AllocOp op) { allocOps.push_back(op); }); + for (memref::AllocOp allocOp : allocOps) (void)normalizeMemRef(allocOp); // We use this OpBuilder to create new memref layout later. diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -88,8 +88,8 @@ auto allocOperands = getDynOperands(forOp.getLoc(), oldMemRef, bOuter); // Create and place the alloc right before the 'affine.for' operation. - Value newMemRef = - bOuter.create(forOp.getLoc(), newMemRefType, allocOperands); + Value newMemRef = bOuter.create( + forOp.getLoc(), newMemRefType, allocOperands); // Create 'iv mod 2' value to index the leading dimension. auto d0 = bInner.getAffineDimExpr(0); @@ -115,7 +115,7 @@ } // Insert the dealloc op right after the for loop. bOuter.setInsertionPointAfter(forOp); - bOuter.create(forOp.getLoc(), newMemRef); + bOuter.create(forOp.getLoc(), newMemRef); return true; } @@ -201,7 +201,7 @@ bool escapingUses = false; for (auto *user : memref.getUsers()) { // We can double buffer regardless of dealloc's outside the loop. - if (isa(user)) + if (isa(user)) continue; if (!forOp.getBody()->findAncestorOpInBlock(*user)) { LLVM_DEBUG(llvm::dbgs() @@ -274,7 +274,8 @@ if (oldMemRef.use_empty()) { allocOp->erase(); } else if (oldMemRef.hasOneUse()) { - if (auto dealloc = dyn_cast(*oldMemRef.user_begin())) { + if (auto dealloc = + dyn_cast(*oldMemRef.user_begin())) { dealloc.erase(); allocOp->erase(); } @@ -296,7 +297,8 @@ if (oldTagMemRef.use_empty()) { tagAllocOp->erase(); } else if (oldTagMemRef.hasOneUse()) { - if (auto dealloc = dyn_cast(*oldTagMemRef.user_begin())) { + if (auto dealloc = + dyn_cast(*oldTagMemRef.user_begin())) { dealloc.erase(); tagAllocOp->erase(); } diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -18,6 +18,7 @@ #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" @@ -2470,7 +2471,8 @@ // Create the fast memory space buffer just before the 'affine.for' // operation. - fastMemRef = prologue.create(loc, fastMemRefType).getResult(); + fastMemRef = + prologue.create(loc, fastMemRefType).getResult(); // Record it. fastBufferMap[memref] = fastMemRef; // fastMemRefType is a constant shaped memref. @@ -2540,7 +2542,7 @@ // Create a tag (single element 1-d memref) for the DMA. auto tagMemRefType = MemRefType::get({1}, top.getIntegerType(32), {}, copyOptions.tagMemorySpace); - auto tagMemRef = prologue.create(loc, tagMemRefType); + auto tagMemRef = prologue.create(loc, tagMemRefType); SmallVector tagIndices({zeroIndex}); auto tagAffineMap = b.getMultiDimIdentityMap(tagIndices.size()); @@ -2568,7 +2570,7 @@ numElementsSSA); // Generate dealloc for the tag. - auto tagDeallocOp = epilogue.create(loc, tagMemRef); + auto tagDeallocOp = epilogue.create(loc, tagMemRef); if (*nEnd == end && isCopyOutAtEndOfBlock) // Since new ops are being appended (for outgoing DMAs), adjust the end to // mark end of range of the original. @@ -2577,7 +2579,7 @@ // Generate dealloc for the buffer. if (!existingBuf) { - auto bufDeallocOp = epilogue.create(loc, fastMemRef); + auto bufDeallocOp = epilogue.create(loc, fastMemRef); // When generating pointwise copies, `nEnd' has to be set to deallocOp on // the fast buffer (since it marks the new end insertion point). if (!copyOptions.generateDma && *nEnd == end && isCopyOutAtEndOfBlock) diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -253,7 +253,7 @@ // Skip dealloc's - no replacement is necessary, and a memref replacement // at other uses doesn't hurt these dealloc's. - if (isa(op) && !replaceInDeallocOp) + if (isa(op) && !replaceInDeallocOp) continue; // Check if the memref was used in a non-dereferencing context. It is fine @@ -380,7 +380,7 @@ } // TODO: Currently works for static memrefs with a single layout map. -LogicalResult mlir::normalizeMemRef(AllocOp allocOp) { +LogicalResult mlir::normalizeMemRef(memref::AllocOp allocOp) { MemRefType memrefType = allocOp.getType(); OpBuilder b(allocOp); @@ -396,8 +396,8 @@ Value oldMemRef = allocOp.getResult(); SmallVector symbolOperands(allocOp.symbolOperands()); - AllocOp newAlloc = b.create(allocOp.getLoc(), newMemRefType, - allocOp.alignmentAttr()); + memref::AllocOp newAlloc = b.create( + allocOp.getLoc(), newMemRefType, allocOp.alignmentAttr()); AffineMap layoutMap = memrefType.getAffineMaps().front(); // Replace all uses of the old memref. if (failed(replaceAllMemRefUsesWith(oldMemRef, /*newMemRef=*/newAlloc, @@ -414,8 +414,9 @@ } // Replace any uses of the original alloc op and erase it. All remaining uses // have to be dealloc's; RAMUW above would've failed otherwise. - assert(llvm::all_of(oldMemRef.getUsers(), - [](Operation *op) { return isa(op); })); + assert(llvm::all_of(oldMemRef.getUsers(), [](Operation *op) { + return isa(op); + })); oldMemRef.replaceAllUsesWith(newAlloc); allocOp.erase(); return success(); diff --git a/mlir/test/Analysis/test-alias-analysis.mlir b/mlir/test/Analysis/test-alias-analysis.mlir --- a/mlir/test/Analysis/test-alias-analysis.mlir +++ b/mlir/test/Analysis/test-alias-analysis.mlir @@ -23,10 +23,10 @@ // CHECK-DAG: alloc_2#0 <-> func.region0#0: MayAlias // CHECK-DAG: alloc_2#0 <-> func.region0#1: MayAlias func @simple(%arg: memref<2xf32>, %arg1: memref<2xf32>) attributes {test.ptr = "func"} { - %0 = alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> - %1 = alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> - %2 = alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> - %3 = alloc() {test.ptr = "alloc_2"} : memref<8x64xf32> + %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> + %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> + %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> + %3 = memref.alloc() {test.ptr = "alloc_2"} : memref<8x64xf32> return } @@ -50,9 +50,9 @@ // CHECK-DAG: func.region0.block1#0 <-> func.region0.block2#0: MustAlias func @control_flow(%arg: memref<2xf32>, %cond: i1) attributes {test.ptr = "func"} { - %0 = alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> - %1 = alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> - %2 = alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> + %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> + %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> + %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> cond_br %cond, ^bb1(%0 : memref<8x64xf32>), ^bb2(%0 : memref<8x64xf32>) @@ -83,9 +83,9 @@ // CHECK-DAG: func.region0.block1#0 <-> func.region0.block2#0: MayAlias func @control_flow_merge(%arg: memref<2xf32>, %cond: i1) attributes {test.ptr = "func"} { - %0 = alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> - %1 = alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> - %2 = alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> + %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> + %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> + %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> cond_br %cond, ^bb1(%0 : memref<8x64xf32>), ^bb2(%2 : memref<8x64xf32>) @@ -123,9 +123,9 @@ // CHECK-DAG: if_alloc#0 <-> func.region0#0: MayAlias // CHECK-DAG: if_alloc#0 <-> func.region0#1: MayAlias func @region_control_flow(%arg: memref<2xf32>, %cond: i1) attributes {test.ptr = "func"} { - %0 = alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> - %1 = alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> - %2 = alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> + %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> + %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> + %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> %3 = scf.if %cond -> (memref<8x64xf32>) { scf.yield %0 : memref<8x64xf32> @@ -181,9 +181,9 @@ // CHECK-DAG: for_alloca.region0#1 <-> func.region0#3: NoAlias func @region_loop_control_flow(%arg: memref<2xf32>, %loopI0 : index, %loopI1 : index, %loopI2 : index) attributes {test.ptr = "func"} { - %0 = alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> - %1 = alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> - %2 = alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> + %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32> + %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32> + %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> %result = scf.for %i0 = %loopI0 to %loopI1 step %loopI2 iter_args(%si = %0) -> (memref<8x64xf32>) { scf.yield %si : memref<8x64xf32> @@ -201,11 +201,11 @@ // CHECK-DAG: view#0 <-> func.region0#0: NoAlias // CHECK-DAG: view#0 <-> func.region0#1: NoAlias func @view_like(%arg: memref<2xf32>, %size: index) attributes {test.ptr = "func"} { - %1 = alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> + %1 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> %c0 = constant 0 : index - %2 = alloca (%size) {test.ptr = "alloca_1"} : memref - %3 = view %2[%c0][] {test.ptr = "view"} : memref to memref<8x64xf32> + %2 = memref.alloca (%size) {test.ptr = "alloca_1"} : memref + %3 = memref.view %2[%c0][] {test.ptr = "view"} : memref to memref<8x64xf32> return } @@ -225,7 +225,7 @@ // CHECK-DAG: constant_3#0 <-> func.region0#0: MayAlias func @constants(%arg: memref<2xf32>) attributes {test.ptr = "func"} { - %1 = alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> + %1 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32> %c0 = constant {test.ptr = "constant_1"} 0 : index %c0_2 = constant {test.ptr = "constant_2"} 0 : index diff --git a/mlir/test/Analysis/test-liveness.mlir b/mlir/test/Analysis/test-liveness.mlir --- a/mlir/test/Analysis/test-liveness.mlir +++ b/mlir/test/Analysis/test-liveness.mlir @@ -221,7 +221,7 @@ // CHECK-NEXT: LiveOut:{{ *$}} %2 = addi %0, %arg5 : i32 %3 = addi %2, %0 : i32 - store %3, %buffer[] : memref + memref.store %3, %buffer[] : memref } return %1 : i32 } @@ -265,7 +265,7 @@ %2 = addi %0, %arg5 : i32 scf.for %arg7 = %arg0 to %arg1 step %arg2 { %3 = addi %2, %0 : i32 - store %3, %buffer[] : memref + memref.store %3, %buffer[] : memref } } return %1 : i32 @@ -299,7 +299,7 @@ // CHECK-NEXT: LiveIn: arg5@0 arg6@0 val_7 // CHECK-NEXT: LiveOut:{{ *$}} %2 = addi %0, %arg5 : i32 - store %2, %buffer[] : memref + memref.store %2, %buffer[] : memref } br ^exit @@ -312,7 +312,7 @@ // CHECK-NEXT: LiveIn: arg6@0 val_7 val_8 // CHECK-NEXT: LiveOut:{{ *$}} %2 = addi %0, %1 : i32 - store %2, %buffer[] : memref + memref.store %2, %buffer[] : memref } return %1 : i32 } diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c --- a/mlir/test/CAPI/ir.c +++ b/mlir/test/CAPI/ir.c @@ -60,7 +60,7 @@ mlirBlockAppendOwnedOperation(loopBody, add); MlirOperationState storeState = mlirOperationStateGet( - mlirStringRefCreateFromCString("std.store"), location); + mlirStringRefCreateFromCString("memref.store"), location); MlirValue storeOperands[] = {mlirOperationGetResult(add, 0), funcArg0, iv}; mlirOperationStateAddOperands(&storeState, 3, storeOperands); MlirOperation store = mlirOperationCreate(&storeState); @@ -173,7 +173,7 @@ // CHECK: %[[LHS:.*]] = load %[[ARG0]][%[[I]]] : memref // CHECK: %[[RHS:.*]] = load %[[ARG1]][%[[I]]] : memref // CHECK: %[[SUM:.*]] = addf %[[LHS]], %[[RHS]] : f32 - // CHECK: store %[[SUM]], %[[ARG0]][%[[I]]] : memref + // CHECK: memref.store %[[SUM]], %[[ARG0]][%[[I]]] : memref // CHECK: } // CHECK: return // CHECK: } @@ -345,7 +345,7 @@ // CHECK: %[[LHS:.*]] = load %{{.*}}[%[[I]]] : memref // CHECK: %[[RHS:.*]] = load %{{.*}}[%[[I]]] : memref // CHECK: %[[SUM:.*]] = addf %[[LHS]], %[[RHS]] : f32 - // CHECK: store %[[SUM]], %{{.*}}[%[[I]]] : memref + // CHECK: memref.store %[[SUM]], %{{.*}}[%[[I]]] : memref // CHECK: } // CHECK: return // CHECK: First operation: {{.*}} = constant 0 : index diff --git a/mlir/test/Conversion/AffineToStandard/lower-affine-to-vector.mlir b/mlir/test/Conversion/AffineToStandard/lower-affine-to-vector.mlir --- a/mlir/test/Conversion/AffineToStandard/lower-affine-to-vector.mlir +++ b/mlir/test/Conversion/AffineToStandard/lower-affine-to-vector.mlir @@ -1,13 +1,12 @@ // RUN: mlir-opt -lower-affine --split-input-file %s | FileCheck %s - // CHECK-LABEL: func @affine_vector_load func @affine_vector_load(%arg0 : index) { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> affine.for %i0 = 0 to 16 { %1 = affine.vector_load %0[%i0 + symbol(%arg0) + 7] : memref<100xf32>, vector<8xf32> } -// CHECK: %[[buf:.*]] = alloc +// CHECK: %[[buf:.*]] = memref.alloc // CHECK: %[[a:.*]] = addi %{{.*}}, %{{.*}} : index // CHECK-NEXT: %[[c7:.*]] = constant 7 : index // CHECK-NEXT: %[[b:.*]] = addi %[[a]], %[[c7]] : index @@ -19,12 +18,12 @@ // CHECK-LABEL: func @affine_vector_store func @affine_vector_store(%arg0 : index) { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %1 = constant dense<11.0> : vector<4xf32> affine.for %i0 = 0 to 16 { affine.vector_store %1, %0[%i0 - symbol(%arg0) + 7] : memref<100xf32>, vector<4xf32> } -// CHECK: %[[buf:.*]] = alloc +// CHECK: %[[buf:.*]] = memref.alloc // CHECK: %[[val:.*]] = constant dense // CHECK: %[[c_1:.*]] = constant -1 : index // CHECK-NEXT: %[[a:.*]] = muli %arg0, %[[c_1]] : index @@ -39,11 +38,11 @@ // CHECK-LABEL: func @vector_load_2d func @vector_load_2d() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 16 step 2{ affine.for %i1 = 0 to 16 step 8 { %1 = affine.vector_load %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32> -// CHECK: %[[buf:.*]] = alloc +// CHECK: %[[buf:.*]] = memref.alloc // CHECK: scf.for %[[i0:.*]] = // CHECK: scf.for %[[i1:.*]] = // CHECK-NEXT: vector.load %[[buf]][%[[i0]], %[[i1]]] : memref<100x100xf32>, vector<2x8xf32> @@ -56,12 +55,12 @@ // CHECK-LABEL: func @vector_store_2d func @vector_store_2d() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> %1 = constant dense<11.0> : vector<2x8xf32> affine.for %i0 = 0 to 16 step 2{ affine.for %i1 = 0 to 16 step 8 { affine.vector_store %1, %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32> -// CHECK: %[[buf:.*]] = alloc +// CHECK: %[[buf:.*]] = memref.alloc // CHECK: %[[val:.*]] = constant dense // CHECK: scf.for %[[i0:.*]] = // CHECK: scf.for %[[i1:.*]] = diff --git a/mlir/test/Conversion/AffineToStandard/lower-affine.mlir b/mlir/test/Conversion/AffineToStandard/lower-affine.mlir --- a/mlir/test/Conversion/AffineToStandard/lower-affine.mlir +++ b/mlir/test/Conversion/AffineToStandard/lower-affine.mlir @@ -533,7 +533,7 @@ // CHECK-LABEL: func @affine_load func @affine_load(%arg0 : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { %1 = affine.load %0[%i0 + symbol(%arg0) + 7] : memref<10xf32> } @@ -546,7 +546,7 @@ // CHECK-LABEL: func @affine_store func @affine_store(%arg0 : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %1 = constant 11.0 : f32 affine.for %i0 = 0 to 10 { affine.store %1, %0[%i0 - symbol(%arg0) + 7] : memref<10xf32> @@ -571,22 +571,22 @@ // CHECK-LABEL: func @affine_prefetch func @affine_prefetch(%arg0 : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.prefetch %0[%i0 + symbol(%arg0) + 7], read, locality<3>, data : memref<10xf32> } // CHECK: %[[a:.*]] = addi %{{.*}}, %{{.*}} : index // CHECK-NEXT: %[[c7:.*]] = constant 7 : index // CHECK-NEXT: %[[b:.*]] = addi %[[a]], %[[c7]] : index -// CHECK-NEXT: prefetch %[[v0:.*]][%[[b]]], read, locality<3>, data : memref<10xf32> +// CHECK-NEXT: memref.prefetch %[[v0:.*]][%[[b]]], read, locality<3>, data : memref<10xf32> return } // CHECK-LABEL: func @affine_dma_start func @affine_dma_start(%arg0 : index) { - %0 = alloc() : memref<100xf32> - %1 = alloc() : memref<100xf32, 2> - %2 = alloc() : memref<1xi32> + %0 = memref.alloc() : memref<100xf32> + %1 = memref.alloc() : memref<100xf32, 2> + %2 = memref.alloc() : memref<1xi32> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { @@ -603,7 +603,7 @@ // CHECK-LABEL: func @affine_dma_wait func @affine_dma_wait(%arg0 : index) { - %2 = alloc() : memref<1xi32> + %2 = memref.alloc() : memref<1xi32> %c64 = constant 64 : index affine.for %i0 = 0 to 10 { affine.dma_wait %2[%i0 + %arg0 + 17], %c64 : memref<1xi32> @@ -702,7 +702,7 @@ ///////////////////////////////////////////////////////////////////// func @affine_parallel_simple(%arg0: memref<3x3xf32>, %arg1: memref<3x3xf32>) -> (memref<3x3xf32>) { - %O = alloc() : memref<3x3xf32> + %O = memref.alloc() : memref<3x3xf32> affine.parallel (%kx, %ky) = (0, 0) to (2, 2) { %1 = affine.load %arg0[%kx, %ky] : memref<3x3xf32> %2 = affine.load %arg1[%kx, %ky] : memref<3x3xf32> diff --git a/mlir/test/Conversion/AsyncToLLVM/convert-to-llvm.mlir b/mlir/test/Conversion/AsyncToLLVM/convert-to-llvm.mlir --- a/mlir/test/Conversion/AsyncToLLVM/convert-to-llvm.mlir +++ b/mlir/test/Conversion/AsyncToLLVM/convert-to-llvm.mlir @@ -20,7 +20,7 @@ // CHECK: %[[TOKEN:.*]] = call @async_execute_fn(%arg0, %arg1) %token = async.execute { %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<1xf32> + memref.store %arg0, %arg1[%c0] : memref<1xf32> async.yield } // CHECK: call @mlirAsyncRuntimeAwaitToken(%[[TOKEN]]) @@ -51,7 +51,7 @@ // Resume coroutine after suspension. // CHECK: ^[[RESUME]]: -// CHECK: store %arg0, %arg1[%c0] : memref<1xf32> +// CHECK: memref.store %arg0, %arg1[%c0] : memref<1xf32> // CHECK: call @mlirAsyncRuntimeEmplaceToken(%[[RET]]) // Delete coroutine. @@ -74,12 +74,12 @@ %token1 = async.execute { %c1 = constant 1: index - store %arg0, %arg2[%c0] : memref<1xf32> + memref.store %arg0, %arg2[%c0] : memref<1xf32> async.yield } async.await %token1 : !async.token - store %arg1, %arg2[%c0] : memref<1xf32> + memref.store %arg1, %arg2[%c0] : memref<1xf32> async.yield } // CHECK: call @mlirAsyncRuntimeAwaitToken(%[[TOKEN]]) @@ -95,7 +95,7 @@ // CHECK: %[[HDL_0:.*]] = llvm.intr.coro.begin // CHECK: call @mlirAsyncRuntimeExecute // CHECK: llvm.intr.coro.suspend -// CHECK: store %arg0, %arg1[%arg2] : memref<1xf32> +// CHECK: memref.store %arg0, %arg1[%arg2] : memref<1xf32> // CHECK: call @mlirAsyncRuntimeEmplaceToken(%[[RET_0]]) // Function outlined from the outer async.execute operation. @@ -115,7 +115,7 @@ // CHECK: llvm.intr.coro.suspend // Emplace result token after second resumption. -// CHECK: store %arg2, %arg1[%c0] : memref<1xf32> +// CHECK: memref.store %arg2, %arg1[%c0] : memref<1xf32> // CHECK: call @mlirAsyncRuntimeEmplaceToken(%[[RET_1]]) // ----- @@ -125,13 +125,13 @@ // CHECK: %0 = call @async_execute_fn(%arg0, %arg1) %token = async.execute { %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<1xf32> + memref.store %arg0, %arg1[%c0] : memref<1xf32> async.yield } // CHECK: %1 = call @async_execute_fn_0(%0, %arg0, %arg1) %token_0 = async.execute [%token] { %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<1xf32> + memref.store %arg0, %arg1[%c0] : memref<1xf32> async.yield } return @@ -144,7 +144,7 @@ // CHECK: %[[HDL_0:.*]] = llvm.intr.coro.begin // CHECK: call @mlirAsyncRuntimeExecute // CHECK: llvm.intr.coro.suspend -// CHECK: store %arg0, %arg1[%c0] : memref<1xf32> +// CHECK: memref.store %arg0, %arg1[%c0] : memref<1xf32> // CHECK: call @mlirAsyncRuntimeEmplaceToken(%[[RET_0]]) // Function outlined from the second async.execute operation with dependency. @@ -163,7 +163,7 @@ // CHECK: llvm.intr.coro.suspend // Emplace result token after second resumption. -// CHECK: store %arg1, %arg2[%c0] : memref<1xf32> +// CHECK: memref.store %arg1, %arg2[%c0] : memref<1xf32> // CHECK: call @mlirAsyncRuntimeEmplaceToken(%[[RET_1]]) // ----- diff --git a/mlir/test/Conversion/GPUCommon/memory-attrbution.mlir b/mlir/test/Conversion/GPUCommon/memory-attrbution.mlir --- a/mlir/test/Conversion/GPUCommon/memory-attrbution.mlir +++ b/mlir/test/Conversion/GPUCommon/memory-attrbution.mlir @@ -42,7 +42,7 @@ // ROCDL: llvm.getelementptr // ROCDL: llvm.store %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<4xf32, 5> + memref.store %arg0, %arg1[%c0] : memref<4xf32, 5> "terminator"() : () -> () } @@ -108,7 +108,7 @@ // ROCDL: llvm.getelementptr // ROCDL: llvm.store %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<4xf32, 3> + memref.store %arg0, %arg1[%c0] : memref<4xf32, 3> "terminator"() : () -> () } @@ -178,7 +178,7 @@ // ROCDL: %[[descr10:.*]] = llvm.insertvalue %[[c1]], %[[descr9]][4, 2] %c0 = constant 0 : index - store %arg0, %arg1[%c0,%c0,%c0] : memref<4x2x6xf32, 3> + memref.store %arg0, %arg1[%c0,%c0,%c0] : memref<4x2x6xf32, 3> "terminator"() : () -> () } } @@ -222,10 +222,10 @@ // ROCDL: llvm.alloca %[[c4]] x f32 : (i64) -> !llvm.ptr %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<1xf32, 3> - store %arg0, %arg2[%c0] : memref<2xf32, 3> - store %arg0, %arg3[%c0] : memref<3xf32, 5> - store %arg0, %arg4[%c0] : memref<4xf32, 5> + memref.store %arg0, %arg1[%c0] : memref<1xf32, 3> + memref.store %arg0, %arg2[%c0] : memref<2xf32, 3> + memref.store %arg0, %arg3[%c0] : memref<3xf32, 5> + memref.store %arg0, %arg4[%c0] : memref<4xf32, 5> "terminator"() : () -> () } } diff --git a/mlir/test/Conversion/GPUToSPIRV/load-store.mlir b/mlir/test/Conversion/GPUToSPIRV/load-store.mlir --- a/mlir/test/Conversion/GPUToSPIRV/load-store.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/load-store.mlir @@ -17,7 +17,7 @@ %c1_2 = constant 1 : index gpu.launch_func @kernels::@load_store_kernel blocks in (%0, %c1_2, %c1_2) threads in (%1, %c1_2, %c1_2) - args(%arg0 : memref<12x4xf32>, %arg1 : memref<12x4xf32>, %arg2 : memref<12x4xf32>, + args(%arg0 : memref<12x4xf32>, %arg1 : memref<12x4xf32>, %arg2 : memref<12x4xf32>, %c0 : index, %c0_0 : index, %c1 : index, %c1_1 : index) return } @@ -77,7 +77,7 @@ %16 = addf %14, %15 : f32 // CHECK: %[[PTR3:.*]] = spv.AccessChain %[[ARG2]]{{\[}}{{%.*}}, {{%.*}}{{\]}} // CHECK-NEXT: spv.Store "StorageBuffer" %[[PTR3]], %[[VAL3]] - store %16, %arg2[%12, %13] : memref<12x4xf32> + memref.store %16, %arg2[%12, %13] : memref<12x4xf32> gpu.return } } diff --git a/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir b/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir --- a/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir +++ b/mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir @@ -1,6 +1,6 @@ // RUN: mlir-opt %s -convert-gpu-launch-to-vulkan-launch | FileCheck %s -// CHECK: %[[resource:.*]] = alloc() : memref<12xf32> +// CHECK: %[[resource:.*]] = memref.alloc() : memref<12xf32> // CHECK: %[[index:.*]] = constant 1 : index // CHECK: call @vulkanLaunch(%[[index]], %[[index]], %[[index]], %[[resource]]) {spirv_blob = "{{.*}}", spirv_entry_point = "kernel"} @@ -24,7 +24,7 @@ } } func @foo() { - %0 = alloc() : memref<12xf32> + %0 = memref.alloc() : memref<12xf32> %c1 = constant 1 : index gpu.launch_func @kernels::@kernel blocks in(%c1, %c1, %c1) diff --git a/mlir/test/Conversion/LinalgToVector/linalg-to-vector.mlir b/mlir/test/Conversion/LinalgToVector/linalg-to-vector.mlir --- a/mlir/test/Conversion/LinalgToVector/linalg-to-vector.mlir +++ b/mlir/test/Conversion/LinalgToVector/linalg-to-vector.mlir @@ -21,12 +21,12 @@ // CHECK: %[[v0:.*]] = dim %[[arg1]], %[[c0]] : memref // CHECK: %[[v1:.*]] = dim %[[arg2]], %[[c0]] : memref // CHECK: %[[v2:.*]] = dim %[[arg0]], %[[c0]] : memref -// CHECK: %[[v3:.*]] = alloc(%[[c12]]) : memref -// CHECK: %[[v4:.*]] = alloc(%[[c12]]) : memref -// CHECK: %[[v5:.*]] = alloc(%[[c4]]) : memref -// CHECK: %[[v6:.*]] = std.view %[[v3]][%[[c0]]][] : memref to memref<3xf32> -// CHECK: %[[v7:.*]] = std.view %[[v4]][%[[c0]]][] : memref to memref<3xf32> -// CHECK: %[[v8:.*]] = std.view %[[v5]][%[[c0]]][] : memref to memref<1xf32> +// CHECK: %[[v3:.*]] = memref.alloc(%[[c12]]) : memref +// CHECK: %[[v4:.*]] = memref.alloc(%[[c12]]) : memref +// CHECK: %[[v5:.*]] = memref.alloc(%[[c4]]) : memref +// CHECK: %[[v6:.*]] = memref.view %[[v3]][%[[c0]]][] : memref to memref<3xf32> +// CHECK: %[[v7:.*]] = memref.view %[[v4]][%[[c0]]][] : memref to memref<3xf32> +// CHECK: %[[v8:.*]] = memref.view %[[v5]][%[[c0]]][] : memref to memref<1xf32> // CHECK: scf.for %[[arg3:.*]] = %[[c0]] to %[[v1]] step %[[c1]] { // CHECK: %[[v9:.*]] = affine.min #[[$map0]](%[[arg3]])[%[[v1]]] // CHECK: %[[v10:.*]] = subview %[[arg2]][%[[arg3]]] [%[[v9]]] [1] : memref to memref diff --git a/mlir/test/Conversion/SCFToGPU/no_blocks_no_threads.mlir b/mlir/test/Conversion/SCFToGPU/no_blocks_no_threads.mlir --- a/mlir/test/Conversion/SCFToGPU/no_blocks_no_threads.mlir +++ b/mlir/test/Conversion/SCFToGPU/no_blocks_no_threads.mlir @@ -25,7 +25,7 @@ // CHECK-BLOCKS-NEXT: %[[INDEX:.*]] = addi %{{.*}}, %[[B0]] // CHECK-BLOCKS-NEXT: load %{{.*}}[%[[INDEX]]] %0 = load %A[%i] : memref - store %0, %B[%i] : memref + memref.store %0, %B[%i] : memref // CHECK-THREADS: gpu.terminator // CHECK-BLOCKS: gpu.terminator } diff --git a/mlir/test/Conversion/SCFToGPU/parallel_loop.mlir b/mlir/test/Conversion/SCFToGPU/parallel_loop.mlir --- a/mlir/test/Conversion/SCFToGPU/parallel_loop.mlir +++ b/mlir/test/Conversion/SCFToGPU/parallel_loop.mlir @@ -10,7 +10,7 @@ scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3) step (%arg4, %step) { %val = load %buf[%i0, %i1] : memref - store %val, %res[%i1, %i0] : memref + memref.store %val, %res[%i1, %i0] : memref } { mapping = [{processor = 1, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>}, {processor = 0, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>}] } return } @@ -29,7 +29,7 @@ // CHECK: [[VAL_23:%.*]] = affine.apply #[[$MAP1]]([[VAL_12]]){{\[}}[[VAL_4]], [[VAL_0]]] // CHECK: [[VAL_24:%.*]] = affine.apply #[[$MAP1]]([[VAL_11]]){{\[}}[[VAL_7]], [[VAL_1]]] // CHECK: [[VAL_25:%.*]] = load [[VAL_5]]{{\[}}[[VAL_23]], [[VAL_24]]] : memref -// CHECK: store [[VAL_25]], [[VAL_6]]{{\[}}[[VAL_24]], [[VAL_23]]] : memref +// CHECK: memref.store [[VAL_25]], [[VAL_6]]{{\[}}[[VAL_24]], [[VAL_23]]] : memref // CHECK: gpu.terminator // CHECK: } // CHECK: return @@ -54,7 +54,7 @@ %idx0 = addi %i0, %si0 : index %idx1 = addi %i1, %si1 : index %val = load %buf[%idx0, %idx1] : memref - store %val, %res[%idx1, %idx0] : memref + memref.store %val, %res[%idx1, %idx0] : memref } { mapping = [ {processor = 4, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>}, {processor = 3, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>} @@ -88,7 +88,7 @@ // CHECK: [[VAL_56:%.*]] = addi [[VAL_52]], [[VAL_54]] : index // CHECK: [[VAL_57:%.*]] = addi [[VAL_53]], [[VAL_55]] : index // CHECK: [[VAL_58:%.*]] = load [[VAL_30]]{{\[}}[[VAL_56]], [[VAL_57]]] : memref -// CHECK: store [[VAL_58]], [[VAL_31]]{{\[}}[[VAL_57]], [[VAL_56]]] : memref +// CHECK: memref.store [[VAL_58]], [[VAL_31]]{{\[}}[[VAL_57]], [[VAL_56]]] : memref // CHECK: gpu.terminator // CHECK: } // CHECK: return @@ -107,7 +107,7 @@ scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3) step (%arg4, %step) { %val = load %buf[%i0, %i1] : memref - store %val, %res[%i1, %i0] : memref + memref.store %val, %res[%i1, %i0] : memref } { mapping = [ {processor = 1, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>}, {processor = 6, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>} @@ -128,7 +128,7 @@ // CHECK: [[VAL_81:%.*]] = affine.apply #[[$MAP1]]([[VAL_70]]){{\[}}[[VAL_63]], [[VAL_59]]] // CHECK: scf.for [[VAL_82:%.*]] = [[VAL_60]] to [[VAL_62]] step [[VAL_66]] { // CHECK: [[VAL_83:%.*]] = load [[VAL_64]]{{\[}}[[VAL_81]], [[VAL_82]]] : memref -// CHECK: store [[VAL_83]], [[VAL_65]]{{\[}}[[VAL_82]], [[VAL_81]]] : memref +// CHECK: memref.store [[VAL_83]], [[VAL_65]]{{\[}}[[VAL_82]], [[VAL_81]]] : memref // CHECK: } // CHECK: gpu.terminator // CHECK: } @@ -154,7 +154,7 @@ %idx0 = addi %i0, %si0 : index %idx1 = addi %i1, %si1 : index %val = load %buf[%idx0, %idx1] : memref - store %val, %res[%idx1, %idx0] : memref + memref.store %val, %res[%idx1, %idx0] : memref } { mapping = [ {processor = 4, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>}, {processor = 6, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>} @@ -186,7 +186,7 @@ // CHECK: [[VAL_112:%.*]] = addi [[VAL_108]], [[VAL_110]] : index // CHECK: [[VAL_113:%.*]] = addi [[VAL_109]], [[VAL_111]] : index // CHECK: [[VAL_114:%.*]] = load [[VAL_88]]{{\[}}[[VAL_112]], [[VAL_113]]] : memref -// CHECK: store [[VAL_114]], [[VAL_89]]{{\[}}[[VAL_113]], [[VAL_112]]] : memref +// CHECK: memref.store [[VAL_114]], [[VAL_89]]{{\[}}[[VAL_113]], [[VAL_112]]] : memref // CHECK: } // CHECK: } // CHECK: gpu.terminator @@ -232,7 +232,7 @@ %18 = load %11[%arg5, %arg6] : memref %19 = load %16[%arg5, %arg6] : memref %20 = addf %17, %18 : f32 - store %20, %16[%arg5, %arg6] : memref + memref.store %20, %16[%arg5, %arg6] : memref scf.yield } {mapping = [{bound = affine_map<(d0) -> (d0)>, map = affine_map<(d0) -> (d0)>, processor = 3 : i64}, {bound = affine_map<(d0) -> (d0)>, map = affine_map<(d0) -> (d0)>, processor = 4 : i64}]} scf.yield @@ -293,7 +293,7 @@ // CHECK: [[VAL_50:%.*]] = load [[VAL_39]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref // CHECK: [[VAL_51:%.*]] = load [[VAL_44]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref // CHECK: [[VAL_52:%.*]] = addf [[VAL_49]], [[VAL_50]] : f32 -// CHECK: store [[VAL_52]], [[VAL_44]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref +// CHECK: memref.store [[VAL_52]], [[VAL_44]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref // CHECK: } // CHECK: } // CHECK: gpu.terminator @@ -354,7 +354,7 @@ %idx0 = addi %i0, %si0 : index %idx1 = addi %i1, %si1 : index %val = load %buf[%idx0, %idx1] : memref - store %val, %res[%idx1, %idx0] : memref + memref.store %val, %res[%idx1, %idx0] : memref } { mapping = [ {processor = 4, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>}, {processor = 6, map = affine_map<(d0) -> (d0)>, bound = affine_map<(d0) -> (d0)>} diff --git a/mlir/test/Conversion/SCFToGPU/step_one.mlir b/mlir/test/Conversion/SCFToGPU/step_one.mlir --- a/mlir/test/Conversion/SCFToGPU/step_one.mlir +++ b/mlir/test/Conversion/SCFToGPU/step_one.mlir @@ -67,9 +67,9 @@ // CHECK-11: {{.*}} = load %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref // CHECK-22: {{.*}} = load %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref %0 = load %A[%i, %j, %ii, %jj] : memref - // CHECK-11-NEXT: store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref - // CHECK-22-NEXT: store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref - store %0, %B[%i, %j, %ii, %jj] : memref + // CHECK-11-NEXT: memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref + // CHECK-22-NEXT: memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref + memref.store %0, %B[%i, %j, %ii, %jj] : memref // CHECK-11: gpu.terminator // CHECK-22: gpu.terminator diff --git a/mlir/test/Conversion/SCFToGPU/step_positive.mlir b/mlir/test/Conversion/SCFToGPU/step_positive.mlir --- a/mlir/test/Conversion/SCFToGPU/step_positive.mlir +++ b/mlir/test/Conversion/SCFToGPU/step_positive.mlir @@ -20,8 +20,8 @@ // CHECK: {{.*}} = load %{{.*}}[%[[i]], %[[j]]] : memref %0 = load %A[%i, %j] : memref - // CHECK: store {{.*}}, %{{.*}}[%[[i]], %[[j]]] : memref - store %0, %B[%i, %j] : memref + // CHECK: memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]]] : memref + memref.store %0, %B[%i, %j] : memref } } return diff --git a/mlir/test/Conversion/SCFToSPIRV/for.mlir b/mlir/test/Conversion/SCFToSPIRV/for.mlir --- a/mlir/test/Conversion/SCFToSPIRV/for.mlir +++ b/mlir/test/Conversion/SCFToSPIRV/for.mlir @@ -37,7 +37,7 @@ // CHECK: } scf.for %arg4 = %lb to %ub step %step { %1 = load %arg2[%arg4] : memref<10xf32> - store %1, %arg3[%arg4] : memref<10xf32> + memref.store %1, %arg3[%arg4] : memref<10xf32> } return } @@ -78,8 +78,8 @@ // CHECK-DAG: %[[OUT2:.*]] = spv.Load "Function" %[[VAR2]] : f32 // CHECK: spv.Store "StorageBuffer" {{%.*}}, %[[OUT1]] : f32 // CHECK: spv.Store "StorageBuffer" {{%.*}}, %[[OUT2]] : f32 - store %result#0, %arg3[%lb] : memref<10xf32> - store %result#1, %arg3[%ub] : memref<10xf32> + memref.store %result#0, %arg3[%lb] : memref<10xf32> + memref.store %result#1, %arg3[%ub] : memref<10xf32> return } diff --git a/mlir/test/Conversion/SCFToSPIRV/if.mlir b/mlir/test/Conversion/SCFToSPIRV/if.mlir --- a/mlir/test/Conversion/SCFToSPIRV/if.mlir +++ b/mlir/test/Conversion/SCFToSPIRV/if.mlir @@ -20,7 +20,7 @@ // CHECK-NEXT: spv.Return scf.if %arg3 { - store %value, %arg2[%i] : memref<10xf32> + memref.store %value, %arg2[%i] : memref<10xf32> } return } @@ -62,18 +62,18 @@ scf.if %arg5 { scf.if %arg6 { %value = load %arg3[%i] : memref<10xf32> - store %value, %arg4[%i] : memref<10xf32> + memref.store %value, %arg4[%i] : memref<10xf32> } else { %value = load %arg4[%i] : memref<10xf32> - store %value, %arg3[%i] : memref<10xf32> + memref.store %value, %arg3[%i] : memref<10xf32> } } else { scf.if %arg6 { %value = load %arg3[%j] : memref<10xf32> - store %value, %arg4[%j] : memref<10xf32> + memref.store %value, %arg4[%j] : memref<10xf32> } else { %value = load %arg4[%j] : memref<10xf32> - store %value, %arg3[%j] : memref<10xf32> + memref.store %value, %arg3[%j] : memref<10xf32> } } return @@ -116,8 +116,8 @@ } %i = constant 0 : index %j = constant 1 : index - store %0#0, %arg2[%i] : memref<10xf32> - store %0#1, %arg2[%j] : memref<10xf32> + memref.store %0#0, %arg2[%i] : memref<10xf32> + memref.store %0#1, %arg2[%j] : memref<10xf32> return } @@ -149,7 +149,7 @@ } else { scf.yield %arg3 : memref<10xf32> } - store %value, %0[%i] : memref<10xf32> + memref.store %value, %0[%i] : memref<10xf32> return } diff --git a/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir b/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir @@ -1,5 +1,5 @@ // RUN: mlir-opt --lower-host-to-llvm %s | FileCheck %s - + module attributes {gpu.container_module, spv.target_env = #spv.target_env<#spv.vce, {max_compute_workgroup_invocations = 128 : i32, max_compute_workgroup_size = dense<[128, 128, 64]> : vector<3xi32>}>} { // CHECK: llvm.mlir.global linkonce @__spv__foo_bar_arg_0_descriptor_set0_binding0() : !llvm.struct<(array<6 x i32>)> @@ -8,7 +8,7 @@ // CHECK: spv.module @__spv__foo // CHECK: spv.globalVariable @bar_arg_0 bind(0, 0) : !spv.ptr [0])>, StorageBuffer> // CHECK: spv.func @__spv__foo_bar - + // CHECK: spv.EntryPoint "GLCompute" @__spv__foo_bar // CHECK: spv.ExecutionMode @__spv__foo_bar "LocalSize", 1, 1, 1 @@ -38,7 +38,7 @@ } func @main() { - %buffer = alloc() : memref<6xi32> + %buffer = memref.alloc() : memref<6xi32> %one = constant 1 : index gpu.launch_func @foo::@bar blocks in (%one, %one, %one) threads in (%one, %one, %one) args(%buffer : memref<6xi32>) diff --git a/mlir/test/Conversion/StandardToLLVM/calling-convention.mlir b/mlir/test/Conversion/StandardToLLVM/calling-convention.mlir --- a/mlir/test/Conversion/StandardToLLVM/calling-convention.mlir +++ b/mlir/test/Conversion/StandardToLLVM/calling-convention.mlir @@ -151,7 +151,7 @@ // CHECK: %[[DESC_0:.*]] = llvm.mlir.undef : !llvm.struct<(i64, ptr)> // CHECK: %[[DESC_1:.*]] = llvm.insertvalue %{{.*}}, %[[DESC_0]][0] // CHECK: %[[DESC_2:.*]] = llvm.insertvalue %[[MEMORY]], %[[DESC_1]][1] - %0 = memref_cast %arg0: memref<4x3xf32> to memref<*xf32> + %0 = memref.cast %arg0: memref<4x3xf32> to memref<*xf32> // CHECK: %[[ONE:.*]] = llvm.mlir.constant(1 : index) // CHECK: %[[TWO:.*]] = llvm.mlir.constant(2 : index) @@ -213,7 +213,7 @@ // CHECK: %[[DESC_0:.*]] = llvm.mlir.undef : !llvm.struct<(i64, ptr)> // CHECK: %[[DESC_1:.*]] = llvm.insertvalue %{{.*}}, %[[DESC_0]][0] // CHECK: %[[DESC_2:.*]] = llvm.insertvalue %[[MEMORY]], %[[DESC_1]][1] - %0 = memref_cast %arg0 : memref<4x3xf32> to memref<*xf32> + %0 = memref.cast %arg0 : memref<4x3xf32> to memref<*xf32> // Only check that we allocate the memory for each operand of the "return" // separately, even if both operands are the same value. The calling diff --git a/mlir/test/Conversion/StandardToLLVM/convert-dynamic-memref-ops.mlir b/mlir/test/Conversion/StandardToLLVM/convert-dynamic-memref-ops.mlir --- a/mlir/test/Conversion/StandardToLLVM/convert-dynamic-memref-ops.mlir +++ b/mlir/test/Conversion/StandardToLLVM/convert-dynamic-memref-ops.mlir @@ -48,7 +48,7 @@ // CHECK-NEXT: llvm.insertvalue %[[st0]], %{{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> // CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[4, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> // CHECK-NEXT: llvm.insertvalue %[[one]], %{{.*}}[4, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> - %0 = alloc(%arg0, %arg1) : memref + %0 = memref.alloc(%arg0, %arg1) : memref // CHECK-NEXT: llvm.return %{{.*}} : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> return %0 : memref } @@ -58,7 +58,7 @@ // CHECK: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> // CHECK-NEXT: %[[ptri8:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr to !llvm.ptr // CHECK-NEXT: llvm.call @free(%[[ptri8]]) : (!llvm.ptr) -> () - dealloc %arg0 : memref + memref.dealloc %arg0 : memref // CHECK-NEXT: llvm.return return } @@ -82,7 +82,7 @@ // CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[3, 1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK-NEXT: llvm.insertvalue %[[one]], %{{.*}}[4, 1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - %0 = alloc(%arg0, %arg1) : memref + %0 = memref.alloc(%arg0, %arg1) : memref // CHECK-NEXT: llvm.return %{{.*}} : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> return %0 : memref } @@ -107,7 +107,7 @@ // CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[3, 1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK-NEXT: llvm.insertvalue %[[st1]], %{{.*}}[4, 1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - %0 = alloca(%arg0, %arg1) : memref + %0 = memref.alloca(%arg0, %arg1) : memref // Test with explicitly specified alignment. llvm.alloca takes care of the // alignment. The same pointer is thus used for allocation and aligned @@ -116,7 +116,7 @@ // CHECK: %[[desc:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: %[[desc1:.*]] = llvm.insertvalue %[[alloca_aligned]], %[[desc]][0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: llvm.insertvalue %[[alloca_aligned]], %[[desc1]][1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - alloca(%arg0, %arg1) {alignment = 32} : memref + memref.alloca(%arg0, %arg1) {alignment = 32} : memref return %0 : memref } @@ -125,7 +125,7 @@ // CHECK: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK-NEXT: %[[ptri8:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr to !llvm.ptr // CHECK-NEXT: llvm.call @free(%[[ptri8]]) : (!llvm.ptr) -> () - dealloc %arg0 : memref + memref.dealloc %arg0 : memref return } @@ -142,23 +142,23 @@ // ALIGNED-ALLOC-NEXT: %[[alignment:.*]] = llvm.mlir.constant(32 : index) : i64 // ALIGNED-ALLOC-NEXT: %[[allocated:.*]] = llvm.call @aligned_alloc(%[[alignment]], %[[bytes]]) : (i64, i64) -> !llvm.ptr // ALIGNED-ALLOC-NEXT: llvm.bitcast %[[allocated]] : !llvm.ptr to !llvm.ptr - %0 = alloc() {alignment = 32} : memref<32x18xf32> + %0 = memref.alloc() {alignment = 32} : memref<32x18xf32> // Do another alloc just to test that we have a unique declaration for // aligned_alloc. // ALIGNED-ALLOC: llvm.call @aligned_alloc - %1 = alloc() {alignment = 64} : memref<4096xf32> + %1 = memref.alloc() {alignment = 64} : memref<4096xf32> // Alignment is to element type boundaries (minimum 16 bytes). // ALIGNED-ALLOC: %[[c32:.*]] = llvm.mlir.constant(32 : index) : i64 // ALIGNED-ALLOC-NEXT: llvm.call @aligned_alloc(%[[c32]] - %2 = alloc() : memref<4096xvector<8xf32>> + %2 = memref.alloc() : memref<4096xvector<8xf32>> // The minimum alignment is 16 bytes unless explicitly specified. // ALIGNED-ALLOC: %[[c16:.*]] = llvm.mlir.constant(16 : index) : i64 // ALIGNED-ALLOC-NEXT: llvm.call @aligned_alloc(%[[c16]], - %3 = alloc() : memref<4096xvector<2xf32>> + %3 = memref.alloc() : memref<4096xvector<2xf32>> // ALIGNED-ALLOC: %[[c8:.*]] = llvm.mlir.constant(8 : index) : i64 // ALIGNED-ALLOC-NEXT: llvm.call @aligned_alloc(%[[c8]], - %4 = alloc() {alignment = 8} : memref<1024xvector<4xf32>> + %4 = memref.alloc() {alignment = 8} : memref<1024xvector<4xf32>> // Bump the memref allocation size if its size is not a multiple of alignment. // ALIGNED-ALLOC: %[[c32:.*]] = llvm.mlir.constant(32 : index) : i64 // ALIGNED-ALLOC-NEXT: llvm.mlir.constant(1 : index) : i64 @@ -167,11 +167,11 @@ // ALIGNED-ALLOC-NEXT: llvm.urem // ALIGNED-ALLOC-NEXT: %[[SIZE_ALIGNED:.*]] = llvm.sub // ALIGNED-ALLOC-NEXT: llvm.call @aligned_alloc(%[[c32]], %[[SIZE_ALIGNED]]) - %5 = alloc() {alignment = 32} : memref<100xf32> + %5 = memref.alloc() {alignment = 32} : memref<100xf32> // Bump alignment to the next power of two if it isn't. // ALIGNED-ALLOC: %[[c128:.*]] = llvm.mlir.constant(128 : index) : i64 // ALIGNED-ALLOC: llvm.call @aligned_alloc(%[[c128]] - %6 = alloc(%N) : memref> + %6 = memref.alloc(%N) : memref> return %0 : memref<32x18xf32> } @@ -232,17 +232,17 @@ // CHECK-NEXT: [[C3:%.*]] = llvm.mlir.constant(3 : i32) : i32 // CHECK-NEXT: [[C1_1:%.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK-NEXT: "llvm.intr.prefetch"(%[[addr]], [[C1]], [[C3]], [[C1_1]]) : (!llvm.ptr, i32, i32, i32) -> () - prefetch %A[%i, %j], write, locality<3>, data : memref + memref.prefetch %A[%i, %j], write, locality<3>, data : memref // CHECK: [[C0:%.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: [[C0_1:%.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: [[C1_2:%.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: "llvm.intr.prefetch"(%{{.*}}, [[C0]], [[C0_1]], [[C1_2]]) : (!llvm.ptr, i32, i32, i32) -> () - prefetch %A[%i, %j], read, locality<0>, data : memref + memref.prefetch %A[%i, %j], read, locality<0>, data : memref // CHECK: [[C0_2:%.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: [[C2:%.*]] = llvm.mlir.constant(2 : i32) : i32 // CHECK: [[C0_3:%.*]] = llvm.mlir.constant(0 : i32) : i32 // CHECK: "llvm.intr.prefetch"(%{{.*}}, [[C0_2]], [[C2]], [[C0_3]]) : (!llvm.ptr, i32, i32, i32) -> () - prefetch %A[%i, %j], read, locality<2>, instr : memref + memref.prefetch %A[%i, %j], read, locality<2>, instr : memref return } @@ -263,7 +263,7 @@ // CHECK-NEXT: %[[off1:.*]] = llvm.add %[[offI]], %[[J]] : i64 // CHECK-NEXT: %[[addr:.*]] = llvm.getelementptr %[[ptr]][%[[off1]]] : (!llvm.ptr, i64) -> !llvm.ptr // CHECK-NEXT: llvm.store %{{.*}}, %[[addr]] : !llvm.ptr - store %val, %dynamic[%i, %j] : memref + memref.store %val, %dynamic[%i, %j] : memref return } @@ -284,56 +284,56 @@ // CHECK-NEXT: %[[off1:.*]] = llvm.add %[[offI]], %[[J]] : i64 // CHECK-NEXT: %[[addr:.*]] = llvm.getelementptr %[[ptr]][%[[off1]]] : (!llvm.ptr, i64) -> !llvm.ptr // CHECK-NEXT: llvm.store %{{.*}}, %[[addr]] : !llvm.ptr - store %val, %mixed[%i, %j] : memref<42x?xf32> + memref.store %val, %mixed[%i, %j] : memref<42x?xf32> return } // CHECK-LABEL: func @memref_cast_static_to_dynamic func @memref_cast_static_to_dynamic(%static : memref<10x42xf32>) { // CHECK-NOT: llvm.bitcast - %0 = memref_cast %static : memref<10x42xf32> to memref + %0 = memref.cast %static : memref<10x42xf32> to memref return } // CHECK-LABEL: func @memref_cast_static_to_mixed func @memref_cast_static_to_mixed(%static : memref<10x42xf32>) { // CHECK-NOT: llvm.bitcast - %0 = memref_cast %static : memref<10x42xf32> to memref + %0 = memref.cast %static : memref<10x42xf32> to memref return } // CHECK-LABEL: func @memref_cast_dynamic_to_static func @memref_cast_dynamic_to_static(%dynamic : memref) { // CHECK-NOT: llvm.bitcast - %0 = memref_cast %dynamic : memref to memref<10x12xf32> + %0 = memref.cast %dynamic : memref to memref<10x12xf32> return } // CHECK-LABEL: func @memref_cast_dynamic_to_mixed func @memref_cast_dynamic_to_mixed(%dynamic : memref) { // CHECK-NOT: llvm.bitcast - %0 = memref_cast %dynamic : memref to memref + %0 = memref.cast %dynamic : memref to memref return } // CHECK-LABEL: func @memref_cast_mixed_to_dynamic func @memref_cast_mixed_to_dynamic(%mixed : memref<42x?xf32>) { // CHECK-NOT: llvm.bitcast - %0 = memref_cast %mixed : memref<42x?xf32> to memref + %0 = memref.cast %mixed : memref<42x?xf32> to memref return } // CHECK-LABEL: func @memref_cast_mixed_to_static func @memref_cast_mixed_to_static(%mixed : memref<42x?xf32>) { // CHECK-NOT: llvm.bitcast - %0 = memref_cast %mixed : memref<42x?xf32> to memref<42x1xf32> + %0 = memref.cast %mixed : memref<42x?xf32> to memref<42x1xf32> return } // CHECK-LABEL: func @memref_cast_mixed_to_mixed func @memref_cast_mixed_to_mixed(%mixed : memref<42x?xf32>) { // CHECK-NOT: llvm.bitcast - %0 = memref_cast %mixed : memref<42x?xf32> to memref + %0 = memref.cast %mixed : memref<42x?xf32> to memref return } @@ -347,7 +347,7 @@ // CHECK : llvm.mlir.undef : !llvm.struct<(i64, ptr)> // CHECK-DAG: llvm.insertvalue %[[r]], %{{.*}}[0] : !llvm.struct<(i64, ptr)> // CHECK-DAG: llvm.insertvalue %[[p2]], %{{.*}}[1] : !llvm.struct<(i64, ptr)> - %0 = memref_cast %arg : memref<42x2x?xf32> to memref<*xf32> + %0 = memref.cast %arg : memref<42x2x?xf32> to memref<*xf32> return } @@ -355,7 +355,7 @@ func @memref_cast_unranked_to_ranked(%arg : memref<*xf32>) { // CHECK: %[[p:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(i64, ptr)> // CHECK-NEXT: llvm.bitcast %[[p]] : !llvm.ptr to !llvm.ptr, ptr, i64, array<4 x i64>, array<4 x i64>)>> - %0 = memref_cast %arg : memref<*xf32> to memref + %0 = memref.cast %arg : memref<*xf32> to memref return } diff --git a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir --- a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir +++ b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir @@ -93,7 +93,7 @@ // BAREPTR-NEXT: llvm.insertvalue %[[ptr]], %{{.*}}[1] : !llvm.struct<(ptr, ptr, i64)> // BAREPTR-NEXT: %[[c0:.*]] = llvm.mlir.constant(0 : index) : i64 // BAREPTR-NEXT: llvm.insertvalue %[[c0]], %{{.*}}[2] : !llvm.struct<(ptr, ptr, i64)> - %0 = alloc() : memref + %0 = memref.alloc() : memref return %0 : memref } @@ -109,7 +109,7 @@ // BAREPTR: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr, ptr, i64)> // BAREPTR-NEXT: %[[bc:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr to !llvm.ptr // BAREPTR-NEXT: llvm.call @free(%[[bc]]) : (!llvm.ptr) -> () - dealloc %arg0 : memref + memref.dealloc %arg0 : memref return } @@ -161,7 +161,7 @@ // BAREPTR-NEXT: llvm.insertvalue %[[alignedBitCast]], %{{.*}}[1] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> // BAREPTR-NEXT: %[[c0:.*]] = llvm.mlir.constant(0 : index) : i64 // BAREPTR-NEXT: llvm.insertvalue %[[c0]], %{{.*}}[2] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> - %0 = alloc() {alignment = 8} : memref<42xf32> + %0 = memref.alloc() {alignment = 8} : memref<42xf32> return %0 : memref<42xf32> } @@ -183,7 +183,7 @@ // BAREPTR-NEXT: %[[size_bytes:.*]] = llvm.ptrtoint %[[gep]] : !llvm.ptr to i64 // BAREPTR-NEXT: %[[allocated:.*]] = llvm.call @malloc(%[[size_bytes]]) : (i64) -> !llvm.ptr // BAREPTR-NEXT: llvm.bitcast %[[allocated]] : !llvm.ptr to !llvm.ptr - %0 = alloc() : memref<32x18xf32> + %0 = memref.alloc() : memref<32x18xf32> return %0 : memref<32x18xf32> } @@ -199,7 +199,7 @@ // CHECK-NEXT: %[[gep:.*]] = llvm.getelementptr %[[null]][%[[num_elems]]] : (!llvm.ptr, i64) -> !llvm.ptr // CHECK-NEXT: %[[size_bytes:.*]] = llvm.ptrtoint %[[gep]] : !llvm.ptr to i64 // CHECK-NEXT: %[[allocated:.*]] = llvm.alloca %[[size_bytes]] x f32 : (i64) -> !llvm.ptr - %0 = alloca() : memref<32x18xf32> + %0 = memref.alloca() : memref<32x18xf32> // Test with explicitly specified alignment. llvm.alloca takes care of the // alignment. The same pointer is thus used for allocation and aligned @@ -208,7 +208,7 @@ // CHECK: %[[desc:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: %[[desc1:.*]] = llvm.insertvalue %[[alloca_aligned]], %[[desc]][0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: llvm.insertvalue %[[alloca_aligned]], %[[desc1]][1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - alloca() {alignment = 32} : memref<32x18xf32> + memref.alloca() {alignment = 32} : memref<32x18xf32> return %0 : memref<32x18xf32> } @@ -224,7 +224,7 @@ // BAREPTR: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // BAREPTR-NEXT: %[[bc:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr to !llvm.ptr // BAREPTR-NEXT: llvm.call @free(%[[bc]]) : (!llvm.ptr) -> () - dealloc %static : memref<10x8xf32> + memref.dealloc %static : memref<10x8xf32> return } @@ -280,7 +280,7 @@ // BAREPTR: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(ptr, ptr, i64)> // BAREPTR-NEXT: llvm.store %[[val]], %[[ptr]] : !llvm.ptr - store %arg1, %arg0[] : memref + memref.store %arg1, %arg0[] : memref return } @@ -314,7 +314,7 @@ // BAREPTR-NEXT: %[[off1:.*]] = llvm.add %[[offI]], %[[J]] : i64 // BAREPTR-NEXT: %[[addr:.*]] = llvm.getelementptr %[[ptr]][%[[off1]]] : (!llvm.ptr, i64) -> !llvm.ptr // BAREPTR-NEXT: llvm.store %{{.*}}, %[[addr]] : !llvm.ptr - store %val, %static[%i, %j] : memref<10x42xf32> + memref.store %val, %static[%i, %j] : memref<10x42xf32> return } diff --git a/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir b/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir --- a/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir +++ b/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir @@ -786,7 +786,7 @@ func @view(%arg0 : index, %arg1 : index, %arg2 : index) { // CHECK: llvm.mlir.constant(2048 : index) : i64 // CHECK: llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> - %0 = alloc() : memref<2048xi8> + %0 = memref.alloc() : memref<2048xi8> // Test two dynamic sizes. // CHECK: llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> @@ -802,7 +802,7 @@ // CHECK: llvm.insertvalue %[[ARG0]], %{{.*}}[3, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: llvm.mul %{{.*}}, %[[ARG1]] // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - %1 = view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref + %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref // Test one dynamic size. // CHECK: llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> @@ -819,7 +819,7 @@ // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[3, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: llvm.mul %{{.*}}, %[[ARG1]] // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - %3 = view %0[%arg2][%arg1] : memref<2048xi8> to memref<4x?xf32> + %3 = memref.view %0[%arg2][%arg1] : memref<2048xi8> to memref<4x?xf32> // Test static sizes. // CHECK: llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> @@ -837,12 +837,12 @@ // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[3, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: llvm.mlir.constant(4 : index) : i64 // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - %5 = view %0[%arg2][] : memref<2048xi8> to memref<64x4xf32> + %5 = memref.view %0[%arg2][] : memref<2048xi8> to memref<64x4xf32> // Test view memory space. // CHECK: llvm.mlir.constant(2048 : index) : i64 // CHECK: llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> - %6 = alloc() : memref<2048xi8, 4> + %6 = memref.alloc() : memref<2048xi8, 4> // CHECK: llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: %[[BASE_PTR_4:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> @@ -859,7 +859,7 @@ // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[3, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: llvm.mlir.constant(4 : index) : i64 // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - %7 = view %6[%arg2][] : memref<2048xi8, 4> to memref<64x4xf32, 4> + %7 = memref.view %6[%arg2][] : memref<2048xi8, 4> to memref<64x4xf32, 4> return } diff --git a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir --- a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir +++ b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir @@ -3,7 +3,7 @@ // CHECK-LABEL: func @address_space( // CHECK-SAME: !llvm.ptr func @address_space(%arg0 : memref<32xf32, affine_map<(d0) -> (d0)>, 7>) { - %0 = alloc() : memref<32xf32, affine_map<(d0) -> (d0)>, 5> + %0 = memref.alloc() : memref<32xf32, affine_map<(d0) -> (d0)>, 5> %1 = constant 7 : index // CHECK: llvm.load %{{.*}} : !llvm.ptr %2 = load %0[%1] : memref<32xf32, affine_map<(d0) -> (d0)>, 5> @@ -122,25 +122,25 @@ // CHECK: llvm.extractvalue {{.*}}[3, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> // CHECK: llvm.insertvalue {{.*}}[3, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> func @transpose(%arg0: memref) { - %0 = transpose %arg0 (i, j, k) -> (k, i, j) : memref to memref (d2 * s1 + s0 + d0 * s2 + d1)>> + %0 = memref.transpose %arg0 (i, j, k) -> (k, i, j) : memref to memref (d2 * s1 + s0 + d0 * s2 + d1)>> return } // ----- // CHECK: llvm.mlir.global external @gv0() : !llvm.array<2 x f32> -global_memref @gv0 : memref<2xf32> = uninitialized +memref.global @gv0 : memref<2xf32> = uninitialized // CHECK: llvm.mlir.global private @gv1() : !llvm.array<2 x f32> -global_memref "private" @gv1 : memref<2xf32> +memref.global "private" @gv1 : memref<2xf32> // CHECK: llvm.mlir.global external @gv2(dense<{{\[\[}}0.000000e+00, 1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00, 5.000000e+00]]> : tensor<2x3xf32>) : !llvm.array<2 x array<3 x f32>> -global_memref @gv2 : memref<2x3xf32> = dense<[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]> +memref.global @gv2 : memref<2x3xf32> = dense<[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]> // Test 1D memref. // CHECK-LABEL: func @get_gv0_memref func @get_gv0_memref() { - %0 = get_global_memref @gv0 : memref<2xf32> + %0 = memref.get_global @gv0 : memref<2xf32> // CHECK: %[[DIM:.*]] = llvm.mlir.constant(2 : index) : i64 // CHECK: %[[STRIDE:.*]] = llvm.mlir.constant(1 : index) : i64 // CHECK: %[[ADDR:.*]] = llvm.mlir.addressof @gv0 : !llvm.ptr> @@ -179,13 +179,13 @@ // CHECK: llvm.insertvalue %[[DIM1]], {{.*}}[4, 0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> // CHECK: llvm.insertvalue %[[STRIDE1]], {{.*}}[4, 1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> - %0 = get_global_memref @gv2 : memref<2x3xf32> + %0 = memref.get_global @gv2 : memref<2x3xf32> return } // Test scalar memref. // CHECK: llvm.mlir.global external @gv3(1.000000e+00 : f32) : f32 -global_memref @gv3 : memref = dense<1.0> +memref.global @gv3 : memref = dense<1.0> // CHECK-LABEL: func @get_gv3_memref func @get_gv3_memref() { @@ -199,7 +199,7 @@ // CHECK: llvm.insertvalue %[[GEP]], {{.*}}[1] : !llvm.struct<(ptr, ptr, i64)> // CHECK: %[[OFFSET:.*]] = llvm.mlir.constant(0 : index) : i64 // CHECK: llvm.insertvalue %[[OFFSET]], {{.*}}[2] : !llvm.struct<(ptr, ptr, i64)> - %0 = get_global_memref @gv3 : memref + %0 = memref.get_global @gv3 : memref return } diff --git a/mlir/test/Conversion/StandardToSPIRV/alloc.mlir b/mlir/test/Conversion/StandardToSPIRV/alloc.mlir --- a/mlir/test/Conversion/StandardToSPIRV/alloc.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/alloc.mlir @@ -10,22 +10,22 @@ } { func @alloc_dealloc_workgroup_mem(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<4x5xf32, 3> + %0 = memref.alloc() : memref<4x5xf32, 3> %1 = load %0[%arg0, %arg1] : memref<4x5xf32, 3> - store %1, %0[%arg0, %arg1] : memref<4x5xf32, 3> - dealloc %0 : memref<4x5xf32, 3> + memref.store %1, %0[%arg0, %arg1] : memref<4x5xf32, 3> + memref.dealloc %0 : memref<4x5xf32, 3> return } } // CHECK: spv.globalVariable @[[VAR:.+]] : !spv.ptr)>, Workgroup> // CHECK: func @alloc_dealloc_workgroup_mem -// CHECK-NOT: alloc +// CHECK-NOT: memref.alloc // CHECK: %[[PTR:.+]] = spv.mlir.addressof @[[VAR]] // CHECK: %[[LOADPTR:.+]] = spv.AccessChain %[[PTR]] // CHECK: %[[VAL:.+]] = spv.Load "Workgroup" %[[LOADPTR]] : f32 // CHECK: %[[STOREPTR:.+]] = spv.AccessChain %[[PTR]] // CHECK: spv.Store "Workgroup" %[[STOREPTR]], %[[VAL]] : f32 -// CHECK-NOT: dealloc +// CHECK-NOT: memref.dealloc // CHECK: spv.Return // ----- @@ -36,10 +36,10 @@ } { func @alloc_dealloc_workgroup_mem(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<4x5xi16, 3> + %0 = memref.alloc() : memref<4x5xi16, 3> %1 = load %0[%arg0, %arg1] : memref<4x5xi16, 3> - store %1, %0[%arg0, %arg1] : memref<4x5xi16, 3> - dealloc %0 : memref<4x5xi16, 3> + memref.store %1, %0[%arg0, %arg1] : memref<4x5xi16, 3> + memref.dealloc %0 : memref<4x5xi16, 3> return } } @@ -65,8 +65,8 @@ } { func @two_allocs() { - %0 = alloc() : memref<4x5xf32, 3> - %1 = alloc() : memref<2x3xi32, 3> + %0 = memref.alloc() : memref<4x5xf32, 3> + %1 = memref.alloc() : memref<2x3xi32, 3> return } } @@ -86,8 +86,8 @@ } { func @two_allocs_vector() { - %0 = alloc() : memref<4xvector<4xf32>, 3> - %1 = alloc() : memref<2xvector<2xi32>, 3> + %0 = memref.alloc() : memref<4xvector<4xf32>, 3> + %1 = memref.alloc() : memref<2xvector<2xi32>, 3> return } } @@ -109,8 +109,8 @@ { func @alloc_dealloc_dynamic_workgroup_mem(%arg0 : index) { // expected-error @+2 {{unhandled allocation type}} - // expected-error @+1 {{'std.alloc' op operand #0 must be index}} - %0 = alloc(%arg0) : memref<4x?xf32, 3> + // expected-error @+1 {{'memref.alloc' op operand #0 must be index}} + %0 = memref.alloc(%arg0) : memref<4x?xf32, 3> return } } @@ -124,7 +124,7 @@ { func @alloc_dealloc_mem() { // expected-error @+1 {{unhandled allocation type}} - %0 = alloc() : memref<4x5xf32> + %0 = memref.alloc() : memref<4x5xf32> return } } @@ -139,8 +139,8 @@ { func @alloc_dealloc_dynamic_workgroup_mem(%arg0 : memref<4x?xf32, 3>) { // expected-error @+2 {{unhandled deallocation type}} - // expected-error @+1 {{'std.dealloc' op operand #0 must be memref of any type values}} - dealloc %arg0 : memref<4x?xf32, 3> + // expected-error @+1 {{'memref.dealloc' op operand #0 must be memref of any type values}} + memref.dealloc %arg0 : memref<4x?xf32, 3> return } } @@ -155,7 +155,7 @@ func @alloc_dealloc_mem(%arg0 : memref<4x5xf32>) { // expected-error @+2 {{unhandled deallocation type}} // expected-error @+1 {{op operand #0 must be memref of any type values}} - dealloc %arg0 : memref<4x5xf32> + memref.dealloc %arg0 : memref<4x5xf32> return } } diff --git a/mlir/test/Conversion/StandardToSPIRV/legalization.mlir b/mlir/test/Conversion/StandardToSPIRV/legalization.mlir --- a/mlir/test/Conversion/StandardToSPIRV/legalization.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/legalization.mlir @@ -41,10 +41,10 @@ // CHECK: [[INDEX1:%.*]] = addi [[ARG1]], [[STRIDE1]] : index // CHECK: [[STRIDE2:%.*]] = muli [[ARG4]], [[C3]] : index // CHECK: [[INDEX2:%.*]] = addi [[ARG2]], [[STRIDE2]] : index - // CHECK: store [[ARG5]], [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}} + // CHECK: memref.store [[ARG5]], [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}} %0 = subview %arg0[%arg1, %arg2][4, 4][2, 3] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [64, 3]> - store %arg5, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [64, 3]> + memref.store %arg5, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [64, 3]> return } @@ -56,10 +56,10 @@ // CHECK: [[INDEX1:%.*]] = addi [[ARG1]], [[STRIDE1]] : index // CHECK: [[STRIDE2:%.*]] = muli [[ARG4]], [[ARG6]] : index // CHECK: [[INDEX2:%.*]] = addi [[ARG2]], [[STRIDE2]] : index - // CHECK: store [[ARG7]], [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}} + // CHECK: memref.store [[ARG7]], [[ARG0]]{{\[}}[[INDEX1]], [[INDEX2]]{{\]}} %0 = subview %arg0[%arg1, %arg2][4, 4][%arg5, %arg6] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [?, ?]> - store %arg7, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [?, ?]> + memref.store %arg7, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [?, ?]> return } diff --git a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir --- a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir @@ -882,7 +882,7 @@ // CHECK-SAME: [[ZERO2]], [[ZERO2]] // CHECK-SAME: ] : // CHECK: spv.Store "StorageBuffer" %{{.*}} : f32 - store %0, %arg1[] : memref + memref.store %0, %arg1[] : memref return } @@ -901,7 +901,7 @@ // CHECK-SAME: [[ZERO2]], [[ZERO2]] // CHECK-SAME: ] : // CHECK: spv.Store "StorageBuffer" %{{.*}} : i32 - store %0, %arg1[] : memref + memref.store %0, %arg1[] : memref return } @@ -1000,7 +1000,7 @@ // CHECK: %[[PTR:.+]] = spv.AccessChain %[[ARG0]][%[[ZERO]], %[[ACCESS_IDX]]] // CHECK: spv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] // CHECK: spv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] - store %value, %arg0[] : memref + memref.store %value, %arg0[] : memref return } @@ -1026,7 +1026,7 @@ // CHECK: %[[PTR:.+]] = spv.AccessChain %[[ARG0]][%[[ZERO]], %[[ACCESS_IDX]]] // CHECK: spv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] // CHECK: spv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] - store %value, %arg0[%index] : memref<10xi16> + memref.store %value, %arg0[%index] : memref<10xi16> return } @@ -1035,7 +1035,7 @@ // CHECK: spv.Store // CHECK-NOT: spv.AtomicAnd // CHECK-NOT: spv.AtomicOr - store %value, %arg0[] : memref + memref.store %value, %arg0[] : memref return } @@ -1044,7 +1044,7 @@ // CHECK: spv.Store // CHECK-NOT: spv.AtomicAnd // CHECK-NOT: spv.AtomicOr - store %value, %arg0[] : memref + memref.store %value, %arg0[] : memref return } @@ -1108,7 +1108,7 @@ // CHECK: %[[PTR:.+]] = spv.AccessChain %[[ARG0]][%[[ZERO]], %[[ACCESS_IDX]]] // CHECK: spv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]] // CHECK: spv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]] - store %value, %arg0[] : memref + memref.store %value, %arg0[] : memref return } @@ -1117,7 +1117,7 @@ // CHECK: spv.Store // CHECK-NOT: spv.AtomicAnd // CHECK-NOT: spv.AtomicOr - store %value, %arg0[%index] : memref<10xi16> + memref.store %value, %arg0[%index] : memref<10xi16> return } diff --git a/mlir/test/Conversion/StandardToSPIRV/subview-to-spirv.mlir b/mlir/test/Conversion/StandardToSPIRV/subview-to-spirv.mlir --- a/mlir/test/Conversion/StandardToSPIRV/subview-to-spirv.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/subview-to-spirv.mlir @@ -27,11 +27,11 @@ // CHECK: %[[T7:.*]] = addi %[[ARG1]], %[[T6]] // CHECK: %[[T8:.*]] = muli %[[ARG4]], %[[ARG2]] // CHECK: %[[T9:.*]] = addi %[[T8]], %[[C2]] - // CHECK: store %[[STOREVAL]], %[[ARG0]][%[[T7]], %[[T9]]] + // CHECK: memref.store %[[STOREVAL]], %[[ARG0]][%[[T7]], %[[T9]]] %0 = subview %arg0[%arg1, 2][4, 4][3, %arg2] : memref<12x32xf32> to memref<4x4xf32, offset:?, strides: [96, ?]> %1 = load %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [96, ?]> %2 = math.sqrt %1 : f32 - store %2, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [96, ?]> + memref.store %2, %0[%arg3, %arg4] : memref<4x4xf32, offset:?, strides: [96, ?]> return } diff --git a/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir b/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir --- a/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir +++ b/mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir @@ -4,7 +4,7 @@ // CHECK-LABEL: func @materialize_read_1d() { func @materialize_read_1d() { %f0 = constant 0.0: f32 - %A = alloc () : memref<7x42xf32> + %A = memref.alloc () : memref<7x42xf32> affine.for %i0 = 0 to 7 step 4 { affine.for %i1 = 0 to 42 step 4 { %f1 = vector.transfer_read %A[%i0, %i1], %f0 {permutation_map = affine_map<(d0, d1) -> (d0)>} : memref<7x42xf32>, vector<4xf32> @@ -35,7 +35,7 @@ // CHECK-LABEL: func @materialize_read_1d_partially_specialized func @materialize_read_1d_partially_specialized(%dyn1 : index, %dyn2 : index, %dyn4 : index) { %f0 = constant 0.0: f32 - %A = alloc (%dyn1, %dyn2, %dyn4) : memref<7x?x?x42x?xf32> + %A = memref.alloc (%dyn1, %dyn2, %dyn4) : memref<7x?x?x42x?xf32> affine.for %i0 = 0 to 7 { affine.for %i1 = 0 to %dyn1 { affine.for %i2 = 0 to %dyn2 { @@ -52,7 +52,7 @@ } } } - // CHECK: %[[tensor:[0-9]+]] = alloc + // CHECK: %[[tensor:[0-9]+]] = memref.alloc // CHECK-NOT: {{.*}} dim %[[tensor]], %c0 // CHECK-NOT: {{.*}} dim %[[tensor]], %c3 return @@ -65,13 +65,13 @@ // CHECK-LABEL: func @materialize_read(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index, %{{.*}}: index) { func @materialize_read(%M: index, %N: index, %O: index, %P: index) { %f0 = constant 0.0: f32 - // CHECK-DAG: %[[ALLOC:.*]] = alloca() : memref<5x4xvector<3xf32>> + // CHECK-DAG: %[[ALLOC:.*]] = memref.alloca() : memref<5x4xvector<3xf32>> // CHECK-DAG: %[[C0:.*]] = constant 0 : index // CHECK-DAG: %[[C1:.*]] = constant 1 : index // CHECK-DAG: %[[C3:.*]] = constant 3 : index // CHECK-DAG: %[[C4:.*]] = constant 4 : index // CHECK-DAG: %[[C5:.*]] = constant 5 : index - // CHECK: %{{.*}} = alloc(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : memref + // CHECK: %{{.*}} = memref.alloc(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : memref // CHECK-NEXT: affine.for %[[I0:.*]] = 0 to %{{.*}} step 3 { // CHECK-NEXT: affine.for %[[I1:.*]] = 0 to %{{.*}} { // CHECK-NEXT: affine.for %[[I2:.*]] = 0 to %{{.*}} { @@ -107,7 +107,7 @@ // Check that I0 + I4 (of size 3) read from first index load(L0, ...) and write into last index store(..., I4) // Check that I3 + I6 (of size 5) read from last index load(..., L3) and write into first index store(I6, ...) // Other dimensions are just accessed with I1, I2 resp. - %A = alloc (%M, %N, %O, %P) : memref + %A = memref.alloc (%M, %N, %O, %P) : memref affine.for %i0 = 0 to %M step 3 { affine.for %i1 = 0 to %N { affine.for %i2 = 0 to %O { @@ -129,14 +129,14 @@ // CHECK-LABEL:func @materialize_write(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index, %{{.*}}: index) { func @materialize_write(%M: index, %N: index, %O: index, %P: index) { - // CHECK-DAG: %[[ALLOC:.*]] = alloca() : memref<5x4xvector<3xf32>> + // CHECK-DAG: %[[ALLOC:.*]] = memref.alloca() : memref<5x4xvector<3xf32>> // CHECK-DAG: %{{.*}} = constant dense<1.000000e+00> : vector<5x4x3xf32> // CHECK-DAG: %[[C0:.*]] = constant 0 : index // CHECK-DAG: %[[C1:.*]] = constant 1 : index // CHECK-DAG: %[[C3:.*]] = constant 3 : index // CHECK-DAG: %[[C4:.*]] = constant 4 : index // CHECK-DAG: %[[C5:.*]] = constant 5 : index - // CHECK: %{{.*}} = alloc(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : memref + // CHECK: %{{.*}} = memref.alloc(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : memref // CHECK-NEXT: affine.for %[[I0:.*]] = 0 to %{{.*}} step 3 { // CHECK-NEXT: affine.for %[[I1:.*]] = 0 to %{{.*}} step 4 { // CHECK-NEXT: affine.for %[[I2:.*]] = 0 to %{{.*}} { @@ -169,7 +169,7 @@ // Check that I1 + I5 (of size 4) read from second index load(..., I5, ...) and write into second index store(..., S1, ...) // Check that I3 + I6 (of size 5) read from first index load(I6, ...) and write into last index store(..., S3) // Other dimension is just accessed with I2. - %A = alloc (%M, %N, %O, %P) : memref + %A = memref.alloc (%M, %N, %O, %P) : memref %f1 = constant dense<1.000000e+00> : vector<5x4x3xf32> affine.for %i0 = 0 to %M step 3 { affine.for %i1 = 0 to %N step 4 { @@ -204,7 +204,7 @@ %f7 = constant 7.0: f32 // CHECK-DAG: %[[splat:.*]] = constant dense<7.000000e+00> : vector<15xf32> - // CHECK-DAG: %[[alloc:.*]] = alloca() : memref<3xvector<15xf32>> + // CHECK-DAG: %[[alloc:.*]] = memref.alloca() : memref<3xvector<15xf32>> // CHECK-DAG: %[[C0:.*]] = constant 0 : index // CHECK-DAG: %[[dim:.*]] = dim %[[A]], %[[C0]] : memref // CHECK: affine.for %[[I:.*]] = 0 to 3 { @@ -277,7 +277,7 @@ // FULL-UNROLL-SAME: %[[vec:[a-zA-Z0-9]+]]: vector<3x15xf32> func @transfer_write_progressive(%A : memref, %base: index, %vec: vector<3x15xf32>) { // CHECK: %[[C0:.*]] = constant 0 : index - // CHECK: %[[alloc:.*]] = alloca() : memref<3xvector<15xf32>> + // CHECK: %[[alloc:.*]] = memref.alloca() : memref<3xvector<15xf32>> // CHECK: %[[vmemref:.*]] = vector.type_cast %[[alloc]] : memref<3xvector<15xf32>> to memref> // CHECK: store %[[vec]], %[[vmemref]][] : memref> // CHECK: %[[dim:.*]] = dim %[[A]], %[[C0]] : memref @@ -331,7 +331,7 @@ // FULL-UNROLL-SAME: %[[vec:[a-zA-Z0-9]+]]: vector<3x15xf32> func @transfer_write_progressive_unmasked(%A : memref, %base: index, %vec: vector<3x15xf32>) { // CHECK-NOT: scf.if - // CHECK-NEXT: %[[alloc:.*]] = alloca() : memref<3xvector<15xf32>> + // CHECK-NEXT: %[[alloc:.*]] = memref.alloca() : memref<3xvector<15xf32>> // CHECK-NEXT: %[[vmemref:.*]] = vector.type_cast %[[alloc]] : memref<3xvector<15xf32>> to memref> // CHECK-NEXT: store %[[vec]], %[[vmemref]][] : memref> // CHECK-NEXT: affine.for %[[I:.*]] = 0 to 3 { @@ -384,7 +384,7 @@ // CHECK: %[[cst:.*]] = constant 0.000000e+00 : f32 // CHECK: %[[c2:.*]] = constant 2 : index // CHECK: %[[cst0:.*]] = constant dense<0.000000e+00> : vector<3xf32> -// CHECK: %[[m:.*]] = alloca() : memref<3xvector<3xf32>> +// CHECK: %[[m:.*]] = memref.alloca() : memref<3xvector<3xf32>> // CHECK: %[[d:.*]] = dim %[[A]], %[[c2]] : memref // CHECK: affine.for %[[arg1:.*]] = 0 to 3 { // CHECK: %[[cmp:.*]] = cmpi slt, %[[arg1]], %[[d]] : index @@ -413,7 +413,7 @@ // CHECK-SAME: %[[B:.*]]: memref) // CHECK: %[[c0:.*]] = constant 0 : index // CHECK: %[[c2:.*]] = constant 2 : index -// CHECK: %[[m:.*]] = alloca() : memref<3xvector<3xf32>> +// CHECK: %[[m:.*]] = memref.alloca() : memref<3xvector<3xf32>> // CHECK: %[[cast:.*]] = vector.type_cast %[[m]] : memref<3xvector<3xf32>> to memref> // CHECK: store %[[A]], %[[cast]][] : memref> // CHECK: %[[d:.*]] = dim %[[B]], %[[c2]] : memref diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir @@ -4,12 +4,12 @@ func @vector_add_2d(%arg0: index, %arg1: index) -> f32 { // Nothing should be matched in this first block. - // CHECK-NOT:matched: {{.*}} = alloc{{.*}} + // CHECK-NOT:matched: {{.*}} = memref.alloc{{.*}} // CHECK-NOT:matched: {{.*}} = constant 0{{.*}} // CHECK-NOT:matched: {{.*}} = constant 1{{.*}} - %0 = alloc(%arg0, %arg1) : memref - %1 = alloc(%arg0, %arg1) : memref - %2 = alloc(%arg0, %arg1) : memref + %0 = memref.alloc(%arg0, %arg1) : memref + %1 = memref.alloc(%arg0, %arg1) : memref + %2 = memref.alloc(%arg0, %arg1) : memref %c0 = constant 0 : index %cst = constant 1.000000e+00 : f32 diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir @@ -92,9 +92,9 @@ // CHECK-LABEL: func @vector_add_2d func @vector_add_2d(%M : index, %N : index) -> f32 { - %A = alloc (%M, %N) : memref - %B = alloc (%M, %N) : memref - %C = alloc (%M, %N) : memref + %A = memref.alloc (%M, %N) : memref + %B = memref.alloc (%M, %N) : memref + %C = memref.alloc (%M, %N) : memref %f1 = constant 1.0 : f32 %f2 = constant 2.0 : f32 affine.for %i0 = 0 to %M { @@ -309,7 +309,7 @@ // CHECK: affine.for %{{.*}}{{[0-9]*}} = 0 to %{{[0-9]*}} { affine.for %i16 = 0 to %M { // not vectorized, can't vectorize a vector load - %a16 = alloc(%M) : memref> + %a16 = memref.alloc(%M) : memref> %l16 = affine.load %a16[%i16] : memref> } return diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir --- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir +++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir @@ -47,9 +47,9 @@ } func @vector_add_2d(%M : index, %N : index) -> f32 { - %A = alloc (%M, %N) : memref - %B = alloc (%M, %N) : memref - %C = alloc (%M, %N) : memref + %A = memref.alloc (%M, %N) : memref + %B = memref.alloc (%M, %N) : memref + %C = memref.alloc (%M, %N) : memref %f1 = constant 1.0 : f32 %f2 = constant 2.0 : f32 affine.for %i0 = 0 to %M { diff --git a/mlir/test/Dialect/Affine/affine-data-copy.mlir b/mlir/test/Dialect/Affine/affine-data-copy.mlir --- a/mlir/test/Dialect/Affine/affine-data-copy.mlir +++ b/mlir/test/Dialect/Affine/affine-data-copy.mlir @@ -49,7 +49,7 @@ // CHECK: affine.for %[[I:.*]] = 0 to 4096 step 128 { // CHECK: affine.for %[[J:.*]] = 0 to 4096 step 128 { -// CHECK: [[BUFC:%[0-9]+]] = alloc() : memref<128x128xf32> +// CHECK: [[BUFC:%[0-9]+]] = memref.alloc() : memref<128x128xf32> // The result matrix's copy gets hoisted out. // Result matrix copy-in. // CHECK: affine.for %[[II:.*]] = #[[$MAP_IDENTITY]](%{{.*}}) to #[[$MAP_PLUS_128]](%{{.*}}) { @@ -61,7 +61,7 @@ // LHS matrix copy-in. // CHECK: affine.for %[[K:.*]] = 0 to 4096 step 128 { -// CHECK: [[BUFA:%[0-9]+]] = alloc() : memref<128x128xf32> +// CHECK: [[BUFA:%[0-9]+]] = memref.alloc() : memref<128x128xf32> // CHECK: affine.for %[[II:.*]] = #[[$MAP_IDENTITY]](%{{.*}}) to #[[$MAP_PLUS_128]](%{{.*}}) { // CHECK: affine.for %[[KK:.*]] = #[[$MAP_IDENTITY]](%{{.*}}) to #[[$MAP_PLUS_128]](%{{.*}}) { // CHECK: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<4096x4096xf32> @@ -70,7 +70,7 @@ // CHECK: } // RHS matrix copy-in. -// CHECK: [[BUFB:%[0-9]+]] = alloc() : memref<128x128xf32> +// CHECK: [[BUFB:%[0-9]+]] = memref.alloc() : memref<128x128xf32> // CHECK: affine.for %[[KK:.*]] = #[[$MAP_IDENTITY]](%{{.*}}) to #[[$MAP_PLUS_128]](%{{.*}}) { // CHECK: affine.for %[[JJ:.*]] = #[[$MAP_IDENTITY]](%{{.*}}) to #[[$MAP_PLUS_128]](%{{.*}}) { // CHECK: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<4096x4096xf32> @@ -91,8 +91,8 @@ // CHECK: } // CHECK: } // CHECK: } -// CHECK: dealloc [[BUFB]] : memref<128x128xf32> -// CHECK: dealloc [[BUFA]] : memref<128x128xf32> +// CHECK: memref.dealloc [[BUFB]] : memref<128x128xf32> +// CHECK: memref.dealloc [[BUFA]] : memref<128x128xf32> // CHECK: } // Result matrix copy out. @@ -102,15 +102,15 @@ // CHECK: store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<4096x4096xf32> // CHECK: } // CHECK: } -// CHECK: dealloc [[BUFC]] : memref<128x128xf32> +// CHECK: memref.dealloc [[BUFC]] : memref<128x128xf32> // CHECK: } // CHECK: } // Check that only one memref is copied when memref filter is used. // FILTER: affine.for %{{.*}} = 0 to 4096 step 128 { -// FILTER: alloc() : memref<128x4096xf32> -// FILTER-NOT: alloc() +// FILTER: memref.alloc() : memref<128x4096xf32> +// FILTER-NOT: memref.alloc() // FILTER: affine.for // FILTER: affine.for %{{.*}} = 0 to 4096 { // FILTER: affine.for %{{.*}} = 0 to 4096 step 128 { @@ -118,8 +118,8 @@ // FILTER-NEXT: affine.for %{{.*}} = #map{{.*}}(%{{.*}}) to #map{{.*}}(%{{.*}}) { // FILTER-NEXT: affine.for %{{.*}} = #map{{.*}}(%{{.*}}) to #map{{.*}}(%{{.*}}) { // FILTER-NEXT: affine.for %{{.*}} = #map{{.*}}(%{{.*}}) to #map{{.*}}(%{{.*}}) { -// FILTER: dealloc %{{.*}} : memref<128x4096xf32> -// FILTER-NOT: dealloc %{{.*}} : memref<128x4096xf32> +// FILTER: memref.dealloc %{{.*}} : memref<128x4096xf32> +// FILTER-NOT: memref.dealloc %{{.*}} : memref<128x4096xf32> // ----- @@ -145,43 +145,43 @@ } // CHECK-SMALL: affine.for %arg{{.*}} = 0 to 1024 { // CHECK-SMALL: affine.for %arg{{.*}} = 0 to 1024 { -// CHECK-SMALL: alloc() : memref<1x1xf32> +// CHECK-SMALL: memref.alloc() : memref<1x1xf32> // CHECK-SMALL: affine.load %arg{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32> // CHECK-SMALL: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32> // CHECK-SMALL: affine.for %arg{{.*}} = 0 to 1024 { -// CHECK-SMALL: alloc() : memref<1x1xf32> +// CHECK-SMALL: memref.alloc() : memref<1x1xf32> // CHECK-SMALL: affine.load %arg{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32> // CHECK-SMALL: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32> // CHECK-SMALL: affine.load %{{.*}}[0, 0] : memref<1x1xf32> // CHECK-SMALL: affine.load %{{.*}}[0, 0] : memref<1x1xf32> // CHECK-SMALL: addf %{{.*}}, %{{.*}} : f32 // CHECK-SMALL: affine.store %{{.*}}, %{{.*}}[0, 0] : memref<1x1xf32> -// CHECK-SMALL: dealloc %{{.*}} : memref<1x1xf32> +// CHECK-SMALL: memref.dealloc %{{.*}} : memref<1x1xf32> // CHECK-SMALL: } // CHECK-SMALL: affine.load %{{.*}}[0, 0] : memref<1x1xf32> // CHECK-SMALL: affine.store %{{.*}}, %arg{{.*}}[%{{.*}}, %{{.*}}] : memref<1024x1024xf32> -// CHECK-SMALL: dealloc %{{.*}} : memref<1x1xf32> +// CHECK-SMALL: memref.dealloc %{{.*}} : memref<1x1xf32> // CHECK-SMALL: } // CHECK-SMALL: } // CHECK-SMALL: return // Check that only one memref is copied when memref filter is used. -// FILTER: alloc() : memref<1024x1024xf32> -// FILTER-NOT: alloc() +// FILTER: memref.alloc() : memref<1024x1024xf32> +// FILTER-NOT: memref.alloc() // FILTER: affine.for %{{.*}} = 0 to 1024 { // FILTER: affine.for %{{.*}} = 0 to 1024 { // FILTER: affine.for %{{.*}} = 0 to 1024 { // FILTER-NEXT: affine.for %{{.*}} = 0 to 1024 { // FILTER-NEXT: affine.for %{{.*}} = 0 to 1024 { -// FILTER: dealloc %{{.*}} : memref<1024x1024xf32> -// FILTER-NOT: dealloc +// FILTER: memref.dealloc %{{.*}} : memref<1024x1024xf32> +// FILTER-NOT: memref.dealloc // FILTER: return // CHeck that only one memref is copied, because for-memref-region is enabled // (and the first ever encountered load is analyzed). -// MEMREF_REGION: alloc() : memref<1024x1024xf32> -// MEMREF_REGION-NOT: alloc() +// MEMREF_REGION: memref.alloc() : memref<1024x1024xf32> +// MEMREF_REGION-NOT: memref.alloc() // MEMREF_REGION: affine.for %{{.*}} = 0 to 1024 { // MEMREF_REGION: affine.for %{{.*}} = 0 to 1024 { // MEMREF_REGION: } @@ -189,8 +189,8 @@ // MEMREF_REGION-NEXT: affine.for %{{.*}} = 0 to 1024 { // MEMREF_REGION-NEXT: affine.for %{{.*}} = 0 to 1024 { // MEMREF_REGION-NEXT: affine.for %{{.*}} = 0 to 1024 { -// MEMREF_REGION: dealloc %{{.*}} : memref<1024x1024xf32> -// MEMREF_REGION-NOT: dealloc +// MEMREF_REGION: memref.dealloc %{{.*}} : memref<1024x1024xf32> +// MEMREF_REGION-NOT: memref.dealloc // MEMREF_REGION-NEXT: return // ----- @@ -216,7 +216,7 @@ return %A : memref<4096xf32> } // CHECK: affine.for %[[IV1:.*]] = 0 to 4096 step 100 -// CHECK: %[[BUF:.*]] = alloc() : memref<100xf32> +// CHECK: %[[BUF:.*]] = memref.alloc() : memref<100xf32> // CHECK-NEXT: affine.for %[[IV2:.*]] = #[[$MAP_IDENTITY]](%[[IV1]]) to min #[[$MAP_MIN_UB1]](%[[IV1]]) { // CHECK-NEXT: affine.load %{{.*}}[%[[IV2]]] : memref<4096xf32> // CHECK-NEXT: affine.store %{{.*}}, %[[BUF]][%[[IV2]] - %[[IV1]]] : memref<100xf32> @@ -230,7 +230,7 @@ // CHECK-NEXT: affine.load %[[BUF]][%[[IV2]] - %[[IV1]]] : memref<100xf32> // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%[[IV2]]] : memref<4096xf32> // CHECK-NEXT: } -// CHECK-NEXT: dealloc %[[BUF]] : memref<100xf32> +// CHECK-NEXT: memref.dealloc %[[BUF]] : memref<100xf32> // CHECK-NEXT: } // ----- @@ -257,7 +257,7 @@ return } -// CHECK: %[[BUF:.*]] = alloc() : memref<2048x6xf64> +// CHECK: %[[BUF:.*]] = memref.alloc() : memref<2048x6xf64> // CHECK-NEXT: affine.for %[[ii:.*]] = 0 to 2048 { // CHECK-NEXT: affine.for %[[jj:.*]] = max #[[$LB]]()[%[[i]], %[[j]]] to min #[[$UB]]()[%[[i]], %[[j]]] { // CHECK-NEXT: affine.load %{{.*}}[%[[ii]], %[[jj]]] : memref<2048x516xf64> @@ -269,4 +269,4 @@ // CHECK-NEXT: affine.load %[[BUF]][%[[ii_]], %[[jj_]] - symbol(%[[j]]) * 6] : memref<2048x6xf64> // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: dealloc %[[BUF]] : memref<2048x6xf64> +// CHECK-NEXT: memref.dealloc %[[BUF]] : memref<2048x6xf64> diff --git a/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir b/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir --- a/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir +++ b/mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -affine-loop-invariant-code-motion -split-input-file | FileCheck %s func @nested_loops_both_having_invariant_code() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -12,7 +12,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -29,14 +29,14 @@ // CHECK-LABEL: func @store_affine_apply func @store_affine_apply() -> memref<10xf32> { %cf7 = constant 7.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %arg0 = 0 to 10 { %t0 = affine.apply affine_map<(d1) -> (d1 + 1)>(%arg0) affine.store %cf7, %m[%t0] : memref<10xf32> } return %m : memref<10xf32> // CHECK: %cst = constant 7.000000e+00 : f32 -// CHECK-NEXT: %0 = alloc() : memref<10xf32> +// CHECK-NEXT: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: %1 = affine.apply #map{{[0-9]*}}(%arg0) // CHECK-NEXT: affine.store %cst, %0[%1] : memref<10xf32> @@ -47,7 +47,7 @@ // ----- func @nested_loops_code_invariant_to_both() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -57,7 +57,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -68,8 +68,8 @@ // ----- func @single_loop_nothing_invariant() { - %m1 = alloc() : memref<10xf32> - %m2 = alloc() : memref<10xf32> + %m1 = memref.alloc() : memref<10xf32> + %m2 = memref.alloc() : memref<10xf32> affine.for %arg0 = 0 to 10 { %v0 = affine.load %m1[%arg0] : memref<10xf32> %v1 = affine.load %m2[%arg0] : memref<10xf32> @@ -77,8 +77,8 @@ affine.store %v2, %m1[%arg0] : memref<10xf32> } - // CHECK: %0 = alloc() : memref<10xf32> - // CHECK-NEXT: %1 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> + // CHECK-NEXT: %1 = memref.alloc() : memref<10xf32> // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: %2 = affine.load %0[%arg0] : memref<10xf32> // CHECK-NEXT: %3 = affine.load %1[%arg0] : memref<10xf32> @@ -91,7 +91,7 @@ // ----- func @invariant_code_inside_affine_if() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { @@ -103,7 +103,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: %1 = affine.apply #map{{[0-9]*}}(%arg0) @@ -119,7 +119,7 @@ // ----- func @dependent_stores() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -132,7 +132,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -149,7 +149,7 @@ // ----- func @independent_stores() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -162,7 +162,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -179,7 +179,7 @@ // ----- func @load_dependent_store() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -192,7 +192,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -208,7 +208,7 @@ // ----- func @load_after_load() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -221,7 +221,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -237,7 +237,7 @@ // ----- func @invariant_affine_if() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -249,7 +249,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: affine.if #set(%arg0, %arg0) { @@ -264,7 +264,7 @@ // ----- func @invariant_affine_if2() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -276,7 +276,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: affine.for %arg1 = 0 to 10 { @@ -293,7 +293,7 @@ // ----- func @invariant_affine_nested_if() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -307,7 +307,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: affine.for %arg1 = 0 to 10 { @@ -327,7 +327,7 @@ // ----- func @invariant_affine_nested_if_else() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -343,7 +343,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: affine.for %arg1 = 0 to 10 { @@ -365,8 +365,8 @@ // ----- func @invariant_affine_nested_if_else2() { - %m = alloc() : memref<10xf32> - %m2 = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> + %m2 = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -382,8 +382,8 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> - // CHECK-NEXT: %1 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> + // CHECK-NEXT: %1 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: affine.if #set(%arg0, %arg0) { @@ -403,7 +403,7 @@ // ----- func @invariant_affine_nested_if2() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -417,7 +417,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: affine.if #set(%arg0, %arg0) { @@ -435,7 +435,7 @@ // ----- func @invariant_affine_for_inside_affine_if() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -449,7 +449,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: affine.for %arg1 = 0 to 10 { @@ -469,16 +469,16 @@ // ----- func @invariant_constant_and_load() { - %m = alloc() : memref<100xf32> - %m2 = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> + %m2 = memref.alloc() : memref<100xf32> affine.for %arg0 = 0 to 5 { %c0 = constant 0 : index %v = affine.load %m2[%c0] : memref<100xf32> affine.store %v, %m[%arg0] : memref<100xf32> } - // CHECK: %0 = alloc() : memref<100xf32> - // CHECK-NEXT: %1 = alloc() : memref<100xf32> + // CHECK: %0 = memref.alloc() : memref<100xf32> + // CHECK-NEXT: %1 = memref.alloc() : memref<100xf32> // CHECK-NEXT: %c0 = constant 0 : index // CHECK-NEXT: %2 = affine.load %1[%c0] : memref<100xf32> // CHECK-NEXT: affine.for %arg0 = 0 to 5 { @@ -491,7 +491,7 @@ // ----- func @nested_load_store_same_memref() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cst = constant 8.0 : f32 %c0 = constant 0 : index affine.for %arg0 = 0 to 10 { @@ -501,7 +501,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: %c0 = constant 0 : index // CHECK-NEXT: affine.for %arg0 = 0 to 10 { @@ -516,7 +516,7 @@ // ----- func @nested_load_store_same_memref2() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cst = constant 8.0 : f32 %c0 = constant 0 : index affine.for %arg0 = 0 to 10 { @@ -526,7 +526,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: %c0 = constant 0 : index // CHECK-NEXT: affine.for %arg0 = 0 to 10 { @@ -541,7 +541,7 @@ // CHECK-LABEL: func @do_not_hoist_dependent_side_effect_free_op func @do_not_hoist_dependent_side_effect_free_op(%arg0: memref<10x512xf32>) { - %0 = alloca() : memref<1xf32> + %0 = memref.alloca() : memref<1xf32> %cst = constant 8.0 : f32 affine.for %i = 0 to 512 { affine.for %j = 0 to 10 { @@ -571,8 +571,8 @@ // CHECK-LABEL: func @vector_loop_nothing_invariant func @vector_loop_nothing_invariant() { - %m1 = alloc() : memref<40xf32> - %m2 = alloc() : memref<40xf32> + %m1 = memref.alloc() : memref<40xf32> + %m2 = memref.alloc() : memref<40xf32> affine.for %arg0 = 0 to 10 { %v0 = affine.vector_load %m1[%arg0*4] : memref<40xf32>, vector<4xf32> %v1 = affine.vector_load %m2[%arg0*4] : memref<40xf32>, vector<4xf32> @@ -593,9 +593,9 @@ // CHECK-LABEL: func @vector_loop_all_invariant func @vector_loop_all_invariant() { - %m1 = alloc() : memref<4xf32> - %m2 = alloc() : memref<4xf32> - %m3 = alloc() : memref<4xf32> + %m1 = memref.alloc() : memref<4xf32> + %m2 = memref.alloc() : memref<4xf32> + %m3 = memref.alloc() : memref<4xf32> affine.for %arg0 = 0 to 10 { %v0 = affine.vector_load %m1[0] : memref<4xf32>, vector<4xf32> %v1 = affine.vector_load %m2[0] : memref<4xf32>, vector<4xf32> @@ -605,9 +605,9 @@ return } -// CHECK: alloc() -// CHECK-NEXT: alloc() -// CHECK-NEXT: alloc() +// CHECK: memref.alloc() +// CHECK-NEXT: memref.alloc() +// CHECK-NEXT: memref.alloc() // CHECK-NEXT: affine.vector_load // CHECK-NEXT: affine.vector_load // CHECK-NEXT: addf diff --git a/mlir/test/Dialect/Affine/affine-loop-normalize.mlir b/mlir/test/Dialect/Affine/affine-loop-normalize.mlir --- a/mlir/test/Dialect/Affine/affine-loop-normalize.mlir +++ b/mlir/test/Dialect/Affine/affine-loop-normalize.mlir @@ -9,7 +9,7 @@ // CHECK-LABEL: func @normalize_parallel() func @normalize_parallel() { %cst = constant 1.0 : f32 - %0 = alloc() : memref<2x4xf32> + %0 = memref.alloc() : memref<2x4xf32> // CHECK: affine.parallel (%[[i0:.*]], %[[j0:.*]]) = (0, 0) to (4, 2) affine.parallel (%i, %j) = (0, 1) to (10, 5) step (3, 2) { // CHECK: %[[i1:.*]] = affine.apply [[$MAP0]](%[[i0]]) diff --git a/mlir/test/Dialect/Affine/canonicalize.mlir b/mlir/test/Dialect/Affine/canonicalize.mlir --- a/mlir/test/Dialect/Affine/canonicalize.mlir +++ b/mlir/test/Dialect/Affine/canonicalize.mlir @@ -7,7 +7,7 @@ // CHECK-LABEL: func @compose_affine_maps_1dto2d_no_symbols() { func @compose_affine_maps_1dto2d_no_symbols() { - %0 = alloc() : memref<4x4xf32> + %0 = memref.alloc() : memref<4x4xf32> affine.for %i0 = 0 to 15 { // Test load[%x, %x] @@ -26,21 +26,21 @@ %y1_1 = affine.apply affine_map<(d0, d1) -> (d1)> (%y0, %y0) // CHECK-NEXT: %[[I1A:.*]] = affine.apply #[[$MAP1]](%{{.*}}) - // CHECK-NEXT: store %[[V0]], %0[%[[I1A]], %[[I1A]]] - store %v0, %0[%y1_0, %y1_1] : memref<4x4xf32> + // CHECK-NEXT: memref.store %[[V0]], %0[%[[I1A]], %[[I1A]]] + memref.store %v0, %0[%y1_0, %y1_1] : memref<4x4xf32> // Test store[%x, %y] %xy_0 = affine.apply affine_map<(d0, d1) -> (d0)> (%x0, %y0) %xy_1 = affine.apply affine_map<(d0, d1) -> (d1)> (%x0, %y0) - // CHECK-NEXT: store %[[V0]], %0[%[[I0A]], %[[I1A]]] - store %v0, %0[%xy_0, %xy_1] : memref<4x4xf32> + // CHECK-NEXT: memref.store %[[V0]], %0[%[[I0A]], %[[I1A]]] + memref.store %v0, %0[%xy_0, %xy_1] : memref<4x4xf32> // Test store[%y, %x] %yx_0 = affine.apply affine_map<(d0, d1) -> (d0)> (%y0, %x0) %yx_1 = affine.apply affine_map<(d0, d1) -> (d1)> (%y0, %x0) - // CHECK-NEXT: store %[[V0]], %0[%[[I1A]], %[[I0A]]] - store %v0, %0[%yx_0, %yx_1] : memref<4x4xf32> + // CHECK-NEXT: memref.store %[[V0]], %0[%[[I1A]], %[[I0A]]] + memref.store %v0, %0[%yx_0, %yx_1] : memref<4x4xf32> } return } @@ -53,7 +53,7 @@ // CHECK-LABEL: func @compose_affine_maps_1dto2d_with_symbols() { func @compose_affine_maps_1dto2d_with_symbols() { - %0 = alloc() : memref<4x4xf32> + %0 = memref.alloc() : memref<4x4xf32> affine.for %i0 = 0 to 15 { // Test load[%x0, %x0] with symbol %c4 @@ -68,22 +68,22 @@ %x1 = affine.apply affine_map<(d0) -> (d0 + 1)> (%i0) %y1 = affine.apply affine_map<(d0, d1) -> (d0+d1)> (%x0, %x1) // CHECK-NEXT: %[[I1:.*]] = affine.apply #[[$MAP7]](%{{.*}}) - // CHECK-NEXT: store %[[V0]], %{{.*}}[%[[I1]], %[[I1]]] - store %v0, %0[%y1, %y1] : memref<4x4xf32> + // CHECK-NEXT: memref.store %[[V0]], %{{.*}}[%[[I1]], %[[I1]]] + memref.store %v0, %0[%y1, %y1] : memref<4x4xf32> // Test store[%x1, %x0] with symbol %c4 captured by '%x0' map. %y2 = affine.apply affine_map<(d0, d1) -> (d0 + d1)> (%x1, %x0) // CHECK-NEXT: %[[I2:.*]] = affine.apply #[[$MAP7]](%{{.*}}) - // CHECK-NEXT: store %[[V0]], %{{.*}}[%[[I2]], %[[I2]]] - store %v0, %0[%y2, %y2] : memref<4x4xf32> + // CHECK-NEXT: memref.store %[[V0]], %{{.*}}[%[[I2]], %[[I2]]] + memref.store %v0, %0[%y2, %y2] : memref<4x4xf32> // Test store[%x2, %x0] with symbol %c4 from '%x0' and %c5 from '%x2' %c5 = constant 5 : index %x2 = affine.apply affine_map<(d0)[s0] -> (d0 + s0)> (%i0)[%c5] %y3 = affine.apply affine_map<(d0, d1) -> (d0 + d1)> (%x2, %x0) // CHECK: %[[I3:.*]] = affine.apply #[[$MAP7a]](%{{.*}}) - // CHECK-NEXT: store %[[V0]], %{{.*}}[%[[I3]], %[[I3]]] - store %v0, %0[%y3, %y3] : memref<4x4xf32> + // CHECK-NEXT: memref.store %[[V0]], %{{.*}}[%[[I3]], %[[I3]]] + memref.store %v0, %0[%y3, %y3] : memref<4x4xf32> } return } @@ -95,8 +95,8 @@ // CHECK-LABEL: func @compose_affine_maps_2d_tile() { func @compose_affine_maps_2d_tile() { - %0 = alloc() : memref<16x32xf32> - %1 = alloc() : memref<16x32xf32> + %0 = memref.alloc() : memref<16x32xf32> + %1 = memref.alloc() : memref<16x32xf32> %c4 = constant 4 : index %c8 = constant 8 : index @@ -119,8 +119,8 @@ // CHECK-NEXT: %[[L0:.*]] = load %{{.*}}[%[[I0]], %[[I1]]] %v0 = load %0[%x40, %x41] : memref<16x32xf32> - // CHECK-NEXT: store %[[L0]], %{{.*}}[%[[I0]], %[[I1]]] - store %v0, %1[%x40, %x41] : memref<16x32xf32> + // CHECK-NEXT: memref.store %[[L0]], %{{.*}}[%[[I0]], %[[I1]]] + memref.store %v0, %1[%x40, %x41] : memref<16x32xf32> } } } @@ -138,8 +138,8 @@ // CHECK-LABEL: func @compose_affine_maps_dependent_loads() { func @compose_affine_maps_dependent_loads() { - %0 = alloc() : memref<16x32xf32> - %1 = alloc() : memref<16x32xf32> + %0 = memref.alloc() : memref<16x32xf32> + %1 = memref.alloc() : memref<16x32xf32> affine.for %i0 = 0 to 3 { affine.for %i1 = 0 to 3 { @@ -160,12 +160,12 @@ // CHECK-NEXT: %[[V0:.*]] = load %{{.*}}[%[[I0]], %[[I1]]] %v0 = load %0[%x00, %x01] : memref<16x32xf32> - // CHECK-NEXT: store %[[V0]], %{{.*}}[%[[I0]], %[[I2]]] - store %v0, %0[%x00, %x02] : memref<16x32xf32> + // CHECK-NEXT: memref.store %[[V0]], %{{.*}}[%[[I0]], %[[I2]]] + memref.store %v0, %0[%x00, %x02] : memref<16x32xf32> // Swizzle %i0, %i1 - // CHECK-NEXT: store %[[V0]], %{{.*}}[%[[I1]], %[[I0]]] - store %v0, %0[%x01, %x00] : memref<16x32xf32> + // CHECK-NEXT: memref.store %[[V0]], %{{.*}}[%[[I1]], %[[I0]]] + memref.store %v0, %0[%x01, %x00] : memref<16x32xf32> // Swizzle %x00, %x01 and %c3, %c7 %x10 = affine.apply affine_map<(d0, d1)[s0, s1] -> (d0 * s1)> @@ -175,8 +175,8 @@ // CHECK-NEXT: %[[I2A:.*]] = affine.apply #[[$MAP12]](%{{.*}}) // CHECK-NEXT: %[[I2B:.*]] = affine.apply #[[$MAP11]](%{{.*}}) - // CHECK-NEXT: store %[[V0]], %{{.*}}[%[[I2A]], %[[I2B]]] - store %v0, %0[%x10, %x11] : memref<16x32xf32> + // CHECK-NEXT: memref.store %[[V0]], %{{.*}}[%[[I2A]], %[[I2B]]] + memref.store %v0, %0[%x10, %x11] : memref<16x32xf32> } } } @@ -198,8 +198,8 @@ %d1 = affine.apply affine_map<(d0, d1) -> (d1 floordiv 3)> (%b, %c) // CHECK: %[[I0:.*]] = affine.apply #[[$MAP13A]](%{{.*}}) // CHECK: %[[I1:.*]] = affine.apply #[[$MAP13B]](%{{.*}}) - // CHECK-NEXT: store %arg0, %arg1[%[[I0]], %[[I1]]] - store %arg0, %arg1[%d0, %d1] : memref<4x4xf32> + // CHECK-NEXT: memref.store %arg0, %arg1[%[[I0]], %[[I1]]] + memref.store %arg0, %arg1[%d0, %d1] : memref<4x4xf32> } return @@ -223,16 +223,16 @@ // CHECK-LABEL: func @arg_used_as_dim_and_symbol func @arg_used_as_dim_and_symbol(%arg0: memref<100x100xf32>, %arg1: index, %arg2: f32) { %c9 = constant 9 : index - %1 = alloc() : memref<100x100xf32, 1> - %2 = alloc() : memref<1xi32> + %1 = memref.alloc() : memref<100x100xf32, 1> + %2 = memref.alloc() : memref<1xi32> affine.for %i0 = 0 to 100 { affine.for %i1 = 0 to 100 { %3 = affine.apply affine_map<(d0, d1)[s0, s1] -> (d1 + s0 + s1)> (%i0, %i1)[%arg1, %c9] %4 = affine.apply affine_map<(d0, d1, d3) -> (d3 - (d0 + d1))> (%arg1, %c9, %3) - // CHECK: store %arg2, %{{.*}}[%{{.*}}, %{{.*}}] - store %arg2, %1[%4, %arg1] : memref<100x100xf32, 1> + // CHECK: memref.store %arg2, %{{.*}}[%{{.*}}, %{{.*}}] + memref.store %arg2, %1[%4, %arg1] : memref<100x100xf32, 1> } } return @@ -244,17 +244,17 @@ func @trivial_maps() { // CHECK-NOT: affine.apply - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %c0 = constant 0 : index %cst = constant 0.000000e+00 : f32 affine.for %i1 = 0 to 10 { %1 = affine.apply affine_map<()[s0] -> (s0)>()[%c0] - store %cst, %0[%1] : memref<10xf32> + memref.store %cst, %0[%1] : memref<10xf32> %2 = load %0[%c0] : memref<10xf32> %3 = affine.apply affine_map<()[] -> (0)>()[] - store %cst, %0[%3] : memref<10xf32> - store %2, %0[%c0] : memref<10xf32> + memref.store %cst, %0[%3] : memref<10xf32> + memref.store %2, %0[%c0] : memref<10xf32> } return } @@ -422,7 +422,7 @@ %1 = affine.apply affine_map<()[s0] -> (s0 + 1)> ()[%M] %2 = affine.apply affine_map<(d0)[s0] -> (d0 floordiv s0)> (%i0)[%1] // CHECK-DAG: {{.*}} = affine.apply #[[$symbolic_semi_affine]](%{{.*}})[%{{.*}}] - store %f1, %A[%2] : memref + memref.store %f1, %A[%2] : memref } return } @@ -667,7 +667,7 @@ %cst = constant 1.0 : f32 %c0 = constant 0 : index %c4 = constant 4 : index - %0 = alloc() : memref<4xf32> + %0 = memref.alloc() : memref<4xf32> // CHECK: affine.parallel (%{{.*}}) = (0) to (4) affine.parallel (%i) = (%c0) to (%c0 + %c4) { %1 = affine.apply #map3(%i) @@ -686,11 +686,11 @@ %1 = affine.apply affine_map<()[s0] -> (3 * s0)> ()[%i0] %2 = affine.apply affine_map<(d0)[s0, s1] -> (d0 mod s1 + s0 * s1 + s0 * 4)> (%i1)[%0, %1] %3 = index_cast %2: index to i64 - store %3, %A[]: memref + memref.store %3, %A[]: memref affine.for %i2 = 0 to 3 { %4 = affine.apply affine_map<(d0)[s0, s1] -> (d0 ceildiv s1 + s0 + s0 * 3)> (%i2)[%0, %1] %5 = index_cast %4: index to i64 - store %5, %A[]: memref + memref.store %5, %A[]: memref } return } diff --git a/mlir/test/Dialect/Affine/dma-generate.mlir b/mlir/test/Dialect/Affine/dma-generate.mlir --- a/mlir/test/Dialect/Affine/dma-generate.mlir +++ b/mlir/test/Dialect/Affine/dma-generate.mlir @@ -14,21 +14,21 @@ // CHECK-LABEL: func @loop_nest_1d() { func @loop_nest_1d() { - %A = alloc() : memref<256 x f32> - %B = alloc() : memref<512 x f32> - %F = alloc() : memref<256 x f32, 2> + %A = memref.alloc() : memref<256 x f32> + %B = memref.alloc() : memref<512 x f32> + %F = memref.alloc() : memref<256 x f32, 2> // First DMA buffer. - // CHECK: alloc() : memref<256xf32> - // CHECK: alloc() : memref<256xf32, 2> + // CHECK: memref.alloc() : memref<256xf32> + // CHECK: memref.alloc() : memref<256xf32, 2> // Tag for first DMA. - // CHECK: alloc() : memref<1xi32> + // CHECK: memref.alloc() : memref<1xi32> // First DMA transfer. // CHECK: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<256xf32>, memref<256xf32, 2>, memref<1xi32> // CHECK: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> // Second DMA buffer. - // CHECK: alloc() : memref<256xf32, 2> + // CHECK: memref.alloc() : memref<256xf32, 2> // Tag for second DMA. - // CHECK: alloc() : memref<1xi32> + // CHECK: memref.alloc() : memref<1xi32> // Second DMA transfer. // CHECK: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<512xf32>, memref<256xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> @@ -58,13 +58,13 @@ // CHECK-LABEL: func @loop_nest_high_d // CHECK: %{{.*}} = constant 16384 : index -// CHECK-DAG: [[BUFB:%[0-9]+]] = alloc() : memref<512x32xf32, 2> -// CHECK-DAG: [[BUFA:%[0-9]+]] = alloc() : memref<512x32xf32, 2> -// CHECK-DAG: [[BUFC:%[0-9]+]] = alloc() : memref<512x32xf32, 2> -// CHECK-DAG: [[TAGB:%[0-9]+]] = alloc() : memref<1xi32> -// CHECK-DAG: [[TAGA:%[0-9]+]] = alloc() : memref<1xi32> -// CHECK-DAG: [[TAGC:%[0-9]+]] = alloc() : memref<1xi32> -// CHECK-DAG: [[TAGC_W:%[0-9]+]] = alloc() : memref<1xi32> +// CHECK-DAG: [[BUFB:%[0-9]+]] = memref.alloc() : memref<512x32xf32, 2> +// CHECK-DAG: [[BUFA:%[0-9]+]] = memref.alloc() : memref<512x32xf32, 2> +// CHECK-DAG: [[BUFC:%[0-9]+]] = memref.alloc() : memref<512x32xf32, 2> +// CHECK-DAG: [[TAGB:%[0-9]+]] = memref.alloc() : memref<1xi32> +// CHECK-DAG: [[TAGA:%[0-9]+]] = memref.alloc() : memref<1xi32> +// CHECK-DAG: [[TAGC:%[0-9]+]] = memref.alloc() : memref<1xi32> +// CHECK-DAG: [[TAGC_W:%[0-9]+]] = memref.alloc() : memref<1xi32> // INCOMING DMA for B // CHECK-DAG: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], [[BUFB]][%{{.*}}, %{{.*}}], [[TAGB]][%{{.*}}], %{{.*}} : memref<512x32xf32>, memref<512x32xf32, 2>, memref<1xi32> // CHECK-DAG: affine.dma_wait [[TAGB]][%{{.*}}], %{{.*}} : memref<1xi32> @@ -145,10 +145,10 @@ // region within a 256 x 8 memref. // // CHECK-LABEL: func @loop_nest_modulo() { -// CHECK: alloc() : memref<256x8xf32> +// CHECK: memref.alloc() : memref<256x8xf32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 32 step 4 { -// CHECK: alloc() : memref<1x2xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<1x2xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // Composition of the affine map for '%{{.*}}' causes '%{{.*}}' to be added as a symbol. // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}, 0], %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<256x8xf32>, memref<1x2xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> @@ -161,7 +161,7 @@ // CHECK-NEXT: } // CHECK-NEXT: return func @loop_nest_modulo() { - %A = alloc() : memref<256 x 8 x f32> + %A = memref.alloc() : memref<256 x 8 x f32> affine.for %i = 0 to 32 step 4 { // DMAs will be performed at this level (%j is the first unit stride loop) affine.for %j = 0 to 8 { @@ -179,11 +179,11 @@ // dependent on outer loop IVs. // CHECK-LABEL: func @loop_nest_tiled() -> memref<256x1024xf32> { func @loop_nest_tiled() -> memref<256x1024xf32> { - %0 = alloc() : memref<256x1024xf32> + %0 = memref.alloc() : memref<256x1024xf32> affine.for %i0 = 0 to 256 step 32 { affine.for %i1 = 0 to 1024 step 32 { -// CHECK: alloc() : memref<32x32xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<32x32xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // Strided DMA here: 32 x 32 tile in a 256 x 1024 memref. // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}, %{{.*}}, %{{.*}} : memref<256x1024xf32>, memref<32x32xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait @@ -206,8 +206,8 @@ func @dma_constant_dim_access(%A : memref<100x100xf32>) { %one = constant 1 : index %N = constant 100 : index - // CHECK: alloc() : memref<1x100xf32, 2> - // CHECK-NEXT: alloc() : memref<1xi32> + // CHECK: memref.alloc() : memref<1x100xf32, 2> + // CHECK-NEXT: memref.alloc() : memref<1xi32> // No strided DMA needed here. // CHECK: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<100x100xf32>, memref<1x100xf32, 2>, // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> @@ -232,8 +232,8 @@ } } return -// CHECK: alloc() : memref<100x100xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<100x100xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[0, symbol(%{{.*}}) + 9], %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} // CHECK-NEXT: affine.for %[[IV0:.*]] = 0 to 100 { @@ -251,8 +251,8 @@ %K = constant 9 : index // The buffer size can't be bound by a constant smaller than the original // memref size; so the DMA buffer is the entire 100x100. -// CHECK: alloc() : memref<100x100xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<100x100xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<100x100xf32>, memref<100x100xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> affine.for %i = 0 to 100 { @@ -315,7 +315,7 @@ // CHECK-LABEL: func @multi_load_store_union() { func @multi_load_store_union() { - %A = alloc() : memref<512 x 512 x f32> + %A = memref.alloc() : memref<512 x 512 x f32> affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { %idx = affine.apply affine_map<(d0) -> (d0 + 64)>(%i) @@ -335,12 +335,12 @@ } return } -// CHECK: alloc() : memref<512x512xf32> -// CHECK-NEXT: alloc() : memref<382x446xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<512x512xf32> +// CHECK-NEXT: memref.alloc() : memref<382x446xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}, %{{.*}}, %{{.*}} : memref<512x512xf32>, memref<382x446xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 256 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 256 { // CHECK: affine.load %{{.*}}[%{{.*}}, %{{.*}} + 126] : memref<382x446xf32, 2> @@ -363,7 +363,7 @@ func @dma_loop_straightline_interspersed() { %c0 = constant 0 : index %c255 = constant 255 : index - %A = alloc() : memref<256 x f32> + %A = memref.alloc() : memref<256 x f32> %v = affine.load %A[%c0] : memref<256 x f32> affine.for %i = 1 to 255 { affine.load %A[%i] : memref<256 x f32> @@ -374,16 +374,16 @@ } // There are three regions here - the 'load' preceding the loop, the loop // itself, and the operations appearing after the scf. -// CHECK: alloc() : memref<256xf32> -// CHECK-NEXT: alloc() : memref<1xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<256xf32> +// CHECK-NEXT: memref.alloc() : memref<1xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<256xf32>, memref<1xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32, 2> // CHECK-NEXT: dealloc %{{.*}} : memref<1xi32> // CHECK-NEXT: dealloc %{{.*}} : memref<1xf32, 2> -// CHECK-NEXT: alloc() : memref<254xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK-NEXT: memref.alloc() : memref<254xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<256xf32>, memref<254xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> // CHECK-NEXT: affine.for %{{.*}} = 1 to 255 { @@ -391,11 +391,11 @@ // CHECK-NEXT: } // CHECK-NEXT: dealloc %{{.*}} : memref<1xi32> // CHECK-NEXT: dealloc %{{.*}} : memref<254xf32, 2> -// CHECK-NEXT: alloc() : memref<256xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK-NEXT: memref.alloc() : memref<256xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<256xf32>, memref<256xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.load %{{.*}}[255] : memref<256xf32, 2> // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<256xf32, 2> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<256xf32, 2>, memref<256xf32>, memref<1xi32> @@ -410,7 +410,7 @@ // CHECK-LABEL: func @dma_mixed_loop_blocks() { func @dma_mixed_loop_blocks() { %c0 = constant 0 : index - %A = alloc() : memref<256 x 256 x vector<8 x f32>> + %A = memref.alloc() : memref<256 x 256 x vector<8 x f32>> affine.for %i = 0 to 256 { %v = affine.load %A[%c0, %c0] : memref<256 x 256 x vector<8 x f32>> "foo"(%v) : (vector<8 x f32>) -> () @@ -421,9 +421,9 @@ } return } -// CHECK-DAG: [[MEM:%[0-9]+]] = alloc() : memref<256x256xvector<8xf32>> -// CHECK-DAG: [[BUF:%[0-9]+]] = alloc() : memref<256x256xvector<8xf32>, 2> -// CHECK-DAG: [[TAG:%[0-9]+]] = alloc() : memref<1xi32> +// CHECK-DAG: [[MEM:%[0-9]+]] = memref.alloc() : memref<256x256xvector<8xf32>> +// CHECK-DAG: [[BUF:%[0-9]+]] = memref.alloc() : memref<256x256xvector<8xf32>, 2> +// CHECK-DAG: [[TAG:%[0-9]+]] = memref.alloc() : memref<1xi32> // CHECK: affine.dma_start [[MEM]][%{{.*}}, %{{.*}}], [[BUF]][%{{.*}}, %{{.*}}], [[TAG]][%{{.*}}], %{{.*}} : memref<256x256xvector<8xf32>>, memref<256x256xvector<8xf32>, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait [[TAG]][%{{.*}}], %{{.*}} : memref<1xi32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 256 { @@ -443,8 +443,8 @@ } return } -// CHECK: [[BUF:%[0-9]+]] = alloc() : memref<1027xf32, 2> -// CHECK-NEXT: [[MEM:%[0-9]+]] = alloc() : memref<1xi32> +// CHECK: [[BUF:%[0-9]+]] = memref.alloc() : memref<1027xf32, 2> +// CHECK-NEXT: [[MEM:%[0-9]+]] = memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 1024 { // CHECK-NEXT: affine.for %[[I2:.*]] = {{#map[0-9]+}}(%{{.*}}) to {{#map[0-9]+}}(%{{.*}}) { // CHECK: affine.store %{{.*}}, [[BUF]][%[[I2]]] : memref<1027xf32, 2> @@ -456,7 +456,7 @@ // ----- func @test_read_write_region_union() { - %0 = alloc() : memref<256xf32> + %0 = memref.alloc() : memref<256xf32> affine.for %i0 = 0 to 10 { // memref dims: [0, 256) // read region: [100, 110) @@ -470,12 +470,12 @@ return } -// CHECK: alloc() : memref<256xf32> -// CHECK-NEXT: alloc() : memref<85xf32, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<256xf32> +// CHECK-NEXT: memref.alloc() : memref<85xf32, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<256xf32>, memref<85xf32, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 10 { // CHECK: affine.load %{{.*}}[%{{.*}} + 75] : memref<85xf32, 2> // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<85xf32, 2> @@ -493,8 +493,8 @@ // CHECK-LABEL: func @test_analysis_util func @test_analysis_util(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9xf32>, %arg2: memref<2xf32>) -> (memref<144x9xf32>, memref<2xf32>) { %c0 = constant 0 : index - %0 = alloc() : memref<64x1xf32> - %1 = alloc() : memref<144x4xf32> + %0 = memref.alloc() : memref<64x1xf32> + %1 = memref.alloc() : memref<144x4xf32> %2 = constant 0.0 : f32 affine.for %i8 = 0 to 9 step 3 { affine.for %i9 = #map_lb(%i8) to #map_ub(%i8) { @@ -510,7 +510,7 @@ return %arg1, %arg2 : memref<144x9xf32>, memref<2xf32> } // CHECK: affine.for %{{.*}} = 0 to 9 step 3 { -// CHECK: [[BUF:%[0-9]+]] = alloc() : memref<2xf32, 2> +// CHECK: [[BUF:%[0-9]+]] = memref.alloc() : memref<2xf32, 2> // CHECK: affine.dma_start %{{.*}}[%{{.*}} floordiv 8], [[BUF]] // CHECK: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> // CHECK: affine.for %{{.*}} = @@ -539,8 +539,8 @@ return %arg1, %arg2 : memref<144x9xvector<8x128xf32>>, memref<2xvector<8x128xf32>> } -// CHECK: alloc() : memref<4x4x16x1xvector<8x128xf32>, 2> -// CHECK-NEXT: alloc() : memref<1xi32> +// CHECK: memref.alloc() : memref<4x4x16x1xvector<8x128xf32>, 2> +// CHECK-NEXT: memref.alloc() : memref<1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}], %{{.*}}[%{{.*}}], %{{.*}} : memref<4x4x16x1xvector<8x128xf32>>, memref<4x4x16x1xvector<8x128xf32>, 2>, memref<1xi32> // CHECK-NEXT: affine.dma_wait %{{.*}}[%{{.*}}], %{{.*}} : memref<1xi32> @@ -553,7 +553,7 @@ func @load_store_same_memref(%arg0: memref<256x1024xf32>) { // FAST-MEM-16KB: affine.for %{{.*}} = 0 to 256 step 4 affine.for %i0 = 0 to 256 step 4 { - // FAST-MEM-16KB: [[BUF:%[0-9]+]] = alloc() : memref<4x1024xf32, 2> + // FAST-MEM-16KB: [[BUF:%[0-9]+]] = memref.alloc() : memref<4x1024xf32, 2> // FAST-MEM-16KB: affine.dma_start %{{.*}} // FAST-MEM-16KB-NEXT: affine.dma_wait // FAST-MEM-16KB: affine.for %{{.*}} diff --git a/mlir/test/Dialect/Affine/dma.mlir b/mlir/test/Dialect/Affine/dma.mlir --- a/mlir/test/Dialect/Affine/dma.mlir +++ b/mlir/test/Dialect/Affine/dma.mlir @@ -4,9 +4,9 @@ // Test with loop IVs. func @test0(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> - %1 = alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> - %2 = alloc() : memref<1xi32> + %0 = memref.alloc() : memref<100x100xf32> + %1 = memref.alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %2 = memref.alloc() : memref<1xi32> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { @@ -25,9 +25,9 @@ // Test with loop IVs and optional stride arguments. func @test1(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> - %1 = alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> - %2 = alloc() : memref<1xi32> + %0 = memref.alloc() : memref<100x100xf32> + %1 = memref.alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %2 = memref.alloc() : memref<1xi32> %c0 = constant 0 : index %c64 = constant 64 : index %c128 = constant 128 : index @@ -48,9 +48,9 @@ // Test with loop IVs and symbols (without symbol keyword). func @test2(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> - %1 = alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> - %2 = alloc() : memref<1xi32> + %0 = memref.alloc() : memref<100x100xf32> + %1 = memref.alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %2 = memref.alloc() : memref<1xi32> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { @@ -70,9 +70,9 @@ // Test with loop IVs and symbols (with symbol keyword). func @test3(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> - %1 = alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> - %2 = alloc() : memref<1xi32> + %0 = memref.alloc() : memref<100x100xf32> + %1 = memref.alloc() : memref<100x100xf32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %2 = memref.alloc() : memref<1xi32> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { @@ -93,9 +93,9 @@ // Test with loop IVs, symbols and constants in nested affine expressions. func @test4(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> - %1 = alloc() : memref<100x100xf32, 2> - %2 = alloc() : memref<1xi32> + %0 = memref.alloc() : memref<100x100xf32> + %1 = memref.alloc() : memref<100x100xf32, 2> + %2 = memref.alloc() : memref<1xi32> %c64 = constant 64 : index affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { diff --git a/mlir/test/Dialect/Affine/invalid.mlir b/mlir/test/Dialect/Affine/invalid.mlir --- a/mlir/test/Dialect/Affine/invalid.mlir +++ b/mlir/test/Dialect/Affine/invalid.mlir @@ -121,7 +121,7 @@ func @affine_if_invalid_dimop_dim(%arg0: index, %arg1: index, %arg2: index, %arg3: index) { affine.for %n0 = 0 to 7 { - %0 = alloc(%arg0, %arg1, %arg2, %arg3) : memref + %0 = memref.alloc(%arg0, %arg1, %arg2, %arg3) : memref %c0 = constant 0 : index %dim = dim %0, %c0 : memref @@ -253,7 +253,7 @@ // ----- func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> // expected-error@+1 {{reduction must be specified for each output}} %1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) -> (f32) { %2 = affine.load %0[%i, %j] : memref<100x100xf32> @@ -265,7 +265,7 @@ // ----- func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> // expected-error@+1 {{invalid reduction value: "bad"}} %1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) reduce ("bad") -> (f32) { %2 = affine.load %0[%i, %j] : memref<100x100xf32> @@ -277,7 +277,7 @@ // ----- func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<100x100xi32> + %0 = memref.alloc() : memref<100x100xi32> %1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) reduce ("minf") -> (f32) { %2 = affine.load %0[%i, %j] : memref<100x100xi32> // expected-error@+1 {{types mismatch between yield op and its parent}} @@ -289,7 +289,7 @@ // ----- func @vector_load_invalid_vector_type() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> affine.for %i0 = 0 to 16 step 8 { // expected-error@+1 {{requires memref and vector types of the same elemental type}} %1 = affine.vector_load %0[%i0] : memref<100xf32>, vector<8xf64> @@ -300,7 +300,7 @@ // ----- func @vector_store_invalid_vector_type() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %1 = constant dense<7.0> : vector<8xf64> affine.for %i0 = 0 to 16 step 8 { // expected-error@+1 {{requires memref and vector types of the same elemental type}} @@ -312,7 +312,7 @@ // ----- func @vector_load_vector_memref() { - %0 = alloc() : memref<100xvector<8xf32>> + %0 = memref.alloc() : memref<100xvector<8xf32>> affine.for %i0 = 0 to 4 { // expected-error@+1 {{requires memref and vector types of the same elemental type}} %1 = affine.vector_load %0[%i0] : memref<100xvector<8xf32>>, vector<8xf32> @@ -323,7 +323,7 @@ // ----- func @vector_store_vector_memref() { - %0 = alloc() : memref<100xvector<8xf32>> + %0 = memref.alloc() : memref<100xvector<8xf32>> %1 = constant dense<7.0> : vector<8xf32> affine.for %i0 = 0 to 4 { // expected-error@+1 {{requires memref and vector types of the same elemental type}} diff --git a/mlir/test/Dialect/Affine/load-store-invalid.mlir b/mlir/test/Dialect/Affine/load-store-invalid.mlir --- a/mlir/test/Dialect/Affine/load-store-invalid.mlir +++ b/mlir/test/Dialect/Affine/load-store-invalid.mlir @@ -63,7 +63,7 @@ // ----- func @load_non_affine_index(%arg0 : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { %1 = muli %i0, %arg0 : index // expected-error@+1 {{op index must be a dimension or symbol identifier}} @@ -75,7 +75,7 @@ // ----- func @store_non_affine_index(%arg0 : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %1 = constant 11.0 : f32 affine.for %i0 = 0 to 10 { %2 = muli %i0, %arg0 : index @@ -88,7 +88,7 @@ // ----- func @invalid_prefetch_rw(%i : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> // expected-error@+1 {{rw specifier has to be 'read' or 'write'}} affine.prefetch %0[%i], rw, locality<0>, data : memref<10xf32> return @@ -97,7 +97,7 @@ // ----- func @invalid_prefetch_cache_type(%i : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> // expected-error@+1 {{cache type has to be 'data' or 'instr'}} affine.prefetch %0[%i], read, locality<0>, false : memref<10xf32> return @@ -106,9 +106,9 @@ // ----- func @dma_start_non_affine_src_index(%arg0 : index) { - %0 = alloc() : memref<100xf32> - %1 = alloc() : memref<100xf32, 2> - %2 = alloc() : memref<1xi32, 4> + %0 = memref.alloc() : memref<100xf32> + %1 = memref.alloc() : memref<100xf32, 2> + %2 = memref.alloc() : memref<1xi32, 4> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { @@ -123,9 +123,9 @@ // ----- func @dma_start_non_affine_dst_index(%arg0 : index) { - %0 = alloc() : memref<100xf32> - %1 = alloc() : memref<100xf32, 2> - %2 = alloc() : memref<1xi32, 4> + %0 = memref.alloc() : memref<100xf32> + %1 = memref.alloc() : memref<100xf32, 2> + %2 = memref.alloc() : memref<1xi32, 4> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { @@ -140,9 +140,9 @@ // ----- func @dma_start_non_affine_tag_index(%arg0 : index) { - %0 = alloc() : memref<100xf32> - %1 = alloc() : memref<100xf32, 2> - %2 = alloc() : memref<1xi32, 4> + %0 = memref.alloc() : memref<100xf32> + %1 = memref.alloc() : memref<100xf32, 2> + %2 = memref.alloc() : memref<1xi32, 4> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { @@ -157,9 +157,9 @@ // ----- func @dma_wait_non_affine_tag_index(%arg0 : index) { - %0 = alloc() : memref<100xf32> - %1 = alloc() : memref<100xf32, 2> - %2 = alloc() : memref<1xi32, 4> + %0 = memref.alloc() : memref<100xf32> + %1 = memref.alloc() : memref<100xf32, 2> + %2 = memref.alloc() : memref<1xi32, 4> %c0 = constant 0 : index %c64 = constant 64 : index affine.for %i0 = 0 to 10 { diff --git a/mlir/test/Dialect/Affine/load-store.mlir b/mlir/test/Dialect/Affine/load-store.mlir --- a/mlir/test/Dialect/Affine/load-store.mlir +++ b/mlir/test/Dialect/Affine/load-store.mlir @@ -4,7 +4,7 @@ // Test with just loop IVs. func @test0(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { %1 = affine.load %0[%i0, %i1] : memref<100x100xf32> @@ -18,7 +18,7 @@ // Test with loop IVs and constants. func @test1(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { %1 = affine.load %0[%i0 + 3, %i1 + 7] : memref<100x100xf32> @@ -35,7 +35,7 @@ // Test with loop IVs and function args without 'symbol' keyword (should // be parsed as dim identifiers). func @test2(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { %1 = affine.load %0[%i0 + %arg0, %i1 + %arg1] : memref<100x100xf32> @@ -52,7 +52,7 @@ // Test with loop IVs and function args with 'symbol' keyword (should // be parsed as symbol identifiers). func @test3(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { %1 = affine.load %0[%i0 + symbol(%arg0), %i1 + symbol(%arg1)] @@ -70,7 +70,7 @@ // Test with loop IVs, symbols and constants in nested affine expressions. func @test4(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { %1 = affine.load %0[(%i0 + symbol(%arg0)) floordiv 3 + 11, @@ -88,7 +88,7 @@ // Test with swizzled loop IVs. func @test5(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<10x10x10xf32> + %0 = memref.alloc() : memref<10x10x10xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { affine.for %i2 = 0 to 10 { @@ -108,7 +108,7 @@ // Dim identifiers are assigned in parse order: // d0 = %i2, d1 = %arg0, d2 = %i0, d3 = %i1, d4 = %arg1 func @test6(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<10x10x10xf32> + %0 = memref.alloc() : memref<10x10x10xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { affine.for %i2 = 0 to 10 { @@ -131,7 +131,7 @@ // d0 = %i2, d1 = %i0, d2 = %i1 // s0 = %arg0, s1 = %arg1 func @test6(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<10x10x10xf32> + %0 = memref.alloc() : memref<10x10x10xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { affine.for %i2 = 0 to 10 { @@ -157,7 +157,7 @@ // Test with operands without special SSA name. func @test7() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { %1 = affine.apply affine_map<(d1) -> (d1 + 1)>(%i0) %2 = affine.load %0[%1] : memref<10xf32> @@ -183,7 +183,7 @@ // Test with loop IVs and constants. func @test_prefetch(%arg0 : index, %arg1 : index) { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { %1 = affine.load %0[%i0 + 3, %i1 + 7] : memref<100x100xf32> @@ -200,12 +200,12 @@ // Test with just loop IVs. func @vector_load_vector_store_iv() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 16 { affine.for %i1 = 0 to 16 step 8 { %1 = affine.vector_load %0[%i0, %i1] : memref<100x100xf32>, vector<8xf32> affine.vector_store %1, %0[%i0, %i1] : memref<100x100xf32>, vector<8xf32> -// CHECK: %[[buf:.*]] = alloc +// CHECK: %[[buf:.*]] = memref.alloc // CHECK-NEXT: affine.for %[[i0:.*]] = 0 // CHECK-NEXT: affine.for %[[i1:.*]] = 0 // CHECK-NEXT: %[[val:.*]] = affine.vector_load %[[buf]][%[[i0]], %[[i1]]] : memref<100x100xf32>, vector<8xf32> @@ -219,12 +219,12 @@ // Test with loop IVs and constants. func @vector_load_vector_store_iv_constant() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 16 step 4 { %1 = affine.vector_load %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>, vector<4xf32> affine.vector_store %1, %0[%i0 + 3, %i1 + 7] : memref<100x100xf32>, vector<4xf32> -// CHECK: %[[buf:.*]] = alloc +// CHECK: %[[buf:.*]] = memref.alloc // CHECK-NEXT: affine.for %[[i0:.*]] = 0 // CHECK-NEXT: affine.for %[[i1:.*]] = 0 // CHECK-NEXT: %[[val:.*]] = affine.vector_load %{{.*}}[%{{.*}} + 3, %{{.*}} + 7] : memref<100x100xf32>, vector<4xf32> @@ -237,12 +237,12 @@ // ----- func @vector_load_vector_store_2d() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> affine.for %i0 = 0 to 16 step 2{ affine.for %i1 = 0 to 16 step 8 { %1 = affine.vector_load %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32> affine.vector_store %1, %0[%i0, %i1] : memref<100x100xf32>, vector<2x8xf32> -// CHECK: %[[buf:.*]] = alloc +// CHECK: %[[buf:.*]] = memref.alloc // CHECK-NEXT: affine.for %[[i0:.*]] = 0 // CHECK-NEXT: affine.for %[[i1:.*]] = 0 // CHECK-NEXT: %[[val:.*]] = affine.vector_load %[[buf]][%[[i0]], %[[i1]]] : memref<100x100xf32>, vector<2x8xf32> diff --git a/mlir/test/Dialect/Affine/loop-tiling-validity.mlir b/mlir/test/Dialect/Affine/loop-tiling-validity.mlir --- a/mlir/test/Dialect/Affine/loop-tiling-validity.mlir +++ b/mlir/test/Dialect/Affine/loop-tiling-validity.mlir @@ -9,7 +9,7 @@ // CHECK-LABEL: func @legal_loop() func @legal_loop() { - %0 = alloc() : memref<64xf32> + %0 = memref.alloc() : memref<64xf32> affine.for %i = 0 to 64 { %1 = affine.load %0[%i] : memref<64xf32> @@ -32,7 +32,7 @@ // CHECK-LABEL: func @illegal_loop_with_diag_dependence func @illegal_loop_with_diag_dependence() { - %A = alloc() : memref<64x64xf32> + %A = memref.alloc() : memref<64x64xf32> affine.for %i = 0 to 64 { // expected-remark@above {{tiled code is illegal due to dependences}} diff --git a/mlir/test/Dialect/Affine/memref-stride-calculation.mlir b/mlir/test/Dialect/Affine/memref-stride-calculation.mlir --- a/mlir/test/Dialect/Affine/memref-stride-calculation.mlir +++ b/mlir/test/Dialect/Affine/memref-stride-calculation.mlir @@ -2,79 +2,79 @@ func @f(%0: index) { // CHECK-LABEL: Testing: f - %1 = alloc() : memref<3x4x5xf32> + %1 = memref.alloc() : memref<3x4x5xf32> // CHECK: MemRefType offset: 0 strides: 20, 5, 1 - %2 = alloc(%0) : memref<3x4x?xf32> + %2 = memref.alloc(%0) : memref<3x4x?xf32> // CHECK: MemRefType offset: 0 strides: ?, ?, 1 - %3 = alloc(%0) : memref<3x?x5xf32> + %3 = memref.alloc(%0) : memref<3x?x5xf32> // CHECK: MemRefType offset: 0 strides: ?, 5, 1 - %4 = alloc(%0) : memref + %4 = memref.alloc(%0) : memref // CHECK: MemRefType offset: 0 strides: 20, 5, 1 - %5 = alloc(%0, %0) : memref + %5 = memref.alloc(%0, %0) : memref // CHECK: MemRefType offset: 0 strides: ?, ?, 1 - %6 = alloc(%0, %0, %0) : memref + %6 = memref.alloc(%0, %0, %0) : memref // CHECK: MemRefType offset: 0 strides: ?, ?, 1 - %11 = alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i, j, k)>> + %11 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i, j, k)>> // CHECK: MemRefType offset: 0 strides: 20, 5, 1 - %b11 = alloc() : memref<3x4x5xf32, offset: 0, strides: [20, 5, 1]> + %b11 = memref.alloc() : memref<3x4x5xf32, offset: 0, strides: [20, 5, 1]> // CHECK: MemRefType offset: 0 strides: 20, 5, 1 - %12 = alloc(%0) : memref<3x4x?xf32, affine_map<(i, j, k)->(i, j, k)>> + %12 = memref.alloc(%0) : memref<3x4x?xf32, affine_map<(i, j, k)->(i, j, k)>> // CHECK: MemRefType offset: 0 strides: ?, ?, 1 - %13 = alloc(%0) : memref<3x?x5xf32, affine_map<(i, j, k)->(i, j, k)>> + %13 = memref.alloc(%0) : memref<3x?x5xf32, affine_map<(i, j, k)->(i, j, k)>> // CHECK: MemRefType offset: 0 strides: ?, 5, 1 - %14 = alloc(%0) : memref(i, j, k)>> + %14 = memref.alloc(%0) : memref(i, j, k)>> // CHECK: MemRefType offset: 0 strides: 20, 5, 1 - %15 = alloc(%0, %0) : memref(i, j, k)>> + %15 = memref.alloc(%0, %0) : memref(i, j, k)>> // CHECK: MemRefType offset: 0 strides: ?, ?, 1 - %16 = alloc(%0, %0, %0) : memref(i, j, k)>> + %16 = memref.alloc(%0, %0, %0) : memref(i, j, k)>> // CHECK: MemRefType offset: 0 strides: ?, ?, 1 - %21 = alloc()[%0] : memref<3x4x5xf32, affine_map<(i, j, k)[M]->(32 * i + 16 * j + M * k + 1)>> + %21 = memref.alloc()[%0] : memref<3x4x5xf32, affine_map<(i, j, k)[M]->(32 * i + 16 * j + M * k + 1)>> // CHECK: MemRefType offset: 1 strides: 32, 16, ? - %22 = alloc()[%0] : memref<3x4x5xf32, affine_map<(i, j, k)[M]->(32 * i + M * j + 16 * k + 3)>> + %22 = memref.alloc()[%0] : memref<3x4x5xf32, affine_map<(i, j, k)[M]->(32 * i + M * j + 16 * k + 3)>> // CHECK: MemRefType offset: 3 strides: 32, ?, 16 - %b22 = alloc(%0)[%0, %0] : memref<3x4x?xf32, offset: 0, strides: [?, ?, 1]> + %b22 = memref.alloc(%0)[%0, %0] : memref<3x4x?xf32, offset: 0, strides: [?, ?, 1]> // CHECK: MemRefType offset: 0 strides: ?, ?, 1 - %23 = alloc(%0)[%0] : memref<3x?x5xf32, affine_map<(i, j, k)[M]->(M * i + 32 * j + 16 * k + 7)>> + %23 = memref.alloc(%0)[%0] : memref<3x?x5xf32, affine_map<(i, j, k)[M]->(M * i + 32 * j + 16 * k + 7)>> // CHECK: MemRefType offset: 7 strides: ?, 32, 16 - %b23 = alloc(%0)[%0] : memref<3x?x5xf32, offset: 0, strides: [?, 5, 1]> + %b23 = memref.alloc(%0)[%0] : memref<3x?x5xf32, offset: 0, strides: [?, 5, 1]> // CHECK: MemRefType offset: 0 strides: ?, 5, 1 - %24 = alloc(%0)[%0] : memref<3x?x5xf32, affine_map<(i, j, k)[M]->(M * i + 32 * j + 16 * k + M)>> + %24 = memref.alloc(%0)[%0] : memref<3x?x5xf32, affine_map<(i, j, k)[M]->(M * i + 32 * j + 16 * k + M)>> // CHECK: MemRefType offset: ? strides: ?, 32, 16 - %b24 = alloc(%0)[%0, %0] : memref<3x?x5xf32, offset: ?, strides: [?, 32, 16]> + %b24 = memref.alloc(%0)[%0, %0] : memref<3x?x5xf32, offset: ?, strides: [?, 32, 16]> // CHECK: MemRefType offset: ? strides: ?, 32, 16 - %25 = alloc(%0, %0)[%0, %0] : memref(M * i + N * j + k + 1)>> + %25 = memref.alloc(%0, %0)[%0, %0] : memref(M * i + N * j + k + 1)>> // CHECK: MemRefType offset: 1 strides: ?, ?, 1 - %b25 = alloc(%0, %0)[%0, %0] : memref + %b25 = memref.alloc(%0, %0)[%0, %0] : memref // CHECK: MemRefType offset: 1 strides: ?, ?, 1 - %26 = alloc(%0)[] : memref(i)>> + %26 = memref.alloc(%0)[] : memref(i)>> // CHECK: MemRefType offset: 0 strides: 1 - %27 = alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(M)>> + %27 = memref.alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(M)>> // CHECK: MemRefType memref<5xf32, affine_map<(d0)[s0] -> (s0)>> cannot be converted to strided form - %28 = alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(123)>> + %28 = memref.alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(123)>> // CHECK: MemRefType memref<5xf32, affine_map<(d0)[s0] -> (123)>> cannot be converted to strided form - %29 = alloc()[%0] : memref(M)>> + %29 = memref.alloc()[%0] : memref(M)>> // CHECK: MemRefType offset: ? strides: - %30 = alloc()[%0] : memref(123)>> + %30 = memref.alloc()[%0] : memref(123)>> // CHECK: MemRefType offset: 123 strides: - %100 = alloc(%0, %0)[%0, %0] : memref(i + j, j, k)>, affine_map<(i, j, k)[M, N]->(M * i + N * j + k + 1)>> + %100 = memref.alloc(%0, %0)[%0, %0] : memref(i + j, j, k)>, affine_map<(i, j, k)[M, N]->(M * i + N * j + k + 1)>> // CHECK: MemRefType memref (d0 + d1, d1, d2)>, affine_map<(d0, d1, d2)[s0, s1] -> (d0 * s0 + d1 * s1 + d2 + 1)>> cannot be converted to strided form - %101 = alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i floordiv 4 + j + k)>> + %101 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i floordiv 4 + j + k)>> // CHECK: MemRefType memref<3x4x5xf32, affine_map<(d0, d1, d2) -> (d0 floordiv 4 + d1 + d2)>> cannot be converted to strided form - %102 = alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i ceildiv 4 + j + k)>> + %102 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i ceildiv 4 + j + k)>> // CHECK: MemRefType memref<3x4x5xf32, affine_map<(d0, d1, d2) -> (d0 ceildiv 4 + d1 + d2)>> cannot be converted to strided form - %103 = alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i mod 4 + j + k)>> + %103 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i mod 4 + j + k)>> // CHECK: MemRefType memref<3x4x5xf32, affine_map<(d0, d1, d2) -> (d0 mod 4 + d1 + d2)>> cannot be converted to strided form - %200 = alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * i + N * i + N * j + K * k - (M + N - 20)* i)>> + %200 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * i + N * i + N * j + K * k - (M + N - 20)* i)>> // CHECK: MemRefType offset: 0 strides: 20, ?, ? - %201 = alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * i + N * i + N * K * j + K * K * k - (M + N - 20) * (i + 1))>> + %201 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * i + N * i + N * K * j + K * K * k - (M + N - 20) * (i + 1))>> // CHECK: MemRefType offset: ? strides: 20, ?, ? - %202 = alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * (i + 1) + j + k - M)>> + %202 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * (i + 1) + j + k - M)>> // CHECK: MemRefType offset: 0 strides: ?, 1, 1 - %203 = alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M + M * (i + N * (j + K * k)))>> + %203 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M + M * (i + N * (j + K * k)))>> // CHECK: MemRefType offset: ? strides: ?, ?, ? return diff --git a/mlir/test/Dialect/Affine/ops.mlir b/mlir/test/Dialect/Affine/ops.mlir --- a/mlir/test/Dialect/Affine/ops.mlir +++ b/mlir/test/Dialect/Affine/ops.mlir @@ -97,7 +97,7 @@ func @valid_symbols(%arg0: index, %arg1: index, %arg2: index) { %c1 = constant 1 : index %c0 = constant 0 : index - %0 = alloc(%arg0, %arg1) : memref + %0 = memref.alloc(%arg0, %arg1) : memref affine.for %arg3 = 0 to %arg2 step 768 { %13 = dim %0, %c1 : memref affine.for %arg4 = 0 to %13 step 264 { diff --git a/mlir/test/Dialect/Affine/parallelize.mlir b/mlir/test/Dialect/Affine/parallelize.mlir --- a/mlir/test/Dialect/Affine/parallelize.mlir +++ b/mlir/test/Dialect/Affine/parallelize.mlir @@ -4,8 +4,8 @@ // CHECK-LABEL: func @reduce_window_max() { func @reduce_window_max() { %cst = constant 0.000000e+00 : f32 - %0 = alloc() : memref<1x8x8x64xf32> - %1 = alloc() : memref<1x18x18x64xf32> + %0 = memref.alloc() : memref<1x8x8x64xf32> + %1 = memref.alloc() : memref<1x18x18x64xf32> affine.for %arg0 = 0 to 1 { affine.for %arg1 = 0 to 8 { affine.for %arg2 = 0 to 8 { @@ -40,8 +40,8 @@ } // CHECK: %[[cst:.*]] = constant 0.000000e+00 : f32 -// CHECK: %[[v0:.*]] = alloc() : memref<1x8x8x64xf32> -// CHECK: %[[v1:.*]] = alloc() : memref<1x18x18x64xf32> +// CHECK: %[[v0:.*]] = memref.alloc() : memref<1x8x8x64xf32> +// CHECK: %[[v1:.*]] = memref.alloc() : memref<1x18x18x64xf32> // CHECK: affine.parallel (%[[arg0:.*]]) = (0) to (1) { // CHECK: affine.parallel (%[[arg1:.*]]) = (0) to (8) { // CHECK: affine.parallel (%[[arg2:.*]]) = (0) to (8) { @@ -75,9 +75,9 @@ // CHECK: } func @loop_nest_3d_outer_two_parallel(%N : index) { - %0 = alloc() : memref<1024 x 1024 x vector<64xf32>> - %1 = alloc() : memref<1024 x 1024 x vector<64xf32>> - %2 = alloc() : memref<1024 x 1024 x vector<64xf32>> + %0 = memref.alloc() : memref<1024 x 1024 x vector<64xf32>> + %1 = memref.alloc() : memref<1024 x 1024 x vector<64xf32>> + %2 = memref.alloc() : memref<1024 x 1024 x vector<64xf32>> affine.for %i = 0 to %N { affine.for %j = 0 to %N { %7 = affine.load %2[%i, %j] : memref<1024x1024xvector<64xf32>> @@ -108,7 +108,7 @@ // CHECK-LABEL: non_affine_load func @non_affine_load() { - %0 = alloc() : memref<100 x f32> + %0 = memref.alloc() : memref<100 x f32> affine.for %i = 0 to 100 { // CHECK: affine.for %{{.*}} = 0 to 100 { load %0[%i] : memref<100 x f32> diff --git a/mlir/test/Dialect/Affine/slicing-utils.mlir b/mlir/test/Dialect/Affine/slicing-utils.mlir --- a/mlir/test/Dialect/Affine/slicing-utils.mlir +++ b/mlir/test/Dialect/Affine/slicing-utils.mlir @@ -17,7 +17,7 @@ // FWDBWD-LABEL: slicing_test func @slicing_test() { // Fake 0 to align on 1 and match ASCII art. - %0 = alloc() : memref<1xi32> + %0 = memref.alloc() : memref<1xi32> // FWD: matched: %[[v1:.*]] {{.*}} forward static slice: // FWD-NEXT: %[[v5:.*]] {{.*}} -> i5 diff --git a/mlir/test/Dialect/Affine/unroll.mlir b/mlir/test/Dialect/Affine/unroll.mlir --- a/mlir/test/Dialect/Affine/unroll.mlir +++ b/mlir/test/Dialect/Affine/unroll.mlir @@ -265,9 +265,9 @@ // count threshold set to 2. // SHORT-LABEL: func @loop_nest_seq_long() -> i32 { func @loop_nest_seq_long() -> i32 { - %A = alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> - %B = alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> - %C = alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %A = memref.alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %B = memref.alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + %C = memref.alloc() : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> %zero = constant 0 : i32 %one = constant 1 : i32 @@ -279,9 +279,9 @@ affine.for %n0 = 0 to 512 { // CHECK: affine.for %arg1 = 0 to 8 affine.for %n1 = 0 to 8 { - store %one, %A[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> - store %two, %B[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> - store %zero, %C[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + memref.store %one, %A[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + memref.store %two, %B[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + memref.store %zero, %C[%n0, %n1] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> } } @@ -306,7 +306,7 @@ %c2 = "affine.apply" (%x, %k2) {map = affine_map<(d0, d1) -> (16*d0 + d1)>} : (index, index) -> index %s1 = load %C[%j1, %c2] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> %s2 = "addi32"(%s0, %s1) : (i32, i32) -> i32 - store %s2, %C[%j1, %c2] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> + memref.store %s2, %C[%j1, %c2] : memref<512 x 512 x i32, affine_map<(d0, d1) -> (d0, d1)>, 2> } } "op4"() : () -> () diff --git a/mlir/test/Dialect/Async/async-parallel-for.mlir b/mlir/test/Dialect/Async/async-parallel-for.mlir --- a/mlir/test/Dialect/Async/async-parallel-for.mlir +++ b/mlir/test/Dialect/Async/async-parallel-for.mlir @@ -6,14 +6,14 @@ // CHECK: scf.for // CHECK: %[[TOKEN:.*]] = async.execute { // CHECK: scf.for - // CHECK: store + // CHECK: memref.store // CHECK: async.yield // CHECK: } // CHECK: async.add_to_group %[[TOKEN]], %[[GROUP]] // CHECK: async.await_all %[[GROUP]] scf.parallel (%i) = (%arg0) to (%arg1) step (%arg2) { %one = constant 1.0 : f32 - store %one, %arg3[%i] : memref + memref.store %one, %arg3[%i] : memref } return @@ -29,7 +29,7 @@ // CHECK: %[[TOKEN:.*]] = async.execute { // CHECK: scf.for // CHECK: scf.for - // CHECK: store + // CHECK: memref.store // CHECK: async.yield // CHECK: } // CHECK: async.add_to_group %[[TOKEN]], %[[GROUP]] @@ -37,7 +37,7 @@ scf.parallel (%i0, %i1) = (%arg0, %arg3) to (%arg1, %arg4) step (%arg2, %arg5) { %one = constant 1.0 : f32 - store %one, %arg6[%i0, %i1] : memref + memref.store %one, %arg6[%i0, %i1] : memref } return diff --git a/mlir/test/Dialect/Async/async-to-async-runtime.mlir b/mlir/test/Dialect/Async/async-to-async-runtime.mlir --- a/mlir/test/Dialect/Async/async-to-async-runtime.mlir +++ b/mlir/test/Dialect/Async/async-to-async-runtime.mlir @@ -4,7 +4,7 @@ func @execute_no_async_args(%arg0: f32, %arg1: memref<1xf32>) { %token = async.execute { %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<1xf32> + memref.store %arg0, %arg1[%c0] : memref<1xf32> async.yield } async.await %token : !async.token @@ -28,7 +28,7 @@ // Resume coroutine after suspension. // CHECK: ^[[RESUME]]: -// CHECK: store +// CHECK: memref.store // CHECK: async.runtime.set_available %[[TOKEN]] // Delete coroutine. @@ -50,12 +50,12 @@ %token1 = async.execute { %c1 = constant 1: index - store %arg0, %arg2[%c0] : memref<1xf32> + memref.store %arg0, %arg2[%c0] : memref<1xf32> async.yield } async.await %token1 : !async.token - store %arg1, %arg2[%c0] : memref<1xf32> + memref.store %arg1, %arg2[%c0] : memref<1xf32> async.yield } // CHECK: async.runtime.await %[[TOKEN]] @@ -77,7 +77,7 @@ // CHECK-SAME: ^[[SUSPEND:.*]], ^[[RESUME:.*]], ^[[CLEANUP:.*]] // CHECK: ^[[RESUME]]: -// CHECK: store +// CHECK: memref.store // CHECK: async.runtime.set_available %[[TOKEN]] // Function outlined from the outer async.execute operation. @@ -103,7 +103,7 @@ // Set token available after second resumption. // CHECK: ^[[RESUME_1]]: -// CHECK: store +// CHECK: memref.store // CHECK: async.runtime.set_available %[[TOKEN]] // CHECK: ^[[CLEANUP]]: @@ -116,13 +116,13 @@ // CHECK: %[[TOKEN:.*]] = call @async_execute_fn %token = async.execute { %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<1xf32> + memref.store %arg0, %arg1[%c0] : memref<1xf32> async.yield } // CHECK: call @async_execute_fn_0(%[[TOKEN]], %arg0, %arg1) %token_0 = async.execute [%token] { %c0 = constant 0 : index - store %arg0, %arg1[%c0] : memref<1xf32> + memref.store %arg0, %arg1[%c0] : memref<1xf32> async.yield } return @@ -157,7 +157,7 @@ // Emplace result token after second resumption. // CHECK: ^[[RESUME_1]]: -// CHECK: store +// CHECK: memref.store // CHECK: async.runtime.set_available %[[TOKEN]] // CHECK: ^[[CLEANUP]]: diff --git a/mlir/test/Dialect/GPU/multiple-all-reduce.mlir b/mlir/test/Dialect/GPU/multiple-all-reduce.mlir --- a/mlir/test/Dialect/GPU/multiple-all-reduce.mlir +++ b/mlir/test/Dialect/GPU/multiple-all-reduce.mlir @@ -1,9 +1,9 @@ // RUN: mlir-opt --gpu-kernel-outlining --convert-gpu-to-nvvm %s | FileCheck %s func @main() { - %data = alloc() : memref<2x6xf32> - %sum = alloc() : memref<2xf32> - %mul = alloc() : memref<2xf32> + %data = memref.alloc() : memref<2x6xf32> + %sum = memref.alloc() : memref<2xf32> + %mul = memref.alloc() : memref<2xf32> %c1 = constant 1 : index // ADD + MUL @@ -11,9 +11,9 @@ threads(%tx, %ty, %tz) in (%block_x = %c1, %block_y = %c1, %block_z = %c1) { %val = load %data[%bx, %tx] : memref<2x6xf32> %reduced0 = "gpu.all_reduce"(%val) ({}) { op = "add" } : (f32) -> (f32) - store %reduced0, %sum[%bx] : memref<2xf32> + memref.store %reduced0, %sum[%bx] : memref<2xf32> %reduced1 = "gpu.all_reduce"(%val) ({}) { op = "mul" } : (f32) -> (f32) - store %reduced1, %mul[%bx] : memref<2xf32> + memref.store %reduced1, %mul[%bx] : memref<2xf32> gpu.terminator } diff --git a/mlir/test/Dialect/Linalg/affine.mlir b/mlir/test/Dialect/Linalg/affine.mlir --- a/mlir/test/Dialect/Linalg/affine.mlir +++ b/mlir/test/Dialect/Linalg/affine.mlir @@ -12,9 +12,9 @@ func @matmul(%arg0: memref, %M: index, %N: index, %K: index) { %c0 = constant 0 : index %c1 = constant 1 : index - %A = view %arg0[%c0][%M, %K] : memref to memref - %B = view %arg0[%c0][%K, %N] : memref to memref - %C = view %arg0[%c0][%M, %N] : memref to memref + %A = memref.view %arg0[%c0][%M, %K] : memref to memref + %B = memref.view %arg0[%c0][%K, %N] : memref to memref + %C = memref.view %arg0[%c0][%M, %N] : memref to memref linalg.matmul ins(%A, %B: memref, memref) outs(%C: memref) return @@ -24,9 +24,9 @@ // CHECK-SAME: [[M:arg[0-9]+]]: index // CHECK-SAME: [[N:arg[0-9]+]]: index // CHECK-SAME: [[K:arg[0-9]+]]: index -// CHECK: %[[A:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECK: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECK: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref +// CHECK: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECK: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECK: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref // CHECK: affine.for %{{.*}} = 0 to %{{.*}} { // CHECK: affine.for %{{.*}} = 0 to %{{.*}} { // CHECK: affine.for %{{.*}} = 0 to %{{.*}} { diff --git a/mlir/test/Dialect/Linalg/bufferize.mlir b/mlir/test/Dialect/Linalg/bufferize.mlir --- a/mlir/test/Dialect/Linalg/bufferize.mlir +++ b/mlir/test/Dialect/Linalg/bufferize.mlir @@ -12,7 +12,7 @@ // CHECK-LABEL: func @basic( // CHECK-SAME: %[[TENSOR:.*]]: tensor<4xf32>) -> tensor<4xf32> { // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]] : memref<4xf32> -// CHECK: %[[RESULT_MEMREF:.*]] = alloc() : memref<4xf32> +// CHECK: %[[RESULT_MEMREF:.*]] = memref.alloc() : memref<4xf32> // CHECK: linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel"]} // CHECK-SAME: ins(%[[MEMREF]] : memref<4xf32>) // CHECK-SAME: outs(%[[RESULT_MEMREF]] : memref<4xf32>) { @@ -45,7 +45,7 @@ // CHECK: #map = affine_map<(d0) -> (d0)> // CHECK-LABEL: func @init_tensor( // CHECK-SAME: %[[IN:.*]]: tensor, %[[SIZE:.*]]: index) -// CHECK: %[[OUT_BUF:.*]] = alloc(%[[SIZE]]) : memref +// CHECK: %[[OUT_BUF:.*]] = memref.alloc(%[[SIZE]]) : memref // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[IN]] : memref // CHECK: linalg.generic // CHECK-SAME: ins(%[[MEMREF]] : memref) @@ -70,8 +70,8 @@ #map0 = affine_map<(d0) -> (d0)> // CHECK-LABEL: func @multiple_results -// CHECK: %[[RESULT0:.*]] = alloc() : memref<4xf32> -// CHECK: %[[RESULT1:.*]] = alloc() : memref<4xf32> +// CHECK: %[[RESULT0:.*]] = memref.alloc() : memref<4xf32> +// CHECK: %[[RESULT1:.*]] = memref.alloc() : memref<4xf32> // CHECK: linalg.generic // CHECK-SAME: ins(%{{.*}} : memref<4xf32>) // CHECK-SAME: outs(%[[RESULT0]], %[[RESULT1]] : memref<4xf32>, memref<4xf32>) @@ -94,8 +94,8 @@ #map0 = affine_map<(d0) -> (d0)> // CHECK-LABEL: func @multiple_results_indexed -// CHECK: %[[RESULT0:.*]] = alloc() : memref<4xi32> -// CHECK: %[[RESULT1:.*]] = alloc() : memref<4xi32> +// CHECK: %[[RESULT0:.*]] = memref.alloc() : memref<4xi32> +// CHECK: %[[RESULT1:.*]] = memref.alloc() : memref<4xi32> // CHECK: linalg.indexed_generic // CHECK-SAME: ins(%{{.*}} : memref<4xi32>) // CHECK-SAME: outs(%[[RESULT0]], %[[RESULT1]] : memref<4xi32>, memref<4xi32>) @@ -129,8 +129,8 @@ // CHECK: %[[MEMREF_ARG:.*]] = tensor_to_memref %[[ARG]] : memref // CHECK: %[[DIM0:.*]] = dim %[[ARG]], %[[C0]] : tensor // CHECK: %[[DIM1:.*]] = dim %[[ARG]], %[[C1]] : tensor -// CHECK: %[[RESULT0:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref -// CHECK: %[[RESULT1:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref +// CHECK: %[[RESULT0:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref +// CHECK: %[[RESULT1:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref // CHECK: linalg.generic // CHECK-SAME: ins(%[[MEMREF_ARG]] : memref) // CHECK-SAME: outs(%[[RESULT0]], %[[RESULT1]] : memref, memref) @@ -167,7 +167,7 @@ // CHECK-SAME: %[[ARG1_TENSOR:.*]]: tensor<3x2xf32>) -> tensor<3x2xf32> { // CHECK: %[[ARG0_MEMREF:.*]] = tensor_to_memref %[[ARG0_TENSOR]] : memref<2x3x4xvector<3x4xi4>> // CHECK: %[[ARG1_MEMREF:.*]] = tensor_to_memref %[[ARG1_TENSOR]] : memref<3x2xf32> -// CHECK: %[[INIT_BUFFER:.*]] = alloc() : memref<3x2xf32> +// CHECK: %[[INIT_BUFFER:.*]] = memref.alloc() : memref<3x2xf32> // CHECK: linalg.copy(%[[ARG1_MEMREF]], %[[INIT_BUFFER]]) : memref<3x2xf32>, memref<3x2xf32> // CHECK: linalg.generic // CHECK-SAME: ins(%[[ARG0_MEMREF]] : memref<2x3x4xvector<3x4xi4>>) @@ -199,7 +199,7 @@ %i0 = call @make_index() : () -> index // CHECK: %[[M0:.*]] = tensor_to_memref %[[T]] : memref - // CHECK-NEXT: %[[A0:.*]] = alloc() : memref<2x3xf32> + // CHECK-NEXT: %[[A0:.*]] = memref.alloc() : memref<2x3xf32> // CHECK-NEXT: %[[SM0:.*]] = subview %[[M0]][0, 0] [2, 3] [1, 1] // CHECK-SAME: memref to memref<2x3xf32, #[[$MAP0]]> // CHECK-NEXT: linalg.copy(%[[SM0]], %[[A0]]) : memref<2x3xf32, #[[$MAP0]]>, memref<2x3xf32> @@ -207,7 +207,7 @@ %st0 = subtensor %t[0, 0][2, 3][1, 1] : tensor to tensor<2x3xf32> // CHECK: %[[M1:.*]] = tensor_to_memref %[[T]] : memref - // CHECK-NEXT: %[[A1:.*]] = alloc(%[[IDX]]) : memref<2x?xf32> + // CHECK-NEXT: %[[A1:.*]] = memref.alloc(%[[IDX]]) : memref<2x?xf32> // CHECK-NEXT: %[[SM1:.*]] = subview %[[M1]][0, %[[IDX]]] [2, %[[IDX]]] [1, 2] // CHECK-SAME: memref to memref<2x?xf32, #[[$MAP1]]> // CHECK-NEXT: linalg.copy(%[[SM1]], %[[A1]]) : memref<2x?xf32, #[[$MAP1]]>, memref<2x?xf32> @@ -243,7 +243,7 @@ // CHECK-DAG: %[[SM0:.*]] = tensor_to_memref %[[ST0]] : memref<2x3xf32> // CHECK-NEXT: %[[DIM0:.*]] = dim %[[T]], %[[C0]] : tensor // CHECK-NEXT: %[[DIM1:.*]] = dim %[[T]], %[[C1]] : tensor - // CHECK-NEXT: %[[M0_COPY:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref + // CHECK-NEXT: %[[M0_COPY:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref // CHECK-NEXT: linalg.copy(%[[M0]], %[[M0_COPY]]) : memref, memref // CHECK-NEXT: %[[SUBVIEW0:.*]] = subview %[[M0_COPY]][0, 0] [2, 3] [1, 1] // CHECK-SAME: memref to memref<2x3xf32, #[[$MAP0]]> @@ -253,7 +253,7 @@ // CHECK-DAG: %[[M1:.*]] = tensor_to_memref %[[T]] : memref // CHECK-DAG: %[[SM1:.*]] = tensor_to_memref %[[ST1]] : memref<2x?xf32> - // CHECK-NEXT: %[[M1_COPY:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref + // CHECK-NEXT: %[[M1_COPY:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref // CHECK-NEXT: linalg.copy(%[[M1]], %[[M1_COPY]]) : memref, memref // CHECK-NEXT: %[[SUBVIEW1:.*]] = subview %[[M1_COPY]][0, %[[IDX]]] [2, %[[IDX]]] [1, 2] // CHECK-SAME: memref to memref<2x?xf32, #[[$MAP1]]> diff --git a/mlir/test/Dialect/Linalg/canonicalize.mlir b/mlir/test/Dialect/Linalg/canonicalize.mlir --- a/mlir/test/Dialect/Linalg/canonicalize.mlir +++ b/mlir/test/Dialect/Linalg/canonicalize.mlir @@ -6,9 +6,9 @@ %c1 = constant 1 : index %c8 = constant 8 : index %c16 = constant 16 : index - %1 = alloc (%b) : memref - %2 = view %1[%c0][] : memref to memref<16x16xf32> - %3 = memref_cast %2 : memref<16x16xf32> to memref + %1 = memref.alloc (%b) : memref + %2 = memref.view %1[%c0][] : memref to memref<16x16xf32> + %3 = memref.cast %2 : memref<16x16xf32> to memref // CHECK: linalg.matmul ins({{.*}}memref<16x16xf32>, memref<16x16xf32>) outs({{.*}}memref<16x16xf32>) linalg.matmul ins(%3, %3: memref, memref) diff --git a/mlir/test/Dialect/Linalg/fold-affine-min-scf.mlir b/mlir/test/Dialect/Linalg/fold-affine-min-scf.mlir --- a/mlir/test/Dialect/Linalg/fold-affine-min-scf.mlir +++ b/mlir/test/Dialect/Linalg/fold-affine-min-scf.mlir @@ -13,21 +13,21 @@ // CHECK: scf.for // CHECK-NEXT: %[[C2:.*]] = constant 2 : index // CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]] - // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref + // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref scf.for %i = %c0 to %c4 step %c2 { %1 = affine.min affine_map<(d0, d1)[] -> (2, d1 - d0)> (%i, %c4) %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // CHECK: scf.for // CHECK-NEXT: %[[C2:.*]] = constant 2 : index // CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]] - // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref + // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref scf.for %i = %c1 to %c7 step %c2 { %1 = affine.min affine_map<(d0)[s0] -> (s0 - d0, 2)> (%i)[%c7] %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // This should not canonicalize because: 4 - %i may take the value 1 < 2. @@ -37,7 +37,7 @@ scf.for %i = %c1 to %c4 step %c2 { %1 = affine.min affine_map<(d0)[s0] -> (2, s0 - d0)> (%i)[%c4] %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // This should not canonicalize because: 16 - %i may take the value 15 < 1024. @@ -47,7 +47,7 @@ scf.for %i = %c1 to %c16 step %c1024 { %1 = affine.min affine_map<(d0) -> (1024, 16 - d0)> (%i) %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // This example should simplify but affine_map is currently missing @@ -62,7 +62,7 @@ scf.for %i = %c0 to %ub step %step { %1 = affine.min affine_map<(d0, d1, d2) -> (d0, d1 - d2)> (%step, %ub, %i) %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // This example should simplify but affine_map is currently missing @@ -79,7 +79,7 @@ scf.for %i = %c0 to %ub2 step %step { %1 = affine.min affine_map<(d0, d1, d2) -> (d0, d2 - d1)> (%step, %i, %ub2) %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } return @@ -96,21 +96,21 @@ // CHECK: scf.parallel // CHECK-NEXT: %[[C2:.*]] = constant 2 : index // CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]] - // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref + // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref scf.parallel (%i) = (%c0) to (%c4) step (%c2) { %1 = affine.min affine_map<(d0, d1)[] -> (2, d1 - d0)> (%i, %c4) %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // CHECK: scf.parallel // CHECK-NEXT: %[[C2:.*]] = constant 2 : index // CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]] - // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref + // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref scf.parallel (%i) = (%c1) to (%c7) step (%c2) { %1 = affine.min affine_map<(d0)[s0] -> (2, s0 - d0)> (%i)[%c7] %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // This example should simplify but affine_map is currently missing @@ -125,7 +125,7 @@ scf.parallel (%i) = (%c0) to (%ub) step (%step) { %1 = affine.min affine_map<(d0, d1, d2) -> (d0, d2 - d1)> (%step, %i, %ub) %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } // This example should simplify but affine_map is currently missing @@ -140,7 +140,7 @@ scf.parallel (%i) = (%c0) to (%ub2) step (%step) { %1 = affine.min affine_map<(d0, d1, d2) -> (d0, d2 - d1)> (%step, %i, %ub2) %2 = index_cast %1: index to i64 - store %2, %A[]: memref + memref.store %2, %A[]: memref } return diff --git a/mlir/test/Dialect/Linalg/forward-vector-transfers.mlir b/mlir/test/Dialect/Linalg/forward-vector-transfers.mlir --- a/mlir/test/Dialect/Linalg/forward-vector-transfers.mlir +++ b/mlir/test/Dialect/Linalg/forward-vector-transfers.mlir @@ -4,17 +4,17 @@ // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref // CHECK-NOT: linalg.fill // CHECK-NOT: linalg.copy -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: vector.transfer_read %[[ARG0]] // CHECK-NOT: masked func @testAllocRead(%in: memref) -> vector<32 x f32> { %c0 = constant 0: index %f0 = constant 0.0: f32 - %alloc = alloc() : memref<32 x f32> + %alloc = memref.alloc() : memref<32 x f32> %subview = subview %alloc[0][16][1] : memref<32 x f32> to memref<16 x f32> linalg.copy(%in, %subview): memref, memref<16 x f32> %0 = vector.transfer_read %alloc[%c0], %f0 {masked = [false]} : memref<32 x f32>, vector<32 x f32> - dealloc %alloc : memref<32 x f32> + memref.dealloc %alloc : memref<32 x f32> return %0: vector<32 x f32> } @@ -22,18 +22,18 @@ // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref // CHECK-NOT: linalg.fill // CHECK-NOT: linalg.copy -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: vector.transfer_read %[[ARG0]] // CHECK-NOT: masked func @testAllocFillRead(%in: memref) -> vector<32 x f32> { %c0 = constant 0: index %f0 = constant 0.0: f32 - %alloc = alloc() : memref<32 x f32> + %alloc = memref.alloc() : memref<32 x f32> linalg.fill(%alloc, %f0): memref<32 x f32>, f32 %subview = subview %alloc[0][16][1] : memref<32 x f32> to memref<16 x f32> linalg.copy(%in, %subview): memref, memref<16 x f32> %0 = vector.transfer_read %alloc[%c0], %f0 {masked = [false]} : memref<32 x f32>, vector<32 x f32> - dealloc %alloc : memref<32 x f32> + memref.dealloc %alloc : memref<32 x f32> return %0: vector<32 x f32> } @@ -41,18 +41,18 @@ // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref // CHECK-NOT: linalg.fill // CHECK-NOT: linalg.copy -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: vector.transfer_read %[[ARG0]] // CHECK-NOT: masked func @testViewRead(%in: memref) -> vector<32 x f32> { %c0 = constant 0: index %f0 = constant 0.0: f32 - %alloc = alloc() : memref<128 x i8> - %view = view %alloc[%c0][] : memref<128 x i8> to memref<32 x f32> + %alloc = memref.alloc() : memref<128 x i8> + %view = memref.view %alloc[%c0][] : memref<128 x i8> to memref<32 x f32> %subview = subview %view[0][16][1] : memref<32 x f32> to memref<16 x f32> linalg.copy(%in, %subview): memref, memref<16 x f32> %0 = vector.transfer_read %view[%c0], %f0 {masked = [false]} : memref<32 x f32>, vector<32 x f32> - dealloc %alloc : memref<128 x i8> + memref.dealloc %alloc : memref<128 x i8> return %0: vector<32 x f32> } @@ -60,19 +60,19 @@ // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref // CHECK-NOT: linalg.fill // CHECK-NOT: linalg.copy -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: vector.transfer_read %[[ARG0]] // CHECK-NOT: masked func @testViewFillRead(%in: memref) -> vector<32 x f32> { %c0 = constant 0: index %f0 = constant 0.0: f32 - %alloc = alloc() : memref<128 x i8> - %view = view %alloc[%c0][] : memref<128 x i8> to memref<32 x f32> + %alloc = memref.alloc() : memref<128 x i8> + %view = memref.view %alloc[%c0][] : memref<128 x i8> to memref<32 x f32> %subview = subview %view[0][16][1] : memref<32 x f32> to memref<16 x f32> linalg.fill(%view, %f0): memref<32 x f32>, f32 linalg.copy(%in, %subview): memref, memref<16 x f32> %0 = vector.transfer_read %view[%c0], %f0 {masked = [false]} : memref<32 x f32>, vector<32 x f32> - dealloc %alloc : memref<128 x i8> + memref.dealloc %alloc : memref<128 x i8> return %0: vector<32 x f32> } @@ -80,17 +80,17 @@ // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: vector // CHECK-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref // CHECK-NOT: linalg.copy -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: vector.transfer_write %[[ARG0]], %[[ARG1]] // CHECK-NOT: masked func @testAllocWrite(%vec: vector<32 x f32>, %out: memref) { %c0 = constant 0: index %f0 = constant 0.0: f32 - %alloc = alloc() : memref<32 x f32> + %alloc = memref.alloc() : memref<32 x f32> %subview = subview %alloc[0][16][1] : memref<32 x f32> to memref<16 x f32> vector.transfer_write %vec, %alloc[%c0] {masked = [false]} : vector<32 x f32>, memref<32 x f32> linalg.copy(%subview, %out): memref<16 x f32>, memref - dealloc %alloc : memref<32 x f32> + memref.dealloc %alloc : memref<32 x f32> return } @@ -98,18 +98,18 @@ // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: vector // CHECK-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref // CHECK-NOT: linalg.copy -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: vector.transfer_write %[[ARG0]], %[[ARG1]] // CHECK-NOT: masked func @testViewWrite(%vec: vector<32 x f32>, %out: memref) { %c0 = constant 0: index %f0 = constant 0.0: f32 - %alloc = alloc() : memref<128 x i8> - %view = view %alloc[%c0][] : memref<128 x i8> to memref<32 x f32> + %alloc = memref.alloc() : memref<128 x i8> + %view = memref.view %alloc[%c0][] : memref<128 x i8> to memref<32 x f32> %subview = subview %view[0][16][1] : memref<32 x f32> to memref<16 x f32> vector.transfer_write %vec, %view[%c0] {masked = [false]} : vector<32 x f32>, memref<32 x f32> linalg.copy(%subview, %out): memref<16 x f32>, memref - dealloc %alloc : memref<128 x i8> + memref.dealloc %alloc : memref<128 x i8> return } @@ -121,20 +121,20 @@ // CHECK-LABEL: failAllocFillRead // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref // CHECK-NOT: vector.transfer_read %[[ARG0]] -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: linalg.copy // CHECK: vector.transfer_read %[[ALLOC]] func @failAllocFillRead(%in: memref) -> vector<32 x f32> { %c0 = constant 0: index %f0 = constant 0.0: f32 %f1 = constant 1.0: f32 - %alloc = alloc() : memref<32 x f32> + %alloc = memref.alloc() : memref<32 x f32> linalg.fill(%alloc, %f0): memref<32 x f32>, f32 %subview = subview %alloc[0][16][1] : memref<32 x f32> to memref<16 x f32> linalg.copy(%in, %subview): memref, memref<16 x f32> "some_interleaved_use"(%subview) : (memref<16 x f32>) -> () %0 = vector.transfer_read %alloc[%c0], %f1: memref<32 x f32>, vector<32 x f32> - dealloc %alloc : memref<32 x f32> + memref.dealloc %alloc : memref<32 x f32> return %0: vector<32 x f32> } @@ -143,17 +143,17 @@ // CHECK-SAME: %[[ARG0:[0-9a-zA-Z]*]]: vector // CHECK-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref // CHECK-NOT: vector.transfer_write %[[ARG0]], %[[ARG1]] -// CHECK: %[[ALLOC:.*]] = alloc +// CHECK: %[[ALLOC:.*]] = memref.alloc // CHECK: vector.transfer_write %[[ARG0]], %[[ALLOC]] // CHECK: linalg.copy func @failAllocWrite(%vec: vector<32 x f32>, %out: memref) { %c0 = constant 0: index %f0 = constant 0.0: f32 - %alloc = alloc() : memref<32 x f32> + %alloc = memref.alloc() : memref<32 x f32> %subview = subview %alloc[0][16][1] : memref<32 x f32> to memref<16 x f32> vector.transfer_write %vec, %alloc[%c0] : vector<32 x f32>, memref<32 x f32> "some_interleaved_use"(%subview) : (memref<16 x f32>) -> () linalg.copy(%subview, %out): memref<16 x f32>, memref - dealloc %alloc : memref<32 x f32> + memref.dealloc %alloc : memref<32 x f32> return } diff --git a/mlir/test/Dialect/Linalg/fusion-pattern.mlir b/mlir/test/Dialect/Linalg/fusion-pattern.mlir --- a/mlir/test/Dialect/Linalg/fusion-pattern.mlir +++ b/mlir/test/Dialect/Linalg/fusion-pattern.mlir @@ -318,7 +318,7 @@ %c1 = constant 1 : index %0 = dim %arg2, %c0 : memref %1 = dim %arg2, %c1 : memref - %2 = alloc(%0, %1) : memref + %2 = memref.alloc(%0, %1) : memref linalg.matmul ins(%arg0, %arg1 : memref, memref) outs(%2 : memref) linalg.generic @@ -340,7 +340,7 @@ // CHECK-SAME: %[[ARG0:[a-zA-Z0-9_]+]]: memref // CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]+]]: memref // CHECK-SAME: %[[ARG2:[a-zA-Z0-9_]+]]: memref -// CHECK: %[[T2:.+]] = alloc(%{{.*}}, %{{.*}}) : memref +// CHECK: %[[T2:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref // CHECK: linalg.matmul // CHECK-SAME: after_transpose_fusion_original // CHECK: scf.parallel (%[[ARG3:[a-zA-Z0-9_]+]], %[[ARG4:.[a-zA-Z0-9_]+]]) @@ -368,7 +368,7 @@ %c1 = constant 1 : index %0 = dim %arg2, %c0 : memref %1 = dim %arg2, %c1 : memref - %2 = alloc(%0, %1) : memref + %2 = memref.alloc(%0, %1) : memref linalg.matmul ins(%arg0, %arg1 : memref, memref) outs(%2 : memref) linalg.generic diff --git a/mlir/test/Dialect/Linalg/fusion-sequence.mlir b/mlir/test/Dialect/Linalg/fusion-sequence.mlir --- a/mlir/test/Dialect/Linalg/fusion-sequence.mlir +++ b/mlir/test/Dialect/Linalg/fusion-sequence.mlir @@ -8,7 +8,7 @@ %c1 = constant 1 : index %d0 = dim %arg0, %c0 : memref %d1 = dim %arg1, %c1 : memref - %0 = alloc(%d0, %d1) : memref + %0 = memref.alloc(%d0, %d1) : memref linalg.fill(%0, %cst) : memref, f32 linalg.matmul ins(%arg0, %arg1 : memref, memref) outs(%0 : memref) @@ -34,7 +34,7 @@ // CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]+]]: memref // CHECK-SAME: %[[ARG2:[a-zA-Z0-9_]+]]: memref // CHECK-SAME: %[[ARG3:[a-zA-Z0-9_]+]]: memref -// CHECK: %[[TEMP:.+]] = alloc(%{{.*}}, %{{.*}}) : memref +// CHECK: %[[TEMP:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref // CHECK: scf.parallel (%[[IV0:.+]], %[[IV1:.+]]) = {{.*}} { // CHECK-DAG: %[[SV_TEMP:.+]] = subview %[[TEMP]][%[[IV0]], %[[IV1]]] // CHECK-DAG: %[[SV_ARG2:.+]] = subview %[[ARG2]][%[[IV1]]] @@ -66,8 +66,8 @@ %n1 = dim %arg1, %c1 : memref %n2 = dim %arg2, %c1 : memref %n3 = dim %arg3, %c1 : memref - %0 = alloc(%m, %n1) : memref - %1 = alloc(%m, %n2) : memref + %0 = memref.alloc(%m, %n1) : memref + %1 = memref.alloc(%m, %n2) : memref linalg.fill(%0, %cst) : memref, f32 linalg.matmul ins(%arg0, %arg1 : memref, memref) outs(%0 : memref) @@ -95,8 +95,8 @@ // CHECK-DAG: %[[M:.+]] = dim %[[ARG0]], %[[C0]] // CHECK-DAG: %[[N1:.+]] = dim %[[ARG1]], %[[C1]] // CHECK-DAG: %[[N2:.+]] = dim %[[ARG2]], %[[C1]] -// CHECK: %[[ALLOC1:.+]] = alloc(%[[M]], %[[N1]]) -// CHECK: %[[ALLOC2:.+]] = alloc(%[[M]], %[[N2]]) +// CHECK: %[[ALLOC1:.+]] = memref.alloc(%[[M]], %[[N1]]) +// CHECK: %[[ALLOC2:.+]] = memref.alloc(%[[M]], %[[N2]]) // CHECK: scf.parallel (%[[IV0:.+]]) = (%[[C0]]) to (%[[M]]) // CHECK-SAME: step (%[[C16]]) { // CHECK: %[[TILE_M:.+]] = affine.min #[[MAP0]](%[[IV0]])[%[[M]]] diff --git a/mlir/test/Dialect/Linalg/fusion.mlir b/mlir/test/Dialect/Linalg/fusion.mlir --- a/mlir/test/Dialect/Linalg/fusion.mlir +++ b/mlir/test/Dialect/Linalg/fusion.mlir @@ -543,11 +543,11 @@ %c0 = constant 0 : index %c3 = constant 3 : index %c2 = constant 2 : index - %A = alloc (%M, %N): memref - %B = alloc (%M, %N): memref - %C = alloc (%M, %N): memref - %D = alloc (%M, %N): memref - %E = alloc (%M, %N): memref + %A = memref.alloc (%M, %N): memref + %B = memref.alloc (%M, %N): memref + %C = memref.alloc (%M, %N): memref + %D = memref.alloc (%M, %N): memref + %E = memref.alloc (%M, %N): memref linalg.generic #pointwise_2d_trait ins(%A, %A : memref, memref) outs(%B : memref) { @@ -601,7 +601,7 @@ %arg2: memref<100x10xf32>) { %c0 = constant 0 : index %c1 = constant 1 : index - %0 = alloc() {temp = true} : memref<100x10xf32> + %0 = memref.alloc() {temp = true} : memref<100x10xf32> linalg.generic { indexing_maps = [#map0, #map1], iterator_types = ["parallel", "parallel"]} @@ -610,7 +610,7 @@ ^bb0(%arg3: f32, %arg4: f32): // no predecessors linalg.yield %arg3 : f32 } - %1 = alloc() {temp = true} : memref<100x10xf32> + %1 = memref.alloc() {temp = true} : memref<100x10xf32> linalg.generic { indexing_maps = [#map1, #map1, #map1], iterator_types = ["parallel", "parallel"]} @@ -620,7 +620,7 @@ %2 = subf %arg3, %arg4 : f32 linalg.yield %2 : f32 } - dealloc %0 : memref<100x10xf32> + memref.dealloc %0 : memref<100x10xf32> %2 = dim %1, %c0 : memref<100x10xf32> %3 = dim %1, %c1 : memref<100x10xf32> %4 = dim %arg2, %c0 : memref<100x10xf32> @@ -642,7 +642,7 @@ } } } - dealloc %1 : memref<100x10xf32> + memref.dealloc %1 : memref<100x10xf32> return } // CHECK-LABEL: func @fusion @@ -719,9 +719,9 @@ %c3 = constant 3 : index %c4 = constant 4 : index - %A = alloca(%dim, %dim)[%s0, %s1] : memref - %B = alloca(%dim, %dim)[%s0, %s1] : memref - %C = alloc(%dim, %dim)[%s0, %s1] : memref + %A = memref.alloca(%dim, %dim)[%s0, %s1] : memref + %B = memref.alloca(%dim, %dim)[%s0, %s1] : memref + %C = memref.alloc(%dim, %dim)[%s0, %s1] : memref linalg.matmul ins(%A, %B : memref, memref) diff --git a/mlir/test/Dialect/Linalg/hoisting.mlir b/mlir/test/Dialect/Linalg/hoisting.mlir --- a/mlir/test/Dialect/Linalg/hoisting.mlir +++ b/mlir/test/Dialect/Linalg/hoisting.mlir @@ -10,77 +10,77 @@ // CHECK-SAME: %[[STEP:[a-zA-Z0-9]*]]: index, // CHECK-SAME: %[[CMP:[a-zA-Z0-9]*]]: i1 func @hoist_allocs(%val: index, %lb : index, %ub : index, %step: index, %cmp: i1) { -// CHECK-DAG: alloca(%[[VAL]]) : memref -// CHECK-DAG: %[[A0:.*]] = alloc(%[[VAL]]) : memref +// CHECK-DAG: memref.alloca(%[[VAL]]) : memref +// CHECK-DAG: %[[A0:.*]] = memref.alloc(%[[VAL]]) : memref // CHECK: scf.for %[[I:.*]] = %[[LB]] to %[[UB]] step %[[STEP]] { -// CHECK: alloca(%[[I]]) : memref -// CHECK: %[[A1:.*]] = alloc(%[[I]]) : memref +// CHECK: memref.alloca(%[[I]]) : memref +// CHECK: %[[A1:.*]] = memref.alloc(%[[I]]) : memref // CHECK: scf.for %[[J:.*]] = %[[LB]] to %[[UB]] step %[[STEP]] { -// CHECK-DAG: alloca(%[[J]]) : memref -// CHECK-DAG: %[[A2:.*]] = alloc(%[[J]]) : memref +// CHECK-DAG: memref.alloca(%[[J]]) : memref +// CHECK-DAG: %[[A2:.*]] = memref.alloc(%[[J]]) : memref // CHECK: scf.for %[[K:.*]] = %[[LB]] to %[[UB]] step %[[STEP]] { scf.for %i = %lb to %ub step %step { scf.for %j = %lb to %ub step %step { scf.for %k = %lb to %ub step %step { // Hoist allocs / deallocs outermost, keep view/subview below k. - %sa0 = alloca(%val) : memref - %a0 = alloc(%val) : memref -// CHECK: std.view %[[A0]][%[[LB]]][] : memref to memref<16xf32> + %sa0 = memref.alloca(%val) : memref + %a0 = memref.alloc(%val) : memref +// CHECK: memref.view %[[A0]][%[[LB]]][] : memref to memref<16xf32> // CHECK: subview %[[A0]][0] [42] [1] : memref to memref<42xi8> - %v0 = view %a0[%lb][] : memref to memref<16 x f32> + %v0 = memref.view %a0[%lb][] : memref to memref<16 x f32> %sv0 = subview %a0[0][42][1] : memref to memref<42 x i8> - dealloc %a0 : memref + memref.dealloc %a0 : memref // Hoist below i. - %sa1 = alloca(%i) : memref - %a1 = alloc(%i) : memref - dealloc %a1 : memref + %sa1 = memref.alloca(%i) : memref + %a1 = memref.alloc(%i) : memref + memref.dealloc %a1 : memref // Hoist below j. - %sa2 = alloca(%j) : memref - %a2 = alloc(%j) : memref - dealloc %a2 : memref + %sa2 = memref.alloca(%j) : memref + %a2 = memref.alloc(%j) : memref + memref.dealloc %a2 : memref // Don't hoist since k innermost. -// CHECK: alloca(%[[K]]) : memref -// CHECK: %[[A3:.*]] = alloc(%[[K]]) : memref -// CHECK: dealloc %[[A3]] : memref - %sa3 = alloca(%k) : memref - %a3 = alloc(%k) : memref - dealloc %a3 : memref +// CHECK: memref.alloca(%[[K]]) : memref +// CHECK: %[[A3:.*]] = memref.alloc(%[[K]]) : memref +// CHECK: memref.dealloc %[[A3]] : memref + %sa3 = memref.alloca(%k) : memref + %a3 = memref.alloc(%k) : memref + memref.dealloc %a3 : memref // No hoisting due to control flow. // CHECK: scf.if %[[CMP]] { -// CHECK: alloca(%[[VAL]]) : memref -// CHECK: %[[A4:.*]] = alloc(%[[VAL]]) : memref -// CHECK: dealloc %[[A4]] : memref +// CHECK: memref.alloca(%[[VAL]]) : memref +// CHECK: %[[A4:.*]] = memref.alloc(%[[VAL]]) : memref +// CHECK: memref.dealloc %[[A4]] : memref scf.if %cmp { - %sa4 = alloca(%val) : memref - %a4 = alloc(%val) : memref - dealloc %a4 : memref + %sa4 = memref.alloca(%val) : memref + %a4 = memref.alloc(%val) : memref + memref.dealloc %a4 : memref } // No hoisting due to load/store. -// CHECK: %[[SA5:.*]] = alloca(%[[VAL]]) : memref -// CHECK: %[[A5:.*]] = alloc(%[[VAL]]) : memref +// CHECK: %[[SA5:.*]] = memref.alloca(%[[VAL]]) : memref +// CHECK: %[[A5:.*]] = memref.alloc(%[[VAL]]) : memref // CHECK: load %[[A5]][%[[LB]]] : memref -// CHECK: store %{{.*}}, %[[SA5]][%[[LB]]] : memref -// CHECK: dealloc %[[A5]] : memref - %sa5 = alloca(%val) : memref - %a5 = alloc(%val) : memref +// CHECK: memref.store %{{.*}}, %[[SA5]][%[[LB]]] : memref +// CHECK: memref.dealloc %[[A5]] : memref + %sa5 = memref.alloca(%val) : memref + %a5 = memref.alloc(%val) : memref %v5 = load %a5[%lb] : memref - store %v5, %sa5[%lb] : memref - dealloc %a5 : memref + memref.store %v5, %sa5[%lb] : memref + memref.dealloc %a5 : memref } } } // CHECK: } -// CHECK: dealloc %[[A2]] : memref +// CHECK: memref.dealloc %[[A2]] : memref // CHECK: } -// CHECK: dealloc %[[A1]] : memref +// CHECK: memref.dealloc %[[A1]] : memref // CHECK: } -// CHECK: dealloc %[[A0]] : memref +// CHECK: memref.dealloc %[[A0]] : memref return } diff --git a/mlir/test/Dialect/Linalg/invalid.mlir b/mlir/test/Dialect/Linalg/invalid.mlir --- a/mlir/test/Dialect/Linalg/invalid.mlir +++ b/mlir/test/Dialect/Linalg/invalid.mlir @@ -12,7 +12,7 @@ // expected-error @+3 {{store index operand count not equal to memref rank}} %c0 = constant 0 : index %f0 = constant 0.0 : f32 - store %f0, %v[%c0] : memref + memref.store %f0, %v[%c0] : memref } // ----- diff --git a/mlir/test/Dialect/Linalg/loops.mlir b/mlir/test/Dialect/Linalg/loops.mlir --- a/mlir/test/Dialect/Linalg/loops.mlir +++ b/mlir/test/Dialect/Linalg/loops.mlir @@ -34,9 +34,9 @@ func @matmul(%arg0: memref, %M: index, %N: index, %K: index) { %c0 = constant 0 : index %c1 = constant 1 : index - %A = view %arg0[%c0][%M, %K] : memref to memref - %B = view %arg0[%c0][%K, %N] : memref to memref - %C = view %arg0[%c0][%M, %N] : memref to memref + %A = memref.view %arg0[%c0][%M, %K] : memref to memref + %B = memref.view %arg0[%c0][%K, %N] : memref to memref + %C = memref.view %arg0[%c0][%M, %N] : memref to memref linalg.matmul ins(%A, %B: memref, memref) outs(%C: memref) return @@ -45,9 +45,9 @@ // CHECKLOOP-SAME: [[M:arg[0-9]+]]: index // CHECKLOOP-SAME: [[N:arg[0-9]+]]: index // CHECKLOOP-SAME: [[K:arg[0-9]+]]: index -// CHECKLOOP: %[[A:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKLOOP: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKLOOP: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref +// CHECKLOOP: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKLOOP: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKLOOP: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref // CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[M]] step %{{.*}} { // CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[N]] step %{{.*}} { // CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} { @@ -62,9 +62,9 @@ // CHECKPARALLEL-SAME: [[M:arg[0-9]+]]: index // CHECKPARALLEL-SAME: [[N:arg[0-9]+]]: index // CHECKPARALLEL-SAME: [[K:arg[0-9]+]]: index -// CHECKPARALLEL: %[[A:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKPARALLEL: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKPARALLEL: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref +// CHECKPARALLEL: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKPARALLEL: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKPARALLEL: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref // CHECKPARALLEL: scf.parallel (%{{.*}}, %{{.*}}) = (%{{.*}}, %{{.*}}) to (%[[M]], %[[N]]) step (%{{.*}}, %{{.*}} { // CHECKPARALLEL: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} { // CHECKPARALLEL-DAG: %[[a:.*]] = load %[[A]][%{{.*}}, %{{.*}}] : memref @@ -79,9 +79,9 @@ func @matvec(%arg0: memref, %M: index, %N: index) { %c0 = constant 0 : index %c1 = constant 1 : index - %2 = view %arg0[%c0][%M, %N] : memref to memref - %3 = view %arg0[%c0][%M] : memref to memref - %4 = view %arg0[%c0][%N] : memref to memref + %2 = memref.view %arg0[%c0][%M, %N] : memref to memref + %3 = memref.view %arg0[%c0][%M] : memref to memref + %4 = memref.view %arg0[%c0][%N] : memref to memref linalg.matvec ins(%2, %3: memref, memref) outs(%4 : memref) return @@ -89,9 +89,9 @@ // CHECKLOOP-LABEL: func @matvec(%{{.*}}: memref, // CHECKLOOP-SAME: [[M:arg[0-9]+]]: index // CHECKLOOP-SAME: [[K:arg[0-9]+]]: index -// CHECKLOOP: %[[A:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKLOOP: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKLOOP: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref +// CHECKLOOP: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKLOOP: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKLOOP: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref // CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[M]] step %{{.*}} { // CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} { // CHECKLOOP-DAG: %[[a:.*]] = load %[[A]][%{{.*}}, %{{.*}}] : memref @@ -104,9 +104,9 @@ // CHECKPARALLEL-LABEL: func @matvec(%{{.*}}: memref, // CHECKPARALLEL-SAME: [[M:arg[0-9]+]]: index // CHECKPARALLEL-SAME: [[K:arg[0-9]+]]: index -// CHECKPARALLEL: %[[A:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKPARALLEL: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref -// CHECKPARALLEL: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref to memref +// CHECKPARALLEL: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKPARALLEL: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref +// CHECKPARALLEL: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref to memref // CHECKPARALLEL: scf.parallel (%{{.*}}) = (%{{.*}}) to (%[[M]]) step (%{{.*}}) { // CHECKPARALLEL: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} { // CHECKPARALLEL-DAG: %[[a:.*]] = load %[[A]][%{{.*}}, %{{.*}}] : memref @@ -120,18 +120,18 @@ func @dot(%arg0: memref, %M: index) { %c0 = constant 0 : index %c1 = constant 1 : index - %1 = view %arg0[%c0][%M] : memref to memref - %2 = view %arg0[%c0][%M] : memref to memref - %3 = view %arg0[%c0][] : memref to memref + %1 = memref.view %arg0[%c0][%M] : memref to memref + %2 = memref.view %arg0[%c0][%M] : memref to memref + %3 = memref.view %arg0[%c0][] : memref to memref linalg.dot ins(%1, %2 : memref, memref) outs(%3 : memref) return } // CHECKLOOP-LABEL: func @dot(%{{.*}}: memref, // CHECKLOOP-SAME: [[K:arg[0-9]+]]: index -// CHECKLOOP: %[[A:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref -// CHECKLOOP: %[[B:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref -// CHECKLOOP: %[[C:.*]] = std.view %{{.*}}[{{.*}}][] : memref to memref +// CHECKLOOP: %[[A:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECKLOOP: %[[B:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECKLOOP: %[[C:.*]] = memref.view %{{.*}}[{{.*}}][] : memref to memref // CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} { // CHECKLOOP-DAG: %[[a:.*]] = load %[[A]][%{{.*}}] : memref // CHECKLOOP-DAG: %[[b:.*]] = load %[[B]][%{{.*}}] : memref @@ -142,9 +142,9 @@ // CHECKPARALLEL-LABEL: func @dot(%{{.*}}: memref, // CHECKPARALLEL-SAME: [[K:arg[0-9]+]]: index -// CHECKPARALLEL: %[[A:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref -// CHECKPARALLEL: %[[B:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref -// CHECKPARALLEL: %[[C:.*]] = std.view %{{.*}}[{{.*}}][] : memref to memref +// CHECKPARALLEL: %[[A:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECKPARALLEL: %[[B:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECKPARALLEL: %[[C:.*]] = memref.view %{{.*}}[{{.*}}][] : memref to memref // CHECKPARALLEL: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} { // CHECKPARALLEL-DAG: %[[a:.*]] = load %[[A]][%{{.*}}] : memref // CHECKPARALLEL-DAG: %[[b:.*]] = load %[[B]][%{{.*}}] : memref diff --git a/mlir/test/Dialect/Linalg/promote.mlir b/mlir/test/Dialect/Linalg/promote.mlir --- a/mlir/test/Dialect/Linalg/promote.mlir +++ b/mlir/test/Dialect/Linalg/promote.mlir @@ -14,9 +14,9 @@ %c2 = constant 2 : index %c0 = constant 0 : index %c1 = constant 1 : index - %3 = view %A[%c0][%M, %K] : memref to memref - %4 = view %A[%c0][%K, %N] : memref to memref - %5 = view %A[%c0][%M, %N] : memref to memref + %3 = memref.view %A[%c0][%M, %K] : memref to memref + %4 = memref.view %A[%c0][%K, %N] : memref to memref + %5 = memref.view %A[%c0][%M, %N] : memref to memref %6 = dim %3, %c0 : memref %7 = dim %3, %c1 : memref %8 = dim %4, %c1 : memref @@ -44,22 +44,22 @@ // CHECK: %[[vB:.*]] = subview {{.*}} : memref // CHECK: %[[vC:.*]] = subview {{.*}} : memref /// -// CHECK: %[[tmpA:.*]] = alloc() : memref<32xi8> -// ALLOCA: %[[tmpA:.*]] = alloca() : memref<32xi8> -// CHECK: %[[fullA:.*]] = std.view %[[tmpA]][{{.*}}][{{.*}}] : memref<32xi8> to memref -// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECK: %[[tmpA:.*]] = memref.alloc() : memref<32xi8> +// ALLOCA: %[[tmpA:.*]] = memref.alloca() : memref<32xi8> +// CHECK: %[[fullA:.*]] = memref.view %[[tmpA]][{{.*}}][{{.*}}] : memref<32xi8> to memref +// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref // CHECK: %[[partialA:.*]] = subview %[[fullA]]{{.*}} : memref to memref /// -// CHECK: %[[tmpB:.*]] = alloc() : memref<48xi8> -// ALLOCA: %[[tmpB:.*]] = alloca() : memref<48xi8> -// CHECK: %[[fullB:.*]] = std.view %[[tmpB]][{{.*}}][{{.*}}] : memref<48xi8> to memref -// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECK: %[[tmpB:.*]] = memref.alloc() : memref<48xi8> +// ALLOCA: %[[tmpB:.*]] = memref.alloca() : memref<48xi8> +// CHECK: %[[fullB:.*]] = memref.view %[[tmpB]][{{.*}}][{{.*}}] : memref<48xi8> to memref +// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref // CHECK: %[[partialB:.*]] = subview %[[fullB]]{{.*}} : memref to memref /// -// CHECK: %[[tmpC:.*]] = alloc() : memref<24xi8> -// ALLOCA: %[[tmpC:.*]] = alloca() : memref<24xi8> -// CHECK: %[[fullC:.*]] = std.view %[[tmpC]][{{.*}}][{{.*}}] : memref<24xi8> to memref -// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECK: %[[tmpC:.*]] = memref.alloc() : memref<24xi8> +// ALLOCA: %[[tmpC:.*]] = memref.alloca() : memref<24xi8> +// CHECK: %[[fullC:.*]] = memref.view %[[tmpC]][{{.*}}][{{.*}}] : memref<24xi8> to memref +// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref // CHECK: %[[partialC:.*]] = subview %[[fullC]]{{.*}} : memref to memref // CHECK: linalg.copy(%[[vA]], %[[partialA]]) : memref, memref @@ -72,12 +72,12 @@ // CHECK: memref, // CHECK: memref // -// CHECK: dealloc %[[tmpA]] : memref<32xi8> -// CHECK: dealloc %[[tmpB]] : memref<48xi8> -// CHECK: dealloc %[[tmpC]] : memref<24xi8> -// ALLOCA-NOT: dealloc %[[tmpA]] : memref<32xi8> -// ALLOCA-NOT: dealloc %[[tmpB]] : memref<48xi8> -// ALLOCA-NOT: dealloc %[[tmpC]] : memref<24xi8> +// CHECK: memref.dealloc %[[tmpA]] : memref<32xi8> +// CHECK: memref.dealloc %[[tmpB]] : memref<48xi8> +// CHECK: memref.dealloc %[[tmpC]] : memref<24xi8> +// ALLOCA-NOT: memref.dealloc %[[tmpA]] : memref<32xi8> +// ALLOCA-NOT: memref.dealloc %[[tmpB]] : memref<48xi8> +// ALLOCA-NOT: memref.dealloc %[[tmpC]] : memref<24xi8> // ----- @@ -87,9 +87,9 @@ %c2 = constant 2 : index %c0 = constant 0 : index %c1 = constant 1 : index - %3 = view %A[%c0][%M, %K] : memref to memref - %4 = view %A[%c0][%K, %N] : memref to memref - %5 = view %A[%c0][%M, %N] : memref to memref + %3 = memref.view %A[%c0][%M, %K] : memref to memref + %4 = memref.view %A[%c0][%K, %N] : memref to memref + %5 = memref.view %A[%c0][%M, %N] : memref to memref %6 = dim %3, %c0 : memref %7 = dim %3, %c1 : memref %8 = dim %4, %c1 : memref @@ -117,19 +117,19 @@ // CHECK: %[[vB_f64:.*]] = subview {{.*}} : memref // CHECK: %[[vC_f64:.*]] = subview {{.*}} : memref /// -// CHECK: %[[tmpA_f64:.*]] = alloc() : memref<64xi8> -// CHECK: %[[fullA_f64:.*]] = std.view %[[tmpA_f64]][{{.*}}][{{.*}}] : memref<64xi8> to memref -// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECK: %[[tmpA_f64:.*]] = memref.alloc() : memref<64xi8> +// CHECK: %[[fullA_f64:.*]] = memref.view %[[tmpA_f64]][{{.*}}][{{.*}}] : memref<64xi8> to memref +// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref // CHECK: %[[partialA_f64:.*]] = subview %[[fullA_f64]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref to memref /// -// CHECK: %[[tmpB_f64:.*]] = alloc() : memref<96xi8> -// CHECK: %[[fullB_f64:.*]] = std.view %[[tmpB_f64]][{{.*}}][{{.*}}] : memref<96xi8> to memref -// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECK: %[[tmpB_f64:.*]] = memref.alloc() : memref<96xi8> +// CHECK: %[[fullB_f64:.*]] = memref.view %[[tmpB_f64]][{{.*}}][{{.*}}] : memref<96xi8> to memref +// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref // CHECK: %[[partialB_f64:.*]] = subview %[[fullB_f64]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref to memref /// -// CHECK: %[[tmpC_f64:.*]] = alloc() : memref<48xi8> -// CHECK: %[[fullC_f64:.*]] = std.view %[[tmpC_f64]][{{.*}}][{{.*}}] : memref<48xi8> to memref -// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref +// CHECK: %[[tmpC_f64:.*]] = memref.alloc() : memref<48xi8> +// CHECK: %[[fullC_f64:.*]] = memref.view %[[tmpC_f64]][{{.*}}][{{.*}}] : memref<48xi8> to memref +// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref to memref // CHECK: %[[partialC_f64:.*]] = subview %[[fullC_f64]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref to memref // CHECK: linalg.copy(%[[vA_f64]], %[[partialA_f64]]) : memref, memref @@ -142,6 +142,6 @@ // CHECK: memref, // CHECK: memref // -// CHECK: dealloc %[[tmpA_f64]] : memref<64xi8> -// CHECK: dealloc %[[tmpB_f64]] : memref<96xi8> -// CHECK: dealloc %[[tmpC_f64]] : memref<48xi8> +// CHECK: memref.dealloc %[[tmpA_f64]] : memref<64xi8> +// CHECK: memref.dealloc %[[tmpB_f64]] : memref<96xi8> +// CHECK: memref.dealloc %[[tmpC_f64]] : memref<48xi8> diff --git a/mlir/test/Dialect/Linalg/promotion_options.mlir b/mlir/test/Dialect/Linalg/promotion_options.mlir --- a/mlir/test/Dialect/Linalg/promotion_options.mlir +++ b/mlir/test/Dialect/Linalg/promotion_options.mlir @@ -19,9 +19,9 @@ // CHECK: %[[T7:.+]] = subview %[[ARG0]] // CHECK: %[[T12:.+]] = subview %[[ARG1]] // CHECK: %[[T17:.+]] = subview %[[ARG2]] -// CHECK: %[[T18:.+]] = alloc(%{{.*}}, %{{.*}}) : memref +// CHECK: %[[T18:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref // CHECK: %[[T19:.+]] = subview %[[T18]] -// CHECK: %[[T20:.+]] = alloc(%{{.*}}, %{{.*}}) : memref +// CHECK: %[[T20:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref // CHECK: %[[T21:.+]] = subview %[[T20]] // CHECK: linalg.fill(%[[T19]], %[[C42]]) // CHECK: linalg.copy(%[[T7]], %[[T19]]) @@ -30,5 +30,5 @@ // CHECK: linalg.matmul ins(%[[T19]], %[[T12]]{{.*}} outs(%[[T21]] // CHECK-NOT: linalg.fill // CHECK: linalg.copy(%[[T21]], %[[T17]]) -// CHECK: dealloc %[[T18]] -// CHECK: dealloc %[[T20]] +// CHECK: memref.dealloc %[[T18]] +// CHECK: memref.dealloc %[[T20]] diff --git a/mlir/test/Dialect/Linalg/roundtrip.mlir b/mlir/test/Dialect/Linalg/roundtrip.mlir --- a/mlir/test/Dialect/Linalg/roundtrip.mlir +++ b/mlir/test/Dialect/Linalg/roundtrip.mlir @@ -88,22 +88,22 @@ func @views(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4: index) { %c0 = constant 0 : index %0 = muli %arg0, %arg0 : index - %1 = alloc (%0) : memref + %1 = memref.alloc (%0) : memref %2 = linalg.range %arg0:%arg1:%arg2 : !linalg.range - %3 = view %1[%c0][%arg0, %arg0] : memref to memref - %4 = view %1[%c0][%arg0, %arg0] : memref to memref> - dealloc %1 : memref + %3 = memref.view %1[%c0][%arg0, %arg0] : memref to memref + %4 = memref.view %1[%c0][%arg0, %arg0] : memref to memref> + memref.dealloc %1 : memref return } // CHECK-LABEL: func @views // CHECK: muli %{{.*}}, %{{.*}} : index -// CHECK-NEXT: alloc(%{{.*}}) : memref +// CHECK-NEXT: memref.alloc(%{{.*}}) : memref // CHECK-NEXT: range -// CHECK-NEXT: std.view %{{.*}}[%{{.*}}][%{{.*}}] : +// CHECK-NEXT: memref.view %{{.*}}[%{{.*}}][%{{.*}}] : // CHECK-SAME: memref to memref -// CHECK-NEXT: view %{{.*}}[%{{.*}}][%{{.*}}] : +// CHECK-NEXT: memref.view %{{.*}}[%{{.*}}][%{{.*}}] : // CHECK-SAME: memref to memref> -// CHECK-NEXT: dealloc %{{.*}} : memref +// CHECK-NEXT: memref.dealloc %{{.*}} : memref // ----- @@ -157,7 +157,7 @@ // CHECK-DAG: #[[$strided3DT:.*]] = affine_map<(d0, d1, d2)[s0, s1, s2] -> (d2 * s1 + s0 + d1 * s2 + d0)> func @transpose(%arg0: memref) { - %0 = transpose %arg0 (i, j, k) -> (k, j, i) : memref to memref (d2 * s1 + s0 + d1 * s2 + d0)>> + %0 = memref.transpose %arg0 (i, j, k) -> (k, j, i) : memref to memref (d2 * s1 + s0 + d1 * s2 + d0)>> return } // CHECK-LABEL: func @transpose diff --git a/mlir/test/Dialect/Linalg/sparse_1d.mlir b/mlir/test/Dialect/Linalg/sparse_1d.mlir --- a/mlir/test/Dialect/Linalg/sparse_1d.mlir +++ b/mlir/test/Dialect/Linalg/sparse_1d.mlir @@ -23,7 +23,7 @@ // CHECK: %[[VAL_5:.*]] = constant 1 : index // CHECK: %[[VAL_6:.*]] = tensor_to_memref %[[VAL_0]] : memref<32xf32> // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_8:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_8:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_7]], %[[VAL_8]]) : memref<32xf32>, memref<32xf32> // CHECK: scf.for %[[VAL_9:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_10:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_9]]] : memref<32xf32> @@ -53,7 +53,7 @@ // CHECK: %[[VAL_5:.*]] = constant 1 : index // CHECK: %[[VAL_6:.*]] = tensor_to_memref %[[VAL_0]] : memref<32xf32> // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_8:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_8:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_7]], %[[VAL_8]]) : memref<32xf32>, memref<32xf32> // CHECK: scf.for %[[VAL_9:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_10:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_9]]] : memref<32xf32> @@ -99,7 +99,7 @@ // CHECK: %[[VAL_8:.*]] = linalg.sparse_indices %[[VAL_0]], %[[VAL_4]] : tensor<32xf32> to memref // CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_11:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_11:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_12:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_13:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -152,7 +152,7 @@ // CHECK: %[[VAL_5:.*]] = linalg.sparse_indices %[[VAL_0]], %[[VAL_2]] : tensor<32xf32> to memref // CHECK: %[[VAL_6:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_1]] : memref<32xf32> -// CHECK: %[[VAL_8:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_8:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_7]], %[[VAL_8]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_9:.*]] = load %[[VAL_4]]{{\[}}%[[VAL_2]]] : memref // CHECK: %[[VAL_10:.*]] = load %[[VAL_4]]{{\[}}%[[VAL_3]]] : memref @@ -193,7 +193,7 @@ // CHECK: %[[VAL_6:.*]] = linalg.sparse_indices %[[VAL_0]], %[[VAL_3]] : tensor<32xf32> to memref // CHECK: %[[VAL_7:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_9:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_9:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_8]], %[[VAL_9]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_10:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_11:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -242,7 +242,7 @@ // CHECK: %[[VAL_6:.*]] = tensor_to_memref %[[VAL_0]] : memref<32xf32> // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_1]] : memref<32xf32> // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_9:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_9:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_8]], %[[VAL_9]]) : memref<32xf32>, memref<32xf32> // CHECK: scf.for %[[VAL_10:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_11:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_10]]] : memref<32xf32> @@ -274,7 +274,7 @@ // CHECK: %[[VAL_6:.*]] = tensor_to_memref %[[VAL_0]] : memref<32xf32> // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_1]] : memref<32xf32> // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_9:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_9:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_8]], %[[VAL_9]]) : memref<32xf32>, memref<32xf32> // CHECK: scf.for %[[VAL_10:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_11:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_10]]] : memref<32xf32> @@ -324,7 +324,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32xf32> to memref // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_12:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_13:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_14:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_6]]] : memref @@ -382,7 +382,7 @@ // CHECK: %[[VAL_7:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32> to memref // CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_10:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_10:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_9]], %[[VAL_10]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_11:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_12:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref @@ -435,7 +435,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<32xf32> // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_12:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_13:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_14:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -493,7 +493,7 @@ // CHECK: %[[VAL_7:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_1]] : memref<32xf32> // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_10:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_10:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_9]], %[[VAL_10]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_11:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_12:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -546,7 +546,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32> to memref // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_12:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_13:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -630,7 +630,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32> to memref // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<32xf32> -// CHECK: %[[VAL_12:.*]] = alloc() : memref<32xf32> +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<32xf32> // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<32xf32>, memref<32xf32> // CHECK: %[[VAL_13:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -708,7 +708,7 @@ // CHECK: %[[VAL_10:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<16xf32> to memref // CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<16xf32> to memref // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_3]] : memref<16xf32> -// CHECK: %[[VAL_13:.*]] = alloc() : memref<16xf32> +// CHECK: %[[VAL_13:.*]] = memref.alloc() : memref<16xf32> // CHECK: linalg.copy(%[[VAL_12]], %[[VAL_13]]) : memref<16xf32>, memref<16xf32> // CHECK: %[[VAL_14:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_15:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -799,7 +799,7 @@ // CHECK: %[[VAL_10:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<16xf32> to memref // CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<16xf32> to memref // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_3]] : memref<16xf32> -// CHECK: %[[VAL_13:.*]] = alloc() : memref<16xf32> +// CHECK: %[[VAL_13:.*]] = memref.alloc() : memref<16xf32> // CHECK: linalg.copy(%[[VAL_12]], %[[VAL_13]]) : memref<16xf32>, memref<16xf32> // CHECK: %[[VAL_14:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_15:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -897,7 +897,7 @@ // CHECK: %[[VAL_4:.*]] = linalg.sparse_pointers %[[VAL_0]], %[[VAL_2]] : tensor to memref // CHECK: %[[VAL_5:.*]] = linalg.sparse_values %[[VAL_0]] : tensor to memref // CHECK: %[[VAL_6:.*]] = tensor_to_memref %[[VAL_1]] : memref -// CHECK: %[[VAL_7:.*]] = alloc() : memref +// CHECK: %[[VAL_7:.*]] = memref.alloc() : memref // CHECK: linalg.copy(%[[VAL_6]], %[[VAL_7]]) : memref, memref // CHECK: %[[VAL_8:.*]] = load %[[VAL_4]]{{\[}}%[[VAL_2]]] : memref // CHECK: %[[VAL_9:.*]] = load %[[VAL_4]]{{\[}}%[[VAL_3]]] : memref @@ -950,7 +950,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<16xf32> to memref // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<16xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref -// CHECK: %[[VAL_12:.*]] = alloc() : memref +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref, memref // CHECK: %[[VAL_13:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -1065,7 +1065,7 @@ // CHECK: %[[VAL_11:.*]] = linalg.sparse_indices %[[VAL_2]], %[[VAL_4]] : tensor<16xf32> to memref // CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_2]] : tensor<16xf32> to memref // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_3]] : memref -// CHECK: %[[VAL_14:.*]] = alloc() : memref +// CHECK: %[[VAL_14:.*]] = memref.alloc() : memref // CHECK: linalg.copy(%[[VAL_13]], %[[VAL_14]]) : memref, memref // CHECK: %[[VAL_15:.*]] = load %[[VAL_9]][] : memref // CHECK: %[[VAL_16:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref diff --git a/mlir/test/Dialect/Linalg/sparse_2d.mlir b/mlir/test/Dialect/Linalg/sparse_2d.mlir --- a/mlir/test/Dialect/Linalg/sparse_2d.mlir +++ b/mlir/test/Dialect/Linalg/sparse_2d.mlir @@ -27,7 +27,7 @@ // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_0]] : memref<32x16xf32> // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_10:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_10:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_9]], %[[VAL_10]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { @@ -62,7 +62,7 @@ // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_0]] : memref<32x16xf32> // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_10:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_10:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_9]], %[[VAL_10]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: scf.for %[[VAL_11:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { @@ -115,7 +115,7 @@ // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_13:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_13:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_12]], %[[VAL_13]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: scf.for %[[VAL_14:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_7]] { // CHECK: %[[VAL_15:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_14]]] : memref @@ -177,7 +177,7 @@ // CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_11:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_11:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_13:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_12]]] : memref @@ -234,7 +234,7 @@ // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_13:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_13:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_12]], %[[VAL_13]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_14:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_6]]] : memref // CHECK: %[[VAL_15:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_7]]] : memref @@ -301,7 +301,7 @@ // CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_11:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_11:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_12:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_13:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -361,7 +361,7 @@ // CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_14:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_15:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_15:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_14]], %[[VAL_15]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_16:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_6]]] : memref // CHECK: %[[VAL_17:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_7]]] : memref @@ -453,7 +453,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16xf32> // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_12:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_13:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -516,7 +516,7 @@ // CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_16:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_16:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_15]], %[[VAL_16]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_17:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -681,7 +681,7 @@ // CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_16:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_16:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_15]], %[[VAL_16]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_17:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -793,7 +793,7 @@ // CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_16:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_16:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_15]], %[[VAL_16]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_17:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -958,7 +958,7 @@ // CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16xf32> -// CHECK: %[[VAL_16:.*]] = alloc() : memref<32x16xf32> +// CHECK: %[[VAL_16:.*]] = memref.alloc() : memref<32x16xf32> // CHECK: linalg.copy(%[[VAL_15]], %[[VAL_16]]) : memref<32x16xf32>, memref<32x16xf32> // CHECK: %[[VAL_17:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -1065,7 +1065,7 @@ // CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<16x32xf32> to memref // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref<32xf32> // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_2]] : memref<16xf32> -// CHECK: %[[VAL_11:.*]] = alloc() : memref<16xf32> +// CHECK: %[[VAL_11:.*]] = memref.alloc() : memref<16xf32> // CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref<16xf32>, memref<16xf32> // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK: %[[VAL_13:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_12]]] : memref @@ -1119,7 +1119,7 @@ // CHECK: %[[VAL_5:.*]] = linalg.sparse_pointers %[[VAL_0]], %[[VAL_4]] : tensor<10x20xf32> to memref // CHECK: %[[VAL_6:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<10x20xf32> to memref // CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_1]] : memref -// CHECK: %[[VAL_8:.*]] = alloc() : memref +// CHECK: %[[VAL_8:.*]] = memref.alloc() : memref // CHECK: linalg.copy(%[[VAL_7]], %[[VAL_8]]) : memref, memref // CHECK: scf.for %[[VAL_9:.*]] = %[[VAL_3]] to %[[VAL_2]] step %[[VAL_4]] { // CHECK: %[[VAL_10:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_9]]] : memref @@ -1172,7 +1172,7 @@ // CHECK: %[[VAL_8:.*]] = dim %[[VAL_1]], %[[VAL_3]] : tensor // CHECK: %[[VAL_9:.*]] = dim %[[VAL_1]], %[[VAL_4]] : tensor // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref -// CHECK: %[[VAL_11:.*]] = alloc(%[[VAL_8]], %[[VAL_9]]) : memref +// CHECK: %[[VAL_11:.*]] = memref.alloc(%[[VAL_8]], %[[VAL_9]]) : memref // CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref, memref // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_3]] to %[[VAL_8]] step %[[VAL_4]] { // CHECK: %[[VAL_13:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_12]]] : memref @@ -1235,7 +1235,7 @@ // CHECK: %[[VAL_14:.*]] = dim %[[VAL_3]], %[[VAL_4]] : tensor // CHECK: %[[VAL_15:.*]] = dim %[[VAL_3]], %[[VAL_5]] : tensor // CHECK: %[[VAL_16:.*]] = tensor_to_memref %[[VAL_3]] : memref -// CHECK: %[[VAL_17:.*]] = alloc(%[[VAL_14]], %[[VAL_15]]) : memref +// CHECK: %[[VAL_17:.*]] = memref.alloc(%[[VAL_14]], %[[VAL_15]]) : memref // CHECK: linalg.copy(%[[VAL_16]], %[[VAL_17]]) : memref, memref // CHECK: %[[VAL_18:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_19:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -1323,7 +1323,7 @@ // CHECK: %[[VAL_21:.*]] = tensor_to_memref %[[VAL_4]] : memref // CHECK: %[[VAL_22:.*]] = dim %[[VAL_5]], %[[VAL_6]] : tensor // CHECK: %[[VAL_23:.*]] = tensor_to_memref %[[VAL_5]] : memref -// CHECK: %[[VAL_24:.*]] = alloc(%[[VAL_22]]) : memref +// CHECK: %[[VAL_24:.*]] = memref.alloc(%[[VAL_22]]) : memref // CHECK: linalg.copy(%[[VAL_23]], %[[VAL_24]]) : memref, memref // CHECK: %[[VAL_25:.*]] = load %[[VAL_21]][] : memref // CHECK: %[[VAL_26:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_6]]] : memref diff --git a/mlir/test/Dialect/Linalg/sparse_3d.mlir b/mlir/test/Dialect/Linalg/sparse_3d.mlir --- a/mlir/test/Dialect/Linalg/sparse_3d.mlir +++ b/mlir/test/Dialect/Linalg/sparse_3d.mlir @@ -28,7 +28,7 @@ // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_0]] : memref<32x16x8xf32> // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_11:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_11:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_6]] to %[[VAL_3]] step %[[VAL_7]] { // CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_6]] to %[[VAL_4]] step %[[VAL_7]] { @@ -66,7 +66,7 @@ // CHECK: %[[VAL_8:.*]] = tensor_to_memref %[[VAL_0]] : memref<32x16x8xf32> // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_11:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_11:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_6]] to %[[VAL_3]] step %[[VAL_7]] { // CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_6]] to %[[VAL_4]] step %[[VAL_7]] { @@ -123,7 +123,7 @@ // CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_14:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_15:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_15:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_14]], %[[VAL_15]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_16:.*]] = %[[VAL_7]] to %[[VAL_4]] step %[[VAL_9]] { // CHECK: scf.for %[[VAL_17:.*]] = %[[VAL_7]] to %[[VAL_5]] step %[[VAL_9]] { @@ -191,7 +191,7 @@ // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_13:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_13:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_12]], %[[VAL_13]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_14:.*]] = %[[VAL_6]] to %[[VAL_4]] step %[[VAL_7]] { // CHECK: scf.for %[[VAL_15:.*]] = %[[VAL_6]] to %[[VAL_5]] step %[[VAL_7]] { @@ -253,7 +253,7 @@ // CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_14:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_13]], %[[VAL_14]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_15:.*]] = %[[VAL_7]] to %[[VAL_3]] step %[[VAL_8]] { // CHECK: %[[VAL_16:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_15]]] : memref @@ -324,7 +324,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_12:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_5]] to %[[VAL_3]] step %[[VAL_6]] { // CHECK: %[[VAL_14:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_13]]] : memref @@ -389,7 +389,7 @@ // CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_16:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_17:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_17:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_16]], %[[VAL_17]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_18:.*]] = %[[VAL_8]] to %[[VAL_4]] step %[[VAL_9]] { // CHECK: %[[VAL_19:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_18]]] : memref @@ -486,7 +486,7 @@ // CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_14:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_13]], %[[VAL_14]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: scf.for %[[VAL_15:.*]] = %[[VAL_5]] to %[[VAL_4]] step %[[VAL_6]] { // CHECK: %[[VAL_16:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_15]]] : memref @@ -550,7 +550,7 @@ // CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_14:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_13]], %[[VAL_14]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_15:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_7]]] : memref // CHECK: %[[VAL_16:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_8]]] : memref @@ -626,7 +626,7 @@ // CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_12:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_13:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_5]]] : memref // CHECK: %[[VAL_14:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -692,7 +692,7 @@ // CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_16:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_17:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_17:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_16]], %[[VAL_17]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_18:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_8]]] : memref // CHECK: %[[VAL_19:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_9]]] : memref @@ -794,7 +794,7 @@ // CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_14:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_14:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_13]], %[[VAL_14]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_15:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_5]]] : memref // CHECK: %[[VAL_16:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref @@ -861,7 +861,7 @@ // CHECK: %[[VAL_13:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_14:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_16:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_16:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_15]], %[[VAL_16]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_17:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_7]]] : memref // CHECK: %[[VAL_18:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_8]]] : memref @@ -966,7 +966,7 @@ // CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_13:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_13:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_12]], %[[VAL_13]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_14:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_15:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -1036,7 +1036,7 @@ // CHECK: %[[VAL_16:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_17:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_18:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_19:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_19:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_18]], %[[VAL_19]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_20:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_8]]] : memref // CHECK: %[[VAL_21:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_9]]] : memref @@ -1167,7 +1167,7 @@ // CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref // CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_1]] : memref<32x16x8xf32> // CHECK: %[[VAL_14:.*]] = tensor_to_memref %[[VAL_2]] : memref<32x16x8xf32> -// CHECK: %[[VAL_15:.*]] = alloc() : memref<32x16x8xf32> +// CHECK: %[[VAL_15:.*]] = memref.alloc() : memref<32x16x8xf32> // CHECK: linalg.copy(%[[VAL_14]], %[[VAL_15]]) : memref<32x16x8xf32>, memref<32x16x8xf32> // CHECK: %[[VAL_16:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref // CHECK: %[[VAL_17:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref @@ -1238,7 +1238,7 @@ // CHECK: %[[VAL_13:.*]] = dim %[[VAL_0]], %[[VAL_5]] : tensor // CHECK: %[[VAL_14:.*]] = dim %[[VAL_0]], %[[VAL_6]] : tensor // CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_0]] : memref -// CHECK: %[[VAL_16:.*]] = alloc(%[[VAL_13]], %[[VAL_14]]) : memref +// CHECK: %[[VAL_16:.*]] = memref.alloc(%[[VAL_13]], %[[VAL_14]]) : memref // CHECK: linalg.copy(%[[VAL_15]], %[[VAL_16]]) : memref, memref // CHECK: scf.for %[[VAL_17:.*]] = %[[VAL_5]] to %[[VAL_13]] step %[[VAL_6]] { // CHECK: scf.for %[[VAL_18:.*]] = %[[VAL_5]] to %[[VAL_10]] step %[[VAL_6]] { @@ -1305,7 +1305,7 @@ // CHECK: %[[VAL_7:.*]] = linalg.sparse_pointers %[[VAL_0]], %[[VAL_2]] : tensor<10x20x30xf32> to memref // CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<10x20x30xf32> to memref // CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref -// CHECK: %[[VAL_10:.*]] = alloc() : memref +// CHECK: %[[VAL_10:.*]] = memref.alloc() : memref // CHECK: linalg.copy(%[[VAL_9]], %[[VAL_10]]) : memref, memref // CHECK: %[[VAL_11:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref // CHECK: %[[VAL_12:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref @@ -1368,7 +1368,7 @@ // CHECK: %[[VAL_9:.*]] = dim %[[VAL_1]], %[[VAL_4]] : tensor // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref -// CHECK: %[[VAL_12:.*]] = alloc() : memref +// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref // CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref, memref // CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_4]] to %[[VAL_9]] step %[[VAL_5]] { // CHECK: %[[VAL_14:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_13]]] : memref @@ -1431,7 +1431,7 @@ // CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<20xf32> // CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<30xf32> // CHECK: %[[VAL_12:.*]] = tensor_to_memref %[[VAL_3]] : memref<10x20x30xf32> -// CHECK: %[[VAL_13:.*]] = alloc() : memref<10x20x30xf32> +// CHECK: %[[VAL_13:.*]] = memref.alloc() : memref<10x20x30xf32> // CHECK: linalg.copy(%[[VAL_12]], %[[VAL_13]]) : memref<10x20x30xf32>, memref<10x20x30xf32> // CHECK: scf.for %[[VAL_14:.*]] = %[[VAL_7]] to %[[VAL_4]] step %[[VAL_8]] { // CHECK: %[[VAL_15:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_14]]] : memref<10xf32> diff --git a/mlir/test/Dialect/Linalg/sparse_lower.mlir b/mlir/test/Dialect/Linalg/sparse_lower.mlir --- a/mlir/test/Dialect/Linalg/sparse_lower.mlir +++ b/mlir/test/Dialect/Linalg/sparse_lower.mlir @@ -47,7 +47,7 @@ // CHECK-HIR: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_6]] : tensor<64x64xf64> to memref // CHECK-HIR: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<64xf64> // CHECK-HIR: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<64xf64> -// CHECK-HIR: %[[VAL_12:.*]] = alloc() : memref<64xf64> +// CHECK-HIR: %[[VAL_12:.*]] = memref.alloc() : memref<64xf64> // CHECK-HIR: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<64xf64>, memref<64xf64> // CHECK-HIR: scf.for %[[VAL_13:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-HIR: %[[VAL_14:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_13]]] : memref @@ -80,7 +80,7 @@ // CHECK-MIR: %[[VAL_8:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr) -> memref // CHECK-MIR: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref<64xf64> // CHECK-MIR: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_2]] : memref<64xf64> -// CHECK-MIR: %[[VAL_11:.*]] = alloc() : memref<64xf64> +// CHECK-MIR: %[[VAL_11:.*]] = memref.alloc() : memref<64xf64> // CHECK-MIR: scf.for %[[VAL_12:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-MIR: %[[VAL_13:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_12]]] : memref<64xf64> // CHECK-MIR: store %[[VAL_13]], %[[VAL_11]]{{\[}}%[[VAL_12]]] : memref<64xf64> @@ -114,7 +114,7 @@ // CHECK-LIR: %[[VAL_6:.*]] = call @sparsePointers64(%[[VAL_0]], %[[VAL_5]]) : (!llvm.ptr, index) -> memref // CHECK-LIR: %[[VAL_7:.*]] = call @sparseIndices64(%[[VAL_0]], %[[VAL_5]]) : (!llvm.ptr, index) -> memref // CHECK-LIR: %[[VAL_8:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr) -> memref -// CHECK-LIR: %[[VAL_9:.*]] = alloc() : memref<64xf64> +// CHECK-LIR: %[[VAL_9:.*]] = memref.alloc() : memref<64xf64> // CHECK-LIR: scf.for %[[VAL_10:.*]] = %[[VAL_4]] to %[[VAL_3]] step %[[VAL_5]] { // CHECK-LIR: %[[VAL_11:.*]] = load %[[VAL_2]]{{\[}}%[[VAL_10]]] : memref<64xf64> // CHECK-LIR: store %[[VAL_11]], %[[VAL_9]]{{\[}}%[[VAL_10]]] : memref<64xf64> diff --git a/mlir/test/Dialect/Linalg/sparse_nd.mlir b/mlir/test/Dialect/Linalg/sparse_nd.mlir --- a/mlir/test/Dialect/Linalg/sparse_nd.mlir +++ b/mlir/test/Dialect/Linalg/sparse_nd.mlir @@ -40,7 +40,7 @@ // CHECK: %[[VAL_17:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<10x20x30x40x50x60x70x80xf32> to memref // CHECK: %[[VAL_18:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<10x20x30x40x50x60x70x80xf32> to memref // CHECK: %[[VAL_19:.*]] = tensor_to_memref %[[VAL_2]] : memref<10x20x30x40x50x60x70x80xf32> -// CHECK: %[[VAL_20:.*]] = alloc() : memref<10x20x30x40x50x60x70x80xf32> +// CHECK: %[[VAL_20:.*]] = memref.alloc() : memref<10x20x30x40x50x60x70x80xf32> // CHECK: linalg.copy(%[[VAL_19]], %[[VAL_20]]) : memref<10x20x30x40x50x60x70x80xf32>, memref<10x20x30x40x50x60x70x80xf32> // CHECK: scf.for %[[VAL_21:.*]] = %[[VAL_11]] to %[[VAL_10]] step %[[VAL_12]] { // CHECK: scf.for %[[VAL_22:.*]] = %[[VAL_11]] to %[[VAL_9]] step %[[VAL_12]] { @@ -71,7 +71,7 @@ // CHECK: %[[VAL_47:.*]] = load %[[VAL_13]]{{\[}}%[[VAL_44]], %[[VAL_41]], %[[VAL_38]], %[[VAL_37]], %[[VAL_32]], %[[VAL_25]], %[[VAL_22]], %[[VAL_21]]] : memref<10x20x30x40x50x60x70x80xf32> // CHECK: %[[VAL_48:.*]] = load %[[VAL_18]]{{\[}}%[[VAL_46]]] : memref // CHECK: %[[VAL_49:.*]] = mulf %[[VAL_47]], %[[VAL_48]] : f32 -// CHECK: store %[[VAL_49]], %[[VAL_20]]{{\[}}%[[VAL_44]], %[[VAL_41]], %[[VAL_38]], %[[VAL_37]], %[[VAL_32]], %[[VAL_25]], %[[VAL_22]], %[[VAL_21]]] : memref<10x20x30x40x50x60x70x80xf32> +// CHECK: memref.store %[[VAL_49]], %[[VAL_20]]{{\[}}%[[VAL_44]], %[[VAL_41]], %[[VAL_38]], %[[VAL_37]], %[[VAL_32]], %[[VAL_25]], %[[VAL_22]], %[[VAL_21]]] : memref<10x20x30x40x50x60x70x80xf32> // CHECK: } // CHECK: } // CHECK: } diff --git a/mlir/test/Dialect/Linalg/standard.mlir b/mlir/test/Dialect/Linalg/standard.mlir --- a/mlir/test/Dialect/Linalg/standard.mlir +++ b/mlir/test/Dialect/Linalg/standard.mlir @@ -20,11 +20,11 @@ // CHECK-SAME: %[[arg0:[a-zA-z0-9]*]]: memref, // CHECK-SAME: %[[arg1:[a-zA-z0-9]*]]: memref, // CHECK-SAME: %[[arg2:[a-zA-z0-9]*]]: memref) { -// CHECK: %[[o0:.*]] = memref_cast %[[arg0]] : +// CHECK: %[[o0:.*]] = memref.cast %[[arg0]] : // CHECK-SAME: memref to memref -// CHECK: %[[o1:.*]] = memref_cast %[[arg1]] : +// CHECK: %[[o1:.*]] = memref.cast %[[arg1]] : // CHECK-SAME: memref to memref -// CHECK: %[[o2:.*]] = memref_cast %[[arg2]] : +// CHECK: %[[o2:.*]] = memref.cast %[[arg2]] : // CHECK-SAME: memref to memref // CHECK: call @linalg_dot_viewsxf32_viewsxf32_viewf32( // CHECK-SAME: %[[o0]], %[[o1]], %[[o2]]) : @@ -37,9 +37,9 @@ // CHECK-LABEL: func @copy( // CHECK-SAME: %[[arg0:[a-zA-z0-9]*]]: memref, // CHECK-SAME: %[[arg1:[a-zA-z0-9]*]]: memref) { -// CHECK: %[[o0:.*]] = memref_cast %[[arg0]] : +// CHECK: %[[o0:.*]] = memref.cast %[[arg0]] : // CHECK-SAME: memref to memref -// CHECK: %[[o1:.*]] = memref_cast %[[arg1]] : +// CHECK: %[[o1:.*]] = memref.cast %[[arg1]] : // CHECK-SAME: memref to memref // CHECK: call @linalg_copy_viewsxsxsxf32_viewsxsxsxf32(%[[o0]], %[[o1]]) : // CHECK-SAME: memref, memref @@ -57,9 +57,9 @@ // CHECK-SAME: (d0, d1, d2) -> (d0, d2, d1) : memref // CHECK: %[[t1:.*]] = transpose %[[arg1]] // CHECK-SAME: (d0, d1, d2) -> (d2, d1, d0) : memref -// CHECK: %[[o0:.*]] = memref_cast %[[t0]] : +// CHECK: %[[o0:.*]] = memref.cast %[[t0]] : // CHECK-SAME: memref to memref -// CHECK: %[[o1:.*]] = memref_cast %[[t1]] : +// CHECK: %[[o1:.*]] = memref.cast %[[t1]] : // CHECK-SAME: memref to memref // CHECK: call @linalg_copy_viewsxsxsxf32_viewsxsxsxf32(%[[o0]], %[[o1]]) : // CHECK-SAME: memref, memref diff --git a/mlir/test/Dialect/Linalg/transform-patterns.mlir b/mlir/test/Dialect/Linalg/transform-patterns.mlir --- a/mlir/test/Dialect/Linalg/transform-patterns.mlir +++ b/mlir/test/Dialect/Linalg/transform-patterns.mlir @@ -248,16 +248,16 @@ // CHECK: %[[s0:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[s1:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[s2:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref to memref -// CHECK: %[[a0:.*]] = alloc({{%.*}}) : memref -// CHECK: %[[v0:.*]] = std.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref +// CHECK: %[[a0:.*]] = memref.alloc({{%.*}}) : memref +// CHECK: %[[v0:.*]] = memref.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[l0:.*]] = subview %[[v0]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] // CHECK-SAME: memref to memref -// CHECK: %[[a1:.*]] = alloc({{%.*}}) : memref -// CHECK: %[[v1:.*]] = std.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref +// CHECK: %[[a1:.*]] = memref.alloc({{%.*}}) : memref +// CHECK: %[[v1:.*]] = memref.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[l1:.*]] = subview %[[v1]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] // CHECK-SAME: memref to memref -// CHECK: %[[a2:.*]] = alloc({{%.*}}) : memref -// CHECK: %[[v2:.*]] = std.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref +// CHECK: %[[a2:.*]] = memref.alloc({{%.*}}) : memref +// CHECK: %[[v2:.*]] = memref.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[l2:.*]] = subview %[[v2]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] // CHECK-SAME: memref to memref // CHECK: linalg.copy(%[[s0]], %[[l0]]) : memref, memref @@ -307,14 +307,14 @@ // CHECK: %[[s0:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[s1:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[s2:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref to memref -// CHECK: %[[a0:.*]] = alloc({{%.*}}) : memref -// CHECK: %[[v0:.*]] = std.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref +// CHECK: %[[a0:.*]] = memref.alloc({{%.*}}) : memref +// CHECK: %[[v0:.*]] = memref.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[l0:.*]] = subview %[[v0]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref to memref -// CHECK-NOT: %[[a1:.*]] = alloc({{%.*}}) : memref -// CHECK-NOT: %[[v1:.*]] = std.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref +// CHECK-NOT: %[[a1:.*]] = memref.alloc({{%.*}}) : memref +// CHECK-NOT: %[[v1:.*]] = memref.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref // CHECK-NOT: %[[l0:.*]] = subview %[[v1]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref to memref -// CHECK-NOT: %[[a2:.*]] = alloc({{%.*}}) : memref -// CHECK-NOT: %[[v2:.*]] = std.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref +// CHECK-NOT: %[[a2:.*]] = memref.alloc({{%.*}}) : memref +// CHECK-NOT: %[[v2:.*]] = memref.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref // CHECK-NOT: %[[l0:.*]] = subview %[[v2]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref to memref // CHECK: linalg.copy(%[[s0]], %[[l0]]) : memref, memref // CHECK-NOT: linalg.copy(%[[s1]], %[[l1]]) : memref, memref @@ -338,8 +338,8 @@ // CHECK-LABEL: func @aligned_promote_fill // CHECK: %[[cf:.*]] = constant {{.*}} : f32 // CHECK: %[[s0:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref to memref -// CHECK: %[[a0:.*]] = alloc({{%.*}}) {alignment = 32 : i64} : memref -// CHECK: %[[v0:.*]] = std.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref +// CHECK: %[[a0:.*]] = memref.alloc({{%.*}}) {alignment = 32 : i64} : memref +// CHECK: %[[v0:.*]] = memref.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref to memref // CHECK: %[[l0:.*]] = subview %[[v0]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref to memref // CHECK: linalg.fill(%[[v0]], {{%.*}}) : memref, f32 // CHECK: linalg.copy(%[[s0]], %[[l0]]) : memref, memref diff --git a/mlir/test/Dialect/OpenACC/invalid.mlir b/mlir/test/Dialect/OpenACC/invalid.mlir --- a/mlir/test/Dialect/OpenACC/invalid.mlir +++ b/mlir/test/Dialect/OpenACC/invalid.mlir @@ -82,21 +82,21 @@ // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{wait_devnum cannot appear without waitOperands}} acc.update wait_devnum(%cst: index) host(%value: memref<10xf32>) // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{async attribute cannot appear with asyncOperand}} acc.update async(%cst: index) host(%value: memref<10xf32>) attributes {async} // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{wait attribute cannot appear with waitOperands}} acc.update wait(%cst: index) host(%value: memref<10xf32>) attributes {wait} @@ -162,14 +162,14 @@ // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{async attribute cannot appear with asyncOperand}} acc.exit_data async(%cst: index) delete(%value : memref<10xf32>) attributes {async} // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{wait_devnum cannot appear without waitOperands}} acc.exit_data wait_devnum(%cst: index) delete(%value : memref<10xf32>) @@ -181,20 +181,20 @@ // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{async attribute cannot appear with asyncOperand}} acc.enter_data async(%cst: index) create(%value : memref<10xf32>) attributes {async} // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{wait attribute cannot appear with waitOperands}} acc.enter_data wait(%cst: index) create(%value : memref<10xf32>) attributes {wait} // ----- %cst = constant 1 : index -%value = alloc() : memref<10xf32> +%value = memref.alloc() : memref<10xf32> // expected-error@+1 {{wait_devnum cannot appear without waitOperands}} acc.enter_data wait_devnum(%cst: index) create(%value : memref<10xf32>) diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir --- a/mlir/test/Dialect/OpenACC/ops.mlir +++ b/mlir/test/Dialect/OpenACC/ops.mlir @@ -20,7 +20,7 @@ %cij = load %C[%arg3, %arg4] : memref<10x10xf32> %p = mulf %a, %b : f32 %co = addf %cij, %p : f32 - store %co, %C[%arg3, %arg4] : memref<10x10xf32> + memref.store %co, %C[%arg3, %arg4] : memref<10x10xf32> } } } @@ -47,7 +47,7 @@ // CHECK-NEXT: %{{.*}} = load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32 // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32 -// CHECK-NEXT: store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> +// CHECK-NEXT: memref.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -75,7 +75,7 @@ %cij = load %C[%arg3, %arg4] : memref<10x10xf32> %p = mulf %a, %b : f32 %co = addf %cij, %p : f32 - store %co, %C[%arg3, %arg4] : memref<10x10xf32> + memref.store %co, %C[%arg3, %arg4] : memref<10x10xf32> } } } @@ -101,7 +101,7 @@ // CHECK-NEXT: %{{.*}} = load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32 // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32 -// CHECK-NEXT: store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> +// CHECK-NEXT: memref.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -130,7 +130,7 @@ %axy = load %a[%x, %y] : memref<10x10xf32> %bxy = load %b[%x, %y] : memref<10x10xf32> %tmp = addf %axy, %bxy : f32 - store %tmp, %c[%y] : memref<10xf32> + memref.store %tmp, %c[%y] : memref<10xf32> } acc.yield } @@ -142,7 +142,7 @@ %ci = load %c[%i] : memref<10xf32> %dx = load %d[%x] : memref<10xf32> %z = addf %ci, %dx : f32 - store %z, %d[%x] : memref<10xf32> + memref.store %z, %d[%x] : memref<10xf32> } acc.yield } attributes {seq} @@ -172,7 +172,7 @@ // CHECK-NEXT: %{{.*}} = load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> // CHECK-NEXT: %{{.*}} = load %{{.*}}[%{{.*}}, %{{.*}}] : memref<10x10xf32> // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32 -// CHECK-NEXT: store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32> +// CHECK-NEXT: memref.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32> // CHECK-NEXT: } // CHECK-NEXT: acc.yield // CHECK-NEXT: } @@ -181,7 +181,7 @@ // CHECK-NEXT: %{{.*}} = load %{{.*}}[%{{.*}}] : memref<10xf32> // CHECK-NEXT: %{{.*}} = load %{{.*}}[%{{.*}}] : memref<10xf32> // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32 -// CHECK-NEXT: store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32> +// CHECK-NEXT: memref.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32> // CHECK-NEXT: } // CHECK-NEXT: acc.yield // CHECK-NEXT: } attributes {seq} diff --git a/mlir/test/Dialect/SCF/canonicalize.mlir b/mlir/test/Dialect/SCF/canonicalize.mlir --- a/mlir/test/Dialect/SCF/canonicalize.mlir +++ b/mlir/test/Dialect/SCF/canonicalize.mlir @@ -10,7 +10,7 @@ %c10 = constant 10 : index scf.parallel (%i0, %i1, %i2) = (%c0, %c3, %c7) to (%c1, %c6, %c10) step (%c1, %c2, %c3) { %c42 = constant 42 : i32 - store %c42, %A[%i0, %i1, %i2] : memref + memref.store %c42, %A[%i0, %i1, %i2] : memref scf.yield } return @@ -25,7 +25,7 @@ // CHECK: [[C7:%.*]] = constant 7 : index // CHECK: [[C42:%.*]] = constant 42 : i32 // CHECK: scf.parallel ([[V0:%.*]]) = ([[C3]]) to ([[C6]]) step ([[C2]]) { -// CHECK: store [[C42]], [[ARG0]]{{\[}}[[C0]], [[V0]], [[C7]]] : memref +// CHECK: memref.store [[C42]], [[ARG0]]{{\[}}[[C0]], [[V0]], [[C7]]] : memref // CHECK: scf.yield // CHECK: } // CHECK: return diff --git a/mlir/test/Dialect/SCF/for-loop-specialization.mlir b/mlir/test/Dialect/SCF/for-loop-specialization.mlir --- a/mlir/test/Dialect/SCF/for-loop-specialization.mlir +++ b/mlir/test/Dialect/SCF/for-loop-specialization.mlir @@ -13,7 +13,7 @@ %B_elem = load %B[%i0] : memref %C_elem = load %C[%i0] : memref %sum_elem = addf %B_elem, %C_elem : f32 - store %sum_elem, %result[%i0] : memref + memref.store %sum_elem, %result[%i0] : memref } return } @@ -28,11 +28,11 @@ // CHECK: [[PRED:%.*]] = cmpi eq, [[MIN]], [[CST_1024]] : index // CHECK: scf.if [[PRED]] { // CHECK: scf.for [[IDX0:%.*]] = [[CST_0]] to [[CST_1024]] step [[CST_1]] { -// CHECK: store +// CHECK: memref.store // CHECK: } // CHECK: } else { // CHECK: scf.for [[IDX0:%.*]] = [[CST_0]] to [[MIN]] step [[CST_1]] { -// CHECK: store +// CHECK: memref.store // CHECK: } // CHECK: } // CHECK: return diff --git a/mlir/test/Dialect/SCF/loop-unroll.mlir b/mlir/test/Dialect/SCF/loop-unroll.mlir --- a/mlir/test/Dialect/SCF/loop-unroll.mlir +++ b/mlir/test/Dialect/SCF/loop-unroll.mlir @@ -8,7 +8,7 @@ %arg3: memref) { %0 = constant 7.0 : f32 scf.for %i0 = %arg0 to %arg1 step %arg2 { - store %0, %arg3[%i0] : memref + memref.store %0, %arg3[%i0] : memref } return } @@ -34,14 +34,14 @@ // Compute step of unrolled loop in V8. // UNROLL-BY-2-DAG: %[[V8:.*]] = muli %[[STEP]], %[[C2]] : index // UNROLL-BY-2: scf.for %[[IV:.*]] = %[[LB]] to %[[V7]] step %[[V8]] { -// UNROLL-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-2-NEXT: %[[C1_IV:.*]] = constant 1 : index // UNROLL-BY-2-NEXT: %[[V9:.*]] = muli %[[STEP]], %[[C1_IV]] : index // UNROLL-BY-2-NEXT: %[[V10:.*]] = addi %[[IV]], %[[V9]] : index -// UNROLL-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[V10]]] : memref +// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V10]]] : memref // UNROLL-BY-2-NEXT: } // UNROLL-BY-2-NEXT: scf.for %[[IV:.*]] = %[[V7]] to %[[UB]] step %[[STEP]] { -// UNROLL-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-2-NEXT: } // UNROLL-BY-2-NEXT: return @@ -67,18 +67,18 @@ // Compute step of unrolled loop in V8. // UNROLL-BY-3-DAG: %[[V8:.*]] = muli %[[STEP]], %[[C3]] : index // UNROLL-BY-3: scf.for %[[IV:.*]] = %[[LB]] to %[[V7]] step %[[V8]] { -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-3-NEXT: %[[C1_IV:.*]] = constant 1 : index // UNROLL-BY-3-NEXT: %[[V9:.*]] = muli %[[STEP]], %[[C1_IV]] : index // UNROLL-BY-3-NEXT: %[[V10:.*]] = addi %[[IV]], %[[V9]] : index -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[V10]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V10]]] : memref // UNROLL-BY-3-NEXT: %[[C2_IV:.*]] = constant 2 : index // UNROLL-BY-3-NEXT: %[[V11:.*]] = muli %[[STEP]], %[[C2_IV]] : index // UNROLL-BY-3-NEXT: %[[V12:.*]] = addi %[[IV]], %[[V11]] : index -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[V12]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V12]]] : memref // UNROLL-BY-3-NEXT: } // UNROLL-BY-3-NEXT: scf.for %[[IV:.*]] = %[[V7]] to %[[UB]] step %[[STEP]] { -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-3-NEXT: } // UNROLL-BY-3-NEXT: return @@ -88,7 +88,7 @@ %0 = constant 7.0 : f32 scf.for %i0 = %arg0 to %arg1 step %arg2 { scf.for %i1 = %arg3 to %arg4 step %arg5 { - store %0, %arg6[%i1] : memref + memref.store %0, %arg6[%i1] : memref } } return @@ -104,15 +104,15 @@ // // UNROLL-OUTER-BY-2: scf.for %[[IV0:.*]] = %[[LB0]] to %{{.*}} step %{{.*}} { // UNROLL-OUTER-BY-2-NEXT: scf.for %[[IV1:.*]] = %[[LB1]] to %[[UB1]] step %[[STEP1]] { -// UNROLL-OUTER-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV1]]] : memref +// UNROLL-OUTER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref // UNROLL-OUTER-BY-2-NEXT: } // UNROLL-OUTER-BY-2-NEXT: scf.for %[[IV1:.*]] = %[[LB1]] to %[[UB1]] step %[[STEP1]] { -// UNROLL-OUTER-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV1]]] : memref +// UNROLL-OUTER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref // UNROLL-OUTER-BY-2-NEXT: } // UNROLL-OUTER-BY-2-NEXT: } // UNROLL-OUTER-BY-2-NEXT: scf.for %[[IV0:.*]] = %{{.*}} to %[[UB0]] step %[[STEP0]] { // UNROLL-OUTER-BY-2-NEXT: scf.for %[[IV1:.*]] = %[[LB1]] to %[[UB1]] step %[[STEP1]] { -// UNROLL-OUTER-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV1]]] : memref +// UNROLL-OUTER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref // UNROLL-OUTER-BY-2-NEXT: } // UNROLL-OUTER-BY-2-NEXT: } // UNROLL-OUTER-BY-2-NEXT: return @@ -123,7 +123,7 @@ %0 = constant 7.0 : f32 scf.for %i0 = %arg0 to %arg1 step %arg2 { scf.for %i1 = %arg3 to %arg4 step %arg5 { - store %0, %arg6[%i1] : memref + memref.store %0, %arg6[%i1] : memref } } return @@ -139,14 +139,14 @@ // // UNROLL-INNER-BY-2: scf.for %[[IV0:.*]] = %[[LB0]] to %[[UB0]] step %[[STEP0]] { // UNROLL-INNER-BY-2: scf.for %[[IV1:.*]] = %[[LB1]] to %{{.*}} step %{{.*}} { -// UNROLL-INNER-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV1]]] : memref +// UNROLL-INNER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref // UNROLL-INNER-BY-2-NEXT: %[[C1_IV:.*]] = constant 1 : index // UNROLL-INNER-BY-2-NEXT: %[[V0:.*]] = muli %[[STEP1]], %[[C1_IV]] : index // UNROLL-INNER-BY-2-NEXT: %[[V1:.*]] = addi %[[IV1]], %[[V0]] : index -// UNROLL-INNER-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[V1]]] : memref +// UNROLL-INNER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref // UNROLL-INNER-BY-2-NEXT: } // UNROLL-INNER-BY-2-NEXT: scf.for %[[IV1:.*]] = %{{.*}} to %[[UB1]] step %[[STEP1]] { -// UNROLL-INNER-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV1]]] : memref +// UNROLL-INNER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref // UNROLL-INNER-BY-2-NEXT: } // UNROLL-INNER-BY-2-NEXT: } // UNROLL-INNER-BY-2-NEXT: return @@ -159,7 +159,7 @@ %ub = constant 20 : index %step = constant 1 : index scf.for %i0 = %lb to %ub step %step { - store %0, %arg0[%i0] : memref + memref.store %0, %arg0[%i0] : memref } return } @@ -171,11 +171,11 @@ // UNROLL-BY-2-DAG: %[[C20:.*]] = constant 20 : index // UNROLL-BY-2-DAG: %[[C2:.*]] = constant 2 : index // UNROLL-BY-2: scf.for %[[IV:.*]] = %[[C0]] to %[[C20]] step %[[C2]] { -// UNROLL-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-2-NEXT: %[[C1_IV:.*]] = constant 1 : index // UNROLL-BY-2-NEXT: %[[V0:.*]] = muli %[[C1]], %[[C1_IV]] : index // UNROLL-BY-2-NEXT: %[[V1:.*]] = addi %[[IV]], %[[V0]] : index -// UNROLL-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[V1]]] : memref +// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref // UNROLL-BY-2-NEXT: } // UNROLL-BY-2-NEXT: return @@ -187,7 +187,7 @@ %ub = constant 20 : index %step = constant 1 : index scf.for %i0 = %lb to %ub step %step { - store %0, %arg0[%i0] : memref + memref.store %0, %arg0[%i0] : memref } return } @@ -201,18 +201,18 @@ // UNROLL-BY-3-DAG: %[[C18:.*]] = constant 18 : index // UNROLL-BY-3-DAG: %[[C3:.*]] = constant 3 : index // UNROLL-BY-3: scf.for %[[IV:.*]] = %[[C0]] to %[[C18]] step %[[C3]] { -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-3-NEXT: %[[C1_IV:.*]] = constant 1 : index // UNROLL-BY-3-NEXT: %[[V0:.*]] = muli %[[C1]], %[[C1_IV]] : index // UNROLL-BY-3-NEXT: %[[V1:.*]] = addi %[[IV]], %[[V0]] : index -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[V1]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref // UNROLL-BY-3-NEXT: %[[C2_IV:.*]] = constant 2 : index // UNROLL-BY-3-NEXT: %[[V2:.*]] = muli %[[C1]], %[[C2_IV]] : index // UNROLL-BY-3-NEXT: %[[V3:.*]] = addi %[[IV]], %[[V2]] : index -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[V3]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V3]]] : memref // UNROLL-BY-3-NEXT: } // UNROLL-BY-3-NEXT: scf.for %[[IV:.*]] = %[[C18]] to %[[C20]] step %[[C1]] { -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-3-NEXT: } // UNROLL-BY-3-NEXT: return @@ -224,7 +224,7 @@ %ub = constant 10 : index %step = constant 1 : index scf.for %i0 = %lb to %ub step %step { - store %0, %arg0[%i0] : memref + memref.store %0, %arg0[%i0] : memref } return } @@ -237,17 +237,17 @@ // UNROLL-BY-3-DAG: %[[C9:.*]] = constant 9 : index // UNROLL-BY-3-DAG: %[[C3:.*]] = constant 3 : index // UNROLL-BY-3: scf.for %[[IV:.*]] = %[[C0]] to %[[C9]] step %[[C3]] { -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref // UNROLL-BY-3-NEXT: %[[C1_IV:.*]] = constant 1 : index // UNROLL-BY-3-NEXT: %[[V0:.*]] = muli %[[C1]], %[[C1_IV]] : index // UNROLL-BY-3-NEXT: %[[V1:.*]] = addi %[[IV]], %[[V0]] : index -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[V1]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref // UNROLL-BY-3-NEXT: %[[C2_IV:.*]] = constant 2 : index // UNROLL-BY-3-NEXT: %[[V2:.*]] = muli %[[C1]], %[[C2_IV]] : index // UNROLL-BY-3-NEXT: %[[V3:.*]] = addi %[[IV]], %[[V2]] : index -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[V3]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V3]]] : memref // UNROLL-BY-3-NEXT: } -// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[C9]]] : memref +// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[C9]]] : memref // UNROLL-BY-3-NEXT: return // Test unroll-up-to functionality. diff --git a/mlir/test/Dialect/SCF/parallel-loop-fusion.mlir b/mlir/test/Dialect/SCF/parallel-loop-fusion.mlir --- a/mlir/test/Dialect/SCF/parallel-loop-fusion.mlir +++ b/mlir/test/Dialect/SCF/parallel-loop-fusion.mlir @@ -29,22 +29,22 @@ %c2 = constant 2 : index %c0 = constant 0 : index %c1 = constant 1 : index - %sum = alloc() : memref<2x2xf32> + %sum = memref.alloc() : memref<2x2xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { %B_elem = load %B[%i, %j] : memref<2x2xf32> %C_elem = load %C[%i, %j] : memref<2x2xf32> %sum_elem = addf %B_elem, %C_elem : f32 - store %sum_elem, %sum[%i, %j] : memref<2x2xf32> + memref.store %sum_elem, %sum[%i, %j] : memref<2x2xf32> scf.yield } scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { %sum_elem = load %sum[%i, %j] : memref<2x2xf32> %A_elem = load %A[%i, %j] : memref<2x2xf32> %product_elem = mulf %sum_elem, %A_elem : f32 - store %product_elem, %result[%i, %j] : memref<2x2xf32> + memref.store %product_elem, %result[%i, %j] : memref<2x2xf32> scf.yield } - dealloc %sum : memref<2x2xf32> + memref.dealloc %sum : memref<2x2xf32> return } // CHECK-LABEL: func @fuse_two @@ -53,20 +53,20 @@ // CHECK: [[C2:%.*]] = constant 2 : index // CHECK: [[C0:%.*]] = constant 0 : index // CHECK: [[C1:%.*]] = constant 1 : index -// CHECK: [[SUM:%.*]] = alloc() +// CHECK: [[SUM:%.*]] = memref.alloc() // CHECK: scf.parallel ([[I:%.*]], [[J:%.*]]) = ([[C0]], [[C0]]) // CHECK-SAME: to ([[C2]], [[C2]]) step ([[C1]], [[C1]]) { // CHECK: [[B_ELEM:%.*]] = load [[B]]{{\[}}[[I]], [[J]]] // CHECK: [[C_ELEM:%.*]] = load [[C]]{{\[}}[[I]], [[J]]] // CHECK: [[SUM_ELEM:%.*]] = addf [[B_ELEM]], [[C_ELEM]] -// CHECK: store [[SUM_ELEM]], [[SUM]]{{\[}}[[I]], [[J]]] +// CHECK: memref.store [[SUM_ELEM]], [[SUM]]{{\[}}[[I]], [[J]]] // CHECK: [[SUM_ELEM_:%.*]] = load [[SUM]]{{\[}}[[I]], [[J]]] // CHECK: [[A_ELEM:%.*]] = load [[A]]{{\[}}[[I]], [[J]]] // CHECK: [[PRODUCT_ELEM:%.*]] = mulf [[SUM_ELEM_]], [[A_ELEM]] -// CHECK: store [[PRODUCT_ELEM]], [[RESULT]]{{\[}}[[I]], [[J]]] +// CHECK: memref.store [[PRODUCT_ELEM]], [[RESULT]]{{\[}}[[I]], [[J]]] // CHECK: scf.yield // CHECK: } -// CHECK: dealloc [[SUM]] +// CHECK: memref.dealloc [[SUM]] // ----- @@ -76,28 +76,28 @@ %c10 = constant 10 : index %c0 = constant 0 : index %c1 = constant 1 : index - %broadcast_rhs = alloc() : memref<100x10xf32> - %diff = alloc() : memref<100x10xf32> + %broadcast_rhs = memref.alloc() : memref<100x10xf32> + %diff = memref.alloc() : memref<100x10xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%c100, %c10) step (%c1, %c1) { %rhs_elem = load %rhs[%i] : memref<100xf32> - store %rhs_elem, %broadcast_rhs[%i, %j] : memref<100x10xf32> + memref.store %rhs_elem, %broadcast_rhs[%i, %j] : memref<100x10xf32> scf.yield } scf.parallel (%i, %j) = (%c0, %c0) to (%c100, %c10) step (%c1, %c1) { %lhs_elem = load %lhs[%i, %j] : memref<100x10xf32> %broadcast_rhs_elem = load %broadcast_rhs[%i, %j] : memref<100x10xf32> %diff_elem = subf %lhs_elem, %broadcast_rhs_elem : f32 - store %diff_elem, %diff[%i, %j] : memref<100x10xf32> + memref.store %diff_elem, %diff[%i, %j] : memref<100x10xf32> scf.yield } scf.parallel (%i, %j) = (%c0, %c0) to (%c100, %c10) step (%c1, %c1) { %diff_elem = load %diff[%i, %j] : memref<100x10xf32> %exp_elem = math.exp %diff_elem : f32 - store %exp_elem, %result[%i, %j] : memref<100x10xf32> + memref.store %exp_elem, %result[%i, %j] : memref<100x10xf32> scf.yield } - dealloc %broadcast_rhs : memref<100x10xf32> - dealloc %diff : memref<100x10xf32> + memref.dealloc %broadcast_rhs : memref<100x10xf32> + memref.dealloc %diff : memref<100x10xf32> return } // CHECK-LABEL: func @fuse_three @@ -107,23 +107,23 @@ // CHECK: [[C10:%.*]] = constant 10 : index // CHECK: [[C0:%.*]] = constant 0 : index // CHECK: [[C1:%.*]] = constant 1 : index -// CHECK: [[BROADCAST_RHS:%.*]] = alloc() -// CHECK: [[DIFF:%.*]] = alloc() +// CHECK: [[BROADCAST_RHS:%.*]] = memref.alloc() +// CHECK: [[DIFF:%.*]] = memref.alloc() // CHECK: scf.parallel ([[I:%.*]], [[J:%.*]]) = ([[C0]], [[C0]]) // CHECK-SAME: to ([[C100]], [[C10]]) step ([[C1]], [[C1]]) { // CHECK: [[RHS_ELEM:%.*]] = load [[RHS]]{{\[}}[[I]]] -// CHECK: store [[RHS_ELEM]], [[BROADCAST_RHS]]{{\[}}[[I]], [[J]]] +// CHECK: memref.store [[RHS_ELEM]], [[BROADCAST_RHS]]{{\[}}[[I]], [[J]]] // CHECK: [[LHS_ELEM:%.*]] = load [[LHS]]{{\[}}[[I]], [[J]]] // CHECK: [[BROADCAST_RHS_ELEM:%.*]] = load [[BROADCAST_RHS]] // CHECK: [[DIFF_ELEM:%.*]] = subf [[LHS_ELEM]], [[BROADCAST_RHS_ELEM]] -// CHECK: store [[DIFF_ELEM]], [[DIFF]]{{\[}}[[I]], [[J]]] +// CHECK: memref.store [[DIFF_ELEM]], [[DIFF]]{{\[}}[[I]], [[J]]] // CHECK: [[DIFF_ELEM_:%.*]] = load [[DIFF]]{{\[}}[[I]], [[J]]] // CHECK: [[EXP_ELEM:%.*]] = math.exp [[DIFF_ELEM_]] -// CHECK: store [[EXP_ELEM]], [[RESULT]]{{\[}}[[I]], [[J]]] +// CHECK: memref.store [[EXP_ELEM]], [[RESULT]]{{\[}}[[I]], [[J]]] // CHECK: scf.yield // CHECK: } -// CHECK: dealloc [[BROADCAST_RHS]] -// CHECK: dealloc [[DIFF]] +// CHECK: memref.dealloc [[BROADCAST_RHS]] +// CHECK: memref.dealloc [[DIFF]] // ----- @@ -196,7 +196,7 @@ scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { scf.yield } - %buffer = alloc() : memref<2x2xf32> + %buffer = memref.alloc() : memref<2x2xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { scf.yield } @@ -233,12 +233,12 @@ %c2 = constant 2 : index %c0 = constant 0 : index %c1 = constant 1 : index - %common_buf = alloc() : memref<2x2xf32> + %common_buf = memref.alloc() : memref<2x2xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { %B_elem = load %B[%i, %j] : memref<2x2xf32> %C_elem = load %C[%i, %j] : memref<2x2xf32> %sum_elem = addf %B_elem, %C_elem : f32 - store %sum_elem, %common_buf[%i, %j] : memref<2x2xf32> + memref.store %sum_elem, %common_buf[%i, %j] : memref<2x2xf32> scf.yield } scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { @@ -246,10 +246,10 @@ %sum_elem = load %common_buf[%k, %j] : memref<2x2xf32> %A_elem = load %A[%i, %j] : memref<2x2xf32> %product_elem = mulf %sum_elem, %A_elem : f32 - store %product_elem, %result[%i, %j] : memref<2x2xf32> + memref.store %product_elem, %result[%i, %j] : memref<2x2xf32> scf.yield } - dealloc %common_buf : memref<2x2xf32> + memref.dealloc %common_buf : memref<2x2xf32> return } // CHECK-LABEL: func @do_not_fuse_unmatching_write_read_patterns @@ -263,12 +263,12 @@ %c2 = constant 2 : index %c0 = constant 0 : index %c1 = constant 1 : index - %sum = alloc() : memref<2x2xf32> + %sum = memref.alloc() : memref<2x2xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { %B_elem = load %B[%i, %j] : memref<2x2xf32> %C_elem = load %common_buf[%i, %j] : memref<2x2xf32> %sum_elem = addf %B_elem, %C_elem : f32 - store %sum_elem, %sum[%i, %j] : memref<2x2xf32> + memref.store %sum_elem, %sum[%i, %j] : memref<2x2xf32> scf.yield } scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { @@ -276,10 +276,10 @@ %sum_elem = load %sum[%k, %j] : memref<2x2xf32> %A_elem = load %A[%i, %j] : memref<2x2xf32> %product_elem = mulf %sum_elem, %A_elem : f32 - store %product_elem, %common_buf[%j, %i] : memref<2x2xf32> + memref.store %product_elem, %common_buf[%j, %i] : memref<2x2xf32> scf.yield } - dealloc %sum : memref<2x2xf32> + memref.dealloc %sum : memref<2x2xf32> return } // CHECK-LABEL: func @do_not_fuse_unmatching_read_write_patterns @@ -292,7 +292,7 @@ %c2 = constant 2 : index %c0 = constant 0 : index %c1 = constant 1 : index - %buffer = alloc() : memref<2x2xf32> + %buffer = memref.alloc() : memref<2x2xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { scf.yield } @@ -315,24 +315,24 @@ %c2 = constant 2 : index %c0 = constant 0 : index %c1 = constant 1 : index - %sum = alloc() : memref<2x2xf32> + %sum = memref.alloc() : memref<2x2xf32> scf.parallel (%k) = (%c0) to (%c2) step (%c1) { scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { %B_elem = load %B[%i, %j] : memref<2x2xf32> %C_elem = load %C[%i, %j] : memref<2x2xf32> %sum_elem = addf %B_elem, %C_elem : f32 - store %sum_elem, %sum[%i, %j] : memref<2x2xf32> + memref.store %sum_elem, %sum[%i, %j] : memref<2x2xf32> scf.yield } scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) { %sum_elem = load %sum[%i, %j] : memref<2x2xf32> %A_elem = load %A[%i, %j] : memref<2x2xf32> %product_elem = mulf %sum_elem, %A_elem : f32 - store %product_elem, %result[%i, %j] : memref<2x2xf32> + memref.store %product_elem, %result[%i, %j] : memref<2x2xf32> scf.yield } } - dealloc %sum : memref<2x2xf32> + memref.dealloc %sum : memref<2x2xf32> return } // CHECK-LABEL: func @nested_fuse @@ -341,19 +341,19 @@ // CHECK: [[C2:%.*]] = constant 2 : index // CHECK: [[C0:%.*]] = constant 0 : index // CHECK: [[C1:%.*]] = constant 1 : index -// CHECK: [[SUM:%.*]] = alloc() +// CHECK: [[SUM:%.*]] = memref.alloc() // CHECK: scf.parallel // CHECK: scf.parallel ([[I:%.*]], [[J:%.*]]) = ([[C0]], [[C0]]) // CHECK-SAME: to ([[C2]], [[C2]]) step ([[C1]], [[C1]]) { // CHECK: [[B_ELEM:%.*]] = load [[B]]{{\[}}[[I]], [[J]]] // CHECK: [[C_ELEM:%.*]] = load [[C]]{{\[}}[[I]], [[J]]] // CHECK: [[SUM_ELEM:%.*]] = addf [[B_ELEM]], [[C_ELEM]] -// CHECK: store [[SUM_ELEM]], [[SUM]]{{\[}}[[I]], [[J]]] +// CHECK: memref.store [[SUM_ELEM]], [[SUM]]{{\[}}[[I]], [[J]]] // CHECK: [[SUM_ELEM_:%.*]] = load [[SUM]]{{\[}}[[I]], [[J]]] // CHECK: [[A_ELEM:%.*]] = load [[A]]{{\[}}[[I]], [[J]]] // CHECK: [[PRODUCT_ELEM:%.*]] = mulf [[SUM_ELEM_]], [[A_ELEM]] -// CHECK: store [[PRODUCT_ELEM]], [[RESULT]]{{\[}}[[I]], [[J]]] +// CHECK: memref.store [[PRODUCT_ELEM]], [[RESULT]]{{\[}}[[I]], [[J]]] // CHECK: scf.yield // CHECK: } // CHECK: } -// CHECK: dealloc [[SUM]] +// CHECK: memref.dealloc [[SUM]] diff --git a/mlir/test/Dialect/SCF/parallel-loop-specialization.mlir b/mlir/test/Dialect/SCF/parallel-loop-specialization.mlir --- a/mlir/test/Dialect/SCF/parallel-loop-specialization.mlir +++ b/mlir/test/Dialect/SCF/parallel-loop-specialization.mlir @@ -15,7 +15,7 @@ %B_elem = load %B[%i0, %i1] : memref %C_elem = load %C[%i0, %i1] : memref %sum_elem = addf %B_elem, %C_elem : f32 - store %sum_elem, %result[%i0, %i1] : memref + memref.store %sum_elem, %result[%i0, %i1] : memref } return } @@ -35,11 +35,11 @@ // CHECK: [[VAL_16:%.*]] = and [[VAL_13]], [[VAL_15]] : i1 // CHECK: scf.if [[VAL_16]] { // CHECK: scf.parallel ([[VAL_17:%.*]], [[VAL_18:%.*]]) = ([[VAL_6]], [[VAL_6]]) to ([[VAL_12]], [[VAL_14]]) step ([[VAL_7]], [[VAL_7]]) { -// CHECK: store +// CHECK: memref.store // CHECK: } // CHECK: } else { // CHECK: scf.parallel ([[VAL_22:%.*]], [[VAL_23:%.*]]) = ([[VAL_6]], [[VAL_6]]) to ([[VAL_10]], [[VAL_11]]) step ([[VAL_7]], [[VAL_7]]) { -// CHECK: store +// CHECK: memref.store // CHECK: } // CHECK: } // CHECK: return diff --git a/mlir/test/Dialect/SCF/parallel-loop-tiling.mlir b/mlir/test/Dialect/SCF/parallel-loop-tiling.mlir --- a/mlir/test/Dialect/SCF/parallel-loop-tiling.mlir +++ b/mlir/test/Dialect/SCF/parallel-loop-tiling.mlir @@ -8,7 +8,7 @@ %B_elem = load %B[%i0, %i1] : memref %C_elem = load %C[%i0, %i1] : memref %sum_elem = addf %B_elem, %C_elem : f32 - store %sum_elem, %result[%i0, %i1] : memref + memref.store %sum_elem, %result[%i0, %i1] : memref } return } @@ -30,7 +30,7 @@ // CHECK: [[V11:%.*]] = load [[ARG8]]{{\[}}[[V9]], [[V10]]] : memref // CHECK: [[V12:%.*]] = load [[ARG9]]{{\[}}[[V9]], [[V10]]] : memref // CHECK: [[V13:%.*]] = addf [[V11]], [[V12]] : f32 -// CHECK: store [[V13]], [[ARG10]]{{\[}}[[V9]], [[V10]]] : memref +// CHECK: memref.store [[V13]], [[ARG10]]{{\[}}[[V9]], [[V10]]] : memref // CHECK: } // CHECK: } // CHECK: return diff --git a/mlir/test/Dialect/Standard/canonicalize.mlir b/mlir/test/Dialect/Standard/canonicalize.mlir --- a/mlir/test/Dialect/Standard/canonicalize.mlir +++ b/mlir/test/Dialect/Standard/canonicalize.mlir @@ -102,7 +102,7 @@ // CHECK-SAME: %[[SHP:[0-9a-z]+]]: memref // CHECK-NEXT: %[[IDX:.*]] = constant 3 // CHECK-NEXT: %[[DIM:.*]] = load %[[SHP]][%[[IDX]]] -// CHECK-NEXT: store +// CHECK-NEXT: memref.store // CHECK-NOT: dim // CHECK: return %[[DIM]] : index func @dim_of_memref_reshape(%arg0: memref<*xf32>, %arg1: memref) @@ -111,7 +111,7 @@ %0 = memref_reshape %arg0(%arg1) : (memref<*xf32>, memref) -> memref<*xf32> // Update the shape to test that he load ends up in the right place. - store %c3, %arg1[%c3] : memref + memref.store %c3, %arg1[%c3] : memref %1 = dim %0, %c3 : memref<*xf32> return %1 : index } @@ -135,7 +135,7 @@ // CHECK-LABEL: func @tensor_cast_to_memref // CHECK-SAME: %[[ARG0:.+]]: tensor<4x6x16x32xi8> // CHECK: %[[M:.+]] = tensor_to_memref %[[ARG0]] : memref<4x6x16x32xi8> -// CHECK: %[[M1:.+]] = memref_cast %[[M]] : memref<4x6x16x32xi8> to memref +// CHECK: %[[M1:.+]] = memref.cast %[[M]] : memref<4x6x16x32xi8> to memref // CHECK: return %[[M1]] : memref func @tensor_cast_to_memref(%arg0 : tensor<4x6x16x32xi8>) -> memref { @@ -147,11 +147,11 @@ // CHECK-LABEL: func @subview_of_memcast // CHECK-SAME: %[[ARG0:.[a-z0-9A-Z_]+]]: memref<4x6x16x32xi8> // CHECK: %[[S:.+]] = subview %arg0[0, 1, 0, 0] [1, 1, 16, 32] [1, 1, 1, 1] : memref<4x6x16x32xi8> to memref<16x32xi8, #{{.*}}> -// CHECK: %[[M:.+]] = memref_cast %[[S]] : memref<16x32xi8, #{{.*}}> to memref<16x32xi8, #{{.*}}> +// CHECK: %[[M:.+]] = memref.cast %[[S]] : memref<16x32xi8, #{{.*}}> to memref<16x32xi8, #{{.*}}> // CHECK: return %[[M]] : memref<16x32xi8, #{{.*}}> func @subview_of_memcast(%arg : memref<4x6x16x32xi8>) -> memref<16x32xi8, affine_map<(d0, d1)[s0] -> (d0 * 32 + d1 + s0)>>{ - %0 = memref_cast %arg : memref<4x6x16x32xi8> to memref + %0 = memref.cast %arg : memref<4x6x16x32xi8> to memref %1 = subview %0[0, 1, 0, 0] [1, 1, 16, 32] [1, 1, 1, 1] : memref to memref<16x32xi8, affine_map<(d0, d1)[s0] -> (d0 * 32 + d1 + s0)>> diff --git a/mlir/test/Dialect/Standard/invalid.mlir b/mlir/test/Dialect/Standard/invalid.mlir --- a/mlir/test/Dialect/Standard/invalid.mlir +++ b/mlir/test/Dialect/Standard/invalid.mlir @@ -18,21 +18,21 @@ func @transpose_not_permutation(%v : memref(off + M * i + j)>>) { // expected-error @+1 {{expected a permutation map}} - transpose %v (i, j) -> (i, i) : memref(off + M * i + j)>> to memref(off + M * i + j)>> + memref.transpose %v (i, j) -> (i, i) : memref(off + M * i + j)>> to memref(off + M * i + j)>> } // ----- func @transpose_bad_rank(%v : memref(off + M * i + j)>>) { // expected-error @+1 {{expected a permutation map of same rank as the input}} - transpose %v (i) -> (i) : memref(off + M * i + j)>> to memref(off + M * i + j)>> + memref.transpose %v (i) -> (i) : memref(off + M * i + j)>> to memref(off + M * i + j)>> } // ----- func @transpose_wrong_type(%v : memref(off + M * i + j)>>) { // expected-error @+1 {{output type 'memref (d0 * s1 + s0 + d1)>>' does not match transposed input type 'memref (d0 * s1 + s0 + d1)>>'}} - transpose %v (i, j) -> (j, i) : memref(off + M * i + j)>> to memref(off + M * i + j)>> + memref.transpose %v (i, j) -> (j, i) : memref(off + M * i + j)>> to memref(off + M * i + j)>> } // ----- @@ -155,60 +155,60 @@ // ----- // expected-error @+1 {{type should be static shaped memref}} -global_memref @foo : i32 +memref.global @foo : i32 // ----- // expected-error @+1 {{type should be static shaped memref}} -global_memref @foo : i32 = 5 +memref.global @foo : i32 = 5 // ----- // expected-error @+1 {{type should be static shaped memref}} -global_memref @foo : memref<*xf32> +memref.global @foo : memref<*xf32> // ----- // expected-error @+1 {{type should be static shaped memref}} -global_memref @foo : memref +memref.global @foo : memref // ----- // expected-error @+1 {{initial value should be a unit or elements attribute}} -global_memref @foo : memref<2x2xf32> = "foo" +memref.global @foo : memref<2x2xf32> = "foo" // ----- // expected-error @+1 {{inferred shape of elements literal ([2]) does not match type ([2, 2])}} -global_memref @foo : memref<2x2xf32> = dense<[0.0, 1.0]> +memref.global @foo : memref<2x2xf32> = dense<[0.0, 1.0]> // ----- // expected-error @+1 {{expected valid '@'-identifier for symbol name}} -global_memref "private" "public" @foo : memref<2x2xf32> = "foo" +memref.global "private" "public" @foo : memref<2x2xf32> = "foo" // ----- // expected-error @+1 {{expected valid '@'-identifier for symbol name}} -global_memref constant external @foo : memref<2x2xf32> = "foo" +memref.global constant external @foo : memref<2x2xf32> = "foo" // ----- // constant qualifier must be after visibility. // expected-error @+1 {{expected valid '@'-identifier for symbol name}} -global_memref constant "private" @foo : memref<2x2xf32> = "foo" +memref.global constant "private" @foo : memref<2x2xf32> = "foo" // ----- // expected-error @+1 {{op visibility expected to be one of ["public", "private", "nested"], but got "priate"}} -global_memref "priate" constant @memref5 : memref<2xf32> = uninitialized +memref.global "priate" constant @memref5 : memref<2xf32> = uninitialized // ----- func @nonexistent_global_memref() { // expected-error @+1 {{'gv' does not reference a valid global memref}} - %0 = get_global_memref @gv : memref<3xf32> + %0 = memref.get_global @gv : memref<3xf32> return } @@ -218,17 +218,17 @@ func @nonexistent_global_memref() { // expected-error @+1 {{'foo' does not reference a valid global memref}} - %0 = get_global_memref @foo : memref<3xf32> + %0 = memref.get_global @foo : memref<3xf32> return } // ----- -global_memref @gv : memref<3xi32> +memref.global @gv : memref<3xi32> func @mismatched_types() { // expected-error @+1 {{result type 'memref<3xf32>' does not match type 'memref<3xi32>' of the global memref @gv}} - %0 = get_global_memref @gv : memref<3xf32> + %0 = memref.get_global @gv : memref<3xf32> return } diff --git a/mlir/test/Dialect/Standard/ops.mlir b/mlir/test/Dialect/Standard/ops.mlir --- a/mlir/test/Dialect/Standard/ops.mlir +++ b/mlir/test/Dialect/Standard/ops.mlir @@ -67,24 +67,24 @@ return %new_unranked : memref<*xf32> } -// CHECK-LABEL: global_memref @memref0 : memref<2xf32> -global_memref @memref0 : memref<2xf32> +// CHECK-LABEL: memref.global @memref0 : memref<2xf32> +memref.global @memref0 : memref<2xf32> -// CHECK-LABEL: global_memref constant @memref1 : memref<2xf32> = dense<[0.000000e+00, 1.000000e+00]> -global_memref constant @memref1 : memref<2xf32> = dense<[0.0, 1.0]> +// CHECK-LABEL: memref.global constant @memref1 : memref<2xf32> = dense<[0.000000e+00, 1.000000e+00]> +memref.global constant @memref1 : memref<2xf32> = dense<[0.0, 1.0]> -// CHECK-LABEL: global_memref @memref2 : memref<2xf32> = uninitialized -global_memref @memref2 : memref<2xf32> = uninitialized +// CHECK-LABEL: memref.global @memref2 : memref<2xf32> = uninitialized +memref.global @memref2 : memref<2xf32> = uninitialized -// CHECK-LABEL: global_memref "private" @memref3 : memref<2xf32> = uninitialized -global_memref "private" @memref3 : memref<2xf32> = uninitialized +// CHECK-LABEL: memref.global "private" @memref3 : memref<2xf32> = uninitialized +memref.global "private" @memref3 : memref<2xf32> = uninitialized -// CHECK-LABEL: global_memref "private" constant @memref4 : memref<2xf32> = uninitialized -global_memref "private" constant @memref4 : memref<2xf32> = uninitialized +// CHECK-LABEL: memref.global "private" constant @memref4 : memref<2xf32> = uninitialized +memref.global "private" constant @memref4 : memref<2xf32> = uninitialized // CHECK-LABEL: func @write_global_memref func @write_global_memref() { - %0 = get_global_memref @memref0 : memref<2xf32> + %0 = memref.get_global @memref0 : memref<2xf32> %1 = constant dense<[1.0, 2.0]> : tensor<2xf32> tensor_store %1, %0 : memref<2xf32> return @@ -92,7 +92,7 @@ // CHECK-LABEL: func @read_global_memref func @read_global_memref() { - %0 = get_global_memref @memref0 : memref<2xf32> + %0 = memref.get_global @memref0 : memref<2xf32> %1 = tensor_load %0 : memref<2xf32> return } diff --git a/mlir/test/Dialect/Tensor/bufferize.mlir b/mlir/test/Dialect/Tensor/bufferize.mlir --- a/mlir/test/Dialect/Tensor/bufferize.mlir +++ b/mlir/test/Dialect/Tensor/bufferize.mlir @@ -3,7 +3,7 @@ // CHECK-LABEL: func @tensor.cast( // CHECK-SAME: %[[TENSOR:.*]]: tensor) -> tensor<2xindex> { // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]] -// CHECK: %[[CASTED:.*]] = memref_cast %[[MEMREF]] : memref to memref<2xindex> +// CHECK: %[[CASTED:.*]] = memref.cast %[[MEMREF]] : memref to memref<2xindex> // CHECK: %[[RET:.*]] = tensor_load %[[CASTED]] // CHECK: return %[[RET]] : tensor<2xindex> func @tensor.cast(%arg0: tensor) -> tensor<2xindex> { @@ -14,7 +14,7 @@ // CHECK-LABEL: func @tensor.cast_from_unranked( // CHECK-SAME: %[[TENSOR:.*]]: tensor<*xf32>) -> tensor<2xf32> { // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]] : memref<*xf32> -// CHECK: %[[CASTED_MEMREF:.*]] = memref_cast %[[MEMREF]] : memref<*xf32> to memref<2xf32> +// CHECK: %[[CASTED_MEMREF:.*]] = memref.cast %[[MEMREF]] : memref<*xf32> to memref<2xf32> // CHECK: %[[RET:.*]] = tensor_load %[[CASTED_MEMREF]] : memref<2xf32> // CHECK: return %[[RET]] : tensor<2xf32> func @tensor.cast_from_unranked(%arg0: tensor<*xf32>) -> tensor<2xf32> { @@ -25,7 +25,7 @@ // CHECK-LABEL: func @tensor.cast_to_unranked( // CHECK-SAME: %[[TENSOR:.*]]: tensor<2xf32>) -> tensor<*xf32> { // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]] : memref<2xf32> -// CHECK: %[[CASTED_MEMREF:.*]] = memref_cast %[[MEMREF]] : memref<2xf32> to memref<*xf32> +// CHECK: %[[CASTED_MEMREF:.*]] = memref.cast %[[MEMREF]] : memref<2xf32> to memref<*xf32> // CHECK: %[[RET:.*]] = tensor_load %[[CASTED_MEMREF]] : memref<*xf32> // CHECK: return %[[RET]] : tensor<*xf32> func @tensor.cast_to_unranked(%arg0: tensor<2xf32>) -> tensor<*xf32> { @@ -48,7 +48,7 @@ // CHECK-LABEL: func @tensor.from_elements( // CHECK-SAME: %[[ELEM0:.*]]: index, // CHECK-SAME: %[[ELEM1:.*]]: index) -> tensor<2xindex> { -// CHECK: %[[MEMREF:.*]] = alloc() +// CHECK: %[[MEMREF:.*]] = memref.alloc() // CHECK: %[[C0:.*]] = constant 0 : index // CHECK: store %[[ELEM0]], %[[MEMREF]][%[[C0]]] // CHECK: %[[C1:.*]] = constant 1 : index @@ -63,7 +63,7 @@ // CHECK-LABEL: func @tensor.generate( // CHECK-SAME: %[[ARG:.*]]: tensor<*xf32>, // CHECK-SAME: %[[DYNAMIC_EXTENT:.*]]: index) -> tensor { -// CHECK: %[[MEMREF:.*]] = alloc(%[[DYNAMIC_EXTENT]]) : memref +// CHECK: %[[MEMREF:.*]] = memref.alloc(%[[DYNAMIC_EXTENT]]) : memref // CHECK: %[[C0:.*]] = constant 0 : index // CHECK: %[[C1:.*]] = constant 1 : index // CHECK: scf.parallel (%[[I:.*]]) = (%[[C0]]) to (%[[DYNAMIC_EXTENT]]) step (%[[C1]]) { @@ -88,7 +88,7 @@ // // CHECK-LABEL: func @tensor.generate_static_and_dynamic( // CHECK-SAME: %[[DYNAMIC_EXTENT:.*]]: index) -> tensor<16x?xindex> { -// CHECK: %[[MEMREF:.*]] = alloc(%[[DYNAMIC_EXTENT]]) : memref<16x?xindex> +// CHECK: %[[MEMREF:.*]] = memref.alloc(%[[DYNAMIC_EXTENT]]) : memref<16x?xindex> // CHECK: %[[C0:.*]] = constant 0 : index // CHECK: %[[C1:.*]] = constant 1 : index // CHECK: %[[C16:.*]] = constant 16 : index diff --git a/mlir/test/Dialect/Tensor/canonicalize.mlir b/mlir/test/Dialect/Tensor/canonicalize.mlir --- a/mlir/test/Dialect/Tensor/canonicalize.mlir +++ b/mlir/test/Dialect/Tensor/canonicalize.mlir @@ -209,12 +209,12 @@ // CHECK-SAME: %[[IDX:.*]]: index func @extract_from_tensor.generate_sideeffects(%idx: index, %tensor: tensor<*xf32>) -> index { %size = rank %tensor : tensor<*xf32> - %mem = alloc(%size) : memref + %mem = memref.alloc(%size) : memref // CHECK: %[[DTENSOR:.*]] = tensor.generate %0 = tensor.generate %size { ^bb0(%arg0: index): %1 = dim %tensor, %arg0 : tensor<*xf32> - store %1, %mem[%arg0] : memref + memref.store %1, %mem[%arg0] : memref tensor.yield %1 : index } : tensor // CHECK: %[[RES:.*]] = tensor.extract %[[DTENSOR]][%[[IDX]]] diff --git a/mlir/test/Dialect/Vector/canonicalize.mlir b/mlir/test/Dialect/Vector/canonicalize.mlir --- a/mlir/test/Dialect/Vector/canonicalize.mlir +++ b/mlir/test/Dialect/Vector/canonicalize.mlir @@ -255,7 +255,7 @@ func @cast_transfers(%A: memref<4x8xf32>) -> (vector<4x8xf32>) { %c0 = constant 0 : index %f0 = constant 0.0 : f32 - %0 = memref_cast %A : memref<4x8xf32> to memref + %0 = memref.cast %A : memref<4x8xf32> to memref // CHECK: vector.transfer_read %{{.*}} {masked = [false, false]} : memref<4x8xf32>, vector<4x8xf32> %1 = vector.transfer_read %0[%c0, %c0], %f0 : memref, vector<4x8xf32> diff --git a/mlir/test/Dialect/Vector/vector-contract-matvec-transforms.mlir b/mlir/test/Dialect/Vector/vector-contract-matvec-transforms.mlir --- a/mlir/test/Dialect/Vector/vector-contract-matvec-transforms.mlir +++ b/mlir/test/Dialect/Vector/vector-contract-matvec-transforms.mlir @@ -59,7 +59,7 @@ // CHECK: %[[T7:.*]] = vector.extract %[[T3]][1] : vector<2x2xf32> // CHECK: %[[T8:.*]] = vector.extract %[[T1]][1] : vector<2xf32> // CHECK: %[[T9:.*]] = vector.outerproduct %[[T7]], %[[T8]], %[[T6]] {kind = #vector.kind} : vector<2xf32>, f32 -// CHECK: store %[[T9]], %[[C]][] : memref> +// CHECK: memref.store %[[T9]], %[[C]][] : memref> // CHECK: return func @matvec2x2(%arg0: memref>, %arg1: memref>, %arg2: memref>) { @@ -67,7 +67,7 @@ %x = load %arg1[] : memref> %b = load %arg2[] : memref> %0 = vector.contract #matvec_trait %A, %x, %b : vector<2x2xf32>, vector<2xf32> into vector<2xf32> - store %0, %arg2[] : memref> + memref.store %0, %arg2[] : memref> return } @@ -85,7 +85,7 @@ // CHECK: %[[T7:.*]] = vector.extract %[[T3]][1] : vector<2x2xf32> // CHECK: %[[T8:.*]] = vector.extract %[[T1]][1] : vector<2xf32> // CHECK: %[[T9:.*]] = vector.outerproduct %[[T7]], %[[T8]], %[[T6]] {kind = #vector.kind} : vector<2xf32>, f32 -// CHECK: store %[[T9]], %[[C]][] : memref> +// CHECK: memref.store %[[T9]], %[[C]][] : memref> // CHECK: return func @matvecmax2x2(%arg0: memref>, %arg1: memref>, %arg2: memref>) { @@ -93,7 +93,7 @@ %x = load %arg1[] : memref> %b = load %arg2[] : memref> %0 = vector.contract #matvecmax_trait %A, %x, %b : vector<2x2xf32>, vector<2xf32> into vector<2xf32> - store %0, %arg2[] : memref> + memref.store %0, %arg2[] : memref> return } @@ -110,7 +110,7 @@ // CHECK: %[[T6:.*]] = vector.extract %[[T0]][1] : vector<2x2xf32> // CHECK: %[[T7:.*]] = vector.extract %[[T1]][1] : vector<2xf32> // CHECK: %[[T8:.*]] = vector.outerproduct %[[T6]], %[[T7]], %[[T5]] {kind = #vector.kind} : vector<2xf32>, f32 -// CHECK: store %[[T8]], %[[C]][] : memref> +// CHECK: memref.store %[[T8]], %[[C]][] : memref> // CHECK: return func @mattransvec2x2(%arg0: memref>, %arg1: memref>, %arg2: memref>) { @@ -118,7 +118,7 @@ %x = load %arg1[] : memref> %b = load %arg2[] : memref> %0 = vector.contract #mattransvec_trait %A, %x, %b : vector<2x2xf32>, vector<2xf32> into vector<2xf32> - store %0, %arg2[] : memref> + memref.store %0, %arg2[] : memref> return } @@ -136,7 +136,7 @@ // CHECK: %[[T7:.*]] = vector.extract %[[T3]][1] : vector<2x2xf32> // CHECK: %[[T8:.*]] = vector.extract %[[T1]][1] : vector<2xf32> // CHECK: %[[T9:.*]] = vector.outerproduct %[[T7]], %[[T8]], %[[T6]] {kind = #vector.kind} : vector<2xf32>, f32 -// CHECK: store %[[T9]], %[[C]][] : memref> +// CHECK: memref.store %[[T9]], %[[C]][] : memref> // CHECK: return func @vecmat2x2(%arg0: memref>, %arg1: memref>, %arg2: memref>) { @@ -144,7 +144,7 @@ %x = load %arg1[] : memref> %b = load %arg2[] : memref> %0 = vector.contract #vecmat_trait %x, %A, %b : vector<2xf32>, vector<2x2xf32> into vector<2xf32> - store %0, %arg2[] : memref> + memref.store %0, %arg2[] : memref> return } @@ -161,7 +161,7 @@ // CHECK: %[[T6:.*]] = vector.extract %[[T0]][1] : vector<2x2xf32> // CHECK: %[[T7:.*]] = vector.extract %[[T1]][1] : vector<2xf32> // CHECK: %[[T8:.*]] = vector.outerproduct %[[T6]], %[[T7]], %[[T5]] {kind = #vector.kind} : vector<2xf32>, f32 -// CHECK: store %[[T8]], %[[C]][] : memref> +// CHECK: memref.store %[[T8]], %[[C]][] : memref> // CHECK: return func @vecmattrans2x2(%arg0: memref>, %arg1: memref>, %arg2: memref>) { @@ -169,6 +169,6 @@ %x = load %arg1[] : memref> %b = load %arg2[] : memref> %0 = vector.contract #vecmattrans_trait %x, %A, %b : vector<2xf32>, vector<2x2xf32> into vector<2xf32> - store %0, %arg2[] : memref> + memref.store %0, %arg2[] : memref> return } diff --git a/mlir/test/Dialect/Vector/vector-transfer-full-partial-split.mlir b/mlir/test/Dialect/Vector/vector-transfer-full-partial-split.mlir --- a/mlir/test/Dialect/Vector/vector-transfer-full-partial-split.mlir +++ b/mlir/test/Dialect/Vector/vector-transfer-full-partial-split.mlir @@ -29,7 +29,7 @@ // CHECK-DAG: %[[c8:.*]] = constant 8 : index // CHECK-DAG: %[[cst:.*]] = constant 0.000000e+00 : f32 // alloca for boundary full tile - // CHECK: %[[alloc:.*]] = alloca() {alignment = 32 : i64} : memref<4x8xf32> + // CHECK: %[[alloc:.*]] = memref.alloca() {alignment = 32 : i64} : memref<4x8xf32> // %i + 4 <= dim(%A, 0) // CHECK: %[[idx0:.*]] = affine.apply #[[$map_p4]]()[%[[i]]] // CHECK: %[[d0:.*]] = dim %[[A]], %[[c0]] : memref @@ -49,7 +49,7 @@ // CHECK: %[[cast_alloc:.*]] = vector.type_cast %[[alloc]] : // CHECK-SAME: memref<4x8xf32> to memref> // CHECK: store %[[slow]], %[[cast_alloc]][] : memref> - // CHECK: %[[yielded:.*]] = memref_cast %[[alloc]] : + // CHECK: %[[yielded:.*]] = memref.cast %[[alloc]] : // CHECK-SAME: memref<4x8xf32> to memref // CHECK: scf.yield %[[yielded]], %[[c0]], %[[c0]] : // CHECK-SAME: memref, index, index @@ -62,7 +62,7 @@ // LINALG-DAG: %[[c8:.*]] = constant 8 : index // LINALG-DAG: %[[cst:.*]] = constant 0.000000e+00 : f32 // alloca for boundary full tile - // LINALG: %[[alloc:.*]] = alloca() {alignment = 32 : i64} : memref<4x8xf32> + // LINALG: %[[alloc:.*]] = memref.alloca() {alignment = 32 : i64} : memref<4x8xf32> // %i + 4 <= dim(%A, 0) // LINALG: %[[idx0:.*]] = affine.apply #[[$map_p4]]()[%[[i]]] // LINALG: %[[d0:.*]] = dim %[[A]], %[[c0]] : memref @@ -84,7 +84,7 @@ // LINALG: %[[sv:.*]] = subview %[[A]][%[[i]], %[[j]]] [%[[sv0]], %[[sv1]]] [1, 1] // LINALG-SAME: memref to memref // LINALG: linalg.copy(%[[sv]], %[[alloc]]) : memref, memref<4x8xf32> - // LINALG: %[[yielded:.*]] = memref_cast %[[alloc]] : + // LINALG: %[[yielded:.*]] = memref.cast %[[alloc]] : // LINALG-SAME: memref<4x8xf32> to memref // LINALG: scf.yield %[[yielded]], %[[c0]], %[[c0]] : // LINALG-SAME: memref, index, index @@ -117,7 +117,7 @@ // CHECK-DAG: %[[c8:.*]] = constant 8 : index // CHECK-DAG: %[[cst:.*]] = constant 0.000000e+00 : f32 // alloca for boundary full tile - // CHECK: %[[alloc:.*]] = alloca() {alignment = 32 : i64} : memref<4x8xf32> + // CHECK: %[[alloc:.*]] = memref.alloca() {alignment = 32 : i64} : memref<4x8xf32> // %i + 4 <= dim(%A, 0) // CHECK: %[[idx0:.*]] = affine.apply #[[$map_p4]]()[%[[i]]] // CHECK: %[[cmp0:.*]] = cmpi sle, %[[idx0]], %[[c7]] : index @@ -128,7 +128,7 @@ // CHECK: %[[cond:.*]] = and %[[cmp0]], %[[cmp1]] : i1 // CHECK: %[[ifres:.*]]:3 = scf.if %[[cond]] -> (memref, index, index) { // inBounds but not cast-compatible: yield a memref_casted form of %A - // CHECK: %[[casted:.*]] = memref_cast %arg0 : + // CHECK: %[[casted:.*]] = memref.cast %arg0 : // CHECK-SAME: memref<7x8xf32, #[[$map_2d_stride_1]]> to memref // CHECK: scf.yield %[[casted]], %[[i]], %[[j]] : // CHECK-SAME: memref, index, index @@ -140,7 +140,7 @@ // CHECK-SAME: memref<4x8xf32> to memref> // CHECK: store %[[slow]], %[[cast_alloc]][] : // CHECK-SAME: memref> - // CHECK: %[[yielded:.*]] = memref_cast %[[alloc]] : + // CHECK: %[[yielded:.*]] = memref.cast %[[alloc]] : // CHECK-SAME: memref<4x8xf32> to memref // CHECK: scf.yield %[[yielded]], %[[c0]], %[[c0]] : // CHECK-SAME: memref, index, index @@ -154,7 +154,7 @@ // LINALG-DAG: %[[c8:.*]] = constant 8 : index // LINALG-DAG: %[[cst:.*]] = constant 0.000000e+00 : f32 // alloca for boundary full tile - // LINALG: %[[alloc:.*]] = alloca() {alignment = 32 : i64} : memref<4x8xf32> + // LINALG: %[[alloc:.*]] = memref.alloca() {alignment = 32 : i64} : memref<4x8xf32> // %i + 4 <= dim(%A, 0) // LINALG: %[[idx0:.*]] = affine.apply #[[$map_p4]]()[%[[i]]] // LINALG: %[[cmp0:.*]] = cmpi sle, %[[idx0]], %[[c7]] : index @@ -165,7 +165,7 @@ // LINALG: %[[cond:.*]] = and %[[cmp0]], %[[cmp1]] : i1 // LINALG: %[[ifres:.*]]:3 = scf.if %[[cond]] -> (memref, index, index) { // inBounds but not cast-compatible: yield a memref_casted form of %A - // LINALG: %[[casted:.*]] = memref_cast %arg0 : + // LINALG: %[[casted:.*]] = memref.cast %arg0 : // LINALG-SAME: memref<7x8xf32, #[[$map_2d_stride_1]]> to memref // LINALG: scf.yield %[[casted]], %[[i]], %[[j]] : // LINALG-SAME: memref, index, index @@ -177,7 +177,7 @@ // LINALG: %[[sv:.*]] = subview %[[A]][%[[i]], %[[j]]] [%[[sv0]], %[[sv1]]] [1, 1] // LINALG-SAME: memref<7x8xf32, #[[$map_2d_stride_1]]> to memref // LINALG: linalg.copy(%[[sv]], %[[alloc]]) : memref, memref<4x8xf32> - // LINALG: %[[yielded:.*]] = memref_cast %[[alloc]] : + // LINALG: %[[yielded:.*]] = memref.cast %[[alloc]] : // LINALG-SAME: memref<4x8xf32> to memref // LINALG: scf.yield %[[yielded]], %[[c0]], %[[c0]] : // LINALG-SAME: memref, index, index diff --git a/mlir/test/Dialect/Vector/vector-transforms.mlir b/mlir/test/Dialect/Vector/vector-transforms.mlir --- a/mlir/test/Dialect/Vector/vector-transforms.mlir +++ b/mlir/test/Dialect/Vector/vector-transforms.mlir @@ -287,9 +287,9 @@ func @vector_transfers(%arg0: index, %arg1: index) { %cst = constant 0.000000e+00 : f32 - %0 = alloc(%arg0, %arg1) : memref - %1 = alloc(%arg0, %arg1) : memref - %2 = alloc(%arg0, %arg1) : memref + %0 = memref.alloc(%arg0, %arg1) : memref + %1 = memref.alloc(%arg0, %arg1) : memref + %2 = memref.alloc(%arg0, %arg1) : memref %cst_0 = constant 1.000000e+00 : f32 %cst_1 = constant 2.000000e+00 : f32 affine.for %arg2 = 0 to %arg0 step 4 { @@ -434,7 +434,7 @@ %cf0 = constant 0.000000e+00 : f32 %vf0 = splat %cf0 : vector<2x4xf32> - %0 = alloc() : memref<6x2x1xvector<2x4xf32>> + %0 = memref.alloc() : memref<6x2x1xvector<2x4xf32>> %1 = vector.transfer_read %0[%c0, %c0, %c0], %vf0 {permutation_map = affine_map<(d0, d1, d2) -> (d1, d2)>} diff --git a/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir b/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir --- a/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir +++ b/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir @@ -16,9 +16,9 @@ // CHECK: [[VAL_3:%.*]] = constant 4.000000e+00 : f64 // CHECK: [[VAL_4:%.*]] = constant 5.000000e+00 : f64 // CHECK: [[VAL_5:%.*]] = constant 6.000000e+00 : f64 -// CHECK: [[VAL_6:%.*]] = alloc() : memref<3x2xf64> -// CHECK: [[VAL_7:%.*]] = alloc() : memref<3x2xf64> -// CHECK: [[VAL_8:%.*]] = alloc() : memref<2x3xf64> +// CHECK: [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64> +// CHECK: [[VAL_7:%.*]] = memref.alloc() : memref<3x2xf64> +// CHECK: [[VAL_8:%.*]] = memref.alloc() : memref<2x3xf64> // CHECK: affine.store [[VAL_0]], [[VAL_8]][0, 0] : memref<2x3xf64> // CHECK: affine.store [[VAL_1]], [[VAL_8]][0, 1] : memref<2x3xf64> // CHECK: affine.store [[VAL_2]], [[VAL_8]][0, 2] : memref<2x3xf64> @@ -36,9 +36,9 @@ // CHECK: [[VAL_16:%.*]] = mulf [[VAL_14]], [[VAL_15]] : f64 // CHECK: affine.store [[VAL_16]], [[VAL_6]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64> // CHECK: toy.print [[VAL_6]] : memref<3x2xf64> -// CHECK: dealloc [[VAL_8]] : memref<2x3xf64> -// CHECK: dealloc [[VAL_7]] : memref<3x2xf64> -// CHECK: dealloc [[VAL_6]] : memref<3x2xf64> +// CHECK: memref.dealloc [[VAL_8]] : memref<2x3xf64> +// CHECK: memref.dealloc [[VAL_7]] : memref<3x2xf64> +// CHECK: memref.dealloc [[VAL_6]] : memref<3x2xf64> // OPT-LABEL: func @main() // OPT: [[VAL_0:%.*]] = constant 1.000000e+00 : f64 @@ -47,8 +47,8 @@ // OPT: [[VAL_3:%.*]] = constant 4.000000e+00 : f64 // OPT: [[VAL_4:%.*]] = constant 5.000000e+00 : f64 // OPT: [[VAL_5:%.*]] = constant 6.000000e+00 : f64 -// OPT: [[VAL_6:%.*]] = alloc() : memref<3x2xf64> -// OPT: [[VAL_7:%.*]] = alloc() : memref<2x3xf64> +// OPT: [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64> +// OPT: [[VAL_7:%.*]] = memref.alloc() : memref<2x3xf64> // OPT: affine.store [[VAL_0]], [[VAL_7]][0, 0] : memref<2x3xf64> // OPT: affine.store [[VAL_1]], [[VAL_7]][0, 1] : memref<2x3xf64> // OPT: affine.store [[VAL_2]], [[VAL_7]][0, 2] : memref<2x3xf64> @@ -61,5 +61,5 @@ // OPT: [[VAL_11:%.*]] = mulf [[VAL_10]], [[VAL_10]] : f64 // OPT: affine.store [[VAL_11]], [[VAL_6]]{{\[}}[[VAL_8]], [[VAL_9]]] : memref<3x2xf64> // OPT: toy.print [[VAL_6]] : memref<3x2xf64> -// OPT: dealloc [[VAL_7]] : memref<2x3xf64> -// OPT: dealloc [[VAL_6]] : memref<3x2xf64> +// OPT: memref.dealloc [[VAL_7]] : memref<2x3xf64> +// OPT: memref.dealloc [[VAL_6]] : memref<3x2xf64> diff --git a/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir b/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir --- a/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir +++ b/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir @@ -16,9 +16,9 @@ // CHECK: [[VAL_3:%.*]] = constant 4.000000e+00 : f64 // CHECK: [[VAL_4:%.*]] = constant 5.000000e+00 : f64 // CHECK: [[VAL_5:%.*]] = constant 6.000000e+00 : f64 -// CHECK: [[VAL_6:%.*]] = alloc() : memref<3x2xf64> -// CHECK: [[VAL_7:%.*]] = alloc() : memref<3x2xf64> -// CHECK: [[VAL_8:%.*]] = alloc() : memref<2x3xf64> +// CHECK: [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64> +// CHECK: [[VAL_7:%.*]] = memref.alloc() : memref<3x2xf64> +// CHECK: [[VAL_8:%.*]] = memref.alloc() : memref<2x3xf64> // CHECK: affine.store [[VAL_0]], [[VAL_8]][0, 0] : memref<2x3xf64> // CHECK: affine.store [[VAL_1]], [[VAL_8]][0, 1] : memref<2x3xf64> // CHECK: affine.store [[VAL_2]], [[VAL_8]][0, 2] : memref<2x3xf64> @@ -36,9 +36,9 @@ // CHECK: [[VAL_16:%.*]] = mulf [[VAL_14]], [[VAL_15]] : f64 // CHECK: affine.store [[VAL_16]], [[VAL_6]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64> // CHECK: toy.print [[VAL_6]] : memref<3x2xf64> -// CHECK: dealloc [[VAL_8]] : memref<2x3xf64> -// CHECK: dealloc [[VAL_7]] : memref<3x2xf64> -// CHECK: dealloc [[VAL_6]] : memref<3x2xf64> +// CHECK: memref.dealloc [[VAL_8]] : memref<2x3xf64> +// CHECK: memref.dealloc [[VAL_7]] : memref<3x2xf64> +// CHECK: memref.dealloc [[VAL_6]] : memref<3x2xf64> // OPT-LABEL: func @main() // OPT: [[VAL_0:%.*]] = constant 1.000000e+00 : f64 @@ -47,8 +47,8 @@ // OPT: [[VAL_3:%.*]] = constant 4.000000e+00 : f64 // OPT: [[VAL_4:%.*]] = constant 5.000000e+00 : f64 // OPT: [[VAL_5:%.*]] = constant 6.000000e+00 : f64 -// OPT: [[VAL_6:%.*]] = alloc() : memref<3x2xf64> -// OPT: [[VAL_7:%.*]] = alloc() : memref<2x3xf64> +// OPT: [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64> +// OPT: [[VAL_7:%.*]] = memref.alloc() : memref<2x3xf64> // OPT: affine.store [[VAL_0]], [[VAL_7]][0, 0] : memref<2x3xf64> // OPT: affine.store [[VAL_1]], [[VAL_7]][0, 1] : memref<2x3xf64> // OPT: affine.store [[VAL_2]], [[VAL_7]][0, 2] : memref<2x3xf64> @@ -61,5 +61,5 @@ // OPT: [[VAL_11:%.*]] = mulf [[VAL_10]], [[VAL_10]] : f64 // OPT: affine.store [[VAL_11]], [[VAL_6]]{{\[}}[[VAL_8]], [[VAL_9]]] : memref<3x2xf64> // OPT: toy.print [[VAL_6]] : memref<3x2xf64> -// OPT: dealloc [[VAL_7]] : memref<2x3xf64> -// OPT: dealloc [[VAL_6]] : memref<3x2xf64> +// OPT: memref.dealloc [[VAL_7]] : memref<2x3xf64> +// OPT: memref.dealloc [[VAL_6]] : memref<3x2xf64> diff --git a/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir b/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir --- a/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir +++ b/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir @@ -16,9 +16,9 @@ // CHECK: [[VAL_3:%.*]] = constant 4.000000e+00 : f64 // CHECK: [[VAL_4:%.*]] = constant 5.000000e+00 : f64 // CHECK: [[VAL_5:%.*]] = constant 6.000000e+00 : f64 -// CHECK: [[VAL_6:%.*]] = alloc() : memref<3x2xf64> -// CHECK: [[VAL_7:%.*]] = alloc() : memref<3x2xf64> -// CHECK: [[VAL_8:%.*]] = alloc() : memref<2x3xf64> +// CHECK: [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64> +// CHECK: [[VAL_7:%.*]] = memref.alloc() : memref<3x2xf64> +// CHECK: [[VAL_8:%.*]] = memref.alloc() : memref<2x3xf64> // CHECK: affine.store [[VAL_0]], [[VAL_8]][0, 0] : memref<2x3xf64> // CHECK: affine.store [[VAL_1]], [[VAL_8]][0, 1] : memref<2x3xf64> // CHECK: affine.store [[VAL_2]], [[VAL_8]][0, 2] : memref<2x3xf64> @@ -36,9 +36,9 @@ // CHECK: [[VAL_16:%.*]] = mulf [[VAL_14]], [[VAL_15]] : f64 // CHECK: affine.store [[VAL_16]], [[VAL_6]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64> // CHECK: toy.print [[VAL_6]] : memref<3x2xf64> -// CHECK: dealloc [[VAL_8]] : memref<2x3xf64> -// CHECK: dealloc [[VAL_7]] : memref<3x2xf64> -// CHECK: dealloc [[VAL_6]] : memref<3x2xf64> +// CHECK: memref.dealloc [[VAL_8]] : memref<2x3xf64> +// CHECK: memref.dealloc [[VAL_7]] : memref<3x2xf64> +// CHECK: memref.dealloc [[VAL_6]] : memref<3x2xf64> // OPT-LABEL: func @main() // OPT: [[VAL_0:%.*]] = constant 1.000000e+00 : f64 @@ -47,8 +47,8 @@ // OPT: [[VAL_3:%.*]] = constant 4.000000e+00 : f64 // OPT: [[VAL_4:%.*]] = constant 5.000000e+00 : f64 // OPT: [[VAL_5:%.*]] = constant 6.000000e+00 : f64 -// OPT: [[VAL_6:%.*]] = alloc() : memref<3x2xf64> -// OPT: [[VAL_7:%.*]] = alloc() : memref<2x3xf64> +// OPT: [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64> +// OPT: [[VAL_7:%.*]] = memref.alloc() : memref<2x3xf64> // OPT: affine.store [[VAL_0]], [[VAL_7]][0, 0] : memref<2x3xf64> // OPT: affine.store [[VAL_1]], [[VAL_7]][0, 1] : memref<2x3xf64> // OPT: affine.store [[VAL_2]], [[VAL_7]][0, 2] : memref<2x3xf64> @@ -61,5 +61,5 @@ // OPT: [[VAL_11:%.*]] = mulf [[VAL_10]], [[VAL_10]] : f64 // OPT: affine.store [[VAL_11]], [[VAL_6]]{{\[}}[[VAL_8]], [[VAL_9]]] : memref<3x2xf64> // OPT: toy.print [[VAL_6]] : memref<3x2xf64> -// OPT: dealloc [[VAL_7]] : memref<2x3xf64> -// OPT: dealloc [[VAL_6]] : memref<3x2xf64> +// OPT: memref.dealloc [[VAL_7]] : memref<2x3xf64> +// OPT: memref.dealloc [[VAL_6]] : memref<3x2xf64> diff --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir --- a/mlir/test/IR/core-ops.mlir +++ b/mlir/test/IR/core-ops.mlir @@ -546,11 +546,11 @@ // CHECK: %{{.*}} = load %arg0[%arg1, %arg1] : memref<4x4xi32> %3 = load %0[%1, %1] : memref<4x4xi32> - // CHECK: prefetch %arg0[%arg1, %arg1], write, locality<1>, data : memref<4x4xi32> - prefetch %0[%1, %1], write, locality<1>, data : memref<4x4xi32> + // CHECK: memref.prefetch %arg0[%arg1, %arg1], write, locality<1>, data : memref<4x4xi32> + memref.prefetch %0[%1, %1], write, locality<1>, data : memref<4x4xi32> - // CHECK: prefetch %arg0[%arg1, %arg1], read, locality<3>, instr : memref<4x4xi32> - prefetch %0[%1, %1], read, locality<3>, instr : memref<4x4xi32> + // CHECK: memref.prefetch %arg0[%arg1, %arg1], read, locality<3>, instr : memref<4x4xi32> + memref.prefetch %0[%1, %1], read, locality<3>, instr : memref<4x4xi32> return } @@ -559,10 +559,10 @@ // CHECK-LABEL: func @zero_dim_no_idx func @zero_dim_no_idx(%arg0 : memref, %arg1 : memref, %arg2 : memref) { %0 = std.load %arg0[] : memref - std.store %0, %arg1[] : memref + memref.store %0, %arg1[] : memref return // CHECK: %0 = load %{{.*}}[] : memref - // CHECK: store %{{.*}}, %{{.*}}[] : memref + // CHECK: memref.store %{{.*}}, %{{.*}}[] : memref } // CHECK-LABEL: func @return_op(%arg0: i32) -> i32 { @@ -600,23 +600,23 @@ // CHECK-LABEL: func @memref_cast(%arg0 func @memref_cast(%arg0: memref<4xf32>, %arg1 : memref, %arg2 : memref<64x16x4xf32, offset: 0, strides: [64, 4, 1]>) { - // CHECK: %0 = memref_cast %arg0 : memref<4xf32> to memref - %0 = memref_cast %arg0 : memref<4xf32> to memref + // CHECK: %0 = memref.cast %arg0 : memref<4xf32> to memref + %0 = memref.cast %arg0 : memref<4xf32> to memref - // CHECK: %1 = memref_cast %arg1 : memref to memref<4xf32> - %1 = memref_cast %arg1 : memref to memref<4xf32> + // CHECK: %1 = memref.cast %arg1 : memref to memref<4xf32> + %1 = memref.cast %arg1 : memref to memref<4xf32> - // CHECK: {{%.*}} = memref_cast %arg2 : memref<64x16x4xf32, #[[$BASE_MAP0]]> to memref<64x16x4xf32, #[[$BASE_MAP3]]> - %2 = memref_cast %arg2 : memref<64x16x4xf32, offset: 0, strides: [64, 4, 1]> to memref<64x16x4xf32, offset: ?, strides: [?, ?, ?]> + // CHECK: {{%.*}} = memref.cast %arg2 : memref<64x16x4xf32, #[[$BASE_MAP0]]> to memref<64x16x4xf32, #[[$BASE_MAP3]]> + %2 = memref.cast %arg2 : memref<64x16x4xf32, offset: 0, strides: [64, 4, 1]> to memref<64x16x4xf32, offset: ?, strides: [?, ?, ?]> - // CHECK: {{%.*}} = memref_cast {{%.*}} : memref<64x16x4xf32, #[[$BASE_MAP3]]> to memref<64x16x4xf32, #[[$BASE_MAP0]]> - %3 = memref_cast %2 : memref<64x16x4xf32, offset: ?, strides: [?, ?, ?]> to memref<64x16x4xf32, offset: 0, strides: [64, 4, 1]> + // CHECK: {{%.*}} = memref.cast {{%.*}} : memref<64x16x4xf32, #[[$BASE_MAP3]]> to memref<64x16x4xf32, #[[$BASE_MAP0]]> + %3 = memref.cast %2 : memref<64x16x4xf32, offset: ?, strides: [?, ?, ?]> to memref<64x16x4xf32, offset: 0, strides: [64, 4, 1]> - // CHECK: memref_cast %{{.*}} : memref<4xf32> to memref<*xf32> - %4 = memref_cast %1 : memref<4xf32> to memref<*xf32> + // CHECK: memref.cast %{{.*}} : memref<4xf32> to memref<*xf32> + %4 = memref.cast %1 : memref<4xf32> to memref<*xf32> - // CHECK: memref_cast %{{.*}} : memref<*xf32> to memref<4xf32> - %5 = memref_cast %4 : memref<*xf32> to memref<4xf32> + // CHECK: memref.cast %{{.*}} : memref<*xf32> to memref<4xf32> + %5 = memref.cast %4 : memref<*xf32> to memref<4xf32> return } @@ -627,19 +627,19 @@ // CHECK-LABEL: func @memref_view(%arg0 func @memref_view(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<2048xi8> + %0 = memref.alloc() : memref<2048xi8> // Test two dynamic sizes and dynamic offset. - // CHECK: %{{.*}} = std.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref - %1 = view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref + // CHECK: %{{.*}} = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref + %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref // Test one dynamic size and dynamic offset. - // CHECK: %{{.*}} = std.view %0[%arg2][%arg1] : memref<2048xi8> to memref<4x?xf32> - %3 = view %0[%arg2][%arg1] : memref<2048xi8> to memref<4x?xf32> + // CHECK: %{{.*}} = memref.view %0[%arg2][%arg1] : memref<2048xi8> to memref<4x?xf32> + %3 = memref.view %0[%arg2][%arg1] : memref<2048xi8> to memref<4x?xf32> // Test static sizes and static offset. - // CHECK: %{{.*}} = std.view %0[{{.*}}][] : memref<2048xi8> to memref<64x4xf32> + // CHECK: %{{.*}} = memref.view %0[{{.*}}][] : memref<2048xi8> to memref<64x4xf32> %c0 = constant 0: index - %5 = view %0[%c0][] : memref<2048xi8> to memref<64x4xf32> + %5 = memref.view %0[%c0][] : memref<2048xi8> to memref<64x4xf32> return } @@ -648,7 +648,7 @@ %c0 = constant 0 : index %c1 = constant 1 : index - %0 = alloc() : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> + %0 = memref.alloc() : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>> // CHECK: subview %0[%c0, %c0, %c0] [%arg0, %arg1, %arg2] [%c1, %c1, %c1] : // CHECK-SAME: memref<8x16x4xf32, #[[$BASE_MAP0]]> // CHECK-SAME: to memref @@ -656,7 +656,7 @@ : memref<8x16x4xf32, offset:0, strides: [64, 4, 1]> to memref - %2 = alloc()[%arg2] : memref<64xf32, affine_map<(d0)[s0] -> (d0 + s0)>> + %2 = memref.alloc()[%arg2] : memref<64xf32, affine_map<(d0)[s0] -> (d0 + s0)>> // CHECK: subview %2[%c1] [%arg0] [%c1] : // CHECK-SAME: memref<64xf32, #[[$BASE_MAP1]]> // CHECK-SAME: to memref @@ -664,7 +664,7 @@ : memref<64xf32, affine_map<(d0)[s0] -> (d0 + s0)>> to memref (d0 * s1 + s0)>> - %4 = alloc() : memref<64x22xf32, affine_map<(d0, d1) -> (d0 * 22 + d1)>> + %4 = memref.alloc() : memref<64x22xf32, affine_map<(d0, d1) -> (d0 * 22 + d1)>> // CHECK: subview %4[%c0, %c1] [%arg0, %arg1] [%c1, %c0] : // CHECK-SAME: memref<64x22xf32, #[[$BASE_MAP2]]> // CHECK-SAME: to memref @@ -679,14 +679,14 @@ : memref<8x16x4xf32, offset:0, strides: [64, 4, 1]> to memref<4x4x4xf32, offset:8, strides: [64, 4, 1]> - %7 = alloc(%arg1, %arg2) : memref + %7 = memref.alloc(%arg1, %arg2) : memref // CHECK: subview {{%.*}}[0, 0] [4, 4] [1, 1] : // CHECK-SAME: memref // CHECK-SAME: to memref<4x4xf32, #[[$SUBVIEW_MAP4]]> %8 = subview %7[0, 0][4, 4][1, 1] : memref to memref<4x4xf32, offset: ?, strides:[?, 1]> - %9 = alloc() : memref<16x4xf32> + %9 = memref.alloc() : memref<16x4xf32> // CHECK: subview {{%.*}}[{{%.*}}, {{%.*}}] [4, 4] [{{%.*}}, {{%.*}}] : // CHECK-SAME: memref<16x4xf32> // CHECK-SAME: to memref<4x4xf32, #[[$SUBVIEW_MAP2]] @@ -699,7 +699,7 @@ %11 = subview %9[%arg1, %arg2][4, 4][2, 2] : memref<16x4xf32> to memref<4x4xf32, offset: ?, strides:[8, 2]> - %12 = alloc() : memref<1x9x1x4x1xf32, affine_map<(d0, d1, d2, d3, d4) -> (36 * d0 + 36 * d1 + 4 * d2 + 4 * d3 + d4)>> + %12 = memref.alloc() : memref<1x9x1x4x1xf32, affine_map<(d0, d1, d2, d3, d4) -> (36 * d0 + 36 * d1 + 4 * d2 + 4 * d3 + d4)>> // CHECK: subview %12[%arg1, %arg1, %arg1, %arg1, %arg1] // CHECK-SAME: [1, 9, 1, 4, 1] [%arg2, %arg2, %arg2, %arg2, %arg2] : // CHECK-SAME: memref<1x9x1x4x1xf32, #[[$SUBVIEW_MAP6]]> to memref<9x4xf32, #[[$SUBVIEW_MAP2]]> @@ -709,7 +709,7 @@ // CHECK-SAME: memref<1x9x1x4x1xf32, #[[$SUBVIEW_MAP6]]> to memref<1x9x4xf32, #[[$BASE_MAP3]]> %14 = subview %12[%arg1, %arg1, %arg1, %arg1, %arg1][1, 9, 1, 4, 1][%arg2, %arg2, %arg2, %arg2, %arg2] : memref<1x9x1x4x1xf32, offset: 0, strides: [36, 36, 4, 4, 1]> to memref<1x9x4xf32, offset: ?, strides: [?, ?, ?]> - %15 = alloc(%arg1, %arg2)[%c0, %c1, %arg1, %arg0, %arg0, %arg2, %arg2] : memref<1x?x5x1x?x1xf32, affine_map<(d0, d1, d2, d3, d4, d5)[s0, s1, s2, s3, s4, s5, s6] -> (s0 + s1 * d0 + s2 * d1 + s3 * d2 + s4 * d3 + s5 * d4 + s6 * d5)>> + %15 = memref.alloc(%arg1, %arg2)[%c0, %c1, %arg1, %arg0, %arg0, %arg2, %arg2] : memref<1x?x5x1x?x1xf32, affine_map<(d0, d1, d2, d3, d4, d5)[s0, s1, s2, s3, s4, s5, s6] -> (s0 + s1 * d0 + s2 * d1 + s3 * d2 + s4 * d3 + s5 * d4 + s6 * d5)>> // CHECK: subview %15[0, 0, 0, 0, 0, 0] [1, %arg1, 5, 1, %arg2, 1] [1, 1, 1, 1, 1, 1] : // CHECK-SAME: memref<1x?x5x1x?x1xf32, #[[$SUBVIEW_MAP7]]> to memref %16 = subview %15[0, 0, 0, 0, 0, 0][1, %arg1, 5, 1, %arg2, 1][1, 1, 1, 1, 1, 1] : memref<1x?x5x1x?x1xf32, offset: ?, strides: [?, ?, ?, ?, ?, ?]> to memref @@ -717,21 +717,21 @@ // CHECK-SAME: memref<1x?x5x1x?x1xf32, #[[$SUBVIEW_MAP7]]> to memref %17 = subview %15[%arg1, %arg1, %arg1, %arg1, %arg1, %arg1][1, %arg1, 5, 1, %arg2, 1][1, 1, 1, 1, 1, 1] : memref<1x?x5x1x?x1xf32, offset: ?, strides: [?, ?, ?, ?, ?, ?]> to memref - %18 = alloc() : memref<1x8xf32> + %18 = memref.alloc() : memref<1x8xf32> // CHECK: subview %18[0, 0] [1, 8] [1, 1] : memref<1x8xf32> to memref<8xf32> %19 = subview %18[0, 0][1, 8][1, 1] : memref<1x8xf32> to memref<8xf32> - %20 = alloc() : memref<8x16x4xf32> + %20 = memref.alloc() : memref<8x16x4xf32> // CHECK: subview %20[0, 0, 0] [1, 16, 4] [1, 1, 1] : memref<8x16x4xf32> to memref<16x4xf32> %21 = subview %20[0, 0, 0][1, 16, 4][1, 1, 1] : memref<8x16x4xf32> to memref<16x4xf32> %22 = subview %20[3, 4, 2][1, 6, 3][1, 1, 1] : memref<8x16x4xf32> to memref<6x3xf32, offset: 210, strides: [4, 1]> - %23 = alloc() : memref + %23 = memref.alloc() : memref %78 = subview %23[] [] [] : memref to memref /// Subview with only leading operands. - %24 = alloc() : memref<5x3xf32> + %24 = memref.alloc() : memref<5x3xf32> // CHECK: subview %{{.*}}[2] [3] [1] : memref<5x3xf32> to memref<3x3xf32, #[[$SUBVIEW_MAP9]]> %25 = subview %24[2][3][1]: memref<5x3xf32> to memref<3x3xf32, offset: 6, strides: [3, 1]> @@ -747,7 +747,7 @@ %28 = subview %24[%arg0, 1] [1, 1] [1, 1] : memref<5x3xf32> to memref (s0)>> // CHECK: subview %{{.*}}[0, %{{.*}}] [%{{.*}}, 1] [1, 1] : memref to memref - %a30 = alloc(%arg0, %arg0) : memref + %a30 = memref.alloc(%arg0, %arg0) : memref %30 = subview %a30[0, %arg1][%arg2, 1][1, 1] : memref to memref (d0 * s1 + s0)>> return diff --git a/mlir/test/IR/invalid-ops.mlir b/mlir/test/IR/invalid-ops.mlir --- a/mlir/test/IR/invalid-ops.mlir +++ b/mlir/test/IR/invalid-ops.mlir @@ -88,7 +88,7 @@ %0 = constant 7 : index // Test alloc with wrong number of dynamic dimensions. // expected-error@+1 {{dimension operand count does not equal memref dynamic dimension count}} - %1 = alloc(%0)[%0] : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> + %1 = memref.alloc(%0)[%0] : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> return } @@ -99,7 +99,7 @@ %0 = constant 7 : index // Test alloc with wrong number of symbols // expected-error@+1 {{symbol operand count does not equal memref symbol count}} - %1 = alloc(%0) : memref<2x?xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> + %1 = memref.alloc(%0) : memref<2x?xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> return } @@ -107,19 +107,19 @@ func @test_store_zero_results() { ^bb0: - %0 = alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> + %0 = memref.alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> %1 = constant 0 : index %2 = constant 1 : index %3 = load %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> // Test that store returns zero results. - %4 = store %3, %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> // expected-error {{cannot name an operation with no results}} + %4 = memref.store %3, %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> // expected-error {{cannot name an operation with no results}} return } // ----- func @test_store_zero_results2(%x: i32, %p: memref) { - "std.store"(%x,%p) : (i32, memref) -> i32 // expected-error {{'std.store' op requires zero results}} + "memref.store"(%x,%p) : (i32, memref) -> i32 // expected-error {{'memref.store' op requires zero results}} return } @@ -127,7 +127,7 @@ func @test_alloc_memref_map_rank_mismatch() { ^bb0: - %0 = alloc() : memref<1024x64xf32, affine_map<(d0) -> (d0)>, 1> // expected-error {{memref affine map dimension mismatch}} + %0 = memref.alloc() : memref<1024x64xf32, affine_map<(d0) -> (d0)>, 1> // expected-error {{memref affine map dimension mismatch}} return } @@ -322,7 +322,7 @@ // ----- func @dma_no_dst_memref(%m : f32, %tag : f32, %c0 : index) { - %mref = alloc() : memref<8 x f32> + %mref = memref.alloc() : memref<8 x f32> // expected-error@+1 {{expected destination to be of memref type}} dma_start %mref[%c0], %m[%c0], %c0, %tag[%c0] : memref<8 x f32>, f32, f32 } @@ -360,7 +360,7 @@ // ----- func @dma_no_tag_memref(%tag : f32, %c0 : index) { - %mref = alloc() : memref<8 x f32> + %mref = memref.alloc() : memref<8 x f32> // expected-error@+1 {{expected tag to be of memref type}} dma_start %mref[%c0], %mref[%c0], %c0, %tag[%c0] : memref<8 x f32>, memref<8 x f32>, f32 } @@ -856,9 +856,9 @@ // ----- func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<2048xi8> + %0 = memref.alloc() : memref<2048xi8> // expected-error@+1 {{expects 1 offset operand}} - %1 = view %0[][%arg0, %arg1] + %1 = memref.view %0[][%arg0, %arg1] : memref<2048xi8> to memref return } @@ -866,9 +866,9 @@ // ----- func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<2048xi8, affine_map<(d0) -> (d0 floordiv 8, d0 mod 8)>> + %0 = memref.alloc() : memref<2048xi8, affine_map<(d0) -> (d0 floordiv 8, d0 mod 8)>> // expected-error@+1 {{unsupported map for base memref type}} - %1 = view %0[%arg2][%arg0, %arg1] + %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8, affine_map<(d0) -> (d0 floordiv 8, d0 mod 8)>> to memref (d0 * 4 + d1 + s0)>> return @@ -877,9 +877,9 @@ // ----- func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<2048xi8> + %0 = memref.alloc() : memref<2048xi8> // expected-error@+1 {{unsupported map for result memref type}} - %1 = view %0[%arg2][%arg0, %arg1] + %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref (d0, d1, s0)>> return } @@ -887,18 +887,18 @@ // ----- func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<2048xi8, 2> + %0 = memref.alloc() : memref<2048xi8, 2> // expected-error@+1 {{different memory spaces}} - %1 = view %0[%arg2][%arg0, %arg1] : memref<2048xi8, 2> to memref + %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8, 2> to memref return } // ----- func @invalid_view(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<2048xi8> + %0 = memref.alloc() : memref<2048xi8> // expected-error@+1 {{incorrect number of size operands for type}} - %1 = view %0[%arg2][%arg0] + %1 = memref.view %0[%arg2][%arg0] : memref<2048xi8> to memref return } @@ -906,7 +906,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected mixed offsets rank to match mixed sizes rank (2 vs 3) so the rank of the result type is well-formed}} %1 = subview %0[0, 0][2, 2, 2][1, 1, 1] : memref<8x16x4xf32> to memref<8x16x4xf32> @@ -916,7 +916,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected mixed sizes rank to match mixed strides rank (3 vs 2) so the rank of the result type is well-formed}} %1 = subview %0[0, 0, 0][2, 2, 2][1, 1] : memref<8x16x4xf32> to memref<8x16x4xf32> @@ -926,7 +926,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected mixed sizes rank to match mixed strides rank (3 vs 2) so the rank of the result type is well-formed}} %1 = memref_reinterpret_cast %0 to offset: [0], sizes: [2, 2, 2], strides:[1, 1] : memref<8x16x4xf32> to memref<8x16x4xf32> @@ -936,7 +936,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32, offset: 0, strides: [64, 4, 1], 2> + %0 = memref.alloc() : memref<8x16x4xf32, offset: 0, strides: [64, 4, 1], 2> // expected-error@+1 {{different memory spaces}} %1 = subview %0[0, 0, 0][%arg2, %arg2, %arg2][1, 1, 1] : memref<8x16x4xf32, offset: 0, strides: [64, 4, 1], 2> to @@ -947,7 +947,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 + d1, d1 + d2, d2)>> + %0 = memref.alloc() : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 + d1, d1 + d2, d2)>> // expected-error@+1 {{is not strided}} %1 = subview %0[0, 0, 0][%arg2, %arg2, %arg2][1, 1, 1] : memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 + d1, d1 + d2, d2)>> to @@ -958,7 +958,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected <= 3 offset values}} %1 = subview %0[%arg0, %arg1, 0, 0][%arg2, 0, 0, 0][1, 1, 1, 1] : memref<8x16x4xf32> to @@ -969,7 +969,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected result type to be 'memref (d0 * s1 + s0 + d1 * s2 + d2 * s3)>>' or a rank-reduced version. (mismatch of result affine map)}} %1 = subview %0[%arg0, %arg1, %arg2][%arg0, %arg1, %arg2][%arg0, %arg1, %arg2] : memref<8x16x4xf32> to @@ -980,7 +980,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected result element type to be 'f32'}} %1 = subview %0[0, 0, 0][8, 16, 4][1, 1, 1] : memref<8x16x4xf32> to @@ -991,7 +991,7 @@ // ----- func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected result rank to be smaller or equal to the source rank.}} %1 = subview %0[0, 0, 0][8, 16, 4][1, 1, 1] : memref<8x16x4xf32> to @@ -1002,7 +1002,7 @@ // ----- func @invalid_rank_reducing_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected result type to be 'memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2)>>' or a rank-reduced version. (mismatch of result sizes)}} %1 = subview %0[0, 0, 0][8, 16, 4][1, 1, 1] : memref<8x16x4xf32> to memref<16x4xf32> @@ -1012,7 +1012,7 @@ // ----- func @invalid_rank_reducing_subview(%arg0 : index, %arg1 : index, %arg2 : index) { - %0 = alloc() : memref<8x16x4xf32> + %0 = memref.alloc() : memref<8x16x4xf32> // expected-error@+1 {{expected result type to be 'memref<8x16x4xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 4 + d2 + 8)>>' or a rank-reduced version. (mismatch of result sizes)}} %1 = subview %0[0, 2, 0][8, 16, 4][1, 1, 1] : memref<8x16x4xf32> to memref<16x4xf32> @@ -1040,7 +1040,7 @@ func @invalid_memref_cast(%arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]>) { // expected-error@+1{{operand type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 16 + d2)>>' and result type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 128 + d1 * 32 + d2 * 2)>>' are cast incompatible}} - %0 = memref_cast %arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]> to memref<12x4x16xf32, offset:0, strides:[128, 32, 2]> + %0 = memref.cast %arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]> to memref<12x4x16xf32, offset:0, strides:[128, 32, 2]> return } @@ -1048,7 +1048,7 @@ func @invalid_memref_cast(%arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]>) { // expected-error@+1{{operand type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 16 + d2)>>' and result type 'memref<12x4x16xf32, affine_map<(d0, d1, d2) -> (d0 * 64 + d1 * 16 + d2 + 16)>>' are cast incompatible}} - %0 = memref_cast %arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]> to memref<12x4x16xf32, offset:16, strides:[64, 16, 1]> + %0 = memref.cast %arg0 : memref<12x4x16xf32, offset:0, strides:[64, 16, 1]> to memref<12x4x16xf32, offset:16, strides:[64, 16, 1]> return } @@ -1056,36 +1056,36 @@ // incompatible element types func @invalid_memref_cast() { - %0 = alloc() : memref<2x5xf32, 0> + %0 = memref.alloc() : memref<2x5xf32, 0> // expected-error@+1 {{operand type 'memref<2x5xf32>' and result type 'memref<*xi32>' are cast incompatible}} - %1 = memref_cast %0 : memref<2x5xf32, 0> to memref<*xi32> + %1 = memref.cast %0 : memref<2x5xf32, 0> to memref<*xi32> return } // ----- func @invalid_prefetch_rw(%i : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> // expected-error@+1 {{rw specifier has to be 'read' or 'write'}} - prefetch %0[%i], rw, locality<0>, data : memref<10xf32> + memref.prefetch %0[%i], rw, locality<0>, data : memref<10xf32> return } // ----- func @invalid_prefetch_cache_type(%i : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> // expected-error@+1 {{cache type has to be 'data' or 'instr'}} - prefetch %0[%i], read, locality<0>, false : memref<10xf32> + memref.prefetch %0[%i], read, locality<0>, false : memref<10xf32> return } // ----- func @invalid_prefetch_locality_hint(%i : index) { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> // expected-error@+1 {{32-bit signless integer attribute whose minimum value is 0 whose maximum value is 3}} - prefetch %0[%i], read, locality<5>, data : memref<10xf32> + memref.prefetch %0[%i], read, locality<5>, data : memref<10xf32> return } @@ -1093,9 +1093,9 @@ // incompatible memory space func @invalid_memref_cast() { - %0 = alloc() : memref<2x5xf32, 0> + %0 = memref.alloc() : memref<2x5xf32, 0> // expected-error@+1 {{operand type 'memref<2x5xf32>' and result type 'memref<*xf32, 1>' are cast incompatible}} - %1 = memref_cast %0 : memref<2x5xf32, 0> to memref<*xf32, 1> + %1 = memref.cast %0 : memref<2x5xf32, 0> to memref<*xf32, 1> return } @@ -1103,10 +1103,10 @@ // unranked to unranked func @invalid_memref_cast() { - %0 = alloc() : memref<2x5xf32, 0> - %1 = memref_cast %0 : memref<2x5xf32, 0> to memref<*xf32, 0> + %0 = memref.alloc() : memref<2x5xf32, 0> + %1 = memref.cast %0 : memref<2x5xf32, 0> to memref<*xf32, 0> // expected-error@+1 {{operand type 'memref<*xf32>' and result type 'memref<*xf32>' are cast incompatible}} - %2 = memref_cast %1 : memref<*xf32, 0> to memref<*xf32, 0> + %2 = memref.cast %1 : memref<*xf32, 0> to memref<*xf32, 0> return } @@ -1177,7 +1177,7 @@ %x = generic_atomic_rmw %I[%i] : memref<10xf32> { ^bb0(%old_value : f32): %c1 = constant 1.0 : f32 - %buf = alloc() : memref<2048xf32> + %buf = memref.alloc() : memref<2048xf32> atomic_yield %c1 : f32 } } @@ -1215,7 +1215,7 @@ // ----- "alloca_without_scoped_alloc_parent"() ( { - std.alloca() : memref<1xf32> + memref.alloca() : memref<1xf32> // expected-error@-1 {{requires an ancestor op with AutomaticAllocationScope trait}} return }) : () -> () diff --git a/mlir/test/IR/memory-ops.mlir b/mlir/test/IR/memory-ops.mlir --- a/mlir/test/IR/memory-ops.mlir +++ b/mlir/test/IR/memory-ops.mlir @@ -6,28 +6,28 @@ func @alloc() { ^bb0: // Test simple alloc. - // CHECK: %0 = alloc() : memref<1024x64xf32, 1> - %0 = alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> + // CHECK: %0 = memref.alloc() : memref<1024x64xf32, 1> + %0 = memref.alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> %c0 = "std.constant"() {value = 0: index} : () -> index %c1 = "std.constant"() {value = 1: index} : () -> index // Test alloc with dynamic dimensions. - // CHECK: %1 = alloc(%c0, %c1) : memref - %1 = alloc(%c0, %c1) : memref (d0, d1)>, 1> + // CHECK: %1 = memref.alloc(%c0, %c1) : memref + %1 = memref.alloc(%c0, %c1) : memref (d0, d1)>, 1> // Test alloc with no dynamic dimensions and one symbol. - // CHECK: %2 = alloc()[%c0] : memref<2x4xf32, #map, 1> - %2 = alloc()[%c0] : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> + // CHECK: %2 = memref.alloc()[%c0] : memref<2x4xf32, #map, 1> + %2 = memref.alloc()[%c0] : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> // Test alloc with dynamic dimensions and one symbol. - // CHECK: %3 = alloc(%c1)[%c0] : memref<2x?xf32, #map, 1> - %3 = alloc(%c1)[%c0] : memref<2x?xf32, affine_map<(d0, d1)[s0] -> (d0 + s0, d1)>, 1> + // CHECK: %3 = memref.alloc(%c1)[%c0] : memref<2x?xf32, #map, 1> + %3 = memref.alloc(%c1)[%c0] : memref<2x?xf32, affine_map<(d0, d1)[s0] -> (d0 + s0, d1)>, 1> // Alloc with no mappings. // b/116054838 Parser crash while parsing ill-formed AllocOp - // CHECK: %4 = alloc() : memref<2xi32> - %4 = alloc() : memref<2 x i32> + // CHECK: %4 = memref.alloc() : memref<2xi32> + %4 = memref.alloc() : memref<2 x i32> // CHECK: return return @@ -37,27 +37,27 @@ func @alloca() { ^bb0: // Test simple alloc. - // CHECK: %0 = alloca() : memref<1024x64xf32, 1> - %0 = alloca() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> + // CHECK: %0 = memref.alloca() : memref<1024x64xf32, 1> + %0 = memref.alloca() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> %c0 = "std.constant"() {value = 0: index} : () -> index %c1 = "std.constant"() {value = 1: index} : () -> index // Test alloca with dynamic dimensions. - // CHECK: %1 = alloca(%c0, %c1) : memref - %1 = alloca(%c0, %c1) : memref (d0, d1)>, 1> + // CHECK: %1 = memref.alloca(%c0, %c1) : memref + %1 = memref.alloca(%c0, %c1) : memref (d0, d1)>, 1> // Test alloca with no dynamic dimensions and one symbol. - // CHECK: %2 = alloca()[%c0] : memref<2x4xf32, #map, 1> - %2 = alloca()[%c0] : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> + // CHECK: %2 = memref.alloca()[%c0] : memref<2x4xf32, #map, 1> + %2 = memref.alloca()[%c0] : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1> // Test alloca with dynamic dimensions and one symbol. - // CHECK: %3 = alloca(%c1)[%c0] : memref<2x?xf32, #map, 1> - %3 = alloca(%c1)[%c0] : memref<2x?xf32, affine_map<(d0, d1)[s0] -> (d0 + s0, d1)>, 1> + // CHECK: %3 = memref.alloca(%c1)[%c0] : memref<2x?xf32, #map, 1> + %3 = memref.alloca(%c1)[%c0] : memref<2x?xf32, affine_map<(d0, d1)[s0] -> (d0 + s0, d1)>, 1> // Alloca with no mappings, but with alignment. - // CHECK: %4 = alloca() {alignment = 64 : i64} : memref<2xi32> - %4 = alloca() {alignment = 64} : memref<2 x i32> + // CHECK: %4 = memref.alloca() {alignment = 64 : i64} : memref<2xi32> + %4 = memref.alloca() {alignment = 64} : memref<2 x i32> return } @@ -65,19 +65,19 @@ // CHECK-LABEL: func @dealloc() { func @dealloc() { ^bb0: - // CHECK: %0 = alloc() : memref<1024x64xf32> - %0 = alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 0> + // CHECK: %0 = memref.alloc() : memref<1024x64xf32> + %0 = memref.alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 0> - // CHECK: dealloc %0 : memref<1024x64xf32> - dealloc %0 : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 0> + // CHECK: memref.dealloc %0 : memref<1024x64xf32> + memref.dealloc %0 : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 0> return } // CHECK-LABEL: func @load_store func @load_store() { ^bb0: - // CHECK: %0 = alloc() : memref<1024x64xf32, 1> - %0 = alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> + // CHECK: %0 = memref.alloc() : memref<1024x64xf32, 1> + %0 = memref.alloc() : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> %1 = constant 0 : index %2 = constant 1 : index @@ -85,8 +85,8 @@ // CHECK: %1 = load %0[%c0, %c1] : memref<1024x64xf32, 1> %3 = load %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> - // CHECK: store %1, %0[%c0, %c1] : memref<1024x64xf32, 1> - store %3, %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> + // CHECK: memref.store %1, %0[%c0, %c1] : memref<1024x64xf32, 1> + memref.store %3, %0[%1, %2] : memref<1024x64xf32, affine_map<(d0, d1) -> (d0, d1)>, 1> return } @@ -97,9 +97,9 @@ %stride = constant 32 : index %elt_per_stride = constant 16 : index - %A = alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> - %Ah = alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 1> - %tag = alloc() : memref<1 x f32> + %A = memref.alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> + %Ah = memref.alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 1> + %tag = memref.alloc() : memref<1 x f32> %num_elements = constant 256 : index diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -287,7 +287,7 @@ %c = constant 0 : i32 // CHECK: %{{.*}} = constant 0 : i32 affine.for %i0 = 1 to %arg0 { // CHECK: affine.for %{{.*}} = 1 to %{{.*}} { affine.for %i1 = affine_map<(d0)[]->(d0)>(%i0)[] to %arg0 { // CHECK: affine.for %{{.*}} = #map{{[0-9]+}}(%{{.*}}) to %{{.*}} { - store %c, %arg1[%i0, %i1] : memref // CHECK: store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] + memref.store %c, %arg1[%i0, %i1] : memref // CHECK: memref.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] } // CHECK: } } // CHECK: } return // CHECK: return diff --git a/mlir/test/IR/slice.mlir b/mlir/test/IR/slice.mlir --- a/mlir/test/IR/slice.mlir +++ b/mlir/test/IR/slice.mlir @@ -1,18 +1,18 @@ // RUN: mlir-opt -slice-analysis-test %s | FileCheck %s func @slicing_linalg_op(%arg0 : index, %arg1 : index, %arg2 : index) { - %a = alloc(%arg0, %arg2) : memref - %b = alloc(%arg2, %arg1) : memref - %c = alloc(%arg0, %arg1) : memref - %d = alloc(%arg0, %arg1) : memref + %a = memref.alloc(%arg0, %arg2) : memref + %b = memref.alloc(%arg2, %arg1) : memref + %c = memref.alloc(%arg0, %arg1) : memref + %d = memref.alloc(%arg0, %arg1) : memref linalg.matmul ins(%a, %b : memref, memref) outs(%c : memref) linalg.matmul ins(%a, %b : memref, memref) outs(%d : memref) - dealloc %c : memref - dealloc %b : memref - dealloc %a : memref - dealloc %d : memref + memref.dealloc %c : memref + memref.dealloc %b : memref + memref.dealloc %a : memref + memref.dealloc %d : memref return } @@ -20,16 +20,16 @@ // CHECK-SAME: %[[ARG0:[a-zA-Z0-9_]+]]: index // CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]+]]: index // CHECK-SAME: %[[ARG2:[a-zA-Z0-9_]+]]: index -// CHECK-DAG: %[[A:.+]] = alloc(%[[ARG0]], %[[ARG2]]) : memref -// CHECK-DAG: %[[B:.+]] = alloc(%[[ARG2]], %[[ARG1]]) : memref -// CHECK-DAG: %[[C:.+]] = alloc(%[[ARG0]], %[[ARG1]]) : memref +// CHECK-DAG: %[[A:.+]] = memref.alloc(%[[ARG0]], %[[ARG2]]) : memref +// CHECK-DAG: %[[B:.+]] = memref.alloc(%[[ARG2]], %[[ARG1]]) : memref +// CHECK-DAG: %[[C:.+]] = memref.alloc(%[[ARG0]], %[[ARG1]]) : memref // CHECK: return // CHECK-LABEL: func @slicing_linalg_op__backward_slice__1 // CHECK-SAME: %[[ARG0:[a-zA-Z0-9_]+]]: index // CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]+]]: index // CHECK-SAME: %[[ARG2:[a-zA-Z0-9_]+]]: index -// CHECK-DAG: %[[A:.+]] = alloc(%[[ARG0]], %[[ARG2]]) : memref -// CHECK-DAG: %[[B:.+]] = alloc(%[[ARG2]], %[[ARG1]]) : memref -// CHECK-DAG: %[[C:.+]] = alloc(%[[ARG0]], %[[ARG1]]) : memref +// CHECK-DAG: %[[A:.+]] = memref.alloc(%[[ARG0]], %[[ARG2]]) : memref +// CHECK-DAG: %[[B:.+]] = memref.alloc(%[[ARG2]], %[[ARG1]]) : memref +// CHECK-DAG: %[[C:.+]] = memref.alloc(%[[ARG0]], %[[ARG1]]) : memref // CHECK: return diff --git a/mlir/test/Transforms/buffer-deallocation.mlir b/mlir/test/Transforms/buffer-deallocation.mlir --- a/mlir/test/Transforms/buffer-deallocation.mlir +++ b/mlir/test/Transforms/buffer-deallocation.mlir @@ -21,7 +21,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): @@ -30,17 +30,17 @@ } // CHECK-NEXT: cond_br -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy // CHECK-NEXT: br ^bb3(%[[ALLOC0]] -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOC2:.*]] = alloc() +// CHECK: %[[ALLOC2:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy -// CHECK-NEXT: dealloc %[[ALLOC1]] +// CHECK-NEXT: memref.dealloc %[[ALLOC1]] // CHECK-NEXT: br ^bb3(%[[ALLOC2]] // CHECK: test.copy -// CHECK-NEXT: dealloc +// CHECK-NEXT: memref.dealloc // CHECK-NEXT: return // ----- @@ -68,7 +68,7 @@ ^bb1: br ^bb3(%arg1 : memref) ^bb2(%0: index): - %1 = alloc(%0) : memref + %1 = memref.alloc(%0) : memref test.buffer_based in(%arg1: memref) out(%1: memref) br ^bb3(%1 : memref) ^bb3(%2: memref): @@ -78,20 +78,20 @@ // CHECK-NEXT: cond_br // CHECK: %[[DIM0:.*]] = dim -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc(%[[DIM0]]) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc(%[[DIM0]]) // CHECK-NEXT: linalg.copy(%{{.*}}, %[[ALLOC0]]) // CHECK-NEXT: br ^bb3(%[[ALLOC0]] // CHECK: ^bb2(%[[IDX:.*]]:{{.*}}) -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc(%[[IDX]]) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc(%[[IDX]]) // CHECK-NEXT: test.buffer_based // CHECK: %[[DIM1:.*]] = dim %[[ALLOC1]] -// CHECK-NEXT: %[[ALLOC2:.*]] = alloc(%[[DIM1]]) +// CHECK-NEXT: %[[ALLOC2:.*]] = memref.alloc(%[[DIM1]]) // CHECK-NEXT: linalg.copy(%[[ALLOC1]], %[[ALLOC2]]) -// CHECK-NEXT: dealloc %[[ALLOC1]] +// CHECK-NEXT: memref.dealloc %[[ALLOC1]] // CHECK-NEXT: br ^bb3 // CHECK-NEXT: ^bb3(%[[ALLOC3:.*]]:{{.*}}) // CHECK: test.copy(%[[ALLOC3]], -// CHECK-NEXT: dealloc %[[ALLOC3]] +// CHECK-NEXT: memref.dealloc %[[ALLOC3]] // CHECK-NEXT: return // ----- @@ -126,7 +126,7 @@ ^bb1: br ^bb6(%arg1 : memref) ^bb2(%0: index): - %1 = alloc(%0) : memref + %1 = memref.alloc(%0) : memref test.buffer_based in(%arg1: memref) out(%1: memref) cond_br %arg0, ^bb3, ^bb4 ^bb3: @@ -145,11 +145,11 @@ // CHECK-NEXT: cond_br // CHECK: ^bb1 // CHECK: %[[DIM0:.*]] = dim -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc(%[[DIM0]]) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc(%[[DIM0]]) // CHECK-NEXT: linalg.copy(%{{.*}}, %[[ALLOC0]]) // CHECK-NEXT: br ^bb6 // CHECK: ^bb2(%[[IDX:.*]]:{{.*}}) -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc(%[[IDX]]) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc(%[[IDX]]) // CHECK-NEXT: test.buffer_based // CHECK: cond_br // CHECK: ^bb3: @@ -158,15 +158,15 @@ // CHECK-NEXT: br ^bb5(%[[ALLOC1]]{{.*}}) // CHECK-NEXT: ^bb5(%[[ALLOC2:.*]]:{{.*}}) // CHECK: %[[DIM2:.*]] = dim %[[ALLOC2]] -// CHECK-NEXT: %[[ALLOC3:.*]] = alloc(%[[DIM2]]) +// CHECK-NEXT: %[[ALLOC3:.*]] = memref.alloc(%[[DIM2]]) // CHECK-NEXT: linalg.copy(%[[ALLOC2]], %[[ALLOC3]]) -// CHECK-NEXT: dealloc %[[ALLOC1]] +// CHECK-NEXT: memref.dealloc %[[ALLOC1]] // CHECK-NEXT: br ^bb6(%[[ALLOC3]]{{.*}}) // CHECK-NEXT: ^bb6(%[[ALLOC4:.*]]:{{.*}}) // CHECK-NEXT: br ^bb7(%[[ALLOC4]]{{.*}}) // CHECK-NEXT: ^bb7(%[[ALLOC5:.*]]:{{.*}}) // CHECK: test.copy(%[[ALLOC5]], -// CHECK-NEXT: dealloc %[[ALLOC4]] +// CHECK-NEXT: memref.dealloc %[[ALLOC4]] // CHECK-NEXT: return // ----- @@ -177,11 +177,11 @@ // CHECK-LABEL: func @emptyUsesValue func @emptyUsesValue(%arg0: memref<4xf32>) { - %0 = alloc() : memref<4xf32> + %0 = memref.alloc() : memref<4xf32> return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() -// CHECK-NEXT: dealloc %[[ALLOC]] +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() +// CHECK-NEXT: memref.dealloc %[[ALLOC]] // CHECK-NEXT: return // ----- @@ -200,7 +200,7 @@ func @criticalEdge(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { cond_br %arg0, ^bb1, ^bb2(%arg1 : memref<2xf32>) ^bb1: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb2(%0 : memref<2xf32>) ^bb2(%1: memref<2xf32>): @@ -208,16 +208,16 @@ return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy // CHECK-NEXT: cond_br -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOC2:.*]] = alloc() +// CHECK: %[[ALLOC2:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy -// CHECK-NEXT: dealloc %[[ALLOC1]] +// CHECK-NEXT: memref.dealloc %[[ALLOC1]] // CHECK: test.copy -// CHECK-NEXT: dealloc +// CHECK-NEXT: memref.dealloc // CHECK-NEXT: return // ----- @@ -233,7 +233,7 @@ // CHECK-LABEL: func @invCriticalEdge func @invCriticalEdge(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1, ^bb2(%arg1 : memref<2xf32>) ^bb1: @@ -261,7 +261,7 @@ // CHECK-LABEL: func @ifElse func @ifElse(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -271,19 +271,19 @@ ^bb2(%3: memref<2xf32>, %4: memref<2xf32>): br ^bb3(%3, %4 : memref<2xf32>, memref<2xf32>) ^bb3(%5: memref<2xf32>, %6: memref<2xf32>): - %7 = alloc() : memref<2xf32> + %7 = memref.alloc() : memref<2xf32> test.buffer_based in(%5: memref<2xf32>) out(%7: memref<2xf32>) test.copy(%7, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[SECOND_ALLOC:.*]] = alloc() +// CHECK: %[[SECOND_ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: dealloc %[[FIRST_ALLOC]] +// CHECK: memref.dealloc %[[FIRST_ALLOC]] // CHECK: test.copy -// CHECK-NEXT: dealloc %[[SECOND_ALLOC]] +// CHECK-NEXT: memref.dealloc %[[SECOND_ALLOC]] // CHECK-NEXT: return // ----- @@ -299,7 +299,7 @@ // CHECK-LABEL: func @ifElseNoUsers func @ifElseNoUsers(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -313,9 +313,9 @@ return } -// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = memref.alloc() // CHECK: test.copy -// CHECK-NEXT: dealloc %[[FIRST_ALLOC]] +// CHECK-NEXT: memref.dealloc %[[FIRST_ALLOC]] // CHECK-NEXT: return // ----- @@ -334,7 +334,7 @@ // CHECK-LABEL: func @ifElseNested func @ifElseNested(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -348,19 +348,19 @@ ^bb4(%6: memref<2xf32>): br ^bb5(%3, %6 : memref<2xf32>, memref<2xf32>) ^bb5(%7: memref<2xf32>, %8: memref<2xf32>): - %9 = alloc() : memref<2xf32> + %9 = memref.alloc() : memref<2xf32> test.buffer_based in(%7: memref<2xf32>) out(%9: memref<2xf32>) test.copy(%9, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[SECOND_ALLOC:.*]] = alloc() +// CHECK: %[[SECOND_ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: dealloc %[[FIRST_ALLOC]] +// CHECK: memref.dealloc %[[FIRST_ALLOC]] // CHECK: test.copy -// CHECK-NEXT: dealloc %[[SECOND_ALLOC]] +// CHECK-NEXT: memref.dealloc %[[SECOND_ALLOC]] // CHECK-NEXT: return // ----- @@ -371,17 +371,17 @@ // CHECK-LABEL: func @redundantOperations func @redundantOperations(%arg0: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%0: memref<2xf32>) out(%1: memref<2xf32>) return } // CHECK: (%[[ARG0:.*]]: {{.*}}) -// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[FIRST_ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based in(%[[ARG0]]{{.*}}out(%[[FIRST_ALLOC]] -// CHECK: %[[SECOND_ALLOC:.*]] = alloc() +// CHECK: %[[SECOND_ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based in(%[[FIRST_ALLOC]]{{.*}}out(%[[SECOND_ALLOC]] // CHECK: dealloc // CHECK-NEXT: dealloc @@ -407,11 +407,11 @@ %arg1: memref<2xf32>) { cond_br %cond, ^bb1, ^bb2 ^bb1: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) br ^exit(%0 : memref<2xf32>) ^bb2: - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%1: memref<2xf32>) br ^exit(%1 : memref<2xf32>) ^exit(%arg2: memref<2xf32>): @@ -422,22 +422,22 @@ // CHECK-NEXT: cond_br // CHECK: ^bb1 // CHECK: ^bb1 -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy -// CHECK-NEXT: dealloc %[[ALLOC0]] +// CHECK-NEXT: memref.dealloc %[[ALLOC0]] // CHECK-NEXT: br ^bb3(%[[ALLOC1]] // CHECK-NEXT: ^bb2 -// CHECK-NEXT: %[[ALLOC2:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC2:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOC3:.*]] = alloc() +// CHECK: %[[ALLOC3:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy -// CHECK-NEXT: dealloc %[[ALLOC2]] +// CHECK-NEXT: memref.dealloc %[[ALLOC2]] // CHECK-NEXT: br ^bb3(%[[ALLOC3]] // CHECK-NEXT: ^bb3(%[[ALLOC4:.*]]:{{.*}}) // CHECK: test.copy -// CHECK-NEXT: dealloc %[[ALLOC4]] +// CHECK-NEXT: memref.dealloc %[[ALLOC4]] // CHECK-NEXT: return // ----- @@ -457,23 +457,23 @@ %cond: i1, %arg0: memref<2xf32>, %arg1: memref<2xf32>) { - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> cond_br %cond, ^bb1, ^bb2 ^bb1: br ^exit(%arg0 : memref<2xf32>) ^bb2: test.buffer_based in(%arg0: memref<2xf32>) out(%1: memref<2xf32>) - dealloc %1 : memref<2xf32> + memref.dealloc %1 : memref<2xf32> br ^exit(%1 : memref<2xf32>) ^exit(%arg2: memref<2xf32>): test.copy(%arg2, %arg1) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: cond_br // CHECK: test.copy -// CHECK-NEXT: dealloc %[[ALLOC0]] +// CHECK-NEXT: memref.dealloc %[[ALLOC0]] // CHECK-NEXT: return // ----- @@ -484,15 +484,15 @@ func @inserting_missing_dealloc_simple( %arg0 : memref<2xf32>, %arg1: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) test.copy(%0, %arg1) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK: test.copy -// CHECK-NEXT: dealloc %[[ALLOC0]] +// CHECK-NEXT: memref.dealloc %[[ALLOC0]] // ----- @@ -501,16 +501,16 @@ // CHECK-LABEL: func @moving_invalid_dealloc_op func @moving_invalid_dealloc_op(%arg0 : memref<2xf32>, %arg1: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) - dealloc %0 : memref<2xf32> + memref.dealloc %0 : memref<2xf32> test.copy(%0, %arg1) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK: test.copy -// CHECK-NEXT: dealloc %[[ALLOC0]] +// CHECK-NEXT: memref.dealloc %[[ALLOC0]] // ----- @@ -530,10 +530,10 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.region_buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) { ^bb0(%gen1_arg0: f32, %gen1_arg1: f32): - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%1: memref<2xf32>) %tmp1 = math.exp %gen1_arg0 : f32 test.region_yield %tmp1 : f32 @@ -545,18 +545,18 @@ } // CHECK: (%[[cond:.*]]: {{.*}}, %[[ARG1:.*]]: {{.*}}, %{{.*}}: {{.*}}) // CHECK-NEXT: cond_br %[[cond]], ^[[BB1:.*]], ^[[BB2:.*]] -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ARG1]], %[[ALLOC0]]) // CHECK: ^[[BB2]]: -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.region_buffer_based in(%[[ARG1]]{{.*}}out(%[[ALLOC1]] -// CHECK: %[[ALLOC2:.*]] = alloc() +// CHECK: %[[ALLOC2:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based in(%[[ARG1]]{{.*}}out(%[[ALLOC2]] -// CHECK: dealloc %[[ALLOC2]] +// CHECK: memref.dealloc %[[ALLOC2]] // CHECK-NEXT: %{{.*}} = math.exp -// CHECK: %[[ALLOC3:.*]] = alloc() +// CHECK: %[[ALLOC3:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC1]], %[[ALLOC3]]) -// CHECK-NEXT: dealloc %[[ALLOC1]] +// CHECK-NEXT: memref.dealloc %[[ALLOC1]] // CHECK: ^[[BB3:.*]]({{.*}}): // CHECK: test.copy // CHECK-NEXT: dealloc @@ -573,18 +573,18 @@ %arg0: memref<5xf32>, %arg1: memref<10xf32>, %arg2: memref<5xf32>) -> (memref<10xf32>, memref<15xf32>) { - %x = alloc() : memref<15xf32> - %y = alloc() : memref<5xf32> + %x = memref.alloc() : memref<15xf32> + %y = memref.alloc() : memref<5xf32> test.buffer_based in(%arg0: memref<5xf32>) out(%y: memref<5xf32>) test.copy(%y, %arg2) : (memref<5xf32>, memref<5xf32>) return %arg1, %x : memref<10xf32>, memref<15xf32> } // CHECK: (%[[ARG0:.*]]: memref<5xf32>, %[[ARG1:.*]]: memref<10xf32>, // CHECK-SAME: %[[RESULT:.*]]: memref<5xf32>) -// CHECK: %[[X:.*]] = alloc() -// CHECK: %[[Y:.*]] = alloc() +// CHECK: %[[X:.*]] = memref.alloc() +// CHECK: %[[Y:.*]] = memref.alloc() // CHECK: test.copy -// CHECK: dealloc %[[Y]] +// CHECK: memref.dealloc %[[Y]] // CHECK: return %[[ARG1]], %[[X]] // ----- @@ -599,21 +599,21 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %3 = alloc(%arg0, %arg1) : memref + %3 = memref.alloc(%arg0, %arg1) : memref scf.yield %1 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: %[[ALLOC1:.*]] = scf.if // CHECK: scf.yield %[[ALLOC0]] -// CHECK: %[[ALLOC2:.*]] = alloc(%arg0, %arg1) -// CHECK-NEXT: dealloc %[[ALLOC2]] +// CHECK: %[[ALLOC2:.*]] = memref.alloc(%arg0, %arg1) +// CHECK-NEXT: memref.dealloc %[[ALLOC2]] // CHECK-NEXT: scf.yield %[[ALLOC0]] // CHECK: return %[[ALLOC1]] @@ -629,27 +629,27 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %3 = alloc(%arg0, %arg1) : memref + %3 = memref.alloc(%arg0, %arg1) : memref scf.yield %3 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: %[[ALLOC1:.*]] = scf.if -// CHECK: %[[ALLOC2:.*]] = alloc +// CHECK: %[[ALLOC2:.*]] = memref.alloc // CHECK-NEXT: linalg.copy(%[[ALLOC0]], %[[ALLOC2]]) // CHECK: scf.yield %[[ALLOC2]] -// CHECK: %[[ALLOC3:.*]] = alloc(%arg0, %arg1) -// CHECK: %[[ALLOC4:.*]] = alloc +// CHECK: %[[ALLOC3:.*]] = memref.alloc(%arg0, %arg1) +// CHECK: %[[ALLOC4:.*]] = memref.alloc // CHECK-NEXT: linalg.copy(%[[ALLOC3]], %[[ALLOC4]]) -// CHECK: dealloc %[[ALLOC3]] +// CHECK: memref.dealloc %[[ALLOC3]] // CHECK: scf.yield %[[ALLOC4]] -// CHECK: dealloc %[[ALLOC0]] +// CHECK: memref.dealloc %[[ALLOC0]] // CHECK-NEXT: return %[[ALLOC1]] // ----- @@ -660,7 +660,7 @@ // CHECK-LABEL: func @inner_region_control_flow func @inner_region_control_flow(%arg0 : index) -> memref { - %0 = alloc(%arg0, %arg0) : memref + %0 = memref.alloc(%arg0, %arg0) : memref %1 = test.region_if %0 : memref -> (memref) then { ^bb0(%arg1 : memref): test.region_if_yield %arg1 : memref @@ -674,7 +674,7 @@ return %1 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: %[[ALLOC1:.*]] = test.region_if // CHECK-NEXT: ^bb0(%[[ALLOC2:.*]]:{{.*}}): // CHECK-NEXT: test.region_if_yield %[[ALLOC2]] @@ -688,7 +688,7 @@ // CHECK-LABEL: func @subview func @subview(%arg0 : index, %arg1 : index, %arg2 : memref) { - %0 = alloc() : memref<64x4xf32, offset: 0, strides: [4, 1]> + %0 = memref.alloc() : memref<64x4xf32, offset: 0, strides: [4, 1]> %1 = subview %0[%arg0, %arg1][%arg0, %arg1][%arg0, %arg1] : memref<64x4xf32, offset: 0, strides: [4, 1]> to memref @@ -697,10 +697,10 @@ return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: subview // CHECK-NEXT: test.copy -// CHECK-NEXT: dealloc %[[ALLOC]] +// CHECK-NEXT: memref.dealloc %[[ALLOC]] // CHECK-NEXT: return // ----- @@ -714,7 +714,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloca() : memref<2xf32> + %0 = memref.alloca() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): @@ -723,7 +723,7 @@ } // CHECK-NEXT: cond_br -// CHECK: %[[ALLOCA:.*]] = alloca() +// CHECK: %[[ALLOCA:.*]] = memref.alloca() // CHECK: br ^bb3(%[[ALLOCA:.*]]) // CHECK-NEXT: ^bb3 // CHECK-NEXT: test.copy @@ -737,7 +737,7 @@ // CHECK-LABEL: func @ifElseAlloca func @ifElseAlloca(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -747,17 +747,17 @@ ^bb2(%3: memref<2xf32>, %4: memref<2xf32>): br ^bb3(%3, %4 : memref<2xf32>, memref<2xf32>) ^bb3(%5: memref<2xf32>, %6: memref<2xf32>): - %7 = alloca() : memref<2xf32> + %7 = memref.alloca() : memref<2xf32> test.buffer_based in(%5: memref<2xf32>) out(%7: memref<2xf32>) test.copy(%7, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOCA:.*]] = alloca() +// CHECK: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based -// CHECK: dealloc %[[ALLOC]] +// CHECK: memref.dealloc %[[ALLOC]] // CHECK: test.copy // CHECK-NEXT: return @@ -768,7 +768,7 @@ %arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloca() : memref<2xf32> + %0 = memref.alloca() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -782,18 +782,18 @@ ^bb4(%6: memref<2xf32>): br ^bb5(%3, %6 : memref<2xf32>, memref<2xf32>) ^bb5(%7: memref<2xf32>, %8: memref<2xf32>): - %9 = alloc() : memref<2xf32> + %9 = memref.alloc() : memref<2xf32> test.buffer_based in(%7: memref<2xf32>) out(%9: memref<2xf32>) test.copy(%9, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOC:.*]] = alloc() +// CHECK: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // CHECK: test.copy -// CHECK-NEXT: dealloc %[[ALLOC]] +// CHECK-NEXT: memref.dealloc %[[ALLOC]] // CHECK-NEXT: return // ----- @@ -807,10 +807,10 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.region_buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) { ^bb0(%gen1_arg0: f32, %gen1_arg1: f32): - %1 = alloca() : memref<2xf32> + %1 = memref.alloca() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%1: memref<2xf32>) %tmp1 = math.exp %gen1_arg0 : f32 test.region_yield %tmp1 : f32 @@ -823,17 +823,17 @@ // CHECK: (%[[cond:.*]]: {{.*}}, %[[ARG1:.*]]: {{.*}}, %{{.*}}: {{.*}}) // CHECK-NEXT: cond_br %[[cond]], ^[[BB1:.*]], ^[[BB2:.*]] // CHECK: ^[[BB1]]: -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy // CHECK: ^[[BB2]]: -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.region_buffer_based in(%[[ARG1]]{{.*}}out(%[[ALLOC1]] -// CHECK: %[[ALLOCA:.*]] = alloca() +// CHECK: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based in(%[[ARG1]]{{.*}}out(%[[ALLOCA]] // CHECK: %{{.*}} = math.exp -// CHECK: %[[ALLOC2:.*]] = alloc() +// CHECK: %[[ALLOC2:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy -// CHECK-NEXT: dealloc %[[ALLOC1]] +// CHECK-NEXT: memref.dealloc %[[ALLOC1]] // CHECK: ^[[BB3:.*]]({{.*}}): // CHECK: test.copy // CHECK-NEXT: dealloc @@ -845,20 +845,20 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %3 = alloca(%arg0, %arg1) : memref + %3 = memref.alloca(%arg0, %arg1) : memref scf.yield %1 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: %[[ALLOC1:.*]] = scf.if // CHECK: scf.yield %[[ALLOC0]] -// CHECK: %[[ALLOCA:.*]] = alloca(%arg0, %arg1) +// CHECK: %[[ALLOCA:.*]] = memref.alloca(%arg0, %arg1) // CHECK-NEXT: scf.yield %[[ALLOC0]] // CHECK: return %[[ALLOC1]] @@ -875,33 +875,33 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index - %3 = alloc() : memref<2xf32> + %3 = memref.alloc() : memref<2xf32> scf.yield %3 : memref<2xf32> } test.copy(%1, %res) : (memref<2xf32>, memref<2xf32>) return } -// CHECK: %[[ALLOC0:.*]] = alloc() -// CHECK-NEXT: dealloc %[[ALLOC0]] -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() +// CHECK-NEXT: memref.dealloc %[[ALLOC0]] +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc() // CHECK: linalg.copy(%arg3, %[[ALLOC1]]) // CHECK: %[[ALLOC2:.*]] = scf.for {{.*}} iter_args // CHECK-SAME: (%[[IALLOC:.*]] = %[[ALLOC1]] // CHECK: cmpi -// CHECK: dealloc %[[IALLOC]] -// CHECK: %[[ALLOC3:.*]] = alloc() -// CHECK: %[[ALLOC4:.*]] = alloc() +// CHECK: memref.dealloc %[[IALLOC]] +// CHECK: %[[ALLOC3:.*]] = memref.alloc() +// CHECK: %[[ALLOC4:.*]] = memref.alloc() // CHECK: linalg.copy(%[[ALLOC3]], %[[ALLOC4]]) -// CHECK: dealloc %[[ALLOC3]] +// CHECK: memref.dealloc %[[ALLOC3]] // CHECK: scf.yield %[[ALLOC4]] // CHECK: } // CHECK: test.copy(%[[ALLOC2]], %arg4) -// CHECK-NEXT: dealloc %[[ALLOC2]] +// CHECK-NEXT: memref.dealloc %[[ALLOC2]] // ----- @@ -918,7 +918,7 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index @@ -933,14 +933,14 @@ return } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: %[[ALLOC1:.*]] = scf.for {{.*}} iter_args(%[[IALLOC:.*]] = // CHECK: %[[ALLOC2:.*]] = scf.if // CHECK: scf.yield %[[ALLOC0]] // CHECK: scf.yield %[[IALLOC]] // CHECK: scf.yield %[[ALLOC2]] // CHECK: test.copy(%[[ALLOC1]], %arg4) -// CHECK: dealloc %[[ALLOC0]] +// CHECK: memref.dealloc %[[ALLOC0]] // ----- @@ -958,12 +958,12 @@ %ub: index, %step: index, %buf: memref<2xf32>) -> memref<2xf32> { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index %3 = scf.if %2 -> (memref<2xf32>) { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> scf.yield %4 : memref<2xf32> } else { scf.yield %0 : memref<2xf32> @@ -973,30 +973,30 @@ return %1 : memref<2xf32> } -// CHECK: %[[ALLOC0:.*]] = alloc() -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%arg3, %[[ALLOC1]]) // CHECK-NEXT: %[[ALLOC2:.*]] = scf.for {{.*}} iter_args // CHECK-SAME: (%[[IALLOC:.*]] = %[[ALLOC1]] -// CHECK: dealloc %[[IALLOC]] +// CHECK: memref.dealloc %[[IALLOC]] // CHECK: %[[ALLOC3:.*]] = scf.if -// CHECK: %[[ALLOC4:.*]] = alloc() -// CHECK-NEXT: %[[ALLOC5:.*]] = alloc() +// CHECK: %[[ALLOC4:.*]] = memref.alloc() +// CHECK-NEXT: %[[ALLOC5:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC4]], %[[ALLOC5]]) -// CHECK-NEXT: dealloc %[[ALLOC4]] +// CHECK-NEXT: memref.dealloc %[[ALLOC4]] // CHECK-NEXT: scf.yield %[[ALLOC5]] -// CHECK: %[[ALLOC6:.*]] = alloc() +// CHECK: %[[ALLOC6:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC0]], %[[ALLOC6]]) // CHECK-NEXT: scf.yield %[[ALLOC6]] -// CHECK: %[[ALLOC7:.*]] = alloc() +// CHECK: %[[ALLOC7:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC3:.*]], %[[ALLOC7]]) -// CHECK-NEXT: dealloc %[[ALLOC3]] +// CHECK-NEXT: memref.dealloc %[[ALLOC3]] // CHECK-NEXT: scf.yield %[[ALLOC7]] -// CHECK: dealloc %[[ALLOC0]] +// CHECK: memref.dealloc %[[ALLOC0]] // CHECK-NEXT: return %[[ALLOC2]] // ----- @@ -1013,17 +1013,17 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = scf.for %i2 = %lb to %ub step %step iter_args(%iterBuf2 = %iterBuf) -> memref<2xf32> { %3 = scf.for %i3 = %lb to %ub step %step iter_args(%iterBuf3 = %iterBuf2) -> memref<2xf32> { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> %5 = cmpi eq, %i, %ub : index %6 = scf.if %5 -> (memref<2xf32>) { - %7 = alloc() : memref<2xf32> + %7 = memref.alloc() : memref<2xf32> scf.yield %7 : memref<2xf32> } else { scf.yield %iterBuf3 : memref<2xf32> @@ -1038,55 +1038,55 @@ return } -// CHECK: %[[ALLOC0:.*]] = alloc() -// CHECK-NEXT: dealloc %[[ALLOC0]] -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() +// CHECK-NEXT: memref.dealloc %[[ALLOC0]] +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%arg3, %[[ALLOC1]]) // CHECK-NEXT: %[[VAL_7:.*]] = scf.for {{.*}} iter_args // CHECK-SAME: (%[[IALLOC0:.*]] = %[[ALLOC1]]) -// CHECK: %[[ALLOC2:.*]] = alloc() +// CHECK: %[[ALLOC2:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[IALLOC0]], %[[ALLOC2]]) -// CHECK-NEXT: dealloc %[[IALLOC0]] +// CHECK-NEXT: memref.dealloc %[[IALLOC0]] // CHECK-NEXT: %[[ALLOC3:.*]] = scf.for {{.*}} iter_args // CHECK-SAME: (%[[IALLOC1:.*]] = %[[ALLOC2]]) -// CHECK: %[[ALLOC5:.*]] = alloc() +// CHECK: %[[ALLOC5:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[IALLOC1]], %[[ALLOC5]]) -// CHECK-NEXT: dealloc %[[IALLOC1]] +// CHECK-NEXT: memref.dealloc %[[IALLOC1]] // CHECK: %[[ALLOC6:.*]] = scf.for {{.*}} iter_args // CHECK-SAME: (%[[IALLOC2:.*]] = %[[ALLOC5]]) -// CHECK: %[[ALLOC8:.*]] = alloc() -// CHECK-NEXT: dealloc %[[ALLOC8]] +// CHECK: %[[ALLOC8:.*]] = memref.alloc() +// CHECK-NEXT: memref.dealloc %[[ALLOC8]] // CHECK: %[[ALLOC9:.*]] = scf.if -// CHECK: %[[ALLOC11:.*]] = alloc() -// CHECK-NEXT: %[[ALLOC12:.*]] = alloc() +// CHECK: %[[ALLOC11:.*]] = memref.alloc() +// CHECK-NEXT: %[[ALLOC12:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC11]], %[[ALLOC12]]) -// CHECK-NEXT: dealloc %[[ALLOC11]] +// CHECK-NEXT: memref.dealloc %[[ALLOC11]] // CHECK-NEXT: scf.yield %[[ALLOC12]] -// CHECK: %[[ALLOC13:.*]] = alloc() +// CHECK: %[[ALLOC13:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[IALLOC2]], %[[ALLOC13]]) // CHECK-NEXT: scf.yield %[[ALLOC13]] -// CHECK: dealloc %[[IALLOC2]] -// CHECK-NEXT: %[[ALLOC10:.*]] = alloc() +// CHECK: memref.dealloc %[[IALLOC2]] +// CHECK-NEXT: %[[ALLOC10:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC9]], %[[ALLOC10]]) -// CHECK-NEXT: dealloc %[[ALLOC9]] +// CHECK-NEXT: memref.dealloc %[[ALLOC9]] // CHECK-NEXT: scf.yield %[[ALLOC10]] -// CHECK: %[[ALLOC7:.*]] = alloc() +// CHECK: %[[ALLOC7:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC6]], %[[ALLOC7]]) -// CHECK-NEXT: dealloc %[[ALLOC6]] +// CHECK-NEXT: memref.dealloc %[[ALLOC6]] // CHECK-NEXT: scf.yield %[[ALLOC7]] -// CHECK: %[[ALLOC4:.*]] = alloc() +// CHECK: %[[ALLOC4:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ALLOC3]], %[[ALLOC4]]) -// CHECK-NEXT: dealloc %[[ALLOC3]] +// CHECK-NEXT: memref.dealloc %[[ALLOC3]] // CHECK-NEXT: scf.yield %[[ALLOC4]] // CHECK: test.copy(%[[VAL_7]], %arg4) -// CHECK-NEXT: dealloc %[[VAL_7]] +// CHECK-NEXT: memref.dealloc %[[VAL_7]] // ----- @@ -1113,7 +1113,7 @@ %const1 = constant 1 : i32 %inc = addi %val, %const1 : i32 %size = std.index_cast %inc : i32 to index - %alloc1 = alloc(%size) : memref + %alloc1 = memref.alloc(%size) : memref br ^loopHeader(%inc, %alloc1 : i32, memref) ^exit(%buff3 : memref): @@ -1139,7 +1139,7 @@ ^loopBody(%val : i32, %buff2: memref<2xf32>): %const1 = constant 1 : i32 %inc = addi %val, %const1 : i32 - %alloc1 = alloc() : memref<2xf32> + %alloc1 = memref.alloc() : memref<2xf32> br ^loopHeader(%inc, %alloc1 : i32, memref<2xf32>) ^loopHeader(%i : i32, %buff : memref<2xf32>): @@ -1162,12 +1162,12 @@ %arg3: memref<2xf32>) { // Confirm the alloc will be dealloc'ed in the block. %1 = shape.assuming %arg0 -> memref<2xf32> { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> shape.assuming_yield %arg2 : memref<2xf32> } // Confirm the alloc will be returned and dealloc'ed after its use. %3 = shape.assuming %arg0 -> memref<2xf32> { - %2 = alloc() : memref<2xf32> + %2 = memref.alloc() : memref<2xf32> shape.assuming_yield %2 : memref<2xf32> } test.copy(%3, %arg3) : (memref<2xf32>, memref<2xf32>) @@ -1178,17 +1178,17 @@ // CHECK-SAME: %[[ARG1:.*]]: {{.*}}, // CHECK-SAME: %[[ARG2:.*]]: {{.*}} // CHECK: %[[UNUSED_RESULT:.*]] = shape.assuming %[[ARG0]] -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() -// CHECK-NEXT: dealloc %[[ALLOC0]] +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() +// CHECK-NEXT: memref.dealloc %[[ALLOC0]] // CHECK-NEXT: shape.assuming_yield %[[ARG1]] // CHECK: %[[ASSUMING_RESULT:.*]] = shape.assuming %[[ARG0]] -// CHECK-NEXT: %[[TMP_ALLOC:.*]] = alloc() -// CHECK-NEXT: %[[RETURNING_ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[TMP_ALLOC:.*]] = memref.alloc() +// CHECK-NEXT: %[[RETURNING_ALLOC:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[TMP_ALLOC]], %[[RETURNING_ALLOC]]) -// CHECK-NEXT: dealloc %[[TMP_ALLOC]] +// CHECK-NEXT: memref.dealloc %[[TMP_ALLOC]] // CHECK-NEXT: shape.assuming_yield %[[RETURNING_ALLOC]] // CHECK: test.copy(%[[ASSUMING_RESULT:.*]], %[[ARG2]]) -// CHECK-NEXT: dealloc %[[ASSUMING_RESULT]] +// CHECK-NEXT: memref.dealloc %[[ASSUMING_RESULT]] // ----- diff --git a/mlir/test/Transforms/buffer-hoisting.mlir b/mlir/test/Transforms/buffer-hoisting.mlir --- a/mlir/test/Transforms/buffer-hoisting.mlir +++ b/mlir/test/Transforms/buffer-hoisting.mlir @@ -18,7 +18,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): @@ -26,7 +26,7 @@ return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: cond_br // ----- @@ -51,7 +51,7 @@ ^bb1: br ^bb3(%arg1 : memref) ^bb2(%0: index): - %1 = alloc(%0) : memref + %1 = memref.alloc(%0) : memref test.buffer_based in(%arg1: memref) out(%1: memref) br ^bb3(%1 : memref) ^bb3(%2: memref): @@ -62,7 +62,7 @@ // CHECK-NEXT: cond_br // CHECK: ^bb2 // CHECK: ^bb2(%[[IDX:.*]]:{{.*}}) -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc(%[[IDX]]) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc(%[[IDX]]) // CHECK-NEXT: test.buffer_based // ----- @@ -93,7 +93,7 @@ ^bb1: br ^bb6(%arg1 : memref) ^bb2(%0: index): - %1 = alloc(%0) : memref + %1 = memref.alloc(%0) : memref test.buffer_based in(%arg1: memref) out(%1: memref) cond_br %arg0, ^bb3, ^bb4 ^bb3: @@ -112,7 +112,7 @@ // CHECK-NEXT: cond_br // CHECK: ^bb2 // CHECK: ^bb2(%[[IDX:.*]]:{{.*}}) -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc(%[[IDX]]) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc(%[[IDX]]) // CHECK-NEXT: test.buffer_based // ----- @@ -130,7 +130,7 @@ func @criticalEdge(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { cond_br %arg0, ^bb1, ^bb2(%arg1 : memref<2xf32>) ^bb1: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb2(%0 : memref<2xf32>) ^bb2(%1: memref<2xf32>): @@ -138,7 +138,7 @@ return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: cond_br // ----- @@ -153,7 +153,7 @@ // CHECK-LABEL: func @ifElse func @ifElse(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -163,18 +163,18 @@ ^bb2(%3: memref<2xf32>, %4: memref<2xf32>): br ^bb3(%3, %4 : memref<2xf32>, memref<2xf32>) ^bb3(%5: memref<2xf32>, %6: memref<2xf32>): - %7 = alloc() : memref<2xf32> + %7 = memref.alloc() : memref<2xf32> test.buffer_based in(%7: memref<2xf32>) out(%7: memref<2xf32>) test.copy(%7, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // CHECK: br ^bb3 // CHECK: br ^bb3 // CHECK-NEXT: ^bb3 -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // CHECK: test.copy(%[[ALLOC1]] // CHECK-NEXT: return @@ -191,7 +191,7 @@ // CHECK-LABEL: func @ifElseNoUsers func @ifElseNoUsers(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -205,7 +205,7 @@ return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // ----- @@ -223,7 +223,7 @@ // CHECK-LABEL: func @ifElseNested func @ifElseNested(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -237,19 +237,19 @@ ^bb4(%6: memref<2xf32>): br ^bb5(%3, %6 : memref<2xf32>, memref<2xf32>) ^bb5(%7: memref<2xf32>, %8: memref<2xf32>): - %9 = alloc() : memref<2xf32> + %9 = memref.alloc() : memref<2xf32> test.buffer_based in(%7: memref<2xf32>) out(%9: memref<2xf32>) test.copy(%9, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // CHECK: br ^bb5 // CHECK: br ^bb5 // CHECK: br ^bb5 // CHECK-NEXT: ^bb5 -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // ----- @@ -259,16 +259,16 @@ // CHECK-LABEL: func @redundantOperations func @redundantOperations(%arg0: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%0: memref<2xf32>) out(%1: memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // ----- @@ -289,11 +289,11 @@ %arg1: memref<2xf32>) { cond_br %cond, ^bb1, ^bb2 ^bb1: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) br ^exit(%0 : memref<2xf32>) ^bb2: - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%1: memref<2xf32>) br ^exit(%1 : memref<2xf32>) ^exit(%arg2: memref<2xf32>): @@ -301,8 +301,8 @@ return } -// CHECK-NEXT: %{{.*}} = alloc() -// CHECK-NEXT: %{{.*}} = alloc() +// CHECK-NEXT: %{{.*}} = memref.alloc() +// CHECK-NEXT: %{{.*}} = memref.alloc() // CHECK-NEXT: cond_br // ----- @@ -326,16 +326,16 @@ ^bb1: br ^exit(%arg0 : memref<2xf32>) ^bb2: - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%1: memref<2xf32>) - dealloc %1 : memref<2xf32> + memref.dealloc %1 : memref<2xf32> br ^exit(%1 : memref<2xf32>) ^exit(%arg2: memref<2xf32>): test.copy(%arg2, %arg1) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %{{.*}} = alloc() +// CHECK-NEXT: %{{.*}} = memref.alloc() // CHECK-NEXT: cond_br // ----- @@ -355,10 +355,10 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.region_buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) { ^bb0(%gen1_arg0: f32, %gen1_arg1: f32): - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%1: memref<2xf32>) %tmp1 = math.exp %gen1_arg0 : f32 test.region_yield %tmp1 : f32 @@ -368,10 +368,10 @@ test.copy(%1, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: cond_br // CHECK: test.region_buffer_based -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // ----- @@ -385,20 +385,20 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %3 = alloc(%arg0, %arg1) : memref + %3 = memref.alloc(%arg0, %arg1) : memref scf.yield %1 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: %{{.*}} = scf.if // CHECK: else -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc(%arg0, %arg1) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc(%arg0, %arg1) // ----- @@ -411,18 +411,18 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %3 = alloc(%arg0, %arg1) : memref + %3 = memref.alloc(%arg0, %arg1) : memref scf.yield %3 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc(%arg0, %arg1) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc(%arg0, %arg1) // CHECK-NEXT: %{{.*}} = scf.if // ----- @@ -437,24 +437,24 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { %3 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %4 = alloc(%arg0, %arg1) : memref + %4 = memref.alloc(%arg0, %arg1) : memref scf.yield %4 : memref } scf.yield %3 : memref } else { - %5 = alloc(%arg1, %arg1) : memref + %5 = memref.alloc(%arg1, %arg1) : memref scf.yield %5 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc(%arg0, %arg1) -// CHECK-NEXT: %[[ALLOC2:.*]] = alloc(%arg1, %arg1) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc(%arg0, %arg1) +// CHECK-NEXT: %[[ALLOC2:.*]] = memref.alloc(%arg1, %arg1) // CHECK-NEXT: %{{.*}} = scf.if // ----- @@ -464,7 +464,7 @@ // CHECK-LABEL: func @inner_region_control_flow func @inner_region_control_flow(%arg0 : index) -> memref { - %0 = alloc(%arg0, %arg0) : memref + %0 = memref.alloc(%arg0, %arg0) : memref %1 = test.region_if %0 : memref -> (memref) then { ^bb0(%arg1 : memref): test.region_if_yield %arg1 : memref @@ -478,7 +478,7 @@ return %1 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: {{.*}} test.region_if // ----- @@ -491,13 +491,13 @@ func @inner_region_control_flow_div( %arg0 : index, %arg1 : index) -> memref { - %0 = alloc(%arg0, %arg0) : memref + %0 = memref.alloc(%arg0, %arg0) : memref %1 = test.region_if %0 : memref -> (memref) then { ^bb0(%arg2 : memref): test.region_if_yield %arg2 : memref } else { ^bb0(%arg2 : memref): - %2 = alloc(%arg0, %arg1) : memref + %2 = memref.alloc(%arg0, %arg1) : memref test.region_if_yield %2 : memref } join { ^bb0(%arg2 : memref): @@ -506,8 +506,8 @@ return %1 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc(%arg0, %arg1) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc(%arg0, %arg1) // CHECK-NEXT: {{.*}} test.region_if // ----- @@ -520,7 +520,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloca() : memref<2xf32> + %0 = memref.alloca() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): @@ -531,7 +531,7 @@ // CHECK-NEXT: cond_br // CHECK: ^bb2 // CHECK: ^bb2 -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based // ----- @@ -544,7 +544,7 @@ %arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloca() : memref<2xf32> + %0 = memref.alloca() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -558,19 +558,19 @@ ^bb4(%6: memref<2xf32>): br ^bb5(%3, %6 : memref<2xf32>, memref<2xf32>) ^bb5(%7: memref<2xf32>, %8: memref<2xf32>): - %9 = alloc() : memref<2xf32> + %9 = memref.alloc() : memref<2xf32> test.buffer_based in(%7: memref<2xf32>) out(%9: memref<2xf32>) test.copy(%9, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based // CHECK: ^bb5 // CHECK: ^bb5 // CHECK: ^bb5 // CHECK-NEXT: ^bb5 -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // ----- @@ -587,10 +587,10 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.region_buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) { ^bb0(%gen1_arg0: f32, %gen1_arg1: f32): - %1 = alloca() : memref<2xf32> + %1 = memref.alloca() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%1: memref<2xf32>) %tmp1 = math.exp %gen1_arg0 : f32 test.region_yield %tmp1 : f32 @@ -600,10 +600,10 @@ test.copy(%1, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: cond_br // CHECK: test.region_buffer_based -// CHECK: %[[ALLOCA:.*]] = alloca() +// CHECK: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based // ----- @@ -618,20 +618,20 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index - %3 = alloc() : memref<2xf32> + %3 = memref.alloc() : memref<2xf32> scf.yield %3 : memref<2xf32> } test.copy(%1, %res) : (memref<2xf32>, memref<2xf32>) return } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: {{.*}} scf.for -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // ----- @@ -645,12 +645,12 @@ %ub: index, %step: index, %buf: memref<2xf32>) -> memref<2xf32> { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index %3 = scf.if %2 -> (memref<2xf32>) { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> scf.yield %4 : memref<2xf32> } else { scf.yield %0 : memref<2xf32> @@ -660,9 +660,9 @@ return %1 : memref<2xf32> } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: {{.*}} scf.for -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // ----- @@ -677,17 +677,17 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = scf.for %i2 = %lb to %ub step %step iter_args(%iterBuf2 = %iterBuf) -> memref<2xf32> { %3 = scf.for %i3 = %lb to %ub step %step iter_args(%iterBuf3 = %iterBuf2) -> memref<2xf32> { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> %5 = cmpi eq, %i, %ub : index %6 = scf.if %5 -> (memref<2xf32>) { - %7 = alloc() : memref<2xf32> + %7 = memref.alloc() : memref<2xf32> scf.yield %7 : memref<2xf32> } else { scf.yield %iterBuf3 : memref<2xf32> @@ -702,12 +702,12 @@ return } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc() -// CHECK: %[[ALLOC2:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc() +// CHECK: %[[ALLOC2:.*]] = memref.alloc() // ----- @@ -719,7 +719,7 @@ %arg0: index, %buf: memref, %res: memref) { - %0 = alloc(%arg0) : memref + %0 = memref.alloc(%arg0) : memref %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref { %2 = scf.for %i2 = %lb to %ub step %step @@ -728,7 +728,7 @@ iter_args(%iterBuf3 = %iterBuf2) -> memref { %5 = cmpi eq, %i, %ub : index %6 = scf.if %5 -> (memref) { - %7 = alloc(%i3) : memref + %7 = memref.alloc(%i3) : memref scf.yield %7 : memref } else { scf.yield %iterBuf3 : memref @@ -744,8 +744,8 @@ } -// CHECK: %[[ALLOC0:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC0:.*]] = memref.alloc({{.*}}) // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for -// CHECK: %[[ALLOC1:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC1:.*]] = memref.alloc({{.*}}) diff --git a/mlir/test/Transforms/buffer-loop-hoisting.mlir b/mlir/test/Transforms/buffer-loop-hoisting.mlir --- a/mlir/test/Transforms/buffer-loop-hoisting.mlir +++ b/mlir/test/Transforms/buffer-loop-hoisting.mlir @@ -17,7 +17,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): @@ -26,7 +26,7 @@ } // CHECK-NEXT: cond_br -// CHECK: %[[ALLOC:.*]] = alloc() +// CHECK: %[[ALLOC:.*]] = memref.alloc() // ----- @@ -50,7 +50,7 @@ ^bb1: br ^bb3(%arg1 : memref) ^bb2(%0: index): - %1 = alloc(%0) : memref + %1 = memref.alloc(%0) : memref test.buffer_based in(%arg1: memref) out(%1: memref) br ^bb3(%1 : memref) ^bb3(%2: memref): @@ -61,7 +61,7 @@ // CHECK-NEXT: cond_br // CHECK: ^bb2 // CHECK: ^bb2(%[[IDX:.*]]:{{.*}}) -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc(%[[IDX]]) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc(%[[IDX]]) // CHECK-NEXT: test.buffer_based // ----- @@ -81,10 +81,10 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.region_buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) { ^bb0(%gen1_arg0: f32, %gen1_arg1: f32): - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%1: memref<2xf32>) %tmp1 = math.exp %gen1_arg0 : f32 test.region_yield %tmp1 : f32 @@ -95,9 +95,9 @@ return } // CHECK-NEXT: cond_br -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK: test.region_buffer_based -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // CHECK-NEXT: test.buffer_based // ----- @@ -111,20 +111,20 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %3 = alloc(%arg0, %arg1) : memref + %3 = memref.alloc(%arg0, %arg1) : memref scf.yield %1 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: %{{.*}} = scf.if // CHECK: else -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc(%arg0, %arg1) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc(%arg0, %arg1) // ----- @@ -138,20 +138,20 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index - %3 = alloc() : memref<2xf32> + %3 = memref.alloc() : memref<2xf32> scf.yield %3 : memref<2xf32> } test.copy(%1, %res) : (memref<2xf32>, memref<2xf32>) return } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: {{.*}} scf.for -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // ----- @@ -165,12 +165,12 @@ %ub: index, %step: index, %buf: memref<2xf32>) -> memref<2xf32> { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index %3 = scf.if %2 -> (memref<2xf32>) { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> scf.yield %4 : memref<2xf32> } else { scf.yield %0 : memref<2xf32> @@ -180,9 +180,9 @@ return %1 : memref<2xf32> } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: {{.*}} scf.for -// CHECK: %[[ALLOC1:.*]] = alloc() +// CHECK: %[[ALLOC1:.*]] = memref.alloc() // ----- @@ -198,23 +198,23 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = scf.for %i2 = %lb to %ub step %step iter_args(%iterBuf2 = %iterBuf) -> memref<2xf32> { %3 = scf.for %i3 = %lb to %ub step %step iter_args(%iterBuf3 = %iterBuf2) -> memref<2xf32> { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> %5 = cmpi eq, %i, %ub : index %6 = scf.if %5 -> (memref<2xf32>) { - %7 = alloc() : memref<2xf32> - %8 = alloc() : memref<2xf32> + %7 = memref.alloc() : memref<2xf32> + %8 = memref.alloc() : memref<2xf32> scf.yield %8 : memref<2xf32> } else { scf.yield %iterBuf3 : memref<2xf32> } - %9 = alloc() : memref<2xf32> + %9 = memref.alloc() : memref<2xf32> scf.yield %6 : memref<2xf32> } scf.yield %3 : memref<2xf32> @@ -225,15 +225,15 @@ return } -// CHECK: %[[ALLOC0:.*]] = alloc() -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc() -// CHECK-NEXT: %[[ALLOC2:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc() +// CHECK-NEXT: %[[ALLOC2:.*]] = memref.alloc() // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for // CHECK: {{.*}} = scf.if -// CHECK: %[[ALLOC3:.*]] = alloc() -// CHECK: %[[ALLOC4:.*]] = alloc() +// CHECK: %[[ALLOC3:.*]] = memref.alloc() +// CHECK: %[[ALLOC4:.*]] = memref.alloc() // ----- @@ -245,22 +245,22 @@ %arg0: index, %buf: memref, %res: memref) { - %0 = alloc(%arg0) : memref + %0 = memref.alloc(%arg0) : memref %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref { %2 = scf.for %i2 = %lb to %ub step %step iter_args(%iterBuf2 = %iterBuf) -> memref { %3 = scf.for %i3 = %lb to %ub step %step iter_args(%iterBuf3 = %iterBuf2) -> memref { - %4 = alloc(%i3) : memref + %4 = memref.alloc(%i3) : memref %5 = cmpi eq, %i, %ub : index %6 = scf.if %5 -> (memref) { - %7 = alloc(%i3) : memref + %7 = memref.alloc(%i3) : memref scf.yield %7 : memref } else { scf.yield %iterBuf3 : memref } - %8 = alloc(%i3) : memref + %8 = memref.alloc(%i3) : memref scf.yield %6 : memref } scf.yield %3 : memref @@ -271,12 +271,12 @@ return } -// CHECK: %[[ALLOC0:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC0:.*]] = memref.alloc({{.*}}) // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for // CHECK-NEXT: {{.*}} = scf.for -// CHECK: %[[ALLOC1:.*]] = alloc({{.*}}) -// CHECK: %[[ALLOC2:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC1:.*]] = memref.alloc({{.*}}) +// CHECK: %[[ALLOC2:.*]] = memref.alloc({{.*}}) // ----- @@ -287,18 +287,18 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { - %2 = alloc() : memref<2xf32> + %2 = memref.alloc() : memref<2xf32> scf.yield %0 : memref<2xf32> } test.copy(%1, %res) : (memref<2xf32>, memref<2xf32>) return } -// CHECK: %[[ALLOC0:.*]] = alloc({{.*}}) -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC0:.*]] = memref.alloc({{.*}}) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc({{.*}}) // CHECK-NEXT: {{.*}} = scf.for // ----- @@ -312,7 +312,7 @@ %res: memref<2xf32>) { %0 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> scf.yield %1 : memref<2xf32> } test.copy(%0, %res) : (memref<2xf32>, memref<2xf32>) @@ -320,7 +320,7 @@ } // CHECK: {{.*}} = scf.for -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc({{.*}}) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc({{.*}}) // ----- @@ -331,12 +331,12 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = scf.for %i2 = %lb to %ub step %step iter_args(%iterBuf2 = %iterBuf) -> memref<2xf32> { - %3 = alloc() : memref<2xf32> + %3 = memref.alloc() : memref<2xf32> scf.yield %0 : memref<2xf32> } scf.yield %0 : memref<2xf32> @@ -345,8 +345,8 @@ return } -// CHECK: %[[ALLOC0:.*]] = alloc({{.*}}) -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC0:.*]] = memref.alloc({{.*}}) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc({{.*}}) // CHECK-NEXT: {{.*}} = scf.for // ----- @@ -362,7 +362,7 @@ iter_args(%iterBuf = %buf) -> memref<2xf32> { %1 = cmpi eq, %i, %ub : index %2 = scf.if %1 -> (memref<2xf32>) { - %3 = alloc() : memref<2xf32> + %3 = memref.alloc() : memref<2xf32> scf.yield %3 : memref<2xf32> } else { scf.yield %iterBuf : memref<2xf32> @@ -375,7 +375,7 @@ // CHECK: {{.*}} = scf.for // CHECK: {{.*}} = scf.if -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc({{.*}}) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc({{.*}}) // ----- @@ -386,12 +386,12 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = cmpi eq, %lb, %ub : index %2 = scf.if %1 -> (memref<2xf32>) { %3 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> scf.yield %0 : memref<2xf32> } scf.yield %0 : memref<2xf32> @@ -405,7 +405,7 @@ } // CHECK: {{.*}} = scf.if -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc({{.*}}) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc({{.*}}) // CHECK: {{.*}} = scf.for // ----- @@ -417,19 +417,19 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { - %2 = alloc(%i) : memref + %2 = memref.alloc(%i) : memref scf.yield %0 : memref<2xf32> } test.copy(%1, %res) : (memref<2xf32>, memref<2xf32>) return } -// CHECK: %[[ALLOC0:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC0:.*]] = memref.alloc({{.*}}) // CHECK-NEXT: {{.*}} = scf.for -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc({{.*}}) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc({{.*}}) // ----- @@ -440,12 +440,12 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = scf.for %i2 = %lb to %ub step %step iter_args(%iterBuf2 = %iterBuf) -> memref<2xf32> { - %3 = alloc(%i) : memref + %3 = memref.alloc(%i) : memref scf.yield %0 : memref<2xf32> } scf.yield %0 : memref<2xf32> @@ -454,7 +454,7 @@ return } -// CHECK: %[[ALLOC0:.*]] = alloc({{.*}}) +// CHECK: %[[ALLOC0:.*]] = memref.alloc({{.*}}) // CHECK-NEXT: {{.*}} = scf.for -// CHECK-NEXT: %[[ALLOC1:.*]] = alloc({{.*}}) +// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc({{.*}}) // CHECK-NEXT: {{.*}} = scf.for diff --git a/mlir/test/Transforms/buffer-results-to-out-params.mlir b/mlir/test/Transforms/buffer-results-to-out-params.mlir --- a/mlir/test/Transforms/buffer-results-to-out-params.mlir +++ b/mlir/test/Transforms/buffer-results-to-out-params.mlir @@ -60,7 +60,7 @@ func private @callee() -> memref<1xf32> // CHECK-LABEL: func @call_basic() { -// CHECK: %[[OUTPARAM:.*]] = alloc() : memref<1xf32> +// CHECK: %[[OUTPARAM:.*]] = memref.alloc() : memref<1xf32> // CHECK: call @callee(%[[OUTPARAM]]) : (memref<1xf32>) -> () // CHECK: "test.sink"(%[[OUTPARAM]]) : (memref<1xf32>) -> () // CHECK: return @@ -77,8 +77,8 @@ func private @callee() -> (memref<1xf32>, memref<2xf32>) // CHECK-LABEL: func @call_multiple_result() { -// CHECK: %[[RESULT0:.*]] = alloc() : memref<1xf32> -// CHECK: %[[RESULT1:.*]] = alloc() : memref<2xf32> +// CHECK: %[[RESULT0:.*]] = memref.alloc() : memref<1xf32> +// CHECK: %[[RESULT1:.*]] = memref.alloc() : memref<2xf32> // CHECK: call @callee(%[[RESULT0]], %[[RESULT1]]) : (memref<1xf32>, memref<2xf32>) -> () // CHECK: "test.sink"(%[[RESULT0]], %[[RESULT1]]) : (memref<1xf32>, memref<2xf32>) -> () // CHECK: } @@ -93,7 +93,7 @@ func private @callee() -> (i1, memref<1xf32>, i32) // CHECK-LABEL: func @call_non_memref_result() { -// CHECK: %[[RESULT0:.*]] = alloc() : memref<1xf32> +// CHECK: %[[RESULT0:.*]] = memref.alloc() : memref<1xf32> // CHECK: %[[NON_MEMREF_RESULTS:.*]]:2 = call @callee(%[[RESULT0]]) : (memref<1xf32>) -> (i1, i32) // CHECK: "test.sink"(%[[NON_MEMREF_RESULTS]]#0, %[[RESULT0]], %[[NON_MEMREF_RESULTS]]#1) : (i1, memref<1xf32>, i32) -> () // CHECK: } diff --git a/mlir/test/Transforms/canonicalize-block-merge.mlir b/mlir/test/Transforms/canonicalize-block-merge.mlir --- a/mlir/test/Transforms/canonicalize-block-merge.mlir +++ b/mlir/test/Transforms/canonicalize-block-merge.mlir @@ -213,13 +213,13 @@ cond_br %arg0, ^bb2, ^bb3 ^bb2: - // CHECK: store %{{.*}}, %{{.*}} : memref - store %c0_i32, %arg1[] : memref + // CHECK: memref.store %{{.*}}, %{{.*}} : memref + memref.store %c0_i32, %arg1[] : memref br ^bb1 ^bb3: - // CHECK: store %{{.*}}, %{{.*}} : memref - store %true, %arg2[] : memref + // CHECK: memref.store %{{.*}}, %{{.*}} : memref + memref.store %true, %arg2[] : memref br ^bb1 } diff --git a/mlir/test/Transforms/canonicalize.mlir b/mlir/test/Transforms/canonicalize.mlir --- a/mlir/test/Transforms/canonicalize.mlir +++ b/mlir/test/Transforms/canonicalize.mlir @@ -61,9 +61,9 @@ // CHECK-LABEL: func @load_dce func @load_dce(%arg0: index) { %c4 = constant 4 : index - %a = alloc(%c4) : memref + %a = memref.alloc(%c4) : memref %2 = load %a[%arg0] : memref - dealloc %a: memref + memref.dealloc %a: memref // CHECK-NEXT: return return } @@ -313,7 +313,7 @@ // CHECK-LABEL: func @memref_cast_folding func @memref_cast_folding(%arg0: memref<4 x f32>, %arg1: f32) -> (f32, f32) { - %0 = memref_cast %arg0 : memref<4xf32> to memref + %0 = memref.cast %arg0 : memref<4xf32> to memref // CHECK-NEXT: %c0 = constant 0 : index %c0 = constant 0 : index %dim = dim %0, %c0 : memref @@ -321,14 +321,14 @@ // CHECK-NEXT: affine.load %arg0[3] %1 = affine.load %0[%dim - 1] : memref - // CHECK-NEXT: store %arg1, %arg0[%c0] : memref<4xf32> - store %arg1, %0[%c0] : memref + // CHECK-NEXT: memref.store %arg1, %arg0[%c0] : memref<4xf32> + memref.store %arg1, %0[%c0] : memref // CHECK-NEXT: %{{.*}} = load %arg0[%c0] : memref<4xf32> %2 = load %0[%c0] : memref - // CHECK-NEXT: dealloc %arg0 : memref<4xf32> - dealloc %0: memref + // CHECK-NEXT: memref.dealloc %arg0 : memref<4xf32> + memref.dealloc %0: memref // CHECK-NEXT: return %{{.*}} return %1, %2 : f32, f32 @@ -337,10 +337,10 @@ // CHECK-LABEL: @fold_memref_cast_in_memref_cast // CHECK-SAME: (%[[ARG0:.*]]: memref<42x42xf64>) func @fold_memref_cast_in_memref_cast(%0: memref<42x42xf64>) { - // CHECK: %[[folded:.*]] = memref_cast %[[ARG0]] : memref<42x42xf64> to memref - %4 = memref_cast %0 : memref<42x42xf64> to memref - // CHECK-NOT: memref_cast - %5 = memref_cast %4 : memref to memref + // CHECK: %[[folded:.*]] = memref.cast %[[ARG0]] : memref<42x42xf64> to memref + %4 = memref.cast %0 : memref<42x42xf64> to memref + // CHECK-NOT: memref.cast + %5 = memref.cast %4 : memref to memref // CHECK: "test.user"(%[[folded]]) "test.user"(%5) : (memref) -> () return @@ -349,9 +349,9 @@ // CHECK-LABEL: @fold_memref_cast_chain // CHECK-SAME: (%[[ARG0:.*]]: memref<42x42xf64>) func @fold_memref_cast_chain(%0: memref<42x42xf64>) { - // CHECK-NOT: memref_cast - %4 = memref_cast %0 : memref<42x42xf64> to memref - %5 = memref_cast %4 : memref to memref<42x42xf64> + // CHECK-NOT: memref.cast + %4 = memref.cast %0 : memref<42x42xf64> to memref + %5 = memref.cast %4 : memref to memref<42x42xf64> // CHECK: "test.user"(%[[ARG0]]) "test.user"(%5) : (memref<42x42xf64>) -> () return @@ -359,11 +359,11 @@ // CHECK-LABEL: func @alloc_const_fold func @alloc_const_fold() -> memref { - // CHECK-NEXT: %0 = alloc() : memref<4xf32> + // CHECK-NEXT: %0 = memref.alloc() : memref<4xf32> %c4 = constant 4 : index - %a = alloc(%c4) : memref + %a = memref.alloc(%c4) : memref - // CHECK-NEXT: %1 = memref_cast %0 : memref<4xf32> to memref + // CHECK-NEXT: %1 = memref.cast %0 : memref<4xf32> to memref // CHECK-NEXT: return %1 : memref return %a : memref } @@ -372,30 +372,30 @@ func @dead_alloc_fold() { // CHECK-NEXT: return %c4 = constant 4 : index - %a = alloc(%c4) : memref + %a = memref.alloc(%c4) : memref return } // CHECK-LABEL: func @dead_dealloc_fold func @dead_dealloc_fold() { // CHECK-NEXT: return - %a = alloc() : memref<4xf32> - dealloc %a: memref<4xf32> + %a = memref.alloc() : memref<4xf32> + memref.dealloc %a: memref<4xf32> return } // CHECK-LABEL: func @dead_dealloc_fold_multi_use func @dead_dealloc_fold_multi_use(%cond : i1) { // CHECK-NEXT: return - %a = alloc() : memref<4xf32> + %a = memref.alloc() : memref<4xf32> cond_br %cond, ^bb1, ^bb2 ^bb1: - dealloc %a: memref<4xf32> + memref.dealloc %a: memref<4xf32> return ^bb2: - dealloc %a: memref<4xf32> + memref.dealloc %a: memref<4xf32> return } @@ -423,29 +423,29 @@ %N = constant 1024 : index %K = constant 512 : index - // CHECK-NEXT: alloc(%arg0) : memref - %a = alloc(%L, %N) : memref + // CHECK-NEXT: memref.alloc(%arg0) : memref + %a = memref.alloc(%L, %N) : memref - // CHECK-NEXT: alloc(%arg1) : memref<4x1024x8x512x?xf32> - %b = alloc(%N, %K, %M) : memref<4 x ? x 8 x ? x ? x f32> + // CHECK-NEXT: memref.alloc(%arg1) : memref<4x1024x8x512x?xf32> + %b = memref.alloc(%N, %K, %M) : memref<4 x ? x 8 x ? x ? x f32> - // CHECK-NEXT: alloc() : memref<512x1024xi32> - %c = alloc(%K, %N) : memref + // CHECK-NEXT: memref.alloc() : memref<512x1024xi32> + %c = memref.alloc(%K, %N) : memref - // CHECK: alloc() : memref<9x9xf32> - %d = alloc(%nine, %nine) : memref + // CHECK: memref.alloc() : memref<9x9xf32> + %d = memref.alloc(%nine, %nine) : memref - // CHECK: alloca(%arg1) : memref<4x1024x8x512x?xf32> - %e = alloca(%N, %K, %M) : memref<4 x ? x 8 x ? x ? x f32> + // CHECK: memref.alloca(%arg1) : memref<4x1024x8x512x?xf32> + %e = memref.alloca(%N, %K, %M) : memref<4 x ? x 8 x ? x ? x f32> // CHECK: affine.for affine.for %i = 0 to %L { // CHECK-NEXT: affine.for affine.for %j = 0 to 10 { // CHECK-NEXT: load %0[%arg2, %arg3] : memref - // CHECK-NEXT: store %{{.*}}, %1[%c0, %c0, %arg2, %arg3, %c0] : memref<4x1024x8x512x?xf32> + // CHECK-NEXT: memref.store %{{.*}}, %1[%c0, %c0, %arg2, %arg3, %c0] : memref<4x1024x8x512x?xf32> %v = load %a[%i, %j] : memref - store %v, %b[%zero, %zero, %i, %j, %zero] : memref<4x?x8x?x?xf32> + memref.store %v, %b[%zero, %zero, %i, %j, %zero] : memref<4x?x8x?x?xf32> } } @@ -468,15 +468,15 @@ %c0 = constant 0 : index %c1 = constant 1 : index %c2 = constant 2 : index - %0 = alloc(%arg0, %arg1) : memref - %1 = alloc(%arg1, %arg2) : memref + %0 = memref.alloc(%arg0, %arg1) : memref + %1 = memref.alloc(%arg1, %arg2) : memref %2 = dim %1, %c2 : memref affine.for %arg3 = 0 to %2 { - %3 = alloc(%arg0) : memref + %3 = memref.alloc(%arg0) : memref %ub = dim %3, %c0 : memref affine.for %arg4 = 0 to %ub { %s = dim %0, %c0 : memref - %v = std.view %3[%c0][%arg4, %s] : memref to memref + %v = memref.view %3[%c0][%arg4, %s] : memref to memref %sv = subview %0[%c0, %c0][%s,%arg4][%c1,%c1] : memref to memref %l = dim %v, %c1 : memref %u = dim %sv, %c0 : memref @@ -502,9 +502,9 @@ // CHECK-NEXT: } // CHECK-NEXT: } - %A = view %BUF[%c0][%M, %K] : memref to memref - %B = view %BUF[%c0][%K, %N] : memref to memref - %C = view %BUF[%c0][%M, %N] : memref to memref + %A = memref.view %BUF[%c0][%M, %K] : memref to memref + %B = memref.view %BUF[%c0][%K, %N] : memref to memref + %C = memref.view %BUF[%c0][%M, %N] : memref to memref %M_ = dim %A, %c0 : memref %K_ = dim %A, %c1 : memref @@ -533,9 +533,9 @@ // CHECK-NEXT: %c42_i32 = constant 42 : i32 // CHECK-NEXT: affine.for %arg1 = 0 to 8 { affine.for %arg1 = 0 to 8 { - // CHECK-NEXT: store %c42_i32, %arg0[%arg1] + // CHECK-NEXT: memref.store %c42_i32, %arg0[%arg1] %c42_i32 = constant 42 : i32 - store %c42_i32, %arg0[%arg1] : memref<8xi32> + memref.store %c42_i32, %arg0[%arg1] : memref<8xi32> } return } @@ -547,8 +547,8 @@ %VT_i_s = affine.apply affine_map<(d0) -> (d0 floordiv 8)> (%VT_i) %VT_k_l = affine.apply affine_map<(d0) -> (d0 floordiv 16)> (%VT_i) - // CHECK: = alloc() : memref<64x32xf32> - %Av = alloc(%VT_i_s, %VT_k_l) : memref + // CHECK: = memref.alloc() : memref<64x32xf32> + %Av = memref.alloc(%VT_i_s, %VT_k_l) : memref return %Av : memref } @@ -663,11 +663,11 @@ // CHECK-LABEL: cast_values func @cast_values(%arg0: memref) -> memref<2xi32> { // NOP cast - %1 = memref_cast %arg0 : memref to memref - // CHECK-NEXT: %[[RET:.*]] = memref_cast %arg0 : memref to memref<2xi32> - %3 = memref_cast %1 : memref to memref<2xi32> + %1 = memref.cast %arg0 : memref to memref + // CHECK-NEXT: %[[RET:.*]] = memref.cast %arg0 : memref to memref<2xi32> + %3 = memref.cast %1 : memref to memref<2xi32> // NOP cast - %5 = memref_cast %3 : memref<2xi32> to memref<2xi32> + %5 = memref.cast %3 : memref<2xi32> to memref<2xi32> // CHECK-NEXT: return %[[RET]] : memref<2xi32> return %5 : memref<2xi32> } @@ -677,32 +677,32 @@ // CHECK-LABEL: func @view func @view(%arg0 : index) -> (f32, f32, f32, f32) { // CHECK: %[[C15:.*]] = constant 15 : index - // CHECK: %[[ALLOC_MEM:.*]] = alloc() : memref<2048xi8> - %0 = alloc() : memref<2048xi8> + // CHECK: %[[ALLOC_MEM:.*]] = memref.alloc() : memref<2048xi8> + %0 = memref.alloc() : memref<2048xi8> %c0 = constant 0 : index %c7 = constant 7 : index %c11 = constant 11 : index %c15 = constant 15 : index // Test: fold constant sizes. - // CHECK: std.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<7x11xf32> - %1 = view %0[%c15][%c7, %c11] : memref<2048xi8> to memref + // CHECK: memref.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<7x11xf32> + %1 = memref.view %0[%c15][%c7, %c11] : memref<2048xi8> to memref %r0 = load %1[%c0, %c0] : memref // Test: fold one constant size. - // CHECK: std.view %[[ALLOC_MEM]][%[[C15]]][%arg0, %arg0] : memref<2048xi8> to memref - %2 = view %0[%c15][%arg0, %arg0, %c7] : memref<2048xi8> to memref + // CHECK: memref.view %[[ALLOC_MEM]][%[[C15]]][%arg0, %arg0] : memref<2048xi8> to memref + %2 = memref.view %0[%c15][%arg0, %arg0, %c7] : memref<2048xi8> to memref %r1 = load %2[%c0, %c0, %c0] : memref // Test: preserve an existing static size. - // CHECK: std.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<7x4xf32> - %3 = view %0[%c15][%c7] : memref<2048xi8> to memref + // CHECK: memref.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<7x4xf32> + %3 = memref.view %0[%c15][%c7] : memref<2048xi8> to memref %r2 = load %3[%c0, %c0] : memref - // Test: folding static alloc and memref_cast into a view. - // CHECK: std.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<15x7xf32> - %4 = memref_cast %0 : memref<2048xi8> to memref - %5 = view %4[%c15][%c15, %c7] : memref to memref + // Test: folding static alloc and memref.cast into a view. + // CHECK memref.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<15x7xf32> + %4 = memref.cast %0 : memref<2048xi8> to memref + %5 = memref.view %4[%c15][%c15, %c7] : memref to memref %r3 = load %5[%c0, %c0] : memref return %r0, %r1, %r2, %r3 : f32, f32, f32, f32 } @@ -739,8 +739,8 @@ // CHECK-NOT: constant 15 : index %c15 = constant 15 : index - // CHECK: %[[ALLOC0:.*]] = alloc() - %0 = alloc() : memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> + // CHECK: %[[ALLOC0:.*]] = memref.alloc() + %0 = memref.alloc() : memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> // Test: subview with constant base memref and constant operands is folded. // Note that the subview uses the base memrefs layout map because it used @@ -760,10 +760,10 @@ %2 = subview %0[%c0, %arg0, %c0] [%c7, %c11, %c15] [%c1, %c1, %c1] : memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> to memref - store %v0, %2[%c0, %c0, %c0] : memref + memref.store %v0, %2[%c0, %c0, %c0] : memref - // CHECK: %[[ALLOC1:.*]] = alloc(%[[ARG0]]) - %3 = alloc(%arg0) : memref + // CHECK: %[[ALLOC1:.*]] = memref.alloc(%[[ARG0]]) + %3 = memref.alloc(%arg0) : memref // Test: subview with constant operands but dynamic base memref is folded as long as the strides and offset of the base memref are static. // CHECK: subview %[[ALLOC1]][0, 0, 0] [7, 11, 15] [1, 1, 1] : // CHECK-SAME: memref @@ -771,7 +771,7 @@ %4 = subview %3[%c0, %c0, %c0] [%c7, %c11, %c15] [%c1, %c1, %c1] : memref to memref - store %v0, %4[%c0, %c0, %c0] : memref + memref.store %v0, %4[%c0, %c0, %c0] : memref // Test: subview offset operands are folded correctly w.r.t. base strides. // CHECK: subview %[[ALLOC0]][1, 2, 7] [7, 11, 2] [1, 1, 1] : @@ -780,7 +780,7 @@ %5 = subview %0[%c1, %c2, %c7] [%c7, %c11, %c2] [%c1, %c1, %c1] : memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> to memref - store %v0, %5[%c0, %c0, %c0] : memref + memref.store %v0, %5[%c0, %c0, %c0] : memref // Test: subview stride operands are folded correctly w.r.t. base strides. // CHECK: subview %[[ALLOC0]][0, 0, 0] [7, 11, 2] [2, 7, 11] : @@ -789,7 +789,7 @@ %6 = subview %0[%c0, %c0, %c0] [%c7, %c11, %c2] [%c2, %c7, %c11] : memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> to memref - store %v0, %6[%c0, %c0, %c0] : memref + memref.store %v0, %6[%c0, %c0, %c0] : memref // Test: subview shape are folded, but offsets and strides are not even if base memref is static // CHECK: subview %[[ALLOC0]][%[[ARG0]], %[[ARG0]], %[[ARG0]]] [7, 11, 2] [%[[ARG1]], %[[ARG1]], %[[ARG1]]] : @@ -798,7 +798,7 @@ %10 = subview %0[%arg0, %arg0, %arg0] [%c7, %c11, %c2] [%arg1, %arg1, %arg1] : memref<8x16x4xf32, offset:0, strides:[64, 4, 1]> to memref - store %v0, %10[%arg1, %arg1, %arg1] : + memref.store %v0, %10[%arg1, %arg1, %arg1] : memref // Test: subview strides are folded, but offsets and shape are not even if base memref is static @@ -808,7 +808,7 @@ %11 = subview %0[%arg0, %arg0, %arg0] [%arg1, %arg1, %arg1] [%c2, %c7, %c11] : memref<8x16x4xf32, offset:0, strides:[64, 4, 1]> to memref - store %v0, %11[%arg0, %arg0, %arg0] : + memref.store %v0, %11[%arg0, %arg0, %arg0] : memref // Test: subview offsets are folded, but strides and shape are not even if base memref is static @@ -818,11 +818,11 @@ %13 = subview %0[%c1, %c2, %c7] [%arg1, %arg1, %arg1] [%arg0, %arg0, %arg0] : memref<8x16x4xf32, offset:0, strides:[64, 4, 1]> to memref - store %v0, %13[%arg1, %arg1, %arg1] : + memref.store %v0, %13[%arg1, %arg1, %arg1] : memref - // CHECK: %[[ALLOC2:.*]] = alloc(%[[ARG0]], %[[ARG0]], %[[ARG1]]) - %14 = alloc(%arg0, %arg0, %arg1) : memref + // CHECK: %[[ALLOC2:.*]] = memref.alloc(%[[ARG0]], %[[ARG0]], %[[ARG1]]) + %14 = memref.alloc(%arg0, %arg0, %arg1) : memref // Test: subview shape are folded, even if base memref is not static // CHECK: subview %[[ALLOC2]][%[[ARG0]], %[[ARG0]], %[[ARG0]]] [7, 11, 2] [%[[ARG1]], %[[ARG1]], %[[ARG1]]] : // CHECK-SAME: memref to @@ -830,7 +830,7 @@ %15 = subview %14[%arg0, %arg0, %arg0] [%c7, %c11, %c2] [%arg1, %arg1, %arg1] : memref to memref - store %v0, %15[%arg1, %arg1, %arg1] : memref + memref.store %v0, %15[%arg1, %arg1, %arg1] : memref // TEST: subview strides are folded, in the type only the most minor stride is folded. // CHECK: subview %[[ALLOC2]][%[[ARG0]], %[[ARG0]], %[[ARG0]]] [%[[ARG1]], %[[ARG1]], %[[ARG1]]] [2, 2, 2] : @@ -839,7 +839,7 @@ %16 = subview %14[%arg0, %arg0, %arg0] [%arg1, %arg1, %arg1] [%c2, %c2, %c2] : memref to memref - store %v0, %16[%arg0, %arg0, %arg0] : memref + memref.store %v0, %16[%arg0, %arg0, %arg0] : memref // TEST: subview offsets are folded but the type offset remains dynamic, when the base memref is not static // CHECK: subview %[[ALLOC2]][1, 1, 1] [%[[ARG0]], %[[ARG0]], %[[ARG0]]] [%[[ARG1]], %[[ARG1]], %[[ARG1]]] : @@ -848,10 +848,10 @@ %17 = subview %14[%c1, %c1, %c1] [%arg0, %arg0, %arg0] [%arg1, %arg1, %arg1] : memref to memref - store %v0, %17[%arg0, %arg0, %arg0] : memref + memref.store %v0, %17[%arg0, %arg0, %arg0] : memref - // CHECK: %[[ALLOC3:.*]] = alloc() : memref<12x4xf32> - %18 = alloc() : memref<12x4xf32> + // CHECK: %[[ALLOC3:.*]] = memref.alloc() : memref<12x4xf32> + %18 = memref.alloc() : memref<12x4xf32> %c4 = constant 4 : index // TEST: subview strides are maintained when sizes are folded @@ -861,7 +861,7 @@ %19 = subview %18[%arg1, %arg1] [%c2, %c4] [1, 1] : memref<12x4xf32> to memref - store %v0, %19[%arg1, %arg1] : memref + memref.store %v0, %19[%arg1, %arg1] : memref // TEST: subview strides and sizes are maintained when offsets are folded // CHECK: subview %[[ALLOC3]][2, 4] [12, 4] [1, 1] : @@ -870,7 +870,7 @@ %20 = subview %18[%c2, %c4] [12, 4] [1, 1] : memref<12x4xf32> to memref<12x4xf32, offset: ?, strides:[4, 1]> - store %v0, %20[%arg1, %arg1] : memref<12x4xf32, offset: ?, strides:[4, 1]> + memref.store %v0, %20[%arg1, %arg1] : memref<12x4xf32, offset: ?, strides:[4, 1]> // Test: dim on subview is rewritten to size operand. %7 = dim %4, %c0 : memref @@ -1006,7 +1006,7 @@ // CHECK-LABEL: func @memref_cast_folding_subview func @memref_cast_folding_subview(%arg0: memref<4x5xf32>, %i: index) -> (memref) { - %0 = memref_cast %arg0 : memref<4x5xf32> to memref + %0 = memref.cast %arg0 : memref<4x5xf32> to memref // CHECK-NEXT: subview %{{.*}}: memref<4x5xf32> %1 = subview %0[%i, %i][%i, %i][%i, %i]: memref to memref // CHECK-NEXT: return %{{.*}} @@ -1022,11 +1022,10 @@ func @memref_cast_folding_subview_static(%V: memref<16x16xf32>, %a: index, %b: index) -> memref<3x4xf32, offset:?, strides:[?, 1]> { - %0 = memref_cast %V : memref<16x16xf32> to memref + %0 = memref.cast %V : memref<16x16xf32> to memref %1 = subview %0[0, 0][3, 4][1, 1] : memref to memref<3x4xf32, offset:?, strides:[?, 1]> // CHECK: subview{{.*}}: memref<16x16xf32> to memref<3x4xf32, #[[$map0]]> - // CHECK: memref_cast{{.*}}: memref<3x4xf32, #[[$map0]]> to memref<3x4xf32, #[[$map1]]> return %1: memref<3x4xf32, offset:?, strides:[?, 1]> } @@ -1034,8 +1033,8 @@ // CHECK-LABEL: func @subtensor // CHECK-SAME: %[[ARG0:[0-9a-z]*]]: index, %[[ARG1:[0-9a-z]*]]: index -func @subtensor(%t: tensor<8x16x4xf32>, %arg0 : index, %arg1 : index) - -> tensor +func @subtensor(%t: tensor<8x16x4xf32>, %arg0 : index, %arg1 : index) + -> tensor { %c0 = constant 0 : index %c1 = constant 1 : index diff --git a/mlir/test/Transforms/constant-fold.mlir b/mlir/test/Transforms/constant-fold.mlir --- a/mlir/test/Transforms/constant-fold.mlir +++ b/mlir/test/Transforms/constant-fold.mlir @@ -13,8 +13,8 @@ %2 = addf %0, %1 : f32 - // CHECK-NEXT: store [[C]], [[ARG]][] - store %2, %p[] : memref + // CHECK-NEXT: memref.store [[C]], [[ARG]][] + memref.store %2, %p[] : memref } } return diff --git a/mlir/test/Transforms/copy-removal.mlir b/mlir/test/Transforms/copy-removal.mlir --- a/mlir/test/Transforms/copy-removal.mlir +++ b/mlir/test/Transforms/copy-removal.mlir @@ -6,7 +6,7 @@ // CHECK-LABEL: func @nested_region_control_flow_div_nested func @nested_region_control_flow_div_nested(%arg0: index, %arg1: index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref // CHECK: %{{.*}} = scf.if %2 = scf.if %0 -> (memref) { // CHECK: %[[PERCENT3:.*]] = scf.if @@ -15,24 +15,24 @@ %7 = dim %1, %c0_0 : memref %c1_1 = constant 1 : index %8 = dim %1, %c1_1 : memref - %9 = alloc(%7, %8) : memref + %9 = memref.alloc(%7, %8) : memref // CHECK: linalg.copy({{.*}}, %[[PERCENT9:.*]]) linalg.copy(%1, %9) : memref, memref // CHECK: scf.yield %[[PERCENT9]] scf.yield %9 : memref } else { - // CHECK: %[[PERCENT7:.*]] = alloc - %7 = alloc(%arg0, %arg1) : memref + // CHECK: %[[PERCENT7:.*]] = memref.alloc + %7 = memref.alloc(%arg0, %arg1) : memref %c0_0 = constant 0 : index %8 = dim %7, %c0_0 : memref %c1_1 = constant 1 : index %9 = dim %7, %c1_1 : memref - // CHECK-NOT: %{{.*}} = alloc + // CHECK-NOT: %{{.*}} = memref.alloc // CHECK-NOT: linalg.copy(%[[PERCENT7]], %{{.*}}) - // CHECK-NOT: dealloc %[[PERCENT7]] - %10 = alloc(%8, %9) : memref + // CHECK-NOT: memref.dealloc %[[PERCENT7]] + %10 = memref.alloc(%8, %9) : memref linalg.copy(%7, %10) : memref, memref - dealloc %7 : memref + memref.dealloc %7 : memref // CHECK: scf.yield %[[PERCENT7]] scf.yield %10 : memref } @@ -40,31 +40,31 @@ %4 = dim %3, %c0 : memref %c1 = constant 1 : index %5 = dim %3, %c1 : memref - // CHECK-NOT: %{{.*}} = alloc + // CHECK-NOT: %{{.*}} = memref.alloc // CHECK-NOT: linalg.copy(%[[PERCENT3]], %{{.*}}) - // CHECK-NOT: dealloc %[[PERCENT3]] - %6 = alloc(%4, %5) : memref + // CHECK-NOT: memref.dealloc %[[PERCENT3]] + %6 = memref.alloc(%4, %5) : memref linalg.copy(%3, %6) : memref, memref - dealloc %3 : memref + memref.dealloc %3 : memref // CHECK: scf.yield %[[PERCENT3]] scf.yield %6 : memref } else { - // CHECK: %[[PERCENT3:.*]] = alloc - %3 = alloc(%arg1, %arg1) : memref + // CHECK: %[[PERCENT3:.*]] = memref.alloc + %3 = memref.alloc(%arg1, %arg1) : memref %c0 = constant 0 : index %4 = dim %3, %c0 : memref %c1 = constant 1 : index %5 = dim %3, %c1 : memref - // CHECK-NOT: %{{.*}} = alloc + // CHECK-NOT: %{{.*}} = memref.alloc // CHECK-NOT: linalg.copy(%[[PERCENT3]], %{{.*}}) - // CHECK-NOT: dealloc %[[PERCENT3]] - %6 = alloc(%4, %5) : memref + // CHECK-NOT: memref.dealloc %[[PERCENT3]] + %6 = memref.alloc(%4, %5) : memref linalg.copy(%3, %6) : memref, memref - dealloc %3 : memref + memref.dealloc %3 : memref // CHECK: scf.yield %[[PERCENT3]] scf.yield %6 : memref } - dealloc %1 : memref + memref.dealloc %1 : memref return %2 : memref } @@ -72,16 +72,16 @@ // CHECK-LABEL: func @simple_test func @simple_test() -> memref<5xf32> { - %temp = alloc() : memref<5xf32> - %ret = alloc() : memref<5xf32> + %temp = memref.alloc() : memref<5xf32> + %ret = memref.alloc() : memref<5xf32> linalg.copy(%ret, %temp) : memref<5xf32>, memref<5xf32> - dealloc %ret : memref<5xf32> + memref.dealloc %ret : memref<5xf32> return %temp : memref<5xf32> } // CHECK-SAME: () -> memref<5xf32> -// CHECK-NEXT: %[[ret:.*]] = alloc() +// CHECK-NEXT: %[[ret:.*]] = memref.alloc() // CHECK-NOT: linalg.copy(%[[ret]], %{{.*}}) -// CHECK-NOT: dealloc %[[ret]] +// CHECK-NOT: memref.dealloc %[[ret]] // CHECK: return %[[ret]] // ----- @@ -92,20 +92,20 @@ // CHECK-LABEL: func @test_with_ret_usage_before_copy func @test_with_ret_usage_before_copy() -> memref<5xf32> { - %ret = alloc() : memref<5xf32> - %temp = alloc() : memref<5xf32> + %ret = memref.alloc() : memref<5xf32> + %temp = memref.alloc() : memref<5xf32> %c0 = constant 0 : index %dimension = dim %ret, %c0 : memref<5xf32> linalg.copy(%ret, %temp) : memref<5xf32>, memref<5xf32> - dealloc %ret : memref<5xf32> + memref.dealloc %ret : memref<5xf32> return %temp : memref<5xf32> } -// CHECK-NEXT: %[[ret:.*]] = alloc() -// CHECK-NOT: %{{.*}} = alloc +// CHECK-NEXT: %[[ret:.*]] = memref.alloc() +// CHECK-NOT: %{{.*}} = memref.alloc // CHECK-NEXT: %{{.*}} = constant // CHECK-NEXT: %[[DIM:.*]] = dim %[[ret]] // CHECK-NOT: linalg.copy(%[[ret]], %{{.*}}) -// CHECK-NOT: dealloc %[[ret]] +// CHECK-NOT: memref.dealloc %[[ret]] // CHECK: return %[[ret]] // ----- @@ -115,13 +115,13 @@ // CHECK-LABEL: func @test_with_ret_usage_after_copy func @test_with_ret_usage_after_copy() -> memref<5xf32> { - %ret = alloc() : memref<5xf32> - %temp = alloc() : memref<5xf32> + %ret = memref.alloc() : memref<5xf32> + %temp = memref.alloc() : memref<5xf32> // CHECK: linalg.copy linalg.copy(%ret, %temp) : memref<5xf32>, memref<5xf32> %c0 = constant 0 : index %dimension = dim %ret, %c0 : memref<5xf32> - dealloc %ret : memref<5xf32> + memref.dealloc %ret : memref<5xf32> return %temp : memref<5xf32> } @@ -132,13 +132,13 @@ // CHECK-LABEL: func @test_with_temp_usage_before_copy func @test_with_temp_usage_before_copy() -> memref<5xf32> { - %ret = alloc() : memref<5xf32> - %temp = alloc() : memref<5xf32> + %ret = memref.alloc() : memref<5xf32> + %temp = memref.alloc() : memref<5xf32> %c0 = constant 0 : index %dimension = dim %temp, %c0 : memref<5xf32> // CHECK: linalg.copy linalg.copy(%ret, %temp) : memref<5xf32>, memref<5xf32> - dealloc %ret : memref<5xf32> + memref.dealloc %ret : memref<5xf32> return %temp : memref<5xf32> } @@ -149,11 +149,11 @@ // removed. // However the following pattern is not handled by copy removal. -// %from = alloc() -// %to = alloc() +// %from = memref.alloc() +// %to = memref.alloc() // copy(%from, %to) // read_from(%from) + write_to(%something_else) -// dealloc(%from) +// memref.dealloc(%from) // return %to // In particular, linalg.generic is a memoryEffectOp between copy and dealloc. // Since no alias analysis is performed and no distinction is made between reads @@ -163,9 +163,9 @@ // CHECK-LABEL: func @test_with_temp_usage_after_copy func @test_with_temp_usage_after_copy() -> memref<5xf32> { - %ret = alloc() : memref<5xf32> - %res = alloc() : memref<5xf32> - %temp = alloc() : memref<5xf32> + %ret = memref.alloc() : memref<5xf32> + %res = memref.alloc() : memref<5xf32> + %temp = memref.alloc() : memref<5xf32> linalg.copy(%ret, %temp) : memref<5xf32>, memref<5xf32> linalg.generic { indexing_maps = [#map0, #map0], @@ -176,22 +176,22 @@ %tmp1 = math.exp %gen1_arg0 : f32 linalg.yield %tmp1 : f32 } - dealloc %ret : memref<5xf32> + memref.dealloc %ret : memref<5xf32> return %temp : memref<5xf32> } -// CHECK-NEXT: %[[ret:.*]] = alloc() -// CHECK-NEXT: %[[res:.*]] = alloc() -// CHECK-NEXT: %[[temp:.*]] = alloc() +// CHECK-NEXT: %[[ret:.*]] = memref.alloc() +// CHECK-NEXT: %[[res:.*]] = memref.alloc() +// CHECK-NEXT: %[[temp:.*]] = memref.alloc() // CHECK-NEXT: linalg.copy(%[[ret]], %[[temp]]) // CHECK-NEXT: linalg.generic -// CHECK: dealloc %[[ret]] +// CHECK: memref.dealloc %[[ret]] // CHECK: return %[[temp]] // ----- // CHECK-LABEL: func @make_allocation func @make_allocation() -> memref<5xf32> { - %mem = alloc() : memref<5xf32> + %mem = memref.alloc() : memref<5xf32> return %mem : memref<5xf32> } @@ -199,12 +199,12 @@ func @test_with_function_call() -> memref<5xf32> { // CHECK-NEXT: %[[ret:.*]] = call @make_allocation() : () -> memref<5xf32> %ret = call @make_allocation() : () -> (memref<5xf32>) - // CHECK-NOT: %{{.*}} = alloc + // CHECK-NOT: %{{.*}} = memref.alloc // CHECK-NOT: linalg.copy(%[[ret]], %{{.*}}) - // CHECK-NOT: dealloc %[[ret]] - %temp = alloc() : memref<5xf32> + // CHECK-NOT: memref.dealloc %[[ret]] + %temp = memref.alloc() : memref<5xf32> linalg.copy(%ret, %temp) : memref<5xf32>, memref<5xf32> - dealloc %ret : memref<5xf32> + memref.dealloc %ret : memref<5xf32> // CHECK: return %[[ret]] return %temp : memref<5xf32> } @@ -213,20 +213,20 @@ // CHECK-LABEL: func @multiple_deallocs_in_different_blocks func @multiple_deallocs_in_different_blocks(%cond : i1) -> memref<5xf32> { - // CHECK-NEXT: %[[PERCENT0:.*]] = alloc() - %0 = alloc() : memref<5xf32> + // CHECK-NEXT: %[[PERCENT0:.*]] = memref.alloc() + %0 = memref.alloc() : memref<5xf32> cond_br %cond, ^bb1, ^bb2 ^bb1: - dealloc %0 : memref<5xf32> + memref.dealloc %0 : memref<5xf32> // CHECK: br ^[[BB3:.*]](%[[PERCENT0]] br ^bb3(%0 : memref<5xf32>) ^bb2: - // CHECK-NOT: %{{.*}} = alloc + // CHECK-NOT: %{{.*}} = memref.alloc // CHECK-NOT: linalg.copy(%[[PERCENT0]], %{{.*}}) - // CHECK-NOT: dealloc %[[PERCENT0]] - %temp = alloc() : memref<5xf32> + // CHECK-NOT: memref.dealloc %[[PERCENT0]] + %temp = memref.alloc() : memref<5xf32> linalg.copy(%0, %temp) : memref<5xf32>, memref<5xf32> - dealloc %0 : memref<5xf32> + memref.dealloc %0 : memref<5xf32> // CHECK: br ^[[BB3]](%[[PERCENT0]] br ^bb3(%temp : memref<5xf32>) ^bb3(%res : memref<5xf32>): @@ -240,12 +240,12 @@ // CHECK-LABEL: func @test_ReuseCopyTargetAsSource func @test_ReuseCopyTargetAsSource(%arg0: memref<2xf32>, %result: memref<2xf32>){ // CHECK-SAME: (%[[ARG0:.*]]: memref<2xf32>, %[[RES:.*]]: memref<2xf32>) - // CHECK-NOT: %{{.*}} = alloc - %temp = alloc() : memref<2xf32> + // CHECK-NOT: %{{.*}} = memref.alloc + %temp = memref.alloc() : memref<2xf32> // CHECK-NEXT: linalg.generic // CHECK-SAME: ins(%[[ARG0]]{{.*}}outs(%[[RES]] // CHECK-NOT: linalg.copy(%{{.*}}, %[[RES]]) - // CHECK-NOT: dealloc %{{.*}} + // CHECK-NOT: memref.dealloc %{{.*}} linalg.generic { indexing_maps = [#map0, #map0], iterator_types = ["parallel"]} @@ -256,7 +256,7 @@ linalg.yield %tmp2 : f32 } linalg.copy(%temp, %result) : memref<2xf32>, memref<2xf32> - dealloc %temp : memref<2xf32> + memref.dealloc %temp : memref<2xf32> // CHECK: return return } @@ -270,8 +270,8 @@ // CHECK-LABEL: func @test_ReuseCopyTargetAsSource func @test_ReuseCopyTargetAsSource(%arg0: memref<2xf32>){ - %to = alloc() : memref<2xf32> - %temp = alloc() : memref<2xf32> + %to = memref.alloc() : memref<2xf32> + %temp = memref.alloc() : memref<2xf32> linalg.generic { indexing_maps = [#map0, #map0], iterator_types = ["parallel"]} @@ -292,7 +292,7 @@ } // CHECK: linalg.copy linalg.copy(%temp, %to) : memref<2xf32>, memref<2xf32> - dealloc %temp : memref<2xf32> + memref.dealloc %temp : memref<2xf32> return } @@ -302,34 +302,34 @@ // CHECK-LABEL: func @loop_alloc func @loop_alloc(%arg0: index, %arg1: index, %arg2: index, %arg3: memref<2xf32>, %arg4: memref<2xf32>) { - // CHECK: %{{.*}} = alloc() - %0 = alloc() : memref<2xf32> - dealloc %0 : memref<2xf32> - // CHECK: %{{.*}} = alloc() - %1 = alloc() : memref<2xf32> + // CHECK: %{{.*}} = memref.alloc() + %0 = memref.alloc() : memref<2xf32> + memref.dealloc %0 : memref<2xf32> + // CHECK: %{{.*}} = memref.alloc() + %1 = memref.alloc() : memref<2xf32> // CHECK: linalg.copy linalg.copy(%arg3, %1) : memref<2xf32>, memref<2xf32> %2 = scf.for %arg5 = %arg0 to %arg1 step %arg2 iter_args(%arg6 = %1) -> (memref<2xf32>) { %3 = cmpi eq, %arg5, %arg1 : index - // CHECK: dealloc - dealloc %arg6 : memref<2xf32> - // CHECK: %[[PERCENT4:.*]] = alloc() - %4 = alloc() : memref<2xf32> - // CHECK-NOT: alloc + // CHECK: memref.dealloc + memref.dealloc %arg6 : memref<2xf32> + // CHECK: %[[PERCENT4:.*]] = memref.alloc() + %4 = memref.alloc() : memref<2xf32> + // CHECK-NOT: memref.alloc // CHECK-NOT: linalg.copy - // CHECK-NOT: dealloc - %5 = alloc() : memref<2xf32> + // CHECK-NOT: memref.dealloc + %5 = memref.alloc() : memref<2xf32> linalg.copy(%4, %5) : memref<2xf32>, memref<2xf32> - dealloc %4 : memref<2xf32> - // CHECK: %[[PERCENT6:.*]] = alloc() - %6 = alloc() : memref<2xf32> + memref.dealloc %4 : memref<2xf32> + // CHECK: %[[PERCENT6:.*]] = memref.alloc() + %6 = memref.alloc() : memref<2xf32> // CHECK: linalg.copy(%[[PERCENT4]], %[[PERCENT6]]) linalg.copy(%5, %6) : memref<2xf32>, memref<2xf32> scf.yield %6 : memref<2xf32> } // CHECK: linalg.copy linalg.copy(%2, %arg4) : memref<2xf32>, memref<2xf32> - dealloc %2 : memref<2xf32> + memref.dealloc %2 : memref<2xf32> return } @@ -341,8 +341,8 @@ // CHECK-LABEL: func @check_with_affine_dialect func @check_with_affine_dialect(%arg0: memref<4xf32>, %arg1: memref<4xf32>, %arg2: memref<4xf32>) { // CHECK-SAME: (%[[ARG0:.*]]: memref<4xf32>, %[[ARG1:.*]]: memref<4xf32>, %[[RES:.*]]: memref<4xf32>) - // CHECK-NOT: alloc - %0 = alloc() : memref<4xf32> + // CHECK-NOT: memref.alloc + %0 = memref.alloc() : memref<4xf32> affine.for %arg3 = 0 to 4 { %5 = affine.load %arg0[%arg3] : memref<4xf32> %6 = affine.load %arg1[%arg3] : memref<4xf32> @@ -355,7 +355,7 @@ // CHECK-NOT: linalg.copy // CHECK-NOT: dealloc linalg.copy(%0, %arg2) : memref<4xf32>, memref<4xf32> - dealloc %0 : memref<4xf32> + memref.dealloc %0 : memref<4xf32> //CHECK: return return } diff --git a/mlir/test/Transforms/cse.mlir b/mlir/test/Transforms/cse.mlir --- a/mlir/test/Transforms/cse.mlir +++ b/mlir/test/Transforms/cse.mlir @@ -96,11 +96,11 @@ /// Check that operations with side effects are not eliminated. // CHECK-LABEL: @side_effect func @side_effect() -> (memref<2x1xf32>, memref<2x1xf32>) { - // CHECK: %0 = alloc() : memref<2x1xf32> - %0 = alloc() : memref<2x1xf32> + // CHECK: %0 = memref.alloc() : memref<2x1xf32> + %0 = memref.alloc() : memref<2x1xf32> - // CHECK-NEXT: %1 = alloc() : memref<2x1xf32> - %1 = alloc() : memref<2x1xf32> + // CHECK-NEXT: %1 = memref.alloc() : memref<2x1xf32> + %1 = memref.alloc() : memref<2x1xf32> // CHECK-NEXT: return %0, %1 : memref<2x1xf32>, memref<2x1xf32> return %0, %1 : memref<2x1xf32>, memref<2x1xf32> diff --git a/mlir/test/Transforms/loop-fusion-dependence-check.mlir b/mlir/test/Transforms/loop-fusion-dependence-check.mlir --- a/mlir/test/Transforms/loop-fusion-dependence-check.mlir +++ b/mlir/test/Transforms/loop-fusion-dependence-check.mlir @@ -4,9 +4,9 @@ // CHECK-LABEL: func @cannot_fuse_would_create_cycle() { func @cannot_fuse_would_create_cycle() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -37,9 +37,9 @@ // CHECK-LABEL: func @can_fuse_rar_dependence() { func @can_fuse_rar_dependence() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -69,10 +69,10 @@ // CHECK-LABEL: func @can_fuse_different_memrefs() { func @can_fuse_different_memrefs() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> - %d = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> + %d = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -102,7 +102,7 @@ // CHECK-LABEL: func @should_not_fuse_across_intermediate_store() { func @should_not_fuse_across_intermediate_store() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -127,7 +127,7 @@ // CHECK-LABEL: func @should_not_fuse_across_intermediate_load() { func @should_not_fuse_across_intermediate_load() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -152,8 +152,8 @@ // CHECK-LABEL: func @should_not_fuse_across_ssa_value_def() { func @should_not_fuse_across_ssa_value_def() { - %0 = alloc() : memref<10xf32> - %1 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> + %1 = memref.alloc() : memref<10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -182,7 +182,7 @@ // CHECK-LABEL: func @should_not_fuse_store_before_load() { func @should_not_fuse_store_before_load() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -208,7 +208,7 @@ // CHECK-LABEL: func @should_not_fuse_across_load_at_depth1() { func @should_not_fuse_across_load_at_depth1() { - %0 = alloc() : memref<10x10xf32> + %0 = memref.alloc() : memref<10x10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -232,7 +232,7 @@ // CHECK-LABEL: func @should_not_fuse_across_load_in_loop_at_depth1() { func @should_not_fuse_across_load_in_loop_at_depth1() { - %0 = alloc() : memref<10x10xf32> + %0 = memref.alloc() : memref<10x10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -258,7 +258,7 @@ // CHECK-LABEL: func @should_not_fuse_across_store_at_depth1() { func @should_not_fuse_across_store_at_depth1() { - %0 = alloc() : memref<10x10xf32> + %0 = memref.alloc() : memref<10x10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -282,7 +282,7 @@ // CHECK-LABEL: func @should_not_fuse_across_store_in_loop_at_depth1() { func @should_not_fuse_across_store_in_loop_at_depth1() { - %0 = alloc() : memref<10x10xf32> + %0 = memref.alloc() : memref<10x10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 @@ -308,8 +308,8 @@ // CHECK-LABEL: func @should_not_fuse_across_ssa_value_def_at_depth1() { func @should_not_fuse_across_ssa_value_def_at_depth1() { - %0 = alloc() : memref<10x10xf32> - %1 = alloc() : memref<10x10xf32> + %0 = memref.alloc() : memref<10x10xf32> + %1 = memref.alloc() : memref<10x10xf32> %c0 = constant 0 : index %cf7 = constant 7.0 : f32 diff --git a/mlir/test/Transforms/loop-fusion-slice-computation.mlir b/mlir/test/Transforms/loop-fusion-slice-computation.mlir --- a/mlir/test/Transforms/loop-fusion-slice-computation.mlir +++ b/mlir/test/Transforms/loop-fusion-slice-computation.mlir @@ -4,7 +4,7 @@ // CHECK-LABEL: func @slice_depth1_loop_nest() { func @slice_depth1_loop_nest() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { // expected-remark@-1 {{slice ( src loop: 1, dst loop: 0, depth: 1 : insert point: (1, 1) loop bounds: [(d0) -> (d0), (d0) -> (d0 + 1)] )}} @@ -24,7 +24,7 @@ // same location. // CHECK-LABEL: func @slice_depth1_loop_nest_with_offsets() { func @slice_depth1_loop_nest_with_offsets() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { // expected-remark@-1 {{slice ( src loop: 1, dst loop: 0, depth: 1 : insert point: (1, 2) loop bounds: [(d0) -> (d0 + 3), (d0) -> (d0 + 4)] )}} @@ -45,7 +45,7 @@ // Slices at loop depth 2 should slice loop bounds of both loops. // CHECK-LABEL: func @slice_depth2_loop_nest() { func @slice_depth2_loop_nest() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { // expected-remark@-1 {{slice ( src loop: 1, dst loop: 0, depth: 1 : insert point: (1, 1) loop bounds: [(d0) -> (d0), (d0) -> (d0 + 1)] [(d0) -> (0), (d0) -> (8)] )}} @@ -71,7 +71,7 @@ // depths 1 and 2 because the dependent store in loop nest %i0 is at depth 2. // CHECK-LABEL: func @slice_depth2_loop_nest_two_loads() { func @slice_depth2_loop_nest_two_loads() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> %c0 = constant 0 : index %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { @@ -99,7 +99,7 @@ // loop nest %i2 is at depth 2. // CHECK-LABEL: func @slice_depth2_loop_nest_two_stores() { func @slice_depth2_loop_nest_two_stores() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> %c0 = constant 0 : index %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { @@ -124,7 +124,7 @@ // Test loop nest which has a smaller outer trip count than its inner scf. // CHECK-LABEL: func @slice_loop_nest_with_smaller_outer_trip_count() { func @slice_loop_nest_with_smaller_outer_trip_count() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> %c0 = constant 0 : index %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { diff --git a/mlir/test/Transforms/loop-fusion-transformation.mlir b/mlir/test/Transforms/loop-fusion-transformation.mlir --- a/mlir/test/Transforms/loop-fusion-transformation.mlir +++ b/mlir/test/Transforms/loop-fusion-transformation.mlir @@ -2,7 +2,7 @@ // CHECK-LABEL: func @slice_depth1_loop_nest() { func @slice_depth1_loop_nest() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 16 { affine.store %cst, %0[%i0] : memref<100xf32> @@ -24,9 +24,9 @@ // CHECK-LABEL: func @should_fuse_reduction_to_pointwise() { func @should_fuse_reduction_to_pointwise() { - %a = alloc() : memref<10x10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10x10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -64,9 +64,9 @@ // CHECK-LABEL: func @should_fuse_avoiding_dependence_cycle() { func @should_fuse_avoiding_dependence_cycle() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 diff --git a/mlir/test/Transforms/loop-fusion.mlir b/mlir/test/Transforms/loop-fusion.mlir --- a/mlir/test/Transforms/loop-fusion.mlir +++ b/mlir/test/Transforms/loop-fusion.mlir @@ -12,7 +12,7 @@ // CHECK-LABEL: func @should_fuse_raw_dep_for_locality() { func @should_fuse_raw_dep_for_locality() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -33,9 +33,9 @@ // CHECK-LABEL: func @should_fuse_reduction_to_pointwise() { func @should_fuse_reduction_to_pointwise() { - %a = alloc() : memref<10x10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10x10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -76,7 +76,7 @@ // CHECK-LABEL: func @should_fuse_loop_nests_with_shifts() { func @should_fuse_loop_nests_with_shifts() { - %a = alloc() : memref<10x10xf32> + %a = memref.alloc() : memref<10x10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 9 { @@ -116,8 +116,8 @@ // CHECK-LABEL: func @should_fuse_loop_nest() { func @should_fuse_loop_nest() { - %a = alloc() : memref<10x10xf32> - %b = alloc() : memref<10x10xf32> + %a = memref.alloc() : memref<10x10xf32> + %b = memref.alloc() : memref<10x10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -137,8 +137,8 @@ } } // Expecting private memref for '%a' first, then private memref for '%b'. - // CHECK-DAG: [[NEWA:%[0-9]+]] = alloc() : memref<1x1xf32> - // CHECK-DAG: [[NEWB:%[0-9]+]] = alloc() : memref<1x1xf32> + // CHECK-DAG: [[NEWA:%[0-9]+]] = memref.alloc() : memref<1x1xf32> + // CHECK-DAG: [[NEWB:%[0-9]+]] = memref.alloc() : memref<1x1xf32> // CHECK: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.store %{{.*}}, [[NEWA]][0, 0] : memref<1x1xf32> @@ -155,9 +155,9 @@ // CHECK-LABEL: func @should_fuse_across_intermediate_loop_with_no_deps() { func @should_fuse_across_intermediate_loop_with_no_deps() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -190,8 +190,8 @@ // CHECK-LABEL: func @should_fuse_all_loops() { func @should_fuse_all_loops() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 // Set up flow dependences from first and second loops to third. @@ -208,8 +208,8 @@ // Should fuse first and second loops into third. // Expecting private memref for '%a' first, then private memref for '%b'. - // CHECK-DAG: [[NEWA:%[0-9]+]] = alloc() : memref<1xf32> - // CHECK-DAG: [[NEWB:%[0-9]+]] = alloc() : memref<1xf32> + // CHECK-DAG: [[NEWA:%[0-9]+]] = memref.alloc() : memref<1xf32> + // CHECK-DAG: [[NEWB:%[0-9]+]] = memref.alloc() : memref<1xf32> // CHECK: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.store %{{.*}}, [[NEWA]][0] : memref<1xf32> // CHECK-NEXT: affine.store %{{.*}}, [[NEWB]][0] : memref<1xf32> @@ -224,9 +224,9 @@ // CHECK-LABEL: func @should_fuse_first_and_second_loops() { func @should_fuse_first_and_second_loops() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -260,9 +260,9 @@ // CHECK-LABEL: func @should_not_fuse_would_create_cycle() { func @should_not_fuse_would_create_cycle() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -303,7 +303,7 @@ // CHECK-LABEL: func @should_fuse_producer_consumer() { func @should_fuse_producer_consumer() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -319,7 +319,7 @@ // %i1, but OK to fuse %i1 into %i2. // TODO: When the fusion pass is run to a fixed-point, it should // fuse all three of these loop nests. - // CHECK: alloc() : memref<1xf32> + // CHECK: memref.alloc() : memref<1xf32> // CHECK: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32> // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32> @@ -333,8 +333,8 @@ // CHECK-LABEL: func @should_fuse_and_move_to_preserve_war_dep() { func @should_fuse_and_move_to_preserve_war_dep() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -366,7 +366,7 @@ // CHECK-LABEL: func @should_fuse_if_top_level_access() { func @should_fuse_if_top_level_access() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -380,7 +380,7 @@ %v1 = affine.load %m[%c0] : memref<10xf32> // Top-level load to '%m' should prevent creating a private memref but // loop nests should be fused and '%i0' should be removed. - // CHECK: %[[m:.*]] = alloc() : memref<10xf32> + // CHECK: %[[m:.*]] = memref.alloc() : memref<10xf32> // CHECK-NOT: alloc // CHECK: affine.for %[[i1:.*]] = 0 to 10 { @@ -395,7 +395,7 @@ // CHECK-LABEL: func @should_fuse_but_not_remove_src() { func @should_fuse_but_not_remove_src() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 100 { @@ -424,7 +424,7 @@ // CHECK-LABEL: func @should_fuse_no_top_level_access() { func @should_fuse_no_top_level_access() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -447,7 +447,7 @@ // CHECK-LABEL: func @should_not_fuse_if_inst_at_top_level() { func @should_not_fuse_if_inst_at_top_level() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -475,7 +475,7 @@ // CHECK-LABEL: func @should_not_fuse_if_inst_in_loop_nest() { func @should_not_fuse_if_inst_in_loop_nest() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %c4 = constant 4 : index @@ -504,7 +504,7 @@ // CHECK-LABEL: func @permute_and_fuse() { func @permute_and_fuse() { - %m = alloc() : memref<10x20x30xf32> + %m = memref.alloc() : memref<10x20x30xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -545,7 +545,7 @@ // Reshape from a 64 x f32 to 16 x 4 x f32. // CHECK-LABEL: func @fuse_reshape_64_16_4 func @fuse_reshape_64_16_4(%in : memref<64xf32>) { - %out = alloc() : memref<16x4xf32> + %out = memref.alloc() : memref<16x4xf32> affine.for %i0 = 0 to 64 { %v = affine.load %in[%i0] : memref<64xf32> @@ -575,8 +575,8 @@ // Reshape a 16x4xf32 to 64xf32. // CHECK-LABEL: func @fuse_reshape_16_4_64 func @fuse_reshape_16_4_64() { - %in = alloc() : memref<16x4xf32> - %out = alloc() : memref<64xf32> + %in = memref.alloc() : memref<16x4xf32> + %out = memref.alloc() : memref<64xf32> affine.for %i0 = 0 to 16 { affine.for %i1 = 0 to 4 { @@ -608,9 +608,9 @@ // All three loop nests below (6-d one, 2-d one, 2-d one is fused into a single // 2-d loop nest). func @R6_to_R2_reshape_square() -> memref<64x9xi32> { - %in = alloc() : memref<2x2x3x3x16x1xi32> - %out = alloc() : memref<64x9xi32> - %live_out = alloc() : memref<64x9xi32> + %in = memref.alloc() : memref<2x2x3x3x16x1xi32> + %out = memref.alloc() : memref<64x9xi32> + %live_out = memref.alloc() : memref<64x9xi32> // Initialize input. affine.for %i0 = 0 to 2 { @@ -670,9 +670,9 @@ // // CHECK-LABEL: func @R6_to_R2_reshape -// CHECK: alloc() : memref<1x2x3x3x16x1xi32> -// CHECK: alloc() : memref<1x1xi32> -// CHECK: alloc() : memref<64x9xi32> +// CHECK: memref.alloc() : memref<1x2x3x3x16x1xi32> +// CHECK: memref.alloc() : memref<1x1xi32> +// CHECK: memref.alloc() : memref<64x9xi32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 64 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 9 { // CHECK-NEXT: affine.apply [[$MAP0]](%{{.*}}, %{{.*}}) @@ -703,7 +703,7 @@ // CHECK-LABEL: func @fuse_symbolic_bounds func @fuse_symbolic_bounds(%M : index, %N : index) { %N_plus_5 = affine.apply affine_map<(d0) -> (d0 + 5)>(%N) - %m = alloc(%M, %N_plus_5) : memref + %m = memref.alloc(%M, %N_plus_5) : memref %c0 = constant 0.0 : f32 %s = constant 5 : index @@ -727,8 +727,8 @@ // CHECK-LABEL: func @should_fuse_reduction_at_depth_of_one func @should_fuse_reduction_at_depth_of_one() { - %a = alloc() : memref<10x100xf32> - %b = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10x100xf32> + %b = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 100 { @@ -772,8 +772,8 @@ // CHECK-LABEL: func @should_fuse_at_src_depth1_and_dst_depth1 func @should_fuse_at_src_depth1_and_dst_depth1() { - %a = alloc() : memref<100x16xf32> - %b = alloc() : memref<100x16xf32> + %a = memref.alloc() : memref<100x16xf32> + %b = memref.alloc() : memref<100x16xf32> affine.for %i0 = 0 to 100 { affine.for %i1 = 0 to 16 { @@ -820,7 +820,7 @@ // CHECK-LABEL: func @should_fuse_src_depth1_at_dst_depth2 func @should_fuse_src_depth1_at_dst_depth2() { - %a = alloc() : memref<100xf32> + %a = memref.alloc() : memref<100xf32> %c0 = constant 0.0 : f32 affine.for %i0 = 0 to 100 { @@ -851,7 +851,7 @@ // CHECK-LABEL: func @fusion_at_depth0_not_currently_supported func @fusion_at_depth0_not_currently_supported() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %c0 = constant 0 : index %cst = constant 0.000000e+00 : f32 affine.for %i0 = 0 to 10 { @@ -862,7 +862,7 @@ } // NOTE: Should shrink memref size to 1 element access by load in dst loop // nest, and make the store in the slice store to the same element. - // CHECK-DAG: alloc() : memref<1xf32> + // CHECK-DAG: memref.alloc() : memref<1xf32> // CHECK: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32> // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32> @@ -875,9 +875,9 @@ // CHECK-LABEL: func @should_fuse_deep_loop_nests func @should_fuse_deep_loop_nests() { - %0 = alloc() : memref<2x2x3x3x16x10xf32, 2> - %1 = alloc() : memref<2x2x3x3x16x10xf32, 2> - %2 = alloc() : memref<3x3x3x3x16x10xf32, 2> + %0 = memref.alloc() : memref<2x2x3x3x16x10xf32, 2> + %1 = memref.alloc() : memref<2x2x3x3x16x10xf32, 2> + %2 = memref.alloc() : memref<3x3x3x3x16x10xf32, 2> %c0 = constant 0 : index %c1 = constant 1 : index %c1_0 = constant 1 : index @@ -934,7 +934,7 @@ // bounds which are a function of the first four loops of destination loop nest, // where the destination loops nests have been interchanged. -// CHECK-DAG: alloc() : memref<1x1x1x1x16x10xf32, 2> +// CHECK-DAG: memref.alloc() : memref<1x1x1x1x16x10xf32, 2> // CHECK: affine.for %{{.*}} = 0 to 3 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 3 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 2 { @@ -979,8 +979,8 @@ // CHECK-LABEL: func @should_fuse_at_depth1_and_reduce_slice_trip_count func @should_fuse_at_depth1_and_reduce_slice_trip_count() { - %a = alloc() : memref<4x256xf32> - %b = alloc() : memref<4x256xf32> + %a = memref.alloc() : memref<4x256xf32> + %b = memref.alloc() : memref<4x256xf32> %c0 = constant 0 : index %cf0 = constant 0.0 : f32 @@ -1008,7 +1008,7 @@ // NOTE: the size of the private memref created for the fused loop nest // is reduced from the original shape from 4x256 to 4x16 because of the // data accessed by the load. - // CHECK-DAG: alloc() : memref<1x16xf32> + // CHECK-DAG: memref.alloc() : memref<1x16xf32> // CHECK: affine.for %{{.*}} = 0 to 4 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 256 { // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref<4x256xf32> @@ -1028,7 +1028,7 @@ // CHECK-LABEL: func @should_fuse_at_depth1_with_trip_count_20 func @should_fuse_at_depth1_with_trip_count_20() { - %a = alloc() : memref<100xf32> + %a = memref.alloc() : memref<100xf32> %c0 = constant 0 : index %cf0 = constant 0.0 : f32 @@ -1047,7 +1047,7 @@ } } // NOTE: The size of the private memref created for fusion is shrunk to 20xf32 - // CHECK-DAG: alloc() : memref<20xf32> + // CHECK-DAG: memref.alloc() : memref<20xf32> // CHECK: affine.for %{{.*}} = 0 to 5 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 20 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<20xf32> @@ -1069,7 +1069,7 @@ // CHECK-LABEL: func @should_fuse_at_depth1_with_trip_count_19 func @should_fuse_at_depth1_with_trip_count_19() { - %a = alloc() : memref<100xf32> + %a = memref.alloc() : memref<100xf32> %c0 = constant 0 : index %cf0 = constant 0.0 : f32 @@ -1088,7 +1088,7 @@ } } // NOTE: The size of the private memref created for fusion is shrunk to 19xf32 - // CHECK-DAG: alloc() : memref<19xf32> + // CHECK-DAG: memref.alloc() : memref<19xf32> // CHECK: affine.for %{{.*}} = 0 to 5 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 19 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<19xf32> @@ -1111,7 +1111,7 @@ // CHECK-LABEL: func @should_fuse_with_private_memrefs_with_diff_shapes() { func @should_fuse_with_private_memrefs_with_diff_shapes() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 100 { @@ -1125,8 +1125,8 @@ } // Should create two new private memrefs customized to the shapes accessed // by loops %{{.*}} and %{{.*}}. - // CHECK-DAG: alloc() : memref<1xf32> - // CHECK-DAG: alloc() : memref<1xf32> + // CHECK-DAG: memref.alloc() : memref<1xf32> + // CHECK-DAG: memref.alloc() : memref<1xf32> // CHECK: affine.for %{{.*}} = 0 to 17 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[0] : memref<1xf32> // CHECK-NEXT: affine.load %{{.*}}[0] : memref<1xf32> @@ -1195,7 +1195,7 @@ // CHECK-LABEL: func @should_fuse_escaping_memref_but_preserve_src_loop() -> memref<10xf32> func @should_fuse_escaping_memref_but_preserve_src_loop() -> memref<10xf32> { %cf7 = constant 7.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> } @@ -1206,7 +1206,7 @@ // because it writes to memref '%m', which is returned by the function, and // the '%i1' memory region does not cover '%i0' memory region. - // CHECK-DAG: alloc() : memref<10xf32> + // CHECK-DAG: memref.alloc() : memref<10xf32> // CHECK: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32> // CHECK-NEXT: } @@ -1221,7 +1221,7 @@ // This should fuse with the %in becoming a 1x1x1. func @R3_to_R2_reshape() { - %in = alloc() : memref<2x3x16xi32> + %in = memref.alloc() : memref<2x3x16xi32> %c0 = constant 0 : index @@ -1249,7 +1249,7 @@ // CHECK-DAG: [[$MAP2:#map[0-9]+]] = affine_map<(d0) -> (d0 floordiv 48)> // CHECK-LABEL: func @R3_to_R2_reshape() -// CHECK-DAG: alloc() : memref<1x1x1xi32> +// CHECK-DAG: memref.alloc() : memref<1x1x1xi32> // CHECK: affine.for %{{.*}} = 0 to 32 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 3 { // CHECK-NEXT: affine.apply [[$MAP0]](%{{.*}}, %{{.*}}) @@ -1265,8 +1265,8 @@ // ----- func @should_fuse_multi_output_producer() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -1293,9 +1293,9 @@ // CHECK-LABEL: func @fusion_preventing_deps_on_middle_loop() { func @fusion_preventing_deps_on_middle_loop() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -1334,9 +1334,9 @@ // CHECK-LABEL: func @should_fuse_and_move_to_preserve_war_dep() { func @should_fuse_and_move_to_preserve_war_dep() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -1368,7 +1368,7 @@ // It is possible to fuse loop '%i0' into '%i3' and preserve dependences // if the fused loop nest is inserted between loops '%i1' and '%i2'. - // CHECK-DAG: alloc() : memref<1xf32> + // CHECK-DAG: memref.alloc() : memref<1xf32> // CHECK: affine.for %{{.*}} = 0 to 3 { // CHECK-NEXT: affine.load %{{.*}}[%{{.*}}] : memref<10xf32> // CHECK-NEXT: } @@ -1389,9 +1389,9 @@ // CHECK-LABEL: func @fusion_preventing_dep_on_constant() { func @fusion_preventing_dep_on_constant() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -1430,9 +1430,9 @@ // CHECK-LABEL: func @should_fuse_and_preserve_dep_on_constant() { func @should_fuse_and_preserve_dep_on_constant() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf11 = constant 11.0 : f32 @@ -1470,7 +1470,7 @@ // CHECK-LABEL: func @should_fuse_at_depth_above_loop_carried_dependence(%{{.*}}: memref<64x4xf32>, %{{.*}}: memref<64x4xf32>) { func @should_fuse_at_depth_above_loop_carried_dependence(%arg0: memref<64x4xf32>, %arg1: memref<64x4xf32>) { - %out = alloc() : memref<64x4xf32> + %out = memref.alloc() : memref<64x4xf32> %0 = constant 0.0 : f32 affine.for %i0 = 0 to 64 { affine.for %i1 = 0 to 4 { @@ -1506,7 +1506,7 @@ // loop nest iteration bounds on its loop '%i1' are reduced to 1, so the // memref size can be reduced to 128x1xf32. - // CHECK: alloc() : memref<64x1xf32> + // CHECK: memref.alloc() : memref<64x1xf32> // CHECK: affine.for %{{.*}} = 0 to 4 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 64 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}, 0] : memref<64x1xf32> @@ -1538,8 +1538,8 @@ // CHECK-LABEL: func @should_fuse_only_two_loops_and_remove_producer() { func @should_fuse_only_two_loops_and_remove_producer() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 @@ -1582,7 +1582,7 @@ // CHECK-LABEL: func @should_fuse_after_one_loop_interchange() { func @should_fuse_after_one_loop_interchange() { - %a = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> %cf0 = constant 0.0 : f32 affine.for %i0 = 0 to 10 { @@ -1617,7 +1617,7 @@ // CHECK-LABEL: func @should_fuse_after_two_loop_interchanges() { func @should_fuse_after_two_loop_interchanges() { - %a = alloc() : memref<6x8xf32> + %a = memref.alloc() : memref<6x8xf32> %cf0 = constant 0.0 : f32 affine.for %i0 = 0 to 6 { @@ -1739,8 +1739,8 @@ // Test case which illustrates fix for b/126454413 func @test_add_slice_bounds() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %c0 = constant 0 : index @@ -1785,7 +1785,7 @@ // ----- func @should_fuse_init_loops_siblings_then_shared_producer(%arg0: memref<10x10xf32>, %arg1: memref<10x10xf32>) { - %0 = alloc() : memref<10x10xf32> + %0 = memref.alloc() : memref<10x10xf32> %cst = constant 0.000000e+00 : f32 %cst_0 = constant 1.000000e+00 : f32 %cst_1 = constant 7.000000e+00 : f32 @@ -1852,11 +1852,11 @@ // ----- func @two_matrix_vector_products() { - %in_matrix = alloc() : memref<10x10xf32> - %in_vec0 = alloc() : memref<10xf32> - %in_vec1 = alloc() : memref<10xf32> - %out_vec0 = alloc() : memref<10xf32> - %out_vec1 = alloc() : memref<10xf32> + %in_matrix = memref.alloc() : memref<10x10xf32> + %in_vec0 = memref.alloc() : memref<10xf32> + %in_vec1 = memref.alloc() : memref<10xf32> + %out_vec0 = memref.alloc() : memref<10xf32> + %out_vec1 = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 // Populate input matrix. @@ -1916,7 +1916,7 @@ // ----- func @should_not_slice_past_slice_barrier() { - %0 = alloc() : memref<100x16xf32> + %0 = memref.alloc() : memref<100x16xf32> affine.for %i0 = 0 to 100 { affine.for %i1 = 0 to 16 { %1 = "op1"() : () -> f32 @@ -1948,7 +1948,7 @@ #map0 = affine_map<(d0, d1) -> (d0 * 16 + d1)> func @fuse_across_dim_mismatch(%arg0: memref<4x4x16x1xf32>, %arg1: memref<144x9xf32>, %arg2: memref<9xf32>) { - %1 = alloc() : memref<144x4xf32> + %1 = memref.alloc() : memref<144x4xf32> %2 = constant 0.0 : f32 affine.for %i2 = 0 to 9 { affine.for %i3 = 0 to 4 { @@ -1972,7 +1972,7 @@ } // MAXIMAL: #map = affine_map<(d0, d1) -> (d0 * 16 + d1)> // MAXIMAL-LABEL: func @fuse_across_dim_mismatch -// MAXIMAL: alloc() : memref<1x1xf32> +// MAXIMAL: memref.alloc() : memref<1x1xf32> // MAXIMAL: affine.for %{{.*}} = 0 to 9 { // MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 9 { // MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 4 { @@ -1998,9 +1998,9 @@ #map12 = affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)> func @fuse_across_varying_dims_complex(%arg0: f32) { %c0 = constant 0 : index - %0 = alloc() : memref<2x2x3x3x16x1xf32> - %1 = alloc() : memref<64x9xf32> - %2 = alloc() : memref<144x4xf32> + %0 = memref.alloc() : memref<2x2x3x3x16x1xf32> + %1 = memref.alloc() : memref<64x9xf32> + %2 = memref.alloc() : memref<144x4xf32> affine.for %i0 = 0 to 64 { affine.for %i1 = 0 to 9 { %4 = affine.apply #map3(%i0, %i1) @@ -2044,10 +2044,10 @@ // MAXIMAL-DAG: [[$MAP7:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 + d1)> // MAXIMAL-DAG: [[$MAP8:#map[0-9]+]] = affine_map<(d0, d1) -> (d0 * 16 - d1 + 15)> // MAXIMAL-LABEL: func @fuse_across_varying_dims_complex -// MAXIMAL-NEXT: alloc() : memref<64x1xf32> +// MAXIMAL-NEXT: memref.alloc() : memref<64x1xf32> // MAXIMAL-NEXT: constant 0 : index -// MAXIMAL-NEXT: alloc() : memref<2x2x3x3x16x1xf32> -// MAXIMAL-NEXT: alloc() : memref<144x4xf32> +// MAXIMAL-NEXT: memref.alloc() : memref<2x2x3x3x16x1xf32> +// MAXIMAL-NEXT: memref.alloc() : memref<144x4xf32> // MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 9 { // MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 9 { // MAXIMAL-NEXT: affine.for %{{.*}} = 0 to 4 { @@ -2081,7 +2081,7 @@ // ----- func @should_fuse_with_slice_union() { - %a = alloc() : memref<100xf32> + %a = memref.alloc() : memref<100xf32> %c0 = constant 0 : index %cf0 = constant 0.0 : f32 @@ -2284,8 +2284,8 @@ // CHECK-LABEL: func @should_fuse_self_dependence_multi_store_producer() { func @should_fuse_self_dependence_multi_store_producer() { - %m = alloc() : memref<10xf32> - %local_m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> + %local_m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -2310,8 +2310,8 @@ // CHECK-LABEL: func @should_fuse_dead_multi_store_producer() { func @should_fuse_dead_multi_store_producer() { - %m = alloc() : memref<10xf32> - %dead_m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> + %dead_m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -2334,7 +2334,7 @@ // CHECK-LABEL: func @should_fuse_function_live_out_multi_store_producer func @should_fuse_function_live_out_multi_store_producer(%live_in_out_m : memref<10xf32>) { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -2359,7 +2359,7 @@ // CHECK-LABEL: func @mul_add_0 func @mul_add_0(%arg0: memref<3x4xf32>, %arg1: memref<4x3xf32>, %arg2: memref<3x3xf32>, %arg3: memref<3x3xf32>) { %cst = constant 0.000000e+00 : f32 - %0 = alloc() : memref<3x3xf32> + %0 = memref.alloc() : memref<3x3xf32> affine.for %arg4 = 0 to 3 { affine.for %arg5 = 0 to 3 { affine.store %cst, %0[%arg4, %arg5] : memref<3x3xf32> @@ -2468,7 +2468,7 @@ // MAXIMAL-LABEL: func @reshape_into_matmul func @reshape_into_matmul(%lhs : memref<1024x1024xf32>, %R: memref<16x64x1024xf32>, %out: memref<1024x1024xf32>) { - %rhs = alloc() : memref<1024x1024xf32> + %rhs = memref.alloc() : memref<1024x1024xf32> // Reshape from 3-d to 2-d. affine.for %i0 = 0 to 16 { @@ -2495,7 +2495,7 @@ } return } -// MAXIMAL-NEXT: alloc +// MAXIMAL-NEXT: memref.alloc // MAXIMAL-NEXT: affine.for // MAXIMAL-NEXT: affine.for // MAXIMAL-NEXT: affine.for @@ -2580,7 +2580,7 @@ // CHECK-LABEL: func @calc func @calc(%arg0: memref, %arg1: memref, %arg2: memref, %len: index) { %c1 = constant 1 : index - %1 = alloc(%len) : memref + %1 = memref.alloc(%len) : memref affine.for %arg4 = 1 to 10 { %7 = affine.load %arg0[%arg4] : memref %8 = affine.load %arg1[%arg4] : memref @@ -2595,7 +2595,7 @@ } return } -// CHECK: alloc() : memref<1xf32> +// CHECK: memref.alloc() : memref<1xf32> // CHECK: affine.for %arg{{.*}} = 1 to 10 { // CHECK-NEXT: affine.load %arg{{.*}} // CHECK-NEXT: affine.load %arg{{.*}} @@ -2623,7 +2623,7 @@ %lhs = load %in0[%d] : memref<32xf32> %rhs = load %in1[%d] : memref<32xf32> %add = subf %lhs, %rhs : f32 - store %add, %in0[%d] : memref<32xf32> + memref.store %add, %in0[%d] : memref<32xf32> } affine.for %d = 0 to 32 { %lhs = affine.load %in0[%d] : memref<32xf32> @@ -2646,12 +2646,12 @@ // CHECK-LABEL: func @should_not_fuse_since_top_level_non_affine_users func @should_not_fuse_since_top_level_non_affine_users(%in0 : memref<32xf32>, %in1 : memref<32xf32>) { - %sum = alloc() : memref + %sum = memref.alloc() : memref affine.for %d = 0 to 32 { %lhs = affine.load %in0[%d] : memref<32xf32> %rhs = affine.load %in1[%d] : memref<32xf32> %add = addf %lhs, %rhs : f32 - store %add, %sum[] : memref + memref.store %add, %sum[] : memref affine.store %add, %in0[%d] : memref<32xf32> } %load_sum = load %sum[] : memref @@ -2662,7 +2662,7 @@ %sub = subf %add, %load_sum: f32 affine.store %sub, %in0[%d] : memref<32xf32> } - dealloc %sum : memref + memref.dealloc %sum : memref return } @@ -2686,7 +2686,7 @@ %add = addf %lhs, %rhs : f32 affine.store %add, %in0[%d] : memref<32xf32> } - store %cst_0, %in0[%c0] : memref<32xf32> + memref.store %cst_0, %in0[%c0] : memref<32xf32> affine.for %d = 0 to 32 { %lhs = affine.load %in0[%d] : memref<32xf32> %rhs = affine.load %in1[%d] : memref<32xf32> @@ -2705,7 +2705,7 @@ // MAXIMAL-LABEL: func @fuse_minor_affine_map func @fuse_minor_affine_map(%in: memref<128xf32>, %out: memref<20x512xf32>) { - %tmp = alloc() : memref<128xf32> + %tmp = memref.alloc() : memref<128xf32> affine.for %arg4 = 0 to 128 { %ld = affine.load %in[%arg4] : memref<128xf32> @@ -2725,7 +2725,7 @@ // TODO: The size of the private memref is not properly computed in the presence // of the 'mod' operation. It should be memref<1xf32> instead of // memref<128xf32>: https://bugs.llvm.org/show_bug.cgi?id=46973 -// MAXIMAL: alloc() : memref<128xf32> +// MAXIMAL: memref.alloc() : memref<128xf32> // MAXIMAL: affine.for // MAXIMAL-NEXT: affine.for // MAXIMAL-NOT: affine.for @@ -2735,9 +2735,9 @@ // CHECK-LABEL: func @should_fuse_multi_store_producer_and_privatize_memfefs func @should_fuse_multi_store_producer_and_privatize_memfefs() { - %a = alloc() : memref<10xf32> - %b = alloc() : memref<10xf32> - %c = alloc() : memref<10xf32> + %a = memref.alloc() : memref<10xf32> + %b = memref.alloc() : memref<10xf32> + %c = memref.alloc() : memref<10xf32> %cst = constant 0.000000e+00 : f32 affine.for %arg0 = 0 to 10 { affine.store %cst, %a[%arg0] : memref<10xf32> diff --git a/mlir/test/Transforms/loop-invariant-code-motion.mlir b/mlir/test/Transforms/loop-invariant-code-motion.mlir --- a/mlir/test/Transforms/loop-invariant-code-motion.mlir +++ b/mlir/test/Transforms/loop-invariant-code-motion.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -split-input-file -loop-invariant-code-motion | FileCheck %s func @nested_loops_both_having_invariant_code() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -13,7 +13,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %[[CST0:.*]] = constant 7.000000e+00 : f32 // CHECK-NEXT: %[[CST1:.*]] = constant 8.000000e+00 : f32 // CHECK-NEXT: %[[ADD0:.*]] = addf %[[CST0]], %[[CST1]] : f32 @@ -28,7 +28,7 @@ // ----- func @nested_loops_code_invariant_to_both() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 @@ -38,7 +38,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -49,8 +49,8 @@ // ----- func @single_loop_nothing_invariant() { - %m1 = alloc() : memref<10xf32> - %m2 = alloc() : memref<10xf32> + %m1 = memref.alloc() : memref<10xf32> + %m2 = memref.alloc() : memref<10xf32> affine.for %arg0 = 0 to 10 { %v0 = affine.load %m1[%arg0] : memref<10xf32> %v1 = affine.load %m2[%arg0] : memref<10xf32> @@ -58,8 +58,8 @@ affine.store %v2, %m1[%arg0] : memref<10xf32> } - // CHECK: %0 = alloc() : memref<10xf32> - // CHECK-NEXT: %1 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> + // CHECK-NEXT: %1 = memref.alloc() : memref<10xf32> // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: %2 = affine.load %0[%arg0] : memref<10xf32> // CHECK-NEXT: %3 = affine.load %1[%arg0] : memref<10xf32> @@ -72,7 +72,7 @@ // ----- func @invariant_code_inside_affine_if() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { @@ -84,7 +84,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %arg0 = 0 to 10 { // CHECK-NEXT: %1 = affine.apply #map(%arg0) @@ -100,7 +100,7 @@ // ----- func @invariant_affine_if() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -110,7 +110,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %[[CST:.*]] = constant 8.000000e+00 : f32 // CHECK-NEXT: affine.for %[[ARG:.*]] = 0 to 10 { // CHECK-NEXT: } @@ -125,7 +125,7 @@ // ----- func @invariant_affine_if2() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -136,7 +136,7 @@ } } - // CHECK: alloc + // CHECK: memref.alloc // CHECK-NEXT: constant // CHECK-NEXT: affine.for // CHECK-NEXT: affine.for @@ -152,7 +152,7 @@ // ----- func @invariant_affine_nested_if() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -165,7 +165,7 @@ } } - // CHECK: alloc + // CHECK: memref.alloc // CHECK-NEXT: constant // CHECK-NEXT: affine.for // CHECK-NEXT: affine.for @@ -184,7 +184,7 @@ // ----- func @invariant_affine_nested_if_else() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf8 = constant 8.0 : f32 affine.for %arg0 = 0 to 10 { affine.for %arg1 = 0 to 10 { @@ -200,7 +200,7 @@ } } - // CHECK: alloc + // CHECK: memref.alloc // CHECK-NEXT: constant // CHECK-NEXT: affine.for // CHECK-NEXT: affine.for @@ -225,7 +225,7 @@ %ci0 = constant 0 : index %ci10 = constant 10 : index %ci1 = constant 1 : index - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 scf.for %arg0 = %ci0 to %ci10 step %ci1 { @@ -234,7 +234,7 @@ } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: %cst = constant 7.000000e+00 : f32 // CHECK-NEXT: %cst_0 = constant 8.000000e+00 : f32 // CHECK-NEXT: %1 = addf %cst, %cst_0 : f32 @@ -248,14 +248,14 @@ %ci0 = constant 0 : index %ci10 = constant 10 : index %ci1 = constant 1 : index - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> scf.for %arg0 = %ci0 to %ci10 step %ci1 { scf.for %arg1 = %ci0 to %ci10 step %ci1 { %v0 = addi %arg0, %arg1 : index } } - // CHECK: %0 = alloc() : memref<10xf32> + // CHECK: %0 = memref.alloc() : memref<10xf32> // CHECK-NEXT: scf.for // CHECK-NEXT: scf.for // CHECK-NEXT: addi diff --git a/mlir/test/Transforms/memref-bound-check.mlir b/mlir/test/Transforms/memref-bound-check.mlir --- a/mlir/test/Transforms/memref-bound-check.mlir +++ b/mlir/test/Transforms/memref-bound-check.mlir @@ -8,8 +8,8 @@ %minusone = constant -1 : index %sym = constant 111 : index - %A = alloc() : memref<9 x 9 x i32> - %B = alloc() : memref<111 x i32> + %A = memref.alloc() : memref<9 x 9 x i32> + %B = memref.alloc() : memref<111 x i32> affine.for %i = -1 to 10 { affine.for %j = -1 to 10 { @@ -41,7 +41,7 @@ // CHECK-LABEL: func @test_mod_floordiv_ceildiv func @test_mod_floordiv_ceildiv() { %zero = constant 0 : index - %A = alloc() : memref<128 x 64 x 64 x i32> + %A = memref.alloc() : memref<128 x 64 x 64 x i32> affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { @@ -64,9 +64,9 @@ // CHECK-LABEL: func @test_no_out_of_bounds() func @test_no_out_of_bounds() { %zero = constant 0 : index - %A = alloc() : memref<257 x 256 x i32> - %C = alloc() : memref<257 x i32> - %B = alloc() : memref<1 x i32> + %A = memref.alloc() : memref<257 x 256 x i32> + %C = memref.alloc() : memref<257 x i32> + %B = memref.alloc() : memref<1 x i32> affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { @@ -90,7 +90,7 @@ // CHECK-LABEL: func @mod_div func @mod_div() { %zero = constant 0 : index - %A = alloc() : memref<128 x 64 x 64 x i32> + %A = memref.alloc() : memref<128 x 64 x 64 x i32> affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { @@ -113,7 +113,7 @@ // Tests with nested mod's and floordiv's. // CHECK-LABEL: func @mod_floordiv_nested() { func @mod_floordiv_nested() { - %A = alloc() : memref<256 x 256 x i32> + %A = memref.alloc() : memref<256 x 256 x i32> affine.for %i = 0 to 256 { affine.for %j = 0 to 256 { %idx0 = affine.apply affine_map<(d0, d1) -> ((d0 mod 1024) floordiv 4)>(%i, %j) @@ -126,7 +126,7 @@ // CHECK-LABEL: func @test_semi_affine_bailout func @test_semi_affine_bailout(%N : index) { - %B = alloc() : memref<10 x i32> + %B = memref.alloc() : memref<10 x i32> affine.for %i = 0 to 10 { %idx = affine.apply affine_map<(d0)[s0] -> (d0 * s0)>(%i)[%N] %y = affine.load %B[%idx] : memref<10 x i32> @@ -137,7 +137,7 @@ // CHECK-LABEL: func @multi_mod_floordiv func @multi_mod_floordiv() { - %A = alloc() : memref<2x2xi32> + %A = memref.alloc() : memref<2x2xi32> affine.for %ii = 0 to 64 { %idx0 = affine.apply affine_map<(d0) -> ((d0 mod 147456) floordiv 1152)> (%ii) %idx1 = affine.apply affine_map<(d0) -> (((d0 mod 147456) mod 1152) floordiv 384)> (%ii) @@ -149,8 +149,8 @@ // CHECK-LABEL: func @delinearize_mod_floordiv func @delinearize_mod_floordiv() { %c0 = constant 0 : index - %in = alloc() : memref<2x2x3x3x16x1xi32> - %out = alloc() : memref<64x9xi32> + %in = memref.alloc() : memref<2x2x3x3x16x1xi32> + %out = memref.alloc() : memref<64x9xi32> // Reshape '%in' into '%out'. affine.for %ii = 0 to 64 { @@ -186,7 +186,7 @@ // CHECK-LABEL: func @out_of_bounds func @out_of_bounds() { - %in = alloc() : memref<1xi32> + %in = memref.alloc() : memref<1xi32> %c9 = constant 9 : i32 affine.for %i0 = 10 to 11 { @@ -208,7 +208,7 @@ // CHECK-LABEL: func @test_complex_mod_floordiv func @test_complex_mod_floordiv(%arg0: memref<4x4x16x1xf32>) { %c0 = constant 0 : index - %0 = alloc() : memref<1x2x3x3x16x1xf32> + %0 = memref.alloc() : memref<1x2x3x3x16x1xf32> affine.for %i0 = 0 to 64 { affine.for %i1 = 0 to 9 { %2 = affine.apply #map3(%i0, %i1) @@ -228,8 +228,8 @@ // CHECK-LABEL: func @test_mod_bound func @test_mod_bound() { - %0 = alloc() : memref<7 x f32> - %1 = alloc() : memref<6 x f32> + %0 = memref.alloc() : memref<7 x f32> + %1 = memref.alloc() : memref<6 x f32> affine.for %i0 = 0 to 4096 { affine.for %i1 = #map0(%i0) to #map1(%i0) { affine.load %0[%i1] : memref<7 x f32> @@ -248,9 +248,9 @@ // CHECK-LABEL: func @test_floordiv_bound func @test_floordiv_bound() { - %0 = alloc() : memref<1027 x f32> - %1 = alloc() : memref<1026 x f32> - %2 = alloc() : memref<4096 x f32> + %0 = memref.alloc() : memref<1027 x f32> + %1 = memref.alloc() : memref<1026 x f32> + %2 = memref.alloc() : memref<4096 x f32> %N = constant 2048 : index affine.for %i0 = 0 to 4096 { affine.for %i1 = #map0(%i0) to #map1(%i0) { @@ -287,7 +287,7 @@ // CHECK-LABEL: func @zero_d_memref func @zero_d_memref() { - %Z = alloc() : memref + %Z = memref.alloc() : memref affine.for %i = 0 to 100 { affine.load %Z[] : memref } diff --git a/mlir/test/Transforms/memref-dataflow-opt.mlir b/mlir/test/Transforms/memref-dataflow-opt.mlir --- a/mlir/test/Transforms/memref-dataflow-opt.mlir +++ b/mlir/test/Transforms/memref-dataflow-opt.mlir @@ -9,7 +9,7 @@ // CHECK-LABEL: func @simple_store_load() { func @simple_store_load() { %cf7 = constant 7.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> %v0 = affine.load %m[%i0] : memref<10xf32> @@ -29,7 +29,7 @@ %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 %cf9 = constant 9.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> %v0 = affine.load %m[%i0] : memref<10xf32> @@ -58,7 +58,7 @@ // CHECK-LABEL: func @store_load_affine_apply func @store_load_affine_apply() -> memref<10x10xf32> { %cf7 = constant 7.0 : f32 - %m = alloc() : memref<10x10xf32> + %m = memref.alloc() : memref<10x10xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { %t0 = affine.apply affine_map<(d0, d1) -> (d1 + 1)>(%i0, %i1) @@ -74,7 +74,7 @@ // The memref and its stores won't be erased due to this memref return. return %m : memref<10x10xf32> // CHECK: %{{.*}} = constant 7.000000e+00 : f32 -// CHECK-NEXT: %{{.*}} = alloc() : memref<10x10xf32> +// CHECK-NEXT: %{{.*}} = memref.alloc() : memref<10x10xf32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: %{{.*}} = affine.apply [[$MAP0]](%{{.*}}, %{{.*}}) @@ -91,7 +91,7 @@ // CHECK-LABEL: func @store_load_nested func @store_load_nested(%N : index) { %cf7 = constant 7.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> affine.for %i1 = 0 to %N { @@ -116,7 +116,7 @@ func @multi_store_load_nested_no_fwd(%N : index) { %cf7 = constant 7.0 : f32 %cf8 = constant 8.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> affine.for %i1 = 0 to %N { @@ -137,7 +137,7 @@ func @store_load_store_nested_no_fwd(%N : index) { %cf7 = constant 7.0 : f32 %cf9 = constant 9.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> affine.for %i1 = 0 to %N { @@ -158,7 +158,7 @@ %cf8 = constant 8.0 : f32 %cf9 = constant 9.0 : f32 %cf10 = constant 10.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> affine.for %i1 = 0 to %N { @@ -181,7 +181,7 @@ // CHECK-LABEL: func @store_load_no_fwd func @store_load_no_fwd() { %cf7 = constant 7.0 : f32 - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> affine.for %i1 = 0 to 10 { @@ -200,7 +200,7 @@ func @store_load_fwd() { %cf7 = constant 7.0 : f32 %c0 = constant 0 : index - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.store %cf7, %m[%c0] : memref<10xf32> affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { @@ -222,7 +222,7 @@ %cf9 = constant 9.0 : f32 %c0 = constant 0 : index %c1 = constant 1 : index - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> affine.for %i0 = 0 to 10 { affine.store %cf7, %m[%i0] : memref<10xf32> affine.for %i1 = 0 to %N { @@ -235,7 +235,7 @@ // Due to this load, the memref isn't optimized away. %v3 = affine.load %m[%c1] : memref<10xf32> return %v3 : f32 -// CHECK: %{{.*}} = alloc() : memref<10xf32> +// CHECK: %{{.*}} = memref.alloc() : memref<10xf32> // CHECK-NEXT: affine.for %{{.*}} = 0 to 10 { // CHECK-NEXT: affine.store %{{.*}}, %{{.*}}[%{{.*}}] : memref<10xf32> // CHECK-NEXT: affine.for %{{.*}} = 0 to %{{.*}} { @@ -285,7 +285,7 @@ // The value loaded from %in can directly be stored to %out by eliminating // store and load from %tmp. func @vector_forwarding(%in : memref<512xf32>, %out : memref<512xf32>) { - %tmp = alloc() : memref<512xf32> + %tmp = memref.alloc() : memref<512xf32> affine.for %i = 0 to 16 { %ld0 = affine.vector_load %in[32*%i] : memref<512xf32>, vector<32xf32> affine.vector_store %ld0, %tmp[32*%i] : memref<512xf32>, vector<32xf32> diff --git a/mlir/test/Transforms/memref-dependence-check.mlir b/mlir/test/Transforms/memref-dependence-check.mlir --- a/mlir/test/Transforms/memref-dependence-check.mlir +++ b/mlir/test/Transforms/memref-dependence-check.mlir @@ -6,7 +6,7 @@ // CHECK-LABEL: func @store_may_execute_before_load() { func @store_may_execute_before_load() { - %m = alloc() : memref<10xf32> + %m = memref.alloc() : memref<10xf32> %cf7 = constant 7.0 : f32 %c0 = constant 4 : index // There is no dependence from store 0 to load 1 at depth if we take into account @@ -33,7 +33,7 @@ // CHECK-LABEL: func @dependent_loops() { func @dependent_loops() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %cst = constant 7.000000e+00 : f32 // There is a dependence from 0 to 1 at depth 1 (common surrounding loops 0) // because the first loop with the store dominates the second scf. @@ -55,8 +55,8 @@ // ----- // CHECK-LABEL: func @different_memrefs() { func @different_memrefs() { - %m.a = alloc() : memref<100xf32> - %m.b = alloc() : memref<100xf32> + %m.a = memref.alloc() : memref<100xf32> + %m.b = memref.alloc() : memref<100xf32> %c0 = constant 0 : index %c1 = constant 1.0 : f32 affine.store %c1, %m.a[%c0] : memref<100xf32> @@ -71,7 +71,7 @@ // ----- // CHECK-LABEL: func @store_load_different_elements() { func @store_load_different_elements() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c0 = constant 0 : index %c1 = constant 1 : index %c7 = constant 7.0 : f32 @@ -87,7 +87,7 @@ // ----- // CHECK-LABEL: func @load_store_different_elements() { func @load_store_different_elements() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c0 = constant 0 : index %c1 = constant 1 : index %c7 = constant 7.0 : f32 @@ -103,7 +103,7 @@ // ----- // CHECK-LABEL: func @store_load_same_element() { func @store_load_same_element() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c11 = constant 11 : index %c7 = constant 7.0 : f32 affine.store %c7, %m[%c11] : memref<100xf32> @@ -118,7 +118,7 @@ // ----- // CHECK-LABEL: func @load_load_same_element() { func @load_load_same_element() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c11 = constant 11 : index %c7 = constant 7.0 : f32 %v0 = affine.load %m[%c11] : memref<100xf32> @@ -133,7 +133,7 @@ // ----- // CHECK-LABEL: func @store_load_same_symbol(%arg0: index) { func @store_load_same_symbol(%arg0: index) { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.store %c7, %m[%arg0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} @@ -147,7 +147,7 @@ // ----- // CHECK-LABEL: func @store_load_different_symbols(%arg0: index, %arg1: index) { func @store_load_different_symbols(%arg0: index, %arg1: index) { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.store %c7, %m[%arg0] : memref<100xf32> // expected-remark@above {{dependence from 0 to 0 at depth 1 = false}} @@ -161,7 +161,7 @@ // ----- // CHECK-LABEL: func @store_load_diff_element_affine_apply_const() { func @store_load_diff_element_affine_apply_const() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c1 = constant 1 : index %c8 = constant 8.0 : f32 %a0 = affine.apply affine_map<(d0) -> (d0)> (%c1) @@ -178,7 +178,7 @@ // ----- // CHECK-LABEL: func @store_load_same_element_affine_apply_const() { func @store_load_same_element_affine_apply_const() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %c9 = constant 9 : index %c11 = constant 11 : index @@ -196,7 +196,7 @@ // ----- // CHECK-LABEL: func @store_load_affine_apply_symbol(%arg0: index) { func @store_load_affine_apply_symbol(%arg0: index) { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %a0 = affine.apply affine_map<(d0) -> (d0)> (%arg0) affine.store %c7, %m[%a0] : memref<100xf32> @@ -212,7 +212,7 @@ // ----- // CHECK-LABEL: func @store_load_affine_apply_symbol_offset(%arg0: index) { func @store_load_affine_apply_symbol_offset(%arg0: index) { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %a0 = affine.apply affine_map<(d0) -> (d0)> (%arg0) affine.store %c7, %m[%a0] : memref<100xf32> @@ -228,7 +228,7 @@ // ----- // CHECK-LABEL: func @store_range_load_after_range() { func @store_range_load_after_range() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %c10 = constant 10 : index affine.for %i0 = 0 to 10 { @@ -251,7 +251,7 @@ // ----- // CHECK-LABEL: func @store_load_func_symbol(%arg0: index, %arg1: index) { func @store_load_func_symbol(%arg0: index, %arg1: index) { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %c10 = constant 10 : index affine.for %i0 = 0 to %arg1 { @@ -274,7 +274,7 @@ // ----- // CHECK-LABEL: func @store_range_load_last_in_range() { func @store_range_load_last_in_range() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %c10 = constant 10 : index affine.for %i0 = 0 to 10 { @@ -302,7 +302,7 @@ // ----- // CHECK-LABEL: func @store_range_load_before_range() { func @store_range_load_before_range() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %c0 = constant 0 : index affine.for %i0 = 1 to 11 { @@ -325,7 +325,7 @@ // ----- // CHECK-LABEL: func @store_range_load_first_in_range() { func @store_range_load_first_in_range() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 %c0 = constant 0 : index affine.for %i0 = 1 to 11 { @@ -351,7 +351,7 @@ // ----- // CHECK-LABEL: func @store_plus_3() { func @store_plus_3() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 1 to 11 { %a0 = affine.apply affine_map<(d0) -> (d0 + 3)> (%i0) @@ -373,7 +373,7 @@ // ----- // CHECK-LABEL: func @load_minus_2() { func @load_minus_2() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 2 to 11 { %a0 = affine.apply affine_map<(d0) -> (d0)> (%i0) @@ -395,7 +395,7 @@ // ----- // CHECK-LABEL: func @perfectly_nested_loops_loop_independent() { func @perfectly_nested_loops_loop_independent() { - %m = alloc() : memref<10x10xf32> + %m = memref.alloc() : memref<10x10xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 11 { affine.for %i1 = 0 to 11 { @@ -426,7 +426,7 @@ // ----- // CHECK-LABEL: func @perfectly_nested_loops_loop_carried_at_depth1() { func @perfectly_nested_loops_loop_carried_at_depth1() { - %m = alloc() : memref<10x10xf32> + %m = memref.alloc() : memref<10x10xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 9 { affine.for %i1 = 0 to 9 { @@ -457,7 +457,7 @@ // ----- // CHECK-LABEL: func @perfectly_nested_loops_loop_carried_at_depth2() { func @perfectly_nested_loops_loop_carried_at_depth2() { - %m = alloc() : memref<10x10xf32> + %m = memref.alloc() : memref<10x10xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { @@ -488,7 +488,7 @@ // ----- // CHECK-LABEL: func @one_common_loop() { func @one_common_loop() { - %m = alloc() : memref<10x10xf32> + %m = memref.alloc() : memref<10x10xf32> %c7 = constant 7.0 : f32 // There is a loop-independent dependence from access 0 to 1 at depth 2. affine.for %i0 = 0 to 10 { @@ -519,8 +519,8 @@ // ----- // CHECK-LABEL: func @dependence_cycle() { func @dependence_cycle() { - %m.a = alloc() : memref<100xf32> - %m.b = alloc() : memref<100xf32> + %m.a = memref.alloc() : memref<100xf32> + %m.b = memref.alloc() : memref<100xf32> // Dependences: // *) loop-independent dependence from access 1 to 2 at depth 2. @@ -573,7 +573,7 @@ // ----- // CHECK-LABEL: func @negative_and_positive_direction_vectors(%arg0: index, %arg1: index) { func @negative_and_positive_direction_vectors(%arg0: index, %arg1: index) { - %m = alloc() : memref<10x10xf32> + %m = memref.alloc() : memref<10x10xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to %arg0 { affine.for %i1 = 0 to %arg1 { @@ -603,7 +603,7 @@ // ----- // CHECK-LABEL: func @war_raw_waw_deps() { func @war_raw_waw_deps() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 10 { @@ -631,7 +631,7 @@ // ----- // CHECK-LABEL: func @mod_deps() { func @mod_deps() { - %m = alloc() : memref<100xf32> + %m = memref.alloc() : memref<100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { %a0 = affine.apply affine_map<(d0) -> (d0 mod 2)> (%i0) @@ -655,7 +655,7 @@ // ----- // CHECK-LABEL: func @loop_nest_depth() { func @loop_nest_depth() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> %c7 = constant 7.0 : f32 affine.for %i0 = 0 to 128 { @@ -691,7 +691,7 @@ // mod/div's successively. // CHECK-LABEL: func @mod_div_3d() { func @mod_div_3d() { - %M = alloc() : memref<2x2x2xi32> + %M = memref.alloc() : memref<2x2x2xi32> %c0 = constant 0 : i32 affine.for %i0 = 0 to 8 { affine.for %i1 = 0 to 8 { @@ -716,8 +716,8 @@ func @delinearize_mod_floordiv() { %c0 = constant 0 : index %val = constant 0 : i32 - %in = alloc() : memref<2x2x3x3x16x1xi32> - %out = alloc() : memref<64x9xi32> + %in = memref.alloc() : memref<2x2x3x3x16x1xi32> + %out = memref.alloc() : memref<64x9xi32> affine.for %i0 = 0 to 2 { affine.for %i1 = 0 to 2 { @@ -788,7 +788,7 @@ // Load and store ops access the same elements in strided scf. // CHECK-LABEL: func @strided_loop_with_dependence_at_depth2 func @strided_loop_with_dependence_at_depth2() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %cf0 = constant 0.0 : f32 affine.for %i0 = 0 to 8 step 2 { affine.store %cf0, %0[%i0] : memref<10xf32> @@ -810,7 +810,7 @@ // Load and store ops access alternating memref elements: no dependence. // CHECK-LABEL: func @strided_loop_with_no_dependence func @strided_loop_with_no_dependence() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %cf0 = constant 0.0 : f32 affine.for %i0 = 0 to 8 step 2 { %a0 = affine.apply affine_map<(d0) -> (d0 + 1)>(%i0) @@ -833,7 +833,7 @@ // Affine.Store op accesses memref elements at offset causing loop-carried dependence. // CHECK-LABEL: func @strided_loop_with_loop_carried_dependence_at_depth1 func @strided_loop_with_loop_carried_dependence_at_depth1() { - %0 = alloc() : memref<10xf32> + %0 = memref.alloc() : memref<10xf32> %cf0 = constant 0.0 : f32 affine.for %i0 = 0 to 8 step 2 { %a0 = affine.apply affine_map<(d0) -> (d0 + 4)>(%i0) @@ -857,7 +857,7 @@ // properly computed when the load and store are at different loop depths. // CHECK-LABEL: func @test_dep_store_depth1_load_depth2 func @test_dep_store_depth1_load_depth2() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 10 { %a0 = affine.apply affine_map<(d0) -> (d0 - 1)>(%i0) @@ -884,7 +884,7 @@ // properly computed when the load and store are at different loop depths. // CHECK-LABEL: func @test_dep_store_depth2_load_depth1 func @test_dep_store_depth2_load_depth1() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cst = constant 7.000000e+00 : f32 affine.for %i0 = 0 to 10 { affine.for %i1 = affine_map<(d0) -> (d0)>(%i0) to affine_map<(d0) -> (d0 + 1)>(%i0) { @@ -912,7 +912,7 @@ // CHECK-LABEL: func @test_affine_for_if_same_block() { func @test_affine_for_if_same_block() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 100 { @@ -940,7 +940,7 @@ // CHECK-LABEL: func @test_affine_for_if_separated() { func @test_affine_for_if_separated() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 10 { @@ -970,7 +970,7 @@ // CHECK-LABEL: func @test_affine_for_if_partially_joined() { func @test_affine_for_if_partially_joined() { - %0 = alloc() : memref<100xf32> + %0 = memref.alloc() : memref<100xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 100 { @@ -1001,7 +1001,7 @@ // CHECK-LABEL: func @test_interleaved_affine_for_if() { func @test_interleaved_affine_for_if() { - %0 = alloc() : memref<100x100xf32> + %0 = memref.alloc() : memref<100x100xf32> %cf7 = constant 7.0 : f32 affine.for %i0 = 0 to 100 { @@ -1039,7 +1039,7 @@ // CHECK-LABEL: func @test_interleaved_affine_for_if() { func @test_interleaved_affine_for_if() { - %0 = alloc() : memref<101xf32> + %0 = memref.alloc() : memref<101xf32> %c0 = constant 0 : index %N = dim %0, %c0 : memref<101xf32> %cf7 = constant 7.0 : f32 diff --git a/mlir/test/Transforms/normalize-memrefs-ops.mlir b/mlir/test/Transforms/normalize-memrefs-ops.mlir --- a/mlir/test/Transforms/normalize-memrefs-ops.mlir +++ b/mlir/test/Transforms/normalize-memrefs-ops.mlir @@ -16,13 +16,13 @@ // CHECK-LABEL: test_norm // CHECK-SAME: (%[[ARG0:.*]]: memref<1x16x1x1x32x64xf32>) func @test_norm(%arg0 : memref<1x16x14x14xf32, #map0>) -> () { - %0 = alloc() : memref<1x16x14x14xf32, #map0> + %0 = memref.alloc() : memref<1x16x14x14xf32, #map0> "test.op_norm"(%arg0, %0) : (memref<1x16x14x14xf32, #map0>, memref<1x16x14x14xf32, #map0>) -> () - dealloc %0 : memref<1x16x14x14xf32, #map0> + memref.dealloc %0 : memref<1x16x14x14xf32, #map0> - // CHECK: %[[v0:.*]] = alloc() : memref<1x16x1x1x32x64xf32> + // CHECK: %[[v0:.*]] = memref.alloc() : memref<1x16x1x1x32x64xf32> // CHECK: "test.op_norm"(%[[ARG0]], %[[v0]]) : (memref<1x16x1x1x32x64xf32>, memref<1x16x1x1x32x64xf32>) -> () - // CHECK: dealloc %[[v0]] : memref<1x16x1x1x32x64xf32> + // CHECK: memref.dealloc %[[v0]] : memref<1x16x1x1x32x64xf32> return } @@ -31,13 +31,13 @@ // CHECK-LABEL: test_nonnorm // CHECK-SAME: (%[[ARG0:.*]]: memref<1x16x14x14xf32, #map>) func @test_nonnorm(%arg0 : memref<1x16x14x14xf32, #map0>) -> () { - %0 = alloc() : memref<1x16x14x14xf32, #map0> + %0 = memref.alloc() : memref<1x16x14x14xf32, #map0> "test.op_nonnorm"(%arg0, %0) : (memref<1x16x14x14xf32, #map0>, memref<1x16x14x14xf32, #map0>) -> () - dealloc %0 : memref<1x16x14x14xf32, #map0> + memref.dealloc %0 : memref<1x16x14x14xf32, #map0> - // CHECK: %[[v0:.*]] = alloc() : memref<1x16x14x14xf32, #map> + // CHECK: %[[v0:.*]] = memref.alloc() : memref<1x16x14x14xf32, #map> // CHECK: "test.op_nonnorm"(%[[ARG0]], %[[v0]]) : (memref<1x16x14x14xf32, #map>, memref<1x16x14x14xf32, #map>) -> () - // CHECK: dealloc %[[v0]] : memref<1x16x14x14xf32, #map> + // CHECK: memref.dealloc %[[v0]] : memref<1x16x14x14xf32, #map> return } @@ -46,13 +46,13 @@ // CHECK-LABEL: test_norm_mix // CHECK-SAME: (%[[ARG0:.*]]: memref<1x16x1x1x32x64xf32> func @test_norm_mix(%arg0 : memref<1x16x1x1x32x64xf32>) -> () { - %0 = alloc() : memref<1x16x14x14xf32, #map0> + %0 = memref.alloc() : memref<1x16x14x14xf32, #map0> "test.op_norm"(%arg0, %0) : (memref<1x16x1x1x32x64xf32>, memref<1x16x14x14xf32, #map0>) -> () - dealloc %0 : memref<1x16x14x14xf32, #map0> + memref.dealloc %0 : memref<1x16x14x14xf32, #map0> - // CHECK: %[[v0:.*]] = alloc() : memref<1x16x1x1x32x64xf32> + // CHECK: %[[v0:.*]] = memref.alloc() : memref<1x16x1x1x32x64xf32> // CHECK: "test.op_norm"(%[[ARG0]], %[[v0]]) : (memref<1x16x1x1x32x64xf32>, memref<1x16x1x1x32x64xf32>) -> () - // CHECK: dealloc %[[v0]] : memref<1x16x1x1x32x64xf32> + // CHECK: memref.dealloc %[[v0]] : memref<1x16x1x1x32x64xf32> return } @@ -63,10 +63,10 @@ // CHECK-LABEL: test_load_store // CHECK-SAME: (%[[ARG0:.*]]: memref<1x16x14x14xf32> func @test_load_store(%arg0 : memref<1x16x14x14xf32>) -> () { - %0 = alloc() : memref<1x16x14x14xf32, #map_tile> - // CHECK: %[[v0:.*]] = alloc() : memref<1x16x1x1x32x32xf32> - %1 = alloc() : memref<1x16x14x14xf32> - // CHECK: %[[v1:.*]] = alloc() : memref<1x16x14x14xf32> + %0 = memref.alloc() : memref<1x16x14x14xf32, #map_tile> + // CHECK: %[[v0:.*]] = memref.alloc() : memref<1x16x1x1x32x32xf32> + %1 = memref.alloc() : memref<1x16x14x14xf32> + // CHECK: %[[v1:.*]] = memref.alloc() : memref<1x16x14x14xf32> "test.op_norm"(%0, %1) : (memref<1x16x14x14xf32, #map_tile>, memref<1x16x14x14xf32>) -> () // CHECK: "test.op_norm"(%[[v0]], %[[v1]]) : (memref<1x16x1x1x32x32xf32>, memref<1x16x14x14xf32>) -> () %cst = constant 3.0 : f32 @@ -77,16 +77,16 @@ %2 = load %1[%i, %j, %k, %l] : memref<1x16x14x14xf32> // CHECK: memref<1x16x14x14xf32> %3 = addf %2, %cst : f32 - store %3, %arg0[%i, %j, %k, %l] : memref<1x16x14x14xf32> + memref.store %3, %arg0[%i, %j, %k, %l] : memref<1x16x14x14xf32> // CHECK: memref<1x16x14x14xf32> } } } } - dealloc %0 : memref<1x16x14x14xf32, #map_tile> - // CHECK: dealloc %[[v0]] : memref<1x16x1x1x32x32xf32> - dealloc %1 : memref<1x16x14x14xf32> - // CHECK: dealloc %[[v1]] : memref<1x16x14x14xf32> + memref.dealloc %0 : memref<1x16x14x14xf32, #map_tile> + // CHECK: memref.dealloc %[[v0]] : memref<1x16x1x1x32x32xf32> + memref.dealloc %1 : memref<1x16x14x14xf32> + // CHECK: memref.dealloc %[[v1]] : memref<1x16x14x14xf32> return } @@ -95,16 +95,16 @@ // CHECK-LABEL: test_norm_ret // CHECK-SAME: (%[[ARG0:.*]]: memref<1x16x1x1x32x32xf32>) -> (memref<1x16x1x1x32x32xf32>, memref<1x16x14x14xf32>) { func @test_norm_ret(%arg0: memref<1x16x14x14xf32, #map_tile>) -> (memref<1x16x14x14xf32, #map_tile>, memref<1x16x14x14xf32>) { - %0 = alloc() : memref<1x16x14x14xf32, #map_tile> - // CHECK-NEXT: %[[v0:.*]] = alloc() : memref<1x16x1x1x32x32xf32> + %0 = memref.alloc() : memref<1x16x14x14xf32, #map_tile> + // CHECK-NEXT: %[[v0:.*]] = memref.alloc() : memref<1x16x1x1x32x32xf32> %1, %2 = "test.op_norm_ret"(%arg0) : (memref<1x16x14x14xf32, #map_tile>) -> (memref<1x16x14x14xf32, #map_tile>, memref<1x16x14x14xf32>) // CHECK-NEXT: %[[v1:.*]], %[[v2:.*]] = "test.op_norm_ret" // CHECK-SAME: (memref<1x16x1x1x32x32xf32>) -> (memref<1x16x1x1x32x32xf32>, memref<1x16x14x14xf32>) "test.op_norm"(%1, %0) : (memref<1x16x14x14xf32, #map_tile>, memref<1x16x14x14xf32, #map_tile>) -> () // CHECK-NEXT: "test.op_norm" // CHECK-SAME: : (memref<1x16x1x1x32x32xf32>, memref<1x16x1x1x32x32xf32>) -> () - dealloc %0 : memref<1x16x14x14xf32, #map_tile> - // CHECK-NEXT: dealloc %[[v0]] : memref<1x16x1x1x32x32xf32> + memref.dealloc %0 : memref<1x16x14x14xf32, #map_tile> + // CHECK-NEXT: memref.dealloc %[[v0]] : memref<1x16x1x1x32x32xf32> return %1, %2 : memref<1x16x14x14xf32, #map_tile>, memref<1x16x14x14xf32> // CHECK-NEXT: return %[[v1]], %[[v2]] : memref<1x16x1x1x32x32xf32>, memref<1x16x14x14xf32> } diff --git a/mlir/test/Transforms/normalize-memrefs.mlir b/mlir/test/Transforms/normalize-memrefs.mlir --- a/mlir/test/Transforms/normalize-memrefs.mlir +++ b/mlir/test/Transforms/normalize-memrefs.mlir @@ -5,32 +5,32 @@ // CHECK-LABEL: func @permute() func @permute() { - %A = alloc() : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> + %A = memref.alloc() : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> affine.for %i = 0 to 64 { affine.for %j = 0 to 256 { %1 = affine.load %A[%i, %j] : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> "prevent.dce"(%1) : (f32) -> () } } - dealloc %A : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> + memref.dealloc %A : memref<64x256xf32, affine_map<(d0, d1) -> (d1, d0)>> return } // The old memref alloc should disappear. // CHECK-NOT: memref<64x256xf32> -// CHECK: [[MEM:%[0-9]+]] = alloc() : memref<256x64xf32> +// CHECK: [[MEM:%[0-9]+]] = memref.alloc() : memref<256x64xf32> // CHECK-NEXT: affine.for %[[I:arg[0-9]+]] = 0 to 64 { // CHECK-NEXT: affine.for %[[J:arg[0-9]+]] = 0 to 256 { // CHECK-NEXT: affine.load [[MEM]][%[[J]], %[[I]]] : memref<256x64xf32> // CHECK-NEXT: "prevent.dce" // CHECK-NEXT: } // CHECK-NEXT: } -// CHECK-NEXT: dealloc [[MEM]] +// CHECK-NEXT: memref.dealloc [[MEM]] // CHECK-NEXT: return // CHECK-LABEL: func @shift func @shift(%idx : index) { - // CHECK-NEXT: alloc() : memref<65xf32> - %A = alloc() : memref<64xf32, affine_map<(d0) -> (d0 + 1)>> + // CHECK-NEXT: memref.alloc() : memref<65xf32> + %A = memref.alloc() : memref<64xf32, affine_map<(d0) -> (d0 + 1)>> // CHECK-NEXT: affine.load %{{.*}}[symbol(%arg0) + 1] : memref<65xf32> affine.load %A[%idx] : memref<64xf32, affine_map<(d0) -> (d0 + 1)>> affine.for %i = 0 to 64 { @@ -44,7 +44,7 @@ // CHECK-LABEL: func @high_dim_permute() func @high_dim_permute() { // CHECK-NOT: memref<64x128x256xf32, - %A = alloc() : memref<64x128x256xf32, affine_map<(d0, d1, d2) -> (d2, d0, d1)>> + %A = memref.alloc() : memref<64x128x256xf32, affine_map<(d0, d1, d2) -> (d2, d0, d1)>> // CHECK: %[[I:arg[0-9]+]] affine.for %i = 0 to 64 { // CHECK: %[[J:arg[0-9]+]] @@ -62,16 +62,16 @@ // CHECK-LABEL: func @invalid_map func @invalid_map() { - %A = alloc() : memref<64x128xf32, affine_map<(d0, d1) -> (d0, -d1 - 10)>> - // CHECK: %{{.*}} = alloc() : memref<64x128xf32, + %A = memref.alloc() : memref<64x128xf32, affine_map<(d0, d1) -> (d0, -d1 - 10)>> + // CHECK: %{{.*}} = memref.alloc() : memref<64x128xf32, return } // A tiled layout. // CHECK-LABEL: func @data_tiling func @data_tiling(%idx : index) { - // CHECK: alloc() : memref<8x32x8x16xf32> - %A = alloc() : memref<64x512xf32, affine_map<(d0, d1) -> (d0 floordiv 8, d1 floordiv 16, d0 mod 8, d1 mod 16)>> + // CHECK: memref.alloc() : memref<8x32x8x16xf32> + %A = memref.alloc() : memref<64x512xf32, affine_map<(d0, d1) -> (d0 floordiv 8, d1 floordiv 16, d0 mod 8, d1 mod 16)>> // CHECK: affine.load %{{.*}}[symbol(%arg0) floordiv 8, symbol(%arg0) floordiv 16, symbol(%arg0) mod 8, symbol(%arg0) mod 16] %1 = affine.load %A[%idx, %idx] : memref<64x512xf32, affine_map<(d0, d1) -> (d0 floordiv 8, d1 floordiv 16, d0 mod 8, d1 mod 16)>> "prevent.dce"(%1) : (f32) -> () @@ -81,7 +81,7 @@ // Strides 2 and 4 along respective dimensions. // CHECK-LABEL: func @strided func @strided() { - %A = alloc() : memref<64x128xf32, affine_map<(d0, d1) -> (2*d0, 4*d1)>> + %A = memref.alloc() : memref<64x128xf32, affine_map<(d0, d1) -> (2*d0, 4*d1)>> // CHECK: affine.for %[[IV0:.*]] = affine.for %i = 0 to 64 { // CHECK: affine.for %[[IV1:.*]] = @@ -97,7 +97,7 @@ // Strided, but the strides are in the linearized space. // CHECK-LABEL: func @strided_cumulative func @strided_cumulative() { - %A = alloc() : memref<2x5xf32, affine_map<(d0, d1) -> (3*d0 + 17*d1)>> + %A = memref.alloc() : memref<2x5xf32, affine_map<(d0, d1) -> (3*d0 + 17*d1)>> // CHECK: affine.for %[[IV0:.*]] = affine.for %i = 0 to 2 { // CHECK: affine.for %[[IV1:.*]] = @@ -114,8 +114,8 @@ // when the index remap has symbols. // CHECK-LABEL: func @symbolic_operands func @symbolic_operands(%s : index) { - // CHECK: alloc() : memref<100xf32> - %A = alloc()[%s] : memref<10x10xf32, affine_map<(d0,d1)[s0] -> (10*d0 + d1)>> + // CHECK: memref.alloc() : memref<100xf32> + %A = memref.alloc()[%s] : memref<10x10xf32, affine_map<(d0,d1)[s0] -> (10*d0 + d1)>> affine.for %i = 0 to 10 { affine.for %j = 0 to 10 { // CHECK: affine.load %{{.*}}[%{{.*}} * 10 + %{{.*}}] : memref<100xf32> @@ -129,7 +129,7 @@ // Semi-affine maps, normalization not implemented yet. // CHECK-LABEL: func @semi_affine_layout_map func @semi_affine_layout_map(%s0: index, %s1: index) { - %A = alloc()[%s0, %s1] : memref<256x1024xf32, affine_map<(d0, d1)[s0, s1] -> (d0*s0 + d1*s1)>> + %A = memref.alloc()[%s0, %s1] : memref<256x1024xf32, affine_map<(d0, d1)[s0, s1] -> (d0*s0 + d1*s1)>> affine.for %i = 0 to 256 { affine.for %j = 0 to 1024 { // CHECK: memref<256x1024xf32, #map{{[0-9]+}}> @@ -141,8 +141,8 @@ // CHECK-LABEL: func @alignment func @alignment() { - %A = alloc() {alignment = 32 : i64}: memref<64x128x256xf32, affine_map<(d0, d1, d2) -> (d2, d0, d1)>> - // CHECK-NEXT: alloc() {alignment = 32 : i64} : memref<256x64x128xf32> + %A = memref.alloc() {alignment = 32 : i64}: memref<64x128x256xf32, affine_map<(d0, d1, d2) -> (d2, d0, d1)>> + // CHECK-NEXT: memref.alloc() {alignment = 32 : i64} : memref<256x64x128xf32> return } @@ -171,20 +171,20 @@ // CHECK-LABEL: func @single_argument_type // CHECK-SAME: (%[[C:arg[0-9]+]]: memref<2x4xf64>) func @single_argument_type(%C : memref<8xf64, #tile>) { - %a = alloc(): memref<8xf64, #tile> - %b = alloc(): memref<16xf64, #tile> + %a = memref.alloc(): memref<8xf64, #tile> + %b = memref.alloc(): memref<16xf64, #tile> %d = constant 23.0 : f64 - %e = alloc(): memref<24xf64> + %e = memref.alloc(): memref<24xf64> call @single_argument_type(%a): (memref<8xf64, #tile>) -> () call @single_argument_type(%C): (memref<8xf64, #tile>) -> () call @multiple_argument_type(%b, %d, %a, %e): (memref<16xf64, #tile>, f64, memref<8xf64, #tile>, memref<24xf64>) -> f64 return } -// CHECK: %[[a:[0-9]+]] = alloc() : memref<2x4xf64> -// CHECK: %[[b:[0-9]+]] = alloc() : memref<4x4xf64> +// CHECK: %[[a:[0-9]+]] = memref.alloc() : memref<2x4xf64> +// CHECK: %[[b:[0-9]+]] = memref.alloc() : memref<4x4xf64> // CHECK: %cst = constant 2.300000e+01 : f64 -// CHECK: %[[e:[0-9]+]] = alloc() : memref<24xf64> +// CHECK: %[[e:[0-9]+]] = memref.alloc() : memref<24xf64> // CHECK: call @single_argument_type(%[[a]]) : (memref<2x4xf64>) -> () // CHECK: call @single_argument_type(%[[C]]) : (memref<2x4xf64>) -> () // CHECK: call @multiple_argument_type(%[[b]], %cst, %[[a]], %[[e]]) : (memref<4x4xf64>, f64, memref<2x4xf64>, memref<24xf64>) -> f64 @@ -227,8 +227,8 @@ // CHECK-LABEL: func @ret_single_argument_type // CHECK-SAME: (%[[C:arg[0-9]+]]: memref<2x4xf64>) -> (memref<4x4xf64>, memref<2x4xf64>) func @ret_single_argument_type(%C: memref<8xf64, #tile>) -> (memref<16xf64, #tile>, memref<8xf64, #tile>){ - %a = alloc() : memref<8xf64, #tile> - %b = alloc() : memref<16xf64, #tile> + %a = memref.alloc() : memref<8xf64, #tile> + %b = memref.alloc() : memref<16xf64, #tile> %d = constant 23.0 : f64 call @ret_single_argument_type(%a) : (memref<8xf64, #tile>) -> (memref<16xf64, #tile>, memref<8xf64, #tile>) call @ret_single_argument_type(%C) : (memref<8xf64, #tile>) -> (memref<16xf64, #tile>, memref<8xf64, #tile>) @@ -237,8 +237,8 @@ return %b, %a: memref<16xf64, #tile>, memref<8xf64, #tile> } -// CHECK: %[[a:[0-9]+]] = alloc() : memref<2x4xf64> -// CHECK: %[[b:[0-9]+]] = alloc() : memref<4x4xf64> +// CHECK: %[[a:[0-9]+]] = memref.alloc() : memref<2x4xf64> +// CHECK: %[[b:[0-9]+]] = memref.alloc() : memref<4x4xf64> // CHECK: %cst = constant 2.300000e+01 : f64 // CHECK: %[[resA:[0-9]+]]:2 = call @ret_single_argument_type(%[[a]]) : (memref<2x4xf64>) -> (memref<4x4xf64>, memref<2x4xf64>) // CHECK: %[[resB:[0-9]+]]:2 = call @ret_single_argument_type(%[[C]]) : (memref<2x4xf64>) -> (memref<4x4xf64>, memref<2x4xf64>) @@ -304,11 +304,11 @@ // CHECK-LABEL: func @simply_call_external() func @simply_call_external() { - %a = alloc() : memref<16xf64, #tile> + %a = memref.alloc() : memref<16xf64, #tile> call @external_func_A(%a) : (memref<16xf64, #tile>) -> () return } -// CHECK: %[[a:[0-9]+]] = alloc() : memref<4x4xf64> +// CHECK: %[[a:[0-9]+]] = memref.alloc() : memref<4x4xf64> // CHECK: call @external_func_A(%[[a]]) : (memref<4x4xf64>) -> () // CHECK-LABEL: func @use_value_of_external diff --git a/mlir/test/Transforms/pipeline-data-transfer.mlir b/mlir/test/Transforms/pipeline-data-transfer.mlir --- a/mlir/test/Transforms/pipeline-data-transfer.mlir +++ b/mlir/test/Transforms/pipeline-data-transfer.mlir @@ -8,10 +8,10 @@ // CHECK-LABEL: func @loop_nest_dma() { func @loop_nest_dma() { - %A = alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> - %Ah = alloc() : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> + %A = memref.alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> + %Ah = memref.alloc() : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> - %tag = alloc() : memref<1 x f32> + %tag = memref.alloc() : memref<1 x f32> %zero = constant 0 : index %num_elts = constant 32 : index @@ -26,13 +26,13 @@ "do_more_compute"(%i, %j) : (index, index) -> () } } - dealloc %tag : memref<1 x f32> - dealloc %Ah : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> + memref.dealloc %tag : memref<1 x f32> + memref.dealloc %Ah : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> return } -// CHECK: %{{.*}} = alloc() : memref<256xf32> -// CHECK: %{{.*}} = alloc() : memref<2x32xf32, 1> -// CHECK-NEXT: %{{.*}} = alloc() : memref<2x1xf32> +// CHECK: %{{.*}} = memref.alloc() : memref<256xf32> +// CHECK: %{{.*}} = memref.alloc() : memref<2x32xf32, 1> +// CHECK-NEXT: %{{.*}} = memref.alloc() : memref<2x1xf32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}} mod 2, %{{.*}}], %{{.*}}[%{{.*}} mod 2, 0], %{{.*}} : memref<256xf32>, memref<2x32xf32, 1>, memref<2x1xf32> // CHECK-NEXT: affine.for %{{.*}} = 1 to 8 { // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[%{{.*}} mod 2, %{{.*}}], %{{.*}}[%{{.*}} mod 2, 0], %{{.*}} : memref<256xf32>, memref<2x32xf32, 1>, memref<2x1xf32> @@ -57,8 +57,8 @@ // CHECK-NEXT: affine.for %{{.*}} = 0 to 32 { // CHECK-NEXT: "do_more_compute"(%{{.*}}, %{{.*}}) : (index, index) -> () // CHECK-NEXT: } -// CHECK-NEXT: dealloc %{{.*}} : memref<2x1xf32> -// CHECK-NEXT: dealloc %{{.*}} : memref<2x32xf32, 1> +// CHECK-NEXT: memref.dealloc %{{.*}} : memref<2x1xf32> +// CHECK-NEXT: memref.dealloc %{{.*}} : memref<2x32xf32, 1> // CHECK-NEXT: return // CHECK-NEXT:} @@ -73,19 +73,19 @@ %c0 = constant 0 : index %c4 = constant 4 : index affine.for %i0 = 0 to 512 step 4 { - %1 = alloc() : memref<4xf32, 1> - %2 = alloc() : memref<1xi32> + %1 = memref.alloc() : memref<4xf32, 1> + %2 = memref.alloc() : memref<1xi32> affine.dma_start %arg0[%i0], %1[%c0], %2[%c0], %c4, : memref<512xf32>, memref<4xf32, 1>, memref<1xi32> affine.dma_wait %2[%c0], %c4 : memref<1xi32> "compute"(%i0) : (index) -> () - dealloc %2 : memref<1xi32> - dealloc %1 : memref<4xf32, 1> + memref.dealloc %2 : memref<1xi32> + memref.dealloc %1 : memref<4xf32, 1> } return } -// CHECK: [[BUF:%[0-9]+]] = alloc() : memref<2x4xf32, 1> -// CHECK: [[TAG:%[0-9]+]] = alloc() : memref<2x1xi32> +// CHECK: [[BUF:%[0-9]+]] = memref.alloc() : memref<2x4xf32, 1> +// CHECK: [[TAG:%[0-9]+]] = memref.alloc() : memref<2x1xi32> // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[(%{{.*}} floordiv 4) mod 2, 0], [[TAG]][(%{{.*}} floordiv 4) mod 2, 0], %{{.*}} : memref<512xf32>, memref<2x4xf32, 1>, memref<2x1xi32> // CHECK-NEXT: affine.for %{{.*}} = 4 to 512 step 4 { // CHECK-NEXT: affine.dma_start %{{.*}}[%{{.*}}], %{{.*}}[(%{{.*}} floordiv 4) mod 2, 0], [[TAG]][(%{{.*}} floordiv 4) mod 2, 0], %{{.*}} : memref<512xf32>, memref<2x4xf32, 1>, memref<2x1xi32> @@ -98,8 +98,8 @@ // CHECK-NEXT: %{{.*}} = affine.apply [[$FLOOR_MOD_2]]([[SHIFTED]]) // CHECK: affine.dma_wait [[TAG]][(%{{.*}} floordiv 4) mod 2, 0], %{{.*}} : memref<2x1xi32> // CHECK-NEXT: "compute"(%{{.*}}) : (index) -> () -// CHECK-NEXT: dealloc [[TAG]] : memref<2x1xi32> -// CHECK-NEXT: dealloc [[BUF]] : memref<2x4xf32, 1> +// CHECK-NEXT: memref.dealloc [[TAG]] : memref<2x1xi32> +// CHECK-NEXT: memref.dealloc [[BUF]] : memref<2x4xf32, 1> // CHECK-NEXT: return // CHECK-NEXT: } @@ -111,15 +111,15 @@ func @loop_dma_nested(%arg0: memref<512x32xvector<8xf32>>, %arg1: memref<512x32xvector<8xf32>>, %arg2: memref<512x32xvector<8xf32>>) { %num_elts = constant 256 : index %c0 = constant 0 : index - %0 = alloc() : memref<64x4xvector<8xf32>, 2> - %1 = alloc() : memref<64x4xvector<8xf32>, 2> - %2 = alloc() : memref<64x4xvector<8xf32>, 2> - %3 = alloc() : memref<2xi32> - %4 = alloc() : memref<2xi32> - %5 = alloc() : memref<2xi32> + %0 = memref.alloc() : memref<64x4xvector<8xf32>, 2> + %1 = memref.alloc() : memref<64x4xvector<8xf32>, 2> + %2 = memref.alloc() : memref<64x4xvector<8xf32>, 2> + %3 = memref.alloc() : memref<2xi32> + %4 = memref.alloc() : memref<2xi32> + %5 = memref.alloc() : memref<2xi32> // Prologue for DMA overlap on arg2. - // CHECK-DAG: [[BUF_ARG2:%[0-9]+]] = alloc() : memref<2x64x4xvector<8xf32>, 2> - // CHECK-DAG: [[TAG_ARG2:%[0-9]+]] = alloc() : memref<2x2xi32> + // CHECK-DAG: [[BUF_ARG2:%[0-9]+]] = memref.alloc() : memref<2x64x4xvector<8xf32>, 2> + // CHECK-DAG: [[TAG_ARG2:%[0-9]+]] = memref.alloc() : memref<2x2xi32> // CHECK: affine.dma_start %{{.*}}[ // CHECK: affine.for %{{.*}} = 1 to 8 { affine.for %i0 = 0 to 8 { @@ -130,10 +130,10 @@ // CHECK: affine.dma_start %{{.*}}[ // CHECK: affine.dma_wait [[TAG_ARG2]] // Prologue for DMA overlap on arg0, arg1 nested within i0 - // CHECK: [[BUF_ARG0:%[0-9]+]] = alloc() : memref<2x64x4xvector<8xf32>, 2> - // CHECK: [[BUF_ARG1:%[0-9]+]] = alloc() : memref<2x64x4xvector<8xf32>, 2> - // CHECK: [[TAG_ARG0:%[0-9]+]] = alloc() : memref<2x2xi32> - // CHECK: [[TAG_ARG1:%[0-9]+]] = alloc() : memref<2x2xi32> + // CHECK: [[BUF_ARG0:%[0-9]+]] = memref.alloc() : memref<2x64x4xvector<8xf32>, 2> + // CHECK: [[BUF_ARG1:%[0-9]+]] = memref.alloc() : memref<2x64x4xvector<8xf32>, 2> + // CHECK: [[TAG_ARG0:%[0-9]+]] = memref.alloc() : memref<2x2xi32> + // CHECK: [[TAG_ARG1:%[0-9]+]] = memref.alloc() : memref<2x2xi32> // CHECK: affine.dma_start %{{.*}}[ // CHECK: affine.dma_start %{{.*}}[ // CHECK-NEXT: affine.for %{{.*}} = 1 to 8 { @@ -157,17 +157,17 @@ // epilogue for arg0, arg1 // CHECK: affine.dma_wait [[TAG_ARG0]] // CHECK: affine.dma_wait [[TAG_ARG1]] - // CHECK-DAG: dealloc [[TAG_ARG1]] : memref<2x2xi32> - // CHECK-DAG: dealloc [[TAG_ARG0]] : memref<2x2xi32> - // CHECK-DAG: dealloc [[BUF_ARG1]] : memref<2x64x4xvector<8xf32>, 2> - // CHECK-DAG: dealloc [[BUF_ARG0]] : memref<2x64x4xvector<8xf32>, 2> + // CHECK-DAG: memref.dealloc [[TAG_ARG1]] : memref<2x2xi32> + // CHECK-DAG: memref.dealloc [[TAG_ARG0]] : memref<2x2xi32> + // CHECK-DAG: memref.dealloc [[BUF_ARG1]] : memref<2x64x4xvector<8xf32>, 2> + // CHECK-DAG: memref.dealloc [[BUF_ARG0]] : memref<2x64x4xvector<8xf32>, 2> // epilogue for DMA overlap on %arg2 // CHECK: affine.dma_wait [[TAG_ARG2]] // Within the epilogue for arg2's DMA, we have the DMAs on %arg1, %arg2 nested. - // CHECK: [[BUF_ARG0_NESTED:%[0-9]+]] = alloc() : memref<2x64x4xvector<8xf32>, 2> - // CHECK: [[BUF_ARG1_NESTED:%[0-9]+]] = alloc() : memref<2x64x4xvector<8xf32>, 2> - // CHECK: [[TAG_ARG0_NESTED:%[0-9]+]] = alloc() : memref<2x2xi32> - // CHECK: [[TAG_ARG1_NESTED:%[0-9]+]] = alloc() : memref<2x2xi32> + // CHECK: [[BUF_ARG0_NESTED:%[0-9]+]] = memref.alloc() : memref<2x64x4xvector<8xf32>, 2> + // CHECK: [[BUF_ARG1_NESTED:%[0-9]+]] = memref.alloc() : memref<2x64x4xvector<8xf32>, 2> + // CHECK: [[TAG_ARG0_NESTED:%[0-9]+]] = memref.alloc() : memref<2x2xi32> + // CHECK: [[TAG_ARG1_NESTED:%[0-9]+]] = memref.alloc() : memref<2x2xi32> // CHECK: affine.dma_start %{{.*}}[ // CHECK: affine.dma_start %{{.*}}[ // CHECK: affine.for %{{.*}} = 1 to 8 { @@ -181,20 +181,20 @@ // CHECK: affine.dma_wait [[TAG_ARG1_NESTED]] // CHECK: affine.for %{{.*}} = 0 to 4 { } - dealloc %5 : memref<2xi32> - dealloc %4 : memref<2xi32> - dealloc %3 : memref<2xi32> - dealloc %2 : memref<64x4xvector<8xf32>, 2> - dealloc %1 : memref<64x4xvector<8xf32>, 2> - dealloc %0 : memref<64x4xvector<8xf32>, 2> + memref.dealloc %5 : memref<2xi32> + memref.dealloc %4 : memref<2xi32> + memref.dealloc %3 : memref<2xi32> + memref.dealloc %2 : memref<64x4xvector<8xf32>, 2> + memref.dealloc %1 : memref<64x4xvector<8xf32>, 2> + memref.dealloc %0 : memref<64x4xvector<8xf32>, 2> return // CHECK: } -// CHECK-DAG: dealloc [[TAG_ARG1_NESTED]] : memref<2x2xi32> -// CHECK-DAG: dealloc [[TAG_ARG0_NESTED]] : memref<2x2xi32> -// CHECK-DAG: dealloc [[BUF_ARG1_NESTED]] : memref<2x64x4xvector<8xf32>, 2> -// CHECK-DAG: dealloc [[BUF_ARG0_NESTED]] : memref<2x64x4xvector<8xf32>, 2> -// CHECK-DAG: dealloc [[TAG_ARG2]] : memref<2x2xi32> -// CHECK-DAG: dealloc [[BUF_ARG2]] : memref<2x64x4xvector<8xf32>, 2> +// CHECK-DAG: memref.dealloc [[TAG_ARG1_NESTED]] : memref<2x2xi32> +// CHECK-DAG: memref.dealloc [[TAG_ARG0_NESTED]] : memref<2x2xi32> +// CHECK-DAG: memref.dealloc [[BUF_ARG1_NESTED]] : memref<2x64x4xvector<8xf32>, 2> +// CHECK-DAG: memref.dealloc [[BUF_ARG0_NESTED]] : memref<2x64x4xvector<8xf32>, 2> +// CHECK-DAG: memref.dealloc [[TAG_ARG2]] : memref<2x2xi32> +// CHECK-DAG: memref.dealloc [[BUF_ARG2]] : memref<2x64x4xvector<8xf32>, 2> // CHECK-NEXT: return } @@ -205,12 +205,12 @@ func @loop_dma_dependent(%arg2: memref<512x32xvector<8xf32>>) { %num_elts = constant 256 : index %c0 = constant 0 : index - %0 = alloc() : memref<64x4xvector<8xf32>, 2> - %1 = alloc() : memref<64x4xvector<8xf32>, 2> - %2 = alloc() : memref<64x4xvector<8xf32>, 2> - %3 = alloc() : memref<2xi32> - %4 = alloc() : memref<2xi32> - %5 = alloc() : memref<2xi32> + %0 = memref.alloc() : memref<64x4xvector<8xf32>, 2> + %1 = memref.alloc() : memref<64x4xvector<8xf32>, 2> + %2 = memref.alloc() : memref<64x4xvector<8xf32>, 2> + %3 = memref.alloc() : memref<2xi32> + %4 = memref.alloc() : memref<2xi32> + %5 = memref.alloc() : memref<2xi32> // The two DMAs below are dependent (incoming and outgoing on the same // memref) in the same iteration; so no pipelining here. @@ -224,12 +224,12 @@ affine.dma_start %2[%c0, %c0], %arg2[%6, %c0], %5[%c0], %num_elts : memref<64x4xvector<8xf32>, 2>, memref<512x32xvector<8xf32>>, memref<2xi32> affine.dma_wait %5[%c0], %num_elts : memref<2xi32> } - dealloc %5 : memref<2xi32> - dealloc %4 : memref<2xi32> - dealloc %3 : memref<2xi32> - dealloc %2 : memref<64x4xvector<8xf32>, 2> - dealloc %1 : memref<64x4xvector<8xf32>, 2> - dealloc %0 : memref<64x4xvector<8xf32>, 2> + memref.dealloc %5 : memref<2xi32> + memref.dealloc %4 : memref<2xi32> + memref.dealloc %3 : memref<2xi32> + memref.dealloc %2 : memref<64x4xvector<8xf32>, 2> + memref.dealloc %1 : memref<64x4xvector<8xf32>, 2> + memref.dealloc %0 : memref<64x4xvector<8xf32>, 2> return } @@ -240,8 +240,8 @@ %c32 = constant 32 : index %num_elt = constant 512 : index %zero = constant 0 : index - %Av = alloc() : memref<32 x 32 x f32, 2> - %tag = alloc() : memref<1 x i32> + %Av = memref.alloc() : memref<32 x 32 x f32, 2> + %tag = memref.alloc() : memref<1 x i32> // CHECK-NOT: affine.dma_start // CHECK: affine.for %{{.*}} = 0 to 16 { @@ -253,8 +253,8 @@ // escaping use; no DMA pipelining / double buffering will be done. "foo"(%Av) : (memref<32 x 32 x f32, 2>) -> () } - dealloc %tag : memref<1 x i32> - dealloc %Av : memref<32 x 32 x f32, 2> + memref.dealloc %tag : memref<1 x i32> + memref.dealloc %Av : memref<32 x 32 x f32, 2> return // CHECK: "foo"(%{{[0-9]+}}) : (memref<32x32xf32, 2>) -> () // CHECK: } @@ -268,8 +268,8 @@ %c32 = constant 32 : index %num_elt = constant 512 : index %zero = constant 0 : index - %Av = alloc() : memref<32 x 32 x f32, 2> - %tag = alloc() : memref<1 x i32> + %Av = memref.alloc() : memref<32 x 32 x f32, 2> + %tag = memref.alloc() : memref<1 x i32> // CHECK-NOT: affine.dma_start // CHECK: affine.for %{{.*}} = 0 to 16 { @@ -281,8 +281,8 @@ // escaping use; no DMA pipelining / double buffering will be done. "foo"(%tag) : (memref<1 x i32>) -> () } - dealloc %tag : memref<1 x i32> - dealloc %Av : memref<32 x 32 x f32, 2> + memref.dealloc %tag : memref<1 x i32> + memref.dealloc %Av : memref<32 x 32 x f32, 2> return // CHECK: "foo"(%{{[0-9]+}}) : (memref<1xi32>) -> () // CHECK: } @@ -297,8 +297,8 @@ %c32 = constant 32 : index %num_elt = constant 512 : index %zero = constant 0 : index - %Av = alloc() : memref<32 x 32 x f32, 2> - %tag = alloc() : memref<1 x i32> + %Av = memref.alloc() : memref<32 x 32 x f32, 2> + %tag = memref.alloc() : memref<1 x i32> // CHECK-NOT: affine.dma_start // CHECK: affine.for %{{.*}} = 0 to 16 { @@ -310,8 +310,8 @@ } // Use live out of 'affine.for' op; no DMA pipelining will be done. %v = affine.load %Av[%zero, %zero] : memref<32 x 32 x f32, 2> - dealloc %tag : memref<1 x i32> - dealloc %Av : memref<32 x 32 x f32, 2> + memref.dealloc %tag : memref<1 x i32> + memref.dealloc %Av : memref<32 x 32 x f32, 2> return %v : f32 // CHECK: affine.load %{{[0-9]+}}[%{{.*}}, %{{.*}}] : memref<32x32xf32, 2> // CHECK: return @@ -325,16 +325,16 @@ %num_elt = constant 512 : index %zero = constant 0 : index - %Av = alloc(%c32, %c32) : memref - %tag = alloc() : memref<1 x i32> + %Av = memref.alloc(%c32, %c32) : memref + %tag = memref.alloc() : memref<1 x i32> // Double buffering for dynamic shaped buffer. -// CHECK: alloc(%{{.*}}, %{{.*}}) : memref +// CHECK: memref.alloc(%{{.*}}, %{{.*}}) : memref // CHECK-NEXT: %[[C0:.*]] = constant 0 : index // CHECK-NEXT: dim %{{.*}}, %[[C0]] : memref // CHECK-NEXT: %[[C1:.*]] = constant 1 : index // CHECK-NEXT: dim %{{.*}}, %[[C1]] : memref -// CHECK-NEXT: alloc(%{{.*}}, %{{.*}}) : memref<2x?x?xf32, 2> +// CHECK-NEXT: memref.alloc(%{{.*}}, %{{.*}}) : memref<2x?x?xf32, 2> // CHECK: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}} mod 2, 0, 0], %{{.*}}[%{{.*}} mod 2, 0], %{{.*}} affine.for %kTT = 0 to 16 { affine.dma_start %arg0[%zero, %zero], %Av[%zero, %zero], %tag[%zero], %num_elt : @@ -342,7 +342,7 @@ memref, memref<1 x i32> affine.dma_wait %tag[%zero], %num_elt : memref<1 x i32> } - dealloc %Av : memref + memref.dealloc %Av : memref return // CHECK-NEXT: affine.for %{{.*}} = 1 to 16 { // CHECK: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}} mod 2, 0, 0], %{{.*}}[%{{.*}} mod 2, 0], %{{.*}} @@ -358,9 +358,9 @@ // before performing any replacement. // CHECK-LABEL: func @escaping_and_indexed_use_mix func @escaping_and_indexed_use_mix() { - %A = alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> - %Ah = alloc() : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> - %tag = alloc() : memref<1 x f32> + %A = memref.alloc() : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> + %Ah = memref.alloc() : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> + %tag = memref.alloc() : memref<1 x f32> %zero = constant 0 : index %num_elts = constant 32 : index @@ -372,8 +372,8 @@ %v = affine.load %Ah[%i] : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> "foo"(%v) : (f32) -> () } - dealloc %A : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> - dealloc %Ah : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> + memref.dealloc %A : memref<256 x f32, affine_map<(d0) -> (d0)>, 0> + memref.dealloc %Ah : memref<32 x f32, affine_map<(d0) -> (d0)>, 1> return } // No replacement. diff --git a/mlir/test/Transforms/promote-buffers-to-stack.mlir b/mlir/test/Transforms/promote-buffers-to-stack.mlir --- a/mlir/test/Transforms/promote-buffers-to-stack.mlir +++ b/mlir/test/Transforms/promote-buffers-to-stack.mlir @@ -21,7 +21,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): @@ -31,7 +31,7 @@ // CHECK-NEXT: cond_br {{.*}} // CHECK: ^bb2 -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK: test.copy // CHECK-NEXT: return @@ -56,7 +56,7 @@ ^bb1: br ^bb3(%arg1 : memref) ^bb2(%0: index): - %1 = alloc(%0) : memref + %1 = memref.alloc(%0) : memref test.buffer_based in(%arg1: memref) out(%1: memref) br ^bb3(%1 : memref) ^bb3(%2: memref): @@ -67,7 +67,7 @@ // CHECK-NEXT: cond_br // CHECK: ^bb2 // CHECK: ^bb2(%[[IDX:.*]]:{{.*}}) -// CHECK-NEXT: %[[ALLOC0:.*]] = alloc(%[[IDX]]) +// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc(%[[IDX]]) // CHECK-NEXT: test.buffer_based // CHECK: br ^bb3 // CHECK-NEXT: ^bb3(%[[ALLOC0:.*]]:{{.*}}) @@ -79,35 +79,35 @@ // CHECK-LABEL: func @dynamicRanked func @dynamicRanked(%tensor: tensor<*xf32>) { %0 = rank %tensor : tensor<*xf32> - %1 = alloc(%0) : memref + %1 = memref.alloc(%0) : memref return } // CHECK-NEXT: %[[RANK:.*]] = rank -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca(%[[RANK]]) +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca(%[[RANK]]) // ----- // CHECK-LABEL: func @dynamicRanked2D func @dynamicRanked2D(%tensor: tensor<*xf32>) { %0 = rank %tensor : tensor<*xf32> - %1 = alloc(%0, %0) : memref + %1 = memref.alloc(%0, %0) : memref return } // CHECK-NEXT: %[[RANK:.*]] = rank -// RANK-NEXT: %[[ALLOC:.*]] = alloca(%[[RANK]], %[[RANK]]) -// DEFINDEX-NEXT: %[[ALLOC:.*]] = alloc(%[[RANK]], %[[RANK]]) +// RANK-NEXT: %[[ALLOC:.*]] = memref.alloca(%[[RANK]], %[[RANK]]) +// DEFINDEX-NEXT: %[[ALLOC:.*]] = memref.alloc(%[[RANK]], %[[RANK]]) // ----- // CHECK-LABEL: func @dynamicNoRank func @dynamicNoRank(%arg0: index) { - %0 = alloc(%arg0) : memref + %0 = memref.alloc(%arg0) : memref return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc // ----- @@ -117,10 +117,10 @@ // CHECK-LABEL: func @emptyUsesValue func @emptyUsesValue(%arg0: memref<4xf32>) { - %0 = alloc() : memref<4xf32> + %0 = memref.alloc() : memref<4xf32> return } -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: return // ----- @@ -138,7 +138,7 @@ func @criticalEdge(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { cond_br %arg0, ^bb1, ^bb2(%arg1 : memref<2xf32>) ^bb1: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) br ^bb2(%0 : memref<2xf32>) ^bb2(%1: memref<2xf32>): @@ -148,7 +148,7 @@ // CHECK-NEXT: cond_br {{.*}} // CHECK: ^bb1 -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK: test.copy // CHECK-NEXT: return @@ -164,7 +164,7 @@ // CHECK-LABEL: func @invCriticalEdge func @invCriticalEdge(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1, ^bb2(%arg1 : memref<2xf32>) ^bb1: @@ -174,7 +174,7 @@ return } -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK: cond_br // CHECK: test.copy // CHECK-NEXT: return @@ -191,7 +191,7 @@ // CHECK-LABEL: func @ifElse func @ifElse(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -201,15 +201,15 @@ ^bb2(%3: memref<2xf32>, %4: memref<2xf32>): br ^bb3(%3, %4 : memref<2xf32>, memref<2xf32>) ^bb3(%5: memref<2xf32>, %6: memref<2xf32>): - %7 = alloc() : memref<2xf32> + %7 = memref.alloc() : memref<2xf32> test.buffer_based in(%5: memref<2xf32>) out(%7: memref<2xf32>) test.copy(%7, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOCA0:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA0:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOCA1:.*]] = alloca() +// CHECK: %[[ALLOCA1:.*]] = memref.alloca() // CHECK: test.buffer_based // CHECK: test.copy(%[[ALLOCA1]] // CHECK-NEXT: return @@ -226,7 +226,7 @@ // CHECK-LABEL: func @ifElseNoUsers func @ifElseNoUsers(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -240,7 +240,7 @@ return } -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK: return // ----- @@ -259,7 +259,7 @@ // CHECK-LABEL: func @ifElseNested func @ifElseNested(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) cond_br %arg0, ^bb1(%arg1, %0 : memref<2xf32>, memref<2xf32>), @@ -273,15 +273,15 @@ ^bb4(%6: memref<2xf32>): br ^bb5(%3, %6 : memref<2xf32>, memref<2xf32>) ^bb5(%7: memref<2xf32>, %8: memref<2xf32>): - %9 = alloc() : memref<2xf32> + %9 = memref.alloc() : memref<2xf32> test.buffer_based in(%7: memref<2xf32>) out(%9: memref<2xf32>) test.copy(%9, %arg2) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOCA0:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA0:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based -// CHECK: %[[ALLOCA1:.*]] = alloca() +// CHECK: %[[ALLOCA1:.*]] = memref.alloca() // CHECK: test.buffer_based // CHECK: test.copy(%[[ALLOCA1]] // CHECK-NEXT: return @@ -294,17 +294,17 @@ // CHECK-LABEL: func @redundantOperations func @redundantOperations(%arg0: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%0: memref<2xf32>) out(%1: memref<2xf32>) return } // CHECK: (%[[ARG0:.*]]: {{.*}}) -// CHECK-NEXT: %[[ALLOCA0:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA0:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based in(%[[ARG0]]{{.*}} out(%[[ALLOCA0]] -// CHECK: %[[ALLOCA1:.*]] = alloca() +// CHECK: %[[ALLOCA1:.*]] = memref.alloca() // CHECK-NEXT: test.buffer_based in(%[[ALLOCA0]]{{.*}} out(%[[ALLOCA1]] // CHECK: return @@ -326,11 +326,11 @@ %arg1: memref<2xf32>) { cond_br %cond, ^bb1, ^bb2 ^bb1: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%0: memref<2xf32>) br ^exit(%0 : memref<2xf32>) ^bb2: - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg0: memref<2xf32>) out(%1: memref<2xf32>) br ^exit(%1 : memref<2xf32>) ^exit(%arg2: memref<2xf32>): @@ -340,9 +340,9 @@ // CHECK-NEXT: cond_br {{.*}} // CHECK: ^bb1 -// CHECK-NEXT: %{{.*}} = alloca() +// CHECK-NEXT: %{{.*}} = memref.alloca() // CHECK: ^bb2 -// CHECK-NEXT: %{{.*}} = alloca() +// CHECK-NEXT: %{{.*}} = memref.alloca() // CHECK: test.copy // CHECK-NEXT: return @@ -362,10 +362,10 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> test.region_buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>) { ^bb0(%gen1_arg0: f32, %gen1_arg1: f32): - %1 = alloc() : memref<2xf32> + %1 = memref.alloc() : memref<2xf32> test.buffer_based in(%arg1: memref<2xf32>) out(%1: memref<2xf32>) %tmp1 = math.exp %gen1_arg0 : f32 test.region_yield %tmp1 : f32 @@ -378,9 +378,9 @@ // CHECK-NEXT: cond_br {{.*}} // CHECK: ^bb2 -// CHECK-NEXT: %[[ALLOCA0:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA0:.*]] = memref.alloca() // CHECK: ^bb0 -// CHECK-NEXT: %[[ALLOCA1:.*]] = alloc() +// CHECK-NEXT: %[[ALLOCA1:.*]] = memref.alloc() // ----- @@ -394,16 +394,16 @@ %arg0: memref<5xf32>, %arg1: memref<10xf32>, %arg2: memref<5xf32>) -> (memref<10xf32>, memref<15xf32>) { - %x = alloc() : memref<15xf32> - %y = alloc() : memref<5xf32> + %x = memref.alloc() : memref<15xf32> + %y = memref.alloc() : memref<5xf32> test.buffer_based in(%arg0: memref<5xf32>) out(%y: memref<5xf32>) test.copy(%y, %arg2) : (memref<5xf32>, memref<5xf32>) return %arg1, %x : memref<10xf32>, memref<15xf32> } // CHECK: (%[[ARG0:.*]]: memref<5xf32>, %[[ARG1:.*]]: memref<10xf32>, // CHECK-SAME: %[[RESULT:.*]]: memref<5xf32>) -// CHECK: %[[ALLOC:.*]] = alloc() -// CHECK: %[[ALLOCA:.*]] = alloca() +// CHECK: %[[ALLOC:.*]] = memref.alloc() +// CHECK: %[[ALLOCA:.*]] = memref.alloca() // CHECK: test.copy // CHECK: return %[[ARG1]], %[[ALLOC]] @@ -418,20 +418,20 @@ %arg0 : index, %arg1 : index) -> memref { %0 = cmpi eq, %arg0, %arg1 : index - %1 = alloc(%arg0, %arg0) : memref + %1 = memref.alloc(%arg0, %arg0) : memref %2 = scf.if %0 -> (memref) { scf.yield %1 : memref } else { - %3 = alloc(%arg0, %arg1) : memref + %3 = memref.alloc(%arg0, %arg1) : memref scf.yield %1 : memref } return %2 : memref } -// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0) +// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0) // CHECK-NEXT: %[[ALLOC1:.*]] = scf.if // CHECK: scf.yield %[[ALLOC0]] -// CHECK: %[[ALLOC2:.*]] = alloc(%arg0, %arg1) +// CHECK: %[[ALLOC2:.*]] = memref.alloc(%arg0, %arg1) // CHECK-NEXT: scf.yield %[[ALLOC0]] // CHECK: return %[[ALLOC1]] @@ -443,7 +443,7 @@ // CHECK-LABEL: func @inner_region_control_flow func @inner_region_control_flow(%arg0 : index) -> memref<2x2xf32> { - %0 = alloc() : memref<2x2xf32> + %0 = memref.alloc() : memref<2x2xf32> %1 = test.region_if %0 : memref<2x2xf32> -> (memref<2x2xf32>) then { ^bb0(%arg1 : memref<2x2xf32>): test.region_if_yield %arg1 : memref<2x2xf32> @@ -457,7 +457,7 @@ return %1 : memref<2x2xf32> } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: %[[ALLOC1:.*]] = test.region_if // CHECK-NEXT: ^bb0(%[[ALLOC2:.*]]:{{.*}}): // CHECK-NEXT: test.region_if_yield %[[ALLOC2]] @@ -479,20 +479,20 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index - %3 = alloc() : memref<2xf32> + %3 = memref.alloc() : memref<2xf32> scf.yield %3 : memref<2xf32> } test.copy(%1, %res) : (memref<2xf32>, memref<2xf32>) return } -// CHECK-NEXT: %[[ALLOCA:.*]] = alloca() +// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca() // CHECK-NEXT: scf.for -// CHECK: %[[ALLOC:.*]] = alloc() +// CHECK: %[[ALLOC:.*]] = memref.alloc() // ----- @@ -509,7 +509,7 @@ %step: index, %buf: memref<2xf32>, %res: memref<2xf32>) { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index @@ -524,7 +524,7 @@ return } -// CHECK: %[[ALLOCA0:.*]] = alloca() +// CHECK: %[[ALLOCA0:.*]] = memref.alloca() // CHECK-NEXT: %[[ALLOCA1:.*]] = scf.for {{.*}} iter_args(%[[IALLOCA:.*]] = // CHECK: %[[ALLOCA2:.*]] = scf.if // CHECK: scf.yield %[[ALLOCA0]] @@ -544,12 +544,12 @@ %ub: index, %step: index, %buf: memref<2xf32>) -> memref<2xf32> { - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> %1 = scf.for %i = %lb to %ub step %step iter_args(%iterBuf = %buf) -> memref<2xf32> { %2 = cmpi eq, %i, %ub : index %3 = scf.if %2 -> (memref<2xf32>) { - %4 = alloc() : memref<2xf32> + %4 = memref.alloc() : memref<2xf32> scf.yield %4 : memref<2xf32> } else { scf.yield %0 : memref<2xf32> @@ -559,10 +559,10 @@ return %1 : memref<2xf32> } -// CHECK: %[[ALLOC0:.*]] = alloc() +// CHECK: %[[ALLOC0:.*]] = memref.alloc() // CHECK-NEXT: %[[ALLOC1:.*]] = scf.for {{.*}} // CHECK: %[[ALLOC2:.*]] = scf.if -// CHECK: %[[ALLOC3:.*]] = alloc() +// CHECK: %[[ALLOC3:.*]] = memref.alloc() // CHECK-NEXT: scf.yield %[[ALLOC3]] // CHECK: scf.yield %[[ALLOC0]] // CHECK: scf.yield %[[ALLOC2]] @@ -575,12 +575,12 @@ // CHECK-LABEL: func @large_buffer_allocation func @large_buffer_allocation(%arg0: memref<2048xf32>) { - %0 = alloc() : memref<2048xf32> + %0 = memref.alloc() : memref<2048xf32> test.copy(%0, %arg0) : (memref<2048xf32>, memref<2048xf32>) return } -// CHECK-NEXT: %[[ALLOC:.*]] = alloc() +// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc() // CHECK-NEXT: test.copy // ----- @@ -591,11 +591,11 @@ // CHECK-LABEL: func @indexElementType func @indexElementType() { - %0 = alloc() : memref<4xindex> + %0 = memref.alloc() : memref<4xindex> return } -// DEFINDEX-NEXT: alloca() -// BIGINDEX-NEXT: alloca() -// LOWLIMIT-NEXT: alloc() -// RANK-NEXT: alloca() +// DEFINDEX-NEXT: memref.alloca() +// BIGINDEX-NEXT: memref.alloca() +// LOWLIMIT-NEXT: memref.alloc() +// RANK-NEXT: memref.alloca() // CHECK-NEXT: return diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp --- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp @@ -266,17 +266,17 @@ OperationFolder *folder) { SmallVector shape(boundingSubViewSize.size(), -1); return b - .create(subView.getLoc(), - MemRefType::get(shape, - subView.getType().getElementType(), - /*affineMapComposition =*/{}, 3), - boundingSubViewSize) + .create( + subView.getLoc(), + MemRefType::get(shape, subView.getType().getElementType(), + /*affineMapComposition =*/{}, 3), + boundingSubViewSize) .getResult(); } // Deallocation callback static LogicalResult deallocCallBackFn(OpBuilder &b, Value buffer) { - b.create(buffer.getLoc(), buffer); + b.create(buffer.getLoc(), buffer); return success(); } diff --git a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp --- a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp +++ b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/Pass/Pass.h" @@ -23,7 +24,7 @@ /// Traverse AllocOp and compute strides of each MemRefType independently. void TestMemRefStrideCalculation::runOnFunction() { llvm::outs() << "Testing: " << getFunction().getName() << "\n"; - getFunction().walk([&](AllocOp allocOp) { + getFunction().walk([&](memref::AllocOp allocOp) { auto memrefType = allocOp.getResult().getType().cast(); int64_t offset; SmallVector strides; diff --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp --- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp +++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp @@ -11,6 +11,7 @@ #include "mlir/Analysis/SliceAnalysis.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Vector/VectorOps.h" @@ -268,7 +269,7 @@ type.getNumElements() % multiplicity != 0) return mlir::WalkResult::advance(); auto filterAlloc = [](Operation *op) { - if (isa(op)) + if (isa(op)) return false; return true; }; diff --git a/mlir/test/mlir-cpu-runner/async-value.mlir b/mlir/test/mlir-cpu-runner/async-value.mlir --- a/mlir/test/mlir-cpu-runner/async-value.mlir +++ b/mlir/test/mlir-cpu-runner/async-value.mlir @@ -44,13 +44,13 @@ // Memref allocated inside async.execute region. // ------------------------------------------------------------------------ // %token2, %result2 = async.execute[%token0] -> !async.value> { - %5 = alloc() : memref + %5 = memref.alloc() : memref %c0 = constant 0.25 : f32 - store %c0, %5[]: memref + memref.store %c0, %5[]: memref async.yield %5 : memref } %6 = async.await %result2 : !async.value> - %7 = memref_cast %6 : memref to memref<*xf32> + %7 = memref.cast %6 : memref to memref<*xf32> // CHECK: Unranked Memref // CHECK-SAME: rank = 0 offset = 0 sizes = [] strides = [] @@ -63,7 +63,7 @@ %token3 = async.execute(%result2 as %unwrapped : !async.value>) { %8 = load %unwrapped[]: memref %9 = addf %8, %8 : f32 - store %9, %unwrapped[]: memref + memref.store %9, %unwrapped[]: memref async.yield } async.await %token3 : !async.token @@ -73,7 +73,7 @@ // CHECK-NEXT: [0.5] call @print_memref_f32(%7): (memref<*xf32>) -> () - dealloc %6 : memref + memref.dealloc %6 : memref return } diff --git a/mlir/test/mlir-cpu-runner/async.mlir b/mlir/test/mlir-cpu-runner/async.mlir --- a/mlir/test/mlir-cpu-runner/async.mlir +++ b/mlir/test/mlir-cpu-runner/async.mlir @@ -24,23 +24,23 @@ %c3 = constant 3.0 : f32 %c4 = constant 4.0 : f32 - %A = alloc() : memref<4xf32> + %A = memref.alloc() : memref<4xf32> linalg.fill(%A, %c0) : memref<4xf32>, f32 // CHECK: [0, 0, 0, 0] - %U = memref_cast %A : memref<4xf32> to memref<*xf32> + %U = memref.cast %A : memref<4xf32> to memref<*xf32> call @print_memref_f32(%U): (memref<*xf32>) -> () // CHECK: Current thread id: [[MAIN:.*]] // CHECK: [1, 0, 0, 0] - store %c1, %A[%i0]: memref<4xf32> + memref.store %c1, %A[%i0]: memref<4xf32> call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () call @print_memref_f32(%U): (memref<*xf32>) -> () %outer = async.execute { // CHECK: Current thread id: [[THREAD0:.*]] // CHECK: [1, 2, 0, 0] - store %c2, %A[%i1]: memref<4xf32> + memref.store %c2, %A[%i1]: memref<4xf32> call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () call @print_memref_f32(%U): (memref<*xf32>) -> () @@ -54,7 +54,7 @@ %inner = async.execute [%noop] { // CHECK: Current thread id: [[THREAD2:.*]] // CHECK: [1, 2, 3, 0] - store %c3, %A[%i2]: memref<4xf32> + memref.store %c3, %A[%i2]: memref<4xf32> call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () call @print_memref_f32(%U): (memref<*xf32>) -> () @@ -64,7 +64,7 @@ // CHECK: Current thread id: [[THREAD3:.*]] // CHECK: [1, 2, 3, 4] - store %c4, %A[%i3]: memref<4xf32> + memref.store %c4, %A[%i3]: memref<4xf32> call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () call @print_memref_f32(%U): (memref<*xf32>) -> () @@ -77,7 +77,7 @@ call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () call @print_memref_f32(%U): (memref<*xf32>) -> () - dealloc %A : memref<4xf32> + memref.dealloc %A : memref<4xf32> return } diff --git a/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir b/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir --- a/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir +++ b/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir @@ -14,12 +14,12 @@ scf.for %arg2 = %c0 to %c2 step %c1 { %0 = load %arg0[%arg2] : memref<2xf32> %1 = addf %0, %cst : f32 - store %1, %arg0[%arg2] : memref<2xf32> + memref.store %1, %arg0[%arg2] : memref<2xf32> // CHECK: 2, 2 %2 = load %arg1[%arg2] : memref<2xf32> %3 = addf %1, %cst_0 : f32 - store %3, %arg1[%arg2] : memref<2xf32> + memref.store %3, %arg1[%arg2] : memref<2xf32> // CHECK-NEXT: 4, 4 } return @@ -39,11 +39,11 @@ %c1 = constant 1 : index %cst = constant 1.000000e+00 : f32 %cst_0 = constant 2.000000e+00 : f32 - %a = alloc() : memref<2xf32> - %b = alloc() : memref<2xf32> + %a = memref.alloc() : memref<2xf32> + %b = memref.alloc() : memref<2xf32> scf.for %i = %c0 to %c2 step %c1 { - store %cst, %a[%i] : memref<2xf32> - store %cst, %b[%i] : memref<2xf32> + memref.store %cst, %a[%i] : memref<2xf32> + memref.store %cst, %b[%i] : memref<2xf32> } call @simple_add1_add2_test(%a, %b) : (memref<2xf32>, memref<2xf32>) -> () @@ -62,7 +62,7 @@ call @printF32(%l3) : (f32) -> () call @printNewline() : () -> () - dealloc %a : memref<2xf32> - dealloc %b : memref<2xf32> + memref.dealloc %a : memref<2xf32> + memref.dealloc %b : memref<2xf32> return } diff --git a/mlir/test/mlir-cpu-runner/global_memref.mlir b/mlir/test/mlir-cpu-runner/global_memref.mlir --- a/mlir/test/mlir-cpu-runner/global_memref.mlir +++ b/mlir/test/mlir-cpu-runner/global_memref.mlir @@ -4,10 +4,10 @@ func private @print_memref_i32(memref<*xi32>) attributes { llvm.emit_c_interface } func private @printNewline() -> () -global_memref "private" @gv0 : memref<4xf32> = dense<[0.0, 1.0, 2.0, 3.0]> +memref.global "private" @gv0 : memref<4xf32> = dense<[0.0, 1.0, 2.0, 3.0]> func @test1DMemref() { - %0 = get_global_memref @gv0 : memref<4xf32> - %U = memref_cast %0 : memref<4xf32> to memref<*xf32> + %0 = memref.get_global @gv0 : memref<4xf32> + %U = memref.cast %0 : memref<4xf32> to memref<*xf32> // CHECK: rank = 1 // CHECK: offset = 0 // CHECK: sizes = [4] @@ -21,8 +21,8 @@ %c2 = constant 2 : index %fp0 = constant 4.0 : f32 %fp1 = constant 5.0 : f32 - store %fp0, %0[%c0] : memref<4xf32> - store %fp1, %0[%c2] : memref<4xf32> + memref.store %fp0, %0[%c0] : memref<4xf32> + memref.store %fp1, %0[%c2] : memref<4xf32> // CHECK: rank = 1 // CHECK: offset = 0 // CHECK: sizes = [4] @@ -33,10 +33,10 @@ return } -global_memref constant @gv1 : memref<3x2xi32> = dense<[[0, 1],[2, 3],[4, 5]]> +memref.global constant @gv1 : memref<3x2xi32> = dense<[[0, 1],[2, 3],[4, 5]]> func @testConstantMemref() { - %0 = get_global_memref @gv1 : memref<3x2xi32> - %U = memref_cast %0 : memref<3x2xi32> to memref<*xi32> + %0 = memref.get_global @gv1 : memref<3x2xi32> + %U = memref.cast %0 : memref<3x2xi32> to memref<*xi32> // CHECK: rank = 2 // CHECK: offset = 0 // CHECK: sizes = [3, 2] @@ -49,10 +49,10 @@ return } -global_memref "private" @gv2 : memref<4x2xf32> = dense<[[0.0, 1.0], [2.0, 3.0], [4.0, 5.0], [6.0, 7.0]]> +memref.global "private" @gv2 : memref<4x2xf32> = dense<[[0.0, 1.0], [2.0, 3.0], [4.0, 5.0], [6.0, 7.0]]> func @test2DMemref() { - %0 = get_global_memref @gv2 : memref<4x2xf32> - %U = memref_cast %0 : memref<4x2xf32> to memref<*xf32> + %0 = memref.get_global @gv2 : memref<4x2xf32> + %U = memref.cast %0 : memref<4x2xf32> to memref<*xf32> // CHECK: rank = 2 // CHECK: offset = 0 // CHECK: sizes = [4, 2] @@ -68,7 +68,7 @@ %c0 = constant 0 : index %c1 = constant 1 : index %fp10 = constant 10.0 : f32 - store %fp10, %0[%c0, %c1] : memref<4x2xf32> + memref.store %fp10, %0[%c0, %c1] : memref<4x2xf32> // CHECK: rank = 2 // CHECK: offset = 0 // CHECK: sizes = [4, 2] @@ -82,10 +82,10 @@ return } -global_memref @gv3 : memref = dense<11> +memref.global @gv3 : memref = dense<11> func @testScalarMemref() { - %0 = get_global_memref @gv3 : memref - %U = memref_cast %0 : memref to memref<*xi32> + %0 = memref.get_global @gv3 : memref + %U = memref.cast %0 : memref to memref<*xi32> // CHECK: rank = 0 // CHECK: offset = 0 // CHECK: sizes = [] diff --git a/mlir/test/mlir-cpu-runner/memref_reinterpret_cast.mlir b/mlir/test/mlir-cpu-runner/memref_reinterpret_cast.mlir --- a/mlir/test/mlir-cpu-runner/memref_reinterpret_cast.mlir +++ b/mlir/test/mlir-cpu-runner/memref_reinterpret_cast.mlir @@ -10,7 +10,7 @@ %c1 = constant 1 : index // Initialize input. - %input = alloc() : memref<2x3xf32> + %input = memref.alloc() : memref<2x3xf32> %dim_x = dim %input, %c0 : memref<2x3xf32> %dim_y = dim %input, %c1 : memref<2x3xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%dim_x, %dim_y) step (%c1, %c1) { @@ -18,9 +18,9 @@ %val = addi %prod, %j : index %val_i64 = index_cast %val : index to i64 %val_f32 = sitofp %val_i64 : i64 to f32 - store %val_f32, %input[%i, %j] : memref<2x3xf32> + memref.store %val_f32, %input[%i, %j] : memref<2x3xf32> } - %unranked_input = memref_cast %input : memref<2x3xf32> to memref<*xf32> + %unranked_input = memref.cast %input : memref<2x3xf32> to memref<*xf32> call @print_memref_f32(%unranked_input) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [2, 3] strides = [3, 1] // CHECK-NEXT: [0, 1, 2] @@ -39,7 +39,7 @@ offset: [0], sizes: [6, 1], strides: [1, 1] : memref<2x3xf32> to memref<6x1xf32> - %unranked_output = memref_cast %output + %unranked_output = memref.cast %output : memref<6x1xf32> to memref<*xf32> call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [6, 1] strides = [1, 1] data = @@ -60,7 +60,7 @@ offset: [%c0], sizes: [%c1, %c6], strides: [%c6, %c1] : memref<2x3xf32> to memref - %unranked_output = memref_cast %output + %unranked_output = memref.cast %output : memref to memref<*xf32> call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [1, 6] strides = [6, 1] data = @@ -69,12 +69,12 @@ } func @cast_unranked_memref_to_static_shape(%input : memref<2x3xf32>) { - %unranked_input = memref_cast %input : memref<2x3xf32> to memref<*xf32> + %unranked_input = memref.cast %input : memref<2x3xf32> to memref<*xf32> %output = memref_reinterpret_cast %unranked_input to offset: [0], sizes: [6, 1], strides: [1, 1] : memref<*xf32> to memref<6x1xf32> - %unranked_output = memref_cast %output + %unranked_output = memref.cast %output : memref<6x1xf32> to memref<*xf32> call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [6, 1] strides = [1, 1] data = @@ -88,7 +88,7 @@ } func @cast_unranked_memref_to_dynamic_shape(%input : memref<2x3xf32>) { - %unranked_input = memref_cast %input : memref<2x3xf32> to memref<*xf32> + %unranked_input = memref.cast %input : memref<2x3xf32> to memref<*xf32> %c0 = constant 0 : index %c1 = constant 1 : index %c6 = constant 6 : index @@ -96,7 +96,7 @@ offset: [%c0], sizes: [%c1, %c6], strides: [%c6, %c1] : memref<*xf32> to memref - %unranked_output = memref_cast %output + %unranked_output = memref.cast %output : memref to memref<*xf32> call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [1, 6] strides = [6, 1] data = diff --git a/mlir/test/mlir-cpu-runner/memref_reshape.mlir b/mlir/test/mlir-cpu-runner/memref_reshape.mlir --- a/mlir/test/mlir-cpu-runner/memref_reshape.mlir +++ b/mlir/test/mlir-cpu-runner/memref_reshape.mlir @@ -11,7 +11,7 @@ %c1 = constant 1 : index // Initialize input. - %input = alloc() : memref<2x3xf32> + %input = memref.alloc() : memref<2x3xf32> %dim_x = dim %input, %c0 : memref<2x3xf32> %dim_y = dim %input, %c1 : memref<2x3xf32> scf.parallel (%i, %j) = (%c0, %c0) to (%dim_x, %dim_y) step (%c1, %c1) { @@ -19,20 +19,20 @@ %val = addi %prod, %j : index %val_i64 = index_cast %val : index to i64 %val_f32 = sitofp %val_i64 : i64 to f32 - store %val_f32, %input[%i, %j] : memref<2x3xf32> + memref.store %val_f32, %input[%i, %j] : memref<2x3xf32> } - %unranked_input = memref_cast %input : memref<2x3xf32> to memref<*xf32> + %unranked_input = memref.cast %input : memref<2x3xf32> to memref<*xf32> call @print_memref_f32(%unranked_input) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [2, 3] strides = [3, 1] // CHECK-NEXT: [0, 1, 2] // CHECK-NEXT: [3, 4, 5] // Initialize shape. - %shape = alloc() : memref<2xindex> + %shape = memref.alloc() : memref<2xindex> %c2 = constant 2 : index %c3 = constant 3 : index - store %c3, %shape[%c0] : memref<2xindex> - store %c2, %shape[%c1] : memref<2xindex> + memref.store %c3, %shape[%c0] : memref<2xindex> + memref.store %c2, %shape[%c1] : memref<2xindex> // Test cases. call @reshape_ranked_memref_to_ranked(%input, %shape) @@ -51,7 +51,7 @@ %output = memref_reshape %input(%shape) : (memref<2x3xf32>, memref<2xindex>) -> memref - %unranked_output = memref_cast %output : memref to memref<*xf32> + %unranked_output = memref.cast %output : memref to memref<*xf32> call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [3, 2] strides = [2, 1] data = // CHECK: [0, 1], @@ -62,11 +62,11 @@ func @reshape_unranked_memref_to_ranked(%input : memref<2x3xf32>, %shape : memref<2xindex>) { - %unranked_input = memref_cast %input : memref<2x3xf32> to memref<*xf32> + %unranked_input = memref.cast %input : memref<2x3xf32> to memref<*xf32> %output = memref_reshape %input(%shape) : (memref<2x3xf32>, memref<2xindex>) -> memref - %unranked_output = memref_cast %output : memref to memref<*xf32> + %unranked_output = memref.cast %output : memref to memref<*xf32> call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> () // CHECK: rank = 2 offset = 0 sizes = [3, 2] strides = [2, 1] data = // CHECK: [0, 1], @@ -77,7 +77,7 @@ func @reshape_ranked_memref_to_unranked(%input : memref<2x3xf32>, %shape : memref<2xindex>) { - %dyn_size_shape = memref_cast %shape : memref<2xindex> to memref + %dyn_size_shape = memref.cast %shape : memref<2xindex> to memref %output = memref_reshape %input(%dyn_size_shape) : (memref<2x3xf32>, memref) -> memref<*xf32> @@ -91,8 +91,8 @@ func @reshape_unranked_memref_to_unranked(%input : memref<2x3xf32>, %shape : memref<2xindex>) { - %unranked_input = memref_cast %input : memref<2x3xf32> to memref<*xf32> - %dyn_size_shape = memref_cast %shape : memref<2xindex> to memref + %unranked_input = memref.cast %input : memref<2x3xf32> to memref<*xf32> + %dyn_size_shape = memref.cast %shape : memref<2xindex> to memref %output = memref_reshape %input(%dyn_size_shape) : (memref<2x3xf32>, memref) -> memref<*xf32> diff --git a/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir b/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir --- a/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir +++ b/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir @@ -1,9 +1,9 @@ // RUN: mlir-opt -convert-linalg-to-loops -lower-affine -convert-scf-to-std -convert-vector-to-llvm -convert-std-to-llvm %s | mlir-cpu-runner -O3 -e main -entry-point-result=void -shared-libs=%mlir_runner_utils_dir/libmlir_c_runner_utils%shlibext | FileCheck %s func @main() { - %A = alloc() : memref<16x16xf32> - %B = alloc() : memref<16x16xf32> - %C = alloc() : memref<16x16xf32> + %A = memref.alloc() : memref<16x16xf32> + %B = memref.alloc() : memref<16x16xf32> + %C = memref.alloc() : memref<16x16xf32> %cf1 = constant 1.00000e+00 : f32 @@ -50,7 +50,7 @@ %c0 = constant 0 : index affine.for %arg3 = 0 to 16 { affine.for %arg4 = 0 to 16 { - %m = alloc() : memref<1xf32> + %m = memref.alloc() : memref<1xf32> %v = affine.load %arg2[%arg3, %arg4] : memref<16x16xf32> affine.store %v, %m[%c0] : memref<1xf32> affine.for %arg5 = 0 to 16 { @@ -63,7 +63,7 @@ } %s = affine.load %m[%c0] : memref<1xf32> affine.store %s, %arg2[%arg3, %arg4] : memref<16x16xf32> - dealloc %m : memref<1xf32> + memref.dealloc %m : memref<1xf32> } } return diff --git a/mlir/test/mlir-cpu-runner/unranked_memref.mlir b/mlir/test/mlir-cpu-runner/unranked_memref.mlir --- a/mlir/test/mlir-cpu-runner/unranked_memref.mlir +++ b/mlir/test/mlir-cpu-runner/unranked_memref.mlir @@ -39,35 +39,35 @@ // CHECK-SAME: strides = [3, 1] // CHECK-COUNT-4: [1, 1, 1] func @main() -> () { - %A = alloc() : memref<10x3xf32, 0> + %A = memref.alloc() : memref<10x3xf32, 0> %f2 = constant 2.00000e+00 : f32 %f5 = constant 5.00000e+00 : f32 %f10 = constant 10.00000e+00 : f32 - %V = memref_cast %A : memref<10x3xf32, 0> to memref + %V = memref.cast %A : memref<10x3xf32, 0> to memref linalg.fill(%V, %f10) : memref, f32 - %U = memref_cast %A : memref<10x3xf32, 0> to memref<*xf32> + %U = memref.cast %A : memref<10x3xf32, 0> to memref<*xf32> call @print_memref_f32(%U) : (memref<*xf32>) -> () - %V2 = memref_cast %U : memref<*xf32> to memref + %V2 = memref.cast %U : memref<*xf32> to memref linalg.fill(%V2, %f5) : memref, f32 - %U2 = memref_cast %V2 : memref to memref<*xf32> + %U2 = memref.cast %V2 : memref to memref<*xf32> call @print_memref_f32(%U2) : (memref<*xf32>) -> () - %V3 = memref_cast %V2 : memref to memref<*xf32> - %V4 = memref_cast %V3 : memref<*xf32> to memref + %V3 = memref.cast %V2 : memref to memref<*xf32> + %V4 = memref.cast %V3 : memref<*xf32> to memref linalg.fill(%V4, %f2) : memref, f32 - %U3 = memref_cast %V2 : memref to memref<*xf32> + %U3 = memref.cast %V2 : memref to memref<*xf32> call @print_memref_f32(%U3) : (memref<*xf32>) -> () // 122 is ASCII for 'z'. %i8_z = constant 122 : i8 - %I8 = alloc() : memref - store %i8_z, %I8[]: memref - %U4 = memref_cast %I8 : memref to memref<*xi8> + %I8 = memref.alloc() : memref + memref.store %i8_z, %I8[]: memref + %U4 = memref.cast %I8 : memref to memref<*xi8> call @print_memref_i8(%U4) : (memref<*xi8>) -> () - dealloc %A : memref<10x3xf32, 0> + memref.dealloc %A : memref<10x3xf32, 0> call @return_var_memref_caller() : () -> () call @return_two_var_memref_caller() : () -> () @@ -79,7 +79,7 @@ func private @print_memref_f32(memref<*xf32>) attributes { llvm.emit_c_interface } func @return_two_var_memref_caller() { - %0 = alloca() : memref<4x3xf32> + %0 = memref.alloca() : memref<4x3xf32> %c0f32 = constant 1.0 : f32 linalg.fill(%0, %c0f32) : memref<4x3xf32>, f32 %1:2 = call @return_two_var_memref(%0) : (memref<4x3xf32>) -> (memref<*xf32>, memref<*xf32>) @@ -89,12 +89,12 @@ } func @return_two_var_memref(%arg0: memref<4x3xf32>) -> (memref<*xf32>, memref<*xf32>) { - %0 = memref_cast %arg0 : memref<4x3xf32> to memref<*xf32> + %0 = memref.cast %arg0 : memref<4x3xf32> to memref<*xf32> return %0, %0 : memref<*xf32>, memref<*xf32> } func @return_var_memref_caller() { - %0 = alloca() : memref<4x3xf32> + %0 = memref.alloca() : memref<4x3xf32> %c0f32 = constant 1.0 : f32 linalg.fill(%0, %c0f32) : memref<4x3xf32>, f32 %1 = call @return_var_memref(%0) : (memref<4x3xf32>) -> memref<*xf32> @@ -103,7 +103,7 @@ } func @return_var_memref(%arg0: memref<4x3xf32>) -> memref<*xf32> { - %0 = memref_cast %arg0: memref<4x3xf32> to memref<*xf32> + %0 = memref.cast %arg0: memref<4x3xf32> to memref<*xf32> return %0 : memref<*xf32> } @@ -111,8 +111,8 @@ func private @printNewline() -> () func @dim_op_of_unranked() { - %ranked = alloc() : memref<4x3xf32> - %unranked = memref_cast %ranked: memref<4x3xf32> to memref<*xf32> + %ranked = memref.alloc() : memref<4x3xf32> + %unranked = memref.cast %ranked: memref<4x3xf32> to memref<*xf32> %c0 = constant 0 : index %dim_0 = dim %unranked, %c0 : memref<*xf32> diff --git a/mlir/test/mlir-cpu-runner/utils.mlir b/mlir/test/mlir-cpu-runner/utils.mlir --- a/mlir/test/mlir-cpu-runner/utils.mlir +++ b/mlir/test/mlir-cpu-runner/utils.mlir @@ -5,11 +5,11 @@ func @print_0d() { %f = constant 2.00000e+00 : f32 - %A = alloc() : memref - store %f, %A[]: memref - %U = memref_cast %A : memref to memref<*xf32> + %A = memref.alloc() : memref + memref.store %f, %A[]: memref + %U = memref.cast %A : memref to memref<*xf32> call @print_memref_f32(%U): (memref<*xf32>) -> () - dealloc %A : memref + memref.dealloc %A : memref return } // PRINT-0D: Unranked Memref base@ = {{.*}} rank = 0 offset = 0 sizes = [] strides = [] data = @@ -17,12 +17,12 @@ func @print_1d() { %f = constant 2.00000e+00 : f32 - %A = alloc() : memref<16xf32> - %B = memref_cast %A: memref<16xf32> to memref + %A = memref.alloc() : memref<16xf32> + %B = memref.cast %A: memref<16xf32> to memref linalg.fill(%B, %f) : memref, f32 - %U = memref_cast %B : memref to memref<*xf32> + %U = memref.cast %B : memref to memref<*xf32> call @print_memref_f32(%U): (memref<*xf32>) -> () - dealloc %A : memref<16xf32> + memref.dealloc %A : memref<16xf32> return } // PRINT-1D: Unranked Memref base@ = {{.*}} rank = 1 offset = 0 sizes = [16] strides = [1] data = @@ -31,15 +31,15 @@ func @print_3d() { %f = constant 2.00000e+00 : f32 %f4 = constant 4.00000e+00 : f32 - %A = alloc() : memref<3x4x5xf32> - %B = memref_cast %A: memref<3x4x5xf32> to memref + %A = memref.alloc() : memref<3x4x5xf32> + %B = memref.cast %A: memref<3x4x5xf32> to memref linalg.fill(%B, %f) : memref, f32 %c2 = constant 2 : index - store %f4, %B[%c2, %c2, %c2]: memref - %U = memref_cast %B : memref to memref<*xf32> + memref.store %f4, %B[%c2, %c2, %c2]: memref + %U = memref.cast %B : memref to memref<*xf32> call @print_memref_f32(%U): (memref<*xf32>) -> () - dealloc %A : memref<3x4x5xf32> + memref.dealloc %A : memref<3x4x5xf32> return } // PRINT-3D: Unranked Memref base@ = {{.*}} rank = 3 offset = 0 sizes = [3, 4, 5] strides = [20, 5, 1] data = @@ -57,13 +57,13 @@ %c0 = constant 0 : index %f10 = constant 10.0 : f32 %vf10 = splat %f10: !vector_type_C - %C = alloc() : !matrix_type_CC - store %vf10, %C[%c0, %c0]: !matrix_type_CC + %C = memref.alloc() : !matrix_type_CC + memref.store %vf10, %C[%c0, %c0]: !matrix_type_CC - %CC = memref_cast %C: !matrix_type_CC to memref + %CC = memref.cast %C: !matrix_type_CC to memref call @print_memref_vector_4x4xf32(%CC): (memref) -> () - dealloc %C : !matrix_type_CC + memref.dealloc %C : !matrix_type_CC return } diff --git a/mlir/test/mlir-opt/commandline.mlir b/mlir/test/mlir-opt/commandline.mlir --- a/mlir/test/mlir-opt/commandline.mlir +++ b/mlir/test/mlir-opt/commandline.mlir @@ -14,6 +14,7 @@ // CHECK-NEXT: llvm_arm_sve // CHECK-NEXT: llvm_avx512 // CHECK-NEXT: math +// CHECK-NEXT: memref // CHECK-NEXT: nvvm // CHECK-NEXT: omp // CHECK-NEXT: pdl diff --git a/mlir/test/mlir-reduce/multiple-function.mlir b/mlir/test/mlir-reduce/multiple-function.mlir --- a/mlir/test/mlir-reduce/multiple-function.mlir +++ b/mlir/test/mlir-reduce/multiple-function.mlir @@ -1,7 +1,7 @@ // UNSUPPORTED: system-windows // RUN: mlir-reduce %s -test %S/failure-test.sh -pass-test function-reducer | FileCheck %s -// This input should be reduced by the pass pipeline so that only -// the @simple5 function remains as this is the shortest function +// This input should be reduced by the pass pipeline so that only +// the @simple5 function remains as this is the shortest function // containing the interesting behavior. // CHECK-NOT: func @simple1() { @@ -26,7 +26,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): "test.crashOp"(%1, %arg2) : (memref<2xf32>, memref<2xf32>) -> () diff --git a/mlir/test/mlir-reduce/simple-test.mlir b/mlir/test/mlir-reduce/simple-test.mlir --- a/mlir/test/mlir-reduce/simple-test.mlir +++ b/mlir/test/mlir-reduce/simple-test.mlir @@ -6,7 +6,7 @@ ^bb1: br ^bb3(%arg1 : memref<2xf32>) ^bb2: - %0 = alloc() : memref<2xf32> + %0 = memref.alloc() : memref<2xf32> br ^bb3(%0 : memref<2xf32>) ^bb3(%1: memref<2xf32>): return diff --git a/mlir/unittests/ExecutionEngine/Invoke.cpp b/mlir/unittests/ExecutionEngine/Invoke.cpp --- a/mlir/unittests/ExecutionEngine/Invoke.cpp +++ b/mlir/unittests/ExecutionEngine/Invoke.cpp @@ -103,7 +103,7 @@ std::string moduleStr = R"mlir( func @zero_ranked(%arg0 : memref) attributes { llvm.emit_c_interface } { %cst42 = constant 42.0 : f32 - store %cst42, %arg0[] : memref + memref.store %cst42, %arg0[] : memref return } )mlir"; @@ -138,7 +138,7 @@ func @one_ranked(%arg0 : memref) attributes { llvm.emit_c_interface } { %cst42 = constant 42.0 : f32 %cst5 = constant 5 : index - store %cst42, %arg0[%cst5] : memref + memref.store %cst42, %arg0[%cst5] : memref return } )mlir"; @@ -191,8 +191,8 @@ %x = constant 2 : index %y = constant 1 : index %cst42 = constant 42.0 : f32 - store %cst42, %arg0[%y, %x] : memref - store %cst42, %arg1[%x, %y] : memref + memref.store %cst42, %arg0[%y, %x] : memref + memref.store %cst42, %arg1[%x, %y] : memref return } )mlir"; @@ -231,9 +231,9 @@ elt = count++; std::string moduleStr = R"mlir( - func private @callback(%arg0: memref, %coefficient: i32) attributes { llvm.emit_c_interface } + func private @callback(%arg0: memref, %coefficient: i32) attributes { llvm.emit_c_interface } func @caller_for_callback(%arg0: memref, %coefficient: i32) attributes { llvm.emit_c_interface } { - %unranked = memref_cast %arg0: memref to memref<*xf32> + %unranked = memref.cast %arg0: memref to memref<*xf32> call @callback(%arg0, %coefficient) : (memref, i32) -> () return }