intel/compiler: Switch to use nir_foreach_function_impl

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23920>
This commit is contained in:
Yonggang Luo
2023-06-28 19:40:56 +08:00
committed by Marge Bot
parent 46df42c4e8
commit 68b8aa788d
9 changed files with 41 additions and 72 deletions

View File

@@ -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);
}

View File

@@ -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");

View File

@@ -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;

View File

@@ -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,15 +432,13 @@ 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) {
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);
}
}
}
}
static bool
@@ -593,14 +585,12 @@ 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) {
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);
}
}
}
}
void
@@ -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",

View File

@@ -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);
}
}

View File

@@ -218,13 +218,11 @@ 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) {
nir_foreach_function_impl(impl, nir) {
nir_foreach_block(block, impl) {
analyze_ubos_block(&state, block);
}
}
}
/* Find ranges: a block, starting 32-byte offset, and length. */
struct util_dynarray ranges;

View File

@@ -311,12 +311,10 @@ brw_nir_lower_cs_intrinsics(nir_shader *nir)
}
}
nir_foreach_function(function, nir) {
if (function->impl) {
state.impl = function->impl;
nir_foreach_function_impl(impl, nir) {
state.impl = impl;
lower_cs_intrinsics_convert_impl(&state);
}
}
return state.progress;
}

View File

@@ -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);
}
}

View File

@@ -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;