[Mesa-dev] [PATCH 1/3] r600g: emit fmul/fadd(fmul) instead of AMDGPU.mul/mad intrinsics

Vincent Lejeune vljn at ovi.com
Thu Nov 29 12:32:07 PST 2012


---
 src/gallium/drivers/r600/r600_llvm.c               | 23 ++++++++++++++++++++++
 .../drivers/radeon/radeon_setup_tgsi_llvm.c        | 10 ++++++----
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c
index 8f1ed26..350527b 100644
--- a/src/gallium/drivers/r600/r600_llvm.c
+++ b/src/gallium/drivers/r600/r600_llvm.c
@@ -387,6 +387,27 @@ static void dp_fetch_args(
 	emit_data->dst_type = base->elem_type;
 }
 
+static void llvm_fmul(
+		const struct lp_build_tgsi_action * action,
+		struct lp_build_tgsi_context * bld_base,
+		struct lp_build_emit_data * emit_data)
+{
+	LLVMBuilderRef builder = bld_base->base.gallivm->builder;
+	emit_data->output[emit_data->chan] = LLVMBuildFMul(builder,
+		emit_data->args[0], emit_data->args[1], "");
+}
+
+static void llvm_fmad(
+		const struct lp_build_tgsi_action * action,
+		struct lp_build_tgsi_context * bld_base,
+		struct lp_build_emit_data * emit_data)
+{
+	LLVMBuilderRef builder = bld_base->base.gallivm->builder;
+	emit_data->output[emit_data->chan] = LLVMBuildFAdd(builder,
+		LLVMBuildFMul(builder, emit_data->args[0], emit_data->args[1], ""),
+		emit_data->args[2], "");
+}
+
 static struct lp_build_tgsi_action dot_action = {
 	.fetch_args = dp_fetch_args,
 	.emit = build_tgsi_intrinsic_nomem,
@@ -428,6 +449,8 @@ LLVMModuleRef r600_tgsi_llvm(
 	bld_base->op_actions[TGSI_OPCODE_TXQ].emit = llvm_emit_tex;
 	bld_base->op_actions[TGSI_OPCODE_TXP].emit = llvm_emit_tex;
 	bld_base->op_actions[TGSI_OPCODE_CMP].emit = emit_cndlt;
+	bld_base->op_actions[TGSI_OPCODE_MUL].emit = llvm_fmul;
+	bld_base->op_actions[TGSI_OPCODE_MAD].emit = llvm_fmad;
 
 	lp_build_tgsi_llvm(bld_base, tokens);
 
diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index 5e3d6c2..cbcebbc 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -547,12 +547,14 @@ static void emit_prepare_cube_coords(
 	mad_args[2] = LLVMConstReal(type, 1.5);
 
 	mad_args[0] = coords[0];
-	coords[0] = build_intrinsic(builder, "llvm.AMDIL.mad.",
-			type, mad_args, 3, LLVMReadNoneAttribute);
+	coords[0] = LLVMBuildFAdd(builder,
+			LLVMBuildFMul(builder, mad_args[0], mad_args[1], ""),
+			mad_args[2], "");
 
 	mad_args[0] = coords[1];
-	coords[1] = build_intrinsic(builder, "llvm.AMDIL.mad.",
-			type, mad_args, 3, LLVMReadNoneAttribute);
+	coords[1] = LLVMBuildFAdd(builder,
+			LLVMBuildFMul(builder, mad_args[0], mad_args[1], ""),
+			mad_args[2], "");
 
 	/* apply yxwy swizzle to cooords */
 	coords[2] = coords[3];
-- 
1.8.0



More information about the mesa-dev mailing list