nir: Add a nir_foreach_function_temp_variable helper

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
This commit is contained in:
Jason Ekstrand
2020-05-20 10:18:14 -05:00
committed by Marge Bot
parent 2956d53400
commit 92dcda5ce9
5 changed files with 10 additions and 4 deletions

View File

@@ -5254,7 +5254,7 @@ setup_locals(struct ac_nir_context *ctx,
{ {
int i, j; int i, j;
ctx->num_locals = 0; 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); unsigned attrib_count = glsl_count_attribute_slots(variable->type, false);
variable->data.driver_location = ctx->num_locals * 4; variable->data.driver_location = ctx->num_locals * 4;
variable->data.location_frac = 0; variable->data.location_frac = 0;

View File

@@ -2750,6 +2750,12 @@ typedef struct {
nir_metadata valid_metadata; nir_metadata valid_metadata;
} nir_function_impl; } 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 * ATTRIBUTE_RETURNS_NONNULL static inline nir_block *
nir_start_block(nir_function_impl *impl) nir_start_block(nir_function_impl *impl)
{ {

View File

@@ -185,7 +185,7 @@ nir_opt_large_constants(nir_shader *shader,
} }
struct var_info *var_infos = ralloc_array(NULL, struct var_info, num_locals); 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_infos[var->index] = (struct var_info) {
.var = var, .var = var,
.is_constant = true, .is_constant = true,

View File

@@ -1431,7 +1431,7 @@ print_function_impl(nir_function_impl *impl, print_state *state)
fprintf(fp, "{\n"); fprintf(fp, "{\n");
nir_foreach_variable(var, &impl->locals) { nir_foreach_function_temp_variable(var, impl) {
fprintf(fp, "\t"); fprintf(fp, "\t");
print_var_decl(var, state); print_var_decl(var, state);
} }

View File

@@ -1178,7 +1178,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state)
state->parent_node = &impl->cf_node; state->parent_node = &impl->cf_node;
exec_list_validate(&impl->locals); 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); validate_var_decl(var, nir_var_function_temp, state);
} }