amd/common: add ac_build_waitcnt()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 12 Dec 2017 17:10:23 +0000 (18:10 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 14 Dec 2017 21:24:44 +0000 (22:24 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/amd/common/ac_nir_to_llvm.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index baa921d65591432a2f2a61c585edc9cc6a4db4fe..b407678c3b0bd2d498ac9b6231919256f9fd63b8 100644 (file)
@@ -1482,6 +1482,15 @@ LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input,
                                  AC_FUNC_ATTR_LEGACY);
 }
 
+void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned simm16)
+{
+       LLVMValueRef args[1] = {
+               LLVMConstInt(ctx->i32, simm16, false),
+       };
+       ac_build_intrinsic(ctx, "llvm.amdgcn.s.waitcnt",
+                          ctx->voidt, args, 1, 0);
+}
+
 void ac_get_image_intr_name(const char *base_name,
                            LLVMTypeRef data_type,
                            LLVMTypeRef coords_type,
index 655dc1dcc86befd5a2f99f3a380ea19151e31e51..4a570c41bc5d53cc58a864b812217c0f487fd6fc 100644 (file)
@@ -286,6 +286,8 @@ LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input,
                          LLVMValueRef offset, LLVMValueRef width,
                          bool is_signed);
 
+void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned simm16);
+
 void ac_get_image_intr_name(const char *base_name,
                            LLVMTypeRef data_type,
                            LLVMTypeRef coords_type,
index 25bdb341e0a9d91f79523da70ef9bf1ce5b7aec1..69d7bead8c1fa333d74f509058ac7162bf092975 100644 (file)
@@ -3674,16 +3674,6 @@ static LLVMValueRef visit_image_size(struct ac_nir_context *ctx,
 #define LGKM_CNT 0x07f
 #define VM_CNT 0xf70
 
-static void emit_waitcnt(struct nir_to_llvm_context *ctx,
-                        unsigned simm16)
-{
-       LLVMValueRef args[1] = {
-               LLVMConstInt(ctx->ac.i32, simm16, false),
-       };
-       ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.s.waitcnt",
-                          ctx->ac.voidt, args, 1, 0);
-}
-
 static void emit_membar(struct nir_to_llvm_context *ctx,
                        const nir_intrinsic_instr *instr)
 {
@@ -3706,7 +3696,7 @@ static void emit_membar(struct nir_to_llvm_context *ctx,
                break;
        }
        if (waitcnt != NOOP_WAITCNT)
-               emit_waitcnt(ctx, waitcnt);
+               ac_build_waitcnt(&ctx->ac, waitcnt);
 }
 
 static void emit_barrier(struct nir_to_llvm_context *ctx)
@@ -3717,7 +3707,7 @@ static void emit_barrier(struct nir_to_llvm_context *ctx)
         */
        if (ctx->options->chip_class == SI &&
            ctx->stage == MESA_SHADER_TESS_CTRL) {
-               emit_waitcnt(ctx, LGKM_CNT & VM_CNT);
+               ac_build_waitcnt(&ctx->ac, LGKM_CNT & VM_CNT);
                return;
        }
        ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.s.barrier",
index 5e49d655fc61a9c5dca2ac21f17cb4fe4d7d40f0..02e24f0c7485be791af5bec245709d7d750ac6e3 100644 (file)
@@ -3681,15 +3681,6 @@ static void si_llvm_return_fs_outputs(struct ac_shader_abi *abi,
        ctx->return_value = ret;
 }
 
-void si_emit_waitcnt(struct si_shader_context *ctx, unsigned simm16)
-{
-       LLVMValueRef args[1] = {
-               LLVMConstInt(ctx->i32, simm16, 0)
-       };
-       lp_build_intrinsic(ctx->ac.builder, "llvm.amdgcn.s.waitcnt",
-                          ctx->voidt, args, 1, 0);
-}
-
 static void membar_emit(
                const struct lp_build_tgsi_action *action,
                struct lp_build_tgsi_context *bld_base,
@@ -3712,7 +3703,7 @@ static void membar_emit(
                waitcnt &= LGKM_CNT;
 
        if (waitcnt != NOOP_WAITCNT)
-               si_emit_waitcnt(ctx, waitcnt);
+               ac_build_waitcnt(&ctx->ac, waitcnt);
 }
 
 static void clock_emit(
@@ -4198,7 +4189,7 @@ static void si_llvm_emit_barrier(const struct lp_build_tgsi_action *action,
         */
        if (ctx->screen->info.chip_class == SI &&
            ctx->type == PIPE_SHADER_TESS_CTRL) {
-               si_emit_waitcnt(ctx, LGKM_CNT & VM_CNT);
+               ac_build_waitcnt(&ctx->ac, LGKM_CNT & VM_CNT);
                return;
        }
 
index f50a022db85686033b336c623e9318cb284950f0..e05927c7fd9745986bfe7422cdd6f5061f37b100 100644 (file)
@@ -294,8 +294,6 @@ void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
 #define LGKM_CNT 0x07f
 #define VM_CNT 0xf70
 
-void si_emit_waitcnt(struct si_shader_context *ctx, unsigned simm16);
-
 LLVMValueRef si_get_indirect_index(struct si_shader_context *ctx,
                                   const struct tgsi_ind_register *ind,
                                   unsigned addr_mul, int rel_index);
index 35ada5f93c83c850856ff477ad5074c19ec9a57a..099f86bd22232d269a50a51f07e70be05f1c73b2 100644 (file)
@@ -567,7 +567,7 @@ static void load_emit(
        }
 
        if (inst->Memory.Qualifier & TGSI_MEMORY_VOLATILE)
-               si_emit_waitcnt(ctx, VM_CNT);
+               ac_build_waitcnt(&ctx->ac, VM_CNT);
 
        can_speculate = !(inst->Memory.Qualifier & TGSI_MEMORY_VOLATILE) &&
                          is_oneway_access_only(inst, info,
@@ -780,7 +780,7 @@ static void store_emit(
        }
 
        if (inst->Memory.Qualifier & TGSI_MEMORY_VOLATILE)
-               si_emit_waitcnt(ctx, VM_CNT);
+               ac_build_waitcnt(&ctx->ac, VM_CNT);
 
        writeonly_memory = is_oneway_access_only(inst, info,
                                                 info->shader_buffers_load |