From: Jason Ekstrand Date: Tue, 8 Sep 2015 23:43:51 +0000 (-0700) Subject: nir: Add a generic instruction index X-Git-Tag: upstream/17.1.0~16042 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ecaef967d6f2775bf7114d857baf3aaa13643a7;p=platform%2Fupstream%2Fmesa.git nir: Add a generic instruction index Reviewed-by: Kenneth Graunke --- diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index 96cf94c..1ff8f21 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -1435,6 +1435,24 @@ nir_index_ssa_defs(nir_function_impl *impl) 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; +} + gl_system_value nir_system_value_from_intrinsic(nir_intrinsic_op intrin) { diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 3a19bd3..37d3682 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -418,6 +418,9 @@ typedef struct nir_instr { nir_instr_type type; struct nir_block *block; + /** generic instruction index. */ + unsigned index; + /* A temporary for optimization and analysis passes to use for storing * flags. For instance, DCE uses this to store the "dead/live" info. */ @@ -1773,6 +1776,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);