[Mesa-dev,8/9] radeonsi: implement TGSI_OPCODE_BFI

Submitted by Marek Olšák on March 2, 2015, 11:54 a.m.

Details

Message ID 1425297263-25991-8-git-send-email-maraeo@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marek Olšák March 2, 2015, 11:54 a.m.
From: Marek Olšák <marek.olsak@amd.com>

---
 .../drivers/radeon/radeon_setup_tgsi_llvm.c        | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index 034095f..c6132d3 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -1234,6 +1234,33 @@  build_tgsi_intrinsic_nomem(
 	build_tgsi_intrinsic(action, bld_base, emit_data, LLVMReadNoneAttribute);
 }
 
+static void emit_bfi(const struct lp_build_tgsi_action * action,
+		     struct lp_build_tgsi_context * bld_base,
+		     struct lp_build_emit_data * emit_data)
+{
+	struct gallivm_state *gallivm = bld_base->base.gallivm;
+	LLVMValueRef bfm_args[] = {
+		emit_data->args[3],
+		emit_data->args[2]
+	};
+	LLVMValueRef bfi_args[3];
+
+	bfi_args[0] =
+		build_intrinsic(gallivm->builder, "llvm.AMDGPU.bfm",
+				emit_data->dst_type, bfm_args,
+				Elements(bfm_args), LLVMReadNoneAttribute);
+
+	bfi_args[1] = LLVMBuildShl(gallivm->builder, emit_data->args[1],
+				   emit_data->args[2], "");
+
+	bfi_args[2] = emit_data->args[0];
+
+	emit_data->output[emit_data->chan] =
+		build_intrinsic(gallivm->builder, "llvm.AMDGPU.bfi",
+				emit_data->dst_type, bfi_args,
+				Elements(bfi_args), LLVMReadNoneAttribute);
+}
+
 void radeon_llvm_context_init(struct radeon_llvm_context * ctx)
 {
 	struct lp_type type;
@@ -1292,6 +1319,7 @@  void radeon_llvm_context_init(struct radeon_llvm_context * ctx)
 	bld_base->op_actions[TGSI_OPCODE_ABS].intr_name = "fabs";
 	bld_base->op_actions[TGSI_OPCODE_AND].emit = emit_and;
 	bld_base->op_actions[TGSI_OPCODE_ARL].emit = emit_arl;
+	bld_base->op_actions[TGSI_OPCODE_BFI].emit = emit_bfi;
 	bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit;
 	bld_base->op_actions[TGSI_OPCODE_BREV].emit = build_tgsi_intrinsic_nomem;
 	bld_base->op_actions[TGSI_OPCODE_BREV].intr_name = "llvm.AMDGPU.brev";