[Mesa-dev] [RFC 1/3] nir: Add a generic instruction index
Kenneth Graunke
kenneth at whitecape.org
Mon Sep 14 11:52:35 PDT 2015
On Tuesday, September 08, 2015 05:35:12 PM Jason Ekstrand wrote:
> ---
> src/glsl/nir/nir.c | 18 ++++++++++++++++++
> src/glsl/nir/nir.h | 4 ++++
> 2 files changed, 22 insertions(+)
Commit message could use a rationale, such as:
This will allow us to efficiently determine whether one instruction
comes before another.
(which is a little different than the reasoning behind SSA defs and
register having indexes...those are for printing...this is IP)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 3f4bec4..156fe94 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -1404,3 +1404,21 @@ 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 = 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 e73b7fb..e7e1881 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -417,6 +417,9 @@ typedef struct nir_instr {
> nir_instr_type type;
> struct nir_block *block;
>
> + /** generic register index. */
> + unsigned index;
Not a register index. An global instruction index or IP of sorts...
Do we want to say something about the how the order of blocks influences
the numbers, and how this affects dominance? It's not immediately
obvious from the code (nir_foreach_block and all...)
Certainly using this within a block is safe and reasonable.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> +
> /* A temporary for optimization and analysis passes to use for storing
> * flags. For instance, DCE uses this to store the "dead/live" info.
> */
> @@ -1739,6 +1742,7 @@ nir_loop *nir_block_get_following_loop(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);
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150914/072f2a48/attachment.sig>
More information about the mesa-dev
mailing list