ir3/ra: Make ir3_reg_interval_remove_all() useful for spilling
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 23 Jul 2021 10:55:39 +0000 (12:55 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 20 Aug 2021 10:37:36 +0000 (10:37 +0000)
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

index 2b2b1fe..242e4c4 100644 (file)
@@ -218,6 +218,16 @@ 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)
@@ -226,6 +236,20 @@ ir3_reg_interval_remove_all(struct ir3_reg_ctx *ctx,
 
    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);
 }
 
 static void
@@ -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,