[Mesa-dev] [PATCH 07/11] ac/radeonsi: create ac_build_shader_clock() helper
Timothy Arceri
tarceri at itsqueeze.com
Fri Feb 2 04:03:45 UTC 2018
---
src/amd/common/ac_llvm_build.c | 8 ++++++++
src/amd/common/ac_llvm_build.h | 2 ++
src/gallium/drivers/radeonsi/si_shader.c | 6 +-----
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 6afe7f9723..026550184f 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -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)
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 78437d603e..57e5c7b5c1 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -118,6 +118,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);
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index e262dc9192..08088450d7 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3940,11 +3940,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, "");
--
2.14.3
More information about the mesa-dev
mailing list