{
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,
struct nir_function_overload;
struct nir_function;
struct nir_shader;
+struct nir_instr;
/**
*/
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;
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;
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;
}