MLIR 22.0.0git
MemRef.h
Go to the documentation of this file.
1//===- MemRef.h - MemRef dialect --------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef MLIR_DIALECT_MEMREF_IR_MEMREF_H_
10#define MLIR_DIALECT_MEMREF_IR_MEMREF_H_
11
15#include "mlir/IR/Dialect.h"
28
29#include <optional>
30
31namespace mlir {
32
33namespace arith {
34enum class AtomicRMWKind : uint64_t;
35class AtomicRMWKindAttr;
36} // namespace arith
37
38class Location;
39class OpBuilder;
40
41raw_ostream &operator<<(raw_ostream &os, const Range &range);
42
43/// Return the list of Range (i.e. offset, size, stride). Each Range
44/// entry contains either the dynamic value or a ConstantIndexOp constructed
45/// with `b` at location `loc`.
46SmallVector<Range, 8> getOrCreateRanges(OffsetSizeAndStrideOpInterface op,
47 OpBuilder &b, Location loc);
48
49namespace memref {
50
51/// This is a common utility used for patterns of the form
52/// "someop(memref.cast) -> someop". It folds the source of any memref.cast
53/// into the root operation directly.
54LogicalResult foldMemRefCast(Operation *op, Value inner = nullptr);
55
56/// Return an unranked/ranked tensor type for the given unranked/ranked memref
57/// type.
58Type getTensorTypeFromMemRefType(Type type);
59
60/// Finds a single dealloc operation for the given allocated value. If there
61/// are > 1 deallocates for `allocValue`, returns std::nullopt, else returns the
62/// single deallocate if it exists or nullptr.
63std::optional<Operation *> findDealloc(Value allocValue);
64
65/// Return the dimension of the given memref value.
66OpFoldResult getMixedSize(OpBuilder &builder, Location loc, Value value,
67 int64_t dim);
68
69/// Return the dimensions of the given memref value.
70SmallVector<OpFoldResult> getMixedSizes(OpBuilder &builder, Location loc,
71 Value value);
72
73/// Create a rank-reducing SubViewOp @[0 .. 0] with strides [1 .. 1] and
74/// appropriate sizes (i.e. `memref.getSizes()`) to reduce the rank of `memref`
75/// to that of `targetShape`.
76Value createCanonicalRankReducingSubViewOp(OpBuilder &b, Location loc,
77 Value memref,
78 ArrayRef<int64_t> targetShape);
79} // namespace memref
80} // namespace mlir
81
82//===----------------------------------------------------------------------===//
83// MemRef Dialect
84//===----------------------------------------------------------------------===//
85
86#include "mlir/Dialect/MemRef/IR/MemRefOpsDialect.h.inc"
87
88//===----------------------------------------------------------------------===//
89// MemRef Dialect Operations
90//===----------------------------------------------------------------------===//
91
92#define GET_OP_CLASSES
93#include "mlir/Dialect/MemRef/IR/MemRefOps.h.inc"
94
95#endif // MLIR_DIALECT_MEMREF_IR_MEMREF_H_
b
Return true if permutation is a valid permutation of the outer_dims_perm (case OuterOrInnerPerm::Oute...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
This class helps build Operations.
Definition Builders.h:207
Type getTensorTypeFromMemRefType(Type type)
Return an unranked/ranked tensor type for the given unranked/ranked memref type.
Definition MemRefOps.cpp:60
OpFoldResult getMixedSize(OpBuilder &builder, Location loc, Value value, int64_t dim)
Return the dimension of the given memref value.
Definition MemRefOps.cpp:68
std::optional< Operation * > findDealloc(Value allocValue)
Finds a single dealloc operation for the given allocated value.
LogicalResult foldMemRefCast(Operation *op, Value inner=nullptr)
This is a common utility used for patterns of the form "someop(memref.cast) -> someop".
Definition MemRefOps.cpp:45
SmallVector< OpFoldResult > getMixedSizes(OpBuilder &builder, Location loc, Value value)
Return the dimensions of the given memref value.
Definition MemRefOps.cpp:77
Value createCanonicalRankReducingSubViewOp(OpBuilder &b, Location loc, Value memref, ArrayRef< int64_t > targetShape)
Create a rank-reducing SubViewOp @[0 .
Include the generated interface declarations.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
SmallVector< Range, 8 > getOrCreateRanges(OffsetSizeAndStrideOpInterface op, OpBuilder &b, Location loc)
Return the list of Range (i.e.
Represents a range (offset, size, and stride) where each element of the triple may be dynamic or stat...