Mesa (main): ir3/ra: Make ir3_reg_interval_remove_all() useful for spilling

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 20 10:57:10 UTC 2021


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

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Fri Jul 23 12:55:39 2021 +0200

ir3/ra: Make ir3_reg_interval_remove_all() useful for spilling

RA uses this to pop and then reinsert intervals when shuffling around
registers. For spilling, we want to remove the interval and also mark
all its descendants as removed. Since "remove_all" sounds more like the
latter, rename the old "remove_all" to "remove_temp". "remove_all" was
already exposed in ir3_ra.h, so there's no need to add it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12033>

---

 src/freedreno/ir3/ir3_ra.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c
index 2b2b1fec1e4..242e4c4fdf1 100644
--- a/src/freedreno/ir3/ir3_ra.c
+++ b/src/freedreno/ir3/ir3_ra.c
@@ -218,12 +218,36 @@ ir3_reg_interval_remove(struct ir3_reg_ctx *ctx,
    interval->inserted = false;
 }
 
+static void
+_mark_free(struct ir3_reg_interval *interval)
+{
+   interval->inserted = false;
+   rb_tree_foreach (struct ir3_reg_interval, child, &interval->children, node) {
+      _mark_free(child);
+   }
+}
+
+/* Remove an interval and all its children from the tree. */
 void
 ir3_reg_interval_remove_all(struct ir3_reg_ctx *ctx,
                             struct ir3_reg_interval *interval)
 {
    assert(!interval->parent);
 
+   ctx->interval_delete(ctx, interval);
+   rb_tree_remove(&ctx->intervals, &interval->node);
+   _mark_free(interval);
+}
+
+/* Used when popping an interval to be shuffled around. Don't disturb children
+ * so that it can be later reinserted.
+ */
+static void
+ir3_reg_interval_remove_temp(struct ir3_reg_ctx *ctx,
+                             struct ir3_reg_interval *interval)
+{
+   assert(!interval->parent);
+
    ctx->interval_delete(ctx, interval);
    rb_tree_remove(&ctx->intervals, &interval->node);
 }
@@ -675,7 +699,7 @@ ra_pop_interval(struct ra_ctx *ctx, struct ra_file *file,
                    });
    }
 
-   ir3_reg_interval_remove_all(&file->reg_ctx, &interval->interval);
+   ir3_reg_interval_remove_temp(&file->reg_ctx, &interval->interval);
 
    return (struct ra_removed_interval){
       .interval = interval,



More information about the mesa-commit mailing list