Mesa (main): ac/llvm: add AC_WAIT_EXP for ac_build_waitcnt

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 23 02:09:39 UTC 2022


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue Mar 22 09:02:14 2022 -0400

ac/llvm: add AC_WAIT_EXP for ac_build_waitcnt

Reviewed-by: Mihai Preda <mhpreda at gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15966>

---

 src/amd/llvm/ac_llvm_build.c | 7 +++++--
 src/amd/llvm/ac_llvm_build.h | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index aae410de3da..8fb33d72259 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -2461,10 +2461,13 @@ void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned wait_flags)
    if (!wait_flags)
       return;
 
+   unsigned expcnt = 7;
    unsigned lgkmcnt = 63;
    unsigned vmcnt = ctx->chip_class >= GFX9 ? 63 : 15;
    unsigned vscnt = 63;
 
+   if (wait_flags & AC_WAIT_EXP)
+      expcnt = 0;
    if (wait_flags & AC_WAIT_LGKM)
       lgkmcnt = 0;
    if (wait_flags & AC_WAIT_VLOAD)
@@ -2480,12 +2483,12 @@ void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned wait_flags)
    /* There is no intrinsic for vscnt(0), so use a fence. */
    if ((wait_flags & AC_WAIT_LGKM && wait_flags & AC_WAIT_VLOAD && wait_flags & AC_WAIT_VSTORE) ||
        vscnt == 0) {
+      assert(!(wait_flags & AC_WAIT_EXP));
       LLVMBuildFence(ctx->builder, LLVMAtomicOrderingRelease, false, "");
       return;
    }
 
-   unsigned simm16 = (lgkmcnt << 8) | (7 << 4) | /* expcnt */
-                     (vmcnt & 0xf) | ((vmcnt >> 4) << 14);
+   unsigned simm16 = (lgkmcnt << 8) | (expcnt << 4) | (vmcnt & 0xf) | ((vmcnt >> 4) << 14);
 
    LLVMValueRef args[1] = {
       LLVMConstInt(ctx->i32, simm16, false),
diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h
index 42928a4e66b..51c70469427 100644
--- a/src/amd/llvm/ac_llvm_build.h
+++ b/src/amd/llvm/ac_llvm_build.h
@@ -52,6 +52,7 @@ enum
 #define AC_WAIT_LGKM   (1 << 0) /* LDS, GDS, constant, message */
 #define AC_WAIT_VLOAD  (1 << 1) /* VMEM load/sample instructions */
 #define AC_WAIT_VSTORE (1 << 2) /* VMEM store instructions */
+#define AC_WAIT_EXP    (1 << 3) /* EXP instructions */
 
 struct ac_llvm_flow;
 struct ac_llvm_compiler;



More information about the mesa-commit mailing list