pan/bi: Add bi_foreach_instr_in_tuple helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 6 Jan 2021 21:17:37 +0000 (16:17 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 Jan 2021 16:55:43 +0000 (16:55 +0000)
Written in a funny way but easy to convince yourself of correctness by
considering cases.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8723>

src/panfrost/bifrost/compiler.h

index 3e9fd8b..3a2940e 100644 (file)
@@ -657,6 +657,11 @@ bi_node_to_index(unsigned node, unsigned node_count)
         bi_foreach_block(ctx, v_block) \
                 bi_foreach_instr_in_block_safe((bi_block *) v_block, v)
 
+#define bi_foreach_instr_in_tuple(tuple, v) \
+        for (bi_instr *v = tuple->fma ?: tuple->add; \
+                        v != NULL; \
+                        v = (v == tuple->add) ? NULL : tuple->add)
+
 /* Based on set_foreach, expanded with automatic type casts */
 
 #define bi_foreach_predecessor(blk, v) \