ac/radeonsi: create ac_build_shader_clock() helper
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 2 Feb 2018 02:54:48 +0000 (13:54 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 6 Feb 2018 21:43:08 +0000 (08:43 +1100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/gallium/drivers/radeonsi/si_shader.c

index 3efcaa12b186f6181eb0f09044123087a920b804..a86ba962fab8be6a759fda986c33d60c8c71141b 100644 (file)
@@ -343,6 +343,14 @@ ac_build_optimization_barrier(struct ac_llvm_context *ctx,
        }
 }
 
+LLVMValueRef
+ac_build_shader_clock(struct ac_llvm_context *ctx)
+{
+       LLVMValueRef tmp = ac_build_intrinsic(ctx, "llvm.readcyclecounter",
+                                             ctx->i64, NULL, 0, 0);
+       return LLVMBuildBitCast(ctx->builder, tmp, ctx->v2i32, "");
+}
+
 LLVMValueRef
 ac_build_ballot(struct ac_llvm_context *ctx,
                LLVMValueRef value)
index 35f849a9869b55d9f4adf29f82358286bb6c5618..47c843fb4b45ca44f307a92dc8cc366d33c7b367 100644 (file)
@@ -119,6 +119,8 @@ ac_build_phi(struct ac_llvm_context *ctx, LLVMTypeRef type,
 void ac_build_optimization_barrier(struct ac_llvm_context *ctx,
                                   LLVMValueRef *pvgpr);
 
+LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx);
+
 LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value);
 
 LLVMValueRef ac_build_vote_all(struct ac_llvm_context *ctx, LLVMValueRef value);
index bb8cf8f7795241003375caab1a2a1e4384c4a00f..b2ff5b24e684eb17841ecad27bfa357f51d75153 100644 (file)
@@ -3873,11 +3873,7 @@ static void clock_emit(
                struct lp_build_emit_data *emit_data)
 {
        struct si_shader_context *ctx = si_shader_context(bld_base);
-       LLVMValueRef tmp;
-
-       tmp = lp_build_intrinsic(ctx->ac.builder, "llvm.readcyclecounter",
-                                ctx->i64, NULL, 0, 0);
-       tmp = LLVMBuildBitCast(ctx->ac.builder, tmp, ctx->v2i32, "");
+       LLVMValueRef tmp = ac_build_shader_clock(&ctx->ac);
 
        emit_data->output[0] =
                LLVMBuildExtractElement(ctx->ac.builder, tmp, ctx->i32_0, "");