}
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);
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);
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;
}
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));
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) {
}
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);
}
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);
}
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);
}
}
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
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);
}
}
/* 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);
}
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);
}
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);
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);
}
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;
}
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;
}
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);
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;
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;
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.
*/
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);
}
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));
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);
{
bool *progress = state;
- void *mem_ctx = ralloc_parent(block);
-
nir_foreach_instr_safe(block, instr) {
if (instr->type != nir_instr_type_phi)
break;
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;
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