diff options
author | Jason Ekstrand <[email protected]> | 2016-10-05 19:08:57 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-10-06 09:16:37 -0700 |
commit | 2ed17d46de045404042f13c6591895a1cf31b167 (patch) | |
tree | a3ae65b79f04ef673578382c631a045f371428e8 /src/compiler/nir/nir_control_flow.c | |
parent | 7a3bcadf4e665ff80775f520715061f4e3d63823 (diff) |
nir: Make nir_foo_first/last_cf_node return a block instead
One of NIR's invariants is that control flow lists always start and end
with blocks. There's no good reason why we should return a cf_node from
these functions since we know that it's always a block. Making it a block
lets us remove a bunch of code.
Signed-off-by: Jason Ekstrand <[email protected]>
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_control_flow.c')
-rw-r--r-- | src/compiler/nir/nir_control_flow.c | 43 |
1 files changed, 10 insertions, 33 deletions
diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c index 1ff7a530f25..380e8aa07c9 100644 --- a/src/compiler/nir/nir_control_flow.c +++ b/src/compiler/nir/nir_control_flow.c @@ -114,13 +114,8 @@ link_non_block_to_block(nir_cf_node *node, nir_block *block) nir_if *if_stmt = nir_cf_node_as_if(node); - nir_cf_node *last_then = nir_if_last_then_node(if_stmt); - assert(last_then->type == nir_cf_node_block); - nir_block *last_then_block = nir_cf_node_as_block(last_then); - - nir_cf_node *last_else = nir_if_last_else_node(if_stmt); - assert(last_else->type == nir_cf_node_block); - nir_block *last_else_block = nir_cf_node_as_block(last_else); + 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)) { unlink_block_successors(last_then_block); @@ -147,13 +142,8 @@ link_block_to_non_block(nir_block *block, nir_cf_node *node) nir_if *if_stmt = nir_cf_node_as_if(node); - nir_cf_node *first_then = nir_if_first_then_node(if_stmt); - assert(first_then->type == nir_cf_node_block); - nir_block *first_then_block = nir_cf_node_as_block(first_then); - - nir_cf_node *first_else = nir_if_first_else_node(if_stmt); - assert(first_else->type == nir_cf_node_block); - nir_block *first_else_block = nir_cf_node_as_block(first_else); + nir_block *first_then_block = nir_if_first_then_block(if_stmt); + nir_block *first_else_block = nir_if_first_else_block(if_stmt); unlink_block_successors(block); link_blocks(block, first_then_block, first_else_block); @@ -168,9 +158,7 @@ link_block_to_non_block(nir_block *block, nir_cf_node *node) nir_loop *loop = nir_cf_node_as_loop(node); - nir_cf_node *loop_header = nir_loop_first_cf_node(loop); - assert(loop_header->type == nir_cf_node_block); - nir_block *loop_header_block = nir_cf_node_as_block(loop_header); + nir_block *loop_header_block = nir_loop_first_block(loop); unlink_block_successors(block); link_blocks(block, loop_header_block, NULL); @@ -319,9 +307,7 @@ block_add_normal_succs(nir_block *block) } else if (parent->type == nir_cf_node_loop) { nir_loop *loop = nir_cf_node_as_loop(parent); - nir_cf_node *head = nir_loop_first_cf_node(loop); - assert(head->type == nir_cf_node_block); - nir_block *head_block = nir_cf_node_as_block(head); + nir_block *head_block = nir_loop_first_block(loop); link_blocks(block, head_block, NULL); insert_phi_undef(head_block, block); @@ -335,22 +321,15 @@ block_add_normal_succs(nir_block *block) if (next->type == nir_cf_node_if) { nir_if *next_if = nir_cf_node_as_if(next); - nir_cf_node *first_then = nir_if_first_then_node(next_if); - assert(first_then->type == nir_cf_node_block); - nir_block *first_then_block = nir_cf_node_as_block(first_then); - - nir_cf_node *first_else = nir_if_first_else_node(next_if); - assert(first_else->type == nir_cf_node_block); - nir_block *first_else_block = nir_cf_node_as_block(first_else); + nir_block *first_then_block = nir_if_first_then_block(next_if); + nir_block *first_else_block = nir_if_first_else_block(next_if); link_blocks(block, first_then_block, first_else_block); } else { assert(next->type == nir_cf_node_loop); nir_loop *next_loop = nir_cf_node_as_loop(next); - nir_cf_node *first = nir_loop_first_cf_node(next_loop); - assert(first->type == nir_cf_node_block); - nir_block *first_block = nir_cf_node_as_block(first); + nir_block *first_block = nir_loop_first_block(next_loop); link_blocks(block, first_block, NULL); insert_phi_undef(first_block, block); @@ -490,9 +469,7 @@ nir_handle_add_jump(nir_block *block) nir_loop *loop = nearest_loop(&block->cf_node); if (jump_instr->type == nir_jump_continue) { - nir_cf_node *first_node = nir_loop_first_cf_node(loop); - assert(first_node->type == nir_cf_node_block); - nir_block *first_block = nir_cf_node_as_block(first_node); + nir_block *first_block = nir_loop_first_block(loop); link_blocks(block, first_block, NULL); } else { nir_cf_node *after = nir_cf_node_next(&loop->cf_node); |