From e414a8c16f3d3c0bb9fcc779e6e9c1e3b39e2c64 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 12 Apr 2022 23:33:09 -0400 Subject: [PATCH] agx: Add agx_after_block_logical helper Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compiler.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/asahi/compiler/agx_compiler.h b/src/asahi/compiler/agx_compiler.h index dea8765d938..4b1fe4ba63d 100644 --- a/src/asahi/compiler/agx_compiler.h +++ b/src/asahi/compiler/agx_compiler.h @@ -635,6 +635,24 @@ agx_after_instr(agx_instr *instr) }; } +/* + * Get a cursor inserting at the logical end of the block. In particular, this + * is before branches or control flow instructions, which occur after the + * logical end but before the physical end. + */ +static inline agx_cursor +agx_after_block_logical(agx_block *block) +{ + /* Search for a p_logical_end */ + agx_foreach_instr_in_block_rev(block, I) { + if (I->op == AGX_OPCODE_P_LOGICAL_END) + return agx_before_instr(I); + } + + /* If there's no p_logical_end, use the physical end */ + return agx_after_block(block); +} + /* IR builder in terms of cursor infrastructure */ typedef struct {