nir/cf: Return a cursor from nir_cf_extract as well
authorJason Ekstrand <jason.ekstrand@collabora.com>
Tue, 26 Apr 2022 13:53:31 +0000 (08:53 -0500)
committerMarge Bot <emma+marge@anholt.net>
Mon, 9 May 2022 08:43:40 +0000 (08:43 +0000)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16036>

src/compiler/nir/nir_control_flow.c
src/compiler/nir/nir_control_flow.h

index 3e2688f..842723a 100644 (file)
@@ -678,7 +678,11 @@ cleanup_cf_node(nir_cf_node *node, nir_function_impl *impl)
    }
 }
 
-void
+/**
+ * Extracts everything between two cursors.  Returns the cursor which is
+ * equivalent to the old begin/end curosors.
+ */
+nir_cursor
 nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end)
 {
    nir_block *block_begin, *block_end, *block_before, *block_after;
@@ -686,7 +690,7 @@ nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end)
    if (nir_cursors_equal(begin, end)) {
       exec_list_make_empty(&extracted->list);
       extracted->impl = NULL; /* we shouldn't need this */
-      return;
+      return begin;
    }
 
    split_block_cursor(begin, &block_before, &block_begin);
@@ -737,7 +741,7 @@ nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end)
       cf_node = next;
    }
 
-   stitch_blocks(block_before, block_after);
+   return stitch_blocks(block_before, block_after);
 }
 
 static void
index f5956ef..34e79b7 100644 (file)
@@ -136,7 +136,8 @@ typedef struct {
    nir_function_impl *impl; /* for cleaning up if the list is deleted */
 } nir_cf_list;
 
-void nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end);
+nir_cursor nir_cf_extract(nir_cf_list *extracted, nir_cursor begin,
+                          nir_cursor end);
 
 nir_cursor nir_cf_reinsert(nir_cf_list *cf_list, nir_cursor cursor);