aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_deref.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-03-15 15:37:50 -0700
committerJason Ekstrand <[email protected]>2018-06-22 20:15:54 -0700
commit54e440945ed67a8850f4e0d6133cfb3bb7a64e68 (patch)
tree644291167d0784df9d4c76988c07a7ee86d06c1c /src/compiler/nir/nir_deref.c
parentf917814c14b4910929da498aa5cce790fa2ec8ec (diff)
nir: Add a pass for fixing deref modes
This will be needed by anything which changes variable modes without rewriting derefs. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_deref.c')
-rw-r--r--src/compiler/nir/nir_deref.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index d7b4bbcdcd6..762b21833cf 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -354,3 +354,33 @@ nir_lower_deref_instrs(nir_shader *shader,
return progress;
}
+
+void
+nir_fixup_deref_modes(nir_shader *shader)
+{
+ nir_foreach_function(function, shader) {
+ if (!function->impl)
+ continue;
+
+ nir_foreach_block(block, function->impl) {
+ nir_foreach_instr(instr, block) {
+ if (instr->type != nir_instr_type_deref)
+ continue;
+
+ nir_deref_instr *deref = nir_instr_as_deref(instr);
+
+ nir_variable_mode parent_mode;
+ if (deref->deref_type == nir_deref_type_var) {
+ parent_mode = deref->var->data.mode;
+ } else {
+ assert(deref->parent.is_ssa);
+ nir_deref_instr *parent =
+ nir_instr_as_deref(deref->parent.ssa->parent_instr);
+ parent_mode = parent->mode;
+ }
+
+ deref->mode = parent_mode;
+ }
+ }
+ }
+}