Mesa (master): nir/register: Add a parent_instr field

Matt Turner mattst88 at kemper.freedesktop.org
Tue Feb 24 22:08:15 UTC 2015


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

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Jan 29 21:45:53 2015 -0800

nir/register: Add a parent_instr field

This adds a parent_instr field similar to the one for ssa_def.  The
difference here is that the parent_instr field on a nir_register can be
NULL if the register does not have a unique definition or if that
definition does not dominate all its uses.  We set this field in the
out-of-SSA pass so that backends can get SSA-like information even after
they have gone out of SSA.

Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/glsl/nir/nir.c          |    1 +
 src/glsl/nir/nir.h          |   11 ++++++++++-
 src/glsl/nir/nir_from_ssa.c |    7 +++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 5b0e4bc..ab57fd4 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -63,6 +63,7 @@ reg_create(void *mem_ctx, struct exec_list *list)
 {
    nir_register *reg = ralloc(mem_ctx, nir_register);
 
+   reg->parent_instr = NULL;
    reg->uses = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
                                 _mesa_key_pointer_equal);
    reg->defs = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index d74caa9..d5df596 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -66,6 +66,7 @@ name(const in_type *parent)                              \
 struct nir_function_overload;
 struct nir_function;
 struct nir_shader;
+struct nir_instr;
 
 
 /**
@@ -386,6 +387,14 @@ typedef struct {
     */
    bool is_packed;
 
+   /**
+    * If this pointer is non-NULL then this register has exactly one
+    * definition and that definition dominates all of its uses.  This is
+    * set by the out-of-SSA pass so that backends can get SSA-like
+    * information even once they have gone out of SSA.
+    */
+   struct nir_instr *parent_instr;
+
    /** set of nir_instr's where this register is used (read from) */
    struct set *uses;
 
@@ -408,7 +417,7 @@ typedef enum {
    nir_instr_type_parallel_copy,
 } nir_instr_type;
 
-typedef struct {
+typedef struct nir_instr {
    struct exec_node node;
    nir_instr_type type;
    struct nir_block *block;
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 7c50095..c695c95 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -508,6 +508,13 @@ get_register_for_ssa_def(nir_ssa_def *def, struct from_ssa_state *state)
       reg->num_components = def->num_components;
       reg->num_array_elems = 0;
 
+      /* This register comes from an SSA definition that was not part of a
+       * phi-web.  Therefore, we know it has a single unique definition
+       * that dominates all of its uses.  Therefore, we can copy the
+       * parent_instr from the SSA def safely.
+       */
+      reg->parent_instr = def->parent_instr;
+
       _mesa_hash_table_insert(state->ssa_table, def, reg);
       return reg;
    }




More information about the mesa-commit mailing list