return ret;
}
+void
+nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src, void *mem_ctx)
+{
+ dest->src = nir_src_copy(src->src, mem_ctx);
+ dest->abs = src->abs;
+ dest->negate = src->negate;
+ for (unsigned i = 0; i < 4; i++)
+ dest->swizzle[i] = src->swizzle[i];
+}
+
+void
+nir_alu_dest_copy(nir_alu_dest *dest, const nir_alu_dest *src, void *mem_ctx)
+{
+ dest->dest = nir_dest_copy(src->dest, mem_ctx);
+ dest->write_mask = src->write_mask;
+ dest->saturate = src->saturate;
+}
+
static inline void
block_add_pred(nir_block *block, nir_block *pred)
{
unsigned write_mask : 4; /* ignored if dest.is_ssa is true */
} nir_alu_dest;
+void nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src, void *mem_ctx);
+void nir_alu_dest_copy(nir_alu_dest *dest, const nir_alu_dest *src,
+ void *mem_ctx);
+
#define OPCODE(name, num_inputs, output_size, output_type, \
input_sizes, input_types, algebraic_props) \
nir_op_##name,
assert(src_idx < nir_op_infos[vec->op].num_inputs);
nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
- mov->src[0].src = nir_src_copy(vec->src[src_idx].src, mem_ctx);
- mov->src[0].negate = vec->src[src_idx].negate;
- mov->src[0].abs = vec->src[src_idx].abs;
+ nir_alu_src_copy(&mov->src[0], &vec->src[src_idx], mem_ctx);
/* We only care about the one swizzle */
mov->src[0].swizzle[i] = vec->src[src_idx].swizzle[0];
- mov->dest.dest = nir_dest_copy(vec->dest.dest, mem_ctx);
- mov->dest.saturate = vec->dest.saturate;
+ nir_alu_dest_copy(&mov->dest, &vec->dest, mem_ctx);
mov->dest.write_mask = (1u << i);
nir_instr_insert_before(&vec->instr, &mov->instr);
assert(mov->instr.type == nir_instr_type_alu);
assert(mov->op == nir_op_fmov || mov->op == nir_op_imov);
- sel->src[idx].src = nir_src_copy(mov->src[0].src, state->mem_ctx);
- sel->src[idx].negate = mov->src[0].negate;
- sel->src[idx].abs = mov->src[0].abs;
- memcpy(sel->src[idx].swizzle, mov->src[0].swizzle, 4);
+ nir_alu_src_copy(&sel->src[idx], &mov->src[0], state->mem_ctx);
} else {
sel->src[idx].src = nir_src_copy(src->src, state->mem_ctx);
}