nir: Add a block start/end ip to live instr index metadata.

I wanted it for the per-instruction live intervals metadata, and it's not
much to store in general.  Make the ip explicitly 32-bit, on suggestion by
jekstrand.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3395>
This commit is contained in:
Eric Anholt 2020-10-14 12:11:20 -07:00
parent 2f5d18403a
commit a206b58157
2 changed files with 18 additions and 1 deletions

View file

@ -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;

View file

@ -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
*/