<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 21, 2015 at 12:19 PM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Assuming this actually compiles with GCC 4.4...<br></blockquote><div><br></div><div>I don't know for sure, but it certainly gets us closer<br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Reviewed-by: Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>><br>
<div><div class="h5"><br>
On Wed, Jan 21, 2015 at 2:14 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> Designated initializers with anonymous unions don't work in MSVC or<br>
> GCC < 4.6. With a couple of constructor methods, we don't need them any<br>
> more and the code is actually cleaner.<br>
><br>
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=88467" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=88467</a><br>
> ---<br>
> src/glsl/nir/nir_from_ssa.c | 30 ++++++++----------------------<br>
> src/glsl/nir/nir_lower_atomics.c | 8 +++-----<br>
> src/glsl/nir/nir_lower_io.c | 9 ++-------<br>
> src/glsl/nir/nir_lower_locals_to_regs.c | 9 ++-------<br>
> src/glsl/nir/nir_lower_system_values.c | 8 +++-----<br>
> src/glsl/nir/nir_lower_vars_to_ssa.c | 16 ++++------------<br>
> src/glsl/nir/nir_opt_constant_folding.c | 16 ++++------------<br>
> src/glsl/nir/nir_opt_cse.c | 16 ++++++----------<br>
> src/glsl/nir/nir_opt_peephole_select.c | 8 +++-----<br>
> src/glsl/nir/nir_search.c | 8 ++------<br>
> 10 files changed, 37 insertions(+), 91 deletions(-)<br>
><br>
> diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c<br>
> index 9728b99..8b8f0f5 100644<br>
> --- a/src/glsl/nir/nir_from_ssa.c<br>
> +++ b/src/glsl/nir/nir_from_ssa.c<br>
> @@ -382,12 +382,9 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)<br>
> entry->dest.is_ssa = true;<br>
> nir_ssa_def_init(&block_pcopy->instr, &entry->dest.ssa,<br>
> phi->dest.ssa.num_components, phi-><a href="http://dest.ssa.name" target="_blank">dest.ssa.name</a>);<br>
> -<br>
> - nir_src entry_dest_src = {<br>
> - .ssa = &entry->dest.ssa,<br>
> - .is_ssa = true,<br>
> - };<br>
> - nir_ssa_def_rewrite_uses(&phi->dest.ssa, entry_dest_src, state->mem_ctx);<br>
> + nir_ssa_def_rewrite_uses(&phi->dest.ssa,<br>
> + nir_src_for_ssa(&entry->dest.ssa),<br>
> + state->mem_ctx);<br>
><br>
> entry->src.is_ssa = true;<br>
> entry->src.ssa = &phi->dest.ssa;<br>
> @@ -620,22 +617,16 @@ emit_copy(nir_parallel_copy_instr *pcopy, nir_src src, nir_src dest_src,<br>
> assert(!dest_src.is_ssa &&<br>
> dest_src.reg.indirect == NULL &&<br>
> dest_src.reg.base_offset == 0);<br>
> - nir_dest dest = {<br>
> - .reg.reg = dest_src.reg.reg,<br>
> - .reg.indirect = NULL,<br>
> - .reg.base_offset = 0,<br>
> - .is_ssa = false,<br>
> - };<br>
><br>
> if (src.is_ssa)<br>
> - assert(src.ssa->num_components >= dest.reg.reg->num_components);<br>
> + assert(src.ssa->num_components >= dest_src.reg.reg->num_components);<br>
> else<br>
> - assert(src.reg.reg->num_components >= dest.reg.reg->num_components);<br>
> + assert(src.reg.reg->num_components >= dest_src.reg.reg->num_components);<br>
><br>
> nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);<br>
> mov->src[0].src = nir_src_copy(src, mem_ctx);<br>
> - mov->dest.dest = nir_dest_copy(dest, mem_ctx);<br>
> - mov->dest.write_mask = (1 << dest.reg.reg->num_components) - 1;<br>
> + mov->dest.dest = nir_dest_for_reg(dest_src.reg.reg);<br>
> + mov->dest.write_mask = (1 << dest_src.reg.reg->num_components) - 1;<br>
><br>
> nir_instr_insert_before(&pcopy->instr, &mov->instr);<br>
> }<br>
> @@ -720,12 +711,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,<br>
> values[src_idx] = entry->src;<br>
> }<br>
><br>
> - nir_src dest_src = {<br>
> - .reg.reg = entry->dest.reg.reg,<br>
> - .reg.indirect = NULL,<br>
> - .reg.base_offset = 0,<br>
> - .is_ssa = false,<br>
> - };<br>
> + nir_src dest_src = nir_src_for_reg(entry->dest.reg.reg);<br>
><br>
> int dest_idx = -1;<br>
> for (int i = 0; i < num_vals; ++i) {<br>
> diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c<br>
> index 874c534..c45b397 100644<br>
> --- a/src/glsl/nir/nir_lower_atomics.c<br>
> +++ b/src/glsl/nir/nir_lower_atomics.c<br>
> @@ -115,11 +115,9 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)<br>
> new_instr->dest.is_ssa = true;<br>
> nir_ssa_def_init(&new_instr->instr, &new_instr->dest.ssa,<br>
> instr->dest.ssa.num_components, NULL);<br>
> - nir_src new_dest_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &new_instr->dest.ssa,<br>
> - };<br>
> - nir_ssa_def_rewrite_uses(&instr->dest.ssa, new_dest_src, mem_ctx);<br>
> + nir_ssa_def_rewrite_uses(&instr->dest.ssa,<br>
> + nir_src_for_ssa(&new_instr->dest.ssa),<br>
> + mem_ctx);<br>
> } else {<br>
> new_instr->dest = nir_dest_copy(instr->dest, mem_ctx);<br>
> }<br>
> diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c<br>
> index af87c13..c35058c 100644<br>
> --- a/src/glsl/nir/nir_lower_io.c<br>
> +++ b/src/glsl/nir/nir_lower_io.c<br>
> @@ -238,13 +238,8 @@ nir_lower_io_block(nir_block *block, void *void_state)<br>
> load->dest.is_ssa = true;<br>
> nir_ssa_def_init(&load->instr, &load->dest.ssa,<br>
> intrin->num_components, NULL);<br>
> -<br>
> - nir_src new_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &load->dest.ssa,<br>
> - };<br>
> -<br>
> - nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,<br>
> + nir_ssa_def_rewrite_uses(&intrin->dest.ssa,<br>
> + nir_src_for_ssa(&load->dest.ssa),<br>
> state->mem_ctx);<br>
> } else {<br>
> load->dest = nir_dest_copy(intrin->dest, state->mem_ctx);<br>
> diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c b/src/glsl/nir/nir_lower_locals_to_regs.c<br>
> index b187541..f50533f 100644<br>
> --- a/src/glsl/nir/nir_lower_locals_to_regs.c<br>
> +++ b/src/glsl/nir/nir_lower_locals_to_regs.c<br>
> @@ -215,13 +215,8 @@ lower_locals_to_regs_block(nir_block *block, void *void_state)<br>
> mov->dest.dest.is_ssa = true;<br>
> nir_ssa_def_init(&mov->instr, &mov->dest.dest.ssa,<br>
> intrin->num_components, NULL);<br>
> -<br>
> - nir_src new_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &mov->dest.dest.ssa,<br>
> - };<br>
> -<br>
> - nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,<br>
> + nir_ssa_def_rewrite_uses(&intrin->dest.ssa,<br>
> + nir_src_for_ssa(&mov->dest.dest.ssa),<br>
> state->mem_ctx);<br>
> } else {<br>
> mov->dest.dest = nir_dest_copy(intrin->dest, state->mem_ctx);<br>
> diff --git a/src/glsl/nir/nir_lower_system_values.c b/src/glsl/nir/nir_lower_system_values.c<br>
> index d1b4d26..f681a6c 100644<br>
> --- a/src/glsl/nir/nir_lower_system_values.c<br>
> +++ b/src/glsl/nir/nir_lower_system_values.c<br>
> @@ -74,11 +74,9 @@ convert_instr(nir_intrinsic_instr *instr)<br>
> new_instr->dest.is_ssa = true;<br>
> nir_ssa_def_init(&new_instr->instr, &new_instr->dest.ssa,<br>
> instr->dest.ssa.num_components, NULL);<br>
> - nir_src new_dest_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &new_instr->dest.ssa,<br>
> - };<br>
> - nir_ssa_def_rewrite_uses(&instr->dest.ssa, new_dest_src, mem_ctx);<br>
> + nir_ssa_def_rewrite_uses(&instr->dest.ssa,<br>
> + nir_src_for_ssa(&new_instr->dest.ssa),<br>
> + mem_ctx);<br>
> } else {<br>
> new_instr->dest = nir_dest_copy(instr->dest, mem_ctx);<br>
> }<br>
> diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c<br>
> index 4df9bdd..061dbce 100644<br>
> --- a/src/glsl/nir/nir_lower_vars_to_ssa.c<br>
> +++ b/src/glsl/nir/nir_lower_vars_to_ssa.c<br>
> @@ -765,12 +765,8 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)<br>
> nir_instr_insert_before(&intrin->instr, &undef->instr);<br>
> nir_instr_remove(&intrin->instr);<br>
><br>
> - nir_src new_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &undef->def,<br>
> - };<br>
> -<br>
> - nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,<br>
> + nir_ssa_def_rewrite_uses(&intrin->dest.ssa,<br>
> + nir_src_for_ssa(&undef->def),<br>
> state->mem_ctx);<br>
> continue;<br>
> }<br>
> @@ -795,12 +791,8 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)<br>
> nir_instr_insert_before(&intrin->instr, &mov->instr);<br>
> nir_instr_remove(&intrin->instr);<br>
><br>
> - nir_src new_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &mov->dest.dest.ssa,<br>
> - };<br>
> -<br>
> - nir_ssa_def_rewrite_uses(&intrin->dest.ssa, new_src,<br>
> + nir_ssa_def_rewrite_uses(&intrin->dest.ssa,<br>
> + nir_src_for_ssa(&mov->dest.dest.ssa),<br>
> state->mem_ctx);<br>
> break;<br>
> }<br>
> diff --git a/src/glsl/nir/nir_opt_constant_folding.c b/src/glsl/nir/nir_opt_constant_folding.c<br>
> index 6c02582..878436b 100644<br>
> --- a/src/glsl/nir/nir_opt_constant_folding.c<br>
> +++ b/src/glsl/nir/nir_opt_constant_folding.c<br>
> @@ -216,12 +216,8 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)<br>
><br>
> nir_instr_insert_before(&instr->instr, &dest->instr);<br>
><br>
> - nir_src new_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &dest->def,<br>
> - };<br>
> -<br>
> - nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, new_src, mem_ctx);<br>
> + nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(&dest->def),<br>
> + mem_ctx);<br>
><br>
> nir_instr_remove(&instr->instr);<br>
> ralloc_free(instr);<br>
> @@ -248,12 +244,8 @@ constant_fold_deref(nir_instr *instr, nir_deref_var *deref)<br>
><br>
> arr->base_offset += indirect->value.u[0];<br>
><br>
> - nir_src empty = {<br>
> - .is_ssa = true,<br>
> - .ssa = NULL,<br>
> - };<br>
> -<br>
> - nir_instr_rewrite_src(instr, &arr->indirect, empty);<br>
> + /* Clear out the source */<br>
> + nir_instr_rewrite_src(instr, &arr->indirect, nir_src_for_ssa(NULL));<br>
><br>
> arr->deref_array_type = nir_deref_array_type_direct;<br>
><br>
> diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c<br>
> index 89d78c8..a33ebdd 100644<br>
> --- a/src/glsl/nir/nir_opt_cse.c<br>
> +++ b/src/glsl/nir/nir_opt_cse.c<br>
> @@ -187,12 +187,10 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)<br>
> !exec_node_is_head_sentinel(node); node = node->prev) {<br>
> nir_instr *other = exec_node_data(nir_instr, node, node);<br>
> if (nir_instrs_equal(instr, other)) {<br>
> - nir_src other_dest_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = nir_instr_get_dest_ssa_def(other),<br>
> - };<br>
> + nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);<br>
> nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),<br>
> - other_dest_src, state->mem_ctx);<br>
> + nir_src_for_ssa(other_def),<br>
> + state->mem_ctx);<br>
> nir_instr_remove(instr);<br>
> state->progress = true;<br>
> return;<br>
> @@ -203,12 +201,10 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)<br>
> block != NULL; block = block->imm_dom) {<br>
> nir_foreach_instr_reverse(block, other) {<br>
> if (nir_instrs_equal(instr, other)) {<br>
> - nir_src other_dest_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = nir_instr_get_dest_ssa_def(other),<br>
> - };<br>
> + nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);<br>
> nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),<br>
> - other_dest_src, state->mem_ctx);<br>
> + nir_src_for_ssa(other_def),<br>
> + state->mem_ctx);<br>
> nir_instr_remove(instr);<br>
> state->progress = true;<br>
> return;<br>
> diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c<br>
> index 5d2f5d6..a0b19c2 100644<br>
> --- a/src/glsl/nir/nir_opt_peephole_select.c<br>
> +++ b/src/glsl/nir/nir_opt_peephole_select.c<br>
> @@ -168,11 +168,9 @@ nir_opt_peephole_select_block(nir_block *block, void *void_state)<br>
> phi->dest.ssa.num_components, phi-><a href="http://dest.ssa.name" target="_blank">dest.ssa.name</a>);<br>
> sel->dest.write_mask = (1 << phi->dest.ssa.num_components) - 1;<br>
><br>
> - nir_src sel_dest_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &sel->dest.dest.ssa,<br>
> - };<br>
> - nir_ssa_def_rewrite_uses(&phi->dest.ssa, sel_dest_src, state->mem_ctx);<br>
> + nir_ssa_def_rewrite_uses(&phi->dest.ssa,<br>
> + nir_src_for_ssa(&sel->dest.dest.ssa),<br>
> + state->mem_ctx);<br>
><br>
> nir_instr_insert_before(&phi->instr, &sel->instr);<br>
> nir_instr_remove(&phi->instr);<br>
> diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c<br>
> index 35323f9..a7bd051 100644<br>
> --- a/src/glsl/nir/nir_search.c<br>
> +++ b/src/glsl/nir/nir_search.c<br>
> @@ -314,12 +314,8 @@ nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,<br>
> &instr->instr, mem_ctx);<br>
> nir_instr_insert_before(&instr->instr, &mov->instr);<br>
><br>
> - nir_src replace_src = {<br>
> - .is_ssa = true,<br>
> - .ssa = &mov->dest.dest.ssa,<br>
> - };<br>
> -<br>
> - nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, replace_src, mem_ctx);<br>
> + nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,<br>
> + nir_src_for_ssa(&mov->dest.dest.ssa), mem_ctx);<br>
><br>
> /* We know this one has no more uses because we just rewrote them all,<br>
> * so we can remove it. The rest of the matched expression, however, we<br>
> --<br>
> 2.2.1<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>