summaryrefslogtreecommitdiffstats
path: root/src/util/register_allocate.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-05-07 17:16:58 -0500
committerJason Ekstrand <[email protected]>2019-05-14 12:30:22 -0500
commit9040215f5d2894e9a900b0f4b154c617f9a0db27 (patch)
treefd2737f63bbfc4d4240710edebb9f28f33c9ceec /src/util/register_allocate.c
parent698bb9b98462e0a3a374ede4bf852a884f907c7f (diff)
util/ra: Add a helper for resetting a node's interference
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/util/register_allocate.c')
-rw-r--r--src/util/register_allocate.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index 8c10741870b..e1138c6a506 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -426,6 +426,31 @@ ra_add_node_adjacency(struct ra_graph *g, unsigned int n1, unsigned int n2)
}
static void
+ra_node_remove_adjacency(struct ra_graph *g, unsigned int n1, unsigned int n2)
+{
+ BITSET_CLEAR(g->nodes[n1].adjacency, n2);
+
+ assert(n1 != n2);
+
+ int n1_class = g->nodes[n1].class;
+ int n2_class = g->nodes[n2].class;
+ g->nodes[n1].q_total -= g->regs->classes[n1_class]->q[n2_class];
+
+ unsigned int i;
+ for (i = 0; i < g->nodes[n1].adjacency_count; i++) {
+ if (g->nodes[n1].adjacency_list[i] == n2) {
+ memmove(&g->nodes[n1].adjacency_list[i],
+ &g->nodes[n1].adjacency_list[i + 1],
+ (g->nodes[n1].adjacency_count - i - 1) *
+ sizeof(g->nodes[n1].adjacency_list[0]));
+ break;
+ }
+ }
+ assert(i < g->nodes[n1].adjacency_count);
+ g->nodes[n1].adjacency_count--;
+}
+
+static void
ra_realloc_interference_graph(struct ra_graph *g, unsigned int alloc)
{
if (alloc <= g->alloc)
@@ -536,6 +561,17 @@ ra_add_node_interference(struct ra_graph *g,
}
}
+void
+ra_reset_node_interference(struct ra_graph *g, unsigned int n)
+{
+ for (unsigned int i = 0; i < g->nodes[n].adjacency_count; i++)
+ ra_node_remove_adjacency(g, g->nodes[n].adjacency_list[i], n);
+
+ memset(g->nodes[n].adjacency, 0,
+ BITSET_WORDS(g->count) * sizeof(BITSET_WORD));
+ g->nodes[n].adjacency_count = 0;
+}
+
static void
update_pq_info(struct ra_graph *g, unsigned int n)
{