nir: Add a cursor helper for getting a cursor after any phi nodes
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 28 Dec 2015 06:50:14 +0000 (22:50 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 24 Mar 2016 22:20:44 +0000 (15:20 -0700)
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/compiler/nir/nir.h

index 718d281d7de5f73c1135226b49e3fdf95d5abb39..51d2e79f57039c3b12757f30a94068e1bd529ecd 100644 (file)
@@ -1934,6 +1934,22 @@ nir_after_cf_node(nir_cf_node *node)
    return nir_before_block(nir_cf_node_as_block(nir_cf_node_next(node)));
 }
 
+static inline nir_cursor
+nir_after_cf_node_and_phis(nir_cf_node *node)
+{
+   if (node->type == nir_cf_node_block)
+      return nir_after_block(nir_cf_node_as_block(node));
+
+   nir_block *block = nir_cf_node_as_block(nir_cf_node_next(node));
+   assert(block->cf_node.type == nir_cf_node_block);
+
+   nir_foreach_instr(block, instr) {
+      if (instr->type != nir_instr_type_phi)
+         return nir_before_instr(instr);
+   }
+   return nir_after_block(block);
+}
+
 static inline nir_cursor
 nir_before_cf_list(struct exec_list *cf_list)
 {