diff options
author | Connor Abbott <[email protected]> | 2015-07-21 19:54:19 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2015-08-24 13:31:41 -0700 |
commit | 762ae436ea578651c9f8a50620196b5d744b8eee (patch) | |
tree | bfea5ec7a7cf50d901aa5600aa2ec8f1afedc0af /src/glsl/nir/nir_control_flow.c | |
parent | b49371b8ede380f10ea3ab333246a3b01ac6aca5 (diff) |
nir/cf: add insert_phi_undef() helper
Signed-off-by: Connor Abbott <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_control_flow.c')
-rw-r--r-- | src/glsl/nir/nir_control_flow.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c index 8d146c491b2..bb94652757b 100644 --- a/src/glsl/nir/nir_control_flow.c +++ b/src/glsl/nir/nir_control_flow.c @@ -230,6 +230,31 @@ rewrite_phi_preds(nir_block *block, nir_block *old_pred, nir_block *new_pred) } } +static void +insert_phi_undef(nir_block *block, nir_block *pred) +{ + nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node); + nir_foreach_instr(block, instr) { + if (instr->type != nir_instr_type_phi) + break; + + nir_phi_instr *phi = nir_instr_as_phi(instr); + nir_ssa_undef_instr *undef = + nir_ssa_undef_instr_create(ralloc_parent(phi), + phi->dest.ssa.num_components); + nir_instr_insert_before_cf_list(&impl->body, &undef->instr); + nir_phi_src *src = ralloc(phi, nir_phi_src); + src->pred = pred; + src->src.parent_instr = &phi->instr; + src->src.is_ssa = true; + src->src.ssa = &undef->def; + + list_addtail(&src->src.use_link, &undef->def.uses); + + exec_list_push_tail(&phi->srcs, &src->node); + } +} + /** * Moves the successors of source to the successors of dest, leaving both * successors of source NULL. |