Module: Mesa
Branch: master
Commit: a206b581578d585d845250f62dfb1e6684ddf2f0
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a206b581578d585d845250f62dfb1e6684ddf2f0

Author: Eric Anholt <[email protected]>
Date:   Wed Oct 14 12:11:20 2020 -0700

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3395>

---

 src/compiler/nir/nir.c |  4 ++++
 src/compiler/nir/nir.h | 15 ++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

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

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to