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