diff options
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/nir/nir.c | 35 | ||||
-rw-r--r-- | src/glsl/nir/nir.h | 14 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_variables.c | 37 | ||||
-rw-r--r-- | src/glsl/nir/nir_opt_copy_propagate.c | 4 | ||||
-rw-r--r-- | src/glsl/nir/nir_opt_cse.c | 7 | ||||
-rw-r--r-- | src/glsl/nir/nir_print.c | 30 | ||||
-rw-r--r-- | src/glsl/nir/nir_split_var_copies.c | 6 | ||||
-rw-r--r-- | src/glsl/nir/nir_to_ssa.c | 121 | ||||
-rw-r--r-- | src/glsl/nir/nir_validate.c | 12 |
9 files changed, 7 insertions, 259 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index cb788d47259..bbf1a865706 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -381,9 +381,6 @@ nir_alu_instr_create(void *mem_ctx, nir_op op) for (unsigned i = 0; i < num_srcs; i++) alu_src_init(&instr->src[i]); - instr->has_predicate = false; - src_init(&instr->predicate); - return instr; } @@ -406,9 +403,6 @@ nir_load_const_instr_create(void *mem_ctx) instr->num_components = 0; instr->array_elems = 0; - instr->has_predicate = false; - src_init(&instr->predicate); - return instr; } @@ -429,9 +423,6 @@ nir_intrinsic_instr_create(void *mem_ctx, nir_intrinsic_op op) for (unsigned i = 0; i < num_srcs; i++) src_init(&instr->src[i]); - instr->has_predicate = false; - src_init(&instr->predicate); - return instr; } @@ -446,9 +437,6 @@ nir_call_instr_create(void *mem_ctx, nir_function_overload *callee) instr->params = ralloc_array(mem_ctx, nir_deref_var *, instr->num_params); instr->return_deref = NULL; - instr->has_predicate = false; - src_init(&instr->predicate); - return instr; } @@ -464,9 +452,6 @@ nir_tex_instr_create(void *mem_ctx, unsigned num_srcs) for (unsigned i = 0; i < 4; i++) src_init(&instr->src[i]); - instr->has_predicate = false; - src_init(&instr->predicate); - instr->sampler_index = 0; instr->sampler_array_size = 0; instr->sampler = NULL; @@ -1521,10 +1506,6 @@ visit_alu_src(nir_alu_instr *instr, nir_foreach_src_cb cb, void *state) if (!visit_src(&instr->src[i].src, cb, state)) return false; - if (instr->has_predicate) - if (!visit_src(&instr->predicate, cb, state)) - return false; - return true; } @@ -1535,10 +1516,6 @@ visit_tex_src(nir_tex_instr *instr, nir_foreach_src_cb cb, void *state) if (!visit_src(&instr->src[i], cb, state)) return false; - if (instr->has_predicate) - if (!visit_src(&instr->predicate, cb, state)) - return false; - if (instr->sampler != NULL) if (!visit_deref_src(instr->sampler, cb, state)) return false; @@ -1561,20 +1538,12 @@ visit_intrinsic_src(nir_intrinsic_instr *instr, nir_foreach_src_cb cb, if (!visit_deref_src(instr->variables[i], cb, state)) return false; - if (instr->has_predicate) - if (!visit_src(&instr->predicate, cb, state)) - return false; - return true; } static bool visit_call_src(nir_call_instr *instr, nir_foreach_src_cb cb, void *state) { - if (instr->has_predicate) - if (!visit_src(&instr->predicate, cb, state)) - return false; - return true; } @@ -1582,10 +1551,6 @@ static bool visit_load_const_src(nir_load_const_instr *instr, nir_foreach_src_cb cb, void *state) { - if (instr->has_predicate) - if (!visit_src(&instr->predicate, cb, state)) - return false; - return true; } diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 822e2ae414c..8887c5815e7 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -606,8 +606,6 @@ extern const nir_op_info nir_op_infos[nir_num_opcodes]; typedef struct nir_alu_instr { nir_instr instr; nir_op op; - bool has_predicate; - nir_src predicate; nir_alu_dest dest; nir_alu_src src[]; } nir_alu_instr; @@ -679,9 +677,6 @@ typedef struct { nir_deref_var **params; nir_deref_var *return_deref; - bool has_predicate; - nir_src predicate; - struct nir_function_overload *callee; } nir_call_instr; @@ -713,9 +708,6 @@ typedef struct { nir_deref_var *variables[2]; - bool has_predicate; - nir_src predicate; - nir_src src[]; } nir_intrinsic_instr; @@ -813,9 +805,6 @@ typedef enum { typedef struct { nir_instr instr; - bool has_predicate; - nir_src predicate; - enum glsl_sampler_dim sampler_dim; nir_alu_type dest_type; @@ -944,9 +933,6 @@ typedef struct { */ unsigned array_elems; - bool has_predicate; - nir_src predicate; - nir_dest dest; } nir_load_const_instr; diff --git a/src/glsl/nir/nir_lower_variables.c b/src/glsl/nir/nir_lower_variables.c index 64682056ddc..4fa421a4d65 100644 --- a/src/glsl/nir/nir_lower_variables.c +++ b/src/glsl/nir/nir_lower_variables.c @@ -548,11 +548,6 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr, store->src[0].is_ssa = true; store->src[0].ssa = &load->dest.ssa; - if (copy_instr->has_predicate) { - store->has_predicate = true; - store->predicate = nir_src_copy(copy_instr->predicate, state->mem_ctx); - } - nir_instr_insert_before(©_instr->instr, &store->instr); register_store_instr(store, false, state); } @@ -831,32 +826,12 @@ lower_deref_to_ssa_block(nir_block *block, void *void_state) assert(intrin->src[0].is_ssa); - nir_alu_instr *mov; - if (intrin->has_predicate) { - mov = nir_alu_instr_create(state->mem_ctx, nir_op_bcsel); - mov->src[0].src = nir_src_copy(intrin->predicate, - state->mem_ctx); - /* Splat the condition to all channels */ - memset(mov->src[0].swizzle, 0, sizeof mov->src[0].swizzle); - - mov->src[1].src.is_ssa = true; - mov->src[1].src.ssa = intrin->src[0].ssa; - for (unsigned i = intrin->num_components; i < 4; i++) - mov->src[1].swizzle[i] = 0; - - mov->src[2].src.is_ssa = true; - mov->src[2].src.ssa = get_ssa_def_for_block(node, block, state); - for (unsigned i = intrin->num_components; i < 4; i++) - mov->src[2].swizzle[i] = 0; - - } else { - mov = nir_alu_instr_create(state->mem_ctx, nir_op_imov); - - mov->src[0].src.is_ssa = true; - mov->src[0].src.ssa = intrin->src[0].ssa; - for (unsigned i = intrin->num_components; i < 4; i++) - mov->src[0].swizzle[i] = 0; - } + nir_alu_instr *mov = nir_alu_instr_create(state->mem_ctx, + nir_op_imov); + mov->src[0].src.is_ssa = true; + mov->src[0].src.ssa = intrin->src[0].ssa; + for (unsigned i = intrin->num_components; i < 4; i++) + mov->src[0].swizzle[i] = 0; mov->dest.write_mask = (1 << intrin->num_components) - 1; mov->dest.dest.is_ssa = true; diff --git a/src/glsl/nir/nir_opt_copy_propagate.c b/src/glsl/nir/nir_opt_copy_propagate.c index 2feebe42c00..aa2df1be857 100644 --- a/src/glsl/nir/nir_opt_copy_propagate.c +++ b/src/glsl/nir/nir_opt_copy_propagate.c @@ -256,10 +256,6 @@ copy_prop_instr(nir_instr *instr) while (copy_prop_alu_src(alu_instr, i)) progress = true; - if (alu_instr->has_predicate) - while (copy_prop_src(&alu_instr->predicate, instr, NULL)) - progress = true; - if (!alu_instr->dest.dest.is_ssa && alu_instr->dest.dest.reg.indirect) while (copy_prop_src(alu_instr->dest.dest.reg.indirect, instr, NULL)) progress = true; diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c index 14bd6bf50e6..0ad575c19c1 100644 --- a/src/glsl/nir/nir_opt_cse.c +++ b/src/glsl/nir/nir_opt_cse.c @@ -67,13 +67,6 @@ nir_instrs_equal(nir_instr *instr1, nir_instr *instr2) if (alu1->op != alu2->op) return false; - if (alu1->has_predicate != alu2->has_predicate) - return false; - - if (alu1->has_predicate && - !nir_srcs_equal(alu1->predicate, alu2->predicate)) - return false; - /* TODO: We can probably acutally do something more inteligent such * as allowing different numbers and taking a maximum or something * here */ diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c index 22a2a1d6557..7d60eb11ee8 100644 --- a/src/glsl/nir/nir_print.c +++ b/src/glsl/nir/nir_print.c @@ -178,12 +178,6 @@ print_alu_dest(nir_alu_dest *dest, FILE *fp) static void print_alu_instr(nir_alu_instr *instr, FILE *fp) { - if (instr->has_predicate) { - fprintf(fp, "("); - print_src(&instr->predicate, fp); - fprintf(fp, ") "); - } - print_alu_dest(&instr->dest, fp); fprintf(fp, " = %s", nir_op_infos[instr->op].name); @@ -327,12 +321,6 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_var_state *state, { unsigned num_srcs = nir_intrinsic_infos[instr->intrinsic].num_srcs; - if (instr->has_predicate) { - fprintf(fp, "("); - print_src(&instr->predicate, fp); - fprintf(fp, ") "); - } - if (nir_intrinsic_infos[instr->intrinsic].has_dest) { print_dest(&instr->dest, fp); fprintf(fp, " = "); @@ -384,12 +372,6 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_var_state *state, static void print_tex_instr(nir_tex_instr *instr, print_var_state *state, FILE *fp) { - if (instr->has_predicate) { - fprintf(fp, "("); - print_src(&instr->predicate, fp); - fprintf(fp, ") "); - } - print_dest(&instr->dest, fp); fprintf(fp, " = "); @@ -505,12 +487,6 @@ print_tex_instr(nir_tex_instr *instr, print_var_state *state, FILE *fp) static void print_call_instr(nir_call_instr *instr, print_var_state *state, FILE *fp) { - if (instr->has_predicate) { - fprintf(fp, "("); - print_src(&instr->predicate, fp); - fprintf(fp, ") "); - } - fprintf(fp, "call %s ", instr->callee->function->name); for (unsigned i = 0; i < instr->num_params; i++) { @@ -555,12 +531,6 @@ print_const_value(nir_const_value value, unsigned num_components, FILE *fp) static void print_load_const_instr(nir_load_const_instr *instr, unsigned tabs, FILE *fp) { - if (instr->has_predicate) { - fprintf(fp, "("); - print_src(&instr->predicate, fp); - fprintf(fp, ") "); - } - print_dest(&instr->dest, fp); fprintf(fp, " = load_const "); diff --git a/src/glsl/nir/nir_split_var_copies.c b/src/glsl/nir/nir_split_var_copies.c index edabfb7e5c3..4d663b51bed 100644 --- a/src/glsl/nir/nir_split_var_copies.c +++ b/src/glsl/nir/nir_split_var_copies.c @@ -184,12 +184,6 @@ split_var_copy_instr(nir_intrinsic_instr *old_copy, nir_intrinsic_instr *new_copy = nir_intrinsic_instr_create(state->mem_ctx, nir_intrinsic_copy_var); - if (old_copy->has_predicate) { - new_copy->has_predicate = true; - new_copy->predicate = nir_src_copy(old_copy->predicate, - state->mem_ctx); - } - /* We need to make copies because a) this deref chain actually * belongs to the copy instruction and b) the deref chains may * have some of the same links due to the way we constructed them diff --git a/src/glsl/nir/nir_to_ssa.c b/src/glsl/nir/nir_to_ssa.c index 6b6a0779a6d..3725ddbe226 100644 --- a/src/glsl/nir/nir_to_ssa.c +++ b/src/glsl/nir/nir_to_ssa.c @@ -148,9 +148,6 @@ typedef struct { /* map from SSA value -> original register */ struct hash_table *ssa_map; - - /* predicate for this instruction */ - nir_src *predicate; } rewrite_state; static nir_ssa_def *get_ssa_src(nir_register *reg, rewrite_state *state) @@ -220,27 +217,6 @@ rewrite_def_forwards(nir_dest *dest, void *_state) if (state->states[index].stack == NULL) return true; - nir_alu_instr *csel = NULL; - if (state->predicate) { - /* - * To capture the information that we may or may not overwrite this - * register due to the predicate, we need to emit a conditional select - * that takes the old version of the register and the new version. - * This is basically a watered-down version of the Psi-SSA - * representation, without any of the optimizations. - * - * TODO: do we actually need full-blown Psi-SSA? - */ - csel = nir_alu_instr_create(state->mem_ctx, nir_op_bcsel); - csel->dest.dest.reg.reg = dest->reg.reg; - csel->dest.write_mask = (1 << dest->reg.reg->num_components) - 1; - csel->src[0].src = nir_src_copy(*state->predicate, state->mem_ctx); - /* Splat the condition to all channels */ - memset(csel->src[0].swizzle, 0, sizeof csel->src[0].swizzle); - csel->src[2].src.is_ssa = true; - csel->src[2].src.ssa = get_ssa_src(dest->reg.reg, state); - } - dest->is_ssa = true; char *name = NULL; @@ -259,21 +235,6 @@ rewrite_def_forwards(nir_dest *dest, void *_state) _mesa_hash_table_insert(state->ssa_map, &dest->ssa, reg); - if (state->predicate) { - csel->src[1].src.is_ssa = true; - csel->src[1].src.ssa = &dest->ssa; - - nir_instr *old_parent_instr = state->parent_instr; - nir_src *old_predicate = state->predicate; - state->parent_instr = &csel->instr; - state->predicate = NULL; - rewrite_def_forwards(&csel->dest.dest, state); - state->parent_instr = old_parent_instr; - state->predicate = old_predicate; - - nir_instr_insert_after(state->parent_instr, &csel->instr); - } - return true; } @@ -281,7 +242,6 @@ static void rewrite_alu_instr_forward(nir_alu_instr *instr, rewrite_state *state) { state->parent_instr = &instr->instr; - state->predicate = instr->has_predicate ? &instr->predicate : NULL; nir_foreach_src(&instr->instr, rewrite_use, state); @@ -383,14 +343,9 @@ rewrite_alu_instr_forward(nir_alu_instr *instr, rewrite_state *state) } } - vec->has_predicate = instr->has_predicate; - if (instr->has_predicate) - vec->predicate = nir_src_copy(instr->predicate, state->mem_ctx); - nir_instr_insert_after(&instr->instr, &vec->instr); state->parent_instr = &vec->instr; - state->predicate = vec->has_predicate ? &vec->predicate : NULL; rewrite_def_forwards(&vec->dest.dest, state); } else { rewrite_def_forwards(&instr->dest.dest, state); @@ -401,54 +356,9 @@ static void rewrite_phi_instr(nir_phi_instr *instr, rewrite_state *state) { state->parent_instr = &instr->instr; - state->predicate = NULL; rewrite_def_forwards(&instr->dest, state); } -static nir_src * -get_instr_predicate(nir_instr *instr) -{ - nir_alu_instr *alu_instr; - nir_load_const_instr *load_const_instr; - nir_intrinsic_instr *intrinsic_instr; - nir_tex_instr *tex_instr; - - switch (instr->type) { - case nir_instr_type_alu: - alu_instr = nir_instr_as_alu(instr); - if (alu_instr->has_predicate) - return &alu_instr->predicate; - else - return NULL; - - case nir_instr_type_load_const: - load_const_instr = nir_instr_as_load_const(instr); - if (load_const_instr->has_predicate) - return &load_const_instr->predicate; - else - return NULL; - - case nir_instr_type_intrinsic: - intrinsic_instr = nir_instr_as_intrinsic(instr); - if (intrinsic_instr->has_predicate) - return &intrinsic_instr->predicate; - else - return NULL; - - case nir_instr_type_tex: - tex_instr = nir_instr_as_tex(instr); - if (tex_instr->has_predicate) - return &tex_instr->predicate; - else - return NULL; - - default: - break; - } - - return NULL; -} - static void rewrite_instr_forward(nir_instr *instr, rewrite_state *state) { @@ -463,7 +373,6 @@ rewrite_instr_forward(nir_instr *instr, rewrite_state *state) } state->parent_instr = instr; - state->predicate = get_instr_predicate(instr); nir_foreach_src(instr, rewrite_use, state); nir_foreach_dest(instr, rewrite_def_forwards, state); @@ -580,35 +489,7 @@ init_rewrite_state(nir_function_impl *impl, rewrite_state *state) * called after phi nodes are inserted so we can count phi node * definitions too. */ - unsigned stack_size = 0; - struct set_entry *entry; - set_foreach(reg->defs, entry) { - nir_instr *def = (nir_instr *) entry->key; - - stack_size++; - - /* - * predicates generate an additional predicate destination that - * gets pushed on the stack - * - * Note: ALU instructions generate an additional instruction too, - * but as of now only the additional instruction is pushed onto - * the stack, and not the original instruction because it doesn't - * need to be (actually, we could do the same with predicates, - * but it was easier to just use the existing codepath). - */ - - if (def->type == nir_instr_type_intrinsic) { - nir_intrinsic_instr *intrinsic_instr = - nir_instr_as_intrinsic(def); - if (nir_intrinsic_infos[intrinsic_instr->intrinsic].has_dest && - intrinsic_instr->has_predicate) - stack_size++; - } else { - if (get_instr_predicate(def) != NULL) - stack_size++; - } - } + unsigned stack_size = reg->defs->entries; state->states[reg->index].stack = ralloc_array(state->states, nir_ssa_def *, diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c index 937cbb9bf6e..f0eb87fd393 100644 --- a/src/glsl/nir/nir_validate.c +++ b/src/glsl/nir/nir_validate.c @@ -254,9 +254,6 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state) for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { validate_alu_src(instr, i, state); } - - if (instr->has_predicate) - validate_src(&instr->predicate, state); } static void @@ -372,9 +369,6 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) default: break; } - - if (instr->has_predicate) - validate_src(&instr->predicate, state); } static void @@ -412,9 +406,6 @@ validate_call_instr(nir_call_instr *instr, validate_state *state) } validate_deref_var(instr->return_deref, state); - - if (instr->has_predicate) - validate_src(&instr->predicate, state); } static void @@ -427,9 +418,6 @@ validate_load_const_instr(nir_load_const_instr *instr, validate_state *state) assert(instr->dest.reg.base_offset + instr->array_elems <= instr->dest.reg.reg->num_array_elems); } - - if (instr->has_predicate) - validate_src(&instr->predicate, state); } static void |