Skip to content

Commit 6c02922

Browse files
committed
Review feedback, add example
1 parent 72f3fce commit 6c02922

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

llvm/docs/AMDGPUUsage.rst

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,13 +1016,13 @@ supported for the ``amdgcn`` target.
10161016
`ptr addrspace(7)` directly, which produces a buffer fat pointer with an initial
10171017
offset of 0 and prevents the address space cast from being rewritten away.
10181018

1019-
The `align` attribute on operations from buffer fat pointers is deemed to apply
1020-
to all componenents of the pointer - that is, an `align 4` load is expected to
1021-
both have the offset be a multiple of 4 and to have a base pointer whose an
1019+
The ``align`` attribute on operations from buffer fat pointers is deemed to apply
1020+
to all componenents of the pointer - that is, an ``align 4`` load is expected to
1021+
both have the offset be a multiple of 4 and to have a base pointer with an
10221022
alignment of 4.
10231023

10241024
(This componentwise definition of alignment is needed to allow for promotion of
1025-
aligned loads to `s_buffer_load`, which requires that both the base pointer and
1025+
aligned loads to ``s_buffer_load``, which requires that both the base pointer and
10261026
offset be appropriately aligned.)
10271027

10281028
**Buffer Resource**
@@ -1048,17 +1048,23 @@ supported for the ``amdgcn`` target.
10481048
(bits `127:96`). The specific interpretation of these fields varies by the
10491049
target architecture and is detailed in the ISA descriptions.
10501050

1051-
When buffer resourcess are passed to buffer intrinsics such as `raw.ptr.buffer.load`
1052-
or `struct.ptr.buffer.store`, the `align` attribute on the pointer is assumed to
1053-
apply to both the offset and the base pointer value. That is, `align 8` means that
1054-
both the base address within the `ptr addrspace(8)` and the `offset` argument
1055-
have their three lowesst bits set to 0. If the stride of the resource is nonzero,
1056-
the stride must be a multiple of the given alignment.
1057-
1058-
In other words, the `align` attribute specifies the alignemnt of the effective
1059-
address being loaded from/stored to *and* acts as a guuarantee that this is
1051+
When buffer resources are passed to buffer intrinsics such as
1052+
``llvm.amdgcn.raw.ptr.buffer.load`` or
1053+
``llvm.amdgcn.struct.ptr.buffer.store``, the ``align`` attribute on the
1054+
pointer is assumed to apply to both the offset and the base pointer value.
1055+
That is, ``align 8`` means that both the base address within the ``ptr
1056+
addrspace(8)`` and the ``offset`` argument have their three lowesst bits set
1057+
to 0. If the stride of the resource is nonzero, the stride must be a multiple
1058+
of the given alignment.
1059+
1060+
In other words, the ``align`` attribute specifies the alignment of the effective
1061+
address being loaded from/stored to *and* acts as a guarantee that this is
10601062
not achieved from adding lower-alignment parts (as hardware may not always
1061-
allow for such an addition).
1063+
allow for such an addition). For example, if a buffer resource has the base
1064+
address ``0xfffe`` and is accessed with a ``raw.ptr.buffer.load`` with an offset
1065+
of ``2``, the load must **not** be marked ``align 4`` (even though the
1066+
effective adddress ``0x10000`` is so aligned) as this would permit the compiler
1067+
to make incorrect transformations (such as promition to )
10621068

10631069
**Buffer Strided Pointer**
10641070
The buffer index pointer is an experimental address space. It represents
@@ -1080,8 +1086,8 @@ supported for the ``amdgcn`` target.
10801086

10811087
As with buffer fat pointers, alignment of a buffer strided pointer applies to
10821088
both the base pointer address and the offset. In addition, the alignment also
1083-
constrains the stride of the pointer. That is, if you do an `align 4` load from
1084-
a buffer strided pointer, this means that the base pointer is `align(4)`, that
1089+
constrains the stride of the pointer. That is, if you do an ``align 4`` load from
1090+
a buffer strided pointer, this means that the base pointer is ``align(4)``, that
10851091
the offset is a multiple of 4 bytes, and that the stride is a multiple of 4.
10861092

10871093
**Streamout Registers**

0 commit comments

Comments
 (0)