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

Author: Eric Anholt <[email protected]>
Date:   Tue Sep 29 15:33:39 2020 -0700

nir: Introduce nir_metadata_instr_index for nir_index_instr() being current.

This will be useful to remove the live_index field from nir_ssa_def.

Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3395>

---

 src/compiler/nir/nir.c          |  3 +++
 src/compiler/nir/nir.h          | 12 ++++++++++++
 src/compiler/nir/nir_metadata.c |  2 ++
 3 files changed, 17 insertions(+)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 34faa346f25..032dbcb3be5 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -935,6 +935,9 @@ nir_instr_insert(nir_cursor cursor, nir_instr *instr)
 
    if (instr->type == nir_instr_type_jump)
       nir_handle_add_jump(instr->block);
+
+   nir_function_impl *impl = nir_cf_node_get_function(&instr->block->cf_node);
+   impl->valid_metadata &= ~nir_metadata_instr_index;
 }
 
 static bool
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 99ad032caff..b480e691008 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2869,6 +2869,18 @@ typedef enum {
     */
    nir_metadata_loop_analysis = 0x10,
 
+   /** Indicates that nir_instr::index values are valid.
+    *
+    * The start instruction has index 0 and they increase through a natural
+    * walk of instructions in blocks in the CFG.  The indices my have holes
+    * after passes such as DCE.
+    *
+    * A pass can preserve this metadata type if it never adds or moves any
+    * instructions (most passes shouldn't preserve this metadata type), but
+    * can preserve it if it only removes instructions.
+    */
+   nir_metadata_instr_index = 0x20,
+
    /** All metadata
     *
     * This includes all nir_metadata flags except not_properly_reset.  Passes
diff --git a/src/compiler/nir/nir_metadata.c b/src/compiler/nir/nir_metadata.c
index 6122394d8b5..0cc8f0624d0 100644
--- a/src/compiler/nir/nir_metadata.c
+++ b/src/compiler/nir/nir_metadata.c
@@ -37,6 +37,8 @@ nir_metadata_require(nir_function_impl *impl, nir_metadata 
required, ...)
 
    if (NEEDS_UPDATE(nir_metadata_block_index))
       nir_index_blocks(impl);
+   if (NEEDS_UPDATE(nir_metadata_instr_index))
+      nir_index_instrs(impl);
    if (NEEDS_UPDATE(nir_metadata_dominance))
       nir_calc_dominance_impl(impl);
    if (NEEDS_UPDATE(nir_metadata_live_ssa_defs))

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

Reply via email to