diff options
-rw-r--r-- | src/gallium/auxiliary/Makefile.sources | 1 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_action.c | 28 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_action.h | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c | 17 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 21 |
5 files changed, 56 insertions, 17 deletions
diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 80c449fe242..021025a3eb0 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -155,6 +155,7 @@ GENERATED_SOURCES := \ util/u_half.c GALLIVM_SOURCES := \ + gallivm/lp_bld_action.c \ gallivm/lp_bld_arit.c \ gallivm/lp_bld_assert.c \ gallivm/lp_bld_bitarit.c \ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_action.c b/src/gallium/auxiliary/gallivm/lp_bld_action.c new file mode 100644 index 00000000000..d9d0e618bfc --- /dev/null +++ b/src/gallium/auxiliary/gallivm/lp_bld_action.c @@ -0,0 +1,28 @@ + +#include "lp_bld_action.h" + +#include "lp_bld_arit.h" +#include "lp_bld_tgsi.h" + +/* TGSI_OPCODE_ABS */ + +static LLVMValueRef +abs_emit( + const struct lp_build_opcode_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + return lp_build_abs(&bld_base->base, emit_data->args[0]); +} + +static struct lp_build_opcode_action abs_action = { + .emit = abs_emit +}; + + +void +lp_set_default_actions( + struct lp_build_tgsi_context * bld_base) +{ + bld_base->op_actions[TGSI_OPCODE_ABS] = abs_action; +} diff --git a/src/gallium/auxiliary/gallivm/lp_bld_action.h b/src/gallium/auxiliary/gallivm/lp_bld_action.h index 4da3479cef7..bfde49c3080 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_action.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_action.h @@ -2,6 +2,8 @@ #ifndef LP_BLD_ACTION_H #define LP_BLD_ACTION_H +#include <llvm-c/Core.h> + struct lp_build_tgsi_context; struct lp_build_emit_data { @@ -44,4 +46,8 @@ struct lp_build_opcode_action const char * intr_name; }; +void +lp_set_default_actions( + struct lp_build_tgsi_context * bld_base); + #endif /* LP_BLD_ACTION_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c index 41ba1f93f02..55451e4bcb2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c @@ -492,7 +492,8 @@ lp_emit_instruction_aos( case TGSI_OPCODE_RSQ: /* TGSI_OPCODE_RECIPSQRT */ src0 = lp_build_emit_fetch(&bld->bld_base, inst, 0, CHAN_ALL); - tmp0 = lp_build_abs(&bld->bld_base.base, src0); + tmp0 = lp_build_emit_llvm_unary(&bld->bld_base, TGSI_OPCODE_ABS, + LLVMTypeOf(src0), src0); dst0 = lp_build_rsqrt(&bld->bld_base.base, tmp0); break; @@ -636,11 +637,6 @@ lp_emit_instruction_aos( case TGSI_OPCODE_XPD: return FALSE; - case TGSI_OPCODE_ABS: - src0 = lp_build_emit_fetch(&bld->bld_base, inst, 0, CHAN_ALL); - dst0 = lp_build_abs(&bld->bld_base.base, src0); - break; - case TGSI_OPCODE_RCC: /* deprecated? */ assert(0); @@ -964,7 +960,11 @@ lp_emit_instruction_aos( break; default: - return FALSE; + dst0 = lp_build_tgsi_inst_llvm_aos(&bld->bld_base, inst); + if (!dst0) { + return FALSE; + } + break; } if (info->num_dst) { @@ -1015,6 +1015,9 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm, bld.bld_base.emit_fetch_funcs[TGSI_FILE_INPUT] = emit_fetch_input; bld.bld_base.emit_fetch_funcs[TGSI_FILE_TEMPORARY] = emit_fetch_temporary; + /* Set opcode actions */ + lp_set_default_actions(&bld.bld_base); + if (!lp_bld_tgsi_list_init(&bld.inst_list)) { return; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 6b7e5cf6fc6..02a55fe6ba1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -46,6 +46,7 @@ #include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_util.h" #include "tgsi/tgsi_scan.h" +#include "lp_bld_action.h" #include "lp_bld_type.h" #include "lp_bld_const.h" #include "lp_bld_arit.h" @@ -1384,7 +1385,8 @@ lp_emit_instruction_soa( case TGSI_OPCODE_RSQ: /* TGSI_OPCODE_RECIPSQRT */ src0 = lp_build_emit_fetch( &bld->bld_base, inst, 0, CHAN_X ); - src0 = lp_build_abs(&bld->bld_base.base, src0); + src0 = lp_build_emit_llvm_unary(&bld->bld_base, TGSI_OPCODE_ABS, + LLVMTypeOf(src0), src0); res = lp_build_rsqrt(&bld->bld_base.base, src0); FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { dst0[chan_index] = res; @@ -1432,7 +1434,8 @@ lp_emit_instruction_soa( LLVMValueRef *p_log2 = NULL; src0 = lp_build_emit_fetch( &bld->bld_base, inst, 0, CHAN_X ); - src0 = lp_build_abs( &bld->bld_base.base, src0 ); + src0 = lp_build_emit_llvm_unary(&bld->bld_base, TGSI_OPCODE_ABS, + LLVMTypeOf(src0), src0); if (IS_DST0_CHANNEL_ENABLED( inst, CHAN_X )) p_floor_log2 = &tmp0; @@ -1727,13 +1730,6 @@ lp_emit_instruction_soa( } break; - case TGSI_OPCODE_ABS: - FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { - tmp0 = lp_build_emit_fetch( &bld->bld_base, inst, 0, chan_index ); - dst0[chan_index] = lp_build_abs( &bld->bld_base.base, tmp0 ); - } - break; - case TGSI_OPCODE_RCC: /* deprecated? */ assert(0); @@ -2232,7 +2228,9 @@ lp_emit_instruction_soa( break; default: - return FALSE; + /* XXX: Add return value to this function and return false if it fails */ + lp_build_tgsi_inst_llvm_soa(&bld->bld_base, inst, dst0); + break; } if(info->num_dst) { @@ -2297,6 +2295,9 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, bld.bld_base.emit_fetch_funcs[TGSI_FILE_SYSTEM_VALUE] = emit_fetch_system_value; bld.bld_base.emit_store = lp_emit_store_soa; + /* Set opcode actions */ + lp_set_default_actions(&bld.bld_base); + if (!lp_bld_tgsi_list_init(&bld.inst_list)) { return; } |