<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Feb 13, 2016 at 10:01 PM, Jordan Justen <span dir="ltr"><<a href="mailto:jordan.l.justen@intel.com" target="_blank">jordan.l.justen@intel.com</a>></span> wrote:<br><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 2016-02-13 18:14:17, Jason Ekstrand wrote:<br>
> This patch series adds actual function support to NIR. Previously all NIR<br>
> usage relied on GLSL to have lowered functions away entirely. As a result,<br>
> any support for functions that was there was dead code and not really<br>
> tested. With SPIR-V on the horizon, NIR will need real function support.<br>
><br>
> The series starts by deleting some dead code in glsl_to_nir and then<br>
> reworking the way functions and parameters are handled. Here's the new<br>
> (i.e., actually well-defined) scheme:<br>
><br>
> - The nir_function_impl struct has a params array that contains pointers<br>
> to the variables that are the functions arguments and a return_var array<br>
> that, if not NULL points to the return variable.<br>
> - Each of these variables has the "param" mode and does not exist in any<br>
> variable list but instead is reachable only through the params array or<br>
> the return_var pointer.<br>
> - Each variable with the "param" mode has a location. For parameters,<br>
> that location is the index into the param array; for return values, the<br>
> location is defined to be -1.<br>
> - Parameters and return values are not printed with the list of locals but<br>
> are, instead, only printed in the argument list and are now printed with<br>
> their type.<br>
><br>
> Since glsl_to_nir, prog_to_nir, and tgsi_to_nir never produce any functions<br>
> other than main(), it's safe to do these reworks in basically any order.<br>
><br>
> The next part of the series builds up to doing function inlining. However,<br>
> function inlining requires return lowering which pass depends on being able<br>
> to repair SSA form when it's done so we need an SSA repair pass. This, in<br>
> turn requires a phi builder and, while we're at it, we might as well rework<br>
> the into-SSA pass. Yeah, I know, it's kind of the long way there, but what<br>
> can you do?<br>
><br>
> Once we have an SSA repair pass, return lowering and function inlining come<br>
> fairly quickly. However, in order to make return lowering possible, we<br>
> have to patch up control-flow handling so it doesn't break when we try<br>
> remove stuff from the top level of the function.<br>
><br>
> Jason Ekstrand (21):<br>
> nir/glsl: Remove dead function parameter handling code<br>
> nir: Add a new "param" variable mode for parameters and return<br>
> variables<br>
> nir: Add a helper for creating a "bare" nir_function_impl<br>
<br>
</div></div>Yeah, I suppose you could move the param init bits to the next patch.<br>
It seems a little better, but also not too important to me.<br></blockquote><div><br></div><div>Done!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> nir: Create function parameters in function_impl_create<br>
> nir/print: Factor variable name lookup into a helper<br>
> nir/print: Better function argument printing<br>
> nir/validate: Better function validation<br>
> nir/clone: Add support for cloning a single function_impl<br>
<br>
</span>1-8 Reviewed-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br></blockquote><div><br></div><div>Thanks!<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>
> nir: Add a phi node placement helper<br>
> nir/dominance: Handle unreachable blocks<br>
> nir/vars_to_ssa: Use the new nir_phi_builder helper<br>
> util/bitset: Allow iterating over const bitsets<br>
> nir: Add a pass to repair SSA form<br>
> nir/cf: Handle relinking top-level blocks<br>
> nir: Add a function for comparing cursors<br>
> nir/cf: Make extracting or re-inserting nothing a no-op<br>
> nir/builder: Add a helper for inserting jump instructions<br>
> nir: Add a cursor helper for getting a cursor after any phi nodes<br>
> nir: Add return lowering pass<br>
> nir/builder: Add helpers for easily inserting copy_var intrinsics<br>
> nir: Add a pass to inline functions<br>
><br>
> src/compiler/Makefile.sources | 5 +<br>
> src/compiler/nir/Makefile.sources | 5 +<br>
> src/compiler/nir/glsl_to_nir.cpp | 51 +---<br>
> src/compiler/nir/nir.c | 115 +++++++-<br>
> src/compiler/nir/nir.h | 38 ++-<br>
> src/compiler/nir/nir_builder.h | 30 ++<br>
> src/compiler/nir/nir_clone.c | 112 +++++--<br>
> src/compiler/nir/nir_control_flow.c | 16 +-<br>
> src/compiler/nir/nir_dominance.c | 6 +-<br>
> src/compiler/nir/nir_inline_functions.c | 270 +++++++++++++++++<br>
> src/compiler/nir/nir_lower_returns.c | 246 ++++++++++++++++<br>
> src/compiler/nir/nir_lower_vars_to_ssa.c | 484 +++++++++----------------------<br>
> src/compiler/nir/nir_phi_builder.c | 254 ++++++++++++++++<br>
> src/compiler/nir/nir_phi_builder.h | 84 ++++++<br>
> src/compiler/nir/nir_print.c | 76 +++--<br>
> src/compiler/nir/nir_repair_ssa.c | 157 ++++++++++<br>
> src/compiler/nir/nir_validate.c | 24 +-<br>
> src/util/bitset.h | 2 +-<br>
> 18 files changed, 1490 insertions(+), 485 deletions(-)<br>
> create mode 100644 src/compiler/nir/nir_inline_functions.c<br>
> create mode 100644 src/compiler/nir/nir_lower_returns.c<br>
> create mode 100644 src/compiler/nir/nir_phi_builder.c<br>
> create mode 100644 src/compiler/nir/nir_phi_builder.h<br>
> create mode 100644 src/compiler/nir/nir_repair_ssa.c<br>
><br>
> --<br>
> 2.5.0.400.gff86faf<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="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>