aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima
diff options
context:
space:
mode:
authorVasily Khoruzhick <[email protected]>2019-07-24 15:25:33 -0700
committerVasily Khoruzhick <[email protected]>2019-08-13 22:38:07 -0700
commitafa64a2105016744258829d521399472c372cd44 (patch)
treebc63ecc326031dd3341e50a9457d5d8218e57a6a /src/gallium/drivers/lima
parent0f5be81eddfbdcb39a0de10afac2b2ec74790e70 (diff)
lima/ppir: introduce accessors for ppir_node sources
Sometimes we need to walk through ppir_node sources, common accessor for all node types will simplify code a lot. Reviewed-by: Qiang Yu <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]>
Diffstat (limited to 'src/gallium/drivers/lima')
-rw-r--r--src/gallium/drivers/lima/ir/pp/ppir.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h
index e8c6e015f0e..2d37d80715a 100644
--- a/src/gallium/drivers/lima/ir/pp/ppir.h
+++ b/src/gallium/drivers/lima/ir/pp/ppir.h
@@ -426,6 +426,47 @@ static inline ppir_dest *ppir_node_get_dest(ppir_node *node)
}
}
+static inline int ppir_node_get_src_num(ppir_node *node)
+{
+ switch (node->type) {
+ case ppir_node_type_alu:
+ return ppir_node_to_alu(node)->num_src;
+ case ppir_node_type_branch:
+ return 2;
+ case ppir_node_type_load_texture:
+ case ppir_node_type_load:
+ case ppir_node_type_store:
+ return 1;
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+static inline ppir_src *ppir_node_get_src(ppir_node *node, int idx)
+{
+ if (idx < 0 || idx >= ppir_node_get_src_num(node))
+ return NULL;
+
+ switch (node->type) {
+ case ppir_node_type_alu:
+ return &ppir_node_to_alu(node)->src[idx];
+ case ppir_node_type_branch:
+ return &ppir_node_to_branch(node)->src[idx];
+ case ppir_node_type_load_texture:
+ return &ppir_node_to_load_texture(node)->src_coords;
+ case ppir_node_type_load:
+ return &ppir_node_to_load(node)->src;
+ case ppir_node_type_store:
+ return &ppir_node_to_store(node)->src;
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
static inline void ppir_node_target_assign(ppir_src *src, ppir_dest *dest)
{
src->type = dest->type;