nir: Add a nir_foreach_function_temp_variable helper
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 20 May 2020 15:18:14 +0000 (10:18 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jul 2020 17:38:58 +0000 (17:38 +0000)
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>

src/amd/llvm/ac_nir_to_llvm.c
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_large_constants.c
src/compiler/nir/nir_print.c
src/compiler/nir/nir_validate.c

index 94b920f748a42babdbca575336a1e09afc620fd0..62b5d15a32b64ceabf5b62f735644dee2398f476 100644 (file)
@@ -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;
index b15de3b5dd304cc6b07580675317d94e0abd1d0e..de26c937722421111744fd1a50d1aac67d2b80cc 100644 (file)
@@ -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)
 {
index ef51c72b7b67149ce756f0b9e56a963df6314c6c..2575407ca0b5b4e3bb72b745a1a1e2f30e364cd2 100644 (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);
-   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,
index fe73746c334520a4cf5859398fa8dd3d8c33fe63..801744cb966f88b6cdf7070d3408b89be34f1fa7 100644 (file)
@@ -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);
    }
index 68396d1108c8559236c460cca898584f84ccc3fd..47beec0fa3f7b479c3c9cf01f2f3b85ba0ef4e3a 100644 (file)
@@ -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);
    }