summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/nir')
-rw-r--r--src/glsl/nir/nir_from_ssa.c30
-rw-r--r--src/glsl/nir/nir_lower_atomics.c8
-rw-r--r--src/glsl/nir/nir_lower_io.c9
-rw-r--r--src/glsl/nir/nir_lower_locals_to_regs.c9
-rw-r--r--src/glsl/nir/nir_lower_system_values.c8
-rw-r--r--src/glsl/nir/nir_lower_vars_to_ssa.c16
-rw-r--r--src/glsl/nir/nir_opt_constant_folding.c16
-rw-r--r--src/glsl/nir/nir_opt_cse.c16
-rw-r--r--src/glsl/nir/nir_opt_peephole_select.c8
-rw-r--r--src/glsl/nir/nir_search.c32
10 files changed, 47 insertions, 105 deletions
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 9728b9980cc..8b8f0f5ac75 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -382,12 +382,9 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
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;
@@ -620,22 +617,16 @@ emit_copy(nir_parallel_copy_instr *pcopy, nir_src src, nir_src dest_src,
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);
}
@@ -720,12 +711,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
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) {
diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c
index 874c5347634..c45b397afba 100644
--- a/src/glsl/nir/nir_lower_atomics.c
+++ b/src/glsl/nir/nir_lower_atomics.c
@@ -115,11 +115,9 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
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);
}
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index af87c13e17a..c35058c14dc 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -238,13 +238,8 @@ nir_lower_io_block(nir_block *block, void *void_state)
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);
diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c b/src/glsl/nir/nir_lower_locals_to_regs.c
index b187541405a..f50533f9575 100644
--- a/src/glsl/nir/nir_lower_locals_to_regs.c
+++ b/src/glsl/nir/nir_lower_locals_to_regs.c
@@ -215,13 +215,8 @@ lower_locals_to_regs_block(nir_block *block, void *void_state)
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);
diff --git a/src/glsl/nir/nir_lower_system_values.c b/src/glsl/nir/nir_lower_system_values.c
index d1b4d26e2ae..f681a6ce934 100644
--- a/src/glsl/nir/nir_lower_system_values.c
+++ b/src/glsl/nir/nir_lower_system_values.c
@@ -74,11 +74,9 @@ convert_instr(nir_intrinsic_instr *instr)
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);
}
diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c
index 4df9bdd8897..061dbce1782 100644
--- a/src/glsl/nir/nir_lower_vars_to_ssa.c
+++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
@@ -765,12 +765,8 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
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;
}
@@ -795,12 +791,8 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
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;
}
diff --git a/src/glsl/nir/nir_opt_constant_folding.c b/src/glsl/nir/nir_opt_constant_folding.c
index 6c02582ed01..878436b5252 100644
--- a/src/glsl/nir/nir_opt_constant_folding.c
+++ b/src/glsl/nir/nir_opt_constant_folding.c
@@ -216,12 +216,8 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
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);
@@ -248,12 +244,8 @@ constant_fold_deref(nir_instr *instr, nir_deref_var *deref)
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;
diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
index 89d78c8d34e..a33ebdd9981 100644
--- a/src/glsl/nir/nir_opt_cse.c
+++ b/src/glsl/nir/nir_opt_cse.c
@@ -187,12 +187,10 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)
!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;
@@ -203,12 +201,10 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)
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;
diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c
index 5d2f5d6208d..a0b19c2ef25 100644
--- a/src/glsl/nir/nir_opt_peephole_select.c
+++ b/src/glsl/nir/nir_opt_peephole_select.c
@@ -168,11 +168,9 @@ nir_opt_peephole_select_block(nir_block *block, void *void_state)
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);
diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c
index 35323f92a6b..e69fdfd431c 100644
--- a/src/glsl/nir/nir_search.c
+++ b/src/glsl/nir/nir_search.c
@@ -221,13 +221,11 @@ construct_value(const nir_search_value *value, nir_alu_type type,
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;
}
@@ -265,13 +263,11 @@ construct_value(const nir_search_value *value, nir_alu_type type,
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;
}
@@ -314,12 +310,8 @@ nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,
&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