ac: add ac_build_load_helper_invocation() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 10 Apr 2019 15:16:51 +0000 (17:16 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 12 Apr 2019 15:30:55 +0000 (17:30 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
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

index d305af280d509e6950f89eb1b7ab9c9accc8557f..19496519165f7ea856b23145375d104fde628d49 100644 (file)
@@ -4057,3 +4057,13 @@ ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij)
        }
        return ac_build_gather_values(ctx, result, 4);
 }
+
+LLVMValueRef
+ac_build_load_helper_invocation(struct ac_llvm_context *ctx)
+{
+       LLVMValueRef result = ac_build_intrinsic(ctx, "llvm.amdgcn.ps.live",
+                                                ctx->i1, NULL, 0,
+                                                AC_FUNC_ATTR_READNONE);
+       result = LLVMBuildNot(ctx->builder, result, "");
+       return LLVMBuildSExt(ctx->builder, result, ctx->i32, "");
+}
index 64b6894538e4b188c38994da45a5957f60a00823..debc029f192554a397c17cfbd861fc4a92826652 100644 (file)
@@ -689,6 +689,9 @@ ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0,
 LLVMValueRef
 ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);
 
+LLVMValueRef
+ac_build_load_helper_invocation(struct ac_llvm_context *ctx);
+
 #ifdef __cplusplus
 }
 #endif
index 1401998c666ed14ee0dc7c6c55563cf25b107062..90f7c66434d28e120352a2a3d7304cb867ed0581 100644 (file)
@@ -2859,17 +2859,6 @@ static void emit_discard(struct ac_nir_context *ctx,
        ctx->abi->emit_kill(ctx->abi, cond);
 }
 
-static LLVMValueRef
-visit_load_helper_invocation(struct ac_nir_context *ctx)
-{
-       LLVMValueRef result = ac_build_intrinsic(&ctx->ac,
-                                                "llvm.amdgcn.ps.live",
-                                                ctx->ac.i1, NULL, 0,
-                                                AC_FUNC_ATTR_READNONE);
-       result = LLVMBuildNot(ctx->ac.builder, result, "");
-       return LLVMBuildSExt(ctx->ac.builder, result, ctx->ac.i32, "");
-}
-
 static LLVMValueRef
 visit_load_local_invocation_index(struct ac_nir_context *ctx)
 {
@@ -3283,7 +3272,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
                result = ctx->abi->front_face;
                break;
        case nir_intrinsic_load_helper_invocation:
-               result = visit_load_helper_invocation(ctx);
+               result = ac_build_load_helper_invocation(&ctx->ac);
                break;
        case nir_intrinsic_load_instance_id:
                result = ctx->abi->instance_id;
index 8ebc8d39e991bc5724caa6ac88cafe4b881886f6..d783555ca331bcf9600de0f11510f50a7fd4f95a 100644 (file)
@@ -2218,12 +2218,7 @@ void si_load_system_value(struct si_shader_context *ctx,
                break;
 
        case TGSI_SEMANTIC_HELPER_INVOCATION:
-               value = ac_build_intrinsic(&ctx->ac,
-                                          "llvm.amdgcn.ps.live",
-                                          ctx->i1, NULL, 0,
-                                          AC_FUNC_ATTR_READNONE);
-               value = LLVMBuildNot(ctx->ac.builder, value, "");
-               value = LLVMBuildSExt(ctx->ac.builder, value, ctx->i32, "");
+               value = ac_build_load_helper_invocation(&ctx->ac);
                break;
 
        case TGSI_SEMANTIC_SUBGROUP_SIZE: