From: Marek Olšák <marek.ol...@amd.com>

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

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";
-- 
2.1.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to