diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-11-07 12:01:50 -0800 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-11-07 12:09:44 -0800 |
commit | 6c731d85666abb61c49e5b4affa196545f5ac086 (patch) | |
tree | 1139e86fa75ff56b19f79caa64173102c7589cd3 /src | |
parent | 7d90e570f311066d1fd1eaafe681a8c939c86bae (diff) | |
download | external_mesa3d-6c731d85666abb61c49e5b4affa196545f5ac086.zip external_mesa3d-6c731d85666abb61c49e5b4affa196545f5ac086.tar.gz external_mesa3d-6c731d85666abb61c49e5b4affa196545f5ac086.tar.bz2 |
nir: Add a nir_deref_tail helper
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/nir/nir.h | 9 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_var_copies.c | 15 | ||||
-rw-r--r-- | src/glsl/nir/nir_split_var_copies.c | 12 |
3 files changed, 13 insertions, 23 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index ef39df5..2559ef2 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -785,6 +785,15 @@ NIR_DEFINE_CAST(nir_deref_as_var, nir_deref, nir_deref_var, deref) NIR_DEFINE_CAST(nir_deref_as_array, nir_deref, nir_deref_array, deref) NIR_DEFINE_CAST(nir_deref_as_struct, nir_deref, nir_deref_struct, deref) +/* Returns the last deref in the chain. */ +static inline nir_deref * +nir_deref_tail(nir_deref *deref) +{ + while (deref->child) + deref = deref->child; + return deref; +} + typedef struct { nir_instr instr; diff --git a/src/glsl/nir/nir_lower_var_copies.c b/src/glsl/nir/nir_lower_var_copies.c index 2167290..98c107a 100644 --- a/src/glsl/nir/nir_lower_var_copies.c +++ b/src/glsl/nir/nir_lower_var_copies.c @@ -53,17 +53,6 @@ deref_next_wildcard_parent(nir_deref *deref) return NULL; } -/* Returns the last deref in the chain. - */ -static nir_deref * -get_deref_tail(nir_deref *deref) -{ - while (deref->child) - deref = deref->child; - - return deref; -} - /* This function recursively walks the given deref chain and replaces the * given copy instruction with an equivalent sequence load/store * operations. @@ -121,8 +110,8 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr, } else { /* In this case, we have no wildcards anymore, so all we have to do * is just emit the load and store operations. */ - src_tail = get_deref_tail(src_tail); - dest_tail = get_deref_tail(dest_tail); + src_tail = nir_deref_tail(src_tail); + dest_tail = nir_deref_tail(dest_tail); assert(src_tail->type == dest_tail->type); diff --git a/src/glsl/nir/nir_split_var_copies.c b/src/glsl/nir/nir_split_var_copies.c index d463f7b..bfbef72 100644 --- a/src/glsl/nir/nir_split_var_copies.c +++ b/src/glsl/nir/nir_split_var_copies.c @@ -67,14 +67,6 @@ struct split_var_copies_state { bool progress; }; -static nir_deref * -get_deref_tail(nir_deref *deref) -{ - while (deref->child != NULL) - deref = deref->child; - return deref; -} - /* Recursively constructs deref chains to split a copy instruction into * multiple (if needed) copy instructions with full-length deref chains. * External callers of this function should pass the tail and head of the @@ -227,8 +219,8 @@ split_var_copies_block(nir_block *block, void *void_state) nir_deref *dest_head = &intrinsic->variables[0]->deref; nir_deref *src_head = &intrinsic->variables[1]->deref; - nir_deref *dest_tail = get_deref_tail(dest_head); - nir_deref *src_tail = get_deref_tail(src_head); + nir_deref *dest_tail = nir_deref_tail(dest_head); + nir_deref *src_tail = nir_deref_tail(src_head); switch (glsl_get_base_type(src_tail->type)) { case GLSL_TYPE_ARRAY: |