mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 13:40:11 +01:00
nir: Factor out nir_src_rewrite_ssa helper
Like nir_instr_rewrite_ssa but without the asserted extra argument. Works on ifs too, now that we have a unified use list. We do need to assert that the source has actually been inserted and has valid use/def chains. Previously, asserting on the parent instruction accomplished that indirectly. For the more general helper, we instead directly assert that there exists a non-null parent, whatever it is. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22343>
This commit is contained in:
parent
2285b5daae
commit
e9e0956d62
1 changed files with 12 additions and 8 deletions
|
|
@ -4341,16 +4341,23 @@ bool nir_src_is_always_uniform(nir_src src);
|
|||
bool nir_srcs_equal(nir_src src1, nir_src src2);
|
||||
bool nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2);
|
||||
|
||||
static inline void
|
||||
nir_src_rewrite_ssa(nir_src *src, nir_ssa_def *new_ssa)
|
||||
{
|
||||
assert(src->is_ssa && src->ssa);
|
||||
assert(src->is_if ? (src->parent_if != NULL) : (src->parent_instr != NULL));
|
||||
list_del(&src->use_link);
|
||||
src->ssa = new_ssa;
|
||||
list_addtail(&src->use_link, &new_ssa->uses);
|
||||
}
|
||||
|
||||
static inline void
|
||||
nir_instr_rewrite_src_ssa(ASSERTED nir_instr *instr,
|
||||
nir_src *src, nir_ssa_def *new_ssa)
|
||||
{
|
||||
assert(!src->is_if);
|
||||
assert(src->parent_instr == instr);
|
||||
assert(src->is_ssa && src->ssa);
|
||||
list_del(&src->use_link);
|
||||
src->ssa = new_ssa;
|
||||
list_addtail(&src->use_link, &new_ssa->uses);
|
||||
nir_src_rewrite_ssa(src, new_ssa);
|
||||
}
|
||||
|
||||
void nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src);
|
||||
|
|
@ -4362,10 +4369,7 @@ nir_if_rewrite_condition_ssa(ASSERTED nir_if *if_stmt,
|
|||
{
|
||||
assert(src->is_if);
|
||||
assert(src->parent_if == if_stmt);
|
||||
assert(src->is_ssa && src->ssa);
|
||||
list_del(&src->use_link);
|
||||
src->ssa = new_ssa;
|
||||
list_addtail(&src->use_link, &new_ssa->uses);
|
||||
nir_src_rewrite_ssa(src, new_ssa);
|
||||
}
|
||||
|
||||
void nir_if_rewrite_condition(nir_if *if_stmt, nir_src new_src);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue