Mesa (main): nir/cf: Return a cursor from nir_cf_extract as well

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 9 09:30:48 UTC 2022


Module: Mesa
Branch: main
Commit: 25661ea028b4d904693b165cd43bb42a6d2d99a2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=25661ea028b4d904693b165cd43bb42a6d2d99a2

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Tue Apr 26 08:53:31 2022 -0500

nir/cf: Return a cursor from nir_cf_extract as well

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16036>

---

 src/compiler/nir/nir_control_flow.c | 10 +++++++---
 src/compiler/nir/nir_control_flow.h |  3 ++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c
index 3e2688f6fbf..842723ab049 100644
--- a/src/compiler/nir/nir_control_flow.c
+++ b/src/compiler/nir/nir_control_flow.c
@@ -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
diff --git a/src/compiler/nir/nir_control_flow.h b/src/compiler/nir/nir_control_flow.h
index f5956ef16e0..34e79b7ad80 100644
--- a/src/compiler/nir/nir_control_flow.h
+++ b/src/compiler/nir/nir_control_flow.h
@@ -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);
 



More information about the mesa-commit mailing list