nir: Remove the mem_ctx parameter from ssa_def_rewrite_uses
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
This commit is contained in:
@@ -1205,7 +1205,7 @@ nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
|
||||
}
|
||||
|
||||
void
|
||||
nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void *mem_ctx)
|
||||
nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src)
|
||||
{
|
||||
assert(!new_src.is_ssa || def != new_src.ssa);
|
||||
|
||||
|
@@ -1740,7 +1740,7 @@ void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
|
||||
unsigned num_components, const char *name);
|
||||
void nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
|
||||
unsigned num_components, const char *name);
|
||||
void nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void *mem_ctx);
|
||||
void nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src);
|
||||
|
||||
/* visits basic blocks in source-code order */
|
||||
typedef bool (*nir_foreach_block_cb)(nir_block *block, void *state);
|
||||
|
@@ -654,7 +654,7 @@ replace_ssa_def_uses(nir_ssa_def *def, void *void_impl)
|
||||
nir_ssa_undef_instr *undef =
|
||||
nir_ssa_undef_instr_create(mem_ctx, def->num_components);
|
||||
nir_instr_insert_before_cf_list(&impl->body, &undef->instr);
|
||||
nir_ssa_def_rewrite_uses(def, nir_src_for_ssa(&undef->def), mem_ctx);
|
||||
nir_ssa_def_rewrite_uses(def, nir_src_for_ssa(&undef->def));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -359,8 +359,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
|
||||
exec_list_push_tail(&block_pcopy->entries, &entry->node);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&phi->dest.ssa,
|
||||
nir_src_for_ssa(&entry->dest.ssa),
|
||||
state->mem_ctx);
|
||||
nir_src_for_ssa(&entry->dest.ssa));
|
||||
|
||||
nir_instr_rewrite_src(&block_pcopy->instr, &entry->src,
|
||||
nir_src_for_ssa(&phi->dest.ssa));
|
||||
@@ -493,7 +492,7 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)
|
||||
reg->num_array_elems = 0;
|
||||
}
|
||||
|
||||
nir_ssa_def_rewrite_uses(def, nir_src_for_reg(reg), state->mem_ctx);
|
||||
nir_ssa_def_rewrite_uses(def, nir_src_for_reg(reg));
|
||||
assert(list_empty(&def->uses) && list_empty(&def->if_uses));
|
||||
|
||||
if (def->parent_instr->type == nir_instr_type_ssa_undef) {
|
||||
|
@@ -70,8 +70,7 @@ lower_reduction(nir_alu_instr *instr, nir_op chan_op, nir_op merge_op,
|
||||
}
|
||||
|
||||
assert(instr->dest.write_mask == 1);
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(last),
|
||||
mem_ctx);
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(last));
|
||||
nir_instr_remove(&instr->instr);
|
||||
}
|
||||
|
||||
@@ -168,8 +167,7 @@ lower_alu_instr_scalar(nir_alu_instr *instr, void *mem_ctx)
|
||||
nir_instr_insert_before(&instr->instr, &vec_instr->instr);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,
|
||||
nir_src_for_ssa(&vec_instr->dest.dest.ssa),
|
||||
mem_ctx);
|
||||
nir_src_for_ssa(&vec_instr->dest.dest.ssa));
|
||||
|
||||
nir_instr_remove(&instr->instr);
|
||||
}
|
||||
|
@@ -116,8 +116,7 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
|
||||
nir_ssa_dest_init(&new_instr->instr, &new_instr->dest,
|
||||
instr->dest.ssa.num_components, NULL);
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.ssa,
|
||||
nir_src_for_ssa(&new_instr->dest.ssa),
|
||||
mem_ctx);
|
||||
nir_src_for_ssa(&new_instr->dest.ssa));
|
||||
} else {
|
||||
nir_dest_copy(&new_instr->dest, &instr->dest, mem_ctx);
|
||||
}
|
||||
|
@@ -116,9 +116,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu)
|
||||
}
|
||||
|
||||
assert(alu->dest.dest.is_ssa);
|
||||
nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa,
|
||||
nir_src_for_ssa(q),
|
||||
ralloc_parent(alu));
|
||||
nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(q));
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@@ -186,8 +186,7 @@ nir_lower_io_block(nir_block *block, void *void_state)
|
||||
nir_ssa_dest_init(&load->instr, &load->dest,
|
||||
intrin->num_components, NULL);
|
||||
nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
|
||||
nir_src_for_ssa(&load->dest.ssa),
|
||||
state->mem_ctx);
|
||||
nir_src_for_ssa(&load->dest.ssa));
|
||||
} else {
|
||||
nir_dest_copy(&load->dest, &intrin->dest, state->mem_ctx);
|
||||
}
|
||||
|
@@ -71,8 +71,7 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower)
|
||||
}
|
||||
|
||||
/* Replace the old load with a reference to our reconstructed vector. */
|
||||
nir_ssa_def_rewrite_uses(&lower->def, nir_src_for_ssa(vec),
|
||||
ralloc_parent(b.impl));
|
||||
nir_ssa_def_rewrite_uses(&lower->def, nir_src_for_ssa(vec));
|
||||
nir_instr_remove(&lower->instr);
|
||||
}
|
||||
|
||||
|
@@ -221,8 +221,7 @@ lower_locals_to_regs_block(nir_block *block, void *void_state)
|
||||
nir_ssa_dest_init(&mov->instr, &mov->dest.dest,
|
||||
intrin->num_components, NULL);
|
||||
nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
|
||||
nir_src_for_ssa(&mov->dest.dest.ssa),
|
||||
state->shader);
|
||||
nir_src_for_ssa(&mov->dest.dest.ssa));
|
||||
} else {
|
||||
nir_dest_copy(&mov->dest.dest, &intrin->dest, &mov->instr);
|
||||
}
|
||||
|
@@ -242,8 +242,7 @@ lower_phis_to_scalar_block(nir_block *block, void *void_state)
|
||||
nir_instr_insert_after(&last_phi->instr, &vec->instr);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&phi->dest.ssa,
|
||||
nir_src_for_ssa(&vec->dest.dest.ssa),
|
||||
state->mem_ctx);
|
||||
nir_src_for_ssa(&vec->dest.dest.ssa));
|
||||
|
||||
ralloc_steal(state->dead_ctx, phi);
|
||||
nir_instr_remove(&phi->instr);
|
||||
|
@@ -80,8 +80,7 @@ convert_instr(nir_intrinsic_instr *instr)
|
||||
nir_ssa_dest_init(&new_instr->instr, &new_instr->dest,
|
||||
instr->dest.ssa.num_components, NULL);
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.ssa,
|
||||
nir_src_for_ssa(&new_instr->dest.ssa),
|
||||
mem_ctx);
|
||||
nir_src_for_ssa(&new_instr->dest.ssa));
|
||||
} else {
|
||||
nir_dest_copy(&new_instr->dest, &instr->dest, mem_ctx);
|
||||
}
|
||||
|
@@ -625,8 +625,7 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
|
||||
nir_instr_remove(&intrin->instr);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
|
||||
nir_src_for_ssa(&undef->def),
|
||||
state->shader);
|
||||
nir_src_for_ssa(&undef->def));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -650,8 +649,7 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
|
||||
nir_instr_remove(&intrin->instr);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
|
||||
nir_src_for_ssa(&mov->dest.dest.ssa),
|
||||
state->shader);
|
||||
nir_src_for_ssa(&mov->dest.dest.ssa));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -80,8 +80,8 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
|
||||
|
||||
nir_instr_insert_before(&instr->instr, &new_instr->instr);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(&new_instr->def),
|
||||
mem_ctx);
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,
|
||||
nir_src_for_ssa(&new_instr->def));
|
||||
|
||||
nir_instr_remove(&instr->instr);
|
||||
ralloc_free(instr);
|
||||
|
@@ -272,8 +272,7 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)
|
||||
if (nir_instrs_equal(instr, other)) {
|
||||
nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);
|
||||
nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),
|
||||
nir_src_for_ssa(other_def),
|
||||
state->mem_ctx);
|
||||
nir_src_for_ssa(other_def));
|
||||
nir_instr_remove(instr);
|
||||
state->progress = true;
|
||||
return;
|
||||
@@ -286,8 +285,7 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)
|
||||
if (nir_instrs_equal(instr, other)) {
|
||||
nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);
|
||||
nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),
|
||||
nir_src_for_ssa(other_def),
|
||||
state->mem_ctx);
|
||||
nir_src_for_ssa(other_def));
|
||||
nir_instr_remove(instr);
|
||||
state->progress = true;
|
||||
return;
|
||||
|
@@ -83,8 +83,6 @@ remove_after_cf_node(nir_cf_node *node)
|
||||
static void
|
||||
opt_constant_if(nir_if *if_stmt, bool condition)
|
||||
{
|
||||
void *mem_ctx = ralloc_parent(if_stmt);
|
||||
|
||||
/* First, we need to remove any phi nodes after the if by rewriting uses to
|
||||
* point to the correct source.
|
||||
*/
|
||||
@@ -109,7 +107,7 @@ opt_constant_if(nir_if *if_stmt, bool condition)
|
||||
|
||||
assert(def);
|
||||
assert(phi->dest.is_ssa);
|
||||
nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def), mem_ctx);
|
||||
nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def));
|
||||
nir_instr_remove(instr);
|
||||
}
|
||||
|
||||
|
@@ -224,8 +224,7 @@ nir_opt_peephole_ffma_block(nir_block *block, void *void_state)
|
||||
add->dest.dest.ssa.num_components,
|
||||
add->dest.dest.ssa.name);
|
||||
nir_ssa_def_rewrite_uses(&add->dest.dest.ssa,
|
||||
nir_src_for_ssa(&ffma->dest.dest.ssa),
|
||||
state->mem_ctx);
|
||||
nir_src_for_ssa(&ffma->dest.dest.ssa));
|
||||
|
||||
nir_instr_insert_before(&add->instr, &ffma->instr);
|
||||
assert(list_empty(&add->dest.dest.ssa.uses));
|
||||
|
@@ -214,8 +214,7 @@ nir_opt_peephole_select_block(nir_block *block, void *void_state)
|
||||
sel->dest.write_mask = (1 << phi->dest.ssa.num_components) - 1;
|
||||
|
||||
nir_ssa_def_rewrite_uses(&phi->dest.ssa,
|
||||
nir_src_for_ssa(&sel->dest.dest.ssa),
|
||||
state->mem_ctx);
|
||||
nir_src_for_ssa(&sel->dest.dest.ssa));
|
||||
|
||||
nir_instr_insert_before(&phi->instr, &sel->instr);
|
||||
nir_instr_remove(&phi->instr);
|
||||
|
@@ -47,8 +47,6 @@ remove_phis_block(nir_block *block, void *state)
|
||||
{
|
||||
bool *progress = state;
|
||||
|
||||
void *mem_ctx = ralloc_parent(block);
|
||||
|
||||
nir_foreach_instr_safe(block, instr) {
|
||||
if (instr->type != nir_instr_type_phi)
|
||||
break;
|
||||
@@ -75,8 +73,7 @@ remove_phis_block(nir_block *block, void *state)
|
||||
continue;
|
||||
|
||||
assert(phi->dest.is_ssa);
|
||||
nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def),
|
||||
mem_ctx);
|
||||
nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def));
|
||||
nir_instr_remove(instr);
|
||||
|
||||
*progress = true;
|
||||
|
@@ -367,7 +367,7 @@ nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,
|
||||
nir_instr_insert_before(&instr->instr, &mov->instr);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,
|
||||
nir_src_for_ssa(&mov->dest.dest.ssa), mem_ctx);
|
||||
nir_src_for_ssa(&mov->dest.dest.ssa));
|
||||
|
||||
/* We know this one has no more uses because we just rewrote them all,
|
||||
* so we can remove it. The rest of the matched expression, however, we
|
||||
|
Reference in New Issue
Block a user