From: Jason Ekstrand Date: Wed, 20 May 2020 15:18:14 +0000 (-0500) Subject: nir: Add a nir_foreach_function_temp_variable helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=92dcda5ce9185125453ff376957cbf32e348edfe;p=mesa.git nir: Add a nir_foreach_function_temp_variable helper Reviewed-by: Gert Wollny Part-of: --- diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 94b920f748a..62b5d15a32b 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -5254,7 +5254,7 @@ setup_locals(struct ac_nir_context *ctx, { int i, j; ctx->num_locals = 0; - nir_foreach_variable(variable, &func->impl->locals) { + nir_foreach_function_temp_variable(variable, func->impl) { unsigned attrib_count = glsl_count_attribute_slots(variable->type, false); variable->data.driver_location = ctx->num_locals * 4; variable->data.location_frac = 0; diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index b15de3b5dd3..de26c937722 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2750,6 +2750,12 @@ typedef struct { nir_metadata valid_metadata; } nir_function_impl; +#define nir_foreach_function_temp_variable(var, impl) \ + foreach_list_typed(nir_variable, var, node, &(impl)->locals) + +#define nir_foreach_function_temp_variable_safe(var, impl) \ + foreach_list_typed_safe(nir_variable, var, node, &(impl)->locals) + ATTRIBUTE_RETURNS_NONNULL static inline nir_block * nir_start_block(nir_function_impl *impl) { diff --git a/src/compiler/nir/nir_opt_large_constants.c b/src/compiler/nir/nir_opt_large_constants.c index ef51c72b7b6..2575407ca0b 100644 --- a/src/compiler/nir/nir_opt_large_constants.c +++ b/src/compiler/nir/nir_opt_large_constants.c @@ -185,7 +185,7 @@ nir_opt_large_constants(nir_shader *shader, } struct var_info *var_infos = ralloc_array(NULL, struct var_info, num_locals); - nir_foreach_variable(var, &impl->locals) { + nir_foreach_function_temp_variable(var, impl) { var_infos[var->index] = (struct var_info) { .var = var, .is_constant = true, diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index fe73746c334..801744cb966 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -1431,7 +1431,7 @@ print_function_impl(nir_function_impl *impl, print_state *state) fprintf(fp, "{\n"); - nir_foreach_variable(var, &impl->locals) { + nir_foreach_function_temp_variable(var, impl) { fprintf(fp, "\t"); print_var_decl(var, state); } diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 68396d1108c..47beec0fa3f 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -1178,7 +1178,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state) state->parent_node = &impl->cf_node; exec_list_validate(&impl->locals); - nir_foreach_variable(var, &impl->locals) { + nir_foreach_function_temp_variable(var, impl) { validate_var_decl(var, nir_var_function_temp, state); }