diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index b3a5384f663..66bfb399225 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -1929,8 +1929,12 @@ nir_index_instrs(nir_function_impl *impl) unsigned index = 0; nir_foreach_block(block, impl) { + block->start_ip = index; + nir_foreach_instr(instr, block) instr->index = index++; + + block->end_ip = index; } return index; diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 70eed7948ea..250d47f79b4 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -747,7 +747,7 @@ typedef struct nir_instr { uint8_t pass_flags; /** generic instruction index. */ - unsigned index; + uint32_t index; } nir_instr; static inline nir_instr * @@ -2670,6 +2670,19 @@ typedef struct nir_block { */ uint32_t dom_pre_index, dom_post_index; + /** + * nir_instr->index for the first nir_instr in the block. If the block is + * empty, it will be the index of the immediately previous instr, or 0. + * Valid when the impl has nir_metadata_instr_index. + */ + uint32_t start_ip; + /** + * nir_instr->index for the last nir_instr in the block. If the block is + * empty, it will be the same as start_ip. Valid when the impl has + * nir_metadata_instr_index. + */ + uint32_t end_ip; + /* SSA def live in and out for this block; used for liveness analysis. * Indexed by ssa_def->index */