nir: rename global/local to private/function memory
authorKarol Herbst <kherbst@redhat.com>
Tue, 23 Oct 2018 21:26:22 +0000 (23:26 +0200)
committerKarol Herbst <kherbst@redhat.com>
Tue, 8 Jan 2019 17:51:46 +0000 (18:51 +0100)
the naming is a bit confusing no matter how you look at it. Within SPIR-V
"global" memory is memory accessible from all threads. glsl "global" memory
normally refers to shader thread private memory declared at global scope. As
we already use "shared" for memory shared across all thrads of a work group
the solution where everybody could be happy with is to rename "global" to
"private" and use "global" later for memory usually stored within system
accessible memory (be it VRAM or system RAM if keeping SVM in mind).
glsl "local" memory is memory only accessible within a function, while SPIR-V
"local" memory is memory accessible within the same workgroup.

v2: rename local to function as well
v3: rename vtn_variable_mode_local as well

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
33 files changed:
src/amd/common/ac_nir_to_llvm.c
src/amd/vulkan/radv_shader.c
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_inline_functions.c
src/compiler/nir/nir_linking_helpers.c
src/compiler/nir/nir_lower_clip.c
src/compiler/nir/nir_lower_constant_initializers.c
src/compiler/nir/nir_lower_global_vars_to_local.c
src/compiler/nir/nir_lower_io_to_temporaries.c
src/compiler/nir/nir_lower_locals_to_regs.c
src/compiler/nir/nir_lower_vars_to_ssa.c
src/compiler/nir/nir_opt_copy_prop_vars.c
src/compiler/nir/nir_opt_dead_write_vars.c
src/compiler/nir/nir_opt_find_array_copies.c
src/compiler/nir/nir_opt_large_constants.c
src/compiler/nir/nir_print.c
src/compiler/nir/nir_remove_dead_variables.c
src/compiler/nir/nir_split_vars.c
src/compiler/nir/nir_validate.c
src/compiler/nir/tests/vars_tests.cpp
src/compiler/spirv/vtn_cfg.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c
src/freedreno/ir3/ir3_nir.c
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/gallium/drivers/v3d/v3d_program.c
src/gallium/drivers/vc4/vc4_program.c
src/intel/compiler/brw_nir.c
src/intel/vulkan/anv_pipeline.c
src/mesa/main/glspirv.c
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 5bf91b5171084b0a62804d7c9fa4110c4c6e540e..89c76175291ec02307f1797928ea5cd768616a71 100644 (file)
@@ -1925,7 +1925,7 @@ static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
                                values[chan] = ctx->abi->inputs[idx + chan + const_index * stride];
                }
                break;
-       case nir_var_local:
+       case nir_var_function:
                for (unsigned chan = 0; chan < ve; chan++) {
                        if (indir_index) {
                                unsigned count = glsl_count_attribute_slots(
@@ -2057,7 +2057,7 @@ visit_store_var(struct ac_nir_context *ctx,
                        }
                }
                break;
-       case nir_var_local:
+       case nir_var_function:
                for (unsigned chan = 0; chan < 8; chan++) {
                        if (!(writemask & (1 << chan)))
                                continue;
@@ -4072,7 +4072,7 @@ ac_lower_indirect_derefs(struct nir_shader *nir, enum chip_class chip_class)
         * See the following thread for more details of the problem:
         * https://lists.freedesktop.org/archives/mesa-dev/2017-July/162106.html
         */
-       indirect_mask |= nir_var_local;
+       indirect_mask |= nir_var_function;
 
        nir_lower_indirect_derefs(nir, indirect_mask);
 }
index 9ca586486c40b0f4a9a12ae07be874e24c14d4bd..7d78f62c2c48bec57c6d6191f85e8ccd0faa73e0 100644 (file)
@@ -126,8 +126,8 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively,
         do {
                 progress = false;
 
-               NIR_PASS(progress, shader, nir_split_array_vars, nir_var_local);
-               NIR_PASS(progress, shader, nir_shrink_vec_array_vars, nir_var_local);
+               NIR_PASS(progress, shader, nir_split_array_vars, nir_var_function);
+               NIR_PASS(progress, shader, nir_shrink_vec_array_vars, nir_var_function);
 
                 NIR_PASS_V(shader, nir_lower_vars_to_ssa);
                NIR_PASS_V(shader, nir_lower_pack);
@@ -267,7 +267,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
                 * inline functions.  That way they get properly initialized at the top
                 * of the function and not at the top of its caller.
                 */
-               NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_local);
+               NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_function);
                NIR_PASS_V(nir, nir_lower_returns);
                NIR_PASS_V(nir, nir_inline_functions);
                NIR_PASS_V(nir, nir_opt_deref);
@@ -329,7 +329,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
        nir_split_var_copies(nir);
 
        nir_lower_global_vars_to_local(nir);
-       nir_remove_dead_variables(nir, nir_var_local);
+       nir_remove_dead_variables(nir, nir_var_function);
        nir_lower_subgroups(nir, &(struct nir_lower_subgroups_options) {
                        .subgroup_size = 64,
                        .ballot_bit_size = 64,
index d1a051b1d1883b877f83f8a3c97d4c952cf53ec0..15b74cac2810d2e4b7683de21d7085045c3f6ecb 100644 (file)
@@ -310,16 +310,16 @@ nir_visitor::visit(ir_variable *ir)
    case ir_var_auto:
    case ir_var_temporary:
       if (is_global)
-         var->data.mode = nir_var_global;
+         var->data.mode = nir_var_private;
       else
-         var->data.mode = nir_var_local;
+         var->data.mode = nir_var_function;
       break;
 
    case ir_var_function_in:
    case ir_var_function_out:
    case ir_var_function_inout:
    case ir_var_const_in:
-      var->data.mode = nir_var_local;
+      var->data.mode = nir_var_function;
       break;
 
    case ir_var_shader_in:
@@ -448,7 +448,7 @@ nir_visitor::visit(ir_variable *ir)
 
    var->interface_type = ir->get_interface_type();
 
-   if (var->data.mode == nir_var_local)
+   if (var->data.mode == nir_var_function)
       nir_function_impl_add_variable(impl, var);
    else
       nir_shader_add_variable(shader, var);
@@ -1454,7 +1454,7 @@ nir_visitor::visit(ir_expression *ir)
           * sense, we'll just turn it into a load which will probably
           * eventually end up as an SSA definition.
           */
-         assert(this->deref->mode == nir_var_global);
+         assert(this->deref->mode == nir_var_private);
          op = nir_intrinsic_load_deref;
       }
 
index 07bb96dc3b02ae94e9b1f3ba47f05511113e16fe..99e5925cd0ba2489224d7066ea06edcadeb70f43 100644 (file)
@@ -125,11 +125,11 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var)
       assert(!"invalid mode");
       break;
 
-   case nir_var_local:
+   case nir_var_function:
       assert(!"nir_shader_add_variable cannot be used for local variables");
       break;
 
-   case nir_var_global:
+   case nir_var_private:
       exec_list_push_tail(&shader->globals, &var->node);
       break;
 
@@ -189,7 +189,7 @@ nir_local_variable_create(nir_function_impl *impl,
    nir_variable *var = rzalloc(impl->function->shader, nir_variable);
    var->name = ralloc_strdup(var, name);
    var->type = type;
-   var->data.mode = nir_var_local;
+   var->data.mode = nir_var_function;
 
    nir_function_impl_add_variable(impl, var);
 
index 8db7cc44aef01353c2b8de3dfdb3a96e003e2051..76c09069985827dc3a2c7acf882353cf336c1fad 100644 (file)
@@ -97,8 +97,8 @@ typedef struct {
 typedef enum {
    nir_var_shader_in       = (1 << 0),
    nir_var_shader_out      = (1 << 1),
-   nir_var_global          = (1 << 2),
-   nir_var_local           = (1 << 3),
+   nir_var_private         = (1 << 2),
+   nir_var_function        = (1 << 3),
    nir_var_uniform         = (1 << 4),
    nir_var_ubo             = (1 << 5),
    nir_var_system_value    = (1 << 6),
@@ -441,7 +441,7 @@ typedef struct nir_variable {
 static inline bool
 nir_variable_is_global(const nir_variable *var)
 {
-   return var->data.mode != nir_var_local;
+   return var->data.mode != nir_var_function;
 }
 
 typedef struct nir_register {
@@ -2310,7 +2310,7 @@ void nir_shader_add_variable(nir_shader *shader, nir_variable *var);
 static inline void
 nir_function_impl_add_variable(nir_function_impl *impl, nir_variable *var)
 {
-   assert(var->data.mode == nir_var_local);
+   assert(var->data.mode == nir_var_function);
    exec_list_push_tail(&impl->locals, &var->node);
 }
 
index 864638d23154b9405bdbaf4a29d7840075c92998..dd2dfa04cfcc514bdfb300a686b4ceba19165dec 100644 (file)
@@ -137,7 +137,7 @@ inline_function_impl(nir_function_impl *impl, struct set *inlined)
  * For most use-cases, function inlining is a multi-step process.  The general
  * pattern employed by SPIR-V consumers and others is as follows:
  *
- *  1. nir_lower_constant_initializers(shader, nir_var_local)
+ *  1. nir_lower_constant_initializers(shader, nir_var_function)
  *
  *     This is needed because local variables from the callee are simply added
  *     to the locals list for the caller and the information about where the
@@ -192,7 +192,7 @@ inline_function_impl(nir_function_impl *impl, struct set *inlined)
  *    spirv_to_nir returns the root function and so we can just use == whereas
  *    with GL, you may have to look for a function named "main".
  *
- *  6. nir_lower_constant_initializers(shader, ~nir_var_local)
+ *  6. nir_lower_constant_initializers(shader, ~nir_var_function)
  *
  *     Lowering constant initializers on inputs, outputs, global variables,
  *     etc. requires that we know the main entrypoint so that we know where to
index f2e8ec94ad966625521dc220b6b414d22f15ba9b..2e89aa7dd19bf6895470c842238bc169aa63589b 100644 (file)
@@ -133,7 +133,7 @@ nir_remove_unused_io_vars(nir_shader *shader, struct exec_list *var_list,
       if (!(other_stage & get_variable_io_mask(var, shader->info.stage))) {
          /* This one is invalid, make it a global variable instead */
          var->data.location = 0;
-         var->data.mode = nir_var_global;
+         var->data.mode = nir_var_private;
 
          exec_node_remove(&var->node);
          exec_list_push_tail(&shader->globals, &var->node);
index 880d65c617bcef120cd40def526d3f320d2c1f14..6fdf1a9b008729bb0b219d8cd3b6d0edb87bc9f5 100644 (file)
@@ -212,7 +212,7 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables, bool use_vars)
 
       if (clipvertex) {
          exec_node_remove(&clipvertex->node);
-         clipvertex->data.mode = nir_var_global;
+         clipvertex->data.mode = nir_var_private;
          exec_list_push_tail(&shader->globals, &clipvertex->node);
       }
    } else {
index 4e9cea46157736ff3c7c6c87ce8b7a0edec7329b..b213576bbd55b86a0cabbb749bd1d2a1e06b6e1d 100644 (file)
@@ -92,13 +92,13 @@ nir_lower_constant_initializers(nir_shader *shader, nir_variable_mode modes)
    bool progress = false;
 
    nir_builder builder;
-   if (modes & ~nir_var_local)
+   if (modes & ~nir_var_function)
       nir_builder_init(&builder, nir_shader_get_entrypoint(shader));
 
    if (modes & nir_var_shader_out)
       progress |= lower_const_initializer(&builder, &shader->outputs);
 
-   if (modes & nir_var_global)
+   if (modes & nir_var_private)
       progress |= lower_const_initializer(&builder, &shader->globals);
 
    if (modes & nir_var_system_value)
@@ -114,7 +114,7 @@ nir_lower_constant_initializers(nir_shader *shader, nir_variable_mode modes)
       }
    }
 
-   if (modes & nir_var_local) {
+   if (modes & nir_var_function) {
       nir_foreach_function(function, shader) {
          if (!function->impl)
             continue;
index be99cf9ad02c84c6dd26cf52832604da3dfb3048..7cc1b2cb69ea87cb30a2686f61e5eadb03059adf 100644 (file)
@@ -36,7 +36,7 @@ static void
 register_var_use(nir_variable *var, nir_function_impl *impl,
                  struct hash_table *var_func_table)
 {
-   if (var->data.mode != nir_var_global)
+   if (var->data.mode != nir_var_private)
       return;
 
    struct hash_entry *entry =
@@ -89,11 +89,11 @@ nir_lower_global_vars_to_local(nir_shader *shader)
       nir_variable *var = (void *)entry->key;
       nir_function_impl *impl = entry->data;
 
-      assert(var->data.mode == nir_var_global);
+      assert(var->data.mode == nir_var_private);
 
       if (impl != NULL) {
          exec_node_remove(&var->node);
-         var->data.mode = nir_var_local;
+         var->data.mode = nir_var_function;
          exec_list_push_tail(&impl->locals, &var->node);
          nir_metadata_preserve(impl, nir_metadata_block_index |
                                      nir_metadata_dominance |
index b83aaf46e6a663cddfb14d1b0bd91639f21b2f5c..2487add33ed5c036956c43fd3e0a9d13005b4f81 100644 (file)
@@ -134,7 +134,7 @@ create_shadow_temp(struct lower_io_state *state, nir_variable *var)
    /* Give the original a new name with @<mode>-temp appended */
    const char *mode = (temp->data.mode == nir_var_shader_in) ? "in" : "out";
    temp->name = ralloc_asprintf(var, "%s@%s-temp", mode, nvar->name);
-   temp->data.mode = nir_var_global;
+   temp->data.mode = nir_var_private;
    temp->data.read_only = false;
    temp->data.fb_fetch_output = false;
    temp->data.compact = false;
index 773b7fde6d0fdc0a633e514e6736b811ac8eb11b..3b77119b6f8fa8de26174a4ee8bb349d26db858f 100644 (file)
@@ -192,7 +192,7 @@ lower_locals_to_regs_block(nir_block *block,
       switch (intrin->intrinsic) {
       case nir_intrinsic_load_deref: {
          nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
-         if (deref->mode != nir_var_local)
+         if (deref->mode != nir_var_function)
             continue;
 
          b->cursor = nir_before_instr(&intrin->instr);
@@ -218,7 +218,7 @@ lower_locals_to_regs_block(nir_block *block,
 
       case nir_intrinsic_store_deref: {
          nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
-         if (deref->mode != nir_var_local)
+         if (deref->mode != nir_var_function)
             continue;
 
          b->cursor = nir_before_instr(&intrin->instr);
index 646efd9ad8978605d0d0701f57d77202be49c61b..98f3169f6acbe0a625210e7bc10a82c948072a85 100644 (file)
@@ -208,7 +208,7 @@ get_deref_node(nir_deref_instr *deref, struct lower_variables_state *state)
    /* This pass only works on local variables.  Just ignore any derefs with
     * a non-local mode.
     */
-   if (deref->mode != nir_var_local)
+   if (deref->mode != nir_var_function)
       return NULL;
 
    struct deref_node *node = get_deref_node_recur(deref, state);
@@ -507,7 +507,7 @@ rename_variables(struct lower_variables_state *state)
          switch (intrin->intrinsic) {
          case nir_intrinsic_load_deref: {
             nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
-            if (deref->mode != nir_var_local)
+            if (deref->mode != nir_var_function)
                continue;
 
             struct deref_node *node = get_deref_node(deref, state);
@@ -557,7 +557,7 @@ rename_variables(struct lower_variables_state *state)
 
          case nir_intrinsic_store_deref: {
             nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
-            if (deref->mode != nir_var_local)
+            if (deref->mode != nir_var_function)
                continue;
 
             struct deref_node *node = get_deref_node(deref, state);
@@ -685,7 +685,7 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
       assert(path->path[0]->deref_type == nir_deref_type_var);
 
       /* We don't build deref nodes for non-local variables */
-      assert(path->path[0]->var->data.mode == nir_var_local);
+      assert(path->path[0]->var->data.mode == nir_var_function);
 
       if (path_may_be_aliased(path, &state)) {
          exec_node_remove(&node->direct_derefs_link);
index 36403e87e8f0677a4be01eeced432dc26dad7cc2..28c93d359100d3352d8d0ecc6cd449a45dfab64e 100644 (file)
@@ -134,8 +134,8 @@ gather_vars_written(struct copy_prop_var_state *state,
       nir_foreach_instr(instr, block) {
          if (instr->type == nir_instr_type_call) {
             written->modes |= nir_var_shader_out |
-                              nir_var_global |
-                              nir_var_local |
+                              nir_var_private |
+                              nir_var_function |
                               nir_var_ssbo |
                               nir_var_shared;
             continue;
@@ -615,8 +615,8 @@ copy_prop_vars_block(struct copy_prop_var_state *state,
    nir_foreach_instr_safe(instr, block) {
       if (instr->type == nir_instr_type_call) {
          apply_barrier_for_modes(copies, nir_var_shader_out |
-                                         nir_var_global |
-                                         nir_var_local |
+                                         nir_var_private |
+                                         nir_var_function |
                                          nir_var_ssbo |
                                          nir_var_shared);
          continue;
index 2ae5f78b7911823c6c0ce03dd1ceaeffd90e54c6..49c71cced213233d0bb09957a3e6efa0aceab8c2 100644 (file)
@@ -119,8 +119,8 @@ remove_dead_write_vars_local(void *mem_ctx, nir_block *block)
    nir_foreach_instr_safe(instr, block) {
       if (instr->type == nir_instr_type_call) {
          clear_unused_for_modes(&unused_writes, nir_var_shader_out |
-                                                nir_var_global |
-                                                nir_var_local |
+                                                nir_var_private |
+                                                nir_var_function |
                                                 nir_var_ssbo |
                                                 nir_var_shared);
          continue;
index 5cfcd73b6b87ee3635f86b6ca2406199acb1dfcf..40ba5e21f2c8ac1752f1a32f92b6013ab2662c96 100644 (file)
@@ -225,7 +225,7 @@ opt_find_array_copies_block(nir_builder *b, nir_block *block,
        * continue on because it won't affect local stores or read-only
        * variables.
        */
-      if (dst_deref->mode != nir_var_local)
+      if (dst_deref->mode != nir_var_function)
          continue;
 
       /* We keep track of the SSA indices where the two last-written
@@ -273,7 +273,7 @@ opt_find_array_copies_block(nir_builder *b, nir_block *block,
        */
       const nir_variable_mode read_only_modes =
          nir_var_shader_in | nir_var_uniform | nir_var_system_value;
-      if (!(src_deref->mode & (nir_var_local | read_only_modes)))
+      if (!(src_deref->mode & (nir_var_function | read_only_modes)))
          goto reset;
 
       /* If we don't yet have an active copy, then make this instruction the
index aa22f05d8099d5a8082e5485ca9114854344e439..282c73a40bdc13f3e2c29e0faa586fd0dacd0e31 100644 (file)
@@ -196,9 +196,9 @@ nir_opt_large_constants(nir_shader *shader,
             continue;
          }
 
-         if (dst_deref && dst_deref->mode == nir_var_local) {
+         if (dst_deref && dst_deref->mode == nir_var_function) {
             nir_variable *var = nir_deref_instr_get_variable(dst_deref);
-            assert(var->data.mode == nir_var_local);
+            assert(var->data.mode == nir_var_function);
 
             /* We only consider variables constant if they only have constant
              * stores, all the stores come before any reads, and all stores
@@ -210,9 +210,9 @@ nir_opt_large_constants(nir_shader *shader,
                info->is_constant = false;
          }
 
-         if (src_deref && src_deref->mode == nir_var_local) {
+         if (src_deref && src_deref->mode == nir_var_function) {
             nir_variable *var = nir_deref_instr_get_variable(src_deref);
-            assert(var->data.mode == nir_var_local);
+            assert(var->data.mode == nir_var_function);
 
             var_infos[var->data.index].found_read = true;
          }
@@ -258,7 +258,7 @@ nir_opt_large_constants(nir_shader *shader,
          switch (intrin->intrinsic) {
          case nir_intrinsic_load_deref: {
             nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
-            if (deref->mode != nir_var_local)
+            if (deref->mode != nir_var_function)
                continue;
 
             nir_variable *var = nir_deref_instr_get_variable(deref);
@@ -276,7 +276,7 @@ nir_opt_large_constants(nir_shader *shader,
 
          case nir_intrinsic_store_deref: {
             nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
-            if (deref->mode != nir_var_local)
+            if (deref->mode != nir_var_function)
                continue;
 
             nir_variable *var = nir_deref_instr_get_variable(deref);
@@ -292,7 +292,7 @@ nir_opt_large_constants(nir_shader *shader,
 
          case nir_intrinsic_copy_deref: {
             nir_deref_instr *deref = nir_src_as_deref(intrin->src[1]);
-            if (deref->mode != nir_var_local)
+            if (deref->mode != nir_var_function)
                continue;
 
             nir_variable *var = nir_deref_instr_get_variable(deref);
index 696839a69b124acfeb9291a836352c339db29a3e..cfbc8be7a2c23b92a01296b837c64fe083e6f0e5 100644 (file)
@@ -421,10 +421,10 @@ get_variable_mode_str(nir_variable_mode mode, bool want_local_global_mode)
       return "ssbo";
    case nir_var_shared:
       return "shared";
-   case nir_var_global:
-      return want_local_global_mode ? "global" : "";
-   case nir_var_local:
-      return want_local_global_mode ? "local" : "";
+   case nir_var_private:
+      return want_local_global_mode ? "private" : "";
+   case nir_var_function:
+      return want_local_global_mode ? "function" : "";
    default:
       return "";
    }
index 5e972491a1c2bfcfa031563372975022449ed9a8..a8a347b6a67b223324b707f57254f746cefafaf7 100644 (file)
@@ -71,7 +71,7 @@ add_var_use_deref(nir_deref_instr *deref, struct set *live)
     * all means we need to keep it alive.
     */
    assert(deref->mode == deref->var->data.mode);
-   if (!(deref->mode & (nir_var_local | nir_var_global | nir_var_shared)) ||
+   if (!(deref->mode & (nir_var_function | nir_var_private | nir_var_shared)) ||
        deref_used_for_not_store(deref))
       _mesa_set_add(live, deref->var);
 }
@@ -178,7 +178,7 @@ nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes)
    if (modes & nir_var_shader_out)
       progress = remove_dead_vars(&shader->outputs, live) || progress;
 
-   if (modes & nir_var_global)
+   if (modes & nir_var_private)
       progress = remove_dead_vars(&shader->globals, live) || progress;
 
    if (modes & nir_var_system_value)
@@ -187,7 +187,7 @@ nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes)
    if (modes & nir_var_shared)
       progress = remove_dead_vars(&shader->shared, live) || progress;
 
-   if (modes & nir_var_local) {
+   if (modes & nir_var_function) {
       nir_foreach_function(function, shader) {
          if (function->impl) {
             if (remove_dead_vars(&function->impl->locals, live))
index e738ee3f3859756cfd2a206a57cc03c15cbfa50e..5044d29f146e5f63165f94578dff7a425d4d89a1 100644 (file)
@@ -115,7 +115,7 @@ init_field_for_type(struct field *field, struct field *parent,
          var_type = wrap_type_in_array(var_type, f->type);
 
       nir_variable_mode mode = state->base_var->data.mode;
-      if (mode == nir_var_local) {
+      if (mode == nir_var_function) {
          field->var = nir_local_variable_create(state->impl, var_type, name);
       } else {
          field->var = nir_variable_create(state->shader, mode, var_type, name);
@@ -260,10 +260,10 @@ nir_split_struct_vars(nir_shader *shader, nir_variable_mode modes)
       _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
                               _mesa_key_pointer_equal);
 
-   assert((modes & (nir_var_global | nir_var_local)) == modes);
+   assert((modes & (nir_var_private | nir_var_function)) == modes);
 
    bool has_global_splits = false;
-   if (modes & nir_var_global) {
+   if (modes & nir_var_private) {
       has_global_splits = split_var_list_structs(shader, NULL,
                                                  &shader->globals,
                                                  var_field_map, mem_ctx);
@@ -275,7 +275,7 @@ nir_split_struct_vars(nir_shader *shader, nir_variable_mode modes)
          continue;
 
       bool has_local_splits = false;
-      if (modes & nir_var_local) {
+      if (modes & nir_var_function) {
          has_local_splits = split_var_list_structs(shader, function->impl,
                                                    &function->impl->locals,
                                                    var_field_map, mem_ctx);
@@ -455,7 +455,7 @@ create_split_array_vars(struct array_var_info *var_info,
       name = ralloc_asprintf(mem_ctx, "(%s)", name);
 
       nir_variable_mode mode = var_info->base_var->data.mode;
-      if (mode == nir_var_local) {
+      if (mode == nir_var_function) {
          split->var = nir_local_variable_create(impl,
                                                 var_info->split_var_type, name);
       } else {
@@ -797,10 +797,10 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
       _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
                               _mesa_key_pointer_equal);
 
-   assert((modes & (nir_var_global | nir_var_local)) == modes);
+   assert((modes & (nir_var_private | nir_var_function)) == modes);
 
    bool has_global_array = false;
-   if (modes & nir_var_global) {
+   if (modes & nir_var_private) {
       has_global_array = init_var_list_array_infos(&shader->globals,
                                                    var_info_map, mem_ctx);
    }
@@ -811,7 +811,7 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
          continue;
 
       bool has_local_array = false;
-      if (modes & nir_var_local) {
+      if (modes & nir_var_function) {
          has_local_array = init_var_list_array_infos(&function->impl->locals,
                                                      var_info_map, mem_ctx);
       }
@@ -829,7 +829,7 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
    }
 
    bool has_global_splits = false;
-   if (modes & nir_var_global) {
+   if (modes & nir_var_private) {
       has_global_splits = split_var_list_arrays(shader, NULL,
                                                 &shader->globals,
                                                 var_info_map, mem_ctx);
@@ -841,7 +841,7 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
          continue;
 
       bool has_local_splits = false;
-      if (modes & nir_var_local) {
+      if (modes & nir_var_function) {
          has_local_splits = split_var_list_arrays(shader, function->impl,
                                                   &function->impl->locals,
                                                   var_info_map, mem_ctx);
@@ -1497,10 +1497,10 @@ function_impl_has_vars_with_modes(nir_function_impl *impl,
 {
    nir_shader *shader = impl->function->shader;
 
-   if ((modes & nir_var_global) && !exec_list_is_empty(&shader->globals))
+   if ((modes & nir_var_private) && !exec_list_is_empty(&shader->globals))
       return true;
 
-   if ((modes & nir_var_local) && !exec_list_is_empty(&impl->locals))
+   if ((modes & nir_var_function) && !exec_list_is_empty(&impl->locals))
       return true;
 
    return false;
@@ -1518,7 +1518,7 @@ function_impl_has_vars_with_modes(nir_function_impl *impl,
 bool
 nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)
 {
-   assert((modes & (nir_var_global | nir_var_local)) == modes);
+   assert((modes & (nir_var_private | nir_var_function)) == modes);
 
    void *mem_ctx = ralloc_context(NULL);
 
@@ -1547,7 +1547,7 @@ nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)
    }
 
    bool globals_shrunk = false;
-   if (modes & nir_var_global)
+   if (modes & nir_var_private)
       globals_shrunk = shrink_vec_var_list(&shader->globals, var_usage_map);
 
    bool progress = false;
@@ -1556,7 +1556,7 @@ nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)
          continue;
 
       bool locals_shrunk = false;
-      if (modes & nir_var_local) {
+      if (modes & nir_var_function) {
          locals_shrunk = shrink_vec_var_list(&function->impl->locals,
                                              var_usage_map);
       }
index dc7b5b5f1128f908f48bed1982fd2882468f82ce..f506b54d3b5eb7d80c5b9c3ad4d48e47df355568 100644 (file)
@@ -397,7 +397,7 @@ validate_var_use(nir_variable *var, validate_state *state)
 {
    struct hash_entry *entry = _mesa_hash_table_search(state->var_defs, var);
    validate_assert(state, entry);
-   if (var->data.mode == nir_var_local)
+   if (var->data.mode == nir_var_function)
       validate_assert(state, (nir_function_impl *) entry->data == state->impl);
 }
 
index 74bf5c050238f61fb033e1bbb570a3bcd55d23e2..8e187b4646a298a4a629420dd3330ae4fceda2f8 100644 (file)
@@ -34,14 +34,14 @@ protected:
    ~nir_vars_test();
 
    nir_variable *create_int(nir_variable_mode mode, const char *name) {
-      if (mode == nir_var_local)
+      if (mode == nir_var_function)
          return nir_local_variable_create(b->impl, glsl_int_type(), name);
       return nir_variable_create(b->shader, mode, glsl_int_type(), name);
    }
 
    nir_variable *create_ivec2(nir_variable_mode mode, const char *name) {
       const glsl_type *var_type = glsl_vector_type(GLSL_TYPE_INT, 2);
-      if (mode == nir_var_local)
+      if (mode == nir_var_function)
          return nir_local_variable_create(b->impl, var_type, name);
       return nir_variable_create(b->shader, mode, var_type, name);
    }
@@ -191,7 +191,7 @@ TEST_F(nir_redundant_load_vars_test, invalidate_inside_if_block)
     * if statement.  They should be invalidated accordingly.
     */
 
-   nir_variable **g = create_many_int(nir_var_global, "g", 3);
+   nir_variable **g = create_many_int(nir_var_private, "g", 3);
    nir_variable **out = create_many_int(nir_var_shader_out, "out", 3);
 
    nir_load_var(b, g[0]);
@@ -259,7 +259,7 @@ TEST_F(nir_redundant_load_vars_test, invalidate_live_load_in_the_end_of_loop)
 TEST_F(nir_copy_prop_vars_test, simple_copies)
 {
    nir_variable *in   = create_int(nir_var_shader_in,  "in");
-   nir_variable *temp = create_int(nir_var_local,      "temp");
+   nir_variable *temp = create_int(nir_var_function,   "temp");
    nir_variable *out  = create_int(nir_var_shader_out, "out");
 
    nir_copy_var(b, temp, in);
@@ -284,7 +284,7 @@ TEST_F(nir_copy_prop_vars_test, simple_copies)
 
 TEST_F(nir_copy_prop_vars_test, simple_store_load)
 {
-   nir_variable **v = create_many_ivec2(nir_var_local, "v", 2);
+   nir_variable **v = create_many_ivec2(nir_var_function, "v", 2);
    unsigned mask = 1 | 2;
 
    nir_ssa_def *stored_value = nir_imm_ivec2(b, 10, 20);
@@ -312,7 +312,7 @@ TEST_F(nir_copy_prop_vars_test, simple_store_load)
 
 TEST_F(nir_copy_prop_vars_test, store_store_load)
 {
-   nir_variable **v = create_many_ivec2(nir_var_local, "v", 2);
+   nir_variable **v = create_many_ivec2(nir_var_function, "v", 2);
    unsigned mask = 1 | 2;
 
    nir_ssa_def *first_value = nir_imm_ivec2(b, 10, 20);
@@ -345,7 +345,7 @@ TEST_F(nir_copy_prop_vars_test, store_store_load)
 
 TEST_F(nir_copy_prop_vars_test, store_store_load_different_components)
 {
-   nir_variable **v = create_many_ivec2(nir_var_local, "v", 2);
+   nir_variable **v = create_many_ivec2(nir_var_function, "v", 2);
 
    nir_ssa_def *first_value = nir_imm_ivec2(b, 10, 20);
    nir_store_var(b, v[0], first_value, 1 << 1);
@@ -384,7 +384,7 @@ TEST_F(nir_copy_prop_vars_test, store_store_load_different_components)
 
 TEST_F(nir_copy_prop_vars_test, store_store_load_different_components_in_many_blocks)
 {
-   nir_variable **v = create_many_ivec2(nir_var_local, "v", 2);
+   nir_variable **v = create_many_ivec2(nir_var_function, "v", 2);
 
    nir_ssa_def *first_value = nir_imm_ivec2(b, 10, 20);
    nir_store_var(b, v[0], first_value, 1 << 1);
@@ -459,7 +459,7 @@ TEST_F(nir_copy_prop_vars_test, memory_barrier_in_two_blocks)
 
 TEST_F(nir_copy_prop_vars_test, simple_store_load_in_two_blocks)
 {
-   nir_variable **v = create_many_ivec2(nir_var_local, "v", 2);
+   nir_variable **v = create_many_ivec2(nir_var_function, "v", 2);
    unsigned mask = 1 | 2;
 
    nir_ssa_def *stored_value = nir_imm_ivec2(b, 10, 20);
index 9cec036d46217f76c5056bd65d80e62f9754f7c3..aef1b7e18fb68a372828acb75323ba4f91cf4a94 100644 (file)
@@ -884,7 +884,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list,
                glsl_get_bare_type(b->func->type->return_type->type);
             nir_deref_instr *ret_deref =
                nir_build_deref_cast(&b->nb, nir_load_param(&b->nb, 0),
-                                    nir_var_local, ret_type, 0);
+                                    nir_var_function, ret_type, 0);
             vtn_local_store(b, src, ret_deref);
          }
 
index bfc4b95d999f0ce88f701458aa6e11ca047842d6..a54cb8c6495b8b4022353554bf8502570bec3877 100644 (file)
@@ -412,8 +412,8 @@ struct vtn_access_chain {
 };
 
 enum vtn_variable_mode {
-   vtn_variable_mode_local,
-   vtn_variable_mode_global,
+   vtn_variable_mode_function,
+   vtn_variable_mode_private,
    vtn_variable_mode_uniform,
    vtn_variable_mode_ubo,
    vtn_variable_mode_ssbo,
index 90fcc605a459496f51eae8f3998326a890a28ddb..50cd1b42c691cb854efc47a1dd106423de94b3eb 100644 (file)
@@ -1691,12 +1691,12 @@ vtn_storage_class_to_mode(struct vtn_builder *b,
       nir_mode = nir_var_shader_out;
       break;
    case SpvStorageClassPrivate:
-      mode = vtn_variable_mode_global;
-      nir_mode = nir_var_global;
+      mode = vtn_variable_mode_private;
+      nir_mode = nir_var_private;
       break;
    case SpvStorageClassFunction:
-      mode = vtn_variable_mode_local;
-      nir_mode = nir_var_local;
+      mode = vtn_variable_mode_function;
+      nir_mode = nir_var_function;
       break;
    case SpvStorageClassWorkgroup:
       mode = vtn_variable_mode_workgroup;
@@ -1922,8 +1922,8 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
    val->pointer = vtn_pointer_for_variable(b, var, ptr_type);
 
    switch (var->mode) {
-   case vtn_variable_mode_local:
-   case vtn_variable_mode_global:
+   case vtn_variable_mode_function:
+   case vtn_variable_mode_private:
    case vtn_variable_mode_uniform:
       /* For these, we create the variable normally */
       var->var = rzalloc(b->shader, nir_variable);
@@ -2068,7 +2068,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
          var->var->data.image.format = without_array->image_format;
    }
 
-   if (var->mode == vtn_variable_mode_local) {
+   if (var->mode == vtn_variable_mode_function) {
       vtn_assert(var->var != NULL && var->var->members == NULL);
       nir_function_impl_add_variable(b->nb.impl, var->var);
    } else if (var->var) {
index f5db5d151efe68e5f017096363cb79d1a667e3a0..e865ac9820595f399a73a324583016e12974cd83 100644 (file)
@@ -194,7 +194,7 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
        if (OPT(s, nir_lower_idiv))
                ir3_optimize_loop(s);
 
-       OPT_V(s, nir_remove_dead_variables, nir_var_local);
+       OPT_V(s, nir_remove_dead_variables, nir_var_function);
 
        OPT_V(s, nir_move_load_const);
 
index 0f365d9ebe0544ef437cb33cca84cb3fda365186..d4b9d2936954e23674e99919846434a8f3796541 100644 (file)
@@ -182,7 +182,7 @@ ttn_emit_declaration(struct ttn_compile *c)
          nir_variable *var = rzalloc(b->shader, nir_variable);
 
          var->type = glsl_array_type(glsl_vec4_type(), array_size, 0);
-         var->data.mode = nir_var_global;
+         var->data.mode = nir_var_private;
          var->name = ralloc_asprintf(var, "arr_%d", decl->Array.ArrayID);
 
          exec_list_push_tail(&b->shader->globals, &var->node);
index 03c45fffbdb40ad20537280fc0fcc5577b7c18b7..de9cc9ad5c8c5475a6578c4f0f4310021b547462 100644 (file)
@@ -296,7 +296,7 @@ v3d_shader_state_create(struct pipe_context *pctx,
 
         v3d_optimize_nir(s);
 
-        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_local);
+        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function);
 
         /* Garbage collect dead instructions */
         nir_sweep(s);
index fb75c07e2667dc9941365cf070ae67e3439dd868..a0c009f424cce393d114184cd8bccfaec1a75f40 100644 (file)
@@ -1598,7 +1598,7 @@ vc4_optimize_nir(struct nir_shader *s)
                 NIR_PASS(progress, s, nir_opt_loop_unroll,
                          nir_var_shader_in |
                          nir_var_shader_out |
-                         nir_var_local);
+                         nir_var_function);
         } while (progress);
 }
 
@@ -2517,7 +2517,7 @@ vc4_shader_state_create(struct pipe_context *pctx,
 
         vc4_optimize_nir(s);
 
-        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_local);
+        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function);
 
         /* Garbage collect dead instructions */
         nir_sweep(s);
index 9ba3fca4e0c3f297174eae606a4f612350aab372..77c6c4e0e5aef0ca7e8cc3f20e23057a33154cee 100644 (file)
@@ -527,7 +527,7 @@ brw_nir_no_indirect_mask(const struct brw_compiler *compiler,
    if (compiler->glsl_compiler_options[stage].EmitNoIndirectOutput)
       indirect_mask |= nir_var_shader_out;
    if (compiler->glsl_compiler_options[stage].EmitNoIndirectTemp)
-      indirect_mask |= nir_var_local;
+      indirect_mask |= nir_var_function;
 
    return indirect_mask;
 }
@@ -542,8 +542,8 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler,
    bool progress;
    do {
       progress = false;
-      OPT(nir_split_array_vars, nir_var_local);
-      OPT(nir_shrink_vec_array_vars, nir_var_local);
+      OPT(nir_split_array_vars, nir_var_function);
+      OPT(nir_shrink_vec_array_vars, nir_var_function);
       OPT(nir_lower_vars_to_ssa);
       if (allow_copies) {
          /* Only run this pass in the first call to brw_nir_optimize.  Later
@@ -627,7 +627,7 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler,
    /* Workaround Gfxbench unused local sampler variable which will trigger an
     * assert in the opt_large_constants pass.
     */
-   OPT(nir_remove_dead_variables, nir_var_local);
+   OPT(nir_remove_dead_variables, nir_var_function);
 
    return nir;
 }
@@ -692,7 +692,7 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)
    OPT(nir_lower_global_vars_to_local);
 
    OPT(nir_split_var_copies);
-   OPT(nir_split_struct_vars, nir_var_local);
+   OPT(nir_split_struct_vars, nir_var_function);
 
    /* Run opt_algebraic before int64 lowering so we can hopefully get rid
     * of some int64 instructions.
index 750e258c2d2cae1e0679f23d898a65abc361be9f..d1efaaf060b80068b9922b39853937107e14debe 100644 (file)
@@ -185,7 +185,7 @@ anv_shader_compile_to_nir(struct anv_pipeline *pipeline,
     * inline functions.  That way they get properly initialized at the top
     * of the function and not at the top of its caller.
     */
-   NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_local);
+   NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_function);
    NIR_PASS_V(nir, nir_lower_returns);
    NIR_PASS_V(nir, nir_inline_functions);
    NIR_PASS_V(nir, nir_opt_deref);
@@ -788,7 +788,7 @@ anv_pipeline_link_fs(const struct brw_compiler *compiler,
           !(stage->key.wm.color_outputs_valid & (1 << rt))) {
          /* Unused or out-of-bounds, throw it away */
          deleted_output = true;
-         var->data.mode = nir_var_local;
+         var->data.mode = nir_var_function;
          exec_node_remove(&var->node);
          exec_list_push_tail(&impl->locals, &var->node);
          continue;
index 5ff7ac0495e23cfcaa54a0d41f0f30dd5ae4036d..acad6f42fc75dc1b3f5b02eb3c541af9be473a95 100644 (file)
@@ -243,7 +243,7 @@ _mesa_spirv_to_nir(struct gl_context *ctx,
     * inline functions.  That way they get properly initialized at the top
     * of the function and not at the top of its caller.
     */
-   NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_local);
+   NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_function);
    NIR_PASS_V(nir, nir_lower_returns);
    NIR_PASS_V(nir, nir_inline_functions);
    NIR_PASS_V(nir, nir_opt_deref);
index 5d74524be79986a52b6cb467d5d43daf9f889a19..87e4a37a9d9ddd3fa6422e602f7c156c72ba4d8d 100644 (file)
@@ -103,7 +103,7 @@ st_nir_assign_vs_in_locations(nir_shader *nir)
           * set.
           */
          exec_node_remove(&var->node);
-         var->data.mode = nir_var_global;
+         var->data.mode = nir_var_private;
          exec_list_push_tail(&nir->globals, &var->node);
       }
    }
@@ -616,7 +616,7 @@ st_nir_link_shaders(nir_shader **producer, nir_shader **consumer, bool scalar)
        * See the following thread for more details of the problem:
        * https://lists.freedesktop.org/archives/mesa-dev/2017-July/162106.html
        */
-      nir_variable_mode indirect_mask = nir_var_local;
+      nir_variable_mode indirect_mask = nir_var_function;
 
       NIR_PASS_V(*producer, nir_lower_indirect_derefs, indirect_mask);
       NIR_PASS_V(*consumer, nir_lower_indirect_derefs, indirect_mask);