[Mesa-dev] [PATCH 08/10] nir: Add an instruction index
Connor Abbott
cwabbott0 at gmail.com
Thu Feb 5 17:17:44 PST 2015
On the one hand, this really should use the metadata framework since
it is metadata. On the other hand, this would get invalidated *all the
time* so it doesn't seem so useful to have a dirty flag for it. Maybe
add a comment explaining this? Other than that,
Connor Abbott <cwabbott0 at gmail.com>
On Thu, Feb 5, 2015 at 5:29 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> This index, unlike the others, has to be manually updated by passes that
> want to use it.
> ---
> src/glsl/nir/nir.c | 20 ++++++++++++++++++++
> src/glsl/nir/nir.h | 4 ++++
> 2 files changed, 24 insertions(+)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 8ea7bb5..6758a72 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -352,6 +352,7 @@ instr_init(nir_instr *instr, nir_instr_type type)
> {
> instr->type = type;
> instr->block = NULL;
> + instr->index = UINT_MAX;
> exec_node_init(&instr->node);
> }
>
> @@ -2081,3 +2082,22 @@ nir_index_ssa_defs(nir_function_impl *impl)
> nir_foreach_block(impl, index_ssa_block, &index);
> impl->ssa_alloc = index;
> }
> +
> +static bool
> +index_instrs_block(nir_block *block, void *state)
> +{
> + unsigned *index = (unsigned *)state;
> +
> + nir_foreach_instr(block, instr)
> + instr->index = (*index)++;
> +
> + return true;
> +}
> +
> +unsigned
> +nir_index_instrs(nir_function_impl *impl)
> +{
> + unsigned index = 0;
> + nir_foreach_block(impl, index_instrs_block, &index);
> + return index;
> +}
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index 8e5e686..c49c731 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -411,6 +411,9 @@ typedef struct {
> nir_instr_type type;
> struct nir_block *block;
>
> + /** generic instruction index. */
> + unsigned index;
> +
> /* flag for dead code elimination (see nir_opt_dce.c) */
> bool live;
> } nir_instr;
> @@ -1504,6 +1507,7 @@ nir_if *nir_block_get_following_if(nir_block *block);
> void nir_index_local_regs(nir_function_impl *impl);
> void nir_index_global_regs(nir_shader *shader);
> void nir_index_ssa_defs(nir_function_impl *impl);
> +unsigned nir_index_instrs(nir_function_impl *impl);
>
> void nir_index_blocks(nir_function_impl *impl);
>
> --
> 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