From: Vasily Khoruzhick Date: Mon, 19 Aug 2019 06:03:57 +0000 (-0700) Subject: lima/ppir: add dummy op X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4e695489df70abdcbe8e9c1094e222695c181d59;p=mesa.git lima/ppir: add dummy op We can get following from NIR: (1) r1 = r2 (2) r2 = ssa1 Note that r2 is read before it's assigned, so there's no node for it in comp->var_nodes. We need to create a dummy node in this case which sole purpose is to hold ppir_dest with reg in it. Tested-by: Andreas Baierl Reviewed-by: Qiang Yu Reviewed-by: Erico Nunes Signed-off-by: Vasily Khoruzhick --- diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index 669e5fb4101..2375710f815 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -53,16 +53,16 @@ static void *ppir_node_create_ssa(ppir_block *block, ppir_op op, nir_ssa_def *ss } static void *ppir_node_create_reg(ppir_block *block, ppir_op op, - nir_reg_dest *reg, unsigned mask) + nir_register *reg, unsigned mask) { - ppir_node *node = ppir_node_create(block, op, reg->reg->index, mask); + ppir_node *node = ppir_node_create(block, op, reg->index, mask); if (!node) return NULL; ppir_dest *dest = ppir_node_get_dest(node); list_for_each_entry(ppir_reg, r, &block->comp->reg_list, list) { - if (r->index == reg->reg->index) { + if (r->index == reg->index) { dest->reg = r; break; } @@ -87,7 +87,7 @@ static void *ppir_node_create_dest(ppir_block *block, ppir_op op, if (dest->is_ssa) return ppir_node_create_ssa(block, op, &dest->ssa); else - return ppir_node_create_reg(block, op, &dest->reg, mask); + return ppir_node_create_reg(block, op, dest->reg.reg, mask); } return ppir_node_create(block, op, index, 0); @@ -125,7 +125,15 @@ static void ppir_node_add_src(ppir_compiler *comp, ppir_node *node, while (mask) { int swizzle = ps->swizzle[u_bit_scan(&mask)]; child = comp->var_nodes[(reg->index << 2) + comp->reg_base + swizzle]; - ppir_node_add_dep(node, child); + /* Reg is read before it was written, create a dummy node for it */ + if (!child) { + child = ppir_node_create_reg(node->block, ppir_op_dummy, reg, + u_bit_consecutive(0, 4)); + comp->var_nodes[(reg->index << 2) + comp->reg_base + swizzle] = child; + } + /* Don't add dummies or recursive deps for ops like r1 = r1 + ssa1 */ + if (child && node != child && child->op != ppir_op_dummy) + ppir_node_add_dep(node, child); } } diff --git a/src/gallium/drivers/lima/ir/pp/node.c b/src/gallium/drivers/lima/ir/pp/node.c index 1d4a0c91174..37dd65823fa 100644 --- a/src/gallium/drivers/lima/ir/pp/node.c +++ b/src/gallium/drivers/lima/ir/pp/node.c @@ -331,6 +331,12 @@ const ppir_op_info ppir_op_infos[] = { PPIR_INSTR_SLOT_BRANCH, PPIR_INSTR_SLOT_END }, }, + [ppir_op_dummy] = { + .name = "dummy", + .type = ppir_node_type_alu, + .slots = (int []) { + }, + }, }; void *ppir_node_create(ppir_block *block, ppir_op op, int index, unsigned mask) diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h index bcea3b1dad0..3e852f27ebe 100644 --- a/src/gallium/drivers/lima/ir/pp/ppir.h +++ b/src/gallium/drivers/lima/ir/pp/ppir.h @@ -113,6 +113,8 @@ typedef enum { ppir_op_discard, ppir_op_branch, + ppir_op_dummy, + ppir_op_num, } ppir_op;