From a2affda89d19858905e6d432ec42a5239c00d030 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 12 May 2022 11:43:54 -0400 Subject: [PATCH] pan/bi: Add bi_after_block_logical helper Useful for lowering phis. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/compiler.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index d7c16a8..344aab4 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -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); -- 2.7.4