entry->dest.is_ssa = true;
nir_ssa_def_init(&block_pcopy->instr, &entry->dest.ssa,
phi->dest.ssa.num_components, phi->dest.ssa.name);
-
- nir_src entry_dest_src = {
- .ssa = &entry->dest.ssa,
- .is_ssa = true,
- };
- nir_ssa_def_rewrite_uses(&phi->dest.ssa, entry_dest_src, state->mem_ctx);
+ nir_ssa_def_rewrite_uses(&phi->dest.ssa,
+ nir_src_for_ssa(&entry->dest.ssa),
+ state->mem_ctx);
entry->src.is_ssa = true;
entry->src.ssa = &phi->dest.ssa;
assert(!dest_src.is_ssa &&
dest_src.reg.indirect == NULL &&
dest_src.reg.base_offset == 0);
- nir_dest dest = {
- .reg.reg = dest_src.reg.reg,
- .reg.indirect = NULL,
- .reg.base_offset = 0,
- .is_ssa = false,
- };
if (src.is_ssa)
- assert(src.ssa->num_components >= dest.reg.reg->num_components);
+ assert(src.ssa->num_components >= dest_src.reg.reg->num_components);
else
- assert(src.reg.reg->num_components >= dest.reg.reg->num_components);
+ 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);
- mov->dest.dest = nir_dest_copy(dest, mem_ctx);
- mov->dest.write_mask = (1 << dest.reg.reg->num_components) - 1;
+ mov->dest.dest = nir_dest_for_reg(dest_src.reg.reg);
+ mov->dest.write_mask = (1 << dest_src.reg.reg->num_components) - 1;
nir_instr_insert_before(&pcopy->instr, &mov->instr);
}
values[src_idx] = entry->src;
}
- nir_src dest_src = {
- .reg.reg = entry->dest.reg.reg,
- .reg.indirect = NULL,
- .reg.base_offset = 0,
- .is_ssa = false,
- };
+ nir_src dest_src = nir_src_for_reg(entry->dest.reg.reg);
int dest_idx = -1;
for (int i = 0; i < num_vals; ++i) {
new_instr->dest.is_ssa = true;
nir_ssa_def_init(&new_instr->instr, &new_instr->dest.ssa,
instr->dest.ssa.num_components, NULL);
- nir_src new_dest_src = {
- .is_ssa = true,
- .ssa = &new_instr->dest.ssa,
- };
- nir_ssa_def_rewrite_uses(&instr->dest.ssa, new_dest_src, mem_ctx);
+ nir_ssa_def_rewrite_uses(&instr->dest.ssa,
+ nir_src_for_ssa(&new_instr->dest.ssa),
+ mem_ctx);
} else {
new_instr->dest = nir_dest_copy(instr->dest, mem_ctx);
}
load->dest.is_ssa = true;
nir_ssa_def_init(&load->instr, &load->dest.ssa,
intrin->num_components, NULL);
-
- nir_src new_src = {
- .is_ssa = true,
- .ssa = &load->dest.ssa,
- };
-
- nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,
+ nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
+ nir_src_for_ssa(&load->dest.ssa),
state->mem_ctx);
} else {
load->dest = nir_dest_copy(intrin->dest, state->mem_ctx);
mov->dest.dest.is_ssa = true;
nir_ssa_def_init(&mov->instr, &mov->dest.dest.ssa,
intrin->num_components, NULL);
-
- nir_src new_src = {
- .is_ssa = true,
- .ssa = &mov->dest.dest.ssa,
- };
-
- nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,
+ nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
+ nir_src_for_ssa(&mov->dest.dest.ssa),
state->mem_ctx);
} else {
mov->dest.dest = nir_dest_copy(intrin->dest, state->mem_ctx);
new_instr->dest.is_ssa = true;
nir_ssa_def_init(&new_instr->instr, &new_instr->dest.ssa,
instr->dest.ssa.num_components, NULL);
- nir_src new_dest_src = {
- .is_ssa = true,
- .ssa = &new_instr->dest.ssa,
- };
- nir_ssa_def_rewrite_uses(&instr->dest.ssa, new_dest_src, mem_ctx);
+ nir_ssa_def_rewrite_uses(&instr->dest.ssa,
+ nir_src_for_ssa(&new_instr->dest.ssa),
+ mem_ctx);
} else {
new_instr->dest = nir_dest_copy(instr->dest, mem_ctx);
}
nir_instr_insert_before(&intrin->instr, &undef->instr);
nir_instr_remove(&intrin->instr);
- nir_src new_src = {
- .is_ssa = true,
- .ssa = &undef->def,
- };
-
- nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,
+ nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
+ nir_src_for_ssa(&undef->def),
state->mem_ctx);
continue;
}
nir_instr_insert_before(&intrin->instr, &mov->instr);
nir_instr_remove(&intrin->instr);
- nir_src new_src = {
- .is_ssa = true,
- .ssa = &mov->dest.dest.ssa,
- };
-
- nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,
+ nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
+ nir_src_for_ssa(&mov->dest.dest.ssa),
state->mem_ctx);
break;
}
nir_instr_insert_before(&instr->instr, &dest->instr);
- nir_src new_src = {
- .is_ssa = true,
- .ssa = &dest->def,
- };
-
- nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, new_src, mem_ctx);
+ nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(&dest->def),
+ mem_ctx);
nir_instr_remove(&instr->instr);
ralloc_free(instr);
arr->base_offset += indirect->value.u[0];
- nir_src empty = {
- .is_ssa = true,
- .ssa = NULL,
- };
-
- nir_instr_rewrite_src(instr, &arr->indirect, empty);
+ /* Clear out the source */
+ nir_instr_rewrite_src(instr, &arr->indirect, nir_src_for_ssa(NULL));
arr->deref_array_type = nir_deref_array_type_direct;
!exec_node_is_head_sentinel(node); node = node->prev) {
nir_instr *other = exec_node_data(nir_instr, node, node);
if (nir_instrs_equal(instr, other)) {
- nir_src other_dest_src = {
- .is_ssa = true,
- .ssa = nir_instr_get_dest_ssa_def(other),
- };
+ nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);
nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),
- other_dest_src, state->mem_ctx);
+ nir_src_for_ssa(other_def),
+ state->mem_ctx);
nir_instr_remove(instr);
state->progress = true;
return;
block != NULL; block = block->imm_dom) {
nir_foreach_instr_reverse(block, other) {
if (nir_instrs_equal(instr, other)) {
- nir_src other_dest_src = {
- .is_ssa = true,
- .ssa = nir_instr_get_dest_ssa_def(other),
- };
+ nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);
nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),
- other_dest_src, state->mem_ctx);
+ nir_src_for_ssa(other_def),
+ state->mem_ctx);
nir_instr_remove(instr);
state->progress = true;
return;
phi->dest.ssa.num_components, phi->dest.ssa.name);
sel->dest.write_mask = (1 << phi->dest.ssa.num_components) - 1;
- nir_src sel_dest_src = {
- .is_ssa = true,
- .ssa = &sel->dest.dest.ssa,
- };
- nir_ssa_def_rewrite_uses(&phi->dest.ssa, sel_dest_src, state->mem_ctx);
+ nir_ssa_def_rewrite_uses(&phi->dest.ssa,
+ nir_src_for_ssa(&sel->dest.dest.ssa),
+ state->mem_ctx);
nir_instr_insert_before(&phi->instr, &sel->instr);
nir_instr_remove(&phi->instr);
nir_instr_insert_before(instr, &alu->instr);
- nir_alu_src val = {
- .src.is_ssa = true,
- .src.ssa = &alu->dest.dest.ssa,
- .negate = false,
- .abs = false,
- .swizzle = { 0, 1, 2, 3 }
- };
+ nir_alu_src val;
+ val.src = nir_src_for_ssa(&alu->dest.dest.ssa);
+ val.negate = false;
+ val.abs = false,
+ memcpy(val.swizzle, identity_swizzle, sizeof val.swizzle);
return val;
}
nir_instr_insert_before(instr, &load->instr);
- nir_alu_src val = {
- .src.is_ssa = true,
- .src.ssa = &load->def,
- .negate = false,
- .abs = false,
- .swizzle = { 0, 0, 0, 0 } /* Splatted scalar */
- };
+ nir_alu_src val;
+ val.src = nir_src_for_ssa(&load->def);
+ val.negate = false;
+ val.abs = false,
+ memset(val.swizzle, 0, sizeof val.swizzle);
return val;
}
&instr->instr, mem_ctx);
nir_instr_insert_before(&instr->instr, &mov->instr);
- nir_src replace_src = {
- .is_ssa = true,
- .ssa = &mov->dest.dest.ssa,
- };
-
- nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, replace_src, mem_ctx);
+ nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,
+ nir_src_for_ssa(&mov->dest.dest.ssa), mem_ctx);
/* We know this one has no more uses because we just rewrote them all,
* so we can remove it. The rest of the matched expression, however, we