[Mesa-dev] [PATCH 07/10] radeonsi: move si_emit_ballot() to ac

Connor Abbott connora at valvesoftware.com
Tue Aug 1 02:24:14 UTC 2017


From: Connor Abbott <cwabbott0 at gmail.com>

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
 src/amd/common/ac_llvm_build.c           | 26 ++++++++++++++++++++++
 src/amd/common/ac_llvm_build.h           |  4 ++++
 src/gallium/drivers/radeonsi/si_shader.c | 38 +++++---------------------------
 3 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 7de02fb..2074938 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -244,6 +244,32 @@ ac_build_optimization_barrier(struct ac_llvm_context *ctx,
 }
 
 LLVMValueRef
+ac_build_ballot(struct ac_llvm_context *ctx,
+	        LLVMValueRef value)
+{
+	LLVMValueRef args[3] = {
+		value,
+		ctx->i32_0,
+		LLVMConstInt(ctx->i32, LLVMIntNE, 0)
+	};
+
+	/* We currently have no other way to prevent LLVM from lifting the icmp
+	 * calls to a dominating basic block.
+	 */
+	ac_build_optimization_barrier(ctx, &args[0]);
+
+	if (LLVMTypeOf(args[0]) != ctx->i32)
+		args[0] = LLVMBuildBitCast(ctx->builder, args[0], ctx->i32, "");
+
+	return ac_build_intrinsic(ctx,
+				  "llvm.amdgcn.icmp.i32",
+				  ctx->i64, args, 3,
+				  AC_FUNC_ATTR_NOUNWIND |
+				  AC_FUNC_ATTR_READNONE |
+				  AC_FUNC_ATTR_CONVERGENT);
+}
+
+LLVMValueRef
 ac_build_gather_values_extended(struct ac_llvm_context *ctx,
 				LLVMValueRef *values,
 				unsigned value_count,
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index b3287cf..840b501 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -77,6 +77,10 @@ void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize);
 
 void ac_build_optimization_barrier(struct ac_llvm_context *ctx,
             			   LLVMValueRef *pvgpr);
+
+
+LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value);
+
 LLVMValueRef
 ac_build_gather_values_extended(struct ac_llvm_context *ctx,
 				LLVMValueRef *values,
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index fbe270f..3ebcbee 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3747,32 +3747,6 @@ static void build_interp_intrinsic(const struct lp_build_tgsi_action *action,
 	}
 }
 
-static LLVMValueRef si_emit_ballot(struct si_shader_context *ctx,
-				   LLVMValueRef value)
-{
-	struct gallivm_state *gallivm = &ctx->gallivm;
-	LLVMValueRef args[3] = {
-		value,
-		ctx->i32_0,
-		LLVMConstInt(ctx->i32, LLVMIntNE, 0)
-	};
-
-	/* We currently have no other way to prevent LLVM from lifting the icmp
-	 * calls to a dominating basic block.
-	 */
-	ac_build_optimization_barrier(&ctx->ac, &args[0]);
-
-	if (LLVMTypeOf(args[0]) != ctx->i32)
-		args[0] = LLVMBuildBitCast(gallivm->builder, args[0], ctx->i32, "");
-
-	return lp_build_intrinsic(gallivm->builder,
-				  "llvm.amdgcn.icmp.i32",
-				  ctx->i64, args, 3,
-				  LP_FUNC_ATTR_NOUNWIND |
-				  LP_FUNC_ATTR_READNONE |
-				  LP_FUNC_ATTR_CONVERGENT);
-}
-
 static void vote_all_emit(
 	const struct lp_build_tgsi_action *action,
 	struct lp_build_tgsi_context *bld_base,
@@ -3783,8 +3757,8 @@ static void vote_all_emit(
 	LLVMValueRef active_set, vote_set;
 	LLVMValueRef tmp;
 
-	active_set = si_emit_ballot(ctx, ctx->i32_1);
-	vote_set = si_emit_ballot(ctx, emit_data->args[0]);
+	active_set = ac_build_ballot(&ctx->ac, ctx->i32_1);
+	vote_set = ac_build_ballot(&ctx->ac, emit_data->args[0]);
 
 	tmp = LLVMBuildICmp(gallivm->builder, LLVMIntEQ, vote_set, active_set, "");
 	emit_data->output[emit_data->chan] =
@@ -3801,7 +3775,7 @@ static void vote_any_emit(
 	LLVMValueRef vote_set;
 	LLVMValueRef tmp;
 
-	vote_set = si_emit_ballot(ctx, emit_data->args[0]);
+	vote_set = ac_build_ballot(&ctx->ac, emit_data->args[0]);
 
 	tmp = LLVMBuildICmp(gallivm->builder, LLVMIntNE,
 			    vote_set, LLVMConstInt(ctx->i64, 0, 0), "");
@@ -3819,8 +3793,8 @@ static void vote_eq_emit(
 	LLVMValueRef active_set, vote_set;
 	LLVMValueRef all, none, tmp;
 
-	active_set = si_emit_ballot(ctx, ctx->i32_1);
-	vote_set = si_emit_ballot(ctx, emit_data->args[0]);
+	active_set = ac_build_ballot(&ctx->ac, ctx->i32_1);
+	vote_set = ac_build_ballot(&ctx->ac, emit_data->args[0]);
 
 	all = LLVMBuildICmp(gallivm->builder, LLVMIntEQ, vote_set, active_set, "");
 	none = LLVMBuildICmp(gallivm->builder, LLVMIntEQ,
@@ -3840,7 +3814,7 @@ static void ballot_emit(
 	LLVMValueRef tmp;
 
 	tmp = lp_build_emit_fetch(bld_base, emit_data->inst, 0, TGSI_CHAN_X);
-	tmp = si_emit_ballot(ctx, tmp);
+	tmp = ac_build_ballot(&ctx->ac, tmp);
 	tmp = LLVMBuildBitCast(builder, tmp, ctx->v2i32, "");
 
 	emit_data->output[0] = LLVMBuildExtractElement(builder, tmp, ctx->i32_0, "");
-- 
2.9.4



More information about the mesa-dev mailing list