lima/ppir: support nir_op_ftrunc
authorErico Nunes <nunes.erico@gmail.com>
Tue, 23 Apr 2019 17:36:34 +0000 (19:36 +0200)
committerErico Nunes <nunes.erico@gmail.com>
Thu, 2 May 2019 20:55:56 +0000 (20:55 +0000)
Support nir_op_ftrunc by turning it into a mov with a round to integer
output modifier.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
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/ppir.h

index 97243dc..ded92b1 100644 (file)
@@ -389,6 +389,17 @@ static bool ppir_lower_select(ppir_block *block, ppir_node *node)
    return true;
 }
 
+static bool ppir_lower_trunc(ppir_block *block, ppir_node *node)
+{
+   /* Turn it into a mov with a round to integer output modifier */
+   ppir_alu_node *alu = ppir_node_to_alu(node);
+   ppir_dest *move_dest = &alu->dest;
+   move_dest->modifier = ppir_outmod_round;
+   node->op = ppir_op_mov;
+
+   return true;
+}
+
 static bool (*ppir_lower_funcs[ppir_op_num])(ppir_block *, ppir_node *) = {
    [ppir_op_const] = ppir_lower_const,
    [ppir_op_dot2] = ppir_lower_dot,
@@ -405,6 +416,7 @@ static bool (*ppir_lower_funcs[ppir_op_num])(ppir_block *, ppir_node *) = {
    [ppir_op_le] = ppir_lower_swap_args,
    [ppir_op_load_texture] = ppir_lower_texture,
    [ppir_op_select] = ppir_lower_select,
+   [ppir_op_trunc] = ppir_lower_trunc,
 };
 
 bool ppir_lower_prog(ppir_compiler *comp)
index 008a522..bdf54b2 100644 (file)
@@ -150,6 +150,7 @@ static int nir_to_ppir_opcodes[nir_num_opcodes] = {
    [nir_op_fnot] = ppir_op_not,
    [nir_op_fcsel] = ppir_op_select,
    [nir_op_inot] = ppir_op_not,
+   [nir_op_ftrunc] = ppir_op_trunc,
 };
 
 static ppir_node *ppir_emit_alu(ppir_block *block, nir_instr *ni)
index 6090101..71d80dc 100644 (file)
@@ -78,6 +78,7 @@ typedef enum {
    ppir_op_mod,
    ppir_op_min,
    ppir_op_max,
+   ppir_op_trunc,
 
    ppir_op_dot2,
    ppir_op_dot3,