visit_parallel_copy_dest(nir_parallel_copy_instr *instr,
nir_foreach_dest_cb cb, void *state)
{
- nir_foreach_parallel_copy_entry(instr, entry) {
+ nir_foreach_parallel_copy_entry(entry, instr) {
if (!cb(&entry->dest, state))
return false;
}
static bool
visit_phi_src(nir_phi_instr *instr, nir_foreach_src_cb cb, void *state)
{
- nir_foreach_phi_src(instr, src) {
+ nir_foreach_phi_src(src, instr) {
if (!visit_src(&src->src, cb, state))
return false;
}
visit_parallel_copy_src(nir_parallel_copy_instr *instr,
nir_foreach_src_cb cb, void *state)
{
- nir_foreach_parallel_copy_entry(instr, entry) {
+ nir_foreach_parallel_copy_entry(entry, instr) {
if (!visit_src(&entry->src, cb, state))
return false;
}
{
assert(!new_src.is_ssa || def != new_src.ssa);
- nir_foreach_use_safe(def, use_src)
+ nir_foreach_use_safe(use_src, def)
nir_instr_rewrite_src(use_src->parent_instr, use_src, new_src);
- nir_foreach_if_use_safe(def, use_src)
+ nir_foreach_if_use_safe(use_src, def)
nir_if_rewrite_condition(use_src->parent_if, new_src);
}
{
assert(!new_src.is_ssa || def != new_src.ssa);
- nir_foreach_use_safe(def, use_src) {
+ nir_foreach_use_safe(use_src, def) {
assert(use_src->parent_instr != def->parent_instr);
/* Since def already dominates all of its uses, the only way a use can
* not be dominated by after_me is if it is between def and after_me in
nir_instr_rewrite_src(use_src->parent_instr, use_src, new_src);
}
- nir_foreach_if_use_safe(def, use_src)
+ nir_foreach_if_use_safe(use_src, def)
nir_if_rewrite_condition(use_src->parent_if, new_src);
}
nir_ssa_def_components_read(nir_ssa_def *def)
{
uint8_t read_mask = 0;
- nir_foreach_use(def, use) {
+ nir_foreach_use(use, def) {
if (use->parent_instr->type == nir_instr_type_alu) {
nir_alu_instr *alu = nir_instr_as_alu(use->parent_instr);
nir_alu_src *alu_src = exec_node_data(nir_alu_src, use, src);
return nir_cf_node_as_loop(next_node);
}
-static bool
-index_block(nir_block *block, void *state)
-{
- unsigned *index = state;
- block->index = (*index)++;
- return true;
-}
void
nir_index_blocks(nir_function_impl *impl)
if (impl->valid_metadata & nir_metadata_block_index)
return;
- nir_foreach_block_call(impl, index_block, &index);
+ nir_foreach_block(block, impl) {
+ block->index = index++;
+ }
impl->num_blocks = index;
}
return true;
}
-static bool
-index_ssa_block(nir_block *block, void *state)
-{
- nir_foreach_instr(block, instr)
- nir_foreach_ssa_def(instr, index_ssa_def_cb, state);
-
- return true;
-}
-
/**
* The indices are applied top-to-bottom which has the very nice property
* that, if A dominates B, then A->index <= B->index.
nir_index_ssa_defs(nir_function_impl *impl)
{
unsigned index = 0;
- nir_foreach_block_call(impl, index_ssa_block, &index);
- impl->ssa_alloc = index;
-}
-static bool
-index_instrs_block(nir_block *block, void *state)
-{
- unsigned *index = state;
- nir_foreach_instr(block, instr)
- instr->index = (*index)++;
+ nir_foreach_block(block, impl) {
+ nir_foreach_instr(instr, block)
+ nir_foreach_ssa_def(instr, index_ssa_def_cb, &index);
+ }
- return true;
+ impl->ssa_alloc = index;
}
/**
nir_index_instrs(nir_function_impl *impl)
{
unsigned index = 0;
- nir_foreach_block_call(impl, index_instrs_block, &index);
+
+ nir_foreach_block(block, impl) {
+ nir_foreach_instr(instr, block)
+ instr->index = index++;
+ }
+
return index;
}