Skip to content

Commit 0489cfe

Browse files
Revert "[RandomIRBuilder] Remove use of getNonOpaquePointerElementType() (NFC)"
This reverts commit afdb83b. This was landed with a bad description.
1 parent 305ad9a commit 0489cfe

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

mlir/include/mlir/Dialect/MemRef/IR/MemRef.h

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
#ifndef MLIR_DIALECT_MEMREF_IR_MEMREF_H_
1010
#define MLIR_DIALECT_MEMREF_IR_MEMREF_H_
1111

12+
#include "mlir/Bytecode/BytecodeOpInterface.h"
1213
#include "mlir/Dialect/Arith/IR/Arith.h"
13-
#include "mlir/Dialect/MemRef/Utils/MemRefUtils.h"
1414
#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
15+
#include "mlir/IR/Dialect.h"
1516
#include "mlir/Interfaces/CallInterfaces.h"
17+
#include "mlir/Interfaces/CastInterfaces.h"
1618
#include "mlir/Interfaces/ControlFlowInterfaces.h"
1719
#include "mlir/Interfaces/CopyOpInterface.h"
1820
#include "mlir/Interfaces/InferTypeOpInterface.h"
@@ -30,6 +32,48 @@ enum class AtomicRMWKind : uint64_t;
3032
class AtomicRMWKindAttr;
3133
} // namespace arith
3234

35+
class Location;
36+
class OpBuilder;
37+
38+
raw_ostream &operator<<(raw_ostream &os, const Range &range);
39+
40+
/// Return the list of Range (i.e. offset, size, stride). Each Range
41+
/// entry contains either the dynamic value or a ConstantIndexOp constructed
42+
/// with `b` at location `loc`.
43+
SmallVector<Range, 8> getOrCreateRanges(OffsetSizeAndStrideOpInterface op,
44+
OpBuilder &b, Location loc);
45+
46+
namespace memref {
47+
48+
/// This is a common utility used for patterns of the form
49+
/// "someop(memref.cast) -> someop". It folds the source of any memref.cast
50+
/// into the root operation directly.
51+
LogicalResult foldMemRefCast(Operation *op, Value inner = nullptr);
52+
53+
/// Return an unranked/ranked tensor type for the given unranked/ranked memref
54+
/// type.
55+
Type getTensorTypeFromMemRefType(Type type);
56+
57+
/// Finds a single dealloc operation for the given allocated value. If there
58+
/// are > 1 deallocates for `allocValue`, returns std::nullopt, else returns the
59+
/// single deallocate if it exists or nullptr.
60+
std::optional<Operation *> findDealloc(Value allocValue);
61+
62+
/// Return the dimension of the given memref value.
63+
OpFoldResult getMixedSize(OpBuilder &builder, Location loc, Value value,
64+
int64_t dim);
65+
66+
/// Return the dimensions of the given memref value.
67+
SmallVector<OpFoldResult> getMixedSizes(OpBuilder &builder, Location loc,
68+
Value value);
69+
70+
/// Create a rank-reducing SubViewOp @[0 .. 0] with strides [1 .. 1] and
71+
/// appropriate sizes (i.e. `memref.getSizes()`) to reduce the rank of `memref`
72+
/// to that of `targetShape`.
73+
Value createCanonicalRankReducingSubViewOp(OpBuilder &b, Location loc,
74+
Value memref,
75+
ArrayRef<int64_t> targetShape);
76+
} // namespace memref
3377
} // namespace mlir
3478

3579
//===----------------------------------------------------------------------===//

mlir/include/mlir/Dialect/MemRef/Utils/MemRefUtils.h

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,55 +16,13 @@
1616
#ifndef MLIR_DIALECT_MEMREF_UTILS_MEMREFUTILS_H
1717
#define MLIR_DIALECT_MEMREF_UTILS_MEMREFUTILS_H
1818

19-
#include "mlir/Interfaces/ViewLikeInterface.h"
20-
#include "mlir/Support/LogicalResult.h"
19+
#include "mlir/Dialect/MemRef/IR/MemRef.h"
2120

2221
namespace mlir {
2322

24-
class Location;
2523
class MemRefType;
26-
class OpBuilder;
27-
class Operation;
28-
29-
llvm::raw_ostream &operator<<(raw_ostream &os, const Range &range);
30-
31-
/// Return the list of Range (i.e. offset, size, stride). Each Range
32-
/// entry contains either the dynamic value or a ConstantIndexOp constructed
33-
/// with `b` at location `loc`.
34-
SmallVector<Range, 8> getOrCreateRanges(OffsetSizeAndStrideOpInterface op,
35-
OpBuilder &b, Location loc);
3624

3725
namespace memref {
38-
class ExtractStridedMetadataOp;
39-
40-
/// This is a common utility used for patterns of the form
41-
/// "someop(memref.cast) -> someop". It folds the source of any memref.cast
42-
/// into the root operation directly.
43-
LogicalResult foldMemRefCast(Operation *op, Value inner = nullptr);
44-
45-
/// Return an unranked/ranked tensor type for the given unranked/ranked memref
46-
/// type.
47-
Type getTensorTypeFromMemRefType(Type type);
48-
49-
/// Finds a single dealloc operation for the given allocated value. If there
50-
/// are > 1 deallocates for `allocValue`, returns std::nullopt, else returns
51-
/// the single deallocate if it exists or nullptr.
52-
std::optional<Operation *> findDealloc(Value allocValue);
53-
54-
/// Return the dimension of the given memref value.
55-
OpFoldResult getMixedSize(OpBuilder &builder, Location loc, Value value,
56-
int64_t dim);
57-
58-
/// Return the dimensions of the given memref value.
59-
SmallVector<OpFoldResult> getMixedSizes(OpBuilder &builder, Location loc,
60-
Value value);
61-
62-
/// Create a rank-reducing SubViewOp @[0 .. 0] with strides [1 .. 1] and
63-
/// appropriate sizes (i.e. `memref.getSizes()`) to reduce the rank of
64-
/// `memref` to that of `targetShape`.
65-
Value createCanonicalRankReducingSubViewOp(OpBuilder &b, Location loc,
66-
Value memref,
67-
ArrayRef<int64_t> targetShape);
6826

6927
/// Returns true, if the memref type has static shapes and represents a
7028
/// contiguous chunk of memory.

0 commit comments

Comments
 (0)