summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorVasily Khoruzhick <[email protected]>2019-08-27 22:22:01 -0700
committerVasily Khoruzhick <[email protected]>2019-09-04 00:02:13 +0000
commitbd77d193004c8722b2b670f49d77988296cf6e56 (patch)
treed8f65640126f3a6d07bfac4aca5d3ab58f26930e /src/gallium
parent7659c6197f08587f57f101a88a7e477337ce363c (diff)
lima/ppir: add common helper for creating movs
Introduce common helper for creating movs to avoid code duplication Reviewed-by: Erico Nunes <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/lima/ir/pp/lower.c66
-rw-r--r--src/gallium/drivers/lima/ir/pp/node.c22
-rw-r--r--src/gallium/drivers/lima/ir/pp/ppir.h2
3 files changed, 41 insertions, 49 deletions
diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c
index 5aca32e683e..e49b20e8c7e 100644
--- a/src/gallium/drivers/lima/ir/pp/lower.c
+++ b/src/gallium/drivers/lima/ir/pp/lower.c
@@ -54,35 +54,22 @@ static bool ppir_lower_const(ppir_block *block, ppir_node *node)
break;
}
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1, 0);
+ ppir_node *move = ppir_node_insert_mov(node);
if (unlikely(!move))
return false;
ppir_debug("lower const create move %d for %d\n",
move->index, node->index);
- ppir_alu_node *alu = ppir_node_to_alu(move);
- alu->dest = *dest;
- alu->num_src = 1;
- ppir_node_target_assign(alu->src, node);
- for (int s = 0; s < 4; s++)
- alu->src->swizzle[s] = s;
-
- ppir_node_foreach_succ_safe(node, dep) {
- ppir_node_replace_pred(dep, move);
- ppir_node_replace_child(succ, node, move);
- }
-
/* Need to be careful with changing src/dst type here:
* it has to be done *after* successors have their children
* replaced, otherwise ppir_node_replace_child() won't find
* matching src/dst and as result won't work
*/
- alu->src->type = dest->type = ppir_target_pipeline;
- alu->src->pipeline = dest->pipeline = ppir_pipeline_reg_const0;
+ ppir_src *mov_src = ppir_node_get_src(move, 0);
+ mov_src->type = dest->type = ppir_target_pipeline;
+ mov_src->pipeline = dest->pipeline = ppir_pipeline_reg_const0;
- ppir_node_add_dep(move, node);
- list_addtail(&move->list, &node->list);
return true;
}
@@ -109,27 +96,13 @@ static bool ppir_lower_load(ppir_block *block, ppir_node *node)
return true;
}
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1 , 0);
+ ppir_node *move = ppir_node_insert_mov(node);
if (unlikely(!move))
return false;
- ppir_alu_node *alu = ppir_node_to_alu(move);
-
- alu->dest = *dest;
-
- ppir_node_replace_all_succ(move, node);
-
dest->type = ppir_target_pipeline;
dest->pipeline = ppir_pipeline_reg_uniform;
- alu->num_src = 1;
- ppir_node_target_assign(&alu->src[0], node);
- for (int i = 0; i < 4; i++)
- alu->src->swizzle[i] = i;
-
- ppir_node_add_dep(move, node);
- list_addtail(&move->list, &node->list);
-
return true;
}
@@ -154,6 +127,12 @@ static bool ppir_lower_ddxy(ppir_block *block, ppir_node *node)
static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
{
ppir_load_texture_node *load_tex = ppir_node_to_load_texture(node);
+ ppir_dest *dest = ppir_node_get_dest(node);
+
+ if (ppir_node_is_root(node) && dest->type == ppir_target_ssa) {
+ ppir_node_delete(node);
+ return true;
+ }
/* Create load_coords node */
ppir_load_node *load = ppir_node_create(block, ppir_op_load_coords, -1, 0);
@@ -178,27 +157,16 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
ppir_node_add_dep(node, &load->node);
/* Create move node */
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1 , 0);
+ ppir_node *move = ppir_node_insert_mov(node);
if (unlikely(!move))
return false;
- ppir_alu_node *alu = ppir_node_to_alu(move);
-
- ppir_dest *dest = ppir_node_get_dest(node);
- alu->dest = *dest;
-
- ppir_node_replace_all_succ(move, node);
-
- dest->type = ppir_target_pipeline;
- dest->pipeline = ppir_pipeline_reg_sampler;
-
- alu->num_src = 1;
- ppir_node_target_assign(&alu->src[0], node);
- for (int i = 0; i < 4; i++)
- alu->src->swizzle[i] = i;
+ ppir_debug("lower texture create move %d for %d\n",
+ move->index, node->index);
- ppir_node_add_dep(move, node);
- list_addtail(&move->list, &node->list);
+ ppir_src *mov_src= ppir_node_get_src(move, 0);
+ mov_src->type = dest->type = ppir_target_pipeline;
+ mov_src->pipeline = dest->pipeline = ppir_pipeline_reg_sampler;
return true;
}
diff --git a/src/gallium/drivers/lima/ir/pp/node.c b/src/gallium/drivers/lima/ir/pp/node.c
index db141cac5c1..fd6e2efa035 100644
--- a/src/gallium/drivers/lima/ir/pp/node.c
+++ b/src/gallium/drivers/lima/ir/pp/node.c
@@ -698,3 +698,25 @@ ppir_node *ppir_node_clone(ppir_block *block, ppir_node *node)
return NULL;
}
}
+
+ppir_node *ppir_node_insert_mov(ppir_node *node)
+{
+ ppir_node *move = ppir_node_create(node->block, ppir_op_mov, -1, 0);
+ if (unlikely(!move))
+ return NULL;
+
+ ppir_dest *dest = ppir_node_get_dest(node);
+ ppir_alu_node *alu = ppir_node_to_alu(move);
+ alu->dest = *dest;
+ alu->num_src = 1;
+ ppir_node_target_assign(alu->src, node);
+
+ for (int s = 0; s < 4; s++)
+ alu->src->swizzle[s] = s;
+
+ ppir_node_replace_all_succ(move, node);
+ ppir_node_add_dep(move, node);
+ list_addtail(&move->list, &node->list);
+
+ return move;
+}
diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h
index 462cd93538a..ec649e4afa9 100644
--- a/src/gallium/drivers/lima/ir/pp/ppir.h
+++ b/src/gallium/drivers/lima/ir/pp/ppir.h
@@ -384,6 +384,8 @@ void ppir_node_replace_all_succ(ppir_node *dst, ppir_node *src);
void ppir_node_replace_pred(ppir_dep *dep, ppir_node *new_pred);
ppir_dep *ppir_dep_for_pred(ppir_node *node, ppir_node *pred);
ppir_node *ppir_node_clone(ppir_block *block, ppir_node *node);
+/* Assumes that node successors are in the same block */
+ppir_node *ppir_node_insert_mov(ppir_node *node);
static inline bool ppir_node_is_root(ppir_node *node)
{