[Mesa-dev] [PATCH 3/7] nir: export update_if_uses() and add_def_uses()

Rob Clark robdclark at gmail.com
Sat Oct 24 10:07:56 PDT 2015


From: Rob Clark <robclark at freedesktop.org>

Add it to the private interface, since we'll need it for nir_clone().

Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
 src/glsl/nir/nir.c                      | 13 +++++++++++--
 src/glsl/nir/nir.h                      |  2 ++
 src/glsl/nir/nir_control_flow.c         |  6 +++---
 src/glsl/nir/nir_control_flow_private.h |  1 +
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 300e43f..0cbe4e1 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -728,11 +728,20 @@ add_reg_def_cb(nir_dest *dest, void *state)
    return true;
 }
 
-static void
-add_defs_uses(nir_instr *instr)
+/* TODO better name.. for nir_clone we want to do add_use_cb and
+ * add_reg_def_cb (as part of the 2nd pass), but not add_ssa_def_cb.
+ */
+void
+nir_add_defs_uses(nir_instr *instr)
 {
    nir_foreach_src(instr, add_use_cb, instr);
    nir_foreach_dest(instr, add_reg_def_cb, instr);
+}
+
+static void
+add_defs_uses(nir_instr *instr)
+{
+   nir_add_defs_uses(instr);
    nir_foreach_ssa_def(instr, add_ssa_def_cb, instr);
 }
 
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 097d65b..a09c2a6 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1771,6 +1771,8 @@ nir_after_cf_list(struct exec_list *cf_list)
    return nir_after_cf_node(last_node);
 }
 
+void nir_add_defs_uses(nir_instr *instr);
+
 /**
  * Insert a NIR instruction at the given cursor.
  *
diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c
index 7f51c4f..2c2ef7c 100644
--- a/src/glsl/nir/nir_control_flow.c
+++ b/src/glsl/nir/nir_control_flow.c
@@ -599,8 +599,8 @@ nir_handle_remove_jump(nir_block *block, nir_jump_type type)
    nir_metadata_preserve(impl, nir_metadata_none);
 }
 
-static void
-update_if_uses(nir_cf_node *node)
+void
+nir_update_if_uses(nir_cf_node *node)
 {
    if (node->type != nir_cf_node_if)
       return;
@@ -673,7 +673,7 @@ nir_cf_node_insert(nir_cursor cursor, nir_cf_node *node)
       stitch_blocks(block, after);
       stitch_blocks(before, block);
    } else {
-      update_if_uses(node);
+      nir_update_if_uses(node);
       insert_non_block(before, node, after);
    }
 }
diff --git a/src/glsl/nir/nir_control_flow_private.h b/src/glsl/nir/nir_control_flow_private.h
index f32b57a..c03c9ca 100644
--- a/src/glsl/nir/nir_control_flow_private.h
+++ b/src/glsl/nir/nir_control_flow_private.h
@@ -35,3 +35,4 @@
 
 void nir_handle_add_jump(nir_block *block);
 void nir_handle_remove_jump(nir_block *block, nir_jump_type type);
+void nir_update_if_uses(nir_cf_node *node);
-- 
2.5.0



More information about the mesa-dev mailing list