<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 17, 2014 at 2:35 PM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> ---<br>
> src/glsl/nir/nir.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-<br>
> src/glsl/nir/nir.h | 23 +++++++++++++++++++++++<br>
> src/glsl/nir/nir_print.c | 21 +++++++++++++++++++++<br>
> 3 files changed, 88 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c<br>
> index 27e903e..d3fd084 100644<br>
> --- a/src/glsl/nir/nir.c<br>
> +++ b/src/glsl/nir/nir.c<br>
> @@ -475,6 +475,18 @@ nir_phi_instr_create(void *mem_ctx)<br>
> return instr;<br>
> }<br>
><br>
> +nir_parallel_copy_instr *<br>
> +nir_parallel_copy_instr_create(void *mem_ctx)<br>
> +{<br>
> + nir_parallel_copy_instr *instr = ralloc(mem_ctx, nir_parallel_copy_instr);<br>
> + instr_init(&instr->instr, nir_instr_type_parallel_copy);<br>
> +<br>
> + instr->at_end = false;<br>
> + exec_list_make_empty(&instr->copies);<br>
> +<br>
> + return instr;<br>
> +}<br>
> +<br>
> nir_ssa_undef_instr *<br>
> nir_ssa_undef_instr_create(void *mem_ctx)<br>
> {<br>
> @@ -1377,6 +1389,18 @@ visit_phi_dest(nir_phi_instr *instr, nir_foreach_dest_cb cb, void *state)<br>
> return cb(&instr->dest, state);<br>
> }<br>
><br>
> +static bool<br>
> +visit_parallel_copy_dest(nir_parallel_copy_instr *instr,<br>
> + nir_foreach_dest_cb cb, void *state)<br>
> +{<br>
> + foreach_list_typed(nir_parallel_copy_copy, copy, node, &instr->copies) {<br>
> + if (!cb(©->dest, state))<br>
> + return false;<br>
> + }<br>
> +<br>
> + return true;<br>
> +}<br>
> +<br>
> bool<br>
> nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state)<br>
> {<br>
> @@ -1391,7 +1415,9 @@ nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state)<br>
> return visit_load_const_dest(nir_instr_as_load_const(instr), cb, state);<br>
> case nir_instr_type_phi:<br>
> return visit_phi_dest(nir_instr_as_phi(instr), cb, state);<br>
> - break;<br>
> + case nir_instr_type_parallel_copy:<br>
> + return visit_parallel_copy_dest(nir_instr_as_parallel_copy(instr),<br>
> + cb, state);<br>
><br>
> case nir_instr_type_ssa_undef:<br>
> case nir_instr_type_call:<br>
> @@ -1526,6 +1552,18 @@ visit_phi_src(nir_phi_instr *instr, nir_foreach_src_cb cb, void *state)<br>
> return true;<br>
> }<br>
><br>
> +static bool<br>
> +visit_parallel_copy_src(nir_parallel_copy_instr *instr,<br>
> + nir_foreach_src_cb cb, void *state)<br>
> +{<br>
> + foreach_list_typed(nir_parallel_copy_copy, copy, node, &instr->copies) {<br>
> + if (!visit_src(©->src, cb, state))<br>
> + return false;<br>
> + }<br>
> +<br>
> + return true;<br>
> +}<br>
> +<br>
> typedef struct {<br>
> void *state;<br>
> nir_foreach_src_cb cb;<br>
> @@ -1570,6 +1608,11 @@ nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state)<br>
> if (!visit_phi_src(nir_instr_as_phi(instr), cb, state))<br>
> return false;<br>
> break;<br>
> + case nir_instr_type_parallel_copy:<br>
> + if (!visit_parallel_copy_src(nir_instr_as_parallel_copy(instr),<br>
> + cb, state))<br>
> + return false;<br>
> + break;<br>
> case nir_instr_type_jump:<br>
> case nir_instr_type_ssa_undef:<br>
> return true;<br>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h<br>
> index 988a135..2ebf826 100644<br>
> --- a/src/glsl/nir/nir.h<br>
> +++ b/src/glsl/nir/nir.h<br>
> @@ -396,6 +396,7 @@ typedef enum {<br>
> nir_instr_type_jump,<br>
> nir_instr_type_ssa_undef,<br>
> nir_instr_type_phi,<br>
> + nir_instr_type_parallel_copy,<br>
> } nir_instr_type;<br>
><br>
> typedef struct {<br>
> @@ -933,6 +934,24 @@ typedef struct {<br>
> nir_dest dest;<br>
> } nir_phi_instr;<br>
><br>
> +typedef struct {<br>
> + struct exec_node node;<br>
> + nir_src src;<br>
> + nir_dest dest;<br>
> +} nir_parallel_copy_copy;<br>
<br>
</div></div>I don't really care too much what this is called, but maybe something<br>
less silly like "nir_parallel_copy_entry"?<br>
<span class=""><br>
> +<br>
> +typedef struct {<br>
> + nir_instr instr;<br>
> +<br>
> + /* Indicates that this is the parallel copy at the end of the block.<br>
> + * When isolating phi nodes, we create 2 parallel copies in most blocks;<br>
> + * this flag helps tell them apart.<br>
> + */<br>
> + bool at_end;<br>
<br>
</span>Do we really need this? I haven't read the pass yet, but I thought we<br>
could figure this out by checking to see if we're the last instruction<br>
of the basic block.<br></blockquote><div><br></div><div>Patches 139 and 140 clean up both of these issues<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">
<div><div class="h5"><br>
> +<br>
> + struct exec_list copies;<br>
> +} nir_parallel_copy_instr;<br>
> +<br>
> #define nir_instr_as_alu(_instr) exec_node_data(nir_alu_instr, _instr, instr)<br>
> #define nir_instr_as_call(_instr) exec_node_data(nir_call_instr, _instr, instr)<br>
> #define nir_instr_as_jump(_instr) exec_node_data(nir_jump_instr, _instr, instr)<br>
> @@ -946,6 +965,8 @@ typedef struct {<br>
> exec_node_data(nir_ssa_undef_instr, _instr, instr)<br>
> #define nir_instr_as_phi(_instr) \<br>
> exec_node_data(nir_phi_instr, _instr, instr)<br>
> +#define nir_instr_as_parallel_copy(_instr) \<br>
> + exec_node_data(nir_parallel_copy_instr, _instr, instr)<br>
><br>
><br>
> /*<br>
> @@ -1251,6 +1272,8 @@ nir_tex_instr *nir_tex_instr_create(void *mem_ctx, unsigned num_srcs);<br>
><br>
> nir_phi_instr *nir_phi_instr_create(void *mem_ctx);<br>
><br>
> +nir_parallel_copy_instr *nir_parallel_copy_instr_create(void *mem_ctx);<br>
> +<br>
> nir_ssa_undef_instr *nir_ssa_undef_instr_create(void *mem_ctx);<br>
><br>
> nir_deref_var *nir_deref_var_create(void *mem_ctx, nir_variable *var);<br>
> diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c<br>
> index 4981110..0140f4e 100644<br>
> --- a/src/glsl/nir/nir_print.c<br>
> +++ b/src/glsl/nir/nir_print.c<br>
> @@ -607,6 +607,23 @@ print_phi_instr(nir_phi_instr *instr, FILE *fp)<br>
> }<br>
><br>
> static void<br>
> +print_parallel_copy_instr(nir_parallel_copy_instr *instr, FILE *fp)<br>
> +{<br>
> + bool first = true;<br>
> + fprintf(fp, "pcopy: ");<br>
> + foreach_list_typed(nir_parallel_copy_copy, copy, node, &instr->copies) {<br>
> + if (!first)<br>
> + fprintf(fp, "; ");<br>
> +<br>
> + print_dest(©->dest, fp);<br>
> + fprintf(fp, " = ");<br>
> + print_src(©->src, fp);<br>
> +<br>
> + first = false;<br>
> + }<br>
> +}<br>
> +<br>
> +static void<br>
> print_instr(nir_instr *instr, print_var_state *state, unsigned tabs, FILE *fp)<br>
> {<br>
> print_tabs(tabs, fp);<br>
> @@ -644,6 +661,10 @@ print_instr(nir_instr *instr, print_var_state *state, unsigned tabs, FILE *fp)<br>
> print_phi_instr(nir_instr_as_phi(instr), fp);<br>
> break;<br>
><br>
> + case nir_instr_type_parallel_copy:<br>
> + print_parallel_copy_instr(nir_instr_as_parallel_copy(instr), fp);<br>
> + break;<br>
> +<br>
> default:<br>
> unreachable("Invalid instruction type");<br>
> break;<br>
> --<br>
> 2.2.0<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></div></div>