Mesa (main): aco: update SMEM offset workaround for LLVM 15

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 16 01:09:15 UTC 2022


Module: Mesa
Branch: main
Commit: 33e7ba2e3e144f40174240298bed2fcc0fc93e80
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=33e7ba2e3e144f40174240298bed2fcc0fc93e80

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Tue Jun 14 20:25:24 2022 +0100

aco: update SMEM offset workaround for LLVM 15

This isn't needed since LLVM 15's b0ccf38b018.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-By: Tatsuyuki Ishi <ishitatsuyuki at gmail.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6663
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17036>

---

 src/amd/compiler/aco_print_asm.cpp        | 15 ++++++++++++---
 src/amd/compiler/tests/test_assembler.cpp |  4 ++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/amd/compiler/aco_print_asm.cpp b/src/amd/compiler/aco_print_asm.cpp
index 974ef764cbe..ecfdb950c4a 100644
--- a/src/amd/compiler/aco_print_asm.cpp
+++ b/src/amd/compiler/aco_print_asm.cpp
@@ -308,22 +308,31 @@ disasm_instr(amd_gfx_level gfx_level, LLVMDisasmContextRef disasm, uint32_t* bin
       size = l / 4;
    }
 
+#if LLVM_VERSION_MAJOR <= 14
    /* See: https://github.com/GPUOpen-Tools/radeon_gpu_profiler/issues/65 and
     * https://github.com/llvm/llvm-project/issues/38652
     */
-   if (gfx_level == GFX9 && (binary[pos] & 0xfc024000) == 0xc0024000) {
+   if (invalid) {
+      /* do nothing */
+   } else if (gfx_level == GFX9 && (binary[pos] & 0xfc024000) == 0xc0024000) {
       /* SMEM with IMM=1 and SOE=1: LLVM ignores SOFFSET */
       size_t len = strlen(outline);
-      snprintf(outline + len, outline_size - len, ", s%u", binary[pos + 1] >> 25);
+
+      char imm[16] = {0};
+      while (outline[--len] != ' ') ;
+      strncpy(imm, outline + len + 1, sizeof(imm) - 1);
+
+      snprintf(outline + len, outline_size - len, " s%u offset:%s", binary[pos + 1] >> 25, imm);
    } else if (gfx_level >= GFX10 && (binary[pos] & 0xfc000000) == 0xf4000000 &&
               (binary[pos + 1] & 0xfe000000) != 0xfa000000) {
       /* SMEM non-NULL SOFFSET: LLVM ignores OFFSET */
       uint32_t offset = binary[pos + 1] & 0x1fffff;
       if (offset) {
          size_t len = strlen(outline);
-         snprintf(outline + len, outline_size - len, ", 0x%x", offset);
+         snprintf(outline + len, outline_size - len, " offset:0x%x", offset);
       }
    }
+#endif
 
    return std::make_pair(invalid, size);
 }
diff --git a/src/amd/compiler/tests/test_assembler.cpp b/src/amd/compiler/tests/test_assembler.cpp
index 27201eef876..a368e9ff934 100644
--- a/src/amd/compiler/tests/test_assembler.cpp
+++ b/src/amd/compiler/tests/test_assembler.cpp
@@ -279,8 +279,8 @@ BEGIN_TEST(assembler.smem_offset)
       //~gfx10! s_load_dword s7, s[6:7], 0x42 ; f40001c3 fa000042
       bld.smem(aco_opcode::s_load_dword, dst, sbase, Operand::c32(0x42));
       if (i >= GFX9) {
-         //~gfx9! s_load_dword s7, s[6:7], 0x42, s5 ; c00241c3 0a000042
-         //~gfx10! s_load_dword s7, s[6:7], s5, 0x42 ; f40001c3 0a000042
+         //~gfx9! s_load_dword s7, s[6:7], s5 offset:0x42 ; c00241c3 0a000042
+         //~gfx10! s_load_dword s7, s[6:7], s5 offset:0x42 ; f40001c3 0a000042
          bld.smem(aco_opcode::s_load_dword, dst, sbase, Operand::c32(0x42), offset);
       }
 



More information about the mesa-commit mailing list