}
bool
-nir_foreach_block_in_cf_node(nir_cf_node *node, nir_foreach_block_cb cb,
+nir_foreach_block_in_cf_node_call(nir_cf_node *node, nir_foreach_block_cb cb,
void *state)
{
return foreach_cf_node(node, cb, false, state);
}
bool
-nir_foreach_block(nir_function_impl *impl, nir_foreach_block_cb cb, void *state)
+nir_foreach_block_call(nir_function_impl *impl, nir_foreach_block_cb cb, void *state)
{
foreach_list_typed_safe(nir_cf_node, node, node, &impl->body) {
if (!foreach_cf_node(node, cb, false, state))
}
bool
-nir_foreach_block_reverse(nir_function_impl *impl, nir_foreach_block_cb cb,
+nir_foreach_block_reverse_call(nir_function_impl *impl, nir_foreach_block_cb cb,
void *state)
{
if (!cb(impl->end_block, state))
if (impl->valid_metadata & nir_metadata_block_index)
return;
- nir_foreach_block(impl, index_block, &index);
+ nir_foreach_block_call(impl, index_block, &index);
impl->num_blocks = index;
}
nir_index_ssa_defs(nir_function_impl *impl)
{
unsigned index = 0;
- nir_foreach_block(impl, index_ssa_block, &index);
+ nir_foreach_block_call(impl, index_ssa_block, &index);
impl->ssa_alloc = index;
}
nir_index_instrs(nir_function_impl *impl)
{
unsigned index = 0;
- nir_foreach_block(impl, index_instrs_block, &index);
+ nir_foreach_block_call(impl, index_instrs_block, &index);
return index;
}
/* visits basic blocks in source-code order */
typedef bool (*nir_foreach_block_cb)(nir_block *block, void *state);
-bool nir_foreach_block(nir_function_impl *impl, nir_foreach_block_cb cb,
+bool nir_foreach_block_call(nir_function_impl *impl, nir_foreach_block_cb cb,
void *state);
-bool nir_foreach_block_reverse(nir_function_impl *impl, nir_foreach_block_cb cb,
+bool nir_foreach_block_reverse_call(nir_function_impl *impl, nir_foreach_block_cb cb,
void *state);
-bool nir_foreach_block_in_cf_node(nir_cf_node *node, nir_foreach_block_cb cb,
+bool nir_foreach_block_in_cf_node_call(nir_cf_node *node, nir_foreach_block_cb cb,
void *state);
/* If the following CF node is an if, this function returns that if.
state.progress = false;
state.condition_flags = condition_flags;
- nir_foreach_block_reverse(impl, ${pass_name}_block, &state);
+ nir_foreach_block_reverse_call(impl, ${pass_name}_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_block_index |
{
void *mem_ctx = ralloc_parent(impl);
- nir_foreach_block(impl, block_count_children, NULL);
- nir_foreach_block(impl, block_alloc_children, mem_ctx);
- nir_foreach_block(impl, block_add_child, NULL);
+ nir_foreach_block_call(impl, block_count_children, NULL);
+ nir_foreach_block_call(impl, block_alloc_children, mem_ctx);
+ nir_foreach_block_call(impl, block_add_child, NULL);
}
static void
state.impl = impl;
state.progress = true;
- nir_foreach_block(impl, init_block_cb, &state);
+ nir_foreach_block_call(impl, init_block_cb, &state);
while (state.progress) {
state.progress = false;
- nir_foreach_block(impl, calc_dominance_cb, &state);
+ nir_foreach_block_call(impl, calc_dominance_cb, &state);
}
- nir_foreach_block(impl, calc_dom_frontier_cb, &state);
+ nir_foreach_block_call(impl, calc_dom_frontier_cb, &state);
nir_block *start_block = nir_start_block(impl);
start_block->imm_dom = NULL;
nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp)
{
fprintf(fp, "digraph doms_%s {\n", impl->function->name);
- nir_foreach_block(impl, dump_block_dom, fp);
+ nir_foreach_block_call(impl, dump_block_dom, fp);
fprintf(fp, "}\n\n");
}
void
nir_dump_dom_frontier_impl(nir_function_impl *impl, FILE *fp)
{
- nir_foreach_block(impl, dump_block_dom_frontier, fp);
+ nir_foreach_block_call(impl, dump_block_dom_frontier, fp);
}
void
nir_dump_cfg_impl(nir_function_impl *impl, FILE *fp)
{
fprintf(fp, "digraph cfg_%s {\n", impl->function->name);
- nir_foreach_block(impl, dump_block_succs, fp);
+ nir_foreach_block_call(impl, dump_block_succs, fp);
fprintf(fp, "}\n\n");
}
state.merge_node_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
- nir_foreach_block(impl, add_parallel_copy_to_end_of_block, &state);
- nir_foreach_block(impl, isolate_phi_nodes_block, &state);
+ nir_foreach_block_call(impl, add_parallel_copy_to_end_of_block, &state);
+ nir_foreach_block_call(impl, isolate_phi_nodes_block, &state);
/* Mark metadata as dirty before we ask for liveness analysis */
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_require(impl, nir_metadata_live_ssa_defs |
nir_metadata_dominance);
- nir_foreach_block(impl, coalesce_phi_nodes_block, &state);
- nir_foreach_block(impl, aggressive_coalesce_block, &state);
+ nir_foreach_block_call(impl, coalesce_phi_nodes_block, &state);
+ nir_foreach_block_call(impl, aggressive_coalesce_block, &state);
- nir_foreach_block(impl, resolve_registers_block, &state);
+ nir_foreach_block_call(impl, resolve_registers_block, &state);
- nir_foreach_block(impl, resolve_parallel_copies_block, &state);
+ nir_foreach_block_call(impl, resolve_parallel_copies_block, &state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
}
}
- nir_foreach_block(entrypoint, gather_info_block, shader);
+ nir_foreach_block_call(entrypoint, gather_info_block, shader);
}
*/
/* Figure out when we need to lower to a shadow local */
- nir_foreach_block(callee_copy, lower_params_to_locals_block, callee_copy);
+ nir_foreach_block_call(callee_copy, lower_params_to_locals_block, callee_copy);
for (unsigned i = 0; i < callee_copy->num_params; i++) {
nir_variable *param = callee_copy->params[i];
}
}
- nir_foreach_block(callee_copy, rewrite_param_derefs_block, call);
+ nir_foreach_block_call(callee_copy, rewrite_param_derefs_block, call);
/* Pluck the body out of the function and place it here */
nir_cf_list body;
state.progress = false;
nir_builder_init(&state.builder, impl);
- nir_foreach_block(impl, inline_functions_block, &state);
+ nir_foreach_block_call(impl, inline_functions_block, &state);
if (state.progress) {
/* SSA and register indices are completely messed up now */
* can be compacted into a single bit.
*/
state.num_ssa_defs = 1;
- nir_foreach_block(impl, index_ssa_definitions_block, &state);
+ nir_foreach_block_call(impl, index_ssa_definitions_block, &state);
nir_block_worklist_init(&state.worklist, impl->num_blocks, NULL);
* blocks to the worklist.
*/
state.bitset_words = BITSET_WORDS(state.num_ssa_defs);
- nir_foreach_block(impl, init_liveness_block, &state);
+ nir_foreach_block_call(impl, init_liveness_block, &state);
/* We're now ready to work through the worklist and update the liveness
* sets of each of the blocks. By the time we get to this point, every
nir_builder builder;
nir_builder_init(&builder, impl);
- nir_foreach_block(impl, lower_alu_to_scalar_block, &builder);
+ nir_foreach_block_call(impl, lower_alu_to_scalar_block, &builder);
}
void
nir_foreach_function(shader, function) {
if (function->impl) {
- nir_foreach_block(function->impl, lower_block, (void *) &state);
+ nir_foreach_block_call(function->impl, lower_block, (void *) &state);
nir_metadata_preserve(function->impl, nir_metadata_block_index |
nir_metadata_dominance);
}
nir_foreach_function(shader, function) {
if (function->impl) {
- nir_foreach_block_reverse(function->impl,
+ nir_foreach_block_reverse_call(function->impl,
find_output_in_block, &state);
}
}
{
nir_builder b;
nir_builder_init(&b, impl);
- nir_foreach_block(impl, lower_double_pack_block, &b);
+ nir_foreach_block_call(impl, lower_double_pack_block, &b);
}
void
nir_foreach_function(shader, function) {
if (function->impl) {
state.impl = function->impl;
- nir_foreach_block(function->impl, mark_global_var_uses_block, &state);
+ nir_foreach_block_call(function->impl, mark_global_var_uses_block, &state);
}
}
nir_builder_init(&b, function->impl);
state.builder = &b;
- nir_foreach_block(function->impl, rewrite_intrinsics, &state);
+ nir_foreach_block_call(function->impl, rewrite_intrinsics, &state);
/* This only works because we have a single main() function. */
append_set_vertex_count(function->impl->end_block, &state);
nir_builder b;
nir_builder_init(&b, impl);
- nir_foreach_block(impl, convert_block, &b);
+ nir_foreach_block_call(impl, convert_block, &b);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
}
state.modes = modes;
nir_builder_init(&state.builder, impl);
- nir_foreach_block(impl, lower_indirect_block, &state);
+ nir_foreach_block_call(impl, lower_indirect_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_none);
state.modes = modes;
state.type_size = type_size;
- nir_foreach_block(impl, nir_lower_io_block, &state);
+ nir_foreach_block_call(impl, nir_lower_io_block, &state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
static void
nir_lower_load_const_to_scalar_impl(nir_function_impl *impl)
{
- nir_foreach_block(impl, lower_load_const_to_scalar_block, NULL);
+ nir_foreach_block_call(impl, lower_load_const_to_scalar_block, NULL);
}
void
nir_metadata_require(impl, nir_metadata_dominance);
- nir_foreach_block(impl, lower_locals_to_regs_block, &state);
+ nir_foreach_block_call(impl, lower_locals_to_regs_block, &state);
nir_array_foreach(&state.derefs_array, nir_deref_var *, deref_ptr) {
nir_deref_var *deref = *deref_ptr;
/* For geometry shaders, we have to emit the output copies right
* before each EmitVertex call.
*/
- nir_foreach_block(function->impl, emit_output_copies_block, &state);
+ nir_foreach_block_call(function->impl, emit_output_copies_block, &state);
} else if (function == entrypoint) {
/* For all other shader types, we need to do the copies right before
* the jumps to the end block.
state.phi_table = _mesa_hash_table_create(state.dead_ctx, _mesa_hash_pointer,
_mesa_key_pointer_equal);
- nir_foreach_block(impl, lower_phis_to_scalar_block, &state);
+ nir_foreach_block_call(impl, lower_phis_to_scalar_block, &state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
state.shader_program = shader_program;
state.stage = stage;
- nir_foreach_block(impl, lower_block_cb, &state);
+ nir_foreach_block_call(impl, lower_block_cb, &state);
}
void
state.progress = false;
nir_builder_init(&state.builder, impl);
- nir_foreach_block(impl, convert_block, &state);
+ nir_foreach_block_call(impl, convert_block, &state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
return state.progress;
{
nir_builder_init(&state->b, impl);
- nir_foreach_block(impl, nir_lower_tex_block, state);
+ nir_foreach_block_call(impl, nir_lower_tex_block, state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
static void
nir_lower_to_source_mods_impl(nir_function_impl *impl)
{
- nir_foreach_block(impl, nir_lower_to_source_mods_block, NULL);
+ nir_foreach_block_call(impl, nir_lower_to_source_mods_block, NULL);
}
void
nir_builder_init(b, impl);
- nir_foreach_block(impl, nir_lower_two_sided_color_block, state);
+ nir_foreach_block_call(impl, nir_lower_two_sided_color_block, state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
static void
lower_var_copies_impl(nir_function_impl *impl)
{
- nir_foreach_block(impl, lower_var_copies_block, ralloc_parent(impl));
+ nir_foreach_block_call(impl, lower_var_copies_block, ralloc_parent(impl));
}
/* Lowers every copy_var instruction in the program to a sequence of
/* Build the initial deref structures and direct_deref_nodes table */
state.add_to_direct_deref_nodes = true;
- nir_foreach_block(impl, register_variable_uses_block, &state);
+ nir_foreach_block_call(impl, register_variable_uses_block, &state);
bool progress = false;
* added load/store instructions are registered. We need this
* information for phi node insertion below.
*/
- nir_foreach_block(impl, register_variable_uses_block, &state);
+ nir_foreach_block_call(impl, register_variable_uses_block, &state);
state.phi_builder = nir_phi_builder_create(state.impl);
{
struct vec_to_movs_state state = { impl, false };
- nir_foreach_block(impl, lower_vec_to_movs_block, &state);
+ nir_foreach_block_call(impl, lower_vec_to_movs_block, &state);
if (state.progress) {
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_require(impl, nir_metadata_dominance);
nir_index_instrs(impl);
- nir_foreach_block(impl, move_vec_src_uses_to_dest_block, shader);
+ nir_foreach_block_call(impl, move_vec_src_uses_to_dest_block, shader);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
nir_builder_init(&state.b, impl);
state.progress = false;
- nir_foreach_block(impl, normalize_cubemap_coords_block, &state);
+ nir_foreach_block_call(impl, normalize_cubemap_coords_block, &state);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
state.impl = impl;
state.progress = false;
- nir_foreach_block(impl, constant_fold_block, &state);
+ nir_foreach_block_call(impl, constant_fold_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_block_index |
{
bool progress = false;
- nir_foreach_block(impl, copy_prop_block, &progress);
+ nir_foreach_block_call(impl, copy_prop_block, &progress);
if (progress) {
nir_metadata_preserve(impl, nir_metadata_block_index |
struct exec_list *worklist = ralloc(NULL, struct exec_list);
exec_list_make_empty(worklist);
- nir_foreach_block(impl, init_block_cb, worklist);
+ nir_foreach_block_call(impl, init_block_cb, worklist);
while (!exec_list_is_empty(worklist)) {
nir_instr *instr = worklist_pop(worklist);
ralloc_free(worklist);
bool progress = false;
- nir_foreach_block(impl, delete_block_cb, &progress);
+ nir_foreach_block_call(impl, delete_block_cb, &progress);
if (progress)
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_block_first_instr(after)->type == nir_instr_type_phi)
return false;
- if (!nir_foreach_block_in_cf_node(&loop->cf_node, block_has_no_side_effects,
+ if (!nir_foreach_block_in_cf_node_call(&loop->cf_node, block_has_no_side_effects,
NULL))
return false;
nir_metadata_dominance);
gcm_build_block_info(&impl->body, &state, 0);
- nir_foreach_block(impl, gcm_pin_instructions_block, &state);
+ nir_foreach_block_call(impl, gcm_pin_instructions_block, &state);
foreach_list_typed(nir_instr, instr, node, &state.instrs)
gcm_schedule_early_instr(instr, &state);
state.mem_ctx = ralloc_parent(impl);
state.progress = false;
- nir_foreach_block(impl, nir_opt_peephole_select_block, &state);
+ nir_foreach_block_call(impl, nir_opt_peephole_select_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_none);
{
bool progress = false;
- nir_foreach_block(impl, remove_phis_block, &progress);
+ nir_foreach_block_call(impl, remove_phis_block, &progress);
if (progress) {
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_foreach_function(shader, function) {
if (function->impl) {
- nir_foreach_block(function->impl, opt_undef_block, &progress);
+ nir_foreach_block_call(function->impl, opt_undef_block, &progress);
if (progress)
nir_metadata_preserve(function->impl,
nir_metadata_block_index |
pb->num_blocks = impl->num_blocks;
pb->blocks = ralloc_array(pb, nir_block *, pb->num_blocks);
- nir_foreach_block(impl, fill_block_array, pb->blocks);
+ nir_foreach_block_call(impl, fill_block_array, pb->blocks);
exec_list_make_empty(&pb->values);
{
nir_foreach_function(shader, function) {
if (function->impl) {
- nir_foreach_block(function->impl, add_var_use_block, live);
+ nir_foreach_block_call(function->impl, add_var_use_block, live);
}
}
}
nir_metadata_require(impl, nir_metadata_block_index |
nir_metadata_dominance);
- nir_foreach_block(impl, repair_ssa_block, &state);
+ nir_foreach_block_call(impl, repair_ssa_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_block_index |
state.dead_ctx = ralloc_context(NULL);
state.progress = false;
- nir_foreach_block(impl, split_var_copies_block, &state);
+ nir_foreach_block_call(impl, split_var_copies_block, &state);
ralloc_free(state.dead_ctx);
postvalidate_reg_decl(reg, state);
}
- nir_foreach_block(impl, postvalidate_ssa_defs_block, state);
+ nir_foreach_block_call(impl, postvalidate_ssa_defs_block, state);
}
static void
void
nir_block_worklist_add_all(nir_block_worklist *w, nir_function_impl *impl)
{
- nir_foreach_block(impl, worklist_add_block, w);
+ nir_foreach_block_call(impl, worklist_add_block, w);
}
void
state.progress = false;
nir_builder_init(&state.b, impl);
- nir_foreach_block(impl, lower_if_else_block, &state);
+ nir_foreach_block_call(impl, lower_if_else_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_none);
{
nir_foreach_function(s, function) {
if (function->impl) {
- nir_foreach_block(function->impl,
+ nir_foreach_block_call(function->impl,
vc4_nir_lower_blend_block, c);
nir_metadata_preserve(function->impl,
static bool
vc4_nir_lower_io_impl(struct vc4_compile *c, nir_function_impl *impl)
{
- nir_foreach_block(impl, vc4_nir_lower_io_block, c);
+ nir_foreach_block_call(impl, vc4_nir_lower_io_block, c);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
static bool
vc4_nir_lower_txf_ms_impl(struct vc4_compile *c, nir_function_impl *impl)
{
- nir_foreach_block(impl, vc4_nir_lower_txf_ms_block, c);
+ nir_foreach_block_call(impl, vc4_nir_lower_txf_ms_block, c);
nir_metadata_preserve(impl,
nir_metadata_block_index |
nir_foreach_function(nir, function) {
if (!function->impl)
continue;
- nir_foreach_block(function->impl, count_nir_instrs_in_block, &count);
+ nir_foreach_block_call(function->impl, count_nir_instrs_in_block, &count);
}
return count;
}
nir_foreach_function(shader, function) {
if (function->impl) {
nir_builder_init(&state.builder, function->impl);
- nir_foreach_block(function->impl, apply_dynamic_offsets_block, &state);
+ nir_foreach_block_call(function->impl, apply_dynamic_offsets_block,
+ &state);
nir_metadata_preserve(function->impl, nir_metadata_block_index |
nir_metadata_dominance);
}
nir_foreach_function(shader, function) {
if (function->impl)
- nir_foreach_block(function->impl, get_used_bindings_block, &state);
+ nir_foreach_block_call(function->impl, get_used_bindings_block,
+ &state);
}
for (uint32_t set = 0; set < layout->num_sets; set++) {
nir_foreach_function(shader, function) {
if (function->impl) {
nir_builder_init(&state.builder, function->impl);
- nir_foreach_block(function->impl, apply_pipeline_layout_block, &state);
+ nir_foreach_block_call(function->impl, apply_pipeline_layout_block,
+ &state);
nir_metadata_preserve(function->impl, nir_metadata_block_index |
nir_metadata_dominance);
}
{
nir_foreach_function(shader, function) {
if (function->impl)
- nir_foreach_block(function->impl, lower_push_constants_block, NULL);
+ nir_foreach_block_call(function->impl, lower_push_constants_block, NULL);
}
}
nir_foreach_function(nir, function) {
assert(strcmp(function->name, "main") == 0);
assert(function->impl);
- nir_foreach_block(function->impl, emit_system_values_block, this);
+ nir_foreach_block_call(function->impl, emit_system_values_block, this);
}
}
nir_foreach_function(nir, f) {
if (f->impl) {
nir_builder_init(¶ms.b, f->impl);
- nir_foreach_block(f->impl, add_const_offset_to_base_block, ¶ms);
+ nir_foreach_block_call(f->impl, add_const_offset_to_base_block, ¶ms);
}
}
}
nir_foreach_function(nir, function) {
if (function->impl) {
- nir_foreach_block(function->impl, remap_vs_attrs, &inputs_read);
+ nir_foreach_block_call(function->impl, remap_vs_attrs, &inputs_read);
}
}
}
nir_foreach_function(nir, function) {
if (function->impl) {
- nir_foreach_block(function->impl, remap_inputs_with_vue_map,
+ nir_foreach_block_call(function->impl, remap_inputs_with_vue_map,
(void *) vue_map);
}
}
nir_foreach_function(nir, function) {
if (function->impl) {
nir_builder_init(&state.b, function->impl);
- nir_foreach_block(function->impl, remap_patch_urb_offsets, &state);
+ nir_foreach_block_call(function->impl, remap_patch_urb_offsets, &state);
}
}
}
nir_foreach_function(nir, function) {
if (function->impl) {
nir_builder_init(&state.b, function->impl);
- nir_foreach_block(function->impl, remap_patch_urb_offsets, &state);
+ nir_foreach_block_call(function->impl, remap_patch_urb_offsets, &state);
}
}
}
static void
analyze_boolean_resolves_impl(nir_function_impl *impl)
{
- nir_foreach_block(impl, analyze_boolean_resolves_block, NULL);
+ nir_foreach_block_call(impl, analyze_boolean_resolves_block, NULL);
}
void
nir_builder_init(&state.builder, func->impl);
state.impl_progress = false;
- nir_foreach_block(func->impl, apply_attr_wa_block, &state);
+ nir_foreach_block_call(func->impl, apply_attr_wa_block, &state);
if (state.impl_progress) {
nir_metadata_preserve(func->impl, nir_metadata_block_index |
state.impl = impl;
state.progress = false;
- nir_foreach_block(impl, brw_nir_opt_peephole_ffma_block, &state);
+ nir_foreach_block_call(impl, brw_nir_opt_peephole_ffma_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_foreach_function(nir, function) {
assert(strcmp(function->name, "main") == 0);
assert(function->impl);
- nir_foreach_block(function->impl, setup_system_values_block, this);
+ nir_foreach_block_call(function->impl, setup_system_values_block, this);
}
}