/* Name blocks now that we're done emitting so the order is
* consistent */
block->base.name = block_source_count++;
-
- bi_lower_branch(block);
}
/* Runs before copy prop */
}
} while(progress);
+ bi_foreach_block(ctx, _block) {
+ bi_block *block = (bi_block *) _block;
+ bi_lower_branch(block);
+ }
+
if (bifrost_debug & BIFROST_DBG_SHADERS && !skip_internal)
bi_print_shader(ctx, stdout);
bi_schedule(ctx);
signed bi_block_offset(bi_context *ctx, bi_clause *start, bi_block *target);
bool bi_ec0_packed(unsigned tuple_count);
+/* Check if there are no more instructions starting with a given block, this
+ * needs to recurse in case a shader ends with multiple empty blocks */
+
static inline bool
bi_is_terminal_block(bi_block *block)
{
- return block->base.successors[0] == NULL &&
- block->base.successors[1] == NULL &&
- list_is_empty(&block->base.instructions);
+ return (block == NULL) ||
+ (list_is_empty(&block->base.instructions) &&
+ bi_is_terminal_block((bi_block *) block->base.successors[0]) &&
+ bi_is_terminal_block((bi_block *) block->base.successors[1]));
}
/* Code emit */