nir: Move phi src setup to a helper.

Cleans up the ralloc/list push code all over the tree.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11772>
This commit is contained in:
Emma Anholt
2021-07-07 13:24:45 -07:00
committed by Marge Bot
parent 636f51c6d1
commit 673cc9323a
15 changed files with 51 additions and 117 deletions
+1 -12
View File
@@ -448,23 +448,12 @@ clone_phi(clone_state *state, const nir_phi_instr *phi, nir_block *nblk)
nir_instr_insert_after_block(nblk, &nphi->instr);
foreach_list_typed(nir_phi_src, src, node, &phi->srcs) {
nir_phi_src *nsrc = ralloc(nphi, nir_phi_src);
/* Just copy the old source for now. */
memcpy(nsrc, src, sizeof(*src));
/* Since we're not letting nir_insert_instr handle use/def stuff for us,
* we have to set the parent_instr manually. It doesn't really matter
* when we do it, so we might as well do it here.
*/
nsrc->src.parent_instr = &nphi->instr;
nir_phi_src *nsrc = nir_phi_instr_add_src(nphi, src->pred, src->src);
/* Stash it in the list of phi sources. We'll walk this list and fix up
* sources at the very end of clone_function_impl.
*/
list_add(&nsrc->src.use_link, &state->phi_srcs);
exec_list_push_tail(&nphi->srcs, &nsrc->node);
}
return nphi;