+ util_dynarray_append(&g->nodes[n1].adjacency_list, 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];
+
+ util_dynarray_delete_unordered(&g->nodes[n1].adjacency_list, unsigned int,
+ n2);
+}
+
+static void
+ra_realloc_interference_graph(struct ra_graph *g, unsigned int alloc)
+{
+ if (alloc <= g->alloc)
+ return;
+
+ /* If we always have a whole number of BITSET_WORDs, it makes it much
+ * easier to memset the top of the growing bitsets.
+ */
+ assert(g->alloc % BITSET_WORDBITS == 0);
+ alloc = align64(alloc, BITSET_WORDBITS);
+
+ g->nodes = reralloc(g, g->nodes, struct ra_node, alloc);
+
+ unsigned g_bitset_count = BITSET_WORDS(g->alloc);
+ unsigned bitset_count = BITSET_WORDS(alloc);
+ /* For nodes already in the graph, we just have to grow the adjacency set */
+ for (unsigned i = 0; i < g->alloc; i++) {
+ assert(g->nodes[i].adjacency != NULL);
+ g->nodes[i].adjacency = rerzalloc(g, g->nodes[i].adjacency, BITSET_WORD,
+ g_bitset_count, bitset_count);
+ }
+
+ /* For new nodes, we have to fully initialize them */
+ for (unsigned i = g->alloc; i < alloc; i++) {
+ memset(&g->nodes[i], 0, sizeof(g->nodes[i]));
+ g->nodes[i].adjacency = rzalloc_array(g, BITSET_WORD, bitset_count);
+ util_dynarray_init(&g->nodes[i].adjacency_list, g);
+ g->nodes[i].q_total = 0;
+
+ g->nodes[i].forced_reg = NO_REG;
+ g->nodes[i].reg = NO_REG;