return overload;
}
-nir_src nir_src_copy(nir_src src, void *mem_ctx)
+void nir_src_copy(nir_src *dest, const nir_src *src, void *mem_ctx)
{
- nir_src ret;
- ret.is_ssa = src.is_ssa;
- if (ret.is_ssa) {
- ret.ssa = src.ssa;
+ dest->is_ssa = src->is_ssa;
+ if (src->is_ssa) {
+ dest->ssa = src->ssa;
} else {
- ret.reg.base_offset = src.reg.base_offset;
- ret.reg.reg = src.reg.reg;
- if (src.reg.indirect) {
- ret.reg.indirect = ralloc(mem_ctx, nir_src);
- *ret.reg.indirect = *src.reg.indirect;
+ dest->reg.base_offset = src->reg.base_offset;
+ dest->reg.reg = src->reg.reg;
+ if (src->reg.indirect) {
+ dest->reg.indirect = ralloc(mem_ctx, nir_src);
+ nir_src_copy(dest->reg.indirect, src->reg.indirect, mem_ctx);
} else {
- ret.reg.indirect = NULL;
+ dest->reg.indirect = NULL;
}
}
-
- return ret;
}
-nir_dest nir_dest_copy(nir_dest dest, void *mem_ctx)
+void nir_dest_copy(nir_dest *dest, const nir_dest *src, void *mem_ctx)
{
- nir_dest ret;
- ret.is_ssa = dest.is_ssa;
- if (ret.is_ssa) {
- ret.ssa = dest.ssa;
+ dest->is_ssa = src->is_ssa;
+ if (src->is_ssa) {
+ dest->ssa = src->ssa;
} else {
- ret.reg.base_offset = dest.reg.base_offset;
- ret.reg.reg = dest.reg.reg;
- if (dest.reg.indirect) {
- ret.reg.indirect = ralloc(mem_ctx, nir_src);
- *ret.reg.indirect = *dest.reg.indirect;
+ dest->reg.base_offset = src->reg.base_offset;
+ dest->reg.reg = src->reg.reg;
+ if (src->reg.indirect) {
+ dest->reg.indirect = ralloc(mem_ctx, nir_src);
+ nir_src_copy(dest->reg.indirect, src->reg.indirect, mem_ctx);
} else {
- ret.reg.indirect = NULL;
+ dest->reg.indirect = NULL;
}
}
-
- 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);
+ nir_src_copy(&dest->src, &src->src, mem_ctx);
dest->abs = src->abs;
dest->negate = src->negate;
for (unsigned i = 0; i < 4; 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);
+ nir_dest_copy(&dest->dest, &src->dest, mem_ctx);
dest->write_mask = src->write_mask;
dest->saturate = src->saturate;
}
ret->base_offset = deref->base_offset;
ret->deref_array_type = deref->deref_array_type;
if (deref->deref_array_type == nir_deref_array_type_indirect) {
- ret->indirect = nir_src_copy(deref->indirect, mem_ctx);
+ nir_src_copy(&ret->indirect, &deref->indirect, mem_ctx);
}
ret->deref.type = deref->deref.type;
if (deref->deref.child)
struct ssa_def_rewrite_state *state = void_state;
if (src->is_ssa && src->ssa == state->old)
- *src = nir_src_copy(state->new_src, state->mem_ctx);
+ nir_src_copy(src, &state->new_src, state->mem_ctx);
return true;
}
nir_if *if_use = (nir_if *)entry->key;
_mesa_set_remove(def->if_uses, entry);
- if_use->condition = nir_src_copy(new_src, mem_ctx);
+ nir_src_copy(&if_use->condition, &new_src, mem_ctx);
_mesa_set_add(new_if_uses, if_use);
}
}
return dest;
}
-nir_src nir_src_copy(nir_src src, void *mem_ctx);
-nir_dest nir_dest_copy(nir_dest dest, void *mem_ctx);
+void nir_src_copy(nir_src *dest, const nir_src *src, void *mem_ctx);
+void nir_dest_copy(nir_dest *dest, const nir_dest *src, void *mem_ctx);
typedef struct {
nir_src src;
nir_parallel_copy_entry);
exec_list_push_tail(&pcopy->entries, &entry->node);
- entry->src = nir_src_copy(src->src, state->dead_ctx);
+ nir_src_copy(&entry->src, &src->src, state->dead_ctx);
_mesa_set_add(src->src.ssa->uses, &pcopy->instr);
nir_ssa_dest_init(&pcopy->instr, &entry->dest,
assert(src.reg.reg->num_components >= dest_src.reg.reg->num_components);
nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
- mov->src[0].src = nir_src_copy(src, mem_ctx);
+ nir_src_copy(&mov->src[0].src, &src, mem_ctx);
mov->dest.dest = nir_dest_for_reg(dest_src.reg.reg);
mov->dest.write_mask = (1 << dest_src.reg.reg->num_components) - 1;
nir_alu_instr *mul = nir_alu_instr_create(mem_ctx, nir_op_imul);
nir_ssa_dest_init(&mul->instr, &mul->dest.dest, 1, NULL);
mul->dest.write_mask = 0x1;
- mul->src[0].src = nir_src_copy(deref_array->indirect, mem_ctx);
+ nir_src_copy(&mul->src[0].src, &deref_array->indirect, mem_ctx);
mul->src[1].src.is_ssa = true;
mul->src[1].src.ssa = &atomic_counter_size->def;
nir_instr_insert_before(&instr->instr, &mul->instr);
nir_src_for_ssa(&new_instr->dest.ssa),
mem_ctx);
} else {
- new_instr->dest = nir_dest_copy(instr->dest, mem_ctx);
+ nir_dest_copy(&new_instr->dest, &instr->dest, mem_ctx);
}
nir_instr_insert_before(&instr->instr, &new_instr->instr);
nir_op_imul);
mul->src[0].src.is_ssa = true;
mul->src[0].src.ssa = &load_const->def;
- mul->src[1].src = nir_src_copy(deref_array->indirect,
- state->mem_ctx);
+ nir_src_copy(&mul->src[1].src, &deref_array->indirect,
+ state->mem_ctx);
mul->dest.write_mask = 1;
nir_ssa_dest_init(&mul->instr, &mul->dest.dest, 1, NULL);
nir_instr_insert_before(instr, &mul->instr);
nir_src_for_ssa(&load->dest.ssa),
state->mem_ctx);
} else {
- load->dest = nir_dest_copy(intrin->dest, state->mem_ctx);
+ nir_dest_copy(&load->dest, &intrin->dest, state->mem_ctx);
}
nir_instr_insert_before(&intrin->instr, &load->instr);
store->const_index[0] = offset;
store->const_index[1] = 1;
- store->src[0] = nir_src_copy(intrin->src[0], state->mem_ctx);
+ nir_src_copy(&store->src[0], &intrin->src[0], state->mem_ctx);
if (has_indirect)
store->src[1] = indirect;
if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
if (src.reg.indirect == NULL) {
src.reg.indirect = ralloc(state->mem_ctx, nir_src);
- *src.reg.indirect = nir_src_copy(deref_array->indirect,
- state->mem_ctx);
+ nir_src_copy(src.reg.indirect, &deref_array->indirect,
+ state->mem_ctx);
} else {
nir_alu_instr *add = nir_alu_instr_create(state->mem_ctx,
nir_op_iadd);
add->src[0].src = *src.reg.indirect;
- add->src[1].src = nir_src_copy(deref_array->indirect,
- state->mem_ctx);
+ nir_src_copy(&add->src[1].src, &deref_array->indirect,
+ state->mem_ctx);
add->dest.write_mask = 1;
nir_ssa_dest_init(&add->instr, &add->dest.dest, 1, NULL);
nir_instr_insert_before(instr, &add->instr);
nir_src_for_ssa(&mov->dest.dest.ssa),
state->mem_ctx);
} else {
- mov->dest.dest = nir_dest_copy(intrin->dest, state->mem_ctx);
+ nir_dest_copy(&mov->dest.dest, &intrin->dest, state->mem_ctx);
}
nir_instr_insert_before(&intrin->instr, &mov->instr);
&intrin->instr, state);
nir_alu_instr *mov = nir_alu_instr_create(state->mem_ctx, nir_op_imov);
- mov->src[0].src = nir_src_copy(intrin->src[0], state->mem_ctx);
+ nir_src_copy(&mov->src[0].src, &intrin->src[0], state->mem_ctx);
mov->dest.write_mask = (1 << intrin->num_components) - 1;
mov->dest.dest.is_ssa = false;
mov->dest.dest.reg.reg = reg_src.reg.reg;
nir_instr_rewrite_src(&instr->instr,
&instr->src[instr->num_srcs - 1].src,
- nir_src_copy(deref_array->indirect, mem_ctx));
+ deref_array->indirect);
instr->sampler_array_size = glsl_get_length(deref->type);
nir_src_for_ssa(&new_instr->dest.ssa),
mem_ctx);
} else {
- new_instr->dest = nir_dest_copy(instr->dest, mem_ctx);
+ nir_dest_copy(&new_instr->dest, &instr->dest, mem_ctx);
}
nir_instr_insert_before(&instr->instr, &new_instr->instr);
nir_phi_instr *phi = nir_instr_as_phi(instr);
nir_alu_instr *sel = nir_alu_instr_create(state->mem_ctx, nir_op_bcsel);
- sel->src[0].src = nir_src_copy(if_stmt->condition, state->mem_ctx);
+ nir_src_copy(&sel->src[0].src, &if_stmt->condition, state->mem_ctx);
/* Splat the condition to all channels */
memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
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);
+ nir_src_copy(&sel->src[idx].src, &src->src, state->mem_ctx);
}
}
const nir_search_variable *var = nir_search_value_as_variable(value);
assert(state->variables_seen & (1 << var->variable));
- nir_alu_src val = state->variables[var->variable];
- val.src = nir_src_copy(val.src, mem_ctx);
+ nir_alu_src val;
+ nir_alu_src_copy(&val, &state->variables[var->variable], mem_ctx);
return val;
}