nir_block *end_block = nir_block_create(mem_ctx);
start_block->cf_node.parent = &impl->cf_node;
end_block->cf_node.parent = &impl->cf_node;
- impl->start_block = start_block;
impl->end_block = end_block;
exec_list_push_tail(&impl->body, &start_block->cf_node.node);
struct exec_list body; /** < list of nir_cf_node */
- nir_block *start_block, *end_block;
+ nir_block *end_block;
/** list for all local variables in the function */
struct exec_list locals;
nir_metadata valid_metadata;
} nir_function_impl;
+static inline nir_block *
+nir_start_block(nir_function_impl *impl)
+{
+ return (nir_block *) exec_list_get_head(&impl->body);
+}
+
static inline nir_cf_node *
nir_cf_node_next(nir_cf_node *node)
{
init_block_cb(nir_block *block, void *_state)
{
dom_state *state = (dom_state *) _state;
- if (block == state->impl->start_block)
+ if (block == nir_start_block(state->impl))
block->imm_dom = block;
else
block->imm_dom = NULL;
calc_dominance_cb(nir_block *block, void *_state)
{
dom_state *state = (dom_state *) _state;
- if (block == state->impl->start_block)
+ if (block == nir_start_block(state->impl))
return true;
nir_block *new_idom = NULL;
nir_foreach_block(impl, calc_dom_frontier_cb, &state);
- impl->start_block->imm_dom = NULL;
+ nir_block *start_block = nir_start_block(impl);
+ start_block->imm_dom = NULL;
calc_dom_children(impl);
unsigned dfs_index = 0;
- calc_dfs_indicies(impl->start_block, &dfs_index);
+ calc_dfs_indicies(start_block, &dfs_index);
}
void
nir_foreach_block(impl, register_variable_uses_block, &state);
insert_phi_nodes(&state);
- rename_variables_block(impl->start_block, &state);
+ rename_variables_block(nir_start_block(impl), &state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
/* Start with the instruction at the top. As we iterate over the
* sources, it will get moved down as needed.
*/
- instr->block = state->impl->start_block;
+ instr->block = nir_start_block(state->impl);
state->instr = instr;
nir_foreach_src(instr, gcm_schedule_early_src, state);
rewrite_state state;
init_rewrite_state(impl, &state);
- rewrite_block(impl->start_block, &state);
+ rewrite_block(nir_start_block(impl), &state);
remove_unused_regs(impl, &state);