gallium/ttn: add UMAD
authorRob Clark <robclark@freedesktop.org>
Sat, 4 Apr 2015 22:15:00 +0000 (18:15 -0400)
committerRob Clark <robclark@freedesktop.org>
Sun, 5 Apr 2015 13:24:17 +0000 (09:24 -0400)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/auxiliary/nir/tgsi_to_nir.c

index 4935f6c6bf816e47097c7524430f43060f1e3551..07afdb2733b9d9f1b74fe54f5a2506755ad52c46 100644 (file)
@@ -629,6 +629,12 @@ ttn_dph(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src)
                                    ttn_channel(b, src[1], W)));
 }
 
+static void
+ttn_umad(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src)
+{
+   ttn_move_dest(b, dest, nir_iadd(b, nir_imul(b, src[0], src[1]), src[2]));
+}
+
 static void
 ttn_arr(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src)
 {
@@ -1071,7 +1077,7 @@ static const nir_op op_trans[TGSI_OPCODE_LAST] = {
    [TGSI_OPCODE_U2F] = nir_op_u2f,
    [TGSI_OPCODE_UADD] = nir_op_iadd,
    [TGSI_OPCODE_UDIV] = nir_op_udiv,
-   [TGSI_OPCODE_UMAD] = 0, /* XXX */
+   [TGSI_OPCODE_UMAD] = 0,
    [TGSI_OPCODE_UMAX] = nir_op_umax,
    [TGSI_OPCODE_UMIN] = nir_op_umin,
    [TGSI_OPCODE_UMOD] = nir_op_umod,
@@ -1220,6 +1226,10 @@ ttn_emit_instruction(struct ttn_compile *c)
       ttn_dph(b, op_trans[tgsi_op], dest, src);
       break;
 
+   case TGSI_OPCODE_UMAD:
+      ttn_umad(b, op_trans[tgsi_op], dest, src);
+      break;
+
    case TGSI_OPCODE_LRP:
       ttn_move_dest(b, dest, nir_flrp(b, src[2], src[1], src[0]));
       break;