diff options
author | Rob Clark <[email protected]> | 2020-02-28 10:06:54 -0800 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-10 16:01:39 +0000 |
commit | 36aed70b591f7f4f642b26f46f7928be6d137e7b (patch) | |
tree | b9ee18546df87013212490ebb42163950a4822d2 | |
parent | b3efa2a4da206112f6c9b5adb2df37c2efe646e6 (diff) |
util/ra: spiff out select_reg_callback
Add a parameter so the callback can know which node it is selecting a
register for. And remove the graph parameter, as it is unused by
existing users, and somewhat unnecessary (ie. the callback data could
be used instead).
And add a comment so $future_me remembers how this works.
Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4071>
-rw-r--r-- | src/broadcom/compiler/vir_register_allocate.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_register_allocate.c | 2 | ||||
-rw-r--r-- | src/util/register_allocate.c | 9 | ||||
-rw-r--r-- | src/util/register_allocate.h | 24 |
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); |