gallivm: implement iabs/issg opcode.
authorDave Airlie <airlied@redhat.com>
Mon, 6 Feb 2012 18:33:21 +0000 (18:33 +0000)
committerDave Airlie <airlied@redhat.com>
Wed, 9 May 2012 07:26:55 +0000 (08:26 +0100)
Reimplemented by Olivier Galibert <galibert@pobox.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c

index 4ba4aa545966e588ca5435f0421ee17a884164dc..3a74790e89f580c79b6ecb5d615ddd90d680ec32 100644 (file)
@@ -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);
    }
index 7f011563264a2e5bf8e213ed2d4eb2c28f44445d..d278444ce9005188a644e2023967f6ddd5666e9d 100644 (file)
@@ -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;