nv50/ir: refine limitation on load/store loading offsets, include atomics
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 12 Apr 2021 22:15:04 +0000 (18:15 -0400)
committerMarge Bot <eric+marge@anholt.net>
Sat, 1 May 2021 20:04:21 +0000 (20:04 +0000)
Note that shared memory loads can actually do offsets. The restrictions
vary by generation, this will be added in a later change.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Pierre Moreau <dev@pmoreau.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10164>

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp

index 9008196..14071f2 100644 (file)
@@ -402,11 +402,12 @@ TargetNV50::insnCanLoadOffset(const Instruction *i, int s, int offset) const
    if (!i->src(s).isIndirect(0))
       return true;
    offset += i->src(s).get()->reg.data.offset;
-   if (i->op == OP_LOAD || i->op == OP_STORE) {
+   if (i->op == OP_LOAD || i->op == OP_STORE || i->op == OP_ATOM) {
       // There are some restrictions in theory, but in practice they're never
-      // going to be hit. When we enable shared/global memory, this will
-      // become more important.
-      return true;
+      // going to be hit. However offsets on global/shared memory are just
+      // plain not supported.
+      return i->src(s).getFile() != FILE_MEMORY_GLOBAL &&
+         i->src(s).getFile() != FILE_MEMORY_SHARED;
    }
    return offset >= 0 && offset <= (int32_t)(127 * i->src(s).get()->reg.size);
 }