From 729d9148244551c6bcae00a760f39a6902c925ef Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 6 Feb 2012 18:33:21 +0000 Subject: [PATCH] gallivm: implement iabs/issg opcode. Reimplemented by Olivier Galibert Signed-off-by: Dave Airlie --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 2 +- .../auxiliary/gallivm/lp_bld_tgsi_action.c | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 4ba4aa54596..3a74790e89f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -926,7 +926,7 @@ lp_build_sgn(struct lp_build_context *bld, } else { - LLVMValueRef minus_one = lp_build_const_vec(bld->gallivm, type, -1.0); + LLVMValueRef minus_one = lp_build_const_int_vec(bld->gallivm, type, -1.0); cond = lp_build_cmp(bld, PIPE_FUNC_GREATER, a, bld->zero); res = lp_build_select(bld, cond, bld->one, minus_one); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c index 7f011563264..d278444ce90 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c @@ -1007,6 +1007,17 @@ i2f_emit_cpu( emit_data->args[0]); } +/* TGSI_OPCODE_IABS (CPU Only) */ +static void +iabs_emit_cpu( + const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + emit_data->output[emit_data->chan] = lp_build_abs(&bld_base->int_bld, + emit_data->args[0]); +} + /* TGSI_OPCODE_IDIV (CPU Only) */ static void idiv_emit_cpu( @@ -1101,6 +1112,18 @@ islt_emit_cpu( iset_emit_cpu(action, bld_base, emit_data, PIPE_FUNC_LESS); } + +/* TGSI_OPCODE_ISSG (CPU Only) */ +static void +issg_emit_cpu( + const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + emit_data->output[emit_data->chan] = lp_build_sgn(&bld_base->int_bld, + emit_data->args[0]); +} + /* TGSI_OPCODE_LG2 (CPU Only) */ static void lg2_emit_cpu( @@ -1541,6 +1564,7 @@ lp_set_default_actions_cpu( bld_base->op_actions[TGSI_OPCODE_FLR].emit = flr_emit_cpu; bld_base->op_actions[TGSI_OPCODE_I2F].emit = i2f_emit_cpu; + bld_base->op_actions[TGSI_OPCODE_IABS].emit = iabs_emit_cpu; bld_base->op_actions[TGSI_OPCODE_IDIV].emit = idiv_emit_cpu; bld_base->op_actions[TGSI_OPCODE_INEG].emit = ineg_emit_cpu; bld_base->op_actions[TGSI_OPCODE_IMAX].emit = imax_emit_cpu; @@ -1548,6 +1572,7 @@ lp_set_default_actions_cpu( bld_base->op_actions[TGSI_OPCODE_ISGE].emit = isge_emit_cpu; bld_base->op_actions[TGSI_OPCODE_ISHR].emit = ishr_emit_cpu; bld_base->op_actions[TGSI_OPCODE_ISLT].emit = islt_emit_cpu; + bld_base->op_actions[TGSI_OPCODE_ISSG].emit = issg_emit_cpu; bld_base->op_actions[TGSI_OPCODE_LG2].emit = lg2_emit_cpu; bld_base->op_actions[TGSI_OPCODE_LOG].emit = log_emit_cpu; -- 2.30.2