r300: move building of the interference graph to a separate function

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Reviewed-by: Filip Gawin <filip@gawin.net>
Tested-by: Filip Gawin <filip@gawin.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19618>
This commit is contained in:
Pavel Ondračka 2022-10-29 22:05:38 +02:00 committed by Marge Bot
parent 38f5b287e8
commit 240365a293
3 changed files with 37 additions and 22 deletions

View file

@ -321,28 +321,7 @@ static void do_advanced_regalloc(struct regalloc_state * s)
ra_set_node_class(graph, node_index, node_classes[node_index]);
}
/* Build the interference graph */
for (var_ptr = variables, node_index = 0; var_ptr;
var_ptr = var_ptr->Next,node_index++) {
struct rc_list * a, * b;
unsigned int b_index;
for (a = var_ptr, b = var_ptr->Next, b_index = node_index + 1;
b; b = b->Next, b_index++) {
struct rc_variable * var_a = a->Item;
while (var_a) {
struct rc_variable * var_b = b->Item;
while (var_b) {
if (rc_overlap_live_intervals_array(var_a->Live, var_b->Live)) {
ra_add_node_interference(graph,
node_index, b_index);
}
var_b = var_b->Friend;
}
var_a = var_a->Friend;
}
}
}
rc_build_interference_graph(graph, variables);
/* Add input registers to the interference graph */
for (i = 0, input_node = 0; i< s->NumInputs; i++) {

View file

@ -27,6 +27,7 @@
*/
#include "radeon_regalloc.h"
#include "radeon_list.h"
#define VERBOSE 0
@ -225,6 +226,37 @@ static void add_register_conflicts(
}
}
void rc_build_interference_graph(
struct ra_graph * graph,
struct rc_list * variables)
{
unsigned node_index;
struct rc_list * var_ptr;
/* Build the interference graph */
for (var_ptr = variables, node_index = 0; var_ptr;
var_ptr = var_ptr->Next, node_index++) {
struct rc_list * a, * b;
unsigned int b_index;
for (a = var_ptr, b = var_ptr->Next, b_index = node_index + 1;
b; b = b->Next, b_index++) {
struct rc_variable * var_a = a->Item;
while (var_a) {
struct rc_variable * var_b = b->Item;
while (var_b) {
if (rc_overlap_live_intervals_array(var_a->Live, var_b->Live)) {
ra_add_node_interference(graph,
node_index, b_index);
}
var_b = var_b->Friend;
}
var_a = var_a->Friend;
}
}
}
}
void rc_init_regalloc_state(struct rc_regalloc_state *s)
{
unsigned i, j, index;

View file

@ -125,6 +125,10 @@ static inline int get_reg_id(unsigned int index, unsigned int writemask)
return (index * RC_MASK_XYZW) + (writemask - 1);
}
void rc_build_interference_graph(
struct ra_graph * graph,
struct rc_list * variables);
void rc_init_regalloc_state(struct rc_regalloc_state *s);
void rc_destroy_regalloc_state(struct rc_regalloc_state *s);