diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 6cbb9f26019..2b9ff7ac932 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -7150,11 +7150,8 @@ brw_compute_barycentric_interp_modes(const struct intel_device_info *devinfo, { unsigned barycentric_interp_modes = 0; - nir_foreach_function(f, shader) { - if (!f->impl) - continue; - - nir_foreach_block(block, f->impl) { + nir_foreach_function_impl(impl, shader) { + nir_foreach_block(block, impl) { nir_foreach_instr(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -7255,11 +7252,8 @@ brw_nir_move_interpolation_to_top(nir_shader *nir) { bool progress = false; - nir_foreach_function(f, nir) { - if (!f->impl) - continue; - - nir_block *top = nir_start_block(f->impl); + nir_foreach_function_impl(impl, nir) { + nir_block *top = nir_start_block(impl); nir_cursor cursor = nir_before_instr(nir_block_first_instr(top)); bool impl_progress = false; @@ -7300,7 +7294,7 @@ brw_nir_move_interpolation_to_top(nir_shader *nir) progress = progress || impl_progress; - nir_metadata_preserve(f->impl, impl_progress ? (nir_metadata_block_index | + nir_metadata_preserve(impl, impl_progress ? (nir_metadata_block_index | nir_metadata_dominance) : nir_metadata_all); } diff --git a/src/intel/compiler/brw_kernel.c b/src/intel/compiler/brw_kernel.c index 2d09b48aec0..67f004e10aa 100644 --- a/src/intel/compiler/brw_kernel.c +++ b/src/intel/compiler/brw_kernel.c @@ -312,9 +312,8 @@ brw_kernel_from_spirv(struct brw_compiler *compiler, if (INTEL_DEBUG(DEBUG_CS)) { /* Re-index SSA defs so we print more sensible numbers. */ - nir_foreach_function(function, nir) { - if (function->impl) - nir_index_ssa_defs(function->impl); + nir_foreach_function_impl(impl, nir) { + nir_index_ssa_defs(impl); } fprintf(stderr, "NIR (from SPIR-V) for kernel\n"); @@ -413,9 +412,8 @@ brw_kernel_from_spirv(struct brw_compiler *compiler, if (INTEL_DEBUG(DEBUG_CS)) { /* Re-index SSA defs so we print more sensible numbers. */ - nir_foreach_function(function, nir) { - if (function->impl) - nir_index_ssa_defs(function->impl); + nir_foreach_function_impl(impl, nir) { + nir_index_ssa_defs(impl); } fprintf(stderr, "NIR (before I/O lowering) for kernel\n"); diff --git a/src/intel/compiler/brw_mesh.cpp b/src/intel/compiler/brw_mesh.cpp index 50e0a193b04..04475791aba 100644 --- a/src/intel/compiler/brw_mesh.cpp +++ b/src/intel/compiler/brw_mesh.cpp @@ -820,11 +820,8 @@ brw_can_pack_primitive_indices(nir_shader *nir, struct index_packing_state *stat assert(type->without_array()->is_vector()); assert(type->without_array()->vector_elements == state->vertices_per_primitive); - nir_foreach_function(function, nir) { - if (!function->impl) - continue; - - nir_foreach_block(block, function->impl) { + nir_foreach_function_impl(impl, nir) { + nir_foreach_block(block, impl) { nir_foreach_instr(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue; diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 71298f7e4be..5331a8d85c2 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -273,13 +273,10 @@ brw_nir_lower_vs_inputs(nir_shader *nir, const unsigned num_inputs = util_bitcount64(nir->info.inputs_read); - nir_foreach_function(function, nir) { - if (!function->impl) - continue; + nir_foreach_function_impl(impl, nir) { + nir_builder b = nir_builder_create(impl); - nir_builder b = nir_builder_create(function->impl); - - nir_foreach_block(block, function->impl) { + nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -387,11 +384,8 @@ brw_nir_lower_vue_inputs(nir_shader *nir, nir_io_add_const_offset_to_base(nir, nir_var_shader_in); - nir_foreach_function(function, nir) { - if (!function->impl) - continue; - - nir_foreach_block(block, function->impl) { + nir_foreach_function_impl(impl, nir) { + nir_foreach_block(block, impl) { nir_foreach_instr(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -438,13 +432,11 @@ brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map) nir_io_add_const_offset_to_base(nir, nir_var_shader_in); - nir_foreach_function(function, nir) { - if (function->impl) { - nir_builder b = nir_builder_create(function->impl); - nir_foreach_block(block, function->impl) { - remap_patch_urb_offsets(block, &b, vue_map, - nir->info.tess._primitive_mode); - } + nir_foreach_function_impl(impl, nir) { + nir_builder b = nir_builder_create(impl); + nir_foreach_block(block, impl) { + remap_patch_urb_offsets(block, &b, vue_map, + nir->info.tess._primitive_mode); } } } @@ -593,12 +585,10 @@ brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map, nir_io_add_const_offset_to_base(nir, nir_var_shader_out); - nir_foreach_function(function, nir) { - if (function->impl) { - nir_builder b = nir_builder_create(function->impl); - nir_foreach_block(block, function->impl) { - remap_patch_urb_offsets(block, &b, vue_map, tes_primitive_mode); - } + nir_foreach_function_impl(impl, nir) { + nir_builder b = nir_builder_create(impl); + nir_foreach_block(block, impl) { + remap_patch_urb_offsets(block, &b, vue_map, tes_primitive_mode); } } } @@ -1528,8 +1518,8 @@ brw_vectorize_lower_mem_access(nir_shader *nir, static bool nir_shader_has_local_variables(const nir_shader *nir) { - nir_foreach_function(func, nir) { - if (func->impl && !exec_list_is_empty(&func->impl->locals)) + nir_foreach_function_impl(impl, nir) { + if (!exec_list_is_empty(&impl->locals)) return true; } @@ -1702,9 +1692,8 @@ brw_postprocess_nir(nir_shader *nir, const struct brw_compiler *compiler, if (unlikely(debug_enabled)) { /* Re-index SSA defs so we print more sensible numbers. */ - nir_foreach_function(function, nir) { - if (function->impl) - nir_index_ssa_defs(function->impl); + nir_foreach_function_impl(impl, nir) { + nir_index_ssa_defs(impl); } fprintf(stderr, "NIR (SSA form) for %s shader:\n", diff --git a/src/intel/compiler/brw_nir_analyze_boolean_resolves.c b/src/intel/compiler/brw_nir_analyze_boolean_resolves.c index fd3b253369f..99755de81a3 100644 --- a/src/intel/compiler/brw_nir_analyze_boolean_resolves.c +++ b/src/intel/compiler/brw_nir_analyze_boolean_resolves.c @@ -267,8 +267,7 @@ analyze_boolean_resolves_impl(nir_function_impl *impl) void brw_nir_analyze_boolean_resolves(nir_shader *shader) { - nir_foreach_function(function, shader) { - if (function->impl) - analyze_boolean_resolves_impl(function->impl); + nir_foreach_function_impl(impl, shader) { + analyze_boolean_resolves_impl(impl); } } diff --git a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c index 91a4073e914..30a5b122b26 100644 --- a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c +++ b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c @@ -218,11 +218,9 @@ brw_nir_analyze_ubo_ranges(const struct brw_compiler *compiler, } /* Walk the IR, recording how many times each UBO block/offset is used. */ - nir_foreach_function(function, nir) { - if (function->impl) { - nir_foreach_block(block, function->impl) { - analyze_ubos_block(&state, block); - } + nir_foreach_function_impl(impl, nir) { + nir_foreach_block(block, impl) { + analyze_ubos_block(&state, block); } } diff --git a/src/intel/compiler/brw_nir_lower_cs_intrinsics.c b/src/intel/compiler/brw_nir_lower_cs_intrinsics.c index 679c44b7aad..8c5603ea459 100644 --- a/src/intel/compiler/brw_nir_lower_cs_intrinsics.c +++ b/src/intel/compiler/brw_nir_lower_cs_intrinsics.c @@ -311,11 +311,9 @@ brw_nir_lower_cs_intrinsics(nir_shader *nir) } } - nir_foreach_function(function, nir) { - if (function->impl) { - state.impl = function->impl; - lower_cs_intrinsics_convert_impl(&state); - } + nir_foreach_function_impl(impl, nir) { + state.impl = impl; + lower_cs_intrinsics_convert_impl(&state); } return state.progress; diff --git a/src/intel/compiler/brw_nir_lower_rt_intrinsics.c b/src/intel/compiler/brw_nir_lower_rt_intrinsics.c index b4d8b1e931f..db3f0cda608 100644 --- a/src/intel/compiler/brw_nir_lower_rt_intrinsics.c +++ b/src/intel/compiler/brw_nir_lower_rt_intrinsics.c @@ -382,8 +382,7 @@ void brw_nir_lower_rt_intrinsics(nir_shader *nir, const struct intel_device_info *devinfo) { - nir_foreach_function(function, nir) { - if (function->impl) - lower_rt_intrinsics_impl(function->impl, devinfo); + nir_foreach_function_impl(impl, nir) { + lower_rt_intrinsics_impl(impl, devinfo); } } diff --git a/src/intel/compiler/brw_nir_lower_shader_calls.c b/src/intel/compiler/brw_nir_lower_shader_calls.c index 7e7fac037b4..8891420fbf8 100644 --- a/src/intel/compiler/brw_nir_lower_shader_calls.c +++ b/src/intel/compiler/brw_nir_lower_shader_calls.c @@ -28,11 +28,8 @@ UNUSED static bool no_load_scratch_base_ptr_intrinsic(nir_shader *shader) { - nir_foreach_function(func, shader) { - if (!func->impl) - continue; - - nir_foreach_block(block, func->impl) { + nir_foreach_function_impl(impl, shader) { + nir_foreach_block(block, impl) { nir_foreach_instr(instr, block) { if (instr->type != nir_instr_type_intrinsic) continue;