diff options
author | Jason Ekstrand <[email protected]> | 2015-01-29 21:45:53 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-02-24 14:08:04 -0800 |
commit | c750ecaa1265c3f77d52e69697006cc5ecc3d6dd (patch) | |
tree | 13eb8faeff905e3dbadf441bbe26071326335e66 | |
parent | fc59695b9272335651346bedd7dc8b902a9ccf54 (diff) |
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 <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r-- | src/glsl/nir/nir.c | 1 | ||||
-rw-r--r-- | src/glsl/nir/nir.h | 11 | ||||
-rw-r--r-- | src/glsl/nir/nir_from_ssa.c | 7 |
3 files changed, 18 insertions, 1 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index 5b0e4bc5061..ab57fd4e280 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 d74caa959cc..d5df5960984 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 7c500957767..c695c951f31 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; } |