[Mesa-dev] [PATCH] nir: remove remaining global register support
Timothy Arceri
timothy.arceri at collabora.com
Mon Aug 1 11:15:13 UTC 2016
On Mon, 2016-08-01 at 15:36 +1000, Timothy Arceri wrote:
> These don't seem to have been used since d1d12efb36074.
> ---
> src/compiler/Makefile.sources | 1 -
> src/compiler/nir/nir.c | 23 -------
> src/compiler/nir/nir.h | 14 ----
> src/compiler/nir/nir_clone.c | 6 +-
> src/compiler/nir/nir_opt_global_to_local.c | 102 ------------------
> ----------
> src/compiler/nir/nir_print.c | 10 +--
> src/compiler/nir/nir_sweep.c | 1 -
> src/compiler/nir/nir_validate.c | 39 +++--------
> src/gallium/drivers/freedreno/ir3/ir3_nir.c | 1 -
> src/gallium/drivers/vc4/vc4_program.c | 2 -
> 10 files changed, 10 insertions(+), 189 deletions(-)
> delete mode 100644 src/compiler/nir/nir_opt_global_to_local.c
>
> diff --git a/src/compiler/Makefile.sources
> b/src/compiler/Makefile.sources
> index 0ff9b23..e23c52a 100644
> --- a/src/compiler/Makefile.sources
> +++ b/src/compiler/Makefile.sources
> @@ -224,7 +224,6 @@ NIR_FILES = \
> nir/nir_opt_dce.c \
> nir/nir_opt_dead_cf.c \
> nir/nir_opt_gcm.c \
> - nir/nir_opt_global_to_local.c \
> nir/nir_opt_peephole_select.c \
> nir/nir_opt_remove_phis.c \
> nir/nir_opt_undef.c \
> diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
> index 6bebb73..c0cc0cd 100644
> --- a/src/compiler/nir/nir.c
> +++ b/src/compiler/nir/nir.c
> @@ -45,10 +45,8 @@ nir_shader_create(void *mem_ctx,
> memset(&shader->info, 0, sizeof(shader->info));
>
> exec_list_make_empty(&shader->functions);
> - exec_list_make_empty(&shader->registers);
> exec_list_make_empty(&shader->globals);
> exec_list_make_empty(&shader->system_values);
> - shader->reg_alloc = 0;
>
> shader->num_inputs = 0;
> shader->num_outputs = 0;
> @@ -81,21 +79,10 @@ reg_create(void *mem_ctx, struct exec_list *list)
> }
>
> nir_register *
> -nir_global_reg_create(nir_shader *shader)
> -{
> - nir_register *reg = reg_create(shader, &shader->registers);
> - reg->index = shader->reg_alloc++;
> - reg->is_global = true;
> -
> - return reg;
> -}
> -
> -nir_register *
> nir_local_reg_create(nir_function_impl *impl)
> {
> nir_register *reg = reg_create(ralloc_parent(impl), &impl-
> >registers);
> reg->index = impl->reg_alloc++;
> - reg->is_global = false;
>
> return reg;
> }
> @@ -1061,16 +1048,6 @@ nir_index_local_regs(nir_function_impl *impl)
> impl->reg_alloc = index;
> }
>
> -void
> -nir_index_global_regs(nir_shader *shader)
> -{
> - unsigned index = 0;
> - foreach_list_typed(nir_register, reg, node, &shader->registers) {
> - reg->index = index++;
> - }
> - shader->reg_alloc = index;
> -}
> -
> static bool
> visit_alu_dest(nir_alu_instr *instr, nir_foreach_dest_cb cb, void
> *state)
> {
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 65ecd33..f354f78 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -363,9 +363,6 @@ typedef struct nir_register {
> /** only for debug purposes, can be NULL */
> const char *name;
>
> - /** whether this register is local (per-function) or global (per-
> shader) */
> - bool is_global;
> -
> /**
> * If this flag is set to true, then accessing channels >=
> num_components
> * is well-defined, and simply spills over to the next array
> element. This
> @@ -1877,12 +1874,6 @@ typedef struct nir_shader {
>
> struct exec_list functions; /** < list of nir_function */
>
> - /** list of global register in the shader */
> - struct exec_list registers;
> -
> - /** next available global register index */
> - unsigned reg_alloc;
> -
> /**
> * the highest index a load_input_*, load_uniform_*, etc.
> intrinsic can
> * access plus one
> @@ -1912,8 +1903,6 @@ nir_shader *nir_shader_create(void *mem_ctx,
> const nir_shader_compiler_options
> *options);
>
> /** creates a register, including assigning it an index and adding
> it to the list */
> -nir_register *nir_global_reg_create(nir_shader *shader);
> -
> nir_register *nir_local_reg_create(nir_function_impl *impl);
>
> void nir_reg_remove(nir_register *reg);
> @@ -2275,7 +2264,6 @@ nir_if *nir_block_get_following_if(nir_block
> *block);
> nir_loop *nir_block_get_following_loop(nir_block *block);
>
> void nir_index_local_regs(nir_function_impl *impl);
> -void nir_index_global_regs(nir_shader *shader);
> void nir_index_ssa_defs(nir_function_impl *impl);
> unsigned nir_index_instrs(nir_function_impl *impl);
>
> @@ -2559,8 +2547,6 @@ bool nir_opt_algebraic(nir_shader *shader);
> bool nir_opt_algebraic_late(nir_shader *shader);
> bool nir_opt_constant_folding(nir_shader *shader);
>
> -bool nir_opt_global_to_local(nir_shader *shader);
> -
> bool nir_copy_prop(nir_shader *shader);
>
> bool nir_opt_cse(nir_shader *shader);
> diff --git a/src/compiler/nir/nir_clone.c
> b/src/compiler/nir/nir_clone.c
> index 0e397b0..1a874e7 100644
> --- a/src/compiler/nir/nir_clone.c
> +++ b/src/compiler/nir/nir_clone.c
> @@ -100,7 +100,7 @@ remap_global(clone_state *state, const void *ptr)
> static nir_register *
> remap_reg(clone_state *state, const nir_register *reg)
> {
> - return _lookup_ptr(state, reg, reg->is_global);
> + return _lookup_ptr(state, reg, false);
> }
>
> static nir_variable *
> @@ -183,7 +183,6 @@ clone_register(clone_state *state, const
> nir_register *reg)
> nreg->num_array_elems = reg->num_array_elems;
> nreg->index = reg->index;
> nreg->name = ralloc_strdup(nreg, reg->name);
> - nreg->is_global = reg->is_global;
> nreg->is_packed = reg->is_packed;
>
> /* reconstructing uses/defs/if_uses handled by nir_instr_insert()
> */
> @@ -707,9 +706,6 @@ nir_shader_clone(void *mem_ctx, const nir_shader
> *s)
> nfxn->impl->function = nfxn;
> }
>
> - clone_reg_list(&state, &ns->registers, &s->registers);
> - ns->reg_alloc = s->reg_alloc;
> -
> ns->info = s->info;
> ns->info.name = ralloc_strdup(ns, ns->info.name);
> if (ns->info.label)
> diff --git a/src/compiler/nir/nir_opt_global_to_local.c
> b/src/compiler/nir/nir_opt_global_to_local.c
> deleted file mode 100644
> index 64d689e..0000000
> --- a/src/compiler/nir/nir_opt_global_to_local.c
> +++ /dev/null
> @@ -1,102 +0,0 @@
> -/*
> - * Copyright © 2014 Intel Corporation
> - *
> - * Permission is hereby granted, free of charge, to any person
> obtaining a
> - * copy of this software and associated documentation files (the
> "Software"),
> - * to deal in the Software without restriction, including without
> limitation
> - * the rights to use, copy, modify, merge, publish, distribute,
> sublicense,
> - * and/or sell copies of the Software, and to permit persons to whom
> the
> - * Software is furnished to do so, subject to the following
> conditions:
> - *
> - * The above copyright notice and this permission notice (including
> the next
> - * paragraph) shall be included in all copies or substantial
> portions of the
> - * Software.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
> EVENT SHALL
> - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
> OR OTHER
> - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING
> - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER DEALINGS
> - * IN THE SOFTWARE.
> - *
> - * Authors:
> - * Connor Abbott (cwabbott0 at gmail.com)
> - *
> - */
> -
> -#include "nir.h"
> -
> -static bool
> -global_to_local(nir_register *reg)
> -{
> - nir_function_impl *impl = NULL;
> -
> - assert(reg->is_global);
> -
> - nir_foreach_def(def_dest, reg) {
> - nir_instr *instr = def_dest->reg.parent_instr;
> - nir_function_impl *instr_impl =
> - nir_cf_node_get_function(&instr->block->cf_node);
> - if (impl != NULL) {
> - if (impl != instr_impl)
> - return false;
> - } else {
> - impl = instr_impl;
> - }
> - }
> -
> - nir_foreach_use(use_src, reg) {
> - nir_instr *instr = use_src->parent_instr;
> - nir_function_impl *instr_impl =
> - nir_cf_node_get_function(&instr->block->cf_node);
> - if (impl != NULL) {
> - if (impl != instr_impl)
> - return false;
> - } else {
> - impl = instr_impl;
> - }
> - }
> -
> - nir_foreach_if_use(use_src, reg) {
> - nir_if *if_stmt = use_src->parent_if;
> - nir_function_impl *if_impl =
> nir_cf_node_get_function(&if_stmt->cf_node);
> - if (impl != NULL) {
> - if (impl != if_impl)
> - return false;
> - } else {
> - impl = if_impl;
> - }
> - }
> -
> - if (impl == NULL) {
> - /* this instruction is never used/defined, delete it */
> - nir_reg_remove(reg);
> - return true;
> - }
> -
> - /*
> - * if we've gotten to this point, the register is always
> used/defined in
> - * the same implementation so we can move it to be local to that
> - * implementation.
> - */
> -
> - exec_node_remove(®->node);
> - exec_list_push_tail(&impl->registers, ®->node);
> - reg->index = impl->reg_alloc++;
> - reg->is_global = false;
> - return true;
> -}
> -
> -bool
> -nir_opt_global_to_local(nir_shader *shader)
> -{
> - bool progress = false;
> -
> - foreach_list_typed_safe(nir_register, reg, node, &shader-
> >registers) {
> - if (global_to_local(reg))
> - progress = true;
> - }
> -
> - return progress;
> -}
> diff --git a/src/compiler/nir/nir_print.c
> b/src/compiler/nir/nir_print.c
> index 3beb70a..74449b6 100644
> --- a/src/compiler/nir/nir_print.c
> +++ b/src/compiler/nir/nir_print.c
> @@ -82,11 +82,7 @@ print_register(nir_register *reg, print_state
> *state)
> {
> FILE *fp = state->fp;
> if (reg->name != NULL)
> - fprintf(fp, "/* %s */ ", reg->name);
> - if (reg->is_global)
> - fprintf(fp, "gr%u", reg->index);
> - else
> - fprintf(fp, "r%u", reg->index);
> + fprintf(fp, "/* %s */ r%u", reg->name, reg->index);
Whoops this should be:
if (reg->name != NULL)
fprintf(fp, "/* %s */ ", reg->name);
else
fprintf(fp, "r%u", reg->index);
Fixed locally.
More information about the mesa-dev
mailing list