From 512397058d923704b4bcc16b8748be84dbbe0daa Mon Sep 17 00:00:00 2001 From: Andreas Baierl Date: Fri, 21 Jun 2019 10:50:39 +0200 Subject: [PATCH] lima/ppir: Add fabs op Signed-off-by: Andreas Baierl Reviewed-by: Qiang Yu --- src/gallium/drivers/lima/ir/pp/lower.c | 15 +++++++++++++++ src/gallium/drivers/lima/ir/pp/nir.c | 1 + src/gallium/drivers/lima/ir/pp/node.c | 3 +++ src/gallium/drivers/lima/ir/pp/ppir.h | 1 + 4 files changed, 20 insertions(+) diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c index 192392f6224..db62988078d 100644 --- a/src/gallium/drivers/lima/ir/pp/lower.c +++ b/src/gallium/drivers/lima/ir/pp/lower.c @@ -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, diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index 580d5c3aff1..18c6eb347f4 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -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, diff --git a/src/gallium/drivers/lima/ir/pp/node.c b/src/gallium/drivers/lima/ir/pp/node.c index 38d7e6284e4..a1a7f819f1b 100644 --- a/src/gallium/drivers/lima/ir/pp/node.c +++ b/src/gallium/drivers/lima/ir/pp/node.c @@ -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 []) { diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h index 4b15804952f..cc3a37e8ade 100644 --- a/src/gallium/drivers/lima/ir/pp/ppir.h +++ b/src/gallium/drivers/lima/ir/pp/ppir.h @@ -32,6 +32,7 @@ typedef enum { ppir_op_mov, + ppir_op_abs, ppir_op_add, ppir_op_ddx, -- 2.30.2