summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/broadcom/compiler/nir_to_vir.c1
-rw-r--r--src/compiler/Makefile.sources1
-rw-r--r--src/compiler/nir/meson.build1
-rw-r--r--src/compiler/nir/nir.c23
-rw-r--r--src/compiler/nir/nir.h15
-rw-r--r--src/compiler/nir/nir_clone.c6
-rw-r--r--src/compiler/nir/nir_lower_regs_to_ssa.c1
-rw-r--r--src/compiler/nir/nir_opt_global_to_local.c102
-rw-r--r--src/compiler/nir/nir_print.c9
-rw-r--r--src/compiler/nir/nir_serialize.c7
-rw-r--r--src/compiler/nir/nir_strip.c3
-rw-r--r--src/compiler/nir/nir_sweep.c1
-rw-r--r--src/compiler/nir/nir_validate.c39
-rw-r--r--src/freedreno/ir3/ir3_compiler_nir.c5
-rw-r--r--src/freedreno/ir3/ir3_nir.c1
-rw-r--r--src/gallium/drivers/freedreno/a2xx/ir2_nir.c1
-rw-r--r--src/gallium/drivers/v3d/v3d_program.c1
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c2
18 files changed, 10 insertions, 209 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 2c411b86ed1..2b196324754 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -2299,7 +2299,6 @@ nir_to_vir(struct v3d_compile *c)
ntq_setup_vpm_inputs(c);
ntq_setup_outputs(c);
- ntq_setup_registers(c, &c->s->registers);
/* Find the main function and emit the body. */
nir_foreach_function(function, c->s) {
diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 5fddb6d4db2..066cf47e445 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -289,7 +289,6 @@ NIR_FILES = \
nir/nir_opt_dead_write_vars.c \
nir/nir_opt_find_array_copies.c \
nir/nir_opt_gcm.c \
- nir/nir_opt_global_to_local.c \
nir/nir_opt_idiv_const.c \
nir/nir_opt_if.c \
nir/nir_opt_intrinsics.c \
diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
index c65f2ff62ff..54655f7cd7c 100644
--- a/src/compiler/nir/meson.build
+++ b/src/compiler/nir/meson.build
@@ -171,7 +171,6 @@ files_libnir = files(
'nir_opt_dead_write_vars.c',
'nir_opt_find_array_copies.c',
'nir_opt_gcm.c',
- 'nir_opt_global_to_local.c',
'nir_opt_idiv_const.c',
'nir_opt_if.c',
'nir_opt_intrinsics.c',
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index ae265ae5739..0c3d6e823c6 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -58,10 +58,8 @@ nir_shader_create(void *mem_ctx,
}
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;
@@ -91,21 +89,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;
}
@@ -930,16 +917,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 36e93f7c331..09950bf3398 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -453,9 +453,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;
-
/** set of nir_srcs where this register is used (read from) */
struct list_head uses;
@@ -2352,12 +2349,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
@@ -2404,9 +2395,6 @@ nir_shader *nir_shader_create(void *mem_ctx,
const nir_shader_compiler_options *options,
shader_info *si);
-/** 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);
@@ -2841,7 +2829,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);
@@ -3400,8 +3387,6 @@ bool nir_opt_constant_folding(nir_shader *shader);
bool nir_opt_combine_stores(nir_shader *shader, nir_variable_mode modes);
-bool nir_opt_global_to_local(nir_shader *shader);
-
bool nir_copy_prop(nir_shader *shader);
bool nir_opt_copy_prop_vars(nir_shader *shader);
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index fcbf2b7fdf6..a45a581bd05 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -115,7 +115,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 *
@@ -206,7 +206,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;
/* reconstructing uses/defs/if_uses handled by nir_instr_insert() */
list_inithead(&nreg->uses);
@@ -727,9 +726,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_lower_regs_to_ssa.c b/src/compiler/nir/nir_lower_regs_to_ssa.c
index 678495d7c9f..0db11ff1d1c 100644
--- a/src/compiler/nir/nir_lower_regs_to_ssa.c
+++ b/src/compiler/nir/nir_lower_regs_to_ssa.c
@@ -285,7 +285,6 @@ nir_lower_regs_to_ssa_impl(nir_function_impl *impl)
bool
nir_lower_regs_to_ssa(nir_shader *shader)
{
- assert(exec_list_is_empty(&shader->registers));
bool progress = false;
nir_foreach_function(function, shader) {
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 64d689e102f..00000000000
--- 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 ([email protected])
- *
- */
-
-#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(&reg->node);
- exec_list_push_tail(&impl->registers, &reg->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 5c7e168ccb5..bab42232992 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -81,10 +81,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, "r%u", reg->index);
}
static const char *sizes[] = { "error", "vec1", "vec2", "vec3", "vec4",
@@ -1404,10 +1401,6 @@ nir_print_shader_annotated(nir_shader *shader, FILE *fp,
print_var_decl(var, &state);
}
- foreach_list_typed(nir_register, reg, node, &shader->registers) {
- print_register_decl(reg, &state);
- }
-
foreach_list_typed(nir_function, func, node, &shader->functions) {
print_function(func, &state);
}
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index d318ec27fd1..324c0a154b3 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -236,7 +236,6 @@ write_register(write_ctx *ctx, const nir_register *reg)
blob_write_uint32(ctx->blob, !!(reg->name));
if (reg->name)
blob_write_string(ctx->blob, reg->name);
- blob_write_uint32(ctx->blob, reg->is_global << 1);
}
static nir_register *
@@ -255,8 +254,6 @@ read_register(read_ctx *ctx)
} else {
reg->name = NULL;
}
- unsigned flags = blob_read_uint32(ctx->blob);
- reg->is_global = flags & 0x2;
list_inithead(&reg->uses);
list_inithead(&reg->defs);
@@ -1121,8 +1118,6 @@ nir_serialize(struct blob *blob, const nir_shader *nir)
write_var_list(&ctx, &nir->globals);
write_var_list(&ctx, &nir->system_values);
- write_reg_list(&ctx, &nir->registers);
- blob_write_uint32(blob, nir->reg_alloc);
blob_write_uint32(blob, nir->num_inputs);
blob_write_uint32(blob, nir->num_uniforms);
blob_write_uint32(blob, nir->num_outputs);
@@ -1180,8 +1175,6 @@ nir_deserialize(void *mem_ctx,
read_var_list(&ctx, &ctx.nir->globals);
read_var_list(&ctx, &ctx.nir->system_values);
- read_reg_list(&ctx, &ctx.nir->registers);
- ctx.nir->reg_alloc = blob_read_uint32(blob);
ctx.nir->num_inputs = blob_read_uint32(blob);
ctx.nir->num_uniforms = blob_read_uint32(blob);
ctx.nir->num_outputs = blob_read_uint32(blob);
diff --git a/src/compiler/nir/nir_strip.c b/src/compiler/nir/nir_strip.c
index b2c6f16af96..ba7465c37d1 100644
--- a/src/compiler/nir/nir_strip.c
+++ b/src/compiler/nir/nir_strip.c
@@ -97,9 +97,6 @@ nir_strip(nir_shader *shader)
nir_foreach_variable(var, &shader->globals)
strip_variable(var);
- nir_foreach_register(reg, &shader->registers)
- strip_register(reg);
-
nir_foreach_function(func, shader) {
if (func->impl)
strip_impl(func->impl);
diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c
index b6b56aa078c..56b7a267f64 100644
--- a/src/compiler/nir/nir_sweep.c
+++ b/src/compiler/nir/nir_sweep.c
@@ -169,7 +169,6 @@ nir_sweep(nir_shader *nir)
steal_list(nir, nir_variable, &nir->shared);
steal_list(nir, nir_variable, &nir->globals);
steal_list(nir, nir_variable, &nir->system_values);
- steal_list(nir, nir_register, &nir->registers);
/* Recurse into functions, stealing their contents back. */
foreach_list_typed(nir_function, func, node, &nir->functions) {
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index 8606f6bcd08..9a950218208 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -151,10 +151,8 @@ validate_reg_src(nir_src *src, validate_state *state,
_mesa_set_add(reg_state->if_uses, src);
}
- if (!src->reg.reg->is_global) {
- validate_assert(state, reg_state->where_defined == state->impl &&
- "using a register declared in a different function");
- }
+ validate_assert(state, reg_state->where_defined == state->impl &&
+ "using a register declared in a different function");
if (bit_sizes)
validate_assert(state, src->reg.reg->bit_size & bit_sizes);
@@ -254,10 +252,8 @@ validate_reg_dest(nir_reg_dest *dest, validate_state *state,
reg_validate_state *reg_state = (reg_validate_state *) entry2->data;
_mesa_set_add(reg_state->defs, dest);
- if (!dest->reg->is_global) {
- validate_assert(state, reg_state->where_defined == state->impl &&
- "writing to a register declared in a different function");
- }
+ validate_assert(state, reg_state->where_defined == state->impl &&
+ "writing to a register declared in a different function");
if (bit_sizes)
validate_assert(state, dest->reg->bit_size & bit_sizes);
@@ -933,14 +929,9 @@ validate_cf_node(nir_cf_node *node, validate_state *state)
}
static void
-prevalidate_reg_decl(nir_register *reg, bool is_global, validate_state *state)
+prevalidate_reg_decl(nir_register *reg, validate_state *state)
{
- validate_assert(state, reg->is_global == is_global);
-
- if (is_global)
- validate_assert(state, reg->index < state->shader->reg_alloc);
- else
- validate_assert(state, reg->index < state->impl->reg_alloc);
+ validate_assert(state, reg->index < state->impl->reg_alloc);
validate_assert(state, !BITSET_TEST(state->regs_found, reg->index));
BITSET_SET(state->regs_found, reg->index);
@@ -953,7 +944,7 @@ prevalidate_reg_decl(nir_register *reg, bool is_global, validate_state *state)
reg_state->if_uses = _mesa_pointer_set_create(reg_state);
reg_state->defs = _mesa_pointer_set_create(reg_state);
- reg_state->where_defined = is_global ? NULL : state->impl;
+ reg_state->where_defined = state->impl;
_mesa_hash_table_insert(state->regs, reg, reg_state);
}
@@ -1116,7 +1107,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state)
sizeof(BITSET_WORD));
exec_list_validate(&impl->registers);
foreach_list_typed(nir_register, reg, node, &impl->registers) {
- prevalidate_reg_decl(reg, false, state);
+ prevalidate_reg_decl(reg, state);
}
state->ssa_defs_found = realloc(state->ssa_defs_found,
@@ -1253,25 +1244,11 @@ nir_validate_shader(nir_shader *shader, const char *when)
validate_var_decl(var, true, &state);
}
- state.regs_found = realloc(state.regs_found,
- BITSET_WORDS(shader->reg_alloc) *
- sizeof(BITSET_WORD));
- memset(state.regs_found, 0, BITSET_WORDS(shader->reg_alloc) *
- sizeof(BITSET_WORD));
- exec_list_validate(&shader->registers);
- foreach_list_typed(nir_register, reg, node, &shader->registers) {
- prevalidate_reg_decl(reg, true, &state);
- }
-
exec_list_validate(&shader->functions);
foreach_list_typed(nir_function, func, node, &shader->functions) {
validate_function(func, &state);
}
- foreach_list_typed(nir_register, reg, node, &shader->registers) {
- postvalidate_reg_decl(reg, &state);
- }
-
if (_mesa_hash_table_num_entries(state.errors) > 0)
dump_errors(&state, when);
diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c
index 4171324ccdb..5338d4e046f 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -2608,11 +2608,6 @@ emit_instructions(struct ir3_context *ctx)
ctx->so->num_samp += glsl_type_get_image_count(var->type);
}
- /* Setup registers (which should only be arrays): */
- nir_foreach_register(reg, &ctx->s->registers) {
- ir3_declare_array(ctx, reg);
- }
-
/* NOTE: need to do something more clever when we support >1 fxn */
nir_foreach_register(reg, &fxn->registers) {
ir3_declare_array(ctx, reg);
diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c
index 7a8b9753643..d75df2feef4 100644
--- a/src/freedreno/ir3/ir3_nir.c
+++ b/src/freedreno/ir3/ir3_nir.c
@@ -195,7 +195,6 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
debug_printf("----------------------\n");
}
- OPT_V(s, nir_opt_global_to_local);
OPT_V(s, nir_lower_regs_to_ssa);
OPT_V(s, ir3_nir_lower_io_offsets);
diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
index 3d4145fccdc..0b6fda26c3a 100644
--- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
+++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
@@ -119,7 +119,6 @@ ir2_optimize_nir(nir_shader *s, bool lower)
debug_printf("----------------------\n");
}
- OPT_V(s, nir_opt_global_to_local);
OPT_V(s, nir_lower_regs_to_ssa);
OPT_V(s, nir_lower_vars_to_ssa);
OPT_V(s, nir_lower_indirect_derefs, nir_var_shader_in | nir_var_shader_out);
diff --git a/src/gallium/drivers/v3d/v3d_program.c b/src/gallium/drivers/v3d/v3d_program.c
index fa4fa0b0b29..b8da87c7797 100644
--- a/src/gallium/drivers/v3d/v3d_program.c
+++ b/src/gallium/drivers/v3d/v3d_program.c
@@ -285,7 +285,6 @@ v3d_shader_state_create(struct pipe_context *pctx,
type_size,
(nir_lower_io_options)0);
- NIR_PASS_V(s, nir_opt_global_to_local);
NIR_PASS_V(s, nir_lower_regs_to_ssa);
NIR_PASS_V(s, nir_normalize_cubemap_coords);
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index b57a6b3daf2..91a99d0574b 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2217,7 +2217,6 @@ nir_to_qir(struct vc4_compile *c)
ntq_setup_inputs(c);
ntq_setup_outputs(c);
ntq_setup_uniforms(c);
- ntq_setup_registers(c, &c->s->registers);
/* Find the main function and emit the body. */
nir_foreach_function(function, c->s) {
@@ -2508,7 +2507,6 @@ vc4_shader_state_create(struct pipe_context *pctx,
type_size,
(nir_lower_io_options)0);
- NIR_PASS_V(s, nir_opt_global_to_local);
NIR_PASS_V(s, nir_lower_regs_to_ssa);
NIR_PASS_V(s, nir_normalize_cubemap_coords);