[Mesa-dev] [PATCH 1/3] ra: cleanup the public API

Connor Abbott cwabbott0 at gmail.com
Tue Jul 29 17:53:34 PDT 2014


Previously, there were 3 entrypoints into parts of the actual allocator,
and an API called ra_allocate_no_spills() that called all 3. Nobody
would ever want to call any of the 3 entrypoints by themselves, so
everybody just used ra_allocate_no_spills(). So just make them static
functions, and while we're at it rename ra_allocate_no_spills() to
ra_allocate() since there's no equivalent "with spills," because the
backend is supposed to handle spilling.

Signed-off-by: Connor Abbott <connor.abbott at intel.com>
---
 src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c |  2 +-
 src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp        |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp      |  2 +-
 src/mesa/program/register_allocate.c                     | 12 ++++++------
 src/mesa/program/register_allocate.h                     |  5 +----
 5 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c
index 1970a34..462adbd 100644
--- a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c
+++ b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c
@@ -617,7 +617,7 @@ static void do_advanced_regalloc(struct regalloc_state * s)
 		input_node++;
 	}
 
-	if (!ra_allocate_no_spills(graph)) {
+	if (!ra_allocate(graph)) {
 		rc_error(s->C, "Ran out of hardware temporaries\n");
 		return;
 	}
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index 3f27364..fa13f0d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -484,7 +484,7 @@ fs_visitor::assign_regs(bool allow_spilling)
       }
    }
 
-   if (!ra_allocate_no_spills(g)) {
+   if (!ra_allocate(g)) {
       /* Failed to allocate registers.  Spill a reg, and the caller will
        * loop back into here to try again.
        */
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
index 1caf5ab..ddab342 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
@@ -207,7 +207,7 @@ vec4_visitor::reg_allocate()
 
    setup_payload_interference(g, first_payload_node, node_count);
 
-   if (!ra_allocate_no_spills(g)) {
+   if (!ra_allocate(g)) {
       /* Failed to allocate registers.  Spill a reg, and the caller will
        * loop back into here to try again.
        */
diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index 6fac690..e47a64a 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -440,7 +440,7 @@ pq_test(struct ra_graph *g, unsigned int n)
  * means that either spilling will be required, or optimistic coloring
  * should be applied.
  */
-bool
+static bool
 ra_simplify(struct ra_graph *g)
 {
    bool progress = true;
@@ -477,7 +477,7 @@ ra_simplify(struct ra_graph *g)
  * If all nodes were trivially colorable, then this must succeed.  If
  * not (optimistic coloring), then it may return false;
  */
-bool
+static bool
 ra_select(struct ra_graph *g)
 {
    int i;
@@ -530,7 +530,7 @@ ra_select(struct ra_graph *g)
  * locally-colorable and the rest of the register allocation
  * will succeed.
  */
-void
+static void
 ra_optimistic_color(struct ra_graph *g)
 {
    unsigned int i;
@@ -547,7 +547,7 @@ ra_optimistic_color(struct ra_graph *g)
 }
 
 bool
-ra_allocate_no_spills(struct ra_graph *g)
+ra_allocate(struct ra_graph *g)
 {
    if (!ra_simplify(g)) {
       ra_optimistic_color(g);
@@ -618,11 +618,11 @@ ra_get_best_spill_node(struct ra_graph *g)
 
    /* For any registers not in the stack to be colored, consider them for
     * spilling.  This will mostly collect nodes that were being optimistally
-    * colored as part of ra_allocate_no_spills() if we didn't successfully
+    * colored as part of ra_allocate() if we didn't successfully
     * optimistically color.
     *
     * It also includes nodes not trivially colorable by ra_simplify() if it
-    * was used directly instead of as part of ra_allocate_no_spills().
+    * was used directly instead of as part of ra_allocate().
     */
    for (n = 0; n < g->count; n++) {
       float cost = g->nodes[n].spill_cost;
diff --git a/src/mesa/program/register_allocate.h b/src/mesa/program/register_allocate.h
index 337dcf7..bfc9190 100644
--- a/src/mesa/program/register_allocate.h
+++ b/src/mesa/program/register_allocate.h
@@ -66,10 +66,7 @@ void ra_add_node_interference(struct ra_graph *g,
 /** @} */
 
 /** @{ Graph-coloring register allocation */
-bool ra_simplify(struct ra_graph *g);
-void ra_optimistic_color(struct ra_graph *g);
-bool ra_select(struct ra_graph *g);
-bool ra_allocate_no_spills(struct ra_graph *g);
+bool ra_allocate(struct ra_graph *g);
 
 unsigned int ra_get_node_reg(struct ra_graph *g, unsigned int n);
 void ra_set_node_reg(struct ra_graph * g, unsigned int n, unsigned int reg);
-- 
1.9.3



More information about the mesa-dev mailing list