diff options
author | Jason Ekstrand <[email protected]> | 2016-12-24 09:42:34 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-12-30 12:38:04 -0800 |
commit | 134a5ad31c8d39219f241f7a7cad246a6864c74b (patch) | |
tree | f31ba3874da61a7d6a75fd13c9dc89f42339a873 /src/compiler/nir/nir.c | |
parent | 832dddcf91f168ab057cb5c7f6914b24ae6b864c (diff) |
nir: Make nir_copy_deref follow the "clone" pattern
We rename it to nir_deref_clone, re-order the sources to match the other
clone functions, and expose nir_deref_var_clone. This past part, in
particular, lets us get rid of quite a few lines since we no longer have
to call nir_copy_deref and wrap it in deref_as_var.
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir.c')
-rw-r--r-- | src/compiler/nir/nir.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 885616e99c3..1f6837a88dd 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -624,18 +624,21 @@ 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_deref_var_clone(const nir_deref_var *deref, void *mem_ctx) { + if (deref == NULL) + return NULL; + nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var); ret->deref.type = deref->deref.type; if (deref->deref.child) - ret->deref.child = nir_copy_deref(ret, deref->deref.child); + ret->deref.child = nir_deref_clone(deref->deref.child, ret); return ret; } static nir_deref_array * -copy_deref_array(void *mem_ctx, nir_deref_array *deref) +deref_array_clone(const nir_deref_array *deref, void *mem_ctx) { nir_deref_array *ret = nir_deref_array_create(mem_ctx); ret->base_offset = deref->base_offset; @@ -645,33 +648,33 @@ copy_deref_array(void *mem_ctx, nir_deref_array *deref) } ret->deref.type = deref->deref.type; if (deref->deref.child) - ret->deref.child = nir_copy_deref(ret, deref->deref.child); + ret->deref.child = nir_deref_clone(deref->deref.child, ret); return ret; } static nir_deref_struct * -copy_deref_struct(void *mem_ctx, nir_deref_struct *deref) +deref_struct_clone(const nir_deref_struct *deref, void *mem_ctx) { nir_deref_struct *ret = nir_deref_struct_create(mem_ctx, deref->index); ret->deref.type = deref->deref.type; if (deref->deref.child) - ret->deref.child = nir_copy_deref(ret, deref->deref.child); + ret->deref.child = nir_deref_clone(deref->deref.child, ret); return ret; } nir_deref * -nir_copy_deref(void *mem_ctx, nir_deref *deref) +nir_deref_clone(const nir_deref *deref, void *mem_ctx) { if (deref == NULL) return NULL; switch (deref->deref_type) { case nir_deref_type_var: - return ©_deref_var(mem_ctx, nir_deref_as_var(deref))->deref; + return &nir_deref_var_clone(nir_deref_as_var(deref), mem_ctx)->deref; case nir_deref_type_array: - return ©_deref_array(mem_ctx, nir_deref_as_array(deref))->deref; + return &deref_array_clone(nir_deref_as_array(deref), mem_ctx)->deref; case nir_deref_type_struct: - return ©_deref_struct(mem_ctx, nir_deref_as_struct(deref))->deref; + return &deref_struct_clone(nir_deref_as_struct(deref), mem_ctx)->deref; default: unreachable("Invalid dereference type"); } |