From a5e7c12cedb8a91236dd3caf99133f86349702a9 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Wed, 24 Jul 2019 15:29:34 -0700 Subject: [PATCH] lima/ppir: add ppir_node to ppir_src We'll need it if we want to walk through node sources Reviewed-by: Qiang Yu Signed-off-by: Vasily Khoruzhick --- src/gallium/drivers/lima/ir/pp/lower.c | 8 ++++---- src/gallium/drivers/lima/ir/pp/nir.c | 3 +-- src/gallium/drivers/lima/ir/pp/node.c | 3 +-- src/gallium/drivers/lima/ir/pp/node_to_instr.c | 2 +- src/gallium/drivers/lima/ir/pp/ppir.h | 10 +++++++++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c index 44c06bdd2f8..87b0b257046 100644 --- a/src/gallium/drivers/lima/ir/pp/lower.c +++ b/src/gallium/drivers/lima/ir/pp/lower.c @@ -54,7 +54,7 @@ static bool ppir_lower_const(ppir_block *block, ppir_node *node) ppir_alu_node *alu = ppir_node_to_alu(move); alu->dest = *dest; alu->num_src = 1; - ppir_node_target_assign(alu->src, dest); + ppir_node_target_assign(alu->src, node); for (int i = 0; i < 4; i++) alu->src->swizzle[i] = i; } @@ -104,7 +104,7 @@ static bool ppir_lower_load(ppir_block *block, ppir_node *node) dest->pipeline = ppir_pipeline_reg_uniform; alu->num_src = 1; - ppir_node_target_assign(&alu->src[0], dest); + ppir_node_target_assign(&alu->src[0], node); for (int i = 0; i < 4; i++) alu->src->swizzle[i] = i; @@ -174,7 +174,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node) dest->pipeline = ppir_pipeline_reg_sampler; alu->num_src = 1; - ppir_node_target_assign(&alu->src[0], dest); + ppir_node_target_assign(&alu->src[0], node); for (int i = 0; i < 4; i++) alu->src->swizzle[i] = i; @@ -223,7 +223,7 @@ static bool ppir_lower_select(ppir_block *block, ppir_node *node) assert(ppir_node_first_pred(node) == move); src->swizzle[0] = 0; - ppir_node_target_assign(alu->src, move_dest); + ppir_node_target_assign(alu->src, move); return true; } diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index f3fd578c813..b20a701afc4 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -111,8 +111,7 @@ static void ppir_node_add_src(ppir_compiler *comp, ppir_node *node, } } - ppir_dest *dest = ppir_node_get_dest(child); - ppir_node_target_assign(ps, dest); + ppir_node_target_assign(ps, child); } static int nir_to_ppir_opcodes[nir_num_opcodes] = { diff --git a/src/gallium/drivers/lima/ir/pp/node.c b/src/gallium/drivers/lima/ir/pp/node.c index ff70bb0d2db..061fc4efaa4 100644 --- a/src/gallium/drivers/lima/ir/pp/node.c +++ b/src/gallium/drivers/lima/ir/pp/node.c @@ -407,8 +407,7 @@ static void _ppir_node_replace_child(ppir_src *src, ppir_node *old_child, ppir_n { ppir_dest *od = ppir_node_get_dest(old_child); if (ppir_node_target_equal(src, od)) { - ppir_dest *nd = ppir_node_get_dest(new_child); - ppir_node_target_assign(src, nd); + ppir_node_target_assign(src, new_child); } } diff --git a/src/gallium/drivers/lima/ir/pp/node_to_instr.c b/src/gallium/drivers/lima/ir/pp/node_to_instr.c index f4b3114852f..919a2a3b38f 100644 --- a/src/gallium/drivers/lima/ir/pp/node_to_instr.c +++ b/src/gallium/drivers/lima/ir/pp/node_to_instr.c @@ -62,7 +62,7 @@ static bool insert_to_each_succ_instr(ppir_block *block, ppir_node *node) ppir_alu_node *alu = ppir_node_to_alu(move); alu->dest = *dest; alu->num_src = 1; - ppir_node_target_assign(alu->src, dest); + ppir_node_target_assign(alu->src, node); for (int i = 0; i < 4; i++) alu->src->swizzle[i] = i; } diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h index 2d37d80715a..8f9399c1cac 100644 --- a/src/gallium/drivers/lima/ir/pp/ppir.h +++ b/src/gallium/drivers/lima/ir/pp/ppir.h @@ -188,6 +188,7 @@ typedef enum { typedef struct ppir_src { ppir_target type; + ppir_node *node; union { ppir_reg *ssa; @@ -467,18 +468,25 @@ static inline ppir_src *ppir_node_get_src(ppir_node *node, int idx) return NULL; } -static inline void ppir_node_target_assign(ppir_src *src, ppir_dest *dest) +static inline void ppir_node_target_assign(ppir_src *src, ppir_node *node) { + ppir_dest *dest = ppir_node_get_dest(node); src->type = dest->type; switch (src->type) { case ppir_target_ssa: src->ssa = &dest->ssa; + src->node = node; break; case ppir_target_register: src->reg = dest->reg; + /* Registers can be assigned from multiple nodes, so don't keep + * pointer to the node here + */ + src->node = NULL; break; case ppir_target_pipeline: src->pipeline = dest->pipeline; + src->node = node; break; } } -- 2.30.2