nir: Pull block_ends_in_jump into nir.h
We had two different implementations in different files. May as well have one and put it in nir.h. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -1753,6 +1753,13 @@ nir_block_last_instr(nir_block *block)
|
||||
return exec_node_data(nir_instr, tail, node);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
nir_block_ends_in_jump(nir_block *block)
|
||||
{
|
||||
return !exec_list_is_empty(&block->instr_list) &&
|
||||
nir_block_last_instr(block)->type == nir_instr_type_jump;
|
||||
}
|
||||
|
||||
#define nir_foreach_instr(instr, block) \
|
||||
foreach_list_typed(nir_instr, instr, node, &(block)->instr_list)
|
||||
#define nir_foreach_instr_reverse(instr, block) \
|
||||
|
@@ -45,13 +45,6 @@
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
static bool
|
||||
block_ends_in_jump(nir_block *block)
|
||||
{
|
||||
return !exec_list_is_empty(&block->instr_list) &&
|
||||
nir_block_last_instr(block)->type == nir_instr_type_jump;
|
||||
}
|
||||
|
||||
static inline void
|
||||
block_add_pred(nir_block *block, nir_block *pred)
|
||||
{
|
||||
@@ -117,12 +110,12 @@ link_non_block_to_block(nir_cf_node *node, nir_block *block)
|
||||
nir_block *last_then_block = nir_if_last_then_block(if_stmt);
|
||||
nir_block *last_else_block = nir_if_last_else_block(if_stmt);
|
||||
|
||||
if (!block_ends_in_jump(last_then_block)) {
|
||||
if (!nir_block_ends_in_jump(last_then_block)) {
|
||||
unlink_block_successors(last_then_block);
|
||||
link_blocks(last_then_block, block, NULL);
|
||||
}
|
||||
|
||||
if (!block_ends_in_jump(last_else_block)) {
|
||||
if (!nir_block_ends_in_jump(last_else_block)) {
|
||||
unlink_block_successors(last_else_block);
|
||||
link_blocks(last_else_block, block, NULL);
|
||||
}
|
||||
@@ -339,7 +332,7 @@ split_block_end(nir_block *block)
|
||||
new_block->cf_node.parent = block->cf_node.parent;
|
||||
exec_node_insert_after(&block->cf_node.node, &new_block->cf_node.node);
|
||||
|
||||
if (block_ends_in_jump(block)) {
|
||||
if (nir_block_ends_in_jump(block)) {
|
||||
/* Figure out what successor block would've had if it didn't have a jump
|
||||
* instruction, and make new_block have that successor.
|
||||
*/
|
||||
@@ -553,7 +546,7 @@ stitch_blocks(nir_block *before, nir_block *after)
|
||||
* TODO: special case when before is empty and after isn't?
|
||||
*/
|
||||
|
||||
if (block_ends_in_jump(before)) {
|
||||
if (nir_block_ends_in_jump(before)) {
|
||||
assert(exec_list_is_empty(&after->instr_list));
|
||||
if (after->successors[0])
|
||||
remove_phi_src(after->successors[0], after);
|
||||
@@ -588,7 +581,7 @@ nir_cf_node_insert(nir_cursor cursor, nir_cf_node *node)
|
||||
* already been setup with the correct successors, so we need to set
|
||||
* up jumps here as the block is being inserted.
|
||||
*/
|
||||
if (block_ends_in_jump(block))
|
||||
if (nir_block_ends_in_jump(block))
|
||||
nir_handle_add_jump(block);
|
||||
|
||||
stitch_blocks(block, after);
|
||||
|
@@ -256,16 +256,6 @@ dead_cf_block(nir_block *block)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
ends_in_jump(nir_block *block)
|
||||
{
|
||||
if (exec_list_is_empty(&block->instr_list))
|
||||
return false;
|
||||
|
||||
nir_instr *instr = nir_block_last_instr(block);
|
||||
return instr->type == nir_instr_type_jump;
|
||||
}
|
||||
|
||||
static bool
|
||||
dead_cf_list(struct exec_list *list, bool *list_ends_in_jump)
|
||||
{
|
||||
@@ -297,7 +287,7 @@ dead_cf_list(struct exec_list *list, bool *list_ends_in_jump)
|
||||
progress = true;
|
||||
}
|
||||
|
||||
if (ends_in_jump(block)) {
|
||||
if (nir_block_ends_in_jump(block)) {
|
||||
*list_ends_in_jump = true;
|
||||
|
||||
if (!exec_node_is_tail_sentinel(cur->node.next)) {
|
||||
|
Reference in New Issue
Block a user