[Mesa-dev] [PATCH 01/10] nir: use nir_foreach_ssa_def for indexing ssa defs

Connor Abbott cwabbott0 at gmail.com
Thu Feb 5 15:28:26 PST 2015


Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

On Thu, Feb 5, 2015 at 5:28 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> This is both simpler and more correct.  The old code didn't properly index
> load_const instructions.
> ---
>  src/glsl/nir/nir.c | 26 ++++----------------------
>  1 file changed, 4 insertions(+), 22 deletions(-)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 10e6ed3..9a88bd3 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -2003,37 +2003,19 @@ nir_index_blocks(nir_function_impl *impl)
>  }
>
>  static void
> -index_ssa_def(nir_ssa_def *def, unsigned *index)
> +index_ssa_def_cb(nir_ssa_def *def, void *state)
>  {
> +   unsigned *index = (unsigned *) state;
>     def->index = (*index)++;
> -}
>
> -static bool
> -index_ssa_def_cb(nir_dest *dest, void *state)
> -{
> -   unsigned *index = (unsigned *) state;
> -   if (dest->is_ssa)
> -      index_ssa_def(&dest->ssa, index);
>     return true;
>  }
>
> -static void
> -index_ssa_undef(nir_ssa_undef_instr *instr, unsigned *index)
> -{
> -   index_ssa_def(&instr->def, index);
> -}
> -
>  static bool
>  index_ssa_block(nir_block *block, void *state)
>  {
> -   unsigned *index = (unsigned *) state;
> -
> -   nir_foreach_instr(block, instr) {
> -      if (instr->type == nir_instr_type_ssa_undef)
> -         index_ssa_undef(nir_instr_as_ssa_undef(instr), index);
> -      else
> -         nir_foreach_dest(instr, index_ssa_def_cb, state);
> -   }
> +   nir_foreach_instr(block, instr)
> +      nir_foreach_ssa_def(instr, index_ssa_def_cb, state);
>
>     return true;
>  }
> --
> 2.2.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list