## 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.
#map0 = affine_map<(d0, d1)[s0, s1, s2] -> (d0 * s1 + s0 + d1 * s2)>
func @example(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) {
- %0 = memref_cast %arg0 : memref<?x?xf32> to memref<?x?xf32, #map0>
- %1 = memref_cast %arg1 : memref<?x?xf32> to memref<?x?xf32, #map0>
- %2 = memref_cast %arg2 : memref<?x?xf32> to memref<?x?xf32, #map0>
+ %0 = memref.cast %arg0 : memref<?x?xf32> to memref<?x?xf32, #map0>
+ %1 = memref.cast %arg1 : memref<?x?xf32> to memref<?x?xf32, #map0>
+ %2 = memref.cast %arg2 : memref<?x?xf32> to memref<?x?xf32, #map0>
call @pointwise_add(%0, %1, %2) : (memref<?x?xf32, #map0>, memref<?x?xf32, #map0>, memref<?x?xf32, #map0>) -> ()
return
}
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`,
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.
#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"
/// Insert an allocation and deallocation for the given MemRefType.
static Value insertAllocAndDealloc(MemRefType type, Location loc,
PatternRewriter &rewriter) {
- auto alloc = rewriter.create<AllocOp>(loc, type);
+ auto alloc = rewriter.create<memref::AllocOp>(loc, type);
// Make sure to allocate at the beginning of the block.
auto *parentBlock = alloc->getBlock();
// 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<DeallocOp>(loc, alloc);
+ auto dealloc = rewriter.create<memref::DeallocOp>(loc, alloc);
dealloc->moveBefore(&parentBlock->back());
return alloc;
}
if (!valueShape.empty()) {
for (auto i : llvm::seq<int64_t>(
- 0, *std::max_element(valueShape.begin(), valueShape.end())))
- constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, i));
+ 0, *std::max_element(valueShape.begin(), valueShape.end())))
+ constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, i));
} else {
// This is the case of a tensor of rank 0.
constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, 0));
// 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<AffineDialect, StandardOpsDialect>();
+ target.addLegalDialect<AffineDialect, memref::MemRefDialect,
+ StandardOpsDialect>();
// 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
#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"
/// Insert an allocation and deallocation for the given MemRefType.
static Value insertAllocAndDealloc(MemRefType type, Location loc,
PatternRewriter &rewriter) {
- auto alloc = rewriter.create<AllocOp>(loc, type);
+ auto alloc = rewriter.create<memref::AllocOp>(loc, type);
// Make sure to allocate at the beginning of the block.
auto *parentBlock = alloc->getBlock();
// 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<DeallocOp>(loc, alloc);
+ auto dealloc = rewriter.create<memref::DeallocOp>(loc, alloc);
dealloc->moveBefore(&parentBlock->back());
return alloc;
}
if (!valueShape.empty()) {
for (auto i : llvm::seq<int64_t>(
- 0, *std::max_element(valueShape.begin(), valueShape.end())))
- constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, i));
+ 0, *std::max_element(valueShape.begin(), valueShape.end())))
+ constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, i));
} else {
// This is the case of a tensor of rank 0.
constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, 0));
// 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<AffineDialect, StandardOpsDialect>();
+ target.addLegalDialect<AffineDialect, memref::MemRefDialect,
+ StandardOpsDialect>();
// 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
#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"
/// Insert an allocation and deallocation for the given MemRefType.
static Value insertAllocAndDealloc(MemRefType type, Location loc,
PatternRewriter &rewriter) {
- auto alloc = rewriter.create<AllocOp>(loc, type);
+ auto alloc = rewriter.create<memref::AllocOp>(loc, type);
// Make sure to allocate at the beginning of the block.
auto *parentBlock = alloc->getBlock();
// 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<DeallocOp>(loc, alloc);
+ auto dealloc = rewriter.create<memref::DeallocOp>(loc, alloc);
dealloc->moveBefore(&parentBlock->back());
return alloc;
}
if (!valueShape.empty()) {
for (auto i : llvm::seq<int64_t>(
- 0, *std::max_element(valueShape.begin(), valueShape.end())))
- constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, i));
+ 0, *std::max_element(valueShape.begin(), valueShape.end())))
+ constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, i));
} else {
// This is the case of a tensor of rank 0.
constantIndices.push_back(rewriter.create<ConstantIndexOp>(loc, 0));
// 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<AffineDialect, StandardOpsDialect>();
+ target.addLegalDialect<AffineDialect, memref::MemRefDialect,
+ StandardOpsDialect>();
// 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
/// 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<OperationPass<ModuleOp>>
createLowerToLLVMPass(const LowerToLLVMOptions &options =
LowerToLLVMOptions::getDefaultOptions());
add_subdirectory(Math)
add_subdirectory(Linalg)
add_subdirectory(LLVMIR)
+add_subdirectory(MemRef)
add_subdirectory(OpenACC)
add_subdirectory(OpenMP)
add_subdirectory(PDL)
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.
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.
};
using folded_math_tanh = FoldedValueBuilder<math::TanhOp>;
+using folded_memref_alloc = FoldedValueBuilder<memref::AllocOp>;
+using folded_memref_cast = FoldedValueBuilder<memref::CastOp>;
+using folded_memref_view = FoldedValueBuilder<memref::ViewOp>;
using folded_std_constant_index = FoldedValueBuilder<ConstantIndexOp>;
using folded_std_constant_float = FoldedValueBuilder<ConstantFloatOp>;
using folded_std_constant_int = FoldedValueBuilder<ConstantIntOp>;
using folded_std_muli = FoldedValueBuilder<MulIOp>;
using folded_std_addi = FoldedValueBuilder<AddIOp>;
using folded_std_addf = FoldedValueBuilder<AddFOp>;
-using folded_std_alloc = FoldedValueBuilder<AllocOp>;
using folded_std_constant = FoldedValueBuilder<ConstantOp>;
using folded_std_constant_float = FoldedValueBuilder<ConstantFloatOp>;
using folded_std_constant_index = FoldedValueBuilder<ConstantIndexOp>;
using folded_std_index_cast = FoldedValueBuilder<IndexCastOp>;
using folded_std_muli = FoldedValueBuilder<MulIOp>;
using folded_std_mulf = FoldedValueBuilder<MulFOp>;
-using folded_std_memref_cast = FoldedValueBuilder<MemRefCastOp>;
using folded_std_select = FoldedValueBuilder<SelectOp>;
using folded_std_load = FoldedValueBuilder<LoadOp>;
using folded_std_subi = FoldedValueBuilder<SubIOp>;
using folded_std_sub_view = FoldedValueBuilder<SubViewOp>;
using folded_std_tensor_load = FoldedValueBuilder<TensorLoadOp>;
-using folded_std_view = FoldedValueBuilder<ViewOp>;
using folded_std_zero_extendi = FoldedValueBuilder<ZeroExtendIOp>;
using folded_std_sign_extendi = FoldedValueBuilder<SignExtendIOp>;
using folded_tensor_extract = FoldedValueBuilder<tensor::ExtractOp>;
std::unique_ptr<OperationPass<FuncOp>> 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<OperationPass<FuncOp>> 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<OperationPass<FuncOp>> createConvertLinalgToParallelLoopsPass();
/// Create a pass to convert Linalg operations to affine.for loops and
/// 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) ...
/// ...
/// 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 ...
/// Match and rewrite for the pattern:
/// ```
/// %alloc = ...
-/// [optional] %view = std.view %alloc ...
+/// [optional] %view = memref.view %alloc ...
/// %subView = subview %allocOrView...
/// ...
/// vector.transfer_write %..., %allocOrView[...]
/// into
/// ```
/// [unchanged] %alloc = ...
-/// [unchanged] [optional] %view = std.view %alloc ...
+/// [unchanged] [optional] %view = memref.view %alloc ...
/// [unchanged] %subView = subview %allocOrView...
/// ...
/// vector.transfer_write %..., %out[...]
--- /dev/null
+add_subdirectory(IR)
--- /dev/null
+add_mlir_dialect(MemRefOps memref)
+add_mlir_doc(MemRefOps -gen-dialect-doc MemRefOps Dialects/)
--- /dev/null
+//===- 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_
--- /dev/null
+//===- 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
--- /dev/null
+//===- 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<string mnemonic, list<OpTrait> traits = []>
+ : Op<MemRef_Dialect, mnemonic, traits> {
+ 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<string mnemonic,
+ Resource resource,
+ list<OpTrait> traits = []> :
+ MemRef_Op<mnemonic,
+ !listconcat([
+ AttrSizedOperandSegments
+ ], traits)> {
+
+ let arguments = (ins Variadic<Index>:$dynamicSizes,
+ // The symbolic operands (the ones in square brackets) bind
+ // to the symbols of the memref's layout map.
+ Variadic<Index>:$symbolOperands,
+ Confined<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$alignment);
+ let results = (outs Res<AnyMemRef, "", [MemAlloc<resource>]>:$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<int32_t>(dynamicSizes.size()),
+ static_cast<int32_t>(symbolOperands.size())}));
+ if (alignment)
+ $_state.addAttribute(getAlignmentAttrName(), alignment);
+ }]>];
+
+ let extraClassDeclaration = [{
+ static StringRef getAlignmentAttrName() { return "alignment"; }
+
+ MemRefType getType() { return getResult().getType().cast<MemRefType>(); }
+
+ /// 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<string mnemonic, list<OpTrait> traits = []> :
+ MemRef_Op<mnemonic, traits # [
+ NoSideEffect, SameOperandsAndResultShape,
+ DeclareOpInterfaceMethods<CastOpInterface>
+ ]> {
+ 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<?x?xf32> to memref<4x4xf32>
+ // Erase static shape information, replacing it with dynamic information.
+ %3 = memref.cast %1 : memref<4xf32> to memref<?xf32>
+
+ // 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<AnyMemRef, "", [MemFree]>:$memref);
+
+ let hasCanonicalizer = 1;
+ let hasFolder = 1;
+ let assemblyFormat = "$memref attr-dict `:` type($memref)";
+}
+
+//===----------------------------------------------------------------------===//
+// GetGlobalOp
+//===----------------------------------------------------------------------===//
+
+def MemRef_GetGlobalOp : MemRef_Op<"get_global",
+ [NoSideEffect, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
+ 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<StrAttr>:$sym_visibility,
+ TypeAttr:$type,
+ OptionalAttr<AnyAttr>:$initial_value,
+ UnitAttr:$constant
+ );
+
+ let assemblyFormat = [{
+ ($sym_visibility^)?
+ (`constant` $constant^)?
+ $sym_name `:`
+ custom<GlobalMemrefOpTypeAndInitialValue>($type, $initial_value)
+ attr-dict
+ }];
+
+ let extraClassDeclaration = [{
+ bool isExternal() { return !initial_value(); }
+ bool isUninitialized() {
+ return !isExternal() && initial_value().getValue().isa<UnitAttr>();
+ }
+ }];
+}
+
+//===----------------------------------------------------------------------===//
+// 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<Index>:$indices,
+ BoolAttr:$isWrite,
+ Confined<I32Attr, [IntMinValue<0>,
+ IntMaxValue<3>]>:$localityHint,
+ BoolAttr:$isDataCache);
+
+ let extraClassDeclaration = [{
+ MemRefType getMemRefType() {
+ return memref().getType().cast<MemRefType>();
+ }
+ 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<?xf32>
+ ```
+
+ 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<?xf32>, memref<?xi32>) to memref<*xf32>
+ // Reshape unranked memref.
+ %dst = memref.reshape %src(%shape)
+ : (memref<*xf32>, memref<?xi32>) 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<MemRefType>(); }
+ 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<MemRefType>().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<AnyMemRef, "the reference to store to",
+ [MemWrite]>:$memref,
+ Variadic<Index>:$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<MemRefType>();
+ }
+
+ 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<?x?xf32> to memref<?x?xf32, affine_map<(d0, d1)[s0] -> (d1 * s0 + d0)>>
+ ```
+ }];
+
+ let builders = [
+ OpBuilderDAG<(ins "Value":$in, "AffineMapAttr":$permutation,
+ CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)>];
+
+ let extraClassDeclaration = [{
+ static StringRef getPermutationAttrName() { return "permutation"; }
+ ShapedType getShapedType() { return in().getType().cast<ShapedType>(); }
+ }];
+
+ let hasFolder = 1;
+}
+
+//===----------------------------------------------------------------------===//
+// ViewOp
+//===----------------------------------------------------------------------===//
+
+def MemRef_ViewOp : MemRef_Op<"view", [
+ DeclareOpInterfaceMethods<ViewLikeOpInterface>, 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<?x4x?xf32>
+ ```
+ }];
+
+ let arguments = (ins MemRefRankOf<[I8], [1]>:$source,
+ Index:$byte_shift,
+ Variadic<Index>:$sizes);
+ let results = (outs AnyMemRef);
+
+ let extraClassDeclaration = [{
+ /// The result of a view is always a memref.
+ MemRefType getType() { return getResult().getType().cast<MemRefType>(); }
+
+ /// Returns the dynamic sizes for this view operation. This is redundant
+ /// with `sizes` but needed in template implementations. More specifically:
+ /// ```
+ /// template <typename AnyMemRefDefOp>
+ /// bool isMemRefSizeValidSymbol(AnyMemRefDefOp memrefDefOp, unsigned index,
+ /// Region *region)
+ /// ```
+ operand_range getDynamicSizes() {
+ return {sizes().begin(), sizes().end()};
+ }
+ }];
+
+ let hasCanonicalizer = 1;
+}
+
+#endif // MEMREF_OPS
#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"
namespace edsc {
namespace intrinsics {
+using memref_alloc = ValueBuilder<memref::AllocOp>;
+using memref_alloca = ValueBuilder<memref::AllocaOp>;
+using memref_cast = ValueBuilder<memref::CastOp>;
+using memref_dealloc = OperationBuilder<memref::DeallocOp>;
+using memref_store = OperationBuilder<memref::StoreOp>;
+using memref_view = ValueBuilder<memref::ViewOp>;
using std_addi = ValueBuilder<AddIOp>;
using std_addf = ValueBuilder<AddFOp>;
-using std_alloc = ValueBuilder<AllocOp>;
-using std_alloca = ValueBuilder<AllocaOp>;
using std_call = OperationBuilder<CallOp>;
using std_constant = ValueBuilder<ConstantOp>;
using std_constant_float = ValueBuilder<ConstantFloatOp>;
using std_constant_index = ValueBuilder<ConstantIndexOp>;
using std_constant_int = ValueBuilder<ConstantIntOp>;
-using std_dealloc = OperationBuilder<DeallocOp>;
using std_divis = ValueBuilder<SignedDivIOp>;
using std_diviu = ValueBuilder<UnsignedDivIOp>;
using std_dim = ValueBuilder<DimOp>;
using std_index_cast = ValueBuilder<IndexCastOp>;
using std_muli = ValueBuilder<MulIOp>;
using std_mulf = ValueBuilder<MulFOp>;
-using std_memref_cast = ValueBuilder<MemRefCastOp>;
using std_ret = OperationBuilder<ReturnOp>;
using std_select = ValueBuilder<SelectOp>;
using std_load = ValueBuilder<LoadOp>;
using std_sign_extendi = ValueBuilder<SignExtendIOp>;
using std_splat = ValueBuilder<SplatOp>;
-using std_store = OperationBuilder<StoreOp>;
using std_subf = ValueBuilder<SubFOp>;
using std_subi = ValueBuilder<SubIOp>;
using std_sub_view = ValueBuilder<SubViewOp>;
using std_tensor_load = ValueBuilder<TensorLoadOp>;
using std_tensor_store = OperationBuilder<TensorStoreOp>;
-using std_view = ValueBuilder<ViewOp>;
using std_zero_extendi = ValueBuilder<ZeroExtendIOp>;
using tensor_extract = ValueBuilder<tensor::ExtractOp>;
/// Provide an index notation around sdt_load and std_store.
using StdIndexedValue =
- TemplatedIndexedValue<intrinsics::std_load, intrinsics::std_store>;
+ TemplatedIndexedValue<intrinsics::std_load, intrinsics::memref_store>;
} // namespace intrinsics
} // namespace edsc
} // namespace mlir
computeRankReductionMask(ArrayRef<int64_t> originalShape,
ArrayRef<int64_t> 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<?x?xf32>
-/// %2 = consumer %1 ... : memref<?x?xf32> ...
-/// ```
-///
-/// may fold into:
-///
-/// ```mlir
-/// %2 = consumer %0 ... : memref<8x16xf32> ...
-/// ```
-///
-/// Example 2:
-/// ```
-/// %1 = memref_cast %0 : memref<?x16xf32, affine_map<(i, j)->(16 * i + j)>>
-/// to memref<?x?xf32>
-/// consumer %1 : memref<?x?xf32> ...
-/// ```
-///
-/// may fold into:
-///
-/// ```
-/// consumer %0 ... : memref<?x16xf32, affine_map<(i, j)->(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,
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<string mnemonic, list<OpTrait> traits = []> :
+// Base class for arithmetic cast operations. Requires single operand and
+// result, but does not constrain them to specific types.
+class ArithmeticCastOp<string mnemonic, list<OpTrait> traits = []> :
Std_Op<mnemonic, traits # [
+ ElementwiseMappable,
+ DeclareOpInterfaceMethods<VectorUnrollOpInterface>,
NoSideEffect, SameOperandsAndResultShape,
DeclareOpInterfaceMethods<CastOpInterface>
]> {
let verifier = ?;
}
-// Base class for arithmetic cast operations.
-class ArithmeticCastOp<string mnemonic, list<OpTrait> traits = []> :
- CastOp<mnemonic,
- !listconcat(traits, [ElementwiseMappable,
- DeclareOpInterfaceMethods<VectorUnrollOpInterface>])> {
-}
-
// Base class for unary ops. Requires single operand and result. Individual
// classes will have `operand` accessor.
class UnaryOp<string mnemonic, list<OpTrait> traits = []> :
[DeclareOpInterfaceMethods<VectorUnrollOpInterface>])>,
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<string mnemonic,
- Resource resource,
- list<OpTrait> traits = []> :
- Std_Op<mnemonic,
- !listconcat([
- AttrSizedOperandSegments
- ], traits)> {
-
- let arguments = (ins Variadic<Index>:$dynamicSizes,
- // The symbolic operands (the ones in square brackets) bind
- // to the symbols of the memref's layout map.
- Variadic<Index>:$symbolOperands,
- Confined<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$alignment);
- let results = (outs Res<AnyMemRef, "", [MemAlloc<resource>]>:$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<int32_t>(dynamicSizes.size()),
- static_cast<int32_t>(symbolOperands.size())}));
- if (alignment)
- $_state.addAttribute(getAlignmentAttrName(), alignment);
- }]>];
-
- let extraClassDeclaration = [{
- static StringRef getAlignmentAttrName() { return "alignment"; }
-
- MemRefType getType() { return getResult().getType().cast<MemRefType>(); }
-
- /// 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<string mnemonic, list<OpTrait> traits = []> :
}
//===----------------------------------------------------------------------===//
-// 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
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// 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<AnyMemRef, "", [MemFree]>:$memref);
-
- let hasCanonicalizer = 1;
- let hasFolder = 1;
- let assemblyFormat = "$memref attr-dict `:` type($memref)";
-}
-
-//===----------------------------------------------------------------------===//
// DimOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// 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<StrAttr>:$sym_visibility,
- TypeAttr:$type,
- OptionalAttr<AnyAttr>:$initial_value,
- UnitAttr:$constant
- );
-
- let assemblyFormat = [{
- ($sym_visibility^)?
- (`constant` $constant^)?
- $sym_name `:`
- custom<GlobalMemrefOpTypeAndInitialValue>($type, $initial_value)
- attr-dict
- }];
-
- let extraClassDeclaration = [{
- bool isExternal() { return !initial_value(); }
- bool isUninitialized() {
- return !isExternal() && initial_value().getValue().isa<UnitAttr>();
- }
- }];
-}
-
-//===----------------------------------------------------------------------===//
-// GetGlobalMemrefOp
-//===----------------------------------------------------------------------===//
-
-def GetGlobalMemrefOp : Std_Op<"get_global_memref",
- [NoSideEffect, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
- 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
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// MemRefCastOp
-//===----------------------------------------------------------------------===//
-
-def MemRefCastOp : CastOp<"memref_cast", [
- DeclareOpInterfaceMethods<ViewLikeOpInterface>
- ]> {
- 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<?x?xf32> to memref<4x4xf32>
- // Erase static shape information, replacing it with dynamic information.
- %3 = memref_cast %1 : memref<4xf32> to memref<?xf32>
-
- // 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
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// 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<Index>:$indices,
- BoolAttr:$isWrite,
- Confined<I32Attr, [IntMinValue<0>,
- IntMaxValue<3>]>:$localityHint,
- BoolAttr:$isDataCache);
-
- let extraClassDeclaration = [{
- MemRefType getMemRefType() {
- return memref().getType().cast<MemRefType>();
- }
- static StringRef getLocalityHintAttrName() { return "localityHint"; }
- static StringRef getIsWriteAttrName() { return "isWrite"; }
- static StringRef getIsDataCacheAttrName() { return "isDataCache"; }
- }];
-
- let hasFolder = 1;
-}
-
-//===----------------------------------------------------------------------===//
// RankOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// StoreOp
-//===----------------------------------------------------------------------===//
-
-def StoreOp : Std_Op<"store",
- [TypesMatchWith<"type of 'value' matches element type of 'memref'",
- "memref", "value",
- "$_self.cast<MemRefType>().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<AnyMemRef, "the reference to store to",
- [MemWrite]>:$memref,
- Variadic<Index>:$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<MemRefType>();
- }
-
- operand_range getIndices() {
- return {operand_begin() + 2, operand_end()};
- }
- }];
-
- let hasFolder = 1;
-
- let assemblyFormat = [{
- $value `,` $memref `[` $indices `]` attr-dict `:` type($memref)
- }];
-}
-
-//===----------------------------------------------------------------------===//
// SubFOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// 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<?x?xf32> to memref<?x?xf32, affine_map<(d0, d1)[s0] -> (d1 * s0 + d0)>>
- ```
- }];
-
- let builders = [
- OpBuilderDAG<(ins "Value":$in, "AffineMapAttr":$permutation,
- CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)>];
-
- let extraClassDeclaration = [{
- static StringRef getPermutationAttrName() { return "permutation"; }
- ShapedType getShapedType() { return in().getType().cast<ShapedType>(); }
- }];
-
- let hasFolder = 1;
-}
-
-//===----------------------------------------------------------------------===//
// TruncateIOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// ViewOp
-//===----------------------------------------------------------------------===//
-
-def ViewOp : Std_Op<"view", [
- DeclareOpInterfaceMethods<ViewLikeOpInterface>, 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<?x4x?xf32>
- ```
- }];
-
- let arguments = (ins MemRefRankOf<[I8], [1]>:$source,
- Index:$byte_shift,
- Variadic<Index>:$sizes);
- let results = (outs AnyMemRef);
-
- let extraClassDeclaration = [{
- /// The result of a view is always a memref.
- MemRefType getType() { return getResult().getType().cast<MemRefType>(); }
-
- /// Returns the dynamic sizes for this view operation. This is redundant
- /// with `sizes` but needed in template implementations. More specifically:
- /// ```
- /// template <typename AnyMemRefDefOp>
- /// bool isMemRefSizeValidSymbol(AnyMemRefDefOp memrefDefOp, unsigned index,
- /// Region *region)
- /// ```
- operand_range getDynamicSizes() {
- return {sizes().begin(), sizes().end()};
- }
- }];
-
- let hasCanonicalizer = 1;
-}
-
-//===----------------------------------------------------------------------===//
// XOrOp
//===----------------------------------------------------------------------===//
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()";
}
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.
/// ```
/// %1:3 = scf.if (%inBounds) {
/// // fastpath, direct cast
-/// memref_cast %A: memref<A...> to compatibleMemRefType
+/// memref.cast %A: memref<A...> to compatibleMemRefType
/// scf.yield %view : compatibleMemRefType, index, index
/// } else {
/// // slowpath, masked vector.transfer or linalg.copy.
-/// memref_cast %alloc: memref<B...> to compatibleMemRefType
+/// memref.cast %alloc: memref<B...> to compatibleMemRefType
/// scf.yield %4 : compatibleMemRefType, index, index
// }
/// %0 = vector.transfer_read %1#0[%1#1, %1#2] {masked = [false ... false]}
/// 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 <typename ConcreteType>
class AutomaticAllocationScope
#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"
LLVM::LLVMArmSVEDialect,
linalg::LinalgDialect,
math::MathDialect,
+ memref::MemRefDialect,
scf::SCFDialect,
omp::OpenMPDialect,
pdl::PDLDialect,
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
#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"
/// 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
#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"
: builder(builder), dimValues(dimValues), symbolValues(symbolValues),
loc(loc) {}
- template <typename OpTy> Value buildBinaryExpr(AffineBinaryOpExpr expr) {
+ template <typename OpTy>
+ Value buildBinaryExpr(AffineBinaryOpExpr expr) {
auto lhs = visit(expr.getLHS());
auto rhs = visit(expr.getRHS());
if (!lhs || !rhs)
};
/// 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<AffinePrefetchOp> {
public:
if (!resultOperands)
return failure();
- // Build std.prefetch memref[expandedMap.results].
- rewriter.replaceOpWithNewOp<PrefetchOp>(op, op.memref(), *resultOperands,
- op.isWrite(), op.localityHint(),
- op.isDataCache());
+ // Build memref.prefetch memref[expandedMap.results].
+ rewriter.replaceOpWithNewOp<memref::PrefetchOp>(
+ 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<AffineStoreOp> {
public:
if (!maybeExpandedMap)
return failure();
- // Build std.store valueToStore, memref[expandedMap.results].
- rewriter.replaceOpWithNewOp<mlir::StoreOp>(
+ // Build memref.store valueToStore, memref[expandedMap.results].
+ rewriter.replaceOpWithNewOp<memref::StoreOp>(
op, op.getValueToStore(), op.getMemRef(), *maybeExpandedMap);
return success();
}
populateAffineToStdConversionPatterns(patterns, &getContext());
populateAffineToVectorConversionPatterns(patterns, &getContext());
ConversionTarget target(getContext());
- target
- .addLegalDialect<scf::SCFDialect, StandardOpsDialect, VectorDialect>();
+ target.addLegalDialect<memref::MemRefDialect, scf::SCFDialect,
+ StandardOpsDialect, VectorDialect>();
if (failed(applyPartialConversion(getOperation(), target,
std::move(patterns))))
signalPassFailure();
continue;
}
Value cast =
- b.create<MemRefCastOp>(loc, eraseStridedLayout(memrefType), op);
+ b.create<memref::CastOp>(loc, eraseStridedLayout(memrefType), op);
res.push_back(cast);
}
return res;
// If either inputPerm or outputPerm are non-identities, insert transposes.
auto inputPerm = op.inputPermutation();
if (inputPerm.hasValue() && !inputPerm->isIdentity())
- in = rewriter.create<TransposeOp>(op.getLoc(), in,
- AffineMapAttr::get(*inputPerm));
+ in = rewriter.create<memref::TransposeOp>(op.getLoc(), in,
+ AffineMapAttr::get(*inputPerm));
auto outputPerm = op.outputPermutation();
if (outputPerm.hasValue() && !outputPerm->isIdentity())
- out = rewriter.create<TransposeOp>(op.getLoc(), out,
- AffineMapAttr::get(*outputPerm));
+ out = rewriter.create<memref::TransposeOp>(op.getLoc(), out,
+ AffineMapAttr::get(*outputPerm));
// If nothing was transposed, fail and let the conversion kick in.
if (in == op.input() && out == op.output())
void ConvertLinalgToStandardPass::runOnOperation() {
auto module = getOperation();
ConversionTarget target(getContext());
- target.addLegalDialect<AffineDialect, scf::SCFDialect, StandardOpsDialect>();
+ target.addLegalDialect<AffineDialect, memref::MemRefDialect, scf::SCFDialect,
+ StandardOpsDialect>();
target.addLegalOp<ModuleOp, FuncOp, ModuleTerminatorOp, ReturnOp>();
target.addLegalOp<linalg::ReshapeOp, linalg::RangeOp>();
OwningRewritePatternList patterns;
#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"
}
void mlir::configureParallelLoopToGPULegality(ConversionTarget &target) {
+ target.addLegalDialect<memref::MemRefDialect>();
target.addDynamicallyLegalOp<scf::ParallelOp>([](scf::ParallelOp parallelOp) {
return !parallelOp->getAttr(gpu::getMappingAttrName());
});
#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"
struct AllocOpLowering : public AllocLikeOpLowering {
AllocOpLowering(LLVMTypeConverter &converter)
- : AllocLikeOpLowering(AllocOp::getOperationName(), converter) {}
+ : AllocLikeOpLowering(memref::AllocOp::getOperationName(), converter) {}
std::tuple<Value, Value> allocateBuffer(ConversionPatternRewriter &rewriter,
Location loc, Value sizeBytes,
Operation *op) const override {
// Heap allocations.
- AllocOp allocOp = cast<AllocOp>(op);
+ memref::AllocOp allocOp = cast<memref::AllocOp>(op);
MemRefType memRefType = allocOp.getType();
Value alignment;
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?
/// 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<uint64_t> alignment = allocOp.alignment())
return *alignment;
Location loc, Value sizeBytes,
Operation *op) const override {
// Heap allocations.
- AllocOp allocOp = cast<AllocOp>(op);
+ memref::AllocOp allocOp = cast<memref::AllocOp>(op);
MemRefType memRefType = allocOp.getType();
int64_t alignment = getAllocationAlignment(allocOp);
Value allocAlignment = createIndexConstant(rewriter, loc, alignment);
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
// With alloca, one gets a pointer to the element type right away.
// For stack allocations.
- auto allocaOp = cast<AllocaOp>(op);
+ auto allocaOp = cast<memref::AllocaOp>(op);
auto elementPtrType = this->getElementPtrType(allocaOp.getType());
auto allocatedElementPtr = rewriter.create<LLVM::AllocaOp>(
// 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<DeallocOp> {
- using ConvertOpToLLVMPattern<DeallocOp>::ConvertOpToLLVMPattern;
+struct DeallocOpLowering : public ConvertOpToLLVMPattern<memref::DeallocOp> {
+ using ConvertOpToLLVMPattern<memref::DeallocOp>::ConvertOpToLLVMPattern;
explicit DeallocOpLowering(LLVMTypeConverter &converter)
- : ConvertOpToLLVMPattern<DeallocOp>(converter) {}
+ : ConvertOpToLLVMPattern<memref::DeallocOp>(converter) {}
LogicalResult
- matchAndRewrite(DeallocOp op, ArrayRef<Value> operands,
+ matchAndRewrite(memref::DeallocOp op, ArrayRef<Value> 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<ModuleOp>());
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()));
}
/// GlobalMemrefOp is lowered to a LLVM Global Variable.
-struct GlobalMemrefOpLowering : public ConvertOpToLLVMPattern<GlobalMemrefOp> {
- using ConvertOpToLLVMPattern<GlobalMemrefOp>::ConvertOpToLLVMPattern;
+struct GlobalMemrefOpLowering
+ : public ConvertOpToLLVMPattern<memref::GlobalOp> {
+ using ConvertOpToLLVMPattern<memref::GlobalOp>::ConvertOpToLLVMPattern;
LogicalResult
- matchAndRewrite(GlobalMemrefOp global, ArrayRef<Value> operands,
+ matchAndRewrite(memref::GlobalOp global, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
MemRefType type = global.type().cast<MemRefType>();
if (!isConvertibleAndHasIdentityMaps(type))
/// `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<Value, Value> allocateBuffer(ConversionPatternRewriter &rewriter,
Location loc, Value sizeBytes,
Operation *op) const override {
- auto getGlobalOp = cast<GetGlobalMemrefOp>(op);
+ auto getGlobalOp = cast<memref::GetGlobalOp>(op);
MemRefType type = getGlobalOp.result().getType().cast<MemRefType>();
unsigned memSpace = type.getMemorySpace();
createIndexConstant(rewriter, loc, 0));
auto gep = rewriter.create<LLVM::GEPOp>(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);
}
};
-struct MemRefCastOpLowering : public ConvertOpToLLVMPattern<MemRefCastOp> {
- using ConvertOpToLLVMPattern<MemRefCastOp>::ConvertOpToLLVMPattern;
+struct MemRefCastOpLowering : public ConvertOpToLLVMPattern<memref::CastOp> {
+ using ConvertOpToLLVMPattern<memref::CastOp>::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<MemRefType>() && dstType.isa<MemRefType>())
return success(typeConverter->convertType(srcType) ==
: failure();
}
- void rewrite(MemRefCastOp memRefCastOp, ArrayRef<Value> operands,
+ void rewrite(memref::CastOp memRefCastOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
- MemRefCastOp::Adaptor transformed(operands);
+ memref::CastOp::Adaptor transformed(operands);
auto srcType = memRefCastOp.getOperand().getType();
auto dstType = memRefCastOp.getType();
// Store operation is lowered to obtaining a pointer to the indexed element,
// and storing the given value to it.
-struct StoreOpLowering : public LoadStoreOpLowering<StoreOp> {
+struct StoreOpLowering : public LoadStoreOpLowering<memref::StoreOp> {
using Base::Base;
LogicalResult
- matchAndRewrite(StoreOp op, ArrayRef<Value> operands,
+ matchAndRewrite(memref::StoreOp op, ArrayRef<Value> 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(),
// 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<PrefetchOp> {
+struct PrefetchOpLowering : public LoadStoreOpLowering<memref::PrefetchOp> {
using Base::Base;
LogicalResult
- matchAndRewrite(PrefetchOp prefetchOp, ArrayRef<Value> operands,
+ matchAndRewrite(memref::PrefetchOp prefetchOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
- PrefetchOp::Adaptor transformed(operands);
+ memref::PrefetchOp::Adaptor transformed(operands);
auto type = prefetchOp.getMemRefType();
auto loc = prefetchOp.getLoc();
/// 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<TransposeOp> {
+class TransposeOpLowering : public ConvertOpToLLVMPattern<memref::TransposeOp> {
public:
- using ConvertOpToLLVMPattern<TransposeOp>::ConvertOpToLLVMPattern;
+ using ConvertOpToLLVMPattern<memref::TransposeOp>::ConvertOpToLLVMPattern;
LogicalResult
- matchAndRewrite(TransposeOp transposeOp, ArrayRef<Value> operands,
+ matchAndRewrite(memref::TransposeOp transposeOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto loc = transposeOp.getLoc();
- TransposeOpAdaptor adaptor(operands);
+ memref::TransposeOpAdaptor adaptor(operands);
MemRefDescriptor viewMemRef(adaptor.in());
// No permutation, early exit.
/// 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<ViewOp> {
- using ConvertOpToLLVMPattern<ViewOp>::ConvertOpToLLVMPattern;
+struct ViewOpLowering : public ConvertOpToLLVMPattern<memref::ViewOp> {
+ using ConvertOpToLLVMPattern<memref::ViewOp>::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.
}
LogicalResult
- matchAndRewrite(ViewOp viewOp, ArrayRef<Value> operands,
+ matchAndRewrite(memref::ViewOp viewOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto loc = viewOp.getLoc();
- ViewOpAdaptor adaptor(operands);
+ memref::ViewOpAdaptor adaptor(operands);
auto viewMemRefType = viewOp.getType();
auto targetElementTy =
#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"
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();
}
template <>
-void StoreOpOfSubViewFolder<StoreOp>::replaceOp(
- StoreOp storeOp, SubViewOp subViewOp, ArrayRef<Value> sourceIndices,
+void StoreOpOfSubViewFolder<memref::StoreOp>::replaceOp(
+ memref::StoreOp storeOp, SubViewOp subViewOp, ArrayRef<Value> sourceIndices,
PatternRewriter &rewriter) const {
- rewriter.replaceOpWithNewOp<StoreOp>(storeOp, storeOp.value(),
- subViewOp.source(), sourceIndices);
+ rewriter.replaceOpWithNewOp<memref::StoreOp>(
+ storeOp, storeOp.value(), subViewOp.source(), sourceIndices);
}
template <>
MLIRContext *context, OwningRewritePatternList &patterns) {
patterns.insert<LoadOpOfSubViewFolder<LoadOp>,
LoadOpOfSubViewFolder<vector::TransferReadOp>,
- StoreOpOfSubViewFolder<StoreOp>,
+ StoreOpOfSubViewFolder<memref::StoreOp>,
StoreOpOfSubViewFolder<vector::TransferWriteOp>>(context);
}
//===----------------------------------------------------------------------===//
#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"
/// 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<AllocOp> {
+class AllocOpPattern final : public OpConversionPattern<memref::AllocOp> {
public:
- using OpConversionPattern<AllocOp>::OpConversionPattern;
+ using OpConversionPattern<memref::AllocOp>::OpConversionPattern;
LogicalResult
- matchAndRewrite(AllocOp operation, ArrayRef<Value> operands,
+ matchAndRewrite(memref::AllocOp operation, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
MemRefType allocType = operation.getType();
if (!isAllocationSupported(allocType))
/// 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<DeallocOp> {
+class DeallocOpPattern final : public OpConversionPattern<memref::DeallocOp> {
public:
- using OpConversionPattern<DeallocOp>::OpConversionPattern;
+ using OpConversionPattern<memref::DeallocOp>::OpConversionPattern;
LogicalResult
- matchAndRewrite(DeallocOp operation, ArrayRef<Value> operands,
+ matchAndRewrite(memref::DeallocOp operation, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
MemRefType deallocType = operation.memref().getType().cast<MemRefType>();
if (!isAllocationSupported(deallocType))
ConversionPatternRewriter &rewriter) const override;
};
-/// Converts std.store to spv.Store on integers.
-class IntStoreOpPattern final : public OpConversionPattern<StoreOp> {
+/// Converts memref.store to spv.Store on integers.
+class IntStoreOpPattern final : public OpConversionPattern<memref::StoreOp> {
public:
- using OpConversionPattern<StoreOp>::OpConversionPattern;
+ using OpConversionPattern<memref::StoreOp>::OpConversionPattern;
LogicalResult
- matchAndRewrite(StoreOp storeOp, ArrayRef<Value> operands,
+ matchAndRewrite(memref::StoreOp storeOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override;
};
-/// Converts std.store to spv.Store.
-class StoreOpPattern final : public OpConversionPattern<StoreOp> {
+/// Converts memref.store to spv.Store.
+class StoreOpPattern final : public OpConversionPattern<memref::StoreOp> {
public:
- using OpConversionPattern<StoreOp>::OpConversionPattern;
+ using OpConversionPattern<memref::StoreOp>::OpConversionPattern;
LogicalResult
- matchAndRewrite(StoreOp storeOp, ArrayRef<Value> operands,
+ matchAndRewrite(memref::StoreOp storeOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override;
};
//===----------------------------------------------------------------------===//
LogicalResult
-IntStoreOpPattern::matchAndRewrite(StoreOp storeOp, ArrayRef<Value> operands,
+IntStoreOpPattern::matchAndRewrite(memref::StoreOp storeOp,
+ ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const {
- StoreOpAdaptor storeOperands(operands);
+ memref::StoreOpAdaptor storeOperands(operands);
auto memrefType = storeOp.memref().getType().cast<MemRefType>();
if (!memrefType.getElementType().isSignlessInteger())
return failure();
}
LogicalResult
-StoreOpPattern::matchAndRewrite(StoreOp storeOp, ArrayRef<Value> operands,
+StoreOpPattern::matchAndRewrite(memref::StoreOp storeOp,
+ ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const {
- StoreOpAdaptor storeOperands(operands);
+ memref::StoreOpAdaptor storeOperands(operands);
auto memrefType = storeOp.memref().getType().cast<MemRefType>();
if (memrefType.getElementType().isSignlessInteger())
return failure();
op->getParentWithTrait<OpTrait::AutomaticAllocationScope>();
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;
}
return {vector};
}
// 3.b. Otherwise, just go through the temporary `alloc`.
- std_store(vector, alloc, majorIvs);
+ memref_store(vector, alloc, majorIvs);
return {};
},
[&]() -> scf::ValueVector {
return {vector};
}
// 3.d. Otherwise, just go through the temporary `alloc`.
- std_store(vector, alloc, majorIvs);
+ memref_store(vector, alloc, majorIvs);
return {};
});
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);
}
});
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,
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.
#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"
"expect only `dim` operations with a constant index");
int64_t i = index.getValue();
return TypeSwitch<Operation *, bool>(dimOp.memrefOrTensor().getDefiningOp())
- .Case<ViewOp, SubViewOp, AllocOp>(
+ .Case<memref::ViewOp, SubViewOp, memref::AllocOp>(
[&](auto op) { return isMemRefSizeValidSymbol(op, i, region); })
.Default([](Operation *) { return false; });
}
//===----------------------------------------------------------------------===//
/// 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<MemRefCastOp>();
+ auto cast = operand.get().getDefiningOp<memref::CastOp>();
if (cast && !cast.getOperand().getType().isa<UnrankedMemRefType>()) {
operand.set(cast.getOperand());
folded = true;
add_subdirectory(Linalg)
add_subdirectory(LLVMIR)
add_subdirectory(Math)
+add_subdirectory(MemRef)
add_subdirectory(OpenACC)
add_subdirectory(OpenMP)
add_subdirectory(PDL)
#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"
createPredicatedBlock(isFirstLane, [&] {
Value subgroupId = getDivideBySubgroupSize(invocationIdx);
Value index = create<IndexCastOp>(indexType, subgroupId);
- create<StoreOp>(subgroupReduce, buffer, index);
+ create<memref::StoreOp>(subgroupReduce, buffer, index);
});
create<gpu::BarrierOp>();
Value value = create<LoadOp>(valueType, buffer, index);
Value result =
createSubgroupReduce(numSubgroups, laneId, value, accumFactory);
- create<StoreOp>(result, buffer, zero);
+ create<memref::StoreOp>(result, buffer, zero);
});
// Synchronize workgroup and load result from workgroup memory.
private:
// Shortcut to create an op from rewriter using loc as the first argument.
- template <typename T, typename... Args> T create(Args... args) {
+ template <typename T, typename... Args>
+ T create(Args... args) {
return rewriter.create<T>(loc, std::forward<Args>(args)...);
}
// Creates dimension op of type T, with the result casted to int32.
- template <typename T> Value getDimOp(StringRef dimension) {
+ template <typename T>
+ Value getDimOp(StringRef dimension) {
Value dim = create<T>(indexType, rewriter.getStringAttr(dimension));
return create<IndexCastOp>(int32Type, dim);
}
}
/// Returns an accumulator factory that creates an op of type T.
- template <typename T> AccumulatorFactory getFactory() {
+ template <typename T>
+ AccumulatorFactory getFactory() {
return [&](Value lhs, Value rhs) {
return create<T>(lhs.getType(), lhs, rhs);
};
MLIRSideEffectInterfaces
MLIRViewLikeInterface
MLIRStandard
+ MLIRMemRef
MLIRTensor
)
/// ```
/// 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<MemRefCastOp>();
- if (castOp && canFoldIntoConsumerOp(castOp)) {
+ auto castOp = operand.get().getDefiningOp<memref::CastOp>();
+ if (castOp && memref::CastOp::canFoldIntoConsumerOp(castOp)) {
operand.set(castOp.getOperand());
folded = true;
}
static Value cloneMemref(Location loc, Value memref, OpBuilder &b) {
auto memrefType = memref.getType().cast<MemRefType>();
- auto alloc =
- b.create<AllocOp>(loc, memrefType, getDynOperands(loc, memref, b));
+ auto alloc = b.create<memref::AllocOp>(loc, memrefType,
+ getDynOperands(loc, memref, b));
b.create<linalg::CopyOp>(loc, memref, alloc);
return alloc;
}
continue;
}
- if (auto alloc = resultTensor.getDefiningOp<AllocOp>()) {
+ if (auto alloc = resultTensor.getDefiningOp<memref::AllocOp>()) {
resultBuffers.push_back(resultTensor);
continue;
}
// Allocate buffers for statically-shaped results.
if (memrefType.hasStaticShape()) {
- resultBuffers.push_back(b.create<AllocOp>(loc, memrefType));
+ resultBuffers.push_back(b.create<memref::AllocOp>(loc, memrefType));
continue;
}
- resultBuffers.push_back(b.create<AllocOp>(
+ resultBuffers.push_back(b.create<memref::AllocOp>(
loc, memrefType, getDynOperands(loc, resultTensor, b)));
}
return success();
matchAndRewrite(InitTensorOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const final {
linalg::InitTensorOpAdaptor adaptor(operands, op->getAttrDictionary());
- rewriter.replaceOpWithNewOp<AllocOp>(
+ rewriter.replaceOpWithNewOp<memref::AllocOp>(
op, getTypeConverter()->convertType(op.getType()).cast<MemRefType>(),
adaptor.sizes());
return success();
// op.sizes() capture exactly the dynamic alloc operands matching the
// subviewMemRefType thanks to subview/subtensor canonicalization and
// verification.
- Value alloc =
- rewriter.create<AllocOp>(op.getLoc(), subviewMemRefType, op.sizes());
+ Value alloc = rewriter.create<memref::AllocOp>(
+ op.getLoc(), subviewMemRefType, op.sizes());
Value subView = rewriter.create<SubViewOp>(
op.getLoc(), sourceMemref, op.getMixedOffsets(), op.getMixedSizes(),
op.getMixedStrides());
// Mark all Standard operations legal.
target.addLegalDialect<AffineDialect, math::MathDialect,
- StandardOpsDialect>();
+ memref::MemRefDialect, StandardOpsDialect>();
target.addIllegalOp<InitTensorOp, SubTensorOp, SubTensorInsertOp>();
// Mark all Linalg operations illegal as long as they work on tensors.
#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"
while (changed) {
changed = false;
func.walk([&changed](Operation *op) {
- if (!isa<AllocOp, AllocaOp, DeallocOp>(op))
+ if (!isa<memref::AllocOp, memref::AllocaOp, memref::DeallocOp>(op))
return;
LLVM_DEBUG(DBGS() << "Candidate for hoisting: " << *op << "\n");
v = op->getResult(0);
}
if (v && !llvm::all_of(v.getUses(), [&](OpOperand &operand) {
- return isa<ViewLikeOpInterface, DeallocOp>(operand.getOwner());
+ return isa<ViewLikeOpInterface, memref::DeallocOp>(
+ operand.getOwner());
})) {
LLVM_DEBUG(DBGS() << "Found non view-like or dealloc use: bail\n");
return;
}
// Move AllocOp before the loop.
- if (isa<AllocOp, AllocaOp>(op))
+ if (isa<memref::AllocOp, memref::AllocaOp>(op))
(void)loop.moveOutOfLoop({op});
else // Move DeallocOp outside of the loop.
op->moveAfter(loop);
using folded_linalg_range = FoldedValueBuilder<linalg::RangeOp>;
using folded_std_dim = FoldedValueBuilder<DimOp>;
using folded_std_subview = FoldedValueBuilder<SubViewOp>;
-using folded_std_view = FoldedValueBuilder<ViewOp>;
+using folded_memref_view = FoldedValueBuilder<memref::ViewOp>;
#define DEBUG_TYPE "linalg-promotion"
if (!dynamicBuffers)
if (auto cst = size.getDefiningOp<ConstantIndexOp>())
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;
}
dynamicBuffers, folder, alignment);
SmallVector<int64_t, 4> 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;
static LogicalResult
defaultDeallocBufferCallBack(const LinalgPromotionOptions &options,
OpBuilder &b, Value fullLocalView) {
- auto viewOp = fullLocalView.getDefiningOp<ViewOp>();
+ auto viewOp = fullLocalView.getDefiningOp<memref::ViewOp>();
assert(viewOp && "expected full local view to be a ViewOp");
if (!options.useAlloca)
- std_dealloc(viewOp.source());
+ memref_dealloc(viewOp.source());
return success();
}
// introduces a dense initialization component that may negatively
// impact the running complexity of the sparse kernel.
Value init = rewriter.create<TensorToMemrefOp>(loc, denseTp, tensor);
- Value alloc = rewriter.create<AllocOp>(loc, denseTp, args);
+ Value alloc = rewriter.create<memref::AllocOp>(loc, denseTp, args);
rewriter.create<linalg::CopyOp>(loc, init, alloc);
return alloc;
}
if (codegen.curVecLength > 1)
genVectorStore(codegen, rewriter, rhs, ptr, args);
else
- rewriter.create<StoreOp>(loc, rhs, ptr, args);
+ rewriter.create<memref::StoreOp>(loc, rhs, ptr, args);
}
/// Generates a pointer/index load from the sparse storage scheme.
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"
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())
rewriter.getAffineMapArrayAttr(indexingMaps),
rewriter.getStrArrayAttr(iteratorTypes));
- rewriter.create<StoreOp>(loc, result, output, ValueRange(zeros));
+ rewriter.create<memref::StoreOp>(loc, result, output, ValueRange(zeros));
rewriter.eraseOp(op);
return success();
}
// Transfer into `view`.
Value viewOrAlloc = xferOp.source();
- if (!viewOrAlloc.getDefiningOp<ViewOp>() &&
- !viewOrAlloc.getDefiningOp<AllocOp>())
+ if (!viewOrAlloc.getDefiningOp<memref::ViewOp>() &&
+ !viewOrAlloc.getDefiningOp<memref::AllocOp>())
return failure();
LLVM_DEBUG(llvm::dbgs() << "\n[" DEBUG_TYPE "]: " << viewOrAlloc);
vector::TransferWriteOp xferOp, PatternRewriter &rewriter) const {
// Transfer into `viewOrAlloc`.
Value viewOrAlloc = xferOp.source();
- if (!viewOrAlloc.getDefiningOp<ViewOp>() &&
- !viewOrAlloc.getDefiningOp<AllocOp>())
+ if (!viewOrAlloc.getDefiningOp<memref::ViewOp>() &&
+ !viewOrAlloc.getDefiningOp<memref::AllocOp>())
return failure();
// Ensure there is exactly one subview of `viewOrAlloc` defining `subView`.
--- /dev/null
+add_subdirectory(IR)
--- /dev/null
+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
+)
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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<MemRefInlinerInterface>();
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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<ConstantIndexOp> m_ConstantIndex() {
+ return detail::op_matcher<ConstantIndexOp>();
+}
+
+//===----------------------------------------------------------------------===//
+// 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<CastOp>();
+ if (cast && !cast.getOperand().getType().isa<UnrankedMemRefType>()) {
+ 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<MemRefType>())
+ return RankedTensorType::get(memref.getShape(), memref.getElementType());
+ if (auto memref = type.dyn_cast<UnrankedMemRefType>())
+ return UnrankedTensorType::get(memref.getElementType());
+ return NoneType::get(type.getContext());
+}
+
+//===----------------------------------------------------------------------===//
+// AllocOp / AllocaOp
+//===----------------------------------------------------------------------===//
+
+template <typename AllocLikeOp>
+static LogicalResult verifyAllocLikeOp(AllocLikeOp op) {
+ static_assert(llvm::is_one_of<AllocLikeOp, AllocOp, AllocaOp>::value,
+ "applies to only alloc or alloca");
+ auto memRefType = op.getResult().getType().template dyn_cast<MemRefType>();
+ if (!memRefType)
+ return op.emitOpError("result must be a memref");
+
+ if (static_cast<int64_t>(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<OpTrait::AutomaticAllocationScope>())
+ return op.emitOpError(
+ "requires an ancestor op with AutomaticAllocationScope trait");
+
+ return verifyAllocLikeOp(op);
+}
+
+namespace {
+/// Fold constant dimensions into an alloc like operation.
+template <typename AllocLikeOp>
+struct SimplifyAllocConst : public OpRewritePattern<AllocLikeOp> {
+ using OpRewritePattern<AllocLikeOp>::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<int64_t, 4> newShapeConstants;
+ newShapeConstants.reserve(memrefType.getRank());
+ SmallVector<Value, 4> 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<ConstantIndexOp>(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<int64_t>(newOperands.size()) ==
+ newMemRefType.getNumDynamicDims());
+
+ // Create and insert the alloc op for the new memref.
+ auto newAlloc = rewriter.create<AllocLikeOp>(alloc.getLoc(), newMemRefType,
+ newOperands, IntegerAttr());
+ // Insert a cast so we have the same type as the old alloc.
+ auto resultCast =
+ rewriter.create<CastOp>(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<AllocOp> {
+ using OpRewritePattern<AllocOp>::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<SimplifyAllocConst<AllocOp>, SimplifyDeadAlloc>(context);
+}
+
+void AllocaOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
+ MLIRContext *context) {
+ results.insert<SimplifyAllocConst<AllocaOp>>(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<?x?xf32>
+/// %2 = consumer %1 ... : memref<?x?xf32> ...
+/// ```
+///
+/// may fold into:
+///
+/// ```mlir
+/// %2 = consumer %0 ... : memref<8x16xf32> ...
+/// ```
+///
+/// Example 2:
+/// ```
+/// %1 = memref.cast %0 : memref<?x16xf32, affine_map<(i, j)->(16 * i + j)>>
+/// to memref<?x?xf32>
+/// consumer %1 : memref<?x?xf32> ...
+/// ```
+///
+/// may fold into:
+///
+/// ```
+/// consumer %0 ... : memref<?x16xf32, affine_map<(i, j)->(16 * i + j)>>
+/// ```
+bool CastOp::canFoldIntoConsumerOp(CastOp castOp) {
+ MemRefType sourceType = castOp.source().getType().dyn_cast<MemRefType>();
+ MemRefType resultType = castOp.getType().dyn_cast<MemRefType>();
+
+ // 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<int64_t, 4> 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<MemRefType>();
+ auto bT = b.dyn_cast<MemRefType>();
+
+ auto uaT = a.dyn_cast<UnrankedMemRefType>();
+ auto ubT = b.dyn_cast<UnrankedMemRefType>();
+
+ if (aT && bT) {
+ if (aT.getElementType() != bT.getElementType())
+ return false;
+ if (aT.getAffineMaps() != bT.getAffineMaps()) {
+ int64_t aOffset, bOffset;
+ SmallVector<int64_t, 4> 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<Attribute> 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<DeallocOp> {
+ using OpRewritePattern<DeallocOp>::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<AllocOp>(memref.getDefiningOp()))
+ return failure();
+
+ // Check that all of the uses of the AllocOp are other DeallocOps.
+ for (auto *user : memref.getUsers())
+ if (!isa<DeallocOp>(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<MemRefType>())
+ return op.emitOpError("operand must be a memref");
+ return success();
+}
+
+void DeallocOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
+ MLIRContext *context) {
+ results.insert<SimplifyDeadDealloc>(context);
+}
+
+LogicalResult DeallocOp::fold(ArrayRef<Attribute> cstOperands,
+ SmallVectorImpl<OpFoldResult> &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<MemRefType>();
+ 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<ElementsAttr>())
+ 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<MemRefType>();
+ 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<UnitAttr>() && !initValue.isa<ElementsAttr>())
+ 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<ElementsAttr>()) {
+ 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<GlobalOp>(*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<OpAsmParser::OperandType, 4> 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<Attribute> cstOperands,
+ SmallVectorImpl<OpFoldResult> &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<ShapedType>().getElementType();
+ Type resultElementType = resultType.cast<ShapedType>().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<MemRefType>())
+ if (!operandMemRefType.getAffineMaps().empty())
+ return op.emitOpError(
+ "source memref type should have identity affine map");
+
+ int64_t shapeSize = op.shape().getType().cast<MemRefType>().getDimSize(0);
+ auto resultMemRefType = resultType.dyn_cast<MemRefType>();
+ 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<Attribute> cstOperands,
+ SmallVectorImpl<OpFoldResult> &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<int64_t, 4> sizes(rank, 0);
+ for (auto en : llvm::enumerate(permutationMap.getResults()))
+ sizes[en.index()] =
+ originalSizes[en.value().cast<AffineDimExpr>().getPosition()];
+
+ // Compute permuted strides.
+ int64_t offset;
+ SmallVector<int64_t, 4> strides;
+ auto res = getStridesAndOffset(memRefType, strides, offset);
+ assert(succeeded(res) && strides.size() == static_cast<unsigned>(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<NamedAttribute> attrs) {
+ auto permutationMap = permutation.getValue();
+ assert(permutationMap);
+
+ auto memRefType = in.getType().cast<MemRefType>();
+ // 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<MemRefType>();
+ auto dstType = op.getType().cast<MemRefType>();
+ 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<Attribute>) {
+ if (succeeded(foldMemRefCast(*this)))
+ return getResult();
+ return {};
+}
+
+//===----------------------------------------------------------------------===//
+// ViewOp
+//===----------------------------------------------------------------------===//
+
+static ParseResult parseViewOp(OpAsmParser &parser, OperationState &result) {
+ OpAsmParser::OperandType srcInfo;
+ SmallVector<OpAsmParser::OperandType, 1> offsetInfo;
+ SmallVector<OpAsmParser::OperandType, 4> 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<MemRefType>();
+ 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<ViewOp> {
+ using OpRewritePattern<ViewOp>::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<int64_t, 4> oldStrides;
+ if (failed(getStridesAndOffset(memrefType, oldStrides, oldOffset)))
+ return failure();
+ assert(oldOffset == 0 && "Expected 0 offset");
+
+ SmallVector<Value, 4> newOperands;
+
+ // Offset cannot be folded into result type.
+
+ // Fold any dynamic dim operands which are produced by a constant.
+ SmallVector<int64_t, 4> 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<ConstantIndexOp>(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>(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<CastOp>(viewOp, newViewOp, viewOp.getType());
+ return success();
+ }
+};
+
+struct ViewOpMemrefCastFolder : public OpRewritePattern<ViewOp> {
+ using OpRewritePattern<ViewOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(ViewOp viewOp,
+ PatternRewriter &rewriter) const override {
+ Value memrefOperand = viewOp.getOperand(0);
+ CastOp memrefCastOp = memrefOperand.getDefiningOp<CastOp>();
+ if (!memrefCastOp)
+ return failure();
+ Value allocOperand = memrefCastOp.getOperand();
+ AllocOp allocOp = allocOperand.getDefiningOp<AllocOp>();
+ if (!allocOp)
+ return failure();
+ rewriter.replaceOpWithNewOp<ViewOp>(viewOp, viewOp.getType(), allocOperand,
+ viewOp.byte_shift(), viewOp.sizes());
+ return success();
+ }
+};
+
+} // end anonymous namespace
+
+void ViewOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
+ MLIRContext *context) {
+ results.insert<ViewOpShapeFolder, ViewOpMemrefCastFolder>(context);
+}
+
+//===----------------------------------------------------------------------===//
+// TableGen'd op method definitions
+//===----------------------------------------------------------------------===//
+
+#define GET_OP_CLASSES
+#include "mlir/Dialect/MemRef/IR/MemRefOps.cpp.inc"
//===----------------------------------------------------------------------===//
#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"
ParallelOp firstPloop, ParallelOp secondPloop,
const BlockAndValueMapping &firstToSecondPloopIndices) {
DenseMap<Value, SmallVector<ValueRange, 1>> 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) {
#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"
}
void StandardOpsDialect::initialize() {
+ getContext()->loadDialect<memref::MemRefDialect>();
getContext()->loadDialect<tensor::TensorDialect>();
addOperations<DmaStartOp, DmaWaitOp,
#define GET_OP_LIST
//===----------------------------------------------------------------------===//
/// 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<MemRefCastOp>();
+ auto cast = operand.get().getDefiningOp<memref::CastOp>();
if (cast && !cast.getOperand().getType().isa<UnrankedMemRefType>()) {
operand.set(cast.getOperand());
folded = true;
}
//===----------------------------------------------------------------------===//
-// AllocOp / AllocaOp
-//===----------------------------------------------------------------------===//
-
-template <typename AllocLikeOp>
-static LogicalResult verifyAllocLikeOp(AllocLikeOp op) {
- static_assert(llvm::is_one_of<AllocLikeOp, AllocOp, AllocaOp>::value,
- "applies to only alloc or alloca");
- auto memRefType = op.getResult().getType().template dyn_cast<MemRefType>();
- if (!memRefType)
- return op.emitOpError("result must be a memref");
-
- if (static_cast<int64_t>(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<OpTrait::AutomaticAllocationScope>())
- return op.emitOpError(
- "requires an ancestor op with AutomaticAllocationScope trait");
-
- return verifyAllocLikeOp(op);
-}
-
-namespace {
-/// Fold constant dimensions into an alloc like operation.
-template <typename AllocLikeOp>
-struct SimplifyAllocConst : public OpRewritePattern<AllocLikeOp> {
- using OpRewritePattern<AllocLikeOp>::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<int64_t, 4> newShapeConstants;
- newShapeConstants.reserve(memrefType.getRank());
- SmallVector<Value, 4> 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<ConstantIndexOp>(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<int64_t>(newOperands.size()) ==
- newMemRefType.getNumDynamicDims());
-
- // Create and insert the alloc op for the new memref.
- auto newAlloc = rewriter.create<AllocLikeOp>(alloc.getLoc(), newMemRefType,
- newOperands, IntegerAttr());
- // Insert a cast so we have the same type as the old alloc.
- auto resultCast = rewriter.create<MemRefCastOp>(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<AllocOp> {
- using OpRewritePattern<AllocOp>::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<SimplifyAllocConst<AllocOp>, SimplifyDeadAlloc>(context);
-}
-
-void AllocaOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
- MLIRContext *context) {
- results.insert<SimplifyAllocConst<AllocaOp>>(context);
-}
-
-//===----------------------------------------------------------------------===//
// AndOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// DeallocOp
-//===----------------------------------------------------------------------===//
-namespace {
-/// Fold Dealloc operations that are deallocating an AllocOp that is only used
-/// by other Dealloc operations.
-struct SimplifyDeadDealloc : public OpRewritePattern<DeallocOp> {
- using OpRewritePattern<DeallocOp>::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<AllocOp>(memref.getDefiningOp()))
- return failure();
-
- // Check that all of the uses of the AllocOp are other DeallocOps.
- for (auto *user : memref.getUsers())
- if (!isa<DeallocOp>(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<MemRefType>())
- return op.emitOpError("operand must be a memref");
- return success();
-}
-
-void DeallocOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
- MLIRContext *context) {
- results.insert<SimplifyDeadDealloc>(context);
-}
-
-LogicalResult DeallocOp::fold(ArrayRef<Attribute> cstOperands,
- SmallVectorImpl<OpFoldResult> &results) {
- /// dealloc(memrefcast) -> dealloc
- return foldMemRefCast(*this);
-}
-
-//===----------------------------------------------------------------------===//
// DimOp
//===----------------------------------------------------------------------===//
if (!memrefType)
return {};
- if (auto alloc = dyn_cast_or_null<AllocOp>(definingOp))
+ if (auto alloc = dyn_cast_or_null<memref::AllocOp>(definingOp))
return *(alloc.getDynamicSizes().begin() +
memrefType.getDynamicDimIndex(unsignedIndex));
- if (auto view = dyn_cast_or_null<ViewOp>(definingOp))
+ if (auto view = dyn_cast_or_null<memref::ViewOp>(definingOp))
return *(view.getDynamicSizes().begin() +
memrefType.getDynamicDimIndex(unsignedIndex));
}
//===----------------------------------------------------------------------===//
-// 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<MemRefType>();
- 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<ElementsAttr>())
- 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<MemRefType>();
- 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<UnitAttr>() && !initValue.isa<ElementsAttr>())
- 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<ElementsAttr>()) {
- 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<GlobalMemrefOp>(*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
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// 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<MemRefType>();
- auto bT = b.dyn_cast<MemRefType>();
-
- auto uaT = a.dyn_cast<UnrankedMemRefType>();
- auto ubT = b.dyn_cast<UnrankedMemRefType>();
-
- if (aT && bT) {
- if (aT.getElementType() != bT.getElementType())
- return false;
- if (aT.getAffineMaps() != bT.getAffineMaps()) {
- int64_t aOffset, bOffset;
- SmallVector<int64_t, 4> 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<Attribute> operands) {
- return succeeded(foldMemRefCast(*this)) ? getResult() : Value();
-}
-
-//===----------------------------------------------------------------------===//
// MemRefReinterpretCastOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// 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<OpAsmParser::OperandType, 4> 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<Attribute> cstOperands,
- SmallVectorImpl<OpFoldResult> &results) {
- // prefetch(memrefcast) -> prefetch
- return foldMemRefCast(*this);
-}
-
-//===----------------------------------------------------------------------===//
// RankOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// 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<Attribute> cstOperands,
- SmallVectorImpl<OpFoldResult> &results) {
- /// store(memrefcast) -> store
- return foldMemRefCast(*this);
-}
-
-//===----------------------------------------------------------------------===//
// SubFOp
//===----------------------------------------------------------------------===//
static void replaceWithNewOp(PatternRewriter &rewriter, SubViewOp op,
SubViewOp newOp) {
- rewriter.replaceOpWithNewOp<MemRefCastOp>(op, newOp, op.getType());
+ rewriter.replaceOpWithNewOp<memref::CastOp>(op, newOp, op.getType());
}
static void replaceWithNewOp(PatternRewriter &rewriter, SubTensorOp op,
} // 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<?x?xf32>
-/// %2 = consumer %1 ... : memref<?x?xf32> ...
-/// ```
-///
-/// may fold into:
-///
-/// ```mlir
-/// %2 = consumer %0 ... : memref<8x16xf32> ...
-/// ```
-///
-/// Example 2:
-/// ```
-/// %1 = memref_cast %0 : memref<?x16xf32, affine_map<(i, j)->(16 * i + j)>>
-/// to memref<?x?xf32>
-/// consumer %1 : memref<?x?xf32> ...
-/// ```
-///
-/// may fold into:
-///
-/// ```
-/// consumer %0 ... : memref<?x16xf32, affine_map<(i, j)->(16 * i + j)>>
-/// ```
-bool mlir::canFoldIntoConsumerOp(MemRefCastOp castOp) {
- MemRefType sourceType = castOp.source().getType().dyn_cast<MemRefType>();
- MemRefType resultType = castOp.getType().dyn_cast<MemRefType>();
-
- // 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<int64_t, 4> 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<?x?xf32>
+/// %0 = memref.cast %V : memref<16x16xf32> to memref<?x?xf32>
/// %1 = subview %0[0, 0][3, 4][1, 1] :
/// memref<?x?xf32> 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<SubViewOp> {
}))
return failure();
- auto castOp = subViewOp.source().getDefiningOp<MemRefCastOp>();
+ auto castOp = subViewOp.source().getDefiningOp<memref::CastOp>();
if (!castOp)
return failure();
- if (!canFoldIntoConsumerOp(castOp))
+ if (!memref::CastOp::canFoldIntoConsumerOp(castOp))
return failure();
/// Deduce the resultType of the SubViewOp using `inferSubViewResultType` on
subViewOp.getLoc(), resultType, castOp.source(), subViewOp.offsets(),
subViewOp.sizes(), subViewOp.strides(), subViewOp.static_offsets(),
subViewOp.static_sizes(), subViewOp.static_strides());
- rewriter.replaceOpWithNewOp<MemRefCastOp>(subViewOp, subViewOp.getType(),
- newSubView);
+ rewriter.replaceOpWithNewOp<memref::CastOp>(subViewOp, subViewOp.getType(),
+ newSubView);
return success();
}
};
srcTensorType.getElementType());
Value memref = rewriter.create<TensorToMemrefOp>(
tensorToMemRef.getLoc(), memrefType, tensorCastOperand.getOperand());
- rewriter.replaceOpWithNewOp<MemRefCastOp>(tensorToMemRef,
- tensorToMemRef.getType(), memref);
+ rewriter.replaceOpWithNewOp<memref::CastOp>(
+ tensorToMemRef, tensorToMemRef.getType(), memref);
return success();
}
};
}
//===----------------------------------------------------------------------===//
-// 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<int64_t, 4> sizes(rank, 0);
- for (auto en : llvm::enumerate(permutationMap.getResults()))
- sizes[en.index()] =
- originalSizes[en.value().cast<AffineDimExpr>().getPosition()];
-
- // Compute permuted strides.
- int64_t offset;
- SmallVector<int64_t, 4> strides;
- auto res = getStridesAndOffset(memRefType, strides, offset);
- assert(succeeded(res) && strides.size() == static_cast<unsigned>(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<NamedAttribute> attrs) {
- auto permutationMap = permutation.getValue();
- assert(permutationMap);
-
- auto memRefType = in.getType().cast<MemRefType>();
- // 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<MemRefType>();
- auto dstType = op.getType().cast<MemRefType>();
- 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<Attribute>) {
- if (succeeded(foldMemRefCast(*this)))
- return getResult();
- return {};
-}
-
-//===----------------------------------------------------------------------===//
// TruncateIOp
//===----------------------------------------------------------------------===//
}
//===----------------------------------------------------------------------===//
-// ViewOp
-//===----------------------------------------------------------------------===//
-
-static ParseResult parseViewOp(OpAsmParser &parser, OperationState &result) {
- OpAsmParser::OperandType srcInfo;
- SmallVector<OpAsmParser::OperandType, 1> offsetInfo;
- SmallVector<OpAsmParser::OperandType, 4> 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<MemRefType>();
- 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<ViewOp> {
- using OpRewritePattern<ViewOp>::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<int64_t, 4> oldStrides;
- if (failed(getStridesAndOffset(memrefType, oldStrides, oldOffset)))
- return failure();
- assert(oldOffset == 0 && "Expected 0 offset");
-
- SmallVector<Value, 4> newOperands;
-
- // Offset cannot be folded into result type.
-
- // Fold any dynamic dim operands which are produced by a constant.
- SmallVector<int64_t, 4> 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<ConstantIndexOp>(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>(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<MemRefCastOp>(viewOp, newViewOp,
- viewOp.getType());
- return success();
- }
-};
-
-struct ViewOpMemrefCastFolder : public OpRewritePattern<ViewOp> {
- using OpRewritePattern<ViewOp>::OpRewritePattern;
-
- LogicalResult matchAndRewrite(ViewOp viewOp,
- PatternRewriter &rewriter) const override {
- Value memrefOperand = viewOp.getOperand(0);
- MemRefCastOp memrefCastOp = memrefOperand.getDefiningOp<MemRefCastOp>();
- if (!memrefCastOp)
- return failure();
- Value allocOperand = memrefCastOp.getOperand();
- AllocOp allocOp = allocOperand.getDefiningOp<AllocOp>();
- if (!allocOp)
- return failure();
- rewriter.replaceOpWithNewOp<ViewOp>(viewOp, viewOp.getType(), allocOperand,
- viewOp.byte_shift(), viewOp.sizes());
- return success();
- }
-};
-
-} // end anonymous namespace
-
-void ViewOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
- MLIRContext *context) {
- results.insert<ViewOpShapeFolder, ViewOpMemrefCastFolder>(context);
-}
-
-//===----------------------------------------------------------------------===//
// XOrOp
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
#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"
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<Attribute, GlobalMemrefOp> globals;
+ DenseMap<Attribute, memref::GlobalOp> globals;
};
GlobalCreator::GlobalCreator(ModuleOp module) {
interleave(type.getShape(), os, "x");
os << "x" << type.getElementType();
- auto global = globalBuilder.create<GlobalMemrefOp>(
+ auto global = globalBuilder.create<memref::GlobalOp>(
op.getLoc(), (Twine("__constant_") + os.str()).str(),
/*sym_visibility=*/globalBuilder.getStringAttr("private"),
/*type=*/
return failure();
auto globalMemref = globals.getGlobalFor(op.value());
- rewriter.replaceOpWithNewOp<GetGlobalMemrefOp>(op, globalMemref.type(),
- globalMemref.getName());
+ rewriter.replaceOpWithNewOp<memref::GetGlobalOp>(op, globalMemref.type(),
+ globalMemref.getName());
return success();
}
GlobalCreator &globals;
#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"
matchAndRewrite(tensor::CastOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto resultType = getTypeConverter()->convertType(op.getType());
- rewriter.replaceOpWithNewOp<MemRefCastOp>(op, resultType, operands[0]);
+ rewriter.replaceOpWithNewOp<memref::CastOp>(op, resultType, operands[0]);
return success();
}
};
int numberOfElements = op.elements().size();
auto resultType = MemRefType::get(
{numberOfElements}, op.getType().cast<TensorType>().getElementType());
- Value result = rewriter.create<AllocOp>(op.getLoc(), resultType);
+ Value result = rewriter.create<memref::AllocOp>(op.getLoc(), resultType);
for (auto element : llvm::enumerate(op.elements())) {
Value index =
rewriter.create<ConstantIndexOp>(op.getLoc(), element.index());
- rewriter.create<StoreOp>(op.getLoc(), element.value(), result, index);
+ rewriter.create<memref::StoreOp>(op.getLoc(), element.value(), result,
+ index);
}
rewriter.replaceOp(op, {result});
return success();
RankedTensorType tensorType = op.getType().cast<RankedTensorType>();
MemRefType memrefType =
MemRefType::get(tensorType.getShape(), tensorType.getElementType());
- Value result =
- rewriter.create<AllocOp>(loc, memrefType, transformed.dynamicExtents());
+ Value result = rewriter.create<memref::AllocOp>(
+ loc, memrefType, transformed.dynamicExtents());
// Collect loop bounds.
int64_t rank = tensorType.getRank();
// about creating that.
Operation *elementYield = parallelBody->getTerminator()->getPrevNode();
rewriter.setInsertionPointAfter(elementYield);
- rewriter.replaceOpWithNewOp<StoreOp>(elementYield,
- elementYield->getOperands()[0], result,
- parallelBody->getArguments());
+ rewriter.replaceOpWithNewOp<memref::StoreOp>(
+ elementYield, elementYield->getOperands()[0], result,
+ parallelBody->getArguments());
rewriter.replaceOp(op, {result});
return success();
populateTensorBufferizePatterns(context, typeConverter, patterns);
target.addIllegalOp<tensor::CastOp, tensor::ExtractOp,
tensor::FromElementsOp, tensor::GenerateOp>();
+ target.addLegalDialect<memref::MemRefDialect>();
target.addLegalDialect<StandardOpsDialect>();
target.addLegalDialect<scf::SCFDialect>();
//===----------------------------------------------------------------------===//
#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"
/// ```
/// 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<MemRefCastOp>();
- if (castOp && canFoldIntoConsumerOp(castOp)) {
+ auto castOp = operand.get().getDefiningOp<memref::CastOp>();
+ if (castOp && memref::CastOp::canFoldIntoConsumerOp(castOp)) {
operand.set(castOp.getOperand());
folded = true;
}
#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"
/// 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();
/// Produce IR resembling:
/// ```
/// %1:3 = scf.if (%inBounds) {
-/// memref_cast %A: memref<A...> to compatibleMemRefType
+/// memref.cast %A: memref<A...> 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<B...> to compatibleMemRefType
+/// memref.cast %alloc: memref<B...> to compatibleMemRefType
/// scf.yield %4, ... : compatibleMemRefType, index, index
/// }
/// ```
[&]() -> 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());
Value memRefSubView = createScopedSubViewIntersection(
cast<VectorTransferOpInterface>(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);
/// Produce IR resembling:
/// ```
/// %1:3 = scf.if (%inBounds) {
-/// memref_cast %A: memref<A...> to compatibleMemRefType
+/// memref.cast %A: memref<A...> to compatibleMemRefType
/// scf.yield %view, ... : compatibleMemRefType, index, index
/// } else {
/// %2 = vector.transfer_read %view[...], %pad : memref<A...>, vector<...>
/// %3 = vector.type_cast %extra_alloc :
/// memref<...> to memref<vector<...>>
/// store %2, %3[] : memref<vector<...>>
-/// %4 = memref_cast %alloc: memref<B...> to compatibleMemRefType
+/// %4 = memref.cast %alloc: memref<B...> to compatibleMemRefType
/// scf.yield %4, ... : compatibleMemRefType, index, index
/// }
/// ```
[&]() -> 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());
Operation *newXfer =
ScopedContext::getBuilderRef().clone(*xferOp.getOperation());
Value vector = cast<VectorTransferOpInterface>(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);
/// ```
/// %1:3 = scf.if (%inBounds) {
/// // fastpath, direct cast
-/// memref_cast %A: memref<A...> to compatibleMemRefType
+/// memref.cast %A: memref<A...> to compatibleMemRefType
/// scf.yield %view : compatibleMemRefType, index, index
/// } else {
/// // slowpath, masked vector.transfer or linalg.copy.
-/// memref_cast %alloc: memref<B...> to compatibleMemRefType
+/// memref.cast %alloc: memref<B...> to compatibleMemRefType
/// scf.yield %4 : compatibleMemRefType, index, index
// }
/// %0 = vector.transfer_read %1#0[%1#1, %1#2] {masked = [false ... false]}
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 =
#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"
// TODO: provide a generic interface to create dialect-specific
// Alloc and CopyOp nodes.
- auto alloc = builder.create<AllocOp>(terminator->getLoc(), memRefType,
- dynamicOperands);
+ auto alloc = builder.create<memref::AllocOp>(terminator->getLoc(),
+ memRefType, dynamicOperands);
// Create a new copy operation that copies to contents of the old
// allocation to the new one.
continue;
// If there is no dealloc node, insert one in the right place.
OpBuilder builder(nextOp);
- builder.create<DeallocOp>(alloc.getLoc(), alloc);
+ builder.create<memref::DeallocOp>(alloc.getLoc(), alloc);
}
}
}
// 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"
unsigned bitwidthOfIndexType,
unsigned maxRankOfAllocatedMemRef) {
auto type = alloc.getType().dyn_cast<ShapedType>();
- if (!type || !alloc.getDefiningOp<AllocOp>())
+ if (!type || !alloc.getDefiningOp<memref::AllocOp>())
return false;
if (!type.hasStaticShape()) {
// Check if the dynamic shape dimension of the alloc is produced by RankOp.
// `AutomaticAllocationScope` determined during the initialization phase.
OpBuilder builder(startOperation);
Operation *allocOp = alloc.getDefiningOp();
- Operation *alloca = builder.create<AllocaOp>(
+ Operation *alloca = builder.create<memref::AllocaOp>(
alloc.getLoc(), alloc.getType().cast<MemRefType>(),
allocOp->getOperands());
#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"
didFail = true;
return;
}
- Value outParam = builder.create<AllocOp>(
+ Value outParam = builder.create<memref::AllocOp>(
op.getLoc(), memref.getType().cast<MemRefType>());
memref.replaceAllUsesWith(outParam);
outParams.push_back(outParam);
#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"
// 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<AllocOp>(forOp.getLoc(), newMemRefType);
+ Value newMemRef = top.create<memref::AllocOp>(forOp.getLoc(), newMemRefType);
// Build an AffineMap to remap access functions based on lower bound offsets.
SmallVector<AffineExpr, 4> remapExprs;
continue;
// Use list expected to match the dep graph info.
auto *op = memref.getDefiningOp();
- if (isa_and_nonnull<AllocOp>(op))
+ if (isa_and_nonnull<memref::AllocOp>(op))
op->erase();
}
}
#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"
// Perform the actual store to load forwarding.
Value storeVal =
- cast<AffineWriteOpInterface>(lastWriteStoreOp).getValueToStore();
+ cast<AffineWriteOpInterface>(lastWriteStoreOp).getValueToStore();
loadOp.getValue().replaceAllUsesWith(storeVal);
// Record the memref for a later sweep to optimize away.
memrefsToErase.insert(loadOp.getMemRef());
for (auto memref : memrefsToErase) {
// If the memref hasn't been alloc'ed in this function, skip.
Operation *defOp = memref.getDefiningOp();
- if (!defOp || !isa<AllocOp>(defOp))
+ if (!defOp || !isa<memref::AllocOp>(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<AffineWriteOpInterface, DeallocOp>(ownerOp);
+ return !isa<AffineWriteOpInterface, memref::DeallocOp>(ownerOp);
}))
continue;
#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"
return true;
if (funcOp
- .walk([&](AllocOp allocOp) -> WalkResult {
+ .walk([&](memref::AllocOp allocOp) -> WalkResult {
Value oldMemRef = allocOp.getResult();
if (!isMemRefNormalizable(oldMemRef.getUsers()))
return WalkResult::interrupt();
// 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<AllocOp, 4> allocOps;
- funcOp.walk([&](AllocOp op) { allocOps.push_back(op); });
- for (AllocOp allocOp : allocOps)
+ SmallVector<memref::AllocOp, 4> 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.
auto allocOperands = getDynOperands(forOp.getLoc(), oldMemRef, bOuter);
// Create and place the alloc right before the 'affine.for' operation.
- Value newMemRef =
- bOuter.create<AllocOp>(forOp.getLoc(), newMemRefType, allocOperands);
+ Value newMemRef = bOuter.create<memref::AllocOp>(
+ forOp.getLoc(), newMemRefType, allocOperands);
// Create 'iv mod 2' value to index the leading dimension.
auto d0 = bInner.getAffineDimExpr(0);
}
// Insert the dealloc op right after the for loop.
bOuter.setInsertionPointAfter(forOp);
- bOuter.create<DeallocOp>(forOp.getLoc(), newMemRef);
+ bOuter.create<memref::DeallocOp>(forOp.getLoc(), newMemRef);
return true;
}
bool escapingUses = false;
for (auto *user : memref.getUsers()) {
// We can double buffer regardless of dealloc's outside the loop.
- if (isa<DeallocOp>(user))
+ if (isa<memref::DeallocOp>(user))
continue;
if (!forOp.getBody()->findAncestorOpInBlock(*user)) {
LLVM_DEBUG(llvm::dbgs()
if (oldMemRef.use_empty()) {
allocOp->erase();
} else if (oldMemRef.hasOneUse()) {
- if (auto dealloc = dyn_cast<DeallocOp>(*oldMemRef.user_begin())) {
+ if (auto dealloc =
+ dyn_cast<memref::DeallocOp>(*oldMemRef.user_begin())) {
dealloc.erase();
allocOp->erase();
}
if (oldTagMemRef.use_empty()) {
tagAllocOp->erase();
} else if (oldTagMemRef.hasOneUse()) {
- if (auto dealloc = dyn_cast<DeallocOp>(*oldTagMemRef.user_begin())) {
+ if (auto dealloc =
+ dyn_cast<memref::DeallocOp>(*oldTagMemRef.user_begin())) {
dealloc.erase();
tagAllocOp->erase();
}
#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"
// Create the fast memory space buffer just before the 'affine.for'
// operation.
- fastMemRef = prologue.create<AllocOp>(loc, fastMemRefType).getResult();
+ fastMemRef =
+ prologue.create<memref::AllocOp>(loc, fastMemRefType).getResult();
// Record it.
fastBufferMap[memref] = fastMemRef;
// fastMemRefType is a constant shaped memref.
// 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<AllocOp>(loc, tagMemRefType);
+ auto tagMemRef = prologue.create<memref::AllocOp>(loc, tagMemRefType);
SmallVector<Value, 4> tagIndices({zeroIndex});
auto tagAffineMap = b.getMultiDimIdentityMap(tagIndices.size());
numElementsSSA);
// Generate dealloc for the tag.
- auto tagDeallocOp = epilogue.create<DeallocOp>(loc, tagMemRef);
+ auto tagDeallocOp = epilogue.create<memref::DeallocOp>(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.
// Generate dealloc for the buffer.
if (!existingBuf) {
- auto bufDeallocOp = epilogue.create<DeallocOp>(loc, fastMemRef);
+ auto bufDeallocOp = epilogue.create<memref::DeallocOp>(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)
// Skip dealloc's - no replacement is necessary, and a memref replacement
// at other uses doesn't hurt these dealloc's.
- if (isa<DeallocOp>(op) && !replaceInDeallocOp)
+ if (isa<memref::DeallocOp>(op) && !replaceInDeallocOp)
continue;
// Check if the memref was used in a non-dereferencing context. It is fine
}
// 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);
Value oldMemRef = allocOp.getResult();
SmallVector<Value, 4> symbolOperands(allocOp.symbolOperands());
- AllocOp newAlloc = b.create<AllocOp>(allocOp.getLoc(), newMemRefType,
- allocOp.alignmentAttr());
+ memref::AllocOp newAlloc = b.create<memref::AllocOp>(
+ allocOp.getLoc(), newMemRefType, allocOp.alignmentAttr());
AffineMap layoutMap = memrefType.getAffineMaps().front();
// Replace all uses of the old memref.
if (failed(replaceAllMemRefUsesWith(oldMemRef, /*newMemRef=*/newAlloc,
}
// 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<DeallocOp>(op); }));
+ assert(llvm::all_of(oldMemRef.getUsers(), [](Operation *op) {
+ return isa<memref::DeallocOp>(op);
+ }));
oldMemRef.replaceAllUsesWith(newAlloc);
allocOp.erase();
return success();
// 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
}
// 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>)
// 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>)
// 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>
// 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>
// 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<?xi8>
- %3 = view %2[%c0][] {test.ptr = "view"} : memref<?xi8> to memref<8x64xf32>
+ %2 = memref.alloca (%size) {test.ptr = "alloca_1"} : memref<?xi8>
+ %3 = memref.view %2[%c0][] {test.ptr = "view"} : memref<?xi8> to memref<8x64xf32>
return
}
// 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
// CHECK-NEXT: LiveOut:{{ *$}}
%2 = addi %0, %arg5 : i32
%3 = addi %2, %0 : i32
- store %3, %buffer[] : memref<i32>
+ memref.store %3, %buffer[] : memref<i32>
}
return %1 : i32
}
%2 = addi %0, %arg5 : i32
scf.for %arg7 = %arg0 to %arg1 step %arg2 {
%3 = addi %2, %0 : i32
- store %3, %buffer[] : memref<i32>
+ memref.store %3, %buffer[] : memref<i32>
}
}
return %1 : i32
// CHECK-NEXT: LiveIn: arg5@0 arg6@0 val_7
// CHECK-NEXT: LiveOut:{{ *$}}
%2 = addi %0, %arg5 : i32
- store %2, %buffer[] : memref<i32>
+ memref.store %2, %buffer[] : memref<i32>
}
br ^exit
// CHECK-NEXT: LiveIn: arg6@0 val_7 val_8
// CHECK-NEXT: LiveOut:{{ *$}}
%2 = addi %0, %1 : i32
- store %2, %buffer[] : memref<i32>
+ memref.store %2, %buffer[] : memref<i32>
}
return %1 : i32
}
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);
// CHECK: %[[LHS:.*]] = load %[[ARG0]][%[[I]]] : memref<?xf32>
// CHECK: %[[RHS:.*]] = load %[[ARG1]][%[[I]]] : memref<?xf32>
// CHECK: %[[SUM:.*]] = addf %[[LHS]], %[[RHS]] : f32
- // CHECK: store %[[SUM]], %[[ARG0]][%[[I]]] : memref<?xf32>
+ // CHECK: memref.store %[[SUM]], %[[ARG0]][%[[I]]] : memref<?xf32>
// CHECK: }
// CHECK: return
// CHECK: }
// CHECK: %[[LHS:.*]] = load %{{.*}}[%[[I]]] : memref<?xf32>
// CHECK: %[[RHS:.*]] = load %{{.*}}[%[[I]]] : memref<?xf32>
// CHECK: %[[SUM:.*]] = addf %[[LHS]], %[[RHS]] : f32
- // CHECK: store %[[SUM]], %{{.*}}[%[[I]]] : memref<?xf32>
+ // CHECK: memref.store %[[SUM]], %{{.*}}[%[[I]]] : memref<?xf32>
// CHECK: }
// CHECK: return
// CHECK: First operation: {{.*}} = constant 0 : index
// 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
// 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
// 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>
// 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:.*]] =
// 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>
}
// 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>
// 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 {
// 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>
/////////////////////////////////////////////////////////////////////
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>
// 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]])
// 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.
%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]])
// 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.
// 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]])
// -----
// 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
// 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.
// 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]])
// -----
// 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"() : () -> ()
}
// 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"() : () -> ()
}
// 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"() : () -> ()
}
}
// ROCDL: llvm.alloca %[[c4]] x f32 : (i64) -> !llvm.ptr<f32, 5>
%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"() : () -> ()
}
}
%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
}
%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
}
}
// 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"}
}
}
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)
// CHECK: %[[v0:.*]] = dim %[[arg1]], %[[c0]] : memref<?xf32>
// CHECK: %[[v1:.*]] = dim %[[arg2]], %[[c0]] : memref<?xf32>
// CHECK: %[[v2:.*]] = dim %[[arg0]], %[[c0]] : memref<?xf32>
-// CHECK: %[[v3:.*]] = alloc(%[[c12]]) : memref<?xi8>
-// CHECK: %[[v4:.*]] = alloc(%[[c12]]) : memref<?xi8>
-// CHECK: %[[v5:.*]] = alloc(%[[c4]]) : memref<?xi8>
-// CHECK: %[[v6:.*]] = std.view %[[v3]][%[[c0]]][] : memref<?xi8> to memref<3xf32>
-// CHECK: %[[v7:.*]] = std.view %[[v4]][%[[c0]]][] : memref<?xi8> to memref<3xf32>
-// CHECK: %[[v8:.*]] = std.view %[[v5]][%[[c0]]][] : memref<?xi8> to memref<1xf32>
+// CHECK: %[[v3:.*]] = memref.alloc(%[[c12]]) : memref<?xi8>
+// CHECK: %[[v4:.*]] = memref.alloc(%[[c12]]) : memref<?xi8>
+// CHECK: %[[v5:.*]] = memref.alloc(%[[c4]]) : memref<?xi8>
+// CHECK: %[[v6:.*]] = memref.view %[[v3]][%[[c0]]][] : memref<?xi8> to memref<3xf32>
+// CHECK: %[[v7:.*]] = memref.view %[[v4]][%[[c0]]][] : memref<?xi8> to memref<3xf32>
+// CHECK: %[[v8:.*]] = memref.view %[[v5]][%[[c0]]][] : memref<?xi8> 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<?xf32> to memref<?xf32, #[[$map1]]>
// CHECK-BLOCKS-NEXT: %[[INDEX:.*]] = addi %{{.*}}, %[[B0]]
// CHECK-BLOCKS-NEXT: load %{{.*}}[%[[INDEX]]]
%0 = load %A[%i] : memref<?xf32>
- store %0, %B[%i] : memref<?xf32>
+ memref.store %0, %B[%i] : memref<?xf32>
// CHECK-THREADS: gpu.terminator
// CHECK-BLOCKS: gpu.terminator
}
scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3)
step (%arg4, %step) {
%val = load %buf[%i0, %i1] : memref<?x?xf32>
- store %val, %res[%i1, %i0] : memref<?x?xf32>
+ memref.store %val, %res[%i1, %i0] : memref<?x?xf32>
} { 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
}
// 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<?x?xf32>
-// CHECK: store [[VAL_25]], [[VAL_6]]{{\[}}[[VAL_24]], [[VAL_23]]] : memref<?x?xf32>
+// CHECK: memref.store [[VAL_25]], [[VAL_6]]{{\[}}[[VAL_24]], [[VAL_23]]] : memref<?x?xf32>
// CHECK: gpu.terminator
// CHECK: }
// CHECK: return
%idx0 = addi %i0, %si0 : index
%idx1 = addi %i1, %si1 : index
%val = load %buf[%idx0, %idx1] : memref<?x?xf32>
- store %val, %res[%idx1, %idx0] : memref<?x?xf32>
+ memref.store %val, %res[%idx1, %idx0] : memref<?x?xf32>
} { 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)>}
// 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<?x?xf32>
-// CHECK: store [[VAL_58]], [[VAL_31]]{{\[}}[[VAL_57]], [[VAL_56]]] : memref<?x?xf32>
+// CHECK: memref.store [[VAL_58]], [[VAL_31]]{{\[}}[[VAL_57]], [[VAL_56]]] : memref<?x?xf32>
// CHECK: gpu.terminator
// CHECK: }
// CHECK: return
scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3)
step (%arg4, %step) {
%val = load %buf[%i0, %i1] : memref<?x?xf32>
- store %val, %res[%i1, %i0] : memref<?x?xf32>
+ memref.store %val, %res[%i1, %i0] : memref<?x?xf32>
} { 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)>}
// 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<?x?xf32>
-// CHECK: store [[VAL_83]], [[VAL_65]]{{\[}}[[VAL_82]], [[VAL_81]]] : memref<?x?xf32>
+// CHECK: memref.store [[VAL_83]], [[VAL_65]]{{\[}}[[VAL_82]], [[VAL_81]]] : memref<?x?xf32>
// CHECK: }
// CHECK: gpu.terminator
// CHECK: }
%idx0 = addi %i0, %si0 : index
%idx1 = addi %i1, %si1 : index
%val = load %buf[%idx0, %idx1] : memref<?x?xf32>
- store %val, %res[%idx1, %idx0] : memref<?x?xf32>
+ memref.store %val, %res[%idx1, %idx0] : memref<?x?xf32>
} { 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)>}
// 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<?x?xf32>
-// CHECK: store [[VAL_114]], [[VAL_89]]{{\[}}[[VAL_113]], [[VAL_112]]] : memref<?x?xf32>
+// CHECK: memref.store [[VAL_114]], [[VAL_89]]{{\[}}[[VAL_113]], [[VAL_112]]] : memref<?x?xf32>
// CHECK: }
// CHECK: }
// CHECK: gpu.terminator
%18 = load %11[%arg5, %arg6] : memref<?x?xf32, #map3>
%19 = load %16[%arg5, %arg6] : memref<?x?xf32, #map3>
%20 = addf %17, %18 : f32
- store %20, %16[%arg5, %arg6] : memref<?x?xf32, #map3>
+ memref.store %20, %16[%arg5, %arg6] : memref<?x?xf32, #map3>
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
// CHECK: [[VAL_50:%.*]] = load [[VAL_39]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref<?x?xf32, #[[$MAP5]]>
// CHECK: [[VAL_51:%.*]] = load [[VAL_44]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref<?x?xf32, #[[$MAP5]]>
// CHECK: [[VAL_52:%.*]] = addf [[VAL_49]], [[VAL_50]] : f32
-// CHECK: store [[VAL_52]], [[VAL_44]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref<?x?xf32, #[[$MAP5]]>
+// CHECK: memref.store [[VAL_52]], [[VAL_44]]{{\[}}[[VAL_45]], [[VAL_47]]] : memref<?x?xf32, #[[$MAP5]]>
// CHECK: }
// CHECK: }
// CHECK: gpu.terminator
%idx0 = addi %i0, %si0 : index
%idx1 = addi %i1, %si1 : index
%val = load %buf[%idx0, %idx1] : memref<?x?xf32>
- store %val, %res[%idx1, %idx0] : memref<?x?xf32>
+ memref.store %val, %res[%idx1, %idx0] : memref<?x?xf32>
} { 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)>}
// CHECK-11: {{.*}} = load %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>
// CHECK-22: {{.*}} = load %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>
%0 = load %A[%i, %j, %ii, %jj] : memref<?x?x?x?xf32>
- // CHECK-11-NEXT: store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>
- // CHECK-22-NEXT: store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>
- store %0, %B[%i, %j, %ii, %jj] : memref<?x?x?x?xf32>
+ // CHECK-11-NEXT: memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>
+ // CHECK-22-NEXT: memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>
+ memref.store %0, %B[%i, %j, %ii, %jj] : memref<?x?x?x?xf32>
// CHECK-11: gpu.terminator
// CHECK-22: gpu.terminator
// CHECK: {{.*}} = load %{{.*}}[%[[i]], %[[j]]] : memref<?x?xf32>
%0 = load %A[%i, %j] : memref<?x?xf32>
- // CHECK: store {{.*}}, %{{.*}}[%[[i]], %[[j]]] : memref<?x?xf32>
- store %0, %B[%i, %j] : memref<?x?xf32>
+ // CHECK: memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]]] : memref<?x?xf32>
+ memref.store %0, %B[%i, %j] : memref<?x?xf32>
}
}
return
// 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
}
// 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
}
// CHECK-NEXT: spv.Return
scf.if %arg3 {
- store %value, %arg2[%i] : memref<10xf32>
+ memref.store %value, %arg2[%i] : memref<10xf32>
}
return
}
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
}
%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
}
} else {
scf.yield %arg3 : memref<10xf32>
}
- store %value, %0[%i] : memref<10xf32>
+ memref.store %value, %0[%i] : memref<10xf32>
return
}
// RUN: mlir-opt --lower-host-to-llvm %s | FileCheck %s
-
+
module attributes {gpu.container_module, spv.target_env = #spv.target_env<#spv.vce<v1.0, [Shader], [SPV_KHR_variable_pointers]>, {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>)>
// CHECK: spv.module @__spv__foo
// CHECK: spv.globalVariable @bar_arg_0 bind(0, 0) : !spv.ptr<!spv.struct<(!spv.array<6 x i32, stride=4> [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
}
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>)
// CHECK: %[[DESC_0:.*]] = llvm.mlir.undef : !llvm.struct<(i64, ptr<i8>)>
// 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)
// CHECK: %[[DESC_0:.*]] = llvm.mlir.undef : !llvm.struct<(i64, ptr<i8>)>
// 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
// CHECK-NEXT: llvm.insertvalue %[[st0]], %{{.*}}[4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<3 x i64>, array<3 x i64>)>
// CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[4, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<3 x i64>, array<3 x i64>)>
// CHECK-NEXT: llvm.insertvalue %[[one]], %{{.*}}[4, 2] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<3 x i64>, array<3 x i64>)>
- %0 = alloc(%arg0, %arg1) : memref<?x42x?xf32>
+ %0 = memref.alloc(%arg0, %arg1) : memref<?x42x?xf32>
// CHECK-NEXT: llvm.return %{{.*}} : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<3 x i64>, array<3 x i64>)>
return %0 : memref<?x42x?xf32>
}
// CHECK: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<3 x i64>, array<3 x i64>)>
// CHECK-NEXT: %[[ptri8:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr<f32> to !llvm.ptr<i8>
// CHECK-NEXT: llvm.call @free(%[[ptri8]]) : (!llvm.ptr<i8>) -> ()
- dealloc %arg0 : memref<?x42x?xf32>
+ memref.dealloc %arg0 : memref<?x42x?xf32>
// CHECK-NEXT: llvm.return
return
}
// CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[3, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK-NEXT: llvm.insertvalue %[[one]], %{{.*}}[4, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
- %0 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %0 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
// CHECK-NEXT: llvm.return %{{.*}} : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
return %0 : memref<?x?xf32>
}
// CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[3, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK-NEXT: llvm.insertvalue %[[N]], %{{.*}}[4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK-NEXT: llvm.insertvalue %[[st1]], %{{.*}}[4, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
- %0 = alloca(%arg0, %arg1) : memref<?x?xf32>
+ %0 = memref.alloca(%arg0, %arg1) : memref<?x?xf32>
// Test with explicitly specified alignment. llvm.alloca takes care of the
// alignment. The same pointer is thus used for allocation and aligned
// CHECK: %[[desc:.*]] = llvm.mlir.undef : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: %[[desc1:.*]] = llvm.insertvalue %[[alloca_aligned]], %[[desc]][0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.insertvalue %[[alloca_aligned]], %[[desc1]][1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
- alloca(%arg0, %arg1) {alignment = 32} : memref<?x?xf32>
+ memref.alloca(%arg0, %arg1) {alignment = 32} : memref<?x?xf32>
return %0 : memref<?x?xf32>
}
// CHECK: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK-NEXT: %[[ptri8:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr<f32> to !llvm.ptr<i8>
// CHECK-NEXT: llvm.call @free(%[[ptri8]]) : (!llvm.ptr<i8>) -> ()
- dealloc %arg0 : memref<?x?xf32>
+ memref.dealloc %arg0 : memref<?x?xf32>
return
}
// ALIGNED-ALLOC-NEXT: %[[alignment:.*]] = llvm.mlir.constant(32 : index) : i64
// ALIGNED-ALLOC-NEXT: %[[allocated:.*]] = llvm.call @aligned_alloc(%[[alignment]], %[[bytes]]) : (i64, i64) -> !llvm.ptr<i8>
// ALIGNED-ALLOC-NEXT: llvm.bitcast %[[allocated]] : !llvm.ptr<i8> to !llvm.ptr<f32>
- %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
// 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<?xvector<18xf32>>
+ %6 = memref.alloc(%N) : memref<?xvector<18xf32>>
return %0 : memref<32x18xf32>
}
// 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<f32>, i32, i32, i32) -> ()
- prefetch %A[%i, %j], write, locality<3>, data : memref<?x?xf32>
+ memref.prefetch %A[%i, %j], write, locality<3>, data : memref<?x?xf32>
// 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<f32>, i32, i32, i32) -> ()
- prefetch %A[%i, %j], read, locality<0>, data : memref<?x?xf32>
+ memref.prefetch %A[%i, %j], read, locality<0>, data : memref<?x?xf32>
// 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<f32>, i32, i32, i32) -> ()
- prefetch %A[%i, %j], read, locality<2>, instr : memref<?x?xf32>
+ memref.prefetch %A[%i, %j], read, locality<2>, instr : memref<?x?xf32>
return
}
// CHECK-NEXT: %[[off1:.*]] = llvm.add %[[offI]], %[[J]] : i64
// CHECK-NEXT: %[[addr:.*]] = llvm.getelementptr %[[ptr]][%[[off1]]] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
// CHECK-NEXT: llvm.store %{{.*}}, %[[addr]] : !llvm.ptr<f32>
- store %val, %dynamic[%i, %j] : memref<?x?xf32>
+ memref.store %val, %dynamic[%i, %j] : memref<?x?xf32>
return
}
// CHECK-NEXT: %[[off1:.*]] = llvm.add %[[offI]], %[[J]] : i64
// CHECK-NEXT: %[[addr:.*]] = llvm.getelementptr %[[ptr]][%[[off1]]] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
// CHECK-NEXT: llvm.store %{{.*}}, %[[addr]] : !llvm.ptr<f32>
- 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<?x?xf32>
+ %0 = memref.cast %static : memref<10x42xf32> to memref<?x?xf32>
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<?x42xf32>
+ %0 = memref.cast %static : memref<10x42xf32> to memref<?x42xf32>
return
}
// CHECK-LABEL: func @memref_cast_dynamic_to_static
func @memref_cast_dynamic_to_static(%dynamic : memref<?x?xf32>) {
// CHECK-NOT: llvm.bitcast
- %0 = memref_cast %dynamic : memref<?x?xf32> to memref<10x12xf32>
+ %0 = memref.cast %dynamic : memref<?x?xf32> to memref<10x12xf32>
return
}
// CHECK-LABEL: func @memref_cast_dynamic_to_mixed
func @memref_cast_dynamic_to_mixed(%dynamic : memref<?x?xf32>) {
// CHECK-NOT: llvm.bitcast
- %0 = memref_cast %dynamic : memref<?x?xf32> to memref<?x12xf32>
+ %0 = memref.cast %dynamic : memref<?x?xf32> to memref<?x12xf32>
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<?x?xf32>
+ %0 = memref.cast %mixed : memref<42x?xf32> to memref<?x?xf32>
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<?x1xf32>
+ %0 = memref.cast %mixed : memref<42x?xf32> to memref<?x1xf32>
return
}
// CHECK : llvm.mlir.undef : !llvm.struct<(i64, ptr<i8>)>
// CHECK-DAG: llvm.insertvalue %[[r]], %{{.*}}[0] : !llvm.struct<(i64, ptr<i8>)>
// CHECK-DAG: llvm.insertvalue %[[p2]], %{{.*}}[1] : !llvm.struct<(i64, ptr<i8>)>
- %0 = memref_cast %arg : memref<42x2x?xf32> to memref<*xf32>
+ %0 = memref.cast %arg : memref<42x2x?xf32> to memref<*xf32>
return
}
func @memref_cast_unranked_to_ranked(%arg : memref<*xf32>) {
// CHECK: %[[p:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(i64, ptr<i8>)>
// CHECK-NEXT: llvm.bitcast %[[p]] : !llvm.ptr<i8> to !llvm.ptr<struct<(ptr<f32>, ptr<f32>, i64, array<4 x i64>, array<4 x i64>)>>
- %0 = memref_cast %arg : memref<*xf32> to memref<?x?x10x2xf32>
+ %0 = memref.cast %arg : memref<*xf32> to memref<?x?x10x2xf32>
return
}
// BAREPTR-NEXT: llvm.insertvalue %[[ptr]], %{{.*}}[1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64)>
// BAREPTR-NEXT: %[[c0:.*]] = llvm.mlir.constant(0 : index) : i64
// BAREPTR-NEXT: llvm.insertvalue %[[c0]], %{{.*}}[2] : !llvm.struct<(ptr<f32>, ptr<f32>, i64)>
- %0 = alloc() : memref<f32>
+ %0 = memref.alloc() : memref<f32>
return %0 : memref<f32>
}
// BAREPTR: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64)>
// BAREPTR-NEXT: %[[bc:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr<f32> to !llvm.ptr<i8>
// BAREPTR-NEXT: llvm.call @free(%[[bc]]) : (!llvm.ptr<i8>) -> ()
- dealloc %arg0 : memref<f32>
+ memref.dealloc %arg0 : memref<f32>
return
}
// BAREPTR-NEXT: llvm.insertvalue %[[alignedBitCast]], %{{.*}}[1] : !llvm.struct<(ptr<f32>, ptr<f32>, 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<f32>, ptr<f32>, 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>
}
// BAREPTR-NEXT: %[[size_bytes:.*]] = llvm.ptrtoint %[[gep]] : !llvm.ptr<f32> to i64
// BAREPTR-NEXT: %[[allocated:.*]] = llvm.call @malloc(%[[size_bytes]]) : (i64) -> !llvm.ptr<i8>
// BAREPTR-NEXT: llvm.bitcast %[[allocated]] : !llvm.ptr<i8> to !llvm.ptr<f32>
- %0 = alloc() : memref<32x18xf32>
+ %0 = memref.alloc() : memref<32x18xf32>
return %0 : memref<32x18xf32>
}
// CHECK-NEXT: %[[gep:.*]] = llvm.getelementptr %[[null]][%[[num_elems]]] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
// CHECK-NEXT: %[[size_bytes:.*]] = llvm.ptrtoint %[[gep]] : !llvm.ptr<f32> to i64
// CHECK-NEXT: %[[allocated:.*]] = llvm.alloca %[[size_bytes]] x f32 : (i64) -> !llvm.ptr<f32>
- %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
// CHECK: %[[desc:.*]] = llvm.mlir.undef : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: %[[desc1:.*]] = llvm.insertvalue %[[alloca_aligned]], %[[desc]][0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.insertvalue %[[alloca_aligned]], %[[desc1]][1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
- alloca() {alignment = 32} : memref<32x18xf32>
+ memref.alloca() {alignment = 32} : memref<32x18xf32>
return %0 : memref<32x18xf32>
}
// BAREPTR: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// BAREPTR-NEXT: %[[bc:.*]] = llvm.bitcast %[[ptr]] : !llvm.ptr<f32> to !llvm.ptr<i8>
// BAREPTR-NEXT: llvm.call @free(%[[bc]]) : (!llvm.ptr<i8>) -> ()
- dealloc %static : memref<10x8xf32>
+ memref.dealloc %static : memref<10x8xf32>
return
}
// BAREPTR: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64)>
// BAREPTR-NEXT: llvm.store %[[val]], %[[ptr]] : !llvm.ptr<f32>
- store %arg1, %arg0[] : memref<f32>
+ memref.store %arg1, %arg0[] : memref<f32>
return
}
// BAREPTR-NEXT: %[[off1:.*]] = llvm.add %[[offI]], %[[J]] : i64
// BAREPTR-NEXT: %[[addr:.*]] = llvm.getelementptr %[[ptr]][%[[off1]]] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
// BAREPTR-NEXT: llvm.store %{{.*}}, %[[addr]] : !llvm.ptr<f32>
- store %val, %static[%i, %j] : memref<10x42xf32>
+ memref.store %val, %static[%i, %j] : memref<10x42xf32>
return
}
func @view(%arg0 : index, %arg1 : index, %arg2 : index) {
// CHECK: llvm.mlir.constant(2048 : index) : i64
// CHECK: llvm.mlir.undef : !llvm.struct<(ptr<i8>, ptr<i8>, 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<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.insertvalue %[[ARG0]], %{{.*}}[3, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.mul %{{.*}}, %[[ARG1]]
// CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
- %1 = view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref<?x?xf32>
+ %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref<?x?xf32>
// Test one dynamic size.
// CHECK: llvm.mlir.undef : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[3, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.mul %{{.*}}, %[[ARG1]]
// CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, 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<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[3, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.mlir.constant(4 : index) : i64
// CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, 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<i8, 4>, ptr<i8, 4>, 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<f32, 4>, ptr<f32, 4>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: %[[BASE_PTR_4:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(ptr<i8, 4>, ptr<i8, 4>, i64, array<1 x i64>, array<1 x i64>)>
// CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[3, 0] : !llvm.struct<(ptr<f32, 4>, ptr<f32, 4>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.mlir.constant(4 : index) : i64
// CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[4, 0] : !llvm.struct<(ptr<f32, 4>, ptr<f32, 4>, 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
}
// CHECK-LABEL: func @address_space(
// CHECK-SAME: !llvm.ptr<f32, 7>
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<f32, 5>
%2 = load %0[%1] : memref<32xf32, affine_map<(d0) -> (d0)>, 5>
// CHECK: llvm.extractvalue {{.*}}[3, 2] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<3 x i64>, array<3 x i64>)>
// CHECK: llvm.insertvalue {{.*}}[3, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<3 x i64>, array<3 x i64>)>
func @transpose(%arg0: memref<?x?x?xf32, offset: ?, strides: [?, ?, 1]>) {
- %0 = transpose %arg0 (i, j, k) -> (k, i, j) : memref<?x?x?xf32, offset: ?, strides: [?, ?, 1]> to memref<?x?x?xf32, affine_map<(d0, d1, d2)[s0, s1, s2] -> (d2 * s1 + s0 + d0 * s2 + d1)>>
+ %0 = memref.transpose %arg0 (i, j, k) -> (k, i, j) : memref<?x?x?xf32, offset: ?, strides: [?, ?, 1]> to memref<?x?x?xf32, affine_map<(d0, d1, d2)[s0, s1, s2] -> (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<array<2 x f32>>
// CHECK: llvm.insertvalue %[[DIM1]], {{.*}}[4, 0] : !llvm.struct<(ptr<f32>, ptr<f32>, i64, array<2 x i64>, array<2 x i64>)>
// CHECK: llvm.insertvalue %[[STRIDE1]], {{.*}}[4, 1] : !llvm.struct<(ptr<f32>, ptr<f32>, 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<f32> = dense<1.0>
+memref.global @gv3 : memref<f32> = dense<1.0>
// CHECK-LABEL: func @get_gv3_memref
func @get_gv3_memref() {
// CHECK: llvm.insertvalue %[[GEP]], {{.*}}[1] : !llvm.struct<(ptr<f32>, ptr<f32>, i64)>
// CHECK: %[[OFFSET:.*]] = llvm.mlir.constant(0 : index) : i64
// CHECK: llvm.insertvalue %[[OFFSET]], {{.*}}[2] : !llvm.struct<(ptr<f32>, ptr<f32>, i64)>
- %0 = get_global_memref @gv3 : memref<f32>
+ %0 = memref.get_global @gv3 : memref<f32>
return
}
}
{
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<!spv.struct<(!spv.array<20 x f32, stride=4>)>, 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
// -----
}
{
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
}
}
}
{
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
}
}
}
{
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
}
}
{
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
}
}
{
func @alloc_dealloc_mem() {
// expected-error @+1 {{unhandled allocation type}}
- %0 = alloc() : memref<4x5xf32>
+ %0 = memref.alloc() : memref<4x5xf32>
return
}
}
{
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
}
}
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
}
}
// 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
}
// 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
}
// CHECK-SAME: [[ZERO2]], [[ZERO2]]
// CHECK-SAME: ] :
// CHECK: spv.Store "StorageBuffer" %{{.*}} : f32
- store %0, %arg1[] : memref<f32>
+ memref.store %0, %arg1[] : memref<f32>
return
}
// CHECK-SAME: [[ZERO2]], [[ZERO2]]
// CHECK-SAME: ] :
// CHECK: spv.Store "StorageBuffer" %{{.*}} : i32
- store %0, %arg1[] : memref<i32>
+ memref.store %0, %arg1[] : memref<i32>
return
}
// 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<i8>
+ memref.store %value, %arg0[] : memref<i8>
return
}
// 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
}
// CHECK: spv.Store
// CHECK-NOT: spv.AtomicAnd
// CHECK-NOT: spv.AtomicOr
- store %value, %arg0[] : memref<i32>
+ memref.store %value, %arg0[] : memref<i32>
return
}
// CHECK: spv.Store
// CHECK-NOT: spv.AtomicAnd
// CHECK-NOT: spv.AtomicOr
- store %value, %arg0[] : memref<f32>
+ memref.store %value, %arg0[] : memref<f32>
return
}
// 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<i8>
+ memref.store %value, %arg0[] : memref<i8>
return
}
// 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
}
// 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
}
// 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>
// 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 {
}
}
}
- // CHECK: %[[tensor:[0-9]+]] = alloc
+ // CHECK: %[[tensor:[0-9]+]] = memref.alloc
// CHECK-NOT: {{.*}} dim %[[tensor]], %c0
// CHECK-NOT: {{.*}} dim %[[tensor]], %c3
return
// 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<?x?x?x?xf32>
+ // CHECK: %{{.*}} = memref.alloc(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : memref<?x?x?x?xf32>
// CHECK-NEXT: affine.for %[[I0:.*]] = 0 to %{{.*}} step 3 {
// CHECK-NEXT: affine.for %[[I1:.*]] = 0 to %{{.*}} {
// CHECK-NEXT: affine.for %[[I2:.*]] = 0 to %{{.*}} {
// 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<?x?x?x?xf32, 0>
+ %A = memref.alloc (%M, %N, %O, %P) : memref<?x?x?x?xf32, 0>
affine.for %i0 = 0 to %M step 3 {
affine.for %i1 = 0 to %N {
affine.for %i2 = 0 to %O {
// 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<?x?x?x?xf32>
+ // CHECK: %{{.*}} = memref.alloc(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : memref<?x?x?x?xf32>
// 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 %{{.*}} {
// 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<?x?x?x?xf32, 0>
+ %A = memref.alloc (%M, %N, %O, %P) : memref<?x?x?x?xf32, 0>
%f1 = constant dense<1.000000e+00> : vector<5x4x3xf32>
affine.for %i0 = 0 to %M step 3 {
affine.for %i1 = 0 to %N step 4 {
%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<?x?xf32>
// CHECK: affine.for %[[I:.*]] = 0 to 3 {
// FULL-UNROLL-SAME: %[[vec:[a-zA-Z0-9]+]]: vector<3x15xf32>
func @transfer_write_progressive(%A : memref<?x?xf32>, %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<vector<3x15xf32>>
// CHECK: store %[[vec]], %[[vmemref]][] : memref<vector<3x15xf32>>
// CHECK: %[[dim:.*]] = dim %[[A]], %[[C0]] : memref<?x?xf32>
// FULL-UNROLL-SAME: %[[vec:[a-zA-Z0-9]+]]: vector<3x15xf32>
func @transfer_write_progressive_unmasked(%A : memref<?x?xf32>, %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<vector<3x15xf32>>
// CHECK-NEXT: store %[[vec]], %[[vmemref]][] : memref<vector<3x15xf32>>
// CHECK-NEXT: affine.for %[[I:.*]] = 0 to 3 {
// 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<?x?x?x?xf32>
// CHECK: affine.for %[[arg1:.*]] = 0 to 3 {
// CHECK: %[[cmp:.*]] = cmpi slt, %[[arg1]], %[[d]] : index
// CHECK-SAME: %[[B:.*]]: memref<?x?x?x?xf32>)
// 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<vector<3x3xf32>>
// CHECK: store %[[A]], %[[cast]][] : memref<vector<3x3xf32>>
// CHECK: %[[d:.*]] = dim %[[B]], %[[c2]] : memref<?x?x?x?xf32>
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<?x?xf32>
- %1 = alloc(%arg0, %arg1) : memref<?x?xf32>
- %2 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %0 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
+ %2 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
%c0 = constant 0 : index
%cst = constant 1.000000e+00 : f32
// CHECK-LABEL: func @vector_add_2d
func @vector_add_2d(%M : index, %N : index) -> f32 {
- %A = alloc (%M, %N) : memref<?x?xf32, 0>
- %B = alloc (%M, %N) : memref<?x?xf32, 0>
- %C = alloc (%M, %N) : memref<?x?xf32, 0>
+ %A = memref.alloc (%M, %N) : memref<?x?xf32, 0>
+ %B = memref.alloc (%M, %N) : memref<?x?xf32, 0>
+ %C = memref.alloc (%M, %N) : memref<?x?xf32, 0>
%f1 = constant 1.0 : f32
%f2 = constant 2.0 : f32
affine.for %i0 = 0 to %M {
// 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<?xvector<2xf32>>
+ %a16 = memref.alloc(%M) : memref<?xvector<2xf32>>
%l16 = affine.load %a16[%i16] : memref<?xvector<2xf32>>
}
return
}
func @vector_add_2d(%M : index, %N : index) -> f32 {
- %A = alloc (%M, %N) : memref<?x?xf32, 0>
- %B = alloc (%M, %N) : memref<?x?xf32, 0>
- %C = alloc (%M, %N) : memref<?x?xf32, 0>
+ %A = memref.alloc (%M, %N) : memref<?x?xf32, 0>
+ %B = memref.alloc (%M, %N) : memref<?x?xf32, 0>
+ %C = memref.alloc (%M, %N) : memref<?x?xf32, 0>
%f1 = constant 1.0 : f32
%f2 = constant 2.0 : f32
affine.for %i0 = 0 to %M {
// 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]](%{{.*}}) {
// 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>
// 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>
// 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.
// 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 {
// 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>
// -----
}
// 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: }
// 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
// -----
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>
// 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: }
// -----
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>
// 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>
// 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
}
}
- // 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
// 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>
// -----
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
}
}
- // 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
// -----
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>
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>
// -----
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 {
}
}
- // 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)
// -----
func @dependent_stores() {
- %m = alloc() : memref<10xf32>
+ %m = memref.alloc() : memref<10xf32>
%cf7 = constant 7.0 : f32
%cf8 = constant 8.0 : f32
}
}
- // 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
// -----
func @independent_stores() {
- %m = alloc() : memref<10xf32>
+ %m = memref.alloc() : memref<10xf32>
%cf7 = constant 7.0 : f32
%cf8 = constant 8.0 : f32
}
}
- // 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
// -----
func @load_dependent_store() {
- %m = alloc() : memref<10xf32>
+ %m = memref.alloc() : memref<10xf32>
%cf7 = constant 7.0 : f32
%cf8 = constant 8.0 : f32
}
}
- // 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
// -----
func @load_after_load() {
- %m = alloc() : memref<10xf32>
+ %m = memref.alloc() : memref<10xf32>
%cf7 = constant 7.0 : f32
%cf8 = constant 8.0 : f32
}
}
- // 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
// -----
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 {
}
}
- // 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) {
// -----
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 {
}
}
- // 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 {
// -----
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 {
}
}
- // 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 {
// -----
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 {
}
}
- // 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 {
// -----
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 {
}
}
- // 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) {
// -----
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 {
}
}
- // 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) {
// -----
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 {
}
}
- // 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 {
// -----
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 {
// -----
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 {
}
}
- // 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 {
// -----
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 {
}
}
- // 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 {
// 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 {
// 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>
// 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>
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
// 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]])
// 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]
%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
}
// 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
%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
}
// 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
// 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>
}
}
}
// 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 {
// 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)>
// 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>
}
}
}
%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
// 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
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
}
%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<?xf32>
+ memref.store %f1, %A[%2] : memref<?xf32>
}
return
}
%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)
%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<i64>
+ memref.store %3, %A[]: memref<i64>
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<i64>
+ memref.store %5, %A[]: memref<i64>
}
return
}
// 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>
// 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>
// 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>
// 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 {
// 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
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>
}
}
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 {
%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 {
// 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)
}
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>
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>
}
// 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 {
// 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>
// 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>) -> ()
}
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 {
}
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>
// -----
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)
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>
// 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) {
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 %{{.*}} =
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>
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 %{{.*}}
// 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 {
// 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
// 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 {
// 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 {
// 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 {
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<?x?x?x?xf32>
+ %0 = memref.alloc(%arg0, %arg1, %arg2, %arg3) : memref<?x?x?x?xf32>
%c0 = constant 0 : index
%dim = dim %0, %c0 : memref<?x?x?x?xf32>
// -----
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>
// -----
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>
// -----
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}}
// -----
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>
// -----
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}}
// -----
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>
// -----
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}}
// -----
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}}
// -----
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
// -----
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
// -----
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
// -----
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 {
// -----
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 {
// -----
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 {
// -----
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 {
// 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>
// 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>
// 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>
// 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)]
// 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,
// 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 {
// 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 {
// 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 {
// 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>
// 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>
// 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>
// 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>
// -----
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>
// 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>
// 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}}
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<?x4x5xf32>
+ %4 = memref.alloc(%0) : memref<?x4x5xf32>
// CHECK: MemRefType offset: 0 strides: 20, 5, 1
- %5 = alloc(%0, %0) : memref<?x4x?xf32>
+ %5 = memref.alloc(%0, %0) : memref<?x4x?xf32>
// CHECK: MemRefType offset: 0 strides: ?, ?, 1
- %6 = alloc(%0, %0, %0) : memref<?x?x?xf32>
+ %6 = memref.alloc(%0, %0, %0) : memref<?x?x?xf32>
// 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<?x4x5xf32, affine_map<(i, j, k)->(i, j, k)>>
+ %14 = memref.alloc(%0) : memref<?x4x5xf32, affine_map<(i, j, k)->(i, j, k)>>
// CHECK: MemRefType offset: 0 strides: 20, 5, 1
- %15 = alloc(%0, %0) : memref<?x4x?xf32, affine_map<(i, j, k)->(i, j, k)>>
+ %15 = memref.alloc(%0, %0) : memref<?x4x?xf32, affine_map<(i, j, k)->(i, j, k)>>
// CHECK: MemRefType offset: 0 strides: ?, ?, 1
- %16 = alloc(%0, %0, %0) : memref<?x?x?xf32, affine_map<(i, j, k)->(i, j, k)>>
+ %16 = memref.alloc(%0, %0, %0) : memref<?x?x?xf32, affine_map<(i, j, k)->(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<?x?x16xf32, affine_map<(i, j, k)[M, N]->(M * i + N * j + k + 1)>>
+ %25 = memref.alloc(%0, %0)[%0, %0] : memref<?x?x16xf32, affine_map<(i, j, k)[M, N]->(M * i + N * j + k + 1)>>
// CHECK: MemRefType offset: 1 strides: ?, ?, 1
- %b25 = alloc(%0, %0)[%0, %0] : memref<?x?x16xf32, offset: 1, strides: [?, ?, 1]>
+ %b25 = memref.alloc(%0, %0)[%0, %0] : memref<?x?x16xf32, offset: 1, strides: [?, ?, 1]>
// CHECK: MemRefType offset: 1 strides: ?, ?, 1
- %26 = alloc(%0)[] : memref<?xf32, affine_map<(i)[M]->(i)>>
+ %26 = memref.alloc(%0)[] : memref<?xf32, affine_map<(i)[M]->(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<f32, affine_map<()[M]->(M)>>
+ %29 = memref.alloc()[%0] : memref<f32, affine_map<()[M]->(M)>>
// CHECK: MemRefType offset: ? strides:
- %30 = alloc()[%0] : memref<f32, affine_map<()[M]->(123)>>
+ %30 = memref.alloc()[%0] : memref<f32, affine_map<()[M]->(123)>>
// CHECK: MemRefType offset: 123 strides:
- %100 = alloc(%0, %0)[%0, %0] : memref<?x?x16xf32, affine_map<(i, j, k)[M, N]->(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<?x?x16xf32, affine_map<(i, j, k)[M, N]->(i + j, j, k)>, affine_map<(i, j, k)[M, N]->(M * i + N * j + k + 1)>>
// CHECK: MemRefType memref<?x?x16xf32, affine_map<(d0, d1, d2)[s0, s1] -> (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
func @valid_symbols(%arg0: index, %arg1: index, %arg2: index) {
%c1 = constant 1 : index
%c0 = constant 0 : index
- %0 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %0 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
affine.for %arg3 = 0 to %arg2 step 768 {
%13 = dim %0, %c1 : memref<?x?xf32>
affine.for %arg4 = 0 to %13 step 264 {
// 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 {
}
// 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) {
// 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>>
// 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>
// 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
// 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
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>
}
}
%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"() : () -> ()
// 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<?xf32>
+ memref.store %one, %arg3[%i] : memref<?xf32>
}
return
// 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]]
scf.parallel (%i0, %i1) = (%arg0, %arg3) to (%arg1, %arg4)
step (%arg2, %arg5) {
%one = constant 1.0 : f32
- store %one, %arg6[%i0, %i1] : memref<?x?xf32>
+ memref.store %one, %arg6[%i0, %i1] : memref<?x?xf32>
}
return
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
// Resume coroutine after suspension.
// CHECK: ^[[RESUME]]:
-// CHECK: store
+// CHECK: memref.store
// CHECK: async.runtime.set_available %[[TOKEN]]
// Delete coroutine.
%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]]
// 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.
// Set token available after second resumption.
// CHECK: ^[[RESUME_1]]:
-// CHECK: store
+// CHECK: memref.store
// CHECK: async.runtime.set_available %[[TOKEN]]
// CHECK: ^[[CLEANUP]]:
// 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
// Emplace result token after second resumption.
// CHECK: ^[[RESUME_1]]:
-// CHECK: store
+// CHECK: memref.store
// CHECK: async.runtime.set_available %[[TOKEN]]
// CHECK: ^[[CLEANUP]]:
// 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
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
}
func @matmul(%arg0: memref<?xi8>, %M: index, %N: index, %K: index) {
%c0 = constant 0 : index
%c1 = constant 1 : index
- %A = view %arg0[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
- %B = view %arg0[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
- %C = view %arg0[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
+ %A = memref.view %arg0[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
+ %B = memref.view %arg0[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
+ %C = memref.view %arg0[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
linalg.matmul ins(%A, %B: memref<?x?xf32>, memref<?x?xf32>)
outs(%C: memref<?x?xf32>)
return
// 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<?xi8> to memref<?x?xf32>
-// CHECK: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
-// CHECK: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: affine.for %{{.*}} = 0 to %{{.*}} {
// CHECK: affine.for %{{.*}} = 0 to %{{.*}} {
// CHECK: affine.for %{{.*}} = 0 to %{{.*}} {
// 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>) {
// CHECK: #map = affine_map<(d0) -> (d0)>
// CHECK-LABEL: func @init_tensor(
// CHECK-SAME: %[[IN:.*]]: tensor<?xf32>, %[[SIZE:.*]]: index)
-// CHECK: %[[OUT_BUF:.*]] = alloc(%[[SIZE]]) : memref<?xf32>
+// CHECK: %[[OUT_BUF:.*]] = memref.alloc(%[[SIZE]]) : memref<?xf32>
// CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[IN]] : memref<?xf32>
// CHECK: linalg.generic
// CHECK-SAME: ins(%[[MEMREF]] : memref<?xf32>)
#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>)
#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>)
// CHECK: %[[MEMREF_ARG:.*]] = tensor_to_memref %[[ARG]] : memref<?x?xf32>
// CHECK: %[[DIM0:.*]] = dim %[[ARG]], %[[C0]] : tensor<?x?xf32>
// CHECK: %[[DIM1:.*]] = dim %[[ARG]], %[[C1]] : tensor<?x?xf32>
-// CHECK: %[[RESULT0:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
-// CHECK: %[[RESULT1:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
+// CHECK: %[[RESULT0:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
+// CHECK: %[[RESULT1:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
// CHECK: linalg.generic
// CHECK-SAME: ins(%[[MEMREF_ARG]] : memref<?x?xf32>)
// CHECK-SAME: outs(%[[RESULT0]], %[[RESULT1]] : memref<?x?xf32>, memref<?x?xf32>)
// 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>>)
%i0 = call @make_index() : () -> index
// CHECK: %[[M0:.*]] = tensor_to_memref %[[T]] : memref<?x?xf32>
- // 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<?x?xf32> to memref<2x3xf32, #[[$MAP0]]>
// CHECK-NEXT: linalg.copy(%[[SM0]], %[[A0]]) : memref<2x3xf32, #[[$MAP0]]>, memref<2x3xf32>
%st0 = subtensor %t[0, 0][2, 3][1, 1] : tensor<?x?xf32> to tensor<2x3xf32>
// CHECK: %[[M1:.*]] = tensor_to_memref %[[T]] : memref<?x?xf32>
- // 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<?x?xf32> to memref<2x?xf32, #[[$MAP1]]>
// CHECK-NEXT: linalg.copy(%[[SM1]], %[[A1]]) : memref<2x?xf32, #[[$MAP1]]>, memref<2x?xf32>
// CHECK-DAG: %[[SM0:.*]] = tensor_to_memref %[[ST0]] : memref<2x3xf32>
// CHECK-NEXT: %[[DIM0:.*]] = dim %[[T]], %[[C0]] : tensor<?x?xf32>
// CHECK-NEXT: %[[DIM1:.*]] = dim %[[T]], %[[C1]] : tensor<?x?xf32>
- // CHECK-NEXT: %[[M0_COPY:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
+ // CHECK-NEXT: %[[M0_COPY:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
// CHECK-NEXT: linalg.copy(%[[M0]], %[[M0_COPY]]) : memref<?x?xf32>, memref<?x?xf32>
// CHECK-NEXT: %[[SUBVIEW0:.*]] = subview %[[M0_COPY]][0, 0] [2, 3] [1, 1]
// CHECK-SAME: memref<?x?xf32> to memref<2x3xf32, #[[$MAP0]]>
// CHECK-DAG: %[[M1:.*]] = tensor_to_memref %[[T]] : memref<?x?xf32>
// CHECK-DAG: %[[SM1:.*]] = tensor_to_memref %[[ST1]] : memref<2x?xf32>
- // CHECK-NEXT: %[[M1_COPY:.*]] = alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
+ // CHECK-NEXT: %[[M1_COPY:.*]] = memref.alloc(%[[DIM0]], %[[DIM1]]) : memref<?x?xf32>
// CHECK-NEXT: linalg.copy(%[[M1]], %[[M1_COPY]]) : memref<?x?xf32>, memref<?x?xf32>
// CHECK-NEXT: %[[SUBVIEW1:.*]] = subview %[[M1_COPY]][0, %[[IDX]]] [2, %[[IDX]]] [1, 2]
// CHECK-SAME: memref<?x?xf32> to memref<2x?xf32, #[[$MAP1]]>
%c1 = constant 1 : index
%c8 = constant 8 : index
%c16 = constant 16 : index
- %1 = alloc (%b) : memref<?xi8>
- %2 = view %1[%c0][] : memref<?xi8> to memref<16x16xf32>
- %3 = memref_cast %2 : memref<16x16xf32> to memref<?x?xf32>
+ %1 = memref.alloc (%b) : memref<?xi8>
+ %2 = memref.view %1[%c0][] : memref<?xi8> to memref<16x16xf32>
+ %3 = memref.cast %2 : memref<16x16xf32> to memref<?x?xf32>
// CHECK: linalg.matmul ins({{.*}}memref<16x16xf32>, memref<16x16xf32>) outs({{.*}}memref<16x16xf32>)
linalg.matmul ins(%3, %3: memref<?x?xf32>, memref<?x?xf32>)
// CHECK: scf.for
// CHECK-NEXT: %[[C2:.*]] = constant 2 : index
// CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]]
- // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref<i64>
+ // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref<i64>
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// CHECK: scf.for
// CHECK-NEXT: %[[C2:.*]] = constant 2 : index
// CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]]
- // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref<i64>
+ // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref<i64>
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// This should not canonicalize because: 4 - %i may take the value 1 < 2.
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// This should not canonicalize because: 16 - %i may take the value 15 < 1024.
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// This example should simplify but affine_map is currently missing
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// This example should simplify but affine_map is currently missing
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
return
// CHECK: scf.parallel
// CHECK-NEXT: %[[C2:.*]] = constant 2 : index
// CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]]
- // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref<i64>
+ // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref<i64>
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// CHECK: scf.parallel
// CHECK-NEXT: %[[C2:.*]] = constant 2 : index
// CHECK-NEXT: %[[C2I64:.*]] = index_cast %[[C2:.*]]
- // CHECK-NEXT: store %[[C2I64]], %{{.*}}[] : memref<i64>
+ // CHECK-NEXT: memref.store %[[C2I64]], %{{.*}}[] : memref<i64>
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// This example should simplify but affine_map is currently missing
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
// This example should simplify but affine_map is currently missing
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<i64>
+ memref.store %2, %A[]: memref<i64>
}
return
// 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<? x f32>) -> 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<? x f32>, 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>
}
// 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<? x f32>) -> 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<? x f32>, 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>
}
// 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<? x f32>) -> 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<? x f32>, 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>
}
// 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<? x f32>) -> 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<? x f32>, 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>
}
// 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<? 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>
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<? x f32>
- dealloc %alloc : memref<32 x f32>
+ memref.dealloc %alloc : memref<32 x f32>
return
}
// 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<? 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>
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<? x f32>
- dealloc %alloc : memref<128 x i8>
+ memref.dealloc %alloc : memref<128 x i8>
return
}
// 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<? x f32>) -> 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<? x f32>, 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>
}
// 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<? 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>
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<? x f32>
- dealloc %alloc : memref<32 x f32>
+ memref.dealloc %alloc : memref<32 x f32>
return
}
%c1 = constant 1 : index
%0 = dim %arg2, %c0 : memref<?x?xf32>
%1 = dim %arg2, %c1 : memref<?x?xf32>
- %2 = alloc(%0, %1) : memref<?x?xf32>
+ %2 = memref.alloc(%0, %1) : memref<?x?xf32>
linalg.matmul ins(%arg0, %arg1 : memref<?x?xf32>, memref<?x?xf32>)
outs(%2 : memref<?x?xf32>)
linalg.generic
// CHECK-SAME: %[[ARG0:[a-zA-Z0-9_]+]]: memref<?x?xf32>
// CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]+]]: memref<?x?xf32>
// CHECK-SAME: %[[ARG2:[a-zA-Z0-9_]+]]: memref<?x?xf32>
-// CHECK: %[[T2:.+]] = alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32>
+// CHECK: %[[T2:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32>
// CHECK: linalg.matmul
// CHECK-SAME: after_transpose_fusion_original
// CHECK: scf.parallel (%[[ARG3:[a-zA-Z0-9_]+]], %[[ARG4:.[a-zA-Z0-9_]+]])
%c1 = constant 1 : index
%0 = dim %arg2, %c0 : memref<?x?xf32>
%1 = dim %arg2, %c1 : memref<?x?xf32>
- %2 = alloc(%0, %1) : memref<?x?xf32>
+ %2 = memref.alloc(%0, %1) : memref<?x?xf32>
linalg.matmul ins(%arg0, %arg1 : memref<?x?xf32>, memref<?x?xf32>)
outs(%2 : memref<?x?xf32>)
linalg.generic
%c1 = constant 1 : index
%d0 = dim %arg0, %c0 : memref<?x?xf32>
%d1 = dim %arg1, %c1 : memref<?x?xf32>
- %0 = alloc(%d0, %d1) : memref<?x?xf32>
+ %0 = memref.alloc(%d0, %d1) : memref<?x?xf32>
linalg.fill(%0, %cst) : memref<?x?xf32>, f32
linalg.matmul ins(%arg0, %arg1 : memref<?x?xf32>, memref<?x?xf32>)
outs(%0 : memref<?x?xf32>)
// CHECK-SAME: %[[ARG1:[a-zA-Z0-9_]+]]: memref<?x?xf32>
// CHECK-SAME: %[[ARG2:[a-zA-Z0-9_]+]]: memref<?xf32>
// CHECK-SAME: %[[ARG3:[a-zA-Z0-9_]+]]: memref<?x?xf32>
-// CHECK: %[[TEMP:.+]] = alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32>
+// CHECK: %[[TEMP:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32>
// CHECK: scf.parallel (%[[IV0:.+]], %[[IV1:.+]]) = {{.*}} {
// CHECK-DAG: %[[SV_TEMP:.+]] = subview %[[TEMP]][%[[IV0]], %[[IV1]]]
// CHECK-DAG: %[[SV_ARG2:.+]] = subview %[[ARG2]][%[[IV1]]]
%n1 = dim %arg1, %c1 : memref<?x?xf32>
%n2 = dim %arg2, %c1 : memref<?x?xf32>
%n3 = dim %arg3, %c1 : memref<?x?xf32>
- %0 = alloc(%m, %n1) : memref<?x?xf32>
- %1 = alloc(%m, %n2) : memref<?x?xf32>
+ %0 = memref.alloc(%m, %n1) : memref<?x?xf32>
+ %1 = memref.alloc(%m, %n2) : memref<?x?xf32>
linalg.fill(%0, %cst) : memref<?x?xf32>, f32
linalg.matmul ins(%arg0, %arg1 : memref<?x?xf32>, memref<?x?xf32>)
outs(%0 : memref<?x?xf32>)
// 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]]]
%c0 = constant 0 : index
%c3 = constant 3 : index
%c2 = constant 2 : index
- %A = alloc (%M, %N): memref<?x?xf32>
- %B = alloc (%M, %N): memref<?x?xf32>
- %C = alloc (%M, %N): memref<?x?xf32>
- %D = alloc (%M, %N): memref<?x?xf32>
- %E = alloc (%M, %N): memref<?x?xf32>
+ %A = memref.alloc (%M, %N): memref<?x?xf32>
+ %B = memref.alloc (%M, %N): memref<?x?xf32>
+ %C = memref.alloc (%M, %N): memref<?x?xf32>
+ %D = memref.alloc (%M, %N): memref<?x?xf32>
+ %E = memref.alloc (%M, %N): memref<?x?xf32>
linalg.generic #pointwise_2d_trait
ins(%A, %A : memref<?x?xf32>, memref<?x?xf32>)
outs(%B : memref<?x?xf32>) {
%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"]}
^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"]}
%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>
}
}
}
- dealloc %1 : memref<100x10xf32>
+ memref.dealloc %1 : memref<100x10xf32>
return
}
// CHECK-LABEL: func @fusion
%c3 = constant 3 : index
%c4 = constant 4 : index
- %A = alloca(%dim, %dim)[%s0, %s1] : memref<?x?xf32, offset: 0, strides: [?, ?]>
- %B = alloca(%dim, %dim)[%s0, %s1] : memref<?x?xf32, offset: 0, strides: [?, ?]>
- %C = alloc(%dim, %dim)[%s0, %s1] : memref<?x?xf32, offset: 0, strides: [?, ?]>
+ %A = memref.alloca(%dim, %dim)[%s0, %s1] : memref<?x?xf32, offset: 0, strides: [?, ?]>
+ %B = memref.alloca(%dim, %dim)[%s0, %s1] : memref<?x?xf32, offset: 0, strides: [?, ?]>
+ %C = memref.alloc(%dim, %dim)[%s0, %s1] : memref<?x?xf32, offset: 0, strides: [?, ?]>
linalg.matmul ins(%A, %B : memref<?x?xf32, offset: 0, strides: [?, ?]>,
memref<?x?xf32, offset: 0, strides: [?, ?]>)
// 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<?xi8>
-// CHECK-DAG: %[[A0:.*]] = alloc(%[[VAL]]) : memref<?xi8>
+// CHECK-DAG: memref.alloca(%[[VAL]]) : memref<?xi8>
+// CHECK-DAG: %[[A0:.*]] = memref.alloc(%[[VAL]]) : memref<?xi8>
// CHECK: scf.for %[[I:.*]] = %[[LB]] to %[[UB]] step %[[STEP]] {
-// CHECK: alloca(%[[I]]) : memref<?xi8>
-// CHECK: %[[A1:.*]] = alloc(%[[I]]) : memref<?xi8>
+// CHECK: memref.alloca(%[[I]]) : memref<?xi8>
+// CHECK: %[[A1:.*]] = memref.alloc(%[[I]]) : memref<?xi8>
// CHECK: scf.for %[[J:.*]] = %[[LB]] to %[[UB]] step %[[STEP]] {
-// CHECK-DAG: alloca(%[[J]]) : memref<?xi8>
-// CHECK-DAG: %[[A2:.*]] = alloc(%[[J]]) : memref<?xi8>
+// CHECK-DAG: memref.alloca(%[[J]]) : memref<?xi8>
+// CHECK-DAG: %[[A2:.*]] = memref.alloc(%[[J]]) : memref<?xi8>
// 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<? x i8>
- %a0 = alloc(%val) : memref<? x i8>
-// CHECK: std.view %[[A0]][%[[LB]]][] : memref<?xi8> to memref<16xf32>
+ %sa0 = memref.alloca(%val) : memref<? x i8>
+ %a0 = memref.alloc(%val) : memref<? x i8>
+// CHECK: memref.view %[[A0]][%[[LB]]][] : memref<?xi8> to memref<16xf32>
// CHECK: subview %[[A0]][0] [42] [1] : memref<?xi8> to memref<42xi8>
- %v0 = view %a0[%lb][] : memref<? x i8> to memref<16 x f32>
+ %v0 = memref.view %a0[%lb][] : memref<? x i8> to memref<16 x f32>
%sv0 = subview %a0[0][42][1] : memref<? x i8> to memref<42 x i8>
- dealloc %a0 : memref<? x i8>
+ memref.dealloc %a0 : memref<? x i8>
// Hoist below i.
- %sa1 = alloca(%i) : memref<? x i8>
- %a1 = alloc(%i) : memref<? x i8>
- dealloc %a1 : memref<? x i8>
+ %sa1 = memref.alloca(%i) : memref<? x i8>
+ %a1 = memref.alloc(%i) : memref<? x i8>
+ memref.dealloc %a1 : memref<? x i8>
// Hoist below j.
- %sa2 = alloca(%j) : memref<? x i8>
- %a2 = alloc(%j) : memref<? x i8>
- dealloc %a2 : memref<? x i8>
+ %sa2 = memref.alloca(%j) : memref<? x i8>
+ %a2 = memref.alloc(%j) : memref<? x i8>
+ memref.dealloc %a2 : memref<? x i8>
// Don't hoist since k innermost.
-// CHECK: alloca(%[[K]]) : memref<?xi8>
-// CHECK: %[[A3:.*]] = alloc(%[[K]]) : memref<?xi8>
-// CHECK: dealloc %[[A3]] : memref<?xi8>
- %sa3 = alloca(%k) : memref<? x i8>
- %a3 = alloc(%k) : memref<? x i8>
- dealloc %a3 : memref<? x i8>
+// CHECK: memref.alloca(%[[K]]) : memref<?xi8>
+// CHECK: %[[A3:.*]] = memref.alloc(%[[K]]) : memref<?xi8>
+// CHECK: memref.dealloc %[[A3]] : memref<?xi8>
+ %sa3 = memref.alloca(%k) : memref<? x i8>
+ %a3 = memref.alloc(%k) : memref<? x i8>
+ memref.dealloc %a3 : memref<? x i8>
// No hoisting due to control flow.
// CHECK: scf.if %[[CMP]] {
-// CHECK: alloca(%[[VAL]]) : memref<?xi8>
-// CHECK: %[[A4:.*]] = alloc(%[[VAL]]) : memref<?xi8>
-// CHECK: dealloc %[[A4]] : memref<?xi8>
+// CHECK: memref.alloca(%[[VAL]]) : memref<?xi8>
+// CHECK: %[[A4:.*]] = memref.alloc(%[[VAL]]) : memref<?xi8>
+// CHECK: memref.dealloc %[[A4]] : memref<?xi8>
scf.if %cmp {
- %sa4 = alloca(%val) : memref<? x i8>
- %a4 = alloc(%val) : memref<? x i8>
- dealloc %a4 : memref<? x i8>
+ %sa4 = memref.alloca(%val) : memref<? x i8>
+ %a4 = memref.alloc(%val) : memref<? x i8>
+ memref.dealloc %a4 : memref<? x i8>
}
// No hoisting due to load/store.
-// CHECK: %[[SA5:.*]] = alloca(%[[VAL]]) : memref<?xi8>
-// CHECK: %[[A5:.*]] = alloc(%[[VAL]]) : memref<?xi8>
+// CHECK: %[[SA5:.*]] = memref.alloca(%[[VAL]]) : memref<?xi8>
+// CHECK: %[[A5:.*]] = memref.alloc(%[[VAL]]) : memref<?xi8>
// CHECK: load %[[A5]][%[[LB]]] : memref<?xi8>
-// CHECK: store %{{.*}}, %[[SA5]][%[[LB]]] : memref<?xi8>
-// CHECK: dealloc %[[A5]] : memref<?xi8>
- %sa5 = alloca(%val) : memref<? x i8>
- %a5 = alloc(%val) : memref<? x i8>
+// CHECK: memref.store %{{.*}}, %[[SA5]][%[[LB]]] : memref<?xi8>
+// CHECK: memref.dealloc %[[A5]] : memref<?xi8>
+ %sa5 = memref.alloca(%val) : memref<? x i8>
+ %a5 = memref.alloc(%val) : memref<? x i8>
%v5 = load %a5[%lb] : memref<? x i8>
- store %v5, %sa5[%lb] : memref<? x i8>
- dealloc %a5 : memref<? x i8>
+ memref.store %v5, %sa5[%lb] : memref<? x i8>
+ memref.dealloc %a5 : memref<? x i8>
}
}
}
// CHECK: }
-// CHECK: dealloc %[[A2]] : memref<?xi8>
+// CHECK: memref.dealloc %[[A2]] : memref<?xi8>
// CHECK: }
-// CHECK: dealloc %[[A1]] : memref<?xi8>
+// CHECK: memref.dealloc %[[A1]] : memref<?xi8>
// CHECK: }
-// CHECK: dealloc %[[A0]] : memref<?xi8>
+// CHECK: memref.dealloc %[[A0]] : memref<?xi8>
return
}
// 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<f32>
+ memref.store %f0, %v[%c0] : memref<f32>
}
// -----
func @matmul(%arg0: memref<?xi8>, %M: index, %N: index, %K: index) {
%c0 = constant 0 : index
%c1 = constant 1 : index
- %A = view %arg0[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
- %B = view %arg0[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
- %C = view %arg0[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
+ %A = memref.view %arg0[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
+ %B = memref.view %arg0[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
+ %C = memref.view %arg0[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
linalg.matmul ins(%A, %B: memref<?x?xf32>, memref<?x?xf32>)
outs(%C: memref<?x?xf32>)
return
// 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<?xi8> to memref<?x?xf32>
-// CHECKLOOP: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
-// CHECKLOOP: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKLOOP: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKLOOP: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKLOOP: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[M]] step %{{.*}} {
// CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[N]] step %{{.*}} {
// CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} {
// 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<?xi8> to memref<?x?xf32>
-// CHECKPARALLEL: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
-// CHECKPARALLEL: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKPARALLEL: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKPARALLEL: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKPARALLEL: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECKPARALLEL: scf.parallel (%{{.*}}, %{{.*}}) = (%{{.*}}, %{{.*}}) to (%[[M]], %[[N]]) step (%{{.*}}, %{{.*}} {
// CHECKPARALLEL: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} {
// CHECKPARALLEL-DAG: %[[a:.*]] = load %[[A]][%{{.*}}, %{{.*}}] : memref<?x?xf32>
func @matvec(%arg0: memref<?xi8>, %M: index, %N: index) {
%c0 = constant 0 : index
%c1 = constant 1 : index
- %2 = view %arg0[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
- %3 = view %arg0[%c0][%M] : memref<?xi8> to memref<?xf32>
- %4 = view %arg0[%c0][%N] : memref<?xi8> to memref<?xf32>
+ %2 = memref.view %arg0[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
+ %3 = memref.view %arg0[%c0][%M] : memref<?xi8> to memref<?xf32>
+ %4 = memref.view %arg0[%c0][%N] : memref<?xi8> to memref<?xf32>
linalg.matvec ins(%2, %3: memref<?x?xf32>, memref<?xf32>)
outs(%4 : memref<?xf32>)
return
// CHECKLOOP-LABEL: func @matvec(%{{.*}}: memref<?xi8>,
// CHECKLOOP-SAME: [[M:arg[0-9]+]]: index
// CHECKLOOP-SAME: [[K:arg[0-9]+]]: index
-// CHECKLOOP: %[[A:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
-// CHECKLOOP: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
-// CHECKLOOP: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKLOOP: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKLOOP: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKLOOP: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
// CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[M]] step %{{.*}} {
// CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} {
// CHECKLOOP-DAG: %[[a:.*]] = load %[[A]][%{{.*}}, %{{.*}}] : memref<?x?xf32>
// CHECKPARALLEL-LABEL: func @matvec(%{{.*}}: memref<?xi8>,
// CHECKPARALLEL-SAME: [[M:arg[0-9]+]]: index
// CHECKPARALLEL-SAME: [[K:arg[0-9]+]]: index
-// CHECKPARALLEL: %[[A:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
-// CHECKPARALLEL: %[[B:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
-// CHECKPARALLEL: %[[C:.*]] = std.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKPARALLEL: %[[A:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECKPARALLEL: %[[B:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKPARALLEL: %[[C:.*]] = memref.view %{{.*}}[{{.*}}] : memref<?xi8> to memref<?xf32>
// CHECKPARALLEL: scf.parallel (%{{.*}}) = (%{{.*}}) to (%[[M]]) step (%{{.*}}) {
// CHECKPARALLEL: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} {
// CHECKPARALLEL-DAG: %[[a:.*]] = load %[[A]][%{{.*}}, %{{.*}}] : memref<?x?xf32>
func @dot(%arg0: memref<?xi8>, %M: index) {
%c0 = constant 0 : index
%c1 = constant 1 : index
- %1 = view %arg0[%c0][%M] : memref<?xi8> to memref<?xf32>
- %2 = view %arg0[%c0][%M] : memref<?xi8> to memref<?xf32>
- %3 = view %arg0[%c0][] : memref<?xi8> to memref<f32>
+ %1 = memref.view %arg0[%c0][%M] : memref<?xi8> to memref<?xf32>
+ %2 = memref.view %arg0[%c0][%M] : memref<?xi8> to memref<?xf32>
+ %3 = memref.view %arg0[%c0][] : memref<?xi8> to memref<f32>
linalg.dot ins(%1, %2 : memref<?xf32>, memref<?xf32>)
outs(%3 : memref<f32>)
return
}
// CHECKLOOP-LABEL: func @dot(%{{.*}}: memref<?xi8>,
// CHECKLOOP-SAME: [[K:arg[0-9]+]]: index
-// CHECKLOOP: %[[A:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
-// CHECKLOOP: %[[B:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
-// CHECKLOOP: %[[C:.*]] = std.view %{{.*}}[{{.*}}][] : memref<?xi8> to memref<f32>
+// CHECKLOOP: %[[A:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKLOOP: %[[B:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKLOOP: %[[C:.*]] = memref.view %{{.*}}[{{.*}}][] : memref<?xi8> to memref<f32>
// CHECKLOOP: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} {
// CHECKLOOP-DAG: %[[a:.*]] = load %[[A]][%{{.*}}] : memref<?xf32>
// CHECKLOOP-DAG: %[[b:.*]] = load %[[B]][%{{.*}}] : memref<?xf32>
// CHECKPARALLEL-LABEL: func @dot(%{{.*}}: memref<?xi8>,
// CHECKPARALLEL-SAME: [[K:arg[0-9]+]]: index
-// CHECKPARALLEL: %[[A:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
-// CHECKPARALLEL: %[[B:.*]] = std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
-// CHECKPARALLEL: %[[C:.*]] = std.view %{{.*}}[{{.*}}][] : memref<?xi8> to memref<f32>
+// CHECKPARALLEL: %[[A:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKPARALLEL: %[[B:.*]] = memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?xf32>
+// CHECKPARALLEL: %[[C:.*]] = memref.view %{{.*}}[{{.*}}][] : memref<?xi8> to memref<f32>
// CHECKPARALLEL: scf.for %{{.*}} = %{{.*}} to %[[K]] step %{{.*}} {
// CHECKPARALLEL-DAG: %[[a:.*]] = load %[[A]][%{{.*}}] : memref<?xf32>
// CHECKPARALLEL-DAG: %[[b:.*]] = load %[[B]][%{{.*}}] : memref<?xf32>
%c2 = constant 2 : index
%c0 = constant 0 : index
%c1 = constant 1 : index
- %3 = view %A[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
- %4 = view %A[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
- %5 = view %A[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
+ %3 = memref.view %A[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
+ %4 = memref.view %A[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
+ %5 = memref.view %A[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
%6 = dim %3, %c0 : memref<?x?xf32>
%7 = dim %3, %c1 : memref<?x?xf32>
%8 = dim %4, %c1 : memref<?x?xf32>
// CHECK: %[[vB:.*]] = subview {{.*}} : memref<?x?xf32>
// CHECK: %[[vC:.*]] = subview {{.*}} : memref<?x?xf32>
///
-// CHECK: %[[tmpA:.*]] = alloc() : memref<32xi8>
-// ALLOCA: %[[tmpA:.*]] = alloca() : memref<32xi8>
-// CHECK: %[[fullA:.*]] = std.view %[[tmpA]][{{.*}}][{{.*}}] : memref<32xi8> to memref<?x?xf32>
-// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[tmpA:.*]] = memref.alloc() : memref<32xi8>
+// ALLOCA: %[[tmpA:.*]] = memref.alloca() : memref<32xi8>
+// CHECK: %[[fullA:.*]] = memref.view %[[tmpA]][{{.*}}][{{.*}}] : memref<32xi8> to memref<?x?xf32>
+// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[partialA:.*]] = subview %[[fullA]]{{.*}} : memref<?x?xf32> to memref<?x?xf32, #[[$strided2D]]>
///
-// CHECK: %[[tmpB:.*]] = alloc() : memref<48xi8>
-// ALLOCA: %[[tmpB:.*]] = alloca() : memref<48xi8>
-// CHECK: %[[fullB:.*]] = std.view %[[tmpB]][{{.*}}][{{.*}}] : memref<48xi8> to memref<?x?xf32>
-// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[tmpB:.*]] = memref.alloc() : memref<48xi8>
+// ALLOCA: %[[tmpB:.*]] = memref.alloca() : memref<48xi8>
+// CHECK: %[[fullB:.*]] = memref.view %[[tmpB]][{{.*}}][{{.*}}] : memref<48xi8> to memref<?x?xf32>
+// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[partialB:.*]] = subview %[[fullB]]{{.*}} : memref<?x?xf32> to memref<?x?xf32, #[[$strided2D]]>
///
-// CHECK: %[[tmpC:.*]] = alloc() : memref<24xi8>
-// ALLOCA: %[[tmpC:.*]] = alloca() : memref<24xi8>
-// CHECK: %[[fullC:.*]] = std.view %[[tmpC]][{{.*}}][{{.*}}] : memref<24xi8> to memref<?x?xf32>
-// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[tmpC:.*]] = memref.alloc() : memref<24xi8>
+// ALLOCA: %[[tmpC:.*]] = memref.alloca() : memref<24xi8>
+// CHECK: %[[fullC:.*]] = memref.view %[[tmpC]][{{.*}}][{{.*}}] : memref<24xi8> to memref<?x?xf32>
+// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[partialC:.*]] = subview %[[fullC]]{{.*}} : memref<?x?xf32> to memref<?x?xf32, #[[$strided2D]]>
// CHECK: linalg.copy(%[[vA]], %[[partialA]]) : memref<?x?xf32, #[[$strided2D]]>, memref<?x?xf32, #[[$strided2D]]>
// CHECK: memref<?x?xf32, #[[$strided2D]]>,
// CHECK: memref<?x?xf32, #[[$strided2D]]>
//
-// 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>
// -----
%c2 = constant 2 : index
%c0 = constant 0 : index
%c1 = constant 1 : index
- %3 = view %A[%c0][%M, %K] : memref<?xi8> to memref<?x?xf64>
- %4 = view %A[%c0][%K, %N] : memref<?xi8> to memref<?x?xf64>
- %5 = view %A[%c0][%M, %N] : memref<?xi8> to memref<?x?xf64>
+ %3 = memref.view %A[%c0][%M, %K] : memref<?xi8> to memref<?x?xf64>
+ %4 = memref.view %A[%c0][%K, %N] : memref<?xi8> to memref<?x?xf64>
+ %5 = memref.view %A[%c0][%M, %N] : memref<?xi8> to memref<?x?xf64>
%6 = dim %3, %c0 : memref<?x?xf64>
%7 = dim %3, %c1 : memref<?x?xf64>
%8 = dim %4, %c1 : memref<?x?xf64>
// CHECK: %[[vB_f64:.*]] = subview {{.*}} : memref<?x?xf64>
// CHECK: %[[vC_f64:.*]] = subview {{.*}} : memref<?x?xf64>
///
-// CHECK: %[[tmpA_f64:.*]] = alloc() : memref<64xi8>
-// CHECK: %[[fullA_f64:.*]] = std.view %[[tmpA_f64]][{{.*}}][{{.*}}] : memref<64xi8> to memref<?x?xf64>
-// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf64>
+// CHECK: %[[tmpA_f64:.*]] = memref.alloc() : memref<64xi8>
+// CHECK: %[[fullA_f64:.*]] = memref.view %[[tmpA_f64]][{{.*}}][{{.*}}] : memref<64xi8> to memref<?x?xf64>
+// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf64>
// CHECK: %[[partialA_f64:.*]] = subview %[[fullA_f64]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref<?x?xf64> to memref<?x?xf64, #[[$strided2D]]>
///
-// CHECK: %[[tmpB_f64:.*]] = alloc() : memref<96xi8>
-// CHECK: %[[fullB_f64:.*]] = std.view %[[tmpB_f64]][{{.*}}][{{.*}}] : memref<96xi8> to memref<?x?xf64>
-// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf64>
+// CHECK: %[[tmpB_f64:.*]] = memref.alloc() : memref<96xi8>
+// CHECK: %[[fullB_f64:.*]] = memref.view %[[tmpB_f64]][{{.*}}][{{.*}}] : memref<96xi8> to memref<?x?xf64>
+// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf64>
// CHECK: %[[partialB_f64:.*]] = subview %[[fullB_f64]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref<?x?xf64> to memref<?x?xf64, #[[$strided2D]]>
///
-// CHECK: %[[tmpC_f64:.*]] = alloc() : memref<48xi8>
-// CHECK: %[[fullC_f64:.*]] = std.view %[[tmpC_f64]][{{.*}}][{{.*}}] : memref<48xi8> to memref<?x?xf64>
-// DYNAMIC: std.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf64>
+// CHECK: %[[tmpC_f64:.*]] = memref.alloc() : memref<48xi8>
+// CHECK: %[[fullC_f64:.*]] = memref.view %[[tmpC_f64]][{{.*}}][{{.*}}] : memref<48xi8> to memref<?x?xf64>
+// DYNAMIC: memref.view %{{.*}}[{{.*}}][{{.*}}] : memref<?xi8> to memref<?x?xf64>
// CHECK: %[[partialC_f64:.*]] = subview %[[fullC_f64]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref<?x?xf64> to memref<?x?xf64, #[[$strided2D]]>
// CHECK: linalg.copy(%[[vA_f64]], %[[partialA_f64]]) : memref<?x?xf64, #[[$strided2D]]>, memref<?x?xf64, #[[$strided2D]]>
// CHECK: memref<?x?xf64, #[[$strided2D]]>,
// CHECK: memref<?x?xf64, #[[$strided2D]]>
//
-// 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>
// CHECK: %[[T7:.+]] = subview %[[ARG0]]
// CHECK: %[[T12:.+]] = subview %[[ARG1]]
// CHECK: %[[T17:.+]] = subview %[[ARG2]]
-// CHECK: %[[T18:.+]] = alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32, 3>
+// CHECK: %[[T18:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32, 3>
// CHECK: %[[T19:.+]] = subview %[[T18]]
-// CHECK: %[[T20:.+]] = alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32, 3>
+// CHECK: %[[T20:.+]] = memref.alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32, 3>
// CHECK: %[[T21:.+]] = subview %[[T20]]
// CHECK: linalg.fill(%[[T19]], %[[C42]])
// CHECK: linalg.copy(%[[T7]], %[[T19]])
// 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]]
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<?xi8>
+ %1 = memref.alloc (%0) : memref<?xi8>
%2 = linalg.range %arg0:%arg1:%arg2 : !linalg.range
- %3 = view %1[%c0][%arg0, %arg0] : memref<?xi8> to memref<?x?xf32>
- %4 = view %1[%c0][%arg0, %arg0] : memref<?xi8> to memref<?x?xvector<4x4xf32>>
- dealloc %1 : memref<?xi8>
+ %3 = memref.view %1[%c0][%arg0, %arg0] : memref<?xi8> to memref<?x?xf32>
+ %4 = memref.view %1[%c0][%arg0, %arg0] : memref<?xi8> to memref<?x?xvector<4x4xf32>>
+ memref.dealloc %1 : memref<?xi8>
return
}
// CHECK-LABEL: func @views
// CHECK: muli %{{.*}}, %{{.*}} : index
-// CHECK-NEXT: alloc(%{{.*}}) : memref<?xi8>
+// CHECK-NEXT: memref.alloc(%{{.*}}) : memref<?xi8>
// CHECK-NEXT: range
-// CHECK-NEXT: std.view %{{.*}}[%{{.*}}][%{{.*}}] :
+// CHECK-NEXT: memref.view %{{.*}}[%{{.*}}][%{{.*}}] :
// CHECK-SAME: memref<?xi8> to memref<?x?xf32>
-// CHECK-NEXT: view %{{.*}}[%{{.*}}][%{{.*}}] :
+// CHECK-NEXT: memref.view %{{.*}}[%{{.*}}][%{{.*}}] :
// CHECK-SAME: memref<?xi8> to memref<?x?xvector<4x4xf32>>
-// CHECK-NEXT: dealloc %{{.*}} : memref<?xi8>
+// CHECK-NEXT: memref.dealloc %{{.*}} : memref<?xi8>
// -----
// CHECK-DAG: #[[$strided3DT:.*]] = affine_map<(d0, d1, d2)[s0, s1, s2] -> (d2 * s1 + s0 + d1 * s2 + d0)>
func @transpose(%arg0: memref<?x?x?xf32, offset: ?, strides: [?, ?, 1]>) {
- %0 = transpose %arg0 (i, j, k) -> (k, j, i) : memref<?x?x?xf32, offset: ?, strides: [?, ?, 1]> to memref<?x?x?xf32, affine_map<(d0, d1, d2)[s0, s1, s2] -> (d2 * s1 + s0 + d1 * s2 + d0)>>
+ %0 = memref.transpose %arg0 (i, j, k) -> (k, j, i) : memref<?x?x?xf32, offset: ?, strides: [?, ?, 1]> to memref<?x?x?xf32, affine_map<(d0, d1, d2)[s0, s1, s2] -> (d2 * s1 + s0 + d1 * s2 + d0)>>
return
}
// CHECK-LABEL: func @transpose
// 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>
// 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>
// CHECK: %[[VAL_8:.*]] = linalg.sparse_indices %[[VAL_0]], %[[VAL_4]] : tensor<32xf32> to memref<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_13:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref<?xindex>
// CHECK: %[[VAL_5:.*]] = linalg.sparse_indices %[[VAL_0]], %[[VAL_2]] : tensor<32xf32> to memref<?xindex>
// CHECK: %[[VAL_6:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_10:.*]] = load %[[VAL_4]]{{\[}}%[[VAL_3]]] : memref<?xindex>
// CHECK: %[[VAL_6:.*]] = linalg.sparse_indices %[[VAL_0]], %[[VAL_3]] : tensor<32xf32> to memref<?xindex>
// CHECK: %[[VAL_7:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_11:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// 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>
// 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>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32xf32> to memref<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_14:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_6]]] : memref<?xindex>
// CHECK: %[[VAL_7:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32> to memref<?xindex>
// CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_12:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_14:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref<?xindex>
// CHECK: %[[VAL_7:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_12:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32> to memref<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<32xf32> to memref<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<16xf32> to memref<?xindex>
// CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_15:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<16xf32> to memref<?xindex>
// CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_15:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref<?xindex>
// CHECK: %[[VAL_4:.*]] = linalg.sparse_pointers %[[VAL_0]], %[[VAL_2]] : tensor<?xf32> to memref<?xindex>
// CHECK: %[[VAL_5:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<?xf32> to memref<?xf32>
// CHECK: %[[VAL_6:.*]] = tensor_to_memref %[[VAL_1]] : memref<f32>
-// CHECK: %[[VAL_7:.*]] = alloc() : memref<f32>
+// CHECK: %[[VAL_7:.*]] = memref.alloc() : memref<f32>
// CHECK: linalg.copy(%[[VAL_6]], %[[VAL_7]]) : memref<f32>, memref<f32>
// CHECK: %[[VAL_8:.*]] = load %[[VAL_4]]{{\[}}%[[VAL_2]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = load %[[VAL_4]]{{\[}}%[[VAL_3]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_3]] : tensor<16xf32> to memref<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<16xf32> to memref<?xf32>
// CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<f32>
-// CHECK: %[[VAL_12:.*]] = alloc() : memref<f32>
+// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<f32>
// CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<f32>, memref<f32>
// CHECK: %[[VAL_13:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref<?xindex>
// CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_11:.*]] = linalg.sparse_indices %[[VAL_2]], %[[VAL_4]] : tensor<16xf32> to memref<?xindex>
// CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_2]] : tensor<16xf32> to memref<?xf32>
// CHECK: %[[VAL_13:.*]] = tensor_to_memref %[[VAL_3]] : memref<f32>
-// CHECK: %[[VAL_14:.*]] = alloc() : memref<f32>
+// CHECK: %[[VAL_14:.*]] = memref.alloc() : memref<f32>
// CHECK: linalg.copy(%[[VAL_13]], %[[VAL_14]]) : memref<f32>, memref<f32>
// CHECK: %[[VAL_15:.*]] = load %[[VAL_9]][] : memref<f32>
// CHECK: %[[VAL_16:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// 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]] {
// 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]] {
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_15:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_7]]] : memref<?xindex>
// CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_13:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref<?xindex>
// CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_17:.*]] = load %[[VAL_8]]{{\[}}%[[VAL_7]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_14:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref<?xindex>
// CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref<?xindex>
// CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref<?xindex>
// CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_13:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<32x16xf32> to memref<?xindex>
// CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<32x16xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_18:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<16x32xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_5:.*]] = linalg.sparse_pointers %[[VAL_0]], %[[VAL_4]] : tensor<10x20xf32> to memref<?xindex>
// CHECK: %[[VAL_6:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<10x20xf32> to memref<?xf32>
// CHECK: %[[VAL_7:.*]] = tensor_to_memref %[[VAL_1]] : memref<f32>
-// CHECK: %[[VAL_8:.*]] = alloc() : memref<f32>
+// CHECK: %[[VAL_8:.*]] = memref.alloc() : memref<f32>
// CHECK: linalg.copy(%[[VAL_7]], %[[VAL_8]]) : memref<f32>, memref<f32>
// CHECK: scf.for %[[VAL_9:.*]] = %[[VAL_3]] to %[[VAL_2]] step %[[VAL_4]] {
// CHECK: %[[VAL_10:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_9]]] : memref<?xindex>
// CHECK: %[[VAL_8:.*]] = dim %[[VAL_1]], %[[VAL_3]] : tensor<?x?xf64>
// CHECK: %[[VAL_9:.*]] = dim %[[VAL_1]], %[[VAL_4]] : tensor<?x?xf64>
// CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<?x?xf64>
-// CHECK: %[[VAL_11:.*]] = alloc(%[[VAL_8]], %[[VAL_9]]) : memref<?x?xf64>
+// CHECK: %[[VAL_11:.*]] = memref.alloc(%[[VAL_8]], %[[VAL_9]]) : memref<?x?xf64>
// CHECK: linalg.copy(%[[VAL_10]], %[[VAL_11]]) : memref<?x?xf64>, memref<?x?xf64>
// CHECK: scf.for %[[VAL_12:.*]] = %[[VAL_3]] to %[[VAL_8]] step %[[VAL_4]] {
// CHECK: %[[VAL_13:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_12]]] : memref<?xindex>
// CHECK: %[[VAL_14:.*]] = dim %[[VAL_3]], %[[VAL_4]] : tensor<?x?xf32>
// CHECK: %[[VAL_15:.*]] = dim %[[VAL_3]], %[[VAL_5]] : tensor<?x?xf32>
// CHECK: %[[VAL_16:.*]] = tensor_to_memref %[[VAL_3]] : memref<?x?xf32>
-// CHECK: %[[VAL_17:.*]] = alloc(%[[VAL_14]], %[[VAL_15]]) : memref<?x?xf32>
+// CHECK: %[[VAL_17:.*]] = memref.alloc(%[[VAL_14]], %[[VAL_15]]) : memref<?x?xf32>
// CHECK: linalg.copy(%[[VAL_16]], %[[VAL_17]]) : memref<?x?xf32>, memref<?x?xf32>
// CHECK: %[[VAL_18:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_19:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref<?xindex>
// CHECK: %[[VAL_21:.*]] = tensor_to_memref %[[VAL_4]] : memref<f32>
// CHECK: %[[VAL_22:.*]] = dim %[[VAL_5]], %[[VAL_6]] : tensor<?xf32>
// CHECK: %[[VAL_23:.*]] = tensor_to_memref %[[VAL_5]] : memref<?xf32>
-// CHECK: %[[VAL_24:.*]] = alloc(%[[VAL_22]]) : memref<?xf32>
+// CHECK: %[[VAL_24:.*]] = memref.alloc(%[[VAL_22]]) : memref<?xf32>
// CHECK: linalg.copy(%[[VAL_23]], %[[VAL_24]]) : memref<?xf32>, memref<?xf32>
// CHECK: %[[VAL_25:.*]] = load %[[VAL_21]][] : memref<f32>
// CHECK: %[[VAL_26:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_6]]] : memref<?xindex>
// 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]] {
// 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]] {
// CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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]] {
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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]] {
// CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_16:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_8]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_14:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref<?xindex>
// CHECK: %[[VAL_14:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_19:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_9]]] : memref<?xindex>
// CHECK: %[[VAL_11:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_16:.*]] = load %[[VAL_7]]{{\[}}%[[VAL_6]]] : memref<?xindex>
// CHECK: %[[VAL_13:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_18:.*]] = load %[[VAL_9]]{{\[}}%[[VAL_8]]] : memref<?xindex>
// CHECK: %[[VAL_10:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_15:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref<?xindex>
// CHECK: %[[VAL_16:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_21:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_9]]] : memref<?xindex>
// CHECK: %[[VAL_12:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<32x16x8xf32> to memref<?xf32>
// 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<?xindex>
// CHECK: %[[VAL_17:.*]] = load %[[VAL_6]]{{\[}}%[[VAL_5]]] : memref<?xindex>
// CHECK: %[[VAL_13:.*]] = dim %[[VAL_0]], %[[VAL_5]] : tensor<?x?xf32>
// CHECK: %[[VAL_14:.*]] = dim %[[VAL_0]], %[[VAL_6]] : tensor<?x?xf32>
// CHECK: %[[VAL_15:.*]] = tensor_to_memref %[[VAL_0]] : memref<?x?xf32>
-// CHECK: %[[VAL_16:.*]] = alloc(%[[VAL_13]], %[[VAL_14]]) : memref<?x?xf32>
+// CHECK: %[[VAL_16:.*]] = memref.alloc(%[[VAL_13]], %[[VAL_14]]) : memref<?x?xf32>
// CHECK: linalg.copy(%[[VAL_15]], %[[VAL_16]]) : memref<?x?xf32>, memref<?x?xf32>
// 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]] {
// CHECK: %[[VAL_7:.*]] = linalg.sparse_pointers %[[VAL_0]], %[[VAL_2]] : tensor<10x20x30xf32> to memref<?xindex>
// CHECK: %[[VAL_8:.*]] = linalg.sparse_values %[[VAL_0]] : tensor<10x20x30xf32> to memref<?xf32>
// CHECK: %[[VAL_9:.*]] = tensor_to_memref %[[VAL_1]] : memref<f32>
-// CHECK: %[[VAL_10:.*]] = alloc() : memref<f32>
+// CHECK: %[[VAL_10:.*]] = memref.alloc() : memref<f32>
// CHECK: linalg.copy(%[[VAL_9]], %[[VAL_10]]) : memref<f32>, memref<f32>
// CHECK: %[[VAL_11:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_3]]] : memref<?xindex>
// CHECK: %[[VAL_12:.*]] = load %[[VAL_5]]{{\[}}%[[VAL_4]]] : memref<?xindex>
// CHECK: %[[VAL_9:.*]] = dim %[[VAL_1]], %[[VAL_4]] : tensor<?xf32>
// CHECK: %[[VAL_10:.*]] = tensor_to_memref %[[VAL_1]] : memref<?xf32>
// CHECK: %[[VAL_11:.*]] = tensor_to_memref %[[VAL_2]] : memref<f32>
-// CHECK: %[[VAL_12:.*]] = alloc() : memref<f32>
+// CHECK: %[[VAL_12:.*]] = memref.alloc() : memref<f32>
// CHECK: linalg.copy(%[[VAL_11]], %[[VAL_12]]) : memref<f32>, memref<f32>
// CHECK: scf.for %[[VAL_13:.*]] = %[[VAL_4]] to %[[VAL_9]] step %[[VAL_5]] {
// CHECK: %[[VAL_14:.*]] = load %[[VAL_10]]{{\[}}%[[VAL_13]]] : memref<?xf32>
// 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>
// CHECK-HIR: %[[VAL_9:.*]] = linalg.sparse_values %[[VAL_6]] : tensor<64x64xf64> to memref<?xf64>
// 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<?xindex>
// CHECK-MIR: %[[VAL_8:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr<i8>) -> memref<?xf64>
// 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>
// CHECK-LIR: %[[VAL_6:.*]] = call @sparsePointers64(%[[VAL_0]], %[[VAL_5]]) : (!llvm.ptr<i8>, index) -> memref<?xindex>
// CHECK-LIR: %[[VAL_7:.*]] = call @sparseIndices64(%[[VAL_0]], %[[VAL_5]]) : (!llvm.ptr<i8>, index) -> memref<?xindex>
// CHECK-LIR: %[[VAL_8:.*]] = call @sparseValuesF64(%[[VAL_0]]) : (!llvm.ptr<i8>) -> memref<?xf64>
-// 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>
// CHECK: %[[VAL_17:.*]] = linalg.sparse_indices %[[VAL_1]], %[[VAL_4]] : tensor<10x20x30x40x50x60x70x80xf32> to memref<?xindex>
// CHECK: %[[VAL_18:.*]] = linalg.sparse_values %[[VAL_1]] : tensor<10x20x30x40x50x60x70x80xf32> to memref<?xf32>
// 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]] {
// 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<?xf32>
// 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: }
// CHECK-SAME: %[[arg0:[a-zA-z0-9]*]]: memref<?xf32, #[[$map0]]>,
// CHECK-SAME: %[[arg1:[a-zA-z0-9]*]]: memref<?xf32, #[[$map0]]>,
// CHECK-SAME: %[[arg2:[a-zA-z0-9]*]]: memref<f32>) {
-// CHECK: %[[o0:.*]] = memref_cast %[[arg0]] :
+// CHECK: %[[o0:.*]] = memref.cast %[[arg0]] :
// CHECK-SAME: memref<?xf32, #[[$map0]]> to memref<?xf32, #[[$map6]]>
-// CHECK: %[[o1:.*]] = memref_cast %[[arg1]] :
+// CHECK: %[[o1:.*]] = memref.cast %[[arg1]] :
// CHECK-SAME: memref<?xf32, #[[$map0]]> to memref<?xf32, #[[$map6]]>
-// CHECK: %[[o2:.*]] = memref_cast %[[arg2]] :
+// CHECK: %[[o2:.*]] = memref.cast %[[arg2]] :
// CHECK-SAME: memref<f32> to memref<f32, #[[$map7]]>
// CHECK: call @linalg_dot_viewsxf32_viewsxf32_viewf32(
// CHECK-SAME: %[[o0]], %[[o1]], %[[o2]]) :
// CHECK-LABEL: func @copy(
// CHECK-SAME: %[[arg0:[a-zA-z0-9]*]]: memref<?x?x?xf32, #[[$map1]]>,
// CHECK-SAME: %[[arg1:[a-zA-z0-9]*]]: memref<?x?x?xf32, #[[$map1]]>) {
-// CHECK: %[[o0:.*]] = memref_cast %[[arg0]] :
+// CHECK: %[[o0:.*]] = memref.cast %[[arg0]] :
// CHECK-SAME: memref<?x?x?xf32, #[[$map1]]> to memref<?x?x?xf32, #[[$map8]]>
-// CHECK: %[[o1:.*]] = memref_cast %[[arg1]] :
+// CHECK: %[[o1:.*]] = memref.cast %[[arg1]] :
// CHECK-SAME: memref<?x?x?xf32, #[[$map1]]> to memref<?x?x?xf32, #[[$map8]]>
// CHECK: call @linalg_copy_viewsxsxsxf32_viewsxsxsxf32(%[[o0]], %[[o1]]) :
// CHECK-SAME: memref<?x?x?xf32, #[[$map8]]>, memref<?x?x?xf32, #[[$map8]]>
// CHECK-SAME: (d0, d1, d2) -> (d0, d2, d1) : memref<?x?x?xf32, #[[$map1]]>
// CHECK: %[[t1:.*]] = transpose %[[arg1]]
// CHECK-SAME: (d0, d1, d2) -> (d2, d1, d0) : memref<?x?x?xf32, #[[$map1]]>
-// CHECK: %[[o0:.*]] = memref_cast %[[t0]] :
+// CHECK: %[[o0:.*]] = memref.cast %[[t0]] :
// CHECK-SAME: memref<?x?x?xf32, #[[$map2]]> to memref<?x?x?xf32, #[[$map8]]>
-// CHECK: %[[o1:.*]] = memref_cast %[[t1]] :
+// CHECK: %[[o1:.*]] = memref.cast %[[t1]] :
// CHECK-SAME: memref<?x?x?xf32, #[[$map4]]> to memref<?x?x?xf32, #[[$map8]]>
// CHECK: call @linalg_copy_viewsxsxsxf32_viewsxsxsxf32(%[[o0]], %[[o1]]) :
// CHECK-SAME: memref<?x?x?xf32, #[[$map8]]>, memref<?x?x?xf32, #[[$map8]]>
// CHECK: %[[s0:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref<?x?xf32, #map{{.*}}> to memref<?x?xf32, #map{{.*}}>
// CHECK: %[[s1:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref<?x?xf32, #map{{.*}}> to memref<?x?xf32, #map{{.*}}>
// CHECK: %[[s2:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref<?x?xf32, #map{{.*}}> to memref<?x?xf32, #map{{.*}}>
-// CHECK: %[[a0:.*]] = alloc({{%.*}}) : memref<?xi8>
-// CHECK: %[[v0:.*]] = std.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[a0:.*]] = memref.alloc({{%.*}}) : memref<?xi8>
+// CHECK: %[[v0:.*]] = memref.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[l0:.*]] = subview %[[v0]][0, 0] [%{{.*}}, %{{.*}}] [1, 1]
// CHECK-SAME: memref<?x?xf32> to memref<?x?xf32, #[[$STRIDED_2D_u_1]]>
-// CHECK: %[[a1:.*]] = alloc({{%.*}}) : memref<?xi8>
-// CHECK: %[[v1:.*]] = std.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[a1:.*]] = memref.alloc({{%.*}}) : memref<?xi8>
+// CHECK: %[[v1:.*]] = memref.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[l1:.*]] = subview %[[v1]][0, 0] [%{{.*}}, %{{.*}}] [1, 1]
// CHECK-SAME: memref<?x?xf32> to memref<?x?xf32, #[[$STRIDED_2D_u_1]]>
-// CHECK: %[[a2:.*]] = alloc({{%.*}}) : memref<?xi8>
-// CHECK: %[[v2:.*]] = std.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[a2:.*]] = memref.alloc({{%.*}}) : memref<?xi8>
+// CHECK: %[[v2:.*]] = memref.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[l2:.*]] = subview %[[v2]][0, 0] [%{{.*}}, %{{.*}}] [1, 1]
// CHECK-SAME: memref<?x?xf32> to memref<?x?xf32, #[[$STRIDED_2D_u_1]]>
// CHECK: linalg.copy(%[[s0]], %[[l0]]) : memref<?x?xf32, #map{{.*}}>, memref<?x?xf32, #map{{.*}}>
// CHECK: %[[s0:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref<?x?xf32, #map{{.*}}> to memref<?x?xf32, #map{{.*}}>
// CHECK: %[[s1:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref<?x?xf32, #map{{.*}}> to memref<?x?xf32, #map{{.*}}>
// CHECK: %[[s2:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref<?x?xf32, #map{{.*}}> to memref<?x?xf32, #map{{.*}}>
-// CHECK: %[[a0:.*]] = alloc({{%.*}}) : memref<?xi8>
-// CHECK: %[[v0:.*]] = std.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[a0:.*]] = memref.alloc({{%.*}}) : memref<?xi8>
+// CHECK: %[[v0:.*]] = memref.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[l0:.*]] = subview %[[v0]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref<?x?xf32> to memref<?x?xf32, #[[$STRIDED_2D_u_1]]>
-// CHECK-NOT: %[[a1:.*]] = alloc({{%.*}}) : memref<?xi8>
-// CHECK-NOT: %[[v1:.*]] = std.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK-NOT: %[[a1:.*]] = memref.alloc({{%.*}}) : memref<?xi8>
+// CHECK-NOT: %[[v1:.*]] = memref.view %[[a1]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK-NOT: %[[l0:.*]] = subview %[[v1]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref<?x?xf32> to memref<?x?xf32, #[[$STRIDED_2D_u_1]]>
-// CHECK-NOT: %[[a2:.*]] = alloc({{%.*}}) : memref<?xi8>
-// CHECK-NOT: %[[v2:.*]] = std.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK-NOT: %[[a2:.*]] = memref.alloc({{%.*}}) : memref<?xi8>
+// CHECK-NOT: %[[v2:.*]] = memref.view %[[a2]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK-NOT: %[[l0:.*]] = subview %[[v2]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref<?x?xf32> to memref<?x?xf32, #[[$STRIDED_2D_u_1]]>
// CHECK: linalg.copy(%[[s0]], %[[l0]]) : memref<?x?xf32, #map{{.*}}>, memref<?x?xf32, #map{{.*}}>
// CHECK-NOT: linalg.copy(%[[s1]], %[[l1]]) : memref<?x?xf32, #map{{.*}}>, memref<?x?xf32, #map{{.*}}>
// CHECK-LABEL: func @aligned_promote_fill
// CHECK: %[[cf:.*]] = constant {{.*}} : f32
// CHECK: %[[s0:.*]] = subview {{%.*}}[{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] [{{%.*}}, {{%.*}}] : memref<?x?xf32, #map{{.*}}> to memref<?x?xf32, #map{{.*}}>
-// CHECK: %[[a0:.*]] = alloc({{%.*}}) {alignment = 32 : i64} : memref<?xi8>
-// CHECK: %[[v0:.*]] = std.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
+// CHECK: %[[a0:.*]] = memref.alloc({{%.*}}) {alignment = 32 : i64} : memref<?xi8>
+// CHECK: %[[v0:.*]] = memref.view %[[a0]][{{.*}}][{{%.*}}, {{%.*}}] : memref<?xi8> to memref<?x?xf32>
// CHECK: %[[l0:.*]] = subview %[[v0]][0, 0] [%{{.*}}, %{{.*}}] [1, 1] : memref<?x?xf32> to memref<?x?xf32, #[[$STRIDED_2D_u_1]]>
// CHECK: linalg.fill(%[[v0]], {{%.*}}) : memref<?x?xf32>, f32
// CHECK: linalg.copy(%[[s0]], %[[l0]]) : memref<?x?xf32, #map{{.*}}>, memref<?x?xf32, #map{{.*}}>
// -----
%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}
// -----
%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>)
// -----
%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>)
%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>
}
}
}
// 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: }
%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>
}
}
}
// 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: }
%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
}
%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}
// 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: }
// 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}
%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<?x?x?xi32>
+ memref.store %c42, %A[%i0, %i1, %i2] : memref<?x?x?xi32>
scf.yield
}
return
// 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<?x?x?xi32>
+// CHECK: memref.store [[C42]], [[ARG0]]{{\[}}[[C0]], [[V0]], [[C7]]] : memref<?x?x?xi32>
// CHECK: scf.yield
// CHECK: }
// CHECK: return
%B_elem = load %B[%i0] : memref<?xf32>
%C_elem = load %C[%i0] : memref<?xf32>
%sum_elem = addf %B_elem, %C_elem : f32
- store %sum_elem, %result[%i0] : memref<?xf32>
+ memref.store %sum_elem, %result[%i0] : memref<?xf32>
}
return
}
// 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
%arg3: memref<?xf32>) {
%0 = constant 7.0 : f32
scf.for %i0 = %arg0 to %arg1 step %arg2 {
- store %0, %arg3[%i0] : memref<?xf32>
+ memref.store %0, %arg3[%i0] : memref<?xf32>
}
return
}
// 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<?xf32>
+// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V10]]] : memref<?xf32>
// UNROLL-BY-2-NEXT: }
// UNROLL-BY-2-NEXT: scf.for %[[IV:.*]] = %[[V7]] to %[[UB]] step %[[STEP]] {
-// UNROLL-BY-2-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
+// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// UNROLL-BY-2-NEXT: }
// UNROLL-BY-2-NEXT: return
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V10]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V12]]] : memref<?xf32>
// UNROLL-BY-3-NEXT: }
// UNROLL-BY-3-NEXT: scf.for %[[IV:.*]] = %[[V7]] to %[[UB]] step %[[STEP]] {
-// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// UNROLL-BY-3-NEXT: }
// UNROLL-BY-3-NEXT: return
%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<?xf32>
+ memref.store %0, %arg6[%i1] : memref<?xf32>
}
}
return
//
// 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<?xf32>
+// UNROLL-OUTER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-OUTER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-OUTER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref<?xf32>
// UNROLL-OUTER-BY-2-NEXT: }
// UNROLL-OUTER-BY-2-NEXT: }
// UNROLL-OUTER-BY-2-NEXT: return
%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<?xf32>
+ memref.store %0, %arg6[%i1] : memref<?xf32>
}
}
return
//
// 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<?xf32>
+// UNROLL-INNER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-INNER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-INNER-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV1]]] : memref<?xf32>
// UNROLL-INNER-BY-2-NEXT: }
// UNROLL-INNER-BY-2-NEXT: }
// UNROLL-INNER-BY-2-NEXT: return
%ub = constant 20 : index
%step = constant 1 : index
scf.for %i0 = %lb to %ub step %step {
- store %0, %arg0[%i0] : memref<?xf32>
+ memref.store %0, %arg0[%i0] : memref<?xf32>
}
return
}
// 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<?xf32>
+// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-2-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref<?xf32>
// UNROLL-BY-2-NEXT: }
// UNROLL-BY-2-NEXT: return
%ub = constant 20 : index
%step = constant 1 : index
scf.for %i0 = %lb to %ub step %step {
- store %0, %arg0[%i0] : memref<?xf32>
+ memref.store %0, %arg0[%i0] : memref<?xf32>
}
return
}
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V3]]] : memref<?xf32>
// UNROLL-BY-3-NEXT: }
// UNROLL-BY-3-NEXT: scf.for %[[IV:.*]] = %[[C18]] to %[[C20]] step %[[C1]] {
-// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// UNROLL-BY-3-NEXT: }
// UNROLL-BY-3-NEXT: return
%ub = constant 10 : index
%step = constant 1 : index
scf.for %i0 = %lb to %ub step %step {
- store %0, %arg0[%i0] : memref<?xf32>
+ memref.store %0, %arg0[%i0] : memref<?xf32>
}
return
}
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[IV]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V1]]] : memref<?xf32>
// 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<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[V3]]] : memref<?xf32>
// UNROLL-BY-3-NEXT: }
-// UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[C9]]] : memref<?xf32>
+// UNROLL-BY-3-NEXT: memref.store %{{.*}}, %[[MEM]][%[[C9]]] : memref<?xf32>
// UNROLL-BY-3-NEXT: return
// Test unroll-up-to functionality.
%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
// 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]]
// -----
%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
// 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]]
// -----
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
}
%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) {
%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
%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) {
%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
%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
}
%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
// 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]]
%B_elem = load %B[%i0, %i1] : memref<?x?xf32>
%C_elem = load %C[%i0, %i1] : memref<?x?xf32>
%sum_elem = addf %B_elem, %C_elem : f32
- store %sum_elem, %result[%i0, %i1] : memref<?x?xf32>
+ memref.store %sum_elem, %result[%i0, %i1] : memref<?x?xf32>
}
return
}
// 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
%B_elem = load %B[%i0, %i1] : memref<?x?xf32>
%C_elem = load %C[%i0, %i1] : memref<?x?xf32>
%sum_elem = addf %B_elem, %C_elem : f32
- store %sum_elem, %result[%i0, %i1] : memref<?x?xf32>
+ memref.store %sum_elem, %result[%i0, %i1] : memref<?x?xf32>
}
return
}
// CHECK: [[V11:%.*]] = load [[ARG8]]{{\[}}[[V9]], [[V10]]] : memref<?x?xf32>
// CHECK: [[V12:%.*]] = load [[ARG9]]{{\[}}[[V9]], [[V10]]] : memref<?x?xf32>
// CHECK: [[V13:%.*]] = addf [[V11]], [[V12]] : f32
-// CHECK: store [[V13]], [[ARG10]]{{\[}}[[V9]], [[V10]]] : memref<?x?xf32>
+// CHECK: memref.store [[V13]], [[ARG10]]{{\[}}[[V9]], [[V10]]] : memref<?x?xf32>
// CHECK: }
// CHECK: }
// CHECK: return
// CHECK-SAME: %[[SHP:[0-9a-z]+]]: memref<?xindex>
// 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<?xindex>)
%0 = memref_reshape %arg0(%arg1)
: (memref<*xf32>, memref<?xindex>) -> memref<*xf32>
// Update the shape to test that he load ends up in the right place.
- store %c3, %arg1[%c3] : memref<?xindex>
+ memref.store %c3, %arg1[%c3] : memref<?xindex>
%1 = dim %0, %c3 : memref<*xf32>
return %1 : index
}
// 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<?x?x16x32xi8>
+// CHECK: %[[M1:.+]] = memref.cast %[[M]] : memref<4x6x16x32xi8> to memref<?x?x16x32xi8>
// CHECK: return %[[M1]] : memref<?x?x16x32xi8>
func @tensor_cast_to_memref(%arg0 : tensor<4x6x16x32xi8>) ->
memref<?x?x16x32xi8> {
// 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<?x?x16x32xi8>
+ %0 = memref.cast %arg : memref<4x6x16x32xi8> to memref<?x?x16x32xi8>
%1 = subview %0[0, 1, 0, 0] [1, 1, 16, 32] [1, 1, 1, 1] :
memref<?x?x16x32xi8> to
memref<16x32xi8, affine_map<(d0, d1)[s0] -> (d0 * 32 + d1 + s0)>>
func @transpose_not_permutation(%v : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>) {
// expected-error @+1 {{expected a permutation map}}
- transpose %v (i, j) -> (i, i) : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>> to memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>
+ memref.transpose %v (i, j) -> (i, i) : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>> to memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>
}
// -----
func @transpose_bad_rank(%v : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>) {
// expected-error @+1 {{expected a permutation map of same rank as the input}}
- transpose %v (i) -> (i) : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>> to memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>
+ memref.transpose %v (i) -> (i) : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>> to memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>
}
// -----
func @transpose_wrong_type(%v : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>) {
// expected-error @+1 {{output type 'memref<?x?xf32, affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)>>' does not match transposed input type 'memref<?x?xf32, affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)>>'}}
- transpose %v (i, j) -> (j, i) : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>> to memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>
+ memref.transpose %v (i, j) -> (j, i) : memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>> to memref<?x?xf32, affine_map<(i, j)[off, M]->(off + M * i + j)>>
}
// -----
// -----
// 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<?x?xf32>
+memref.global @foo : memref<?x?xf32>
// -----
// 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
}
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
}
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
// 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
}
// CHECK-LABEL: func @tensor.cast(
// CHECK-SAME: %[[TENSOR:.*]]: tensor<?xindex>) -> tensor<2xindex> {
// CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]]
-// CHECK: %[[CASTED:.*]] = memref_cast %[[MEMREF]] : memref<?xindex> to memref<2xindex>
+// CHECK: %[[CASTED:.*]] = memref.cast %[[MEMREF]] : memref<?xindex> to memref<2xindex>
// CHECK: %[[RET:.*]] = tensor_load %[[CASTED]]
// CHECK: return %[[RET]] : tensor<2xindex>
func @tensor.cast(%arg0: tensor<?xindex>) -> tensor<2xindex> {
// 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> {
// 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> {
// 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
// CHECK-LABEL: func @tensor.generate(
// CHECK-SAME: %[[ARG:.*]]: tensor<*xf32>,
// CHECK-SAME: %[[DYNAMIC_EXTENT:.*]]: index) -> tensor<?xindex> {
-// CHECK: %[[MEMREF:.*]] = alloc(%[[DYNAMIC_EXTENT]]) : memref<?xindex>
+// CHECK: %[[MEMREF:.*]] = memref.alloc(%[[DYNAMIC_EXTENT]]) : memref<?xindex>
// CHECK: %[[C0:.*]] = constant 0 : index
// CHECK: %[[C1:.*]] = constant 1 : index
// CHECK: scf.parallel (%[[I:.*]]) = (%[[C0]]) to (%[[DYNAMIC_EXTENT]]) step (%[[C1]]) {
//
// 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
// 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<?xindex>
+ %mem = memref.alloc(%size) : memref<?xindex>
// CHECK: %[[DTENSOR:.*]] = tensor.generate
%0 = tensor.generate %size {
^bb0(%arg0: index):
%1 = dim %tensor, %arg0 : tensor<*xf32>
- store %1, %mem[%arg0] : memref<?xindex>
+ memref.store %1, %mem[%arg0] : memref<?xindex>
tensor.yield %1 : index
} : tensor<?xindex>
// CHECK: %[[RES:.*]] = tensor.extract %[[DTENSOR]][%[[IDX]]]
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<?x?xf32>
+ %0 = memref.cast %A : memref<4x8xf32> to memref<?x?xf32>
// CHECK: vector.transfer_read %{{.*}} {masked = [false, false]} : memref<4x8xf32>, vector<4x8xf32>
%1 = vector.transfer_read %0[%c0, %c0], %f0 : memref<?x?xf32>, vector<4x8xf32>
// 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<add>} : vector<2xf32>, f32
-// CHECK: store %[[T9]], %[[C]][] : memref<vector<2xf32>>
+// CHECK: memref.store %[[T9]], %[[C]][] : memref<vector<2xf32>>
// CHECK: return
func @matvec2x2(%arg0: memref<vector<2x2xf32>>, %arg1: memref<vector<2xf32>>,
%arg2: memref<vector<2xf32>>) {
%x = load %arg1[] : memref<vector<2xf32>>
%b = load %arg2[] : memref<vector<2xf32>>
%0 = vector.contract #matvec_trait %A, %x, %b : vector<2x2xf32>, vector<2xf32> into vector<2xf32>
- store %0, %arg2[] : memref<vector<2xf32>>
+ memref.store %0, %arg2[] : memref<vector<2xf32>>
return
}
// 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<max>} : vector<2xf32>, f32
-// CHECK: store %[[T9]], %[[C]][] : memref<vector<2xf32>>
+// CHECK: memref.store %[[T9]], %[[C]][] : memref<vector<2xf32>>
// CHECK: return
func @matvecmax2x2(%arg0: memref<vector<2x2xf32>>, %arg1: memref<vector<2xf32>>,
%arg2: memref<vector<2xf32>>) {
%x = load %arg1[] : memref<vector<2xf32>>
%b = load %arg2[] : memref<vector<2xf32>>
%0 = vector.contract #matvecmax_trait %A, %x, %b : vector<2x2xf32>, vector<2xf32> into vector<2xf32>
- store %0, %arg2[] : memref<vector<2xf32>>
+ memref.store %0, %arg2[] : memref<vector<2xf32>>
return
}
// 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<add>} : vector<2xf32>, f32
-// CHECK: store %[[T8]], %[[C]][] : memref<vector<2xf32>>
+// CHECK: memref.store %[[T8]], %[[C]][] : memref<vector<2xf32>>
// CHECK: return
func @mattransvec2x2(%arg0: memref<vector<2x2xf32>>, %arg1: memref<vector<2xf32>>,
%arg2: memref<vector<2xf32>>) {
%x = load %arg1[] : memref<vector<2xf32>>
%b = load %arg2[] : memref<vector<2xf32>>
%0 = vector.contract #mattransvec_trait %A, %x, %b : vector<2x2xf32>, vector<2xf32> into vector<2xf32>
- store %0, %arg2[] : memref<vector<2xf32>>
+ memref.store %0, %arg2[] : memref<vector<2xf32>>
return
}
// 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<add>} : vector<2xf32>, f32
-// CHECK: store %[[T9]], %[[C]][] : memref<vector<2xf32>>
+// CHECK: memref.store %[[T9]], %[[C]][] : memref<vector<2xf32>>
// CHECK: return
func @vecmat2x2(%arg0: memref<vector<2x2xf32>>, %arg1: memref<vector<2xf32>>,
%arg2: memref<vector<2xf32>>) {
%x = load %arg1[] : memref<vector<2xf32>>
%b = load %arg2[] : memref<vector<2xf32>>
%0 = vector.contract #vecmat_trait %x, %A, %b : vector<2xf32>, vector<2x2xf32> into vector<2xf32>
- store %0, %arg2[] : memref<vector<2xf32>>
+ memref.store %0, %arg2[] : memref<vector<2xf32>>
return
}
// 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<add>} : vector<2xf32>, f32
-// CHECK: store %[[T8]], %[[C]][] : memref<vector<2xf32>>
+// CHECK: memref.store %[[T8]], %[[C]][] : memref<vector<2xf32>>
// CHECK: return
func @vecmattrans2x2(%arg0: memref<vector<2x2xf32>>, %arg1: memref<vector<2xf32>>,
%arg2: memref<vector<2xf32>>) {
%x = load %arg1[] : memref<vector<2xf32>>
%b = load %arg2[] : memref<vector<2xf32>>
%0 = vector.contract #vecmattrans_trait %x, %A, %b : vector<2xf32>, vector<2x2xf32> into vector<2xf32>
- store %0, %arg2[] : memref<vector<2xf32>>
+ memref.store %0, %arg2[] : memref<vector<2xf32>>
return
}
// 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<?x8xf32>
// CHECK: %[[cast_alloc:.*]] = vector.type_cast %[[alloc]] :
// CHECK-SAME: memref<4x8xf32> to memref<vector<4x8xf32>>
// CHECK: store %[[slow]], %[[cast_alloc]][] : memref<vector<4x8xf32>>
- // CHECK: %[[yielded:.*]] = memref_cast %[[alloc]] :
+ // CHECK: %[[yielded:.*]] = memref.cast %[[alloc]] :
// CHECK-SAME: memref<4x8xf32> to memref<?x8xf32>
// CHECK: scf.yield %[[yielded]], %[[c0]], %[[c0]] :
// CHECK-SAME: memref<?x8xf32>, index, index
// 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<?x8xf32>
// LINALG: %[[sv:.*]] = subview %[[A]][%[[i]], %[[j]]] [%[[sv0]], %[[sv1]]] [1, 1]
// LINALG-SAME: memref<?x8xf32> to memref<?x?xf32, #[[$map_2d_stride_8x1]]>
// LINALG: linalg.copy(%[[sv]], %[[alloc]]) : memref<?x?xf32, #[[$map_2d_stride_8x1]]>, memref<4x8xf32>
- // LINALG: %[[yielded:.*]] = memref_cast %[[alloc]] :
+ // LINALG: %[[yielded:.*]] = memref.cast %[[alloc]] :
// LINALG-SAME: memref<4x8xf32> to memref<?x8xf32>
// LINALG: scf.yield %[[yielded]], %[[c0]], %[[c0]] :
// LINALG-SAME: memref<?x8xf32>, index, index
// 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
// CHECK: %[[cond:.*]] = and %[[cmp0]], %[[cmp1]] : i1
// CHECK: %[[ifres:.*]]:3 = scf.if %[[cond]] -> (memref<?x8xf32, #[[$map_2d_stride_1]]>, 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<?x8xf32, #[[$map_2d_stride_1]]>
// CHECK: scf.yield %[[casted]], %[[i]], %[[j]] :
// CHECK-SAME: memref<?x8xf32, #[[$map_2d_stride_1]]>, index, index
// CHECK-SAME: memref<4x8xf32> to memref<vector<4x8xf32>>
// CHECK: store %[[slow]], %[[cast_alloc]][] :
// CHECK-SAME: memref<vector<4x8xf32>>
- // CHECK: %[[yielded:.*]] = memref_cast %[[alloc]] :
+ // CHECK: %[[yielded:.*]] = memref.cast %[[alloc]] :
// CHECK-SAME: memref<4x8xf32> to memref<?x8xf32, #[[$map_2d_stride_1]]>
// CHECK: scf.yield %[[yielded]], %[[c0]], %[[c0]] :
// CHECK-SAME: memref<?x8xf32, #[[$map_2d_stride_1]]>, index, index
// 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
// LINALG: %[[cond:.*]] = and %[[cmp0]], %[[cmp1]] : i1
// LINALG: %[[ifres:.*]]:3 = scf.if %[[cond]] -> (memref<?x8xf32, #[[$map_2d_stride_1]]>, 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<?x8xf32, #[[$map_2d_stride_1]]>
// LINALG: scf.yield %[[casted]], %[[i]], %[[j]] :
// LINALG-SAME: memref<?x8xf32, #[[$map_2d_stride_1]]>, index, index
// LINALG: %[[sv:.*]] = subview %[[A]][%[[i]], %[[j]]] [%[[sv0]], %[[sv1]]] [1, 1]
// LINALG-SAME: memref<7x8xf32, #[[$map_2d_stride_1]]> to memref<?x?xf32, #[[$map_2d_stride_1]]>
// LINALG: linalg.copy(%[[sv]], %[[alloc]]) : memref<?x?xf32, #[[$map_2d_stride_1]]>, memref<4x8xf32>
- // LINALG: %[[yielded:.*]] = memref_cast %[[alloc]] :
+ // LINALG: %[[yielded:.*]] = memref.cast %[[alloc]] :
// LINALG-SAME: memref<4x8xf32> to memref<?x8xf32, #[[$map_2d_stride_1]]>
// LINALG: scf.yield %[[yielded]], %[[c0]], %[[c0]] :
// LINALG-SAME: memref<?x8xf32, #[[$map_2d_stride_1]]>, index, index
func @vector_transfers(%arg0: index, %arg1: index) {
%cst = constant 0.000000e+00 : f32
- %0 = alloc(%arg0, %arg1) : memref<?x?xf32>
- %1 = alloc(%arg0, %arg1) : memref<?x?xf32>
- %2 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %0 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
+ %2 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
%cst_0 = constant 1.000000e+00 : f32
%cst_1 = constant 2.000000e+00 : f32
affine.for %arg2 = 0 to %arg0 step 4 {
%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)>}
// 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>
// 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
// 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>
// 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>
// 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>
// 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
// 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>
// 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>
// 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>
// 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
// 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>
// 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>
// 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
}
// CHECK-LABEL: func @zero_dim_no_idx
func @zero_dim_no_idx(%arg0 : memref<i32>, %arg1 : memref<i32>, %arg2 : memref<i32>) {
%0 = std.load %arg0[] : memref<i32>
- std.store %0, %arg1[] : memref<i32>
+ memref.store %0, %arg1[] : memref<i32>
return
// CHECK: %0 = load %{{.*}}[] : memref<i32>
- // CHECK: store %{{.*}}, %{{.*}}[] : memref<i32>
+ // CHECK: memref.store %{{.*}}, %{{.*}}[] : memref<i32>
}
// CHECK-LABEL: func @return_op(%arg0: i32) -> i32 {
// CHECK-LABEL: func @memref_cast(%arg0
func @memref_cast(%arg0: memref<4xf32>, %arg1 : memref<?xf32>, %arg2 : memref<64x16x4xf32, offset: 0, strides: [64, 4, 1]>) {
- // CHECK: %0 = memref_cast %arg0 : memref<4xf32> to memref<?xf32>
- %0 = memref_cast %arg0 : memref<4xf32> to memref<?xf32>
+ // CHECK: %0 = memref.cast %arg0 : memref<4xf32> to memref<?xf32>
+ %0 = memref.cast %arg0 : memref<4xf32> to memref<?xf32>
- // CHECK: %1 = memref_cast %arg1 : memref<?xf32> to memref<4xf32>
- %1 = memref_cast %arg1 : memref<?xf32> to memref<4xf32>
+ // CHECK: %1 = memref.cast %arg1 : memref<?xf32> to memref<4xf32>
+ %1 = memref.cast %arg1 : memref<?xf32> 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
}
// 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<?x?xf32>
- %1 = view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref<?x?xf32>
+ // CHECK: %{{.*}} = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref<?x?xf32>
+ %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8> to memref<?x?xf32>
// 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
}
%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<?x?x?xf32, #[[$BASE_MAP3]]>
: memref<8x16x4xf32, offset:0, strides: [64, 4, 1]> to
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- %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<?xf32, #[[$SUBVIEW_MAP1]]>
: memref<64xf32, affine_map<(d0)[s0] -> (d0 + s0)>> to
memref<?xf32, affine_map<(d0)[s0, s1] -> (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<?x?xf32, #[[$SUBVIEW_MAP2]]>
: memref<8x16x4xf32, offset:0, strides: [64, 4, 1]> to
memref<4x4x4xf32, offset:8, strides: [64, 4, 1]>
- %7 = alloc(%arg1, %arg2) : memref<?x?xf32>
+ %7 = memref.alloc(%arg1, %arg2) : memref<?x?xf32>
// CHECK: subview {{%.*}}[0, 0] [4, 4] [1, 1] :
// CHECK-SAME: memref<?x?xf32>
// CHECK-SAME: to memref<4x4xf32, #[[$SUBVIEW_MAP4]]>
%8 = subview %7[0, 0][4, 4][1, 1]
: memref<?x?xf32> 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]]
%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]]>
// 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<?x5x?xf32, #[[$BASE_MAP3]]>
%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<?x5x?xf32, offset: ?, strides: [?, ?, ?]>
// CHECK-SAME: memref<1x?x5x1x?x1xf32, #[[$SUBVIEW_MAP7]]> to memref<?x5x?x1xf32, #[[$SUBVIEW_MAP8]]>
%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<?x5x?x1xf32, offset: ?, strides: [?, ?, ?, ?]>
- %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<f32>
+ %23 = memref.alloc() : memref<f32>
%78 = subview %23[] [] [] : memref<f32> to memref<f32>
/// 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]>
%28 = subview %24[%arg0, 1] [1, 1] [1, 1] : memref<5x3xf32> to memref<f32, affine_map<()[s0] -> (s0)>>
// CHECK: subview %{{.*}}[0, %{{.*}}] [%{{.*}}, 1] [1, 1] : memref<?x?xf32> to memref<?xf32, #[[$SUBVIEW_MAP1]]>
- %a30 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %a30 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%30 = subview %a30[0, %arg1][%arg2, 1][1, 1] : memref<?x?xf32> to memref<?xf32, affine_map<(d0)[s0, s1] -> (d0 * s1 + s0)>>
return
%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
}
%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
}
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<i32>) {
- "std.store"(%x,%p) : (i32, memref<i32>) -> i32 // expected-error {{'std.store' op requires zero results}}
+ "memref.store"(%x,%p) : (i32, memref<i32>) -> i32 // expected-error {{'memref.store' op requires zero results}}
return
}
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
}
// -----
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
}
// -----
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
}
// -----
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<?x?xf32>
return
}
// -----
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<?x?xf32, affine_map<(d0, d1)[s0] -> (d0 * 4 + d1 + s0)>>
return
// -----
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<?x?xf32, affine_map<(d0, d1)[s0] -> (d0, d1, s0)>>
return
}
// -----
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<?x?xf32, 1>
+ %1 = memref.view %0[%arg2][%arg0, %arg1] : memref<2048xi8, 2> to memref<?x?xf32, 1>
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<?x?xf32>
return
}
// -----
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>
// -----
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>
// -----
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>
// -----
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
// -----
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
// -----
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
// -----
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<?x?x?xf32, affine_map<(d0, d1, d2)[s0, s1, s2, s3] -> (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
// -----
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
// -----
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
// -----
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>
// -----
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>
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
}
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
}
// 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
}
// 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
}
// 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
}
%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
}
}
// -----
"alloca_without_scoped_alloc_parent"() ( {
- std.alloca() : memref<1xf32>
+ memref.alloca() : memref<1xf32>
// expected-error@-1 {{requires an ancestor op with AutomaticAllocationScope trait}}
return
}) : () -> ()
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<?x?xf32, 1>
- %1 = alloc(%c0, %c1) : memref<?x?xf32, affine_map<(d0, d1) -> (d0, d1)>, 1>
+ // CHECK: %1 = memref.alloc(%c0, %c1) : memref<?x?xf32, 1>
+ %1 = memref.alloc(%c0, %c1) : memref<?x?xf32, affine_map<(d0, d1) -> (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
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<?x?xf32, 1>
- %1 = alloca(%c0, %c1) : memref<?x?xf32, affine_map<(d0, d1) -> (d0, d1)>, 1>
+ // CHECK: %1 = memref.alloca(%c0, %c1) : memref<?x?xf32, 1>
+ %1 = memref.alloca(%c0, %c1) : memref<?x?xf32, affine_map<(d0, d1) -> (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
}
// 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
// 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
}
%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
%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<?x?xi32> // CHECK: store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}]
+ memref.store %c, %arg1[%i0, %i1] : memref<?x?xi32> // CHECK: memref.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}]
} // CHECK: }
} // CHECK: }
return // CHECK: return
// RUN: mlir-opt -slice-analysis-test %s | FileCheck %s
func @slicing_linalg_op(%arg0 : index, %arg1 : index, %arg2 : index) {
- %a = alloc(%arg0, %arg2) : memref<?x?xf32>
- %b = alloc(%arg2, %arg1) : memref<?x?xf32>
- %c = alloc(%arg0, %arg1) : memref<?x?xf32>
- %d = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %a = memref.alloc(%arg0, %arg2) : memref<?x?xf32>
+ %b = memref.alloc(%arg2, %arg1) : memref<?x?xf32>
+ %c = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
+ %d = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
linalg.matmul ins(%a, %b : memref<?x?xf32>, memref<?x?xf32>)
outs(%c : memref<?x?xf32>)
linalg.matmul ins(%a, %b : memref<?x?xf32>, memref<?x?xf32>)
outs(%d : memref<?x?xf32>)
- dealloc %c : memref<?x?xf32>
- dealloc %b : memref<?x?xf32>
- dealloc %a : memref<?x?xf32>
- dealloc %d : memref<?x?xf32>
+ memref.dealloc %c : memref<?x?xf32>
+ memref.dealloc %b : memref<?x?xf32>
+ memref.dealloc %a : memref<?x?xf32>
+ memref.dealloc %d : memref<?x?xf32>
return
}
// 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<?x?xf32>
-// CHECK-DAG: %[[B:.+]] = alloc(%[[ARG2]], %[[ARG1]]) : memref<?x?xf32>
-// CHECK-DAG: %[[C:.+]] = alloc(%[[ARG0]], %[[ARG1]]) : memref<?x?xf32>
+// CHECK-DAG: %[[A:.+]] = memref.alloc(%[[ARG0]], %[[ARG2]]) : memref<?x?xf32>
+// CHECK-DAG: %[[B:.+]] = memref.alloc(%[[ARG2]], %[[ARG1]]) : memref<?x?xf32>
+// CHECK-DAG: %[[C:.+]] = memref.alloc(%[[ARG0]], %[[ARG1]]) : memref<?x?xf32>
// 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<?x?xf32>
-// CHECK-DAG: %[[B:.+]] = alloc(%[[ARG2]], %[[ARG1]]) : memref<?x?xf32>
-// CHECK-DAG: %[[C:.+]] = alloc(%[[ARG0]], %[[ARG1]]) : memref<?x?xf32>
+// CHECK-DAG: %[[A:.+]] = memref.alloc(%[[ARG0]], %[[ARG2]]) : memref<?x?xf32>
+// CHECK-DAG: %[[B:.+]] = memref.alloc(%[[ARG2]], %[[ARG1]]) : memref<?x?xf32>
+// CHECK-DAG: %[[C:.+]] = memref.alloc(%[[ARG0]], %[[ARG1]]) : memref<?x?xf32>
// CHECK: return
^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>):
}
// 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
// -----
^bb1:
br ^bb3(%arg1 : memref<?xf32>)
^bb2(%0: index):
- %1 = alloc(%0) : memref<?xf32>
+ %1 = memref.alloc(%0) : memref<?xf32>
test.buffer_based in(%arg1: memref<?xf32>) out(%1: memref<?xf32>)
br ^bb3(%1 : memref<?xf32>)
^bb3(%2: memref<?xf32>):
// 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
// -----
^bb1:
br ^bb6(%arg1 : memref<?xf32>)
^bb2(%0: index):
- %1 = alloc(%0) : memref<?xf32>
+ %1 = memref.alloc(%0) : memref<?xf32>
test.buffer_based in(%arg1: memref<?xf32>) out(%1: memref<?xf32>)
cond_br %arg0, ^bb3, ^bb4
^bb3:
// 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:
// 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
// -----
// 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
// -----
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>):
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
// -----
// 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:
// 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>),
^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
// -----
// 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>),
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
// -----
// 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>),
^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
// -----
// 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
%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>):
// 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
// -----
%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
// -----
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]]
// -----
// 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]]
// -----
^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
}
// 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
%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]]
// -----
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %3 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %3 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
scf.yield %1 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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]]
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %3 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %3 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
scf.yield %3 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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]]
// -----
// CHECK-LABEL: func @inner_region_control_flow
func @inner_region_control_flow(%arg0 : index) -> memref<?x?xf32> {
- %0 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %0 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%1 = test.region_if %0 : memref<?x?xf32> -> (memref<?x?xf32>) then {
^bb0(%arg1 : memref<?x?xf32>):
test.region_if_yield %arg1 : memref<?x?xf32>
return %1 : memref<?x?xf32>
}
-// 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]]
// CHECK-LABEL: func @subview
func @subview(%arg0 : index, %arg1 : index, %arg2 : memref<?x?xf32>) {
- %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<?x?xf32, offset: ?, strides: [?, ?]>
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
// -----
^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>):
}
// CHECK-NEXT: cond_br
-// CHECK: %[[ALLOCA:.*]] = alloca()
+// CHECK: %[[ALLOCA:.*]] = memref.alloca()
// CHECK: br ^bb3(%[[ALLOCA:.*]])
// CHECK-NEXT: ^bb3
// CHECK-NEXT: test.copy
// 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>),
^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
%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>),
^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
// -----
^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
// 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
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %3 = alloca(%arg0, %arg1) : memref<?x?xf32>
+ %3 = memref.alloca(%arg0, %arg1) : memref<?x?xf32>
scf.yield %1 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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]]
%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]]
// -----
%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
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]]
// -----
%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>
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]]
// -----
%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>
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]]
// -----
%const1 = constant 1 : i32
%inc = addi %val, %const1 : i32
%size = std.index_cast %inc : i32 to index
- %alloc1 = alloc(%size) : memref<?xf32>
+ %alloc1 = memref.alloc(%size) : memref<?xf32>
br ^loopHeader(%inc, %alloc1 : i32, memref<?xf32>)
^exit(%buff3 : memref<?xf32>):
^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>):
%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>)
// 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]]
// -----
^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>):
return
}
-// CHECK-NEXT: %[[ALLOC:.*]] = alloc()
+// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc()
// CHECK-NEXT: cond_br
// -----
^bb1:
br ^bb3(%arg1 : memref<?xf32>)
^bb2(%0: index):
- %1 = alloc(%0) : memref<?xf32>
+ %1 = memref.alloc(%0) : memref<?xf32>
test.buffer_based in(%arg1: memref<?xf32>) out(%1: memref<?xf32>)
br ^bb3(%1 : memref<?xf32>)
^bb3(%2: memref<?xf32>):
// 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
// -----
^bb1:
br ^bb6(%arg1 : memref<?xf32>)
^bb2(%0: index):
- %1 = alloc(%0) : memref<?xf32>
+ %1 = memref.alloc(%0) : memref<?xf32>
test.buffer_based in(%arg1: memref<?xf32>) out(%1: memref<?xf32>)
cond_br %arg0, ^bb3, ^bb4
^bb3:
// 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
// -----
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>):
return
}
-// CHECK-NEXT: %[[ALLOC:.*]] = alloc()
+// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc()
// CHECK-NEXT: cond_br
// -----
// 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>),
^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
// 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>),
return
}
-// CHECK-NEXT: %[[ALLOC0:.*]] = alloc()
+// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc()
// CHECK-NEXT: test.buffer_based
// -----
// 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>),
^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
// -----
// 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
// -----
%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>):
return
}
-// CHECK-NEXT: %{{.*}} = alloc()
-// CHECK-NEXT: %{{.*}} = alloc()
+// CHECK-NEXT: %{{.*}} = memref.alloc()
+// CHECK-NEXT: %{{.*}} = memref.alloc()
// CHECK-NEXT: cond_br
// -----
^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
// -----
^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
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
// -----
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %3 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %3 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
scf.yield %1 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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)
// -----
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %3 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %3 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
scf.yield %3 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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
// -----
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
%3 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %4 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %4 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
scf.yield %4 : memref<?x?xf32>
}
scf.yield %3 : memref<?x?xf32>
} else {
- %5 = alloc(%arg1, %arg1) : memref<?x?xf32>
+ %5 = memref.alloc(%arg1, %arg1) : memref<?x?xf32>
scf.yield %5 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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
// -----
// CHECK-LABEL: func @inner_region_control_flow
func @inner_region_control_flow(%arg0 : index) -> memref<?x?xf32> {
- %0 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %0 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%1 = test.region_if %0 : memref<?x?xf32> -> (memref<?x?xf32>) then {
^bb0(%arg1 : memref<?x?xf32>):
test.region_if_yield %arg1 : memref<?x?xf32>
return %1 : memref<?x?xf32>
}
-// CHECK: %[[ALLOC0:.*]] = alloc(%arg0, %arg0)
+// CHECK: %[[ALLOC0:.*]] = memref.alloc(%arg0, %arg0)
// CHECK-NEXT: {{.*}} test.region_if
// -----
func @inner_region_control_flow_div(
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
- %0 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %0 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%1 = test.region_if %0 : memref<?x?xf32> -> (memref<?x?xf32>) then {
^bb0(%arg2 : memref<?x?xf32>):
test.region_if_yield %arg2 : memref<?x?xf32>
} else {
^bb0(%arg2 : memref<?x?xf32>):
- %2 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %2 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
test.region_if_yield %2 : memref<?x?xf32>
} join {
^bb0(%arg2 : memref<?x?xf32>):
return %1 : memref<?x?xf32>
}
-// 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
// -----
^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>):
// CHECK-NEXT: cond_br
// CHECK: ^bb2
// CHECK: ^bb2
-// CHECK-NEXT: %[[ALLOCA:.*]] = alloca()
+// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca()
// CHECK-NEXT: test.buffer_based
// -----
%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>),
^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
// -----
^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
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
// -----
%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()
// -----
%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>
return %1 : memref<2xf32>
}
-// CHECK: %[[ALLOC0:.*]] = alloc()
+// CHECK: %[[ALLOC0:.*]] = memref.alloc()
// CHECK-NEXT: {{.*}} scf.for
-// CHECK: %[[ALLOC1:.*]] = alloc()
+// CHECK: %[[ALLOC1:.*]] = memref.alloc()
// -----
%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>
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()
// -----
%arg0: index,
%buf: memref<?xf32>,
%res: memref<?xf32>) {
- %0 = alloc(%arg0) : memref<?xf32>
+ %0 = memref.alloc(%arg0) : memref<?xf32>
%1 = scf.for %i = %lb to %ub step %step
iter_args(%iterBuf = %buf) -> memref<?xf32> {
%2 = scf.for %i2 = %lb to %ub step %step
iter_args(%iterBuf3 = %iterBuf2) -> memref<?xf32> {
%5 = cmpi eq, %i, %ub : index
%6 = scf.if %5 -> (memref<?xf32>) {
- %7 = alloc(%i3) : memref<?xf32>
+ %7 = memref.alloc(%i3) : memref<?xf32>
scf.yield %7 : memref<?xf32>
} else {
scf.yield %iterBuf3 : memref<?xf32>
}
-// 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({{.*}})
^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>):
}
// CHECK-NEXT: cond_br
-// CHECK: %[[ALLOC:.*]] = alloc()
+// CHECK: %[[ALLOC:.*]] = memref.alloc()
// -----
^bb1:
br ^bb3(%arg1 : memref<?xf32>)
^bb2(%0: index):
- %1 = alloc(%0) : memref<?xf32>
+ %1 = memref.alloc(%0) : memref<?xf32>
test.buffer_based in(%arg1: memref<?xf32>) out(%1: memref<?xf32>)
br ^bb3(%1 : memref<?xf32>)
^bb3(%2: memref<?xf32>):
// 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
// -----
^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
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
// -----
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %3 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %3 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
scf.yield %1 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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)
// -----
%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()
// -----
%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>
return %1 : memref<2xf32>
}
-// CHECK: %[[ALLOC0:.*]] = alloc()
+// CHECK: %[[ALLOC0:.*]] = memref.alloc()
// CHECK-NEXT: {{.*}} scf.for
-// CHECK: %[[ALLOC1:.*]] = alloc()
+// CHECK: %[[ALLOC1:.*]] = memref.alloc()
// -----
%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>
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()
// -----
%arg0: index,
%buf: memref<?xf32>,
%res: memref<?xf32>) {
- %0 = alloc(%arg0) : memref<?xf32>
+ %0 = memref.alloc(%arg0) : memref<?xf32>
%1 = scf.for %i = %lb to %ub step %step
iter_args(%iterBuf = %buf) -> memref<?xf32> {
%2 = scf.for %i2 = %lb to %ub step %step
iter_args(%iterBuf2 = %iterBuf) -> memref<?xf32> {
%3 = scf.for %i3 = %lb to %ub step %step
iter_args(%iterBuf3 = %iterBuf2) -> memref<?xf32> {
- %4 = alloc(%i3) : memref<?xf32>
+ %4 = memref.alloc(%i3) : memref<?xf32>
%5 = cmpi eq, %i, %ub : index
%6 = scf.if %5 -> (memref<?xf32>) {
- %7 = alloc(%i3) : memref<?xf32>
+ %7 = memref.alloc(%i3) : memref<?xf32>
scf.yield %7 : memref<?xf32>
} else {
scf.yield %iterBuf3 : memref<?xf32>
}
- %8 = alloc(%i3) : memref<?xf32>
+ %8 = memref.alloc(%i3) : memref<?xf32>
scf.yield %6 : memref<?xf32>
}
scf.yield %3 : memref<?xf32>
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({{.*}})
// -----
%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
// -----
%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>)
}
// CHECK: {{.*}} = scf.for
-// CHECK-NEXT: %[[ALLOC0:.*]] = alloc({{.*}})
+// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc({{.*}})
// -----
%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>
return
}
-// CHECK: %[[ALLOC0:.*]] = alloc({{.*}})
-// CHECK-NEXT: %[[ALLOC1:.*]] = alloc({{.*}})
+// CHECK: %[[ALLOC0:.*]] = memref.alloc({{.*}})
+// CHECK-NEXT: %[[ALLOC1:.*]] = memref.alloc({{.*}})
// CHECK-NEXT: {{.*}} = scf.for
// -----
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>
// CHECK: {{.*}} = scf.for
// CHECK: {{.*}} = scf.if
-// CHECK-NEXT: %[[ALLOC0:.*]] = alloc({{.*}})
+// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc({{.*}})
// -----
%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>
}
// CHECK: {{.*}} = scf.if
-// CHECK-NEXT: %[[ALLOC0:.*]] = alloc({{.*}})
+// CHECK-NEXT: %[[ALLOC0:.*]] = memref.alloc({{.*}})
// CHECK: {{.*}} = scf.for
// -----
%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<?xf32>
+ %2 = memref.alloc(%i) : memref<?xf32>
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({{.*}})
// -----
%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<?xf32>
+ %3 = memref.alloc(%i) : memref<?xf32>
scf.yield %0 : memref<2xf32>
}
scf.yield %0 : memref<2xf32>
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
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
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: }
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: }
cond_br %arg0, ^bb2, ^bb3
^bb2:
- // CHECK: store %{{.*}}, %{{.*}} : memref<i32>
- store %c0_i32, %arg1[] : memref<i32>
+ // CHECK: memref.store %{{.*}}, %{{.*}} : memref<i32>
+ memref.store %c0_i32, %arg1[] : memref<i32>
br ^bb1
^bb3:
- // CHECK: store %{{.*}}, %{{.*}} : memref<i1>
- store %true, %arg2[] : memref<i1>
+ // CHECK: memref.store %{{.*}}, %{{.*}} : memref<i1>
+ memref.store %true, %arg2[] : memref<i1>
br ^bb1
}
// CHECK-LABEL: func @load_dce
func @load_dce(%arg0: index) {
%c4 = constant 4 : index
- %a = alloc(%c4) : memref<?xf32>
+ %a = memref.alloc(%c4) : memref<?xf32>
%2 = load %a[%arg0] : memref<?xf32>
- dealloc %a: memref<?xf32>
+ memref.dealloc %a: memref<?xf32>
// CHECK-NEXT: return
return
}
// 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<?xf32>
+ %0 = memref.cast %arg0 : memref<4xf32> to memref<?xf32>
// CHECK-NEXT: %c0 = constant 0 : index
%c0 = constant 0 : index
%dim = dim %0, %c0 : memref<? x f32>
// CHECK-NEXT: affine.load %arg0[3]
%1 = affine.load %0[%dim - 1] : memref<?xf32>
- // CHECK-NEXT: store %arg1, %arg0[%c0] : memref<4xf32>
- store %arg1, %0[%c0] : memref<?xf32>
+ // CHECK-NEXT: memref.store %arg1, %arg0[%c0] : memref<4xf32>
+ memref.store %arg1, %0[%c0] : memref<?xf32>
// CHECK-NEXT: %{{.*}} = load %arg0[%c0] : memref<4xf32>
%2 = load %0[%c0] : memref<?xf32>
- // CHECK-NEXT: dealloc %arg0 : memref<4xf32>
- dealloc %0: memref<?xf32>
+ // CHECK-NEXT: memref.dealloc %arg0 : memref<4xf32>
+ memref.dealloc %0: memref<?xf32>
// CHECK-NEXT: return %{{.*}}
return %1, %2 : f32, f32
// 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<?x?xf64>
- %4 = memref_cast %0 : memref<42x42xf64> to memref<?x42xf64>
- // CHECK-NOT: memref_cast
- %5 = memref_cast %4 : memref<?x42xf64> to memref<?x?xf64>
+ // CHECK: %[[folded:.*]] = memref.cast %[[ARG0]] : memref<42x42xf64> to memref<?x?xf64>
+ %4 = memref.cast %0 : memref<42x42xf64> to memref<?x42xf64>
+ // CHECK-NOT: memref.cast
+ %5 = memref.cast %4 : memref<?x42xf64> to memref<?x?xf64>
// CHECK: "test.user"(%[[folded]])
"test.user"(%5) : (memref<?x?xf64>) -> ()
return
// 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<?x42xf64>
- %5 = memref_cast %4 : memref<?x42xf64> to memref<42x42xf64>
+ // CHECK-NOT: memref.cast
+ %4 = memref.cast %0 : memref<42x42xf64> to memref<?x42xf64>
+ %5 = memref.cast %4 : memref<?x42xf64> to memref<42x42xf64>
// CHECK: "test.user"(%[[ARG0]])
"test.user"(%5) : (memref<42x42xf64>) -> ()
return
// CHECK-LABEL: func @alloc_const_fold
func @alloc_const_fold() -> memref<?xf32> {
- // CHECK-NEXT: %0 = alloc() : memref<4xf32>
+ // CHECK-NEXT: %0 = memref.alloc() : memref<4xf32>
%c4 = constant 4 : index
- %a = alloc(%c4) : memref<?xf32>
+ %a = memref.alloc(%c4) : memref<?xf32>
- // CHECK-NEXT: %1 = memref_cast %0 : memref<4xf32> to memref<?xf32>
+ // CHECK-NEXT: %1 = memref.cast %0 : memref<4xf32> to memref<?xf32>
// CHECK-NEXT: return %1 : memref<?xf32>
return %a : memref<?xf32>
}
func @dead_alloc_fold() {
// CHECK-NEXT: return
%c4 = constant 4 : index
- %a = alloc(%c4) : memref<?xf32>
+ %a = memref.alloc(%c4) : memref<?xf32>
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
}
%N = constant 1024 : index
%K = constant 512 : index
- // CHECK-NEXT: alloc(%arg0) : memref<?x1024xf32>
- %a = alloc(%L, %N) : memref<? x ? x f32>
+ // CHECK-NEXT: memref.alloc(%arg0) : memref<?x1024xf32>
+ %a = memref.alloc(%L, %N) : memref<? x ? x f32>
- // 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<? x ? x i32>
+ // CHECK-NEXT: memref.alloc() : memref<512x1024xi32>
+ %c = memref.alloc(%K, %N) : memref<? x ? x i32>
- // CHECK: alloc() : memref<9x9xf32>
- %d = alloc(%nine, %nine) : memref<? x ? x f32>
+ // CHECK: memref.alloc() : memref<9x9xf32>
+ %d = memref.alloc(%nine, %nine) : memref<? x ? x f32>
- // 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<?x1024xf32>
- // 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<?x?xf32>
- 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>
}
}
%c0 = constant 0 : index
%c1 = constant 1 : index
%c2 = constant 2 : index
- %0 = alloc(%arg0, %arg1) : memref<?x?xf32>
- %1 = alloc(%arg1, %arg2) : memref<?x8x?xf32>
+ %0 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
+ %1 = memref.alloc(%arg1, %arg2) : memref<?x8x?xf32>
%2 = dim %1, %c2 : memref<?x8x?xf32>
affine.for %arg3 = 0 to %2 {
- %3 = alloc(%arg0) : memref<?xi8>
+ %3 = memref.alloc(%arg0) : memref<?xi8>
%ub = dim %3, %c0 : memref<?xi8>
affine.for %arg4 = 0 to %ub {
%s = dim %0, %c0 : memref<?x?xf32>
- %v = std.view %3[%c0][%arg4, %s] : memref<?xi8> to memref<?x?xf32>
+ %v = memref.view %3[%c0][%arg4, %s] : memref<?xi8> to memref<?x?xf32>
%sv = subview %0[%c0, %c0][%s,%arg4][%c1,%c1] : memref<?x?xf32> to memref<?x?xf32, #map1>
%l = dim %v, %c1 : memref<?x?xf32>
%u = dim %sv, %c0 : memref<?x?xf32, #map1>
// CHECK-NEXT: }
// CHECK-NEXT: }
- %A = view %BUF[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
- %B = view %BUF[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
- %C = view %BUF[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
+ %A = memref.view %BUF[%c0][%M, %K] : memref<?xi8> to memref<?x?xf32>
+ %B = memref.view %BUF[%c0][%K, %N] : memref<?xi8> to memref<?x?xf32>
+ %C = memref.view %BUF[%c0][%M, %N] : memref<?xi8> to memref<?x?xf32>
%M_ = dim %A, %c0 : memref<?x?xf32>
%K_ = dim %A, %c1 : memref<?x?xf32>
// 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
}
%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<?x?xf32>
+ // CHECK: = memref.alloc() : memref<64x32xf32>
+ %Av = memref.alloc(%VT_i_s, %VT_k_l) : memref<?x?xf32>
return %Av : memref<?x?xf32>
}
// CHECK-LABEL: cast_values
func @cast_values(%arg0: memref<?xi32>) -> memref<2xi32> {
// NOP cast
- %1 = memref_cast %arg0 : memref<?xi32> to memref<?xi32>
- // CHECK-NEXT: %[[RET:.*]] = memref_cast %arg0 : memref<?xi32> to memref<2xi32>
- %3 = memref_cast %1 : memref<?xi32> to memref<2xi32>
+ %1 = memref.cast %arg0 : memref<?xi32> to memref<?xi32>
+ // CHECK-NEXT: %[[RET:.*]] = memref.cast %arg0 : memref<?xi32> to memref<2xi32>
+ %3 = memref.cast %1 : memref<?xi32> 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>
}
// 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<?x?xf32>
+ // CHECK: memref.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<7x11xf32>
+ %1 = memref.view %0[%c15][%c7, %c11] : memref<2048xi8> to memref<?x?xf32>
%r0 = load %1[%c0, %c0] : memref<?x?xf32>
// Test: fold one constant size.
- // CHECK: std.view %[[ALLOC_MEM]][%[[C15]]][%arg0, %arg0] : memref<2048xi8> to memref<?x?x7xf32>
- %2 = view %0[%c15][%arg0, %arg0, %c7] : memref<2048xi8> to memref<?x?x?xf32>
+ // CHECK: memref.view %[[ALLOC_MEM]][%[[C15]]][%arg0, %arg0] : memref<2048xi8> to memref<?x?x7xf32>
+ %2 = memref.view %0[%c15][%arg0, %arg0, %c7] : memref<2048xi8> to memref<?x?x?xf32>
%r1 = load %2[%c0, %c0, %c0] : memref<?x?x?xf32>
// 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<?x4xf32>
+ // CHECK: memref.view %[[ALLOC_MEM]][%[[C15]]][] : memref<2048xi8> to memref<7x4xf32>
+ %3 = memref.view %0[%c15][%c7] : memref<2048xi8> to memref<?x4xf32>
%r2 = load %3[%c0, %c0] : memref<?x4xf32>
- // 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<?xi8>
- %5 = view %4[%c15][%c15, %c7] : memref<?xi8> to memref<?x?xf32>
+ // 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<?xi8>
+ %5 = memref.view %4[%c15][%c15, %c7] : memref<?xi8> to memref<?x?xf32>
%r3 = load %5[%c0, %c0] : memref<?x?xf32>
return %r0, %r1, %r2, %r3 : f32, f32, f32, f32
}
// 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
%2 = subview %0[%c0, %arg0, %c0] [%c7, %c11, %c15] [%c1, %c1, %c1]
: memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> to
memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
- store %v0, %2[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
+ memref.store %v0, %2[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
- // CHECK: %[[ALLOC1:.*]] = alloc(%[[ARG0]])
- %3 = alloc(%arg0) : memref<?x16x4xf32, offset : 0, strides : [64, 4, 1]>
+ // CHECK: %[[ALLOC1:.*]] = memref.alloc(%[[ARG0]])
+ %3 = memref.alloc(%arg0) : memref<?x16x4xf32, offset : 0, strides : [64, 4, 1]>
// 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<?x16x4xf32, #[[$BASE_MAP0]]>
%4 = subview %3[%c0, %c0, %c0] [%c7, %c11, %c15] [%c1, %c1, %c1]
: memref<?x16x4xf32, offset : 0, strides : [64, 4, 1]> to
memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
- store %v0, %4[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
+ memref.store %v0, %4[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
// Test: subview offset operands are folded correctly w.r.t. base strides.
// CHECK: subview %[[ALLOC0]][1, 2, 7] [7, 11, 2] [1, 1, 1] :
%5 = subview %0[%c1, %c2, %c7] [%c7, %c11, %c2] [%c1, %c1, %c1]
: memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> to
memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
- store %v0, %5[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
+ memref.store %v0, %5[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
// Test: subview stride operands are folded correctly w.r.t. base strides.
// CHECK: subview %[[ALLOC0]][0, 0, 0] [7, 11, 2] [2, 7, 11] :
%6 = subview %0[%c0, %c0, %c0] [%c7, %c11, %c2] [%c2, %c7, %c11]
: memref<8x16x4xf32, offset : 0, strides : [64, 4, 1]> to
memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
- store %v0, %6[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
+ memref.store %v0, %6[%c0, %c0, %c0] : memref<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
// 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]]] :
%10 = subview %0[%arg0, %arg0, %arg0] [%c7, %c11, %c2] [%arg1, %arg1, %arg1] :
memref<8x16x4xf32, offset:0, strides:[64, 4, 1]> to
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- store %v0, %10[%arg1, %arg1, %arg1] :
+ memref.store %v0, %10[%arg1, %arg1, %arg1] :
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
// Test: subview strides are folded, but offsets and shape are not even if base memref is static
%11 = subview %0[%arg0, %arg0, %arg0] [%arg1, %arg1, %arg1] [%c2, %c7, %c11] :
memref<8x16x4xf32, offset:0, strides:[64, 4, 1]> to
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- store %v0, %11[%arg0, %arg0, %arg0] :
+ memref.store %v0, %11[%arg0, %arg0, %arg0] :
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
// Test: subview offsets are folded, but strides and shape are not even if base memref is static
%13 = subview %0[%c1, %c2, %c7] [%arg1, %arg1, %arg1] [%arg0, %arg0, %arg0] :
memref<8x16x4xf32, offset:0, strides:[64, 4, 1]> to
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- store %v0, %13[%arg1, %arg1, %arg1] :
+ memref.store %v0, %13[%arg1, %arg1, %arg1] :
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- // CHECK: %[[ALLOC2:.*]] = alloc(%[[ARG0]], %[[ARG0]], %[[ARG1]])
- %14 = alloc(%arg0, %arg0, %arg1) : memref<?x?x?xf32>
+ // CHECK: %[[ALLOC2:.*]] = memref.alloc(%[[ARG0]], %[[ARG0]], %[[ARG1]])
+ %14 = memref.alloc(%arg0, %arg0, %arg1) : memref<?x?x?xf32>
// 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<?x?x?xf32> to
%15 = subview %14[%arg0, %arg0, %arg0] [%c7, %c11, %c2] [%arg1, %arg1, %arg1] :
memref<?x?x?xf32> to
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- store %v0, %15[%arg1, %arg1, %arg1] : memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
+ memref.store %v0, %15[%arg1, %arg1, %arg1] : memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
// 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] :
%16 = subview %14[%arg0, %arg0, %arg0] [%arg1, %arg1, %arg1] [%c2, %c2, %c2] :
memref<?x?x?xf32> to
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- store %v0, %16[%arg0, %arg0, %arg0] : memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
+ memref.store %v0, %16[%arg0, %arg0, %arg0] : memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
// 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]]] :
%17 = subview %14[%c1, %c1, %c1] [%arg0, %arg0, %arg0] [%arg1, %arg1, %arg1] :
memref<?x?x?xf32> to
memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- store %v0, %17[%arg0, %arg0, %arg0] : memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
+ memref.store %v0, %17[%arg0, %arg0, %arg0] : memref<?x?x?xf32, offset: ?, strides: [?, ?, ?]>
- // 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
%19 = subview %18[%arg1, %arg1] [%c2, %c4] [1, 1] :
memref<12x4xf32> to
memref<?x?xf32, offset: ?, strides:[4, 1]>
- store %v0, %19[%arg1, %arg1] : memref<?x?xf32, offset: ?, strides:[4, 1]>
+ memref.store %v0, %19[%arg1, %arg1] : memref<?x?xf32, offset: ?, strides:[4, 1]>
// TEST: subview strides and sizes are maintained when offsets are folded
// CHECK: subview %[[ALLOC3]][2, 4] [12, 4] [1, 1] :
%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<?x?x?xf32, offset : ?, strides : [?, ?, ?]>
// CHECK-LABEL: func @memref_cast_folding_subview
func @memref_cast_folding_subview(%arg0: memref<4x5xf32>, %i: index) -> (memref<?x?xf32, offset:? , strides: [?, ?]>) {
- %0 = memref_cast %arg0 : memref<4x5xf32> to memref<?x?xf32>
+ %0 = memref.cast %arg0 : memref<4x5xf32> to memref<?x?xf32>
// CHECK-NEXT: subview %{{.*}}: memref<4x5xf32>
%1 = subview %0[%i, %i][%i, %i][%i, %i]: memref<?x?xf32> to memref<?x?xf32, offset:? , strides: [?, ?]>
// CHECK-NEXT: return %{{.*}}
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<?x?xf32>
+ %0 = memref.cast %V : memref<16x16xf32> to memref<?x?xf32>
%1 = subview %0[0, 0][3, 4][1, 1] : memref<?x?xf32> 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]>
}
// 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<?x?x?xf32>
+func @subtensor(%t: tensor<8x16x4xf32>, %arg0 : index, %arg1 : index)
+ -> tensor<?x?x?xf32>
{
%c0 = constant 0 : index
%c1 = constant 1 : index
%2 = addf %0, %1 : f32
- // CHECK-NEXT: store [[C]], [[ARG]][]
- store %2, %p[] : memref<f32>
+ // CHECK-NEXT: memref.store [[C]], [[ARG]][]
+ memref.store %2, %p[] : memref<f32>
}
}
return
// CHECK-LABEL: func @nested_region_control_flow_div_nested
func @nested_region_control_flow_div_nested(%arg0: index, %arg1: index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
// CHECK: %{{.*}} = scf.if
%2 = scf.if %0 -> (memref<?x?xf32>) {
// CHECK: %[[PERCENT3:.*]] = scf.if
%7 = dim %1, %c0_0 : memref<?x?xf32>
%c1_1 = constant 1 : index
%8 = dim %1, %c1_1 : memref<?x?xf32>
- %9 = alloc(%7, %8) : memref<?x?xf32>
+ %9 = memref.alloc(%7, %8) : memref<?x?xf32>
// CHECK: linalg.copy({{.*}}, %[[PERCENT9:.*]])
linalg.copy(%1, %9) : memref<?x?xf32>, memref<?x?xf32>
// CHECK: scf.yield %[[PERCENT9]]
scf.yield %9 : memref<?x?xf32>
} else {
- // CHECK: %[[PERCENT7:.*]] = alloc
- %7 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ // CHECK: %[[PERCENT7:.*]] = memref.alloc
+ %7 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
%c0_0 = constant 0 : index
%8 = dim %7, %c0_0 : memref<?x?xf32>
%c1_1 = constant 1 : index
%9 = dim %7, %c1_1 : memref<?x?xf32>
- // CHECK-NOT: %{{.*}} = alloc
+ // CHECK-NOT: %{{.*}} = memref.alloc
// CHECK-NOT: linalg.copy(%[[PERCENT7]], %{{.*}})
- // CHECK-NOT: dealloc %[[PERCENT7]]
- %10 = alloc(%8, %9) : memref<?x?xf32>
+ // CHECK-NOT: memref.dealloc %[[PERCENT7]]
+ %10 = memref.alloc(%8, %9) : memref<?x?xf32>
linalg.copy(%7, %10) : memref<?x?xf32>, memref<?x?xf32>
- dealloc %7 : memref<?x?xf32>
+ memref.dealloc %7 : memref<?x?xf32>
// CHECK: scf.yield %[[PERCENT7]]
scf.yield %10 : memref<?x?xf32>
}
%4 = dim %3, %c0 : memref<?x?xf32>
%c1 = constant 1 : index
%5 = dim %3, %c1 : memref<?x?xf32>
- // CHECK-NOT: %{{.*}} = alloc
+ // CHECK-NOT: %{{.*}} = memref.alloc
// CHECK-NOT: linalg.copy(%[[PERCENT3]], %{{.*}})
- // CHECK-NOT: dealloc %[[PERCENT3]]
- %6 = alloc(%4, %5) : memref<?x?xf32>
+ // CHECK-NOT: memref.dealloc %[[PERCENT3]]
+ %6 = memref.alloc(%4, %5) : memref<?x?xf32>
linalg.copy(%3, %6) : memref<?x?xf32>, memref<?x?xf32>
- dealloc %3 : memref<?x?xf32>
+ memref.dealloc %3 : memref<?x?xf32>
// CHECK: scf.yield %[[PERCENT3]]
scf.yield %6 : memref<?x?xf32>
} else {
- // CHECK: %[[PERCENT3:.*]] = alloc
- %3 = alloc(%arg1, %arg1) : memref<?x?xf32>
+ // CHECK: %[[PERCENT3:.*]] = memref.alloc
+ %3 = memref.alloc(%arg1, %arg1) : memref<?x?xf32>
%c0 = constant 0 : index
%4 = dim %3, %c0 : memref<?x?xf32>
%c1 = constant 1 : index
%5 = dim %3, %c1 : memref<?x?xf32>
- // CHECK-NOT: %{{.*}} = alloc
+ // CHECK-NOT: %{{.*}} = memref.alloc
// CHECK-NOT: linalg.copy(%[[PERCENT3]], %{{.*}})
- // CHECK-NOT: dealloc %[[PERCENT3]]
- %6 = alloc(%4, %5) : memref<?x?xf32>
+ // CHECK-NOT: memref.dealloc %[[PERCENT3]]
+ %6 = memref.alloc(%4, %5) : memref<?x?xf32>
linalg.copy(%3, %6) : memref<?x?xf32>, memref<?x?xf32>
- dealloc %3 : memref<?x?xf32>
+ memref.dealloc %3 : memref<?x?xf32>
// CHECK: scf.yield %[[PERCENT3]]
scf.yield %6 : memref<?x?xf32>
}
- dealloc %1 : memref<?x?xf32>
+ memref.dealloc %1 : memref<?x?xf32>
return %2 : memref<?x?xf32>
}
// 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]]
// -----
// 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]]
// -----
// 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>
}
// 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>
}
// 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
// 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],
%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>
}
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>
}
// 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>):
// 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"]}
linalg.yield %tmp2 : f32
}
linalg.copy(%temp, %result) : memref<2xf32>, memref<2xf32>
- dealloc %temp : memref<2xf32>
+ memref.dealloc %temp : memref<2xf32>
// CHECK: return
return
}
// 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"]}
}
// CHECK: linalg.copy
linalg.copy(%temp, %to) : memref<2xf32>, memref<2xf32>
- dealloc %temp : memref<2xf32>
+ memref.dealloc %temp : memref<2xf32>
return
}
// 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
}
// 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>
// 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
}
/// 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>
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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)] )}}
// 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)] )}}
// 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)] )}}
// 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 {
// 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 {
// 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 {
// 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>
// 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
// 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
// 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 {
// 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
// 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 {
// 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 {
}
}
// 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>
// 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
// 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.
// 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>
// 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
// 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
// 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 {
// %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>
// 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 {
// 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 {
%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 {
// 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 {
// 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 {
// 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 {
// 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
// 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 {
// 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>
// 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 {
// 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 {
//
// 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]](%{{.*}}, %{{.*}})
// 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<? x ? x f32>
+ %m = memref.alloc(%M, %N_plus_5) : memref<? x ? x f32>
%c0 = constant 0.0 : f32
%s = constant 5 : index
// 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 {
// 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 {
// 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 {
// 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 {
}
// 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>
// 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
// 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 {
// 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
// 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>
// 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
}
}
// 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>
// 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
}
}
// 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>
// 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 {
}
// 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>
// 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>
}
// 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: }
// 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
// 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]](%{{.*}}, %{{.*}})
// -----
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
// 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
// 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
// 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: }
// 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
// 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
// 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 {
// 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>
// 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
// 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 {
// 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 {
// 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
// -----
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
// -----
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.
// -----
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
#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 {
}
// 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 {
#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)
// 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 {
// -----
func @should_fuse_with_slice_union() {
- %a = alloc() : memref<100xf32>
+ %a = memref.alloc() : memref<100xf32>
%c0 = constant 0 : index
%cf0 = constant 0.0 : f32
// 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 {
// 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 {
// 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 {
// 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>
// 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 {
}
return
}
-// MAXIMAL-NEXT: alloc
+// MAXIMAL-NEXT: memref.alloc
// MAXIMAL-NEXT: affine.for
// MAXIMAL-NEXT: affine.for
// MAXIMAL-NEXT: affine.for
// CHECK-LABEL: func @calc
func @calc(%arg0: memref<?xf32>, %arg1: memref<?xf32>, %arg2: memref<?xf32>, %len: index) {
%c1 = constant 1 : index
- %1 = alloc(%len) : memref<?xf32>
+ %1 = memref.alloc(%len) : memref<?xf32>
affine.for %arg4 = 1 to 10 {
%7 = affine.load %arg0[%arg4] : memref<?xf32>
%8 = affine.load %arg1[%arg4] : memref<?xf32>
}
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{{.*}}
%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>
// 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<f32>
+ %sum = memref.alloc() : memref<f32>
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<f32>
+ memref.store %add, %sum[] : memref<f32>
affine.store %add, %in0[%d] : memref<32xf32>
}
%load_sum = load %sum[] : memref<f32>
%sub = subf %add, %load_sum: f32
affine.store %sub, %in0[%d] : memref<32xf32>
}
- dealloc %sum : memref<f32>
+ memref.dealloc %sum : memref<f32>
return
}
%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>
// 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>
// 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
// 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>
// 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
}
}
- // 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
// -----
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
}
}
- // 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
// -----
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>
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>
// -----
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 {
}
}
- // 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)
// -----
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 {
}
}
- // 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: }
// -----
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 {
}
}
- // CHECK: alloc
+ // CHECK: memref.alloc
// CHECK-NEXT: constant
// CHECK-NEXT: affine.for
// CHECK-NEXT: affine.for
// -----
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 {
}
}
- // CHECK: alloc
+ // CHECK: memref.alloc
// CHECK-NEXT: constant
// CHECK-NEXT: affine.for
// CHECK-NEXT: affine.for
// -----
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 {
}
}
- // CHECK: alloc
+ // CHECK: memref.alloc
// CHECK-NEXT: constant
// CHECK-NEXT: affine.for
// CHECK-NEXT: affine.for
%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 {
}
}
- // 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
%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
%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 {
// 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 {
// 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 {
// 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 {
// 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)
// 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>
// 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)
// 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 {
// 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 {
// 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)
// 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>
// 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) {
// CHECK-LABEL: func @zero_d_memref
func @zero_d_memref() {
- %Z = alloc() : memref<f32>
+ %Z = memref.alloc() : memref<f32>
affine.for %i = 0 to 100 {
affine.load %Z[] : memref<f32>
}
// 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>
%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>
// 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)
// 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]](%{{.*}}, %{{.*}})
// 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 {
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 {
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 {
%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 {
// 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 {
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 {
%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 {
// 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 %{{.*}} {
// 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>
// 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
// 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.
// -----
// 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>
// -----
// 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
// -----
// 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
// -----
// 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>
// -----
// 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>
// -----
// 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}}
// -----
// 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}}
// -----
// 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)
// -----
// 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
// -----
// 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>
// -----
// 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>
// -----
// 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 {
// -----
// 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 {
// -----
// 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 {
// -----
// 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 {
// -----
// 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 {
// -----
// 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)
// -----
// 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)
// -----
// 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 {
// -----
// 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 {
// -----
// 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 {
// -----
// 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 {
// -----
// 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.
// -----
// 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 {
// -----
// 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 {
// -----
// 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)
// -----
// 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 {
// 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 {
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 {
// 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>
// 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)
// 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)
// 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)
// 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) {
// 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 {
// 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 {
// 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 {
// 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 {
// 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
// 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
}
// 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
}
// 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
}
// 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
%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
}
// 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>
}
// 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 {
// 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]+]]
// 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) -> ()
// 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:.*]] =
// 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:.*]] =
// 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>
// 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]+}}>
// 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
}
// 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
// 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>)
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>)
// 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
// 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
"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>
// 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:}
%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>
// 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: }
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 {
// 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 {
// 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 {
// 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
}
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.
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
}
%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 {
// 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: }
%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 {
// 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: }
%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 {
}
// 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
%num_elt = constant 512 : index
%zero = constant 0 : index
- %Av = alloc(%c32, %c32) : memref<? x ? x f32, 2>
- %tag = alloc() : memref<1 x i32>
+ %Av = memref.alloc(%c32, %c32) : memref<? x ? x f32, 2>
+ %tag = memref.alloc() : memref<1 x i32>
// Double buffering for dynamic shaped buffer.
-// CHECK: alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32, 2>
+// CHECK: memref.alloc(%{{.*}}, %{{.*}}) : memref<?x?xf32, 2>
// CHECK-NEXT: %[[C0:.*]] = constant 0 : index
// CHECK-NEXT: dim %{{.*}}, %[[C0]] : memref<?x?xf32, 2>
// CHECK-NEXT: %[[C1:.*]] = constant 1 : index
// CHECK-NEXT: dim %{{.*}}, %[[C1]] : memref<?x?xf32, 2>
-// 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 :
memref<? x ? x f32, 2>, memref<1 x i32>
affine.dma_wait %tag[%zero], %num_elt : memref<1 x i32>
}
- dealloc %Av : memref<? x ? x f32, 2>
+ memref.dealloc %Av : memref<? x ? x f32, 2>
return
// CHECK-NEXT: affine.for %{{.*}} = 1 to 16 {
// CHECK: affine.dma_start %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}}[%{{.*}} mod 2, 0, 0], %{{.*}}[%{{.*}} mod 2, 0], %{{.*}}
// 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
%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.
^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>):
// CHECK-NEXT: cond_br {{.*}}
// CHECK: ^bb2
-// CHECK-NEXT: %[[ALLOCA:.*]] = alloca()
+// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca()
// CHECK: test.copy
// CHECK-NEXT: return
^bb1:
br ^bb3(%arg1 : memref<?xf32>)
^bb2(%0: index):
- %1 = alloc(%0) : memref<?xf32>
+ %1 = memref.alloc(%0) : memref<?xf32>
test.buffer_based in(%arg1: memref<?xf32>) out(%1: memref<?xf32>)
br ^bb3(%1 : memref<?xf32>)
^bb3(%2: memref<?xf32>):
// 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:.*]]:{{.*}})
// CHECK-LABEL: func @dynamicRanked
func @dynamicRanked(%tensor: tensor<*xf32>) {
%0 = rank %tensor : tensor<*xf32>
- %1 = alloc(%0) : memref<?xindex>
+ %1 = memref.alloc(%0) : memref<?xindex>
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<?x?xindex>
+ %1 = memref.alloc(%0, %0) : memref<?x?xindex>
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<?xindex>
+ %0 = memref.alloc(%arg0) : memref<?xindex>
return
}
-// CHECK-NEXT: %[[ALLOC:.*]] = alloc
+// CHECK-NEXT: %[[ALLOC:.*]] = memref.alloc
// -----
// 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
// -----
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>):
// CHECK-NEXT: cond_br {{.*}}
// CHECK: ^bb1
-// CHECK-NEXT: %[[ALLOCA:.*]] = alloca()
+// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca()
// CHECK: test.copy
// CHECK-NEXT: return
// 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:
return
}
-// CHECK-NEXT: %[[ALLOCA:.*]] = alloca()
+// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca()
// CHECK: cond_br
// CHECK: test.copy
// CHECK-NEXT: return
// 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>),
^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
// 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>),
return
}
-// CHECK-NEXT: %[[ALLOCA:.*]] = alloca()
+// CHECK-NEXT: %[[ALLOCA:.*]] = memref.alloca()
// CHECK: return
// -----
// 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>),
^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
// 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
%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>):
// 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
^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
// 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()
// -----
%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]]
%arg0 : index,
%arg1 : index) -> memref<?x?xf32> {
%0 = cmpi eq, %arg0, %arg1 : index
- %1 = alloc(%arg0, %arg0) : memref<?x?xf32>
+ %1 = memref.alloc(%arg0, %arg0) : memref<?x?xf32>
%2 = scf.if %0 -> (memref<?x?xf32>) {
scf.yield %1 : memref<?x?xf32>
} else {
- %3 = alloc(%arg0, %arg1) : memref<?x?xf32>
+ %3 = memref.alloc(%arg0, %arg1) : memref<?x?xf32>
scf.yield %1 : memref<?x?xf32>
}
return %2 : memref<?x?xf32>
}
-// 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]]
// 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>
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]]
%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()
// -----
%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
return
}
-// CHECK: %[[ALLOCA0:.*]] = alloca()
+// CHECK: %[[ALLOCA0:.*]] = memref.alloca()
// CHECK-NEXT: %[[ALLOCA1:.*]] = scf.for {{.*}} iter_args(%[[IALLOCA:.*]] =
// CHECK: %[[ALLOCA2:.*]] = scf.if
// CHECK: scf.yield %[[ALLOCA0]]
%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>
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]]
// 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
// -----
// 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
OperationFolder *folder) {
SmallVector<int64_t, 4> shape(boundingSubViewSize.size(), -1);
return b
- .create<AllocOp>(subView.getLoc(),
- MemRefType::get(shape,
- subView.getType().getElementType(),
- /*affineMapComposition =*/{}, 3),
- boundingSubViewSize)
+ .create<memref::AllocOp>(
+ subView.getLoc(),
+ MemRefType::get(shape, subView.getType().getElementType(),
+ /*affineMapComposition =*/{}, 3),
+ boundingSubViewSize)
.getResult();
}
// Deallocation callback
static LogicalResult deallocCallBackFn(OpBuilder &b, Value buffer) {
- b.create<DeallocOp>(buffer.getLoc(), buffer);
+ b.create<memref::DeallocOp>(buffer.getLoc(), buffer);
return success();
}
//
//===----------------------------------------------------------------------===//
+#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Pass/Pass.h"
/// 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<MemRefType>();
int64_t offset;
SmallVector<int64_t, 4> strides;
#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"
type.getNumElements() % multiplicity != 0)
return mlir::WalkResult::advance();
auto filterAlloc = [](Operation *op) {
- if (isa<ConstantOp, AllocOp, CallOp>(op))
+ if (isa<ConstantOp, memref::AllocOp, CallOp>(op))
return false;
return true;
};
// Memref allocated inside async.execute region.
// ------------------------------------------------------------------------ //
%token2, %result2 = async.execute[%token0] -> !async.value<memref<f32>> {
- %5 = alloc() : memref<f32>
+ %5 = memref.alloc() : memref<f32>
%c0 = constant 0.25 : f32
- store %c0, %5[]: memref<f32>
+ memref.store %c0, %5[]: memref<f32>
async.yield %5 : memref<f32>
}
%6 = async.await %result2 : !async.value<memref<f32>>
- %7 = memref_cast %6 : memref<f32> to memref<*xf32>
+ %7 = memref.cast %6 : memref<f32> to memref<*xf32>
// CHECK: Unranked Memref
// CHECK-SAME: rank = 0 offset = 0 sizes = [] strides = []
%token3 = async.execute(%result2 as %unwrapped : !async.value<memref<f32>>) {
%8 = load %unwrapped[]: memref<f32>
%9 = addf %8, %8 : f32
- store %9, %unwrapped[]: memref<f32>
+ memref.store %9, %unwrapped[]: memref<f32>
async.yield
}
async.await %token3 : !async.token
// CHECK-NEXT: [0.5]
call @print_memref_f32(%7): (memref<*xf32>) -> ()
- dealloc %6 : memref<f32>
+ memref.dealloc %6 : memref<f32>
return
}
%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>) -> ()
%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>) -> ()
// 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>) -> ()
call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
call @print_memref_f32(%U): (memref<*xf32>) -> ()
- dealloc %A : memref<4xf32>
+ memref.dealloc %A : memref<4xf32>
return
}
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
%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>) -> ()
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
}
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]
%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]
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]
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]
%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]
return
}
-global_memref @gv3 : memref<i32> = dense<11>
+memref.global @gv3 : memref<i32> = dense<11>
func @testScalarMemref() {
- %0 = get_global_memref @gv3 : memref<i32>
- %U = memref_cast %0 : memref<i32> to memref<*xi32>
+ %0 = memref.get_global @gv3 : memref<i32>
+ %U = memref.cast %0 : memref<i32> to memref<*xi32>
// CHECK: rank = 0
// CHECK: offset = 0
// CHECK: sizes = []
%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) {
%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]
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 =
offset: [%c0], sizes: [%c1, %c6], strides: [%c6, %c1]
: memref<2x3xf32> to memref<?x?xf32, offset: ?, strides: [?, ?]>
- %unranked_output = memref_cast %output
+ %unranked_output = memref.cast %output
: memref<?x?xf32, offset: ?, strides: [?, ?]> to memref<*xf32>
call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> ()
// CHECK: rank = 2 offset = 0 sizes = [1, 6] strides = [6, 1] data =
}
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 =
}
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
offset: [%c0], sizes: [%c1, %c6], strides: [%c6, %c1]
: memref<*xf32> to memref<?x?xf32, offset: ?, strides: [?, ?]>
- %unranked_output = memref_cast %output
+ %unranked_output = memref.cast %output
: memref<?x?xf32, offset: ?, strides: [?, ?]> to memref<*xf32>
call @print_memref_f32(%unranked_output) : (memref<*xf32>) -> ()
// CHECK: rank = 2 offset = 0 sizes = [1, 6] strides = [6, 1] data =
%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) {
%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)
%output = memref_reshape %input(%shape)
: (memref<2x3xf32>, memref<2xindex>) -> memref<?x?xf32>
- %unranked_output = memref_cast %output : memref<?x?xf32> to memref<*xf32>
+ %unranked_output = memref.cast %output : memref<?x?xf32> 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],
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<?x?xf32>
- %unranked_output = memref_cast %output : memref<?x?xf32> to memref<*xf32>
+ %unranked_output = memref.cast %output : memref<?x?xf32> 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],
func @reshape_ranked_memref_to_unranked(%input : memref<2x3xf32>,
%shape : memref<2xindex>) {
- %dyn_size_shape = memref_cast %shape : memref<2xindex> to memref<?xindex>
+ %dyn_size_shape = memref.cast %shape : memref<2xindex> to memref<?xindex>
%output = memref_reshape %input(%dyn_size_shape)
: (memref<2x3xf32>, memref<?xindex>) -> memref<*xf32>
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<?xindex>
+ %unranked_input = memref.cast %input : memref<2x3xf32> to memref<*xf32>
+ %dyn_size_shape = memref.cast %shape : memref<2xindex> to memref<?xindex>
%output = memref_reshape %input(%dyn_size_shape)
: (memref<2x3xf32>, memref<?xindex>) -> memref<*xf32>
// 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
%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 {
}
%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
// 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<?x?xf32>
+ %V = memref.cast %A : memref<10x3xf32, 0> to memref<?x?xf32>
linalg.fill(%V, %f10) : memref<?x?xf32, 0>, 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<?x?xf32>
+ %V2 = memref.cast %U : memref<*xf32> to memref<?x?xf32>
linalg.fill(%V2, %f5) : memref<?x?xf32, 0>, f32
- %U2 = memref_cast %V2 : memref<?x?xf32, 0> to memref<*xf32>
+ %U2 = memref.cast %V2 : memref<?x?xf32, 0> to memref<*xf32>
call @print_memref_f32(%U2) : (memref<*xf32>) -> ()
- %V3 = memref_cast %V2 : memref<?x?xf32> to memref<*xf32>
- %V4 = memref_cast %V3 : memref<*xf32> to memref<?x?xf32>
+ %V3 = memref.cast %V2 : memref<?x?xf32> to memref<*xf32>
+ %V4 = memref.cast %V3 : memref<*xf32> to memref<?x?xf32>
linalg.fill(%V4, %f2) : memref<?x?xf32, 0>, f32
- %U3 = memref_cast %V2 : memref<?x?xf32> to memref<*xf32>
+ %U3 = memref.cast %V2 : memref<?x?xf32> to memref<*xf32>
call @print_memref_f32(%U3) : (memref<*xf32>) -> ()
// 122 is ASCII for 'z'.
%i8_z = constant 122 : i8
- %I8 = alloc() : memref<i8>
- store %i8_z, %I8[]: memref<i8>
- %U4 = memref_cast %I8 : memref<i8> to memref<*xi8>
+ %I8 = memref.alloc() : memref<i8>
+ memref.store %i8_z, %I8[]: memref<i8>
+ %U4 = memref.cast %I8 : memref<i8> 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() : () -> ()
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>)
}
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>
}
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>
}
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>
func @print_0d() {
%f = constant 2.00000e+00 : f32
- %A = alloc() : memref<f32>
- store %f, %A[]: memref<f32>
- %U = memref_cast %A : memref<f32> to memref<*xf32>
+ %A = memref.alloc() : memref<f32>
+ memref.store %f, %A[]: memref<f32>
+ %U = memref.cast %A : memref<f32> to memref<*xf32>
call @print_memref_f32(%U): (memref<*xf32>) -> ()
- dealloc %A : memref<f32>
+ memref.dealloc %A : memref<f32>
return
}
// PRINT-0D: Unranked Memref base@ = {{.*}} rank = 0 offset = 0 sizes = [] strides = [] data =
func @print_1d() {
%f = constant 2.00000e+00 : f32
- %A = alloc() : memref<16xf32>
- %B = memref_cast %A: memref<16xf32> to memref<?xf32>
+ %A = memref.alloc() : memref<16xf32>
+ %B = memref.cast %A: memref<16xf32> to memref<?xf32>
linalg.fill(%B, %f) : memref<?xf32>, f32
- %U = memref_cast %B : memref<?xf32> to memref<*xf32>
+ %U = memref.cast %B : memref<?xf32> 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 =
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<?x?x?xf32>
+ %A = memref.alloc() : memref<3x4x5xf32>
+ %B = memref.cast %A: memref<3x4x5xf32> to memref<?x?x?xf32>
linalg.fill(%B, %f) : memref<?x?x?xf32>, f32
%c2 = constant 2 : index
- store %f4, %B[%c2, %c2, %c2]: memref<?x?x?xf32>
- %U = memref_cast %B : memref<?x?x?xf32> to memref<*xf32>
+ memref.store %f4, %B[%c2, %c2, %c2]: memref<?x?x?xf32>
+ %U = memref.cast %B : memref<?x?x?xf32> 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 =
%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<?x?x!vector_type_C>
+ %CC = memref.cast %C: !matrix_type_CC to memref<?x?x!vector_type_C>
call @print_memref_vector_4x4xf32(%CC): (memref<?x?x!vector_type_C>) -> ()
- dealloc %C : !matrix_type_CC
+ memref.dealloc %C : !matrix_type_CC
return
}
// CHECK-NEXT: llvm_arm_sve
// CHECK-NEXT: llvm_avx512
// CHECK-NEXT: math
+// CHECK-NEXT: memref
// CHECK-NEXT: nvvm
// CHECK-NEXT: omp
// CHECK-NEXT: pdl
// 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() {
^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>) -> ()
^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
std::string moduleStr = R"mlir(
func @zero_ranked(%arg0 : memref<f32>) attributes { llvm.emit_c_interface } {
%cst42 = constant 42.0 : f32
- store %cst42, %arg0[] : memref<f32>
+ memref.store %cst42, %arg0[] : memref<f32>
return
}
)mlir";
func @one_ranked(%arg0 : memref<?xf32>) attributes { llvm.emit_c_interface } {
%cst42 = constant 42.0 : f32
%cst5 = constant 5 : index
- store %cst42, %arg0[%cst5] : memref<?xf32>
+ memref.store %cst42, %arg0[%cst5] : memref<?xf32>
return
}
)mlir";
%x = constant 2 : index
%y = constant 1 : index
%cst42 = constant 42.0 : f32
- store %cst42, %arg0[%y, %x] : memref<?x?xf32>
- store %cst42, %arg1[%x, %y] : memref<?x?xf32>
+ memref.store %cst42, %arg0[%y, %x] : memref<?x?xf32>
+ memref.store %cst42, %arg1[%x, %y] : memref<?x?xf32>
return
}
)mlir";
elt = count++;
std::string moduleStr = R"mlir(
- func private @callback(%arg0: memref<?x?xf32>, %coefficient: i32) attributes { llvm.emit_c_interface }
+ func private @callback(%arg0: memref<?x?xf32>, %coefficient: i32) attributes { llvm.emit_c_interface }
func @caller_for_callback(%arg0: memref<?x?xf32>, %coefficient: i32) attributes { llvm.emit_c_interface } {
- %unranked = memref_cast %arg0: memref<?x?xf32> to memref<*xf32>
+ %unranked = memref.cast %arg0: memref<?x?xf32> to memref<*xf32>
call @callback(%arg0, %coefficient) : (memref<?x?xf32>, i32) -> ()
return
}