pan/midgard: Add mir_foreach_predecessor utility
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 15 Aug 2019 15:36:41 +0000 (08:36 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 19 Aug 2019 15:32:17 +0000 (08:32 -0700)
It's ugly, but c'est la vie.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/compiler.h

index e51ea8ba6028179ec427a3af8f76c2c11fd8b27e..f196389c36a0e5e97700bc0661513d7659c90073 100644 (file)
@@ -360,6 +360,17 @@ mir_next_op(struct midgard_instruction *ins)
         mir_foreach_block(ctx, v_block) \
                 mir_foreach_instr_in_block_safe(v_block, v)
 
+/* Based on set_foreach, expanded with automatic type casts */
+
+#define mir_foreach_predecessor(blk, v) \
+        struct set_entry *_entry_##v; \
+        struct midgard_block *v; \
+        for (_entry_##v = _mesa_set_next_entry(blk->predecessors, NULL), \
+                v = (struct midgard_block *) (_entry_##v ? _entry_##v->key : NULL);  \
+                _entry_##v != NULL; \
+                _entry_##v = _mesa_set_next_entry(blk->predecessors, _entry_##v), \
+                v = (struct midgard_block *) (_entry_##v ? _entry_##v->key : NULL))
+
 static inline midgard_instruction *
 mir_last_in_block(struct midgard_block *block)
 {