Mesa (master): gallivm: implement iabs/issg opcode.

Dave Airlie airlied at kemper.freedesktop.org
Wed May 9 07:31:39 UTC 2012


Module: Mesa
Branch: master
Commit: 729d9148244551c6bcae00a760f39a6902c925ef
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=729d9148244551c6bcae00a760f39a6902c925ef

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Feb  6 18:33:21 2012 +0000

gallivm: implement iabs/issg opcode.

Reimplemented by Olivier Galibert <galibert at pobox.com>

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_arit.c        |    2 +-
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c |   25 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index 4ba4aa5..3a74790 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 7f01156..d278444 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;




More information about the mesa-commit mailing list