From b28bad89b9c44187bb5055769faa3e3dbbfffa35 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 5 Apr 2019 19:41:03 -0500 Subject: [PATCH] nir: Get rid of nir_register::is_packed All we ever do is initialize it to zero, clone it, print it, and validate it. No one ever sets or uses it. Acked-by: Karol Herbst Reviewed-by: Kenneth Graunke --- src/compiler/nir/nir.c | 1 - src/compiler/nir/nir.h | 11 ----------- src/compiler/nir/nir_clone.c | 1 - src/compiler/nir/nir_lower_regs_to_ssa.c | 2 +- src/compiler/nir/nir_print.c | 2 -- src/compiler/nir/nir_serialize.c | 3 +-- src/compiler/nir/nir_validate.c | 25 +++++++++--------------- 7 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 73645912897..ae265ae5739 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -83,7 +83,6 @@ reg_create(void *mem_ctx, struct exec_list *list) reg->num_components = 0; reg->bit_size = 32; reg->num_array_elems = 0; - reg->is_packed = false; reg->name = NULL; exec_list_push_tail(list, ®->node); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index c1ecf5ad561..36e93f7c331 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -456,17 +456,6 @@ typedef struct nir_register { /** 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 - * is useful for backends that can do per-component accessing, in - * particular scalar backends. By setting this flag and making - * num_components equal to 1, structures can be packed tightly into - * registers and then registers can be accessed per-component to get to - * each structure member, even if it crosses vec4 boundaries. - */ - bool is_packed; - /** set of nir_srcs where this register is used (read from) */ struct list_head uses; diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 99aa1da4dc8..fcbf2b7fdf6 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -207,7 +207,6 @@ clone_register(clone_state *state, const nir_register *reg) 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() */ list_inithead(&nreg->uses); diff --git a/src/compiler/nir/nir_lower_regs_to_ssa.c b/src/compiler/nir/nir_lower_regs_to_ssa.c index d70e70260be..678495d7c9f 100644 --- a/src/compiler/nir/nir_lower_regs_to_ssa.c +++ b/src/compiler/nir/nir_lower_regs_to_ssa.c @@ -230,7 +230,7 @@ nir_lower_regs_to_ssa_impl(nir_function_impl *impl) NIR_VLA(BITSET_WORD, defs, block_set_words); nir_foreach_register(reg, &impl->registers) { - if (reg->num_array_elems != 0 || reg->is_packed) { + if (reg->num_array_elems != 0) { /* This pass only really works on "plain" registers. If it's a * packed or array register, just set the value to NULL so that the * rewrite portion of the pass will know to ignore it. diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 4b530a35600..5c7e168ccb5 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -97,8 +97,6 @@ print_register_decl(nir_register *reg, print_state *state) { FILE *fp = state->fp; fprintf(fp, "decl_reg %s %u ", sizes[reg->num_components], reg->bit_size); - if (reg->is_packed) - fprintf(fp, "(packed) "); print_register(reg, state); if (reg->num_array_elems != 0) fprintf(fp, "[%u]", reg->num_array_elems); diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index fd8708fbb43..d318ec27fd1 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -236,7 +236,7 @@ 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 | reg->is_packed); + blob_write_uint32(ctx->blob, reg->is_global << 1); } static nir_register * @@ -257,7 +257,6 @@ read_register(read_ctx *ctx) } unsigned flags = blob_read_uint32(ctx->blob); reg->is_global = flags & 0x2; - reg->is_packed = flags & 0x1; list_inithead(®->uses); list_inithead(®->defs); diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 5f812974720..8606f6bcd08 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -156,12 +156,10 @@ validate_reg_src(nir_src *src, validate_state *state, "using a register declared in a different function"); } - if (!src->reg.reg->is_packed) { - if (bit_sizes) - validate_assert(state, src->reg.reg->bit_size & bit_sizes); - if (num_components) - validate_assert(state, src->reg.reg->num_components == num_components); - } + if (bit_sizes) + validate_assert(state, src->reg.reg->bit_size & bit_sizes); + if (num_components) + validate_assert(state, src->reg.reg->num_components == num_components); validate_assert(state, (src->reg.reg->num_array_elems == 0 || src->reg.base_offset < src->reg.reg->num_array_elems) && @@ -230,8 +228,6 @@ validate_alu_src(nir_alu_instr *instr, unsigned index, validate_state *state) nir_alu_src *src = &instr->src[index]; unsigned num_components = nir_src_num_components(src->src); - if (!src->src.is_ssa && src->src.reg.reg->is_packed) - num_components = NIR_MAX_VEC_COMPONENTS; /* can't check anything */ for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++) { validate_assert(state, src->swizzle[i] < NIR_MAX_VEC_COMPONENTS); @@ -263,12 +259,10 @@ validate_reg_dest(nir_reg_dest *dest, validate_state *state, "writing to a register declared in a different function"); } - if (!dest->reg->is_packed) { - if (bit_sizes) - validate_assert(state, dest->reg->bit_size & bit_sizes); - if (num_components) - validate_assert(state, dest->reg->num_components == num_components); - } + if (bit_sizes) + validate_assert(state, dest->reg->bit_size & bit_sizes); + if (num_components) + validate_assert(state, dest->reg->num_components == num_components); validate_assert(state, (dest->reg->num_array_elems == 0 || dest->base_offset < dest->reg->num_array_elems) && @@ -327,12 +321,11 @@ validate_alu_dest(nir_alu_instr *instr, validate_state *state) nir_alu_dest *dest = &instr->dest; unsigned dest_size = nir_dest_num_components(dest->dest); - bool is_packed = !dest->dest.is_ssa && dest->dest.reg.reg->is_packed; /* * validate that the instruction doesn't write to components not in the * register/SSA value */ - validate_assert(state, is_packed || !(dest->write_mask & ~((1 << dest_size) - 1))); + validate_assert(state, !(dest->write_mask & ~((1 << dest_size) - 1))); /* validate that saturate is only ever used on instructions with * destinations of type float -- 2.30.2