From 07a227f5438e63c5ebd1c49a272253a6784a69ae Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 24 Aug 2018 09:34:05 -0500 Subject: 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 --- src/compiler/nir/nir.h | 7 +++++++ src/compiler/nir/nir_control_flow.c | 17 +++++------------ src/compiler/nir/nir_opt_dead_cf.c | 12 +----------- 3 files changed, 13 insertions(+), 23 deletions(-) (limited to 'src/compiler/nir') diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 45a8c2c64cc..009a6d60371 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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) \ diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c index 1622b35a6c9..3b0a0f1a5b0 100644 --- a/src/compiler/nir/nir_control_flow.c +++ b/src/compiler/nir/nir_control_flow.c @@ -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); diff --git a/src/compiler/nir/nir_opt_dead_cf.c b/src/compiler/nir/nir_opt_dead_cf.c index a652bcd99bb..e224daa1fda 100644 --- a/src/compiler/nir/nir_opt_dead_cf.c +++ b/src/compiler/nir/nir_opt_dead_cf.c @@ -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)) { -- cgit v1.2.3