diff options
author | Ian Romanick <[email protected]> | 2019-05-29 16:48:17 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2019-05-31 08:47:03 -0700 |
commit | 336eab063009ebc96c3625ef1b7cffb2501448ce (patch) | |
tree | 203991fdcbb7247cede4801e3d0cb83f0d5048e9 /src/compiler | |
parent | 0e1c5cc78fe24fb9620cac7bdcf7e927ab042ff8 (diff) |
nir: Add a shallow clone function for nir_alu_instr
Reviewed-by: Jason Ekstrand <[email protected]>
Suggested-by: Jason Ekstrand <[email protected]>
Suggested-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir.h | 3 | ||||
-rw-r--r-- | src/compiler/nir/nir_clone.c | 20 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index e6ba0d977f3..0ed451b9d1a 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2888,6 +2888,9 @@ void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct hash_table void nir_print_instr(const nir_instr *instr, FILE *fp); void nir_print_deref(const nir_deref_instr *deref, FILE *fp); +/** Shallow clone of a single ALU instruction. */ +nir_alu_instr *nir_alu_instr_clone(nir_shader *s, const nir_alu_instr *orig); + nir_shader *nir_shader_clone(void *mem_ctx, const nir_shader *s); nir_function_impl *nir_function_impl_clone(nir_shader *shader, const nir_function_impl *fi); diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index f4000321575..c82ee3c5642 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -265,6 +265,26 @@ __clone_dst(clone_state *state, nir_instr *ninstr, } } +nir_alu_instr * +nir_alu_instr_clone(nir_shader *shader, const nir_alu_instr *orig) +{ + nir_alu_instr *clone = nir_alu_instr_create(shader, orig->op); + + clone->exact = orig->exact; + + for (unsigned i = 0; i < nir_op_infos[orig->op].num_inputs; i++) + nir_alu_src_copy(&clone->src[i], &orig->src[i], clone); + + nir_ssa_dest_init(&clone->instr, + &clone->dest.dest, + orig->dest.dest.ssa.num_components, + orig->dest.dest.ssa.bit_size, + orig->dest.dest.ssa.name); + clone->dest.write_mask = orig->dest.write_mask; + + return clone; +} + static nir_alu_instr * clone_alu(clone_state *state, const nir_alu_instr *alu) { |