nir: add nir_block_get_following_loop() helper
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 8 May 2015 17:17:10 +0000 (13:17 -0400)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 1 Sep 2015 07:58:17 +0000 (00:58 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/nir/nir.c
src/glsl/nir/nir.h

index bf0013121212f1c7855fa375fbcba92d28ea5789..acb251afe8bb3c6195efa0d73cca3d9acfa913de 100644 (file)
@@ -1335,6 +1335,22 @@ nir_block_get_following_if(nir_block *block)
    return nir_cf_node_as_if(next_node);
 }
 
+nir_loop *
+nir_block_get_following_loop(nir_block *block)
+{
+   if (exec_node_is_tail_sentinel(&block->cf_node.node))
+      return NULL;
+
+   if (nir_cf_node_is_last(&block->cf_node))
+      return NULL;
+
+   nir_cf_node *next_node = nir_cf_node_next(&block->cf_node);
+
+   if (next_node->type != nir_cf_node_loop)
+      return NULL;
+
+   return nir_cf_node_as_loop(next_node);
+}
 static bool
 index_block(nir_block *block, void *state)
 {
index c65d090eac1fd6f13ed76e6c795510956a60f2c9..6853b0e9145d98ad88e313d39309ab77d89fae18 100644 (file)
@@ -1732,6 +1732,8 @@ bool nir_foreach_block_reverse(nir_function_impl *impl, nir_foreach_block_cb cb,
  */
 nir_if *nir_block_get_following_if(nir_block *block);
 
+nir_loop *nir_block_get_following_loop(nir_block *block);
+
 void nir_index_local_regs(nir_function_impl *impl);
 void nir_index_global_regs(nir_shader *shader);
 void nir_index_ssa_defs(nir_function_impl *impl);