Skip to content

Commit 59fd287

Browse files
[mlir][memref] Clean up load/store documentation (#130569)
Remove references to the Affine dialect. The documentation is outdated. Separate `affine.load/store` ops have been added. Also add documentation for `nontemporal`.
1 parent cb28ec6 commit 59fd287

File tree

1 file changed

+21
-50
lines changed

1 file changed

+21
-50
lines changed

mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,40 +1184,23 @@ def LoadOp : MemRef_Op<"load",
11841184
DeclareOpInterfaceMethods<DestructurableAccessorOpInterface>]> {
11851185
let summary = "load operation";
11861186
let description = [{
1187-
The `load` op reads an element from a memref specified by an index list. The
1188-
output of load is a new value with the same type as the elements of the
1189-
memref. The arity of indices is the rank of the memref (i.e., if the memref
1190-
loaded from is of rank 3, then 3 indices are required for the load following
1191-
the memref identifier).
1192-
1193-
In an `affine.if` or `affine.for` body, the indices of a load are restricted
1194-
to SSA values bound to surrounding loop induction variables,
1195-
[symbols](Affine.md/#dimensions-and-symbols), results of a
1196-
constant operations, or the result of an
1197-
`affine.apply` operation that can in turn take as arguments all of the
1198-
aforementioned SSA values or the recursively result of such an
1199-
`affine.apply` operation.
1187+
The `load` op reads an element from a memref at the specified indices.
1188+
1189+
The number of indices must match the rank of the memref. The indices must
1190+
be in-bounds: `0 <= idx < dim_size`
1191+
1192+
The single result of `memref.load` is a value with the same type as the
1193+
element type of the memref.
1194+
1195+
A set `nontemporal` attribute indicates that this load is not expected to
1196+
be reused in the cache. For details, refer to the
1197+
[https://llvm.org/docs/LangRef.html#load-instruction](LLVM load instruction).
12001198

12011199
Example:
12021200

12031201
```mlir
1204-
%1 = affine.apply affine_map<(d0, d1) -> (3*d0)> (%i, %j)
1205-
%2 = affine.apply affine_map<(d0, d1) -> (d1+1)> (%i, %j)
1206-
%12 = memref.load %A[%1, %2] : memref<8x?xi32, #layout, memspace0>
1207-
1208-
// Example of an indirect load (treated as non-affine)
1209-
%3 = affine.apply affine_map<(d0) -> (2*d0 + 1)>(%12)
1210-
%13 = memref.load %A[%3, %2] : memref<4x?xi32, #layout, memspace0>
1202+
%0 = memref.load %A[%a, %b] : memref<8x?xi32, #layout, memspace0>
12111203
```
1212-
1213-
**Context:** The `load` and `store` operations are specifically crafted to
1214-
fully resolve a reference to an element of a memref, and (in affine
1215-
`affine.if` and `affine.for` operations) the compiler can follow use-def
1216-
chains (e.g. through [`affine.apply`](Affine.md/#affineapply-affineapplyop)
1217-
operations) to precisely analyze references at compile-time using polyhedral
1218-
techniques. This is possible because of the
1219-
[restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols)
1220-
in these contexts.
12211204
}];
12221205

12231206
let arguments = (ins Arg<AnyMemRef, "the reference to load from",
@@ -1817,32 +1800,20 @@ def MemRef_StoreOp : MemRef_Op<"store",
18171800
DeclareOpInterfaceMethods<DestructurableAccessorOpInterface>]> {
18181801
let summary = "store operation";
18191802
let description = [{
1820-
Store a value to a memref location given by indices. The value stored should
1821-
have the same type as the elemental type of the memref. The number of
1822-
arguments provided within brackets need to match the rank of the memref.
1823-
1824-
In an affine context, the indices of a store are restricted to SSA values
1825-
bound to surrounding loop induction variables,
1826-
[symbols](Affine.md/#restrictions-on-dimensions-and-symbols), results of a
1827-
`constant` operation, or the result of an
1828-
[`affine.apply`](Affine.md/#affineapply-affineapplyop) operation that can in
1829-
turn take as arguments all of the aforementioned SSA values or the
1830-
recursively result of such an `affine.apply` operation.
1803+
The `store` op stores an element into a memref at the specified indices.
1804+
1805+
The number of indices must match the rank of the memref. The indices must
1806+
be in-bounds: `0 <= idx < dim_size`
1807+
1808+
A set `nontemporal` attribute indicates that this store is not expected to
1809+
be reused in the cache. For details, refer to the
1810+
[https://llvm.org/docs/LangRef.html#store-instruction](LLVM store instruction).
18311811

18321812
Example:
18331813

18341814
```mlir
1835-
memref.store %100, %A[%1, 1023] : memref<4x?xf32, #layout, memspace0>
1815+
memref.store %val, %A[%a, %b] : memref<8x?xi32, #layout, memspace0>
18361816
```
1837-
1838-
**Context:** The `load` and `store` operations are specifically crafted to
1839-
fully resolve a reference to an element of a memref, and (in polyhedral
1840-
`affine.if` and `affine.for` operations) the compiler can follow use-def
1841-
chains (e.g. through [`affine.apply`](Affine.md/#affineapply-affineapplyop)
1842-
operations) to precisely analyze references at compile-time using polyhedral
1843-
techniques. This is possible because of the
1844-
[restrictions on dimensions and symbols](Affine.md/#restrictions-on-dimensions-and-symbols)
1845-
in these contexts.
18461817
}];
18471818

18481819
let arguments = (ins AnyType:$value,

0 commit comments

Comments
 (0)