aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/broadcom/compiler/vir_register_allocate.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_register_allocate.c2
-rw-r--r--src/util/register_allocate.c9
-rw-r--r--src/util/register_allocate.h24
4 files changed, 26 insertions, 11 deletions
diff --git a/src/broadcom/compiler/vir_register_allocate.c b/src/broadcom/compiler/vir_register_allocate.c
index 623cc22cefa..d88a8df1141 100644
--- a/src/broadcom/compiler/vir_register_allocate.c
+++ b/src/broadcom/compiler/vir_register_allocate.c
@@ -309,7 +309,7 @@ struct v3d_ra_select_callback_data {
};
static unsigned int
-v3d_ra_select_callback(struct ra_graph *g, BITSET_WORD *regs, void *data)
+v3d_ra_select_callback(unsigned int n, BITSET_WORD *regs, void *data)
{
struct v3d_ra_select_callback_data *v3d_ra = data;
int r5 = ACC_INDEX + 5;
diff --git a/src/gallium/drivers/vc4/vc4_register_allocate.c b/src/gallium/drivers/vc4/vc4_register_allocate.c
index 1d860ea058e..53faf1ae779 100644
--- a/src/gallium/drivers/vc4/vc4_register_allocate.c
+++ b/src/gallium/drivers/vc4/vc4_register_allocate.c
@@ -208,7 +208,7 @@ struct vc4_ra_select_callback_data {
};
static unsigned int
-vc4_ra_select_callback(struct ra_graph *g, BITSET_WORD *regs, void *data)
+vc4_ra_select_callback(unsigned int n, BITSET_WORD *regs, void *data)
{
struct vc4_ra_select_callback_data *vc4_ra = data;
diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index 85453d25290..56517b5161c 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -171,8 +171,7 @@ struct ra_graph {
unsigned int alloc; /**< count of nodes allocated. */
- unsigned int (*select_reg_callback)(struct ra_graph *g, BITSET_WORD *regs,
- void *data);
+ ra_select_reg_callback select_reg_callback;
void *select_reg_callback_data;
/* Temporary data for the algorithm to scratch around in */
@@ -565,9 +564,7 @@ ra_resize_interference_graph(struct ra_graph *g, unsigned int count)
}
void ra_set_select_reg_callback(struct ra_graph *g,
- unsigned int (*callback)(struct ra_graph *g,
- BITSET_WORD *regs,
- void *data),
+ ra_select_reg_callback callback,
void *data)
{
g->select_reg_callback = callback;
@@ -868,7 +865,7 @@ ra_select(struct ra_graph *g)
return false;
}
- r = g->select_reg_callback(g, select_regs, g->select_reg_callback_data);
+ r = g->select_reg_callback(n, select_regs, g->select_reg_callback_data);
} else {
/* Find the lowest-numbered reg which is not used by a member
* of the graph adjacent to us.
diff --git a/src/util/register_allocate.h b/src/util/register_allocate.h
index fcd4d9394e0..7d8459b1eff 100644
--- a/src/util/register_allocate.h
+++ b/src/util/register_allocate.h
@@ -83,10 +83,28 @@ void ra_resize_interference_graph(struct ra_graph *g, unsigned int count);
void ra_set_node_class(struct ra_graph *g, unsigned int n, unsigned int c);
unsigned int ra_get_node_class(struct ra_graph *g, unsigned int n);
unsigned int ra_add_node(struct ra_graph *g, unsigned int c);
+
+/** @{ Register selection callback.
+ *
+ * The register allocator can use either one of two built-in register
+ * selection behaviors (ie. lowest-available or round-robin), or the
+ * user can implement it's own selection policy by setting an register
+ * selection callback. The parameters to the callback are:
+ *
+ * - n the graph node, ie. the virtual variable to select a
+ * register for
+ * - regs bitset of available registers to choose; this bitset
+ * contains *all* registers, but registers of different
+ * classes will not have their corresponding bit set.
+ * - data callback data specified in ra_set_select_reg_callback()
+ */
+typedef unsigned int (*ra_select_reg_callback)(
+ unsigned int n, /* virtual variable to choose a physical reg for */
+ BITSET_WORD *regs, /* available physical regs to choose from */
+ void *data);
+
void ra_set_select_reg_callback(struct ra_graph *g,
- unsigned int (*callback)(struct ra_graph *g,
- BITSET_WORD *regs,
- void *data),
+ ra_select_reg_callback callback,
void *data);
void ra_add_node_interference(struct ra_graph *g,
unsigned int n1, unsigned int n2);