pan/bi: Add bi_after_block_logical helper
authorAlyssa Rosenzweig <alyssa@collabora.com>
Thu, 12 May 2022 15:43:54 +0000 (11:43 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 16:03:23 +0000 (16:03 +0000)
Useful for lowering phis.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>

src/panfrost/bifrost/compiler.h

index d7c16a8..344aab4 100644 (file)
@@ -1271,6 +1271,21 @@ bi_after_instr(bi_instr *instr)
 }
 
 static inline bi_cursor
+bi_after_block_logical(bi_block *block)
+{
+        if (list_is_empty(&block->instructions))
+                return bi_after_block(block);
+
+        bi_instr *last = list_last_entry(&block->instructions, bi_instr, link);
+        assert(last != NULL);
+
+        if (last->branch_target)
+                return bi_before_instr(last);
+        else
+                return bi_after_block(block);
+}
+
+static inline bi_cursor
 bi_before_nonempty_block(bi_block *block)
 {
         bi_instr *I = list_first_entry(&block->instructions, bi_instr, link);