lima/ppir: Add fabs op
authorAndreas Baierl <ichgeh@imkreisrum.de>
Fri, 21 Jun 2019 08:50:39 +0000 (10:50 +0200)
committerAndreas Baierl <ichgeh@imkreisrum.de>
Mon, 24 Jun 2019 14:41:33 +0000 (16:41 +0200)
Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
src/gallium/drivers/lima/ir/pp/lower.c
src/gallium/drivers/lima/ir/pp/nir.c
src/gallium/drivers/lima/ir/pp/node.c
src/gallium/drivers/lima/ir/pp/ppir.h

index 192392f6224deb1598eb7ee1571677b33c9c955f..db62988078d7061ee6e6f620b42be4192e77237e 100644 (file)
@@ -400,6 +400,20 @@ static bool ppir_lower_trunc(ppir_block *block, ppir_node *node)
    return true;
 }
 
+static bool ppir_lower_abs(ppir_block *block, ppir_node *node)
+{
+   /* Turn it into a mov and set the absolute modifier */
+   ppir_alu_node *alu = ppir_node_to_alu(node);
+
+   assert(alu->num_src == 1);
+
+   alu->src[0].absolute = true;
+   alu->src[0].negate = false;
+   node->op = ppir_op_mov;
+
+   return true;
+}
+
 static bool ppir_lower_branch(ppir_block *block, ppir_node *node)
 {
    ppir_branch_node *branch = ppir_node_to_branch(node);
@@ -435,6 +449,7 @@ static bool ppir_lower_branch(ppir_block *block, ppir_node *node)
 }
 
 static bool (*ppir_lower_funcs[ppir_op_num])(ppir_block *, ppir_node *) = {
+   [ppir_op_abs] = ppir_lower_abs,
    [ppir_op_const] = ppir_lower_const,
    [ppir_op_dot2] = ppir_lower_dot,
    [ppir_op_dot3] = ppir_lower_dot,
index 580d5c3aff1dacb4f8e5ce7ece772b8808f4538d..18c6eb347f4047d22eece07fc33e4fcfa81e14dd 100644 (file)
@@ -119,6 +119,7 @@ static int nir_to_ppir_opcodes[nir_num_opcodes] = {
 
    [nir_op_mov] = ppir_op_mov,
    [nir_op_fmul] = ppir_op_mul,
+   [nir_op_fabs] = ppir_op_abs,
    [nir_op_fadd] = ppir_op_add,
    [nir_op_fdot2] = ppir_op_dot2,
    [nir_op_fdot3] = ppir_op_dot3,
index 38d7e6284e402ea8cfe840a18c85ac62c47d38be..a1a7f819f1b0efa98b2827b7f0b4da5b126c616f 100644 (file)
@@ -37,6 +37,9 @@ const ppir_op_info ppir_op_infos[] = {
          PPIR_INSTR_SLOT_END
       },
    },
+   [ppir_op_abs] = {
+      .name = "abs",
+   },
    [ppir_op_mul] = {
       .name = "mul",
       .slots = (int []) {
index 4b15804952f4fd41ef7c2d5ad1b893ebe24f94f8..cc3a37e8adeb3e4ca6730e14a1e510aedd3d97d6 100644 (file)
@@ -32,6 +32,7 @@
 
 typedef enum {
    ppir_op_mov,
+   ppir_op_abs,
    ppir_op_add,
 
    ppir_op_ddx,