[Mesa-dev] [RFC 1/6] nir: Add a helper for copying a deref_var
Jason Ekstrand
jason at jlekstrand.net
Sat Feb 6 05:10:50 UTC 2016
---
src/compiler/nir/nir.c | 6 +++---
src/compiler/nir/nir.h | 1 +
src/compiler/nir/nir_lower_var_copies.c | 4 ++--
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 21bf678..2247a98 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -559,8 +559,8 @@ nir_deref_struct_create(void *mem_ctx, unsigned field_index)
return deref;
}
-static nir_deref_var *
-copy_deref_var(void *mem_ctx, nir_deref_var *deref)
+nir_deref_var *
+nir_copy_deref_var(void *mem_ctx, nir_deref_var *deref)
{
nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var);
ret->deref.type = deref->deref.type;
@@ -599,7 +599,7 @@ nir_copy_deref(void *mem_ctx, nir_deref *deref)
{
switch (deref->deref_type) {
case nir_deref_type_var:
- return ©_deref_var(mem_ctx, nir_deref_as_var(deref))->deref;
+ return &nir_copy_deref_var(mem_ctx, nir_deref_as_var(deref))->deref;
case nir_deref_type_array:
return ©_deref_array(mem_ctx, nir_deref_as_array(deref))->deref;
case nir_deref_type_struct:
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 4968460..3b85bf5 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1697,6 +1697,7 @@ nir_deref_array *nir_deref_array_create(void *mem_ctx);
nir_deref_struct *nir_deref_struct_create(void *mem_ctx, unsigned field_index);
nir_deref *nir_copy_deref(void *mem_ctx, nir_deref *deref);
+nir_deref_var *nir_copy_deref_var(void *mem_ctx, nir_deref_var *deref);
nir_load_const_instr *
nir_deref_get_const_initializer_load(nir_shader *shader, nir_deref_var *deref);
diff --git a/src/compiler/nir/nir_lower_var_copies.c b/src/compiler/nir/nir_lower_var_copies.c
index 8cb3edd..aef5f5e 100644
--- a/src/compiler/nir/nir_lower_var_copies.c
+++ b/src/compiler/nir/nir_lower_var_copies.c
@@ -120,7 +120,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
nir_intrinsic_instr *load =
nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_load_var);
load->num_components = num_components;
- load->variables[0] = nir_deref_as_var(nir_copy_deref(load, &src_head->deref));
+ load->variables[0] = nir_copy_deref_var(load, src_head);
nir_ssa_dest_init(&load->instr, &load->dest, num_components, NULL);
nir_instr_insert_before(©_instr->instr, &load->instr);
@@ -129,7 +129,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_store_var);
store->num_components = num_components;
store->const_index[0] = (1 << num_components) - 1;
- store->variables[0] = nir_deref_as_var(nir_copy_deref(store, &dest_head->deref));
+ store->variables[0] = nir_copy_deref_var(store, dest_head);
store->src[0].is_ssa = true;
store->src[0].ssa = &load->dest.ssa;
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list