Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright © 2010 Intel Corporation
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8.  * and/or sell copies of the Software, and to permit persons to whom the
  9.  * Software is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice (including the next
  12.  * paragraph) shall be included in all copies or substantial portions of the
  13.  * Software.
  14.  *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  18.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21.  * IN THE SOFTWARE.
  22.  *
  23.  * Authors:
  24.  *    Eric Anholt <eric@anholt.net>
  25.  *
  26.  */
  27.  
  28. /** @file register_allocate.c
  29.  *
  30.  * Graph-coloring register allocator.
  31.  *
  32.  * The basic idea of graph coloring is to make a node in a graph for
  33.  * every thing that needs a register (color) number assigned, and make
  34.  * edges in the graph between nodes that interfere (can't be allocated
  35.  * to the same register at the same time).
  36.  *
  37.  * During the "simplify" process, any any node with fewer edges than
  38.  * there are registers means that that edge can get assigned a
  39.  * register regardless of what its neighbors choose, so that node is
  40.  * pushed on a stack and removed (with its edges) from the graph.
  41.  * That likely causes other nodes to become trivially colorable as well.
  42.  *
  43.  * Then during the "select" process, nodes are popped off of that
  44.  * stack, their edges restored, and assigned a color different from
  45.  * their neighbors.  Because they were pushed on the stack only when
  46.  * they were trivially colorable, any color chosen won't interfere
  47.  * with the registers to be popped later.
  48.  *
  49.  * The downside to most graph coloring is that real hardware often has
  50.  * limitations, like registers that need to be allocated to a node in
  51.  * pairs, or aligned on some boundary.  This implementation follows
  52.  * the paper "Retargetable Graph-Coloring Register Allocation for
  53.  * Irregular Architectures" by Johan Runeson and Sven-Olof Nyström.
  54.  *
  55.  * In this system, there are register classes each containing various
  56.  * registers, and registers may interfere with other registers.  For
  57.  * example, one might have a class of base registers, and a class of
  58.  * aligned register pairs that would each interfere with their pair of
  59.  * the base registers.  Each node has a register class it needs to be
  60.  * assigned to.  Define p(B) to be the size of register class B, and
  61.  * q(B,C) to be the number of registers in B that the worst choice
  62.  * register in C could conflict with.  Then, this system replaces the
  63.  * basic graph coloring test of "fewer edges from this node than there
  64.  * are registers" with "For this node of class B, the sum of q(B,C)
  65.  * for each neighbor node of class C is less than pB".
  66.  *
  67.  * A nice feature of the pq test is that q(B,C) can be computed once
  68.  * up front and stored in a 2-dimensional array, so that the cost of
  69.  * coloring a node is constant with the number of registers.  We do
  70.  * this during ra_set_finalize().
  71.  */
  72.  
  73. #include <stdbool.h>
  74. #include <ralloc.h>
  75.  
  76. #include "main/imports.h"
  77. #include "main/macros.h"
  78. #include "main/mtypes.h"
  79. #include "main/bitset.h"
  80. #include "register_allocate.h"
  81.  
  82. #define NO_REG ~0
  83.  
  84. struct ra_reg {
  85.    GLboolean *conflicts;
  86.    unsigned int *conflict_list;
  87.    unsigned int conflict_list_size;
  88.    unsigned int num_conflicts;
  89. };
  90.  
  91. struct ra_regs {
  92.    struct ra_reg *regs;
  93.    unsigned int count;
  94.  
  95.    struct ra_class **classes;
  96.    unsigned int class_count;
  97.  
  98.    bool round_robin;
  99. };
  100.  
  101. struct ra_class {
  102.    GLboolean *regs;
  103.  
  104.    /**
  105.     * p(B) in Runeson/Nyström paper.
  106.     *
  107.     * This is "how many regs are in the set."
  108.     */
  109.    unsigned int p;
  110.  
  111.    /**
  112.     * q(B,C) (indexed by C, B is this register class) in
  113.     * Runeson/Nyström paper.  This is "how many registers of B could
  114.     * the worst choice register from C conflict with".
  115.     */
  116.    unsigned int *q;
  117. };
  118.  
  119. struct ra_node {
  120.    /** @{
  121.     *
  122.     * List of which nodes this node interferes with.  This should be
  123.     * symmetric with the other node.
  124.     */
  125.    BITSET_WORD *adjacency;
  126.    unsigned int *adjacency_list;
  127.    unsigned int adjacency_list_size;
  128.    unsigned int adjacency_count;
  129.    /** @} */
  130.  
  131.    unsigned int class;
  132.  
  133.    /* Register, if assigned, or NO_REG. */
  134.    unsigned int reg;
  135.  
  136.    /**
  137.     * Set when the node is in the trivially colorable stack.  When
  138.     * set, the adjacency to this node is ignored, to implement the
  139.     * "remove the edge from the graph" in simplification without
  140.     * having to actually modify the adjacency_list.
  141.     */
  142.    GLboolean in_stack;
  143.  
  144.    /* For an implementation that needs register spilling, this is the
  145.     * approximate cost of spilling this node.
  146.     */
  147.    float spill_cost;
  148. };
  149.  
  150. struct ra_graph {
  151.    struct ra_regs *regs;
  152.    /**
  153.     * the variables that need register allocation.
  154.     */
  155.    struct ra_node *nodes;
  156.    unsigned int count; /**< count of nodes. */
  157.  
  158.    unsigned int *stack;
  159.    unsigned int stack_count;
  160.  
  161.    /**
  162.     * Tracks the start of the set of optimistically-colored registers in the
  163.     * stack.
  164.     *
  165.     * Along with any registers not in the stack (if one called ra_simplify()
  166.     * and didn't do optimistic coloring), these need to be considered for
  167.     * spilling.
  168.     */
  169.    unsigned int stack_optimistic_start;
  170. };
  171.  
  172. /**
  173.  * Creates a set of registers for the allocator.
  174.  *
  175.  * mem_ctx is a ralloc context for the allocator.  The reg set may be freed
  176.  * using ralloc_free().
  177.  */
  178. struct ra_regs *
  179. ra_alloc_reg_set(void *mem_ctx, unsigned int count)
  180. {
  181.    unsigned int i;
  182.    struct ra_regs *regs;
  183.  
  184.    regs = rzalloc(mem_ctx, struct ra_regs);
  185.    regs->count = count;
  186.    regs->regs = rzalloc_array(regs, struct ra_reg, count);
  187.  
  188.    for (i = 0; i < count; i++) {
  189.       regs->regs[i].conflicts = rzalloc_array(regs->regs, GLboolean, count);
  190.       regs->regs[i].conflicts[i] = GL_TRUE;
  191.  
  192.       regs->regs[i].conflict_list = ralloc_array(regs->regs, unsigned int, 4);
  193.       regs->regs[i].conflict_list_size = 4;
  194.       regs->regs[i].conflict_list[0] = i;
  195.       regs->regs[i].num_conflicts = 1;
  196.    }
  197.  
  198.    return regs;
  199. }
  200.  
  201. /**
  202.  * The register allocator by default prefers to allocate low register numbers,
  203.  * since it was written for hardware (gen4/5 Intel) that is limited in its
  204.  * multithreadedness by the number of registers used in a given shader.
  205.  *
  206.  * However, for hardware without that restriction, densely packed register
  207.  * allocation can put serious constraints on instruction scheduling.  This
  208.  * function tells the allocator to rotate around the registers if possible as
  209.  * it allocates the nodes.
  210.  */
  211. void
  212. ra_set_allocate_round_robin(struct ra_regs *regs)
  213. {
  214.    regs->round_robin = true;
  215. }
  216.  
  217. static void
  218. ra_add_conflict_list(struct ra_regs *regs, unsigned int r1, unsigned int r2)
  219. {
  220.    struct ra_reg *reg1 = &regs->regs[r1];
  221.  
  222.    if (reg1->conflict_list_size == reg1->num_conflicts) {
  223.       reg1->conflict_list_size *= 2;
  224.       reg1->conflict_list = reralloc(regs->regs, reg1->conflict_list,
  225.                                      unsigned int, reg1->conflict_list_size);
  226.    }
  227.    reg1->conflict_list[reg1->num_conflicts++] = r2;
  228.    reg1->conflicts[r2] = GL_TRUE;
  229. }
  230.  
  231. void
  232. ra_add_reg_conflict(struct ra_regs *regs, unsigned int r1, unsigned int r2)
  233. {
  234.    if (!regs->regs[r1].conflicts[r2]) {
  235.       ra_add_conflict_list(regs, r1, r2);
  236.       ra_add_conflict_list(regs, r2, r1);
  237.    }
  238. }
  239.  
  240. /**
  241.  * Adds a conflict between base_reg and reg, and also between reg and
  242.  * anything that base_reg conflicts with.
  243.  *
  244.  * This can simplify code for setting up multiple register classes
  245.  * which are aggregates of some base hardware registers, compared to
  246.  * explicitly using ra_add_reg_conflict.
  247.  */
  248. void
  249. ra_add_transitive_reg_conflict(struct ra_regs *regs,
  250.                                unsigned int base_reg, unsigned int reg)
  251. {
  252.    int i;
  253.  
  254.    ra_add_reg_conflict(regs, reg, base_reg);
  255.  
  256.    for (i = 0; i < regs->regs[base_reg].num_conflicts; i++) {
  257.       ra_add_reg_conflict(regs, reg, regs->regs[base_reg].conflict_list[i]);
  258.    }
  259. }
  260.  
  261. unsigned int
  262. ra_alloc_reg_class(struct ra_regs *regs)
  263. {
  264.    struct ra_class *class;
  265.  
  266.    regs->classes = reralloc(regs->regs, regs->classes, struct ra_class *,
  267.                             regs->class_count + 1);
  268.  
  269.    class = rzalloc(regs, struct ra_class);
  270.    regs->classes[regs->class_count] = class;
  271.  
  272.    class->regs = rzalloc_array(class, GLboolean, regs->count);
  273.  
  274.    return regs->class_count++;
  275. }
  276.  
  277. void
  278. ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r)
  279. {
  280.    struct ra_class *class = regs->classes[c];
  281.  
  282.    class->regs[r] = GL_TRUE;
  283.    class->p++;
  284. }
  285.  
  286. /**
  287.  * Must be called after all conflicts and register classes have been
  288.  * set up and before the register set is used for allocation.
  289.  * To avoid costly q value computation, use the q_values paramater
  290.  * to pass precomputed q values to this function.
  291.  */
  292. void
  293. ra_set_finalize(struct ra_regs *regs, unsigned int **q_values)
  294. {
  295.    unsigned int b, c;
  296.  
  297.    for (b = 0; b < regs->class_count; b++) {
  298.       regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count);
  299.    }
  300.  
  301.    if (q_values) {
  302.       for (b = 0; b < regs->class_count; b++) {
  303.          for (c = 0; c < regs->class_count; c++) {
  304.             regs->classes[b]->q[c] = q_values[b][c];
  305.          }
  306.       }
  307.       return;
  308.    }
  309.  
  310.    /* Compute, for each class B and C, how many regs of B an
  311.     * allocation to C could conflict with.
  312.     */
  313.    for (b = 0; b < regs->class_count; b++) {
  314.       for (c = 0; c < regs->class_count; c++) {
  315.          unsigned int rc;
  316.          int max_conflicts = 0;
  317.  
  318.          for (rc = 0; rc < regs->count; rc++) {
  319.             int conflicts = 0;
  320.             int i;
  321.  
  322.             if (!regs->classes[c]->regs[rc])
  323.                continue;
  324.  
  325.             for (i = 0; i < regs->regs[rc].num_conflicts; i++) {
  326.                unsigned int rb = regs->regs[rc].conflict_list[i];
  327.                if (regs->classes[b]->regs[rb])
  328.                   conflicts++;
  329.             }
  330.             max_conflicts = MAX2(max_conflicts, conflicts);
  331.          }
  332.          regs->classes[b]->q[c] = max_conflicts;
  333.       }
  334.    }
  335. }
  336.  
  337. static void
  338. ra_add_node_adjacency(struct ra_graph *g, unsigned int n1, unsigned int n2)
  339. {
  340.    BITSET_SET(g->nodes[n1].adjacency, n2);
  341.  
  342.    if (g->nodes[n1].adjacency_count >=
  343.        g->nodes[n1].adjacency_list_size) {
  344.       g->nodes[n1].adjacency_list_size *= 2;
  345.       g->nodes[n1].adjacency_list = reralloc(g, g->nodes[n1].adjacency_list,
  346.                                              unsigned int,
  347.                                              g->nodes[n1].adjacency_list_size);
  348.    }
  349.  
  350.    g->nodes[n1].adjacency_list[g->nodes[n1].adjacency_count] = n2;
  351.    g->nodes[n1].adjacency_count++;
  352. }
  353.  
  354. struct ra_graph *
  355. ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count)
  356. {
  357.    struct ra_graph *g;
  358.    unsigned int i;
  359.  
  360.    g = rzalloc(regs, struct ra_graph);
  361.    g->regs = regs;
  362.    g->nodes = rzalloc_array(g, struct ra_node, count);
  363.    g->count = count;
  364.  
  365.    g->stack = rzalloc_array(g, unsigned int, count);
  366.  
  367.    for (i = 0; i < count; i++) {
  368.       int bitset_count = BITSET_WORDS(count);
  369.       g->nodes[i].adjacency = rzalloc_array(g, BITSET_WORD, bitset_count);
  370.  
  371.       g->nodes[i].adjacency_list_size = 4;
  372.       g->nodes[i].adjacency_list =
  373.          ralloc_array(g, unsigned int, g->nodes[i].adjacency_list_size);
  374.       g->nodes[i].adjacency_count = 0;
  375.  
  376.       ra_add_node_adjacency(g, i, i);
  377.       g->nodes[i].reg = NO_REG;
  378.    }
  379.  
  380.    return g;
  381. }
  382.  
  383. void
  384. ra_set_node_class(struct ra_graph *g,
  385.                   unsigned int n, unsigned int class)
  386. {
  387.    g->nodes[n].class = class;
  388. }
  389.  
  390. void
  391. ra_add_node_interference(struct ra_graph *g,
  392.                          unsigned int n1, unsigned int n2)
  393. {
  394.    if (!BITSET_TEST(g->nodes[n1].adjacency, n2)) {
  395.       ra_add_node_adjacency(g, n1, n2);
  396.       ra_add_node_adjacency(g, n2, n1);
  397.    }
  398. }
  399.  
  400. static GLboolean pq_test(struct ra_graph *g, unsigned int n)
  401. {
  402.    unsigned int j;
  403.    unsigned int q = 0;
  404.    int n_class = g->nodes[n].class;
  405.  
  406.    for (j = 0; j < g->nodes[n].adjacency_count; j++) {
  407.       unsigned int n2 = g->nodes[n].adjacency_list[j];
  408.       unsigned int n2_class = g->nodes[n2].class;
  409.  
  410.       if (n != n2 && !g->nodes[n2].in_stack) {
  411.          q += g->regs->classes[n_class]->q[n2_class];
  412.       }
  413.    }
  414.  
  415.    return q < g->regs->classes[n_class]->p;
  416. }
  417.  
  418. /**
  419.  * Simplifies the interference graph by pushing all
  420.  * trivially-colorable nodes into a stack of nodes to be colored,
  421.  * removing them from the graph, and rinsing and repeating.
  422.  *
  423.  * Returns GL_TRUE if all nodes were removed from the graph.  GL_FALSE
  424.  * means that either spilling will be required, or optimistic coloring
  425.  * should be applied.
  426.  */
  427. GLboolean
  428. ra_simplify(struct ra_graph *g)
  429. {
  430.    GLboolean progress = GL_TRUE;
  431.    int i;
  432.  
  433.    while (progress) {
  434.       progress = GL_FALSE;
  435.  
  436.       for (i = g->count - 1; i >= 0; i--) {
  437.          if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG)
  438.             continue;
  439.  
  440.          if (pq_test(g, i)) {
  441.             g->stack[g->stack_count] = i;
  442.             g->stack_count++;
  443.             g->nodes[i].in_stack = GL_TRUE;
  444.             progress = GL_TRUE;
  445.          }
  446.       }
  447.    }
  448.  
  449.    for (i = 0; i < g->count; i++) {
  450.       if (!g->nodes[i].in_stack && g->nodes[i].reg == -1)
  451.          return GL_FALSE;
  452.    }
  453.  
  454.    return GL_TRUE;
  455. }
  456.  
  457. /**
  458.  * Pops nodes from the stack back into the graph, coloring them with
  459.  * registers as they go.
  460.  *
  461.  * If all nodes were trivially colorable, then this must succeed.  If
  462.  * not (optimistic coloring), then it may return GL_FALSE;
  463.  */
  464. GLboolean
  465. ra_select(struct ra_graph *g)
  466. {
  467.    int i;
  468.    int start_search_reg = 0;
  469.  
  470.    while (g->stack_count != 0) {
  471.       unsigned int ri;
  472.       unsigned int r = -1;
  473.       int n = g->stack[g->stack_count - 1];
  474.       struct ra_class *c = g->regs->classes[g->nodes[n].class];
  475.  
  476.       /* Find the lowest-numbered reg which is not used by a member
  477.        * of the graph adjacent to us.
  478.        */
  479.       for (ri = 0; ri < g->regs->count; ri++) {
  480.          r = (start_search_reg + ri) % g->regs->count;
  481.          if (!c->regs[r])
  482.             continue;
  483.  
  484.          /* Check if any of our neighbors conflict with this register choice. */
  485.          for (i = 0; i < g->nodes[n].adjacency_count; i++) {
  486.             unsigned int n2 = g->nodes[n].adjacency_list[i];
  487.  
  488.             if (!g->nodes[n2].in_stack &&
  489.                 g->regs->regs[r].conflicts[g->nodes[n2].reg]) {
  490.                break;
  491.             }
  492.          }
  493.          if (i == g->nodes[n].adjacency_count)
  494.             break;
  495.       }
  496.       if (ri == g->regs->count)
  497.          return GL_FALSE;
  498.  
  499.       g->nodes[n].reg = r;
  500.       g->nodes[n].in_stack = GL_FALSE;
  501.       g->stack_count--;
  502.  
  503.       if (g->regs->round_robin)
  504.          start_search_reg = r + 1;
  505.    }
  506.  
  507.    return GL_TRUE;
  508. }
  509.  
  510. /**
  511.  * Optimistic register coloring: Just push the remaining nodes
  512.  * on the stack.  They'll be colored first in ra_select(), and
  513.  * if they succeed then the locally-colorable nodes are still
  514.  * locally-colorable and the rest of the register allocation
  515.  * will succeed.
  516.  */
  517. void
  518. ra_optimistic_color(struct ra_graph *g)
  519. {
  520.    unsigned int i;
  521.  
  522.    g->stack_optimistic_start = g->stack_count;
  523.    for (i = 0; i < g->count; i++) {
  524.       if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG)
  525.          continue;
  526.  
  527.       g->stack[g->stack_count] = i;
  528.       g->stack_count++;
  529.       g->nodes[i].in_stack = GL_TRUE;
  530.    }
  531. }
  532.  
  533. GLboolean
  534. ra_allocate_no_spills(struct ra_graph *g)
  535. {
  536.    if (!ra_simplify(g)) {
  537.       ra_optimistic_color(g);
  538.    }
  539.    return ra_select(g);
  540. }
  541.  
  542. unsigned int
  543. ra_get_node_reg(struct ra_graph *g, unsigned int n)
  544. {
  545.    return g->nodes[n].reg;
  546. }
  547.  
  548. /**
  549.  * Forces a node to a specific register.  This can be used to avoid
  550.  * creating a register class containing one node when handling data
  551.  * that must live in a fixed location and is known to not conflict
  552.  * with other forced register assignment (as is common with shader
  553.  * input data).  These nodes do not end up in the stack during
  554.  * ra_simplify(), and thus at ra_select() time it is as if they were
  555.  * the first popped off the stack and assigned their fixed locations.
  556.  * Nodes that use this function do not need to be assigned a register
  557.  * class.
  558.  *
  559.  * Must be called before ra_simplify().
  560.  */
  561. void
  562. ra_set_node_reg(struct ra_graph *g, unsigned int n, unsigned int reg)
  563. {
  564.    g->nodes[n].reg = reg;
  565.    g->nodes[n].in_stack = GL_FALSE;
  566. }
  567.  
  568. static float
  569. ra_get_spill_benefit(struct ra_graph *g, unsigned int n)
  570. {
  571.    int j;
  572.    float benefit = 0;
  573.    int n_class = g->nodes[n].class;
  574.  
  575.    /* Define the benefit of eliminating an interference between n, n2
  576.     * through spilling as q(C, B) / p(C).  This is similar to the
  577.     * "count number of edges" approach of traditional graph coloring,
  578.     * but takes classes into account.
  579.     */
  580.    for (j = 0; j < g->nodes[n].adjacency_count; j++) {
  581.       unsigned int n2 = g->nodes[n].adjacency_list[j];
  582.       if (n != n2) {
  583.          unsigned int n2_class = g->nodes[n2].class;
  584.          benefit += ((float)g->regs->classes[n_class]->q[n2_class] /
  585.                      g->regs->classes[n_class]->p);
  586.       }
  587.    }
  588.  
  589.    return benefit;
  590. }
  591.  
  592. /**
  593.  * Returns a node number to be spilled according to the cost/benefit using
  594.  * the pq test, or -1 if there are no spillable nodes.
  595.  */
  596. int
  597. ra_get_best_spill_node(struct ra_graph *g)
  598. {
  599.    unsigned int best_node = -1;
  600.    float best_benefit = 0.0;
  601.    unsigned int n, i;
  602.  
  603.    /* For any registers not in the stack to be colored, consider them for
  604.     * spilling.  This will mostly collect nodes that were being optimistally
  605.     * colored as part of ra_allocate_no_spills() if we didn't successfully
  606.     * optimistically color.
  607.     *
  608.     * It also includes nodes not trivially colorable by ra_simplify() if it
  609.     * was used directly instead of as part of ra_allocate_no_spills().
  610.     */
  611.    for (n = 0; n < g->count; n++) {
  612.       float cost = g->nodes[n].spill_cost;
  613.       float benefit;
  614.  
  615.       if (cost <= 0.0)
  616.          continue;
  617.  
  618.       if (g->nodes[n].in_stack)
  619.          continue;
  620.  
  621.       benefit = ra_get_spill_benefit(g, n);
  622.  
  623.       if (benefit / cost > best_benefit) {
  624.          best_benefit = benefit / cost;
  625.          best_node = n;
  626.       }
  627.    }
  628.  
  629.    /* Also consider spilling any nodes that were set up to be optimistically
  630.     * colored that we couldn't manage to color in ra_select().
  631.     */
  632.    for (i = g->stack_optimistic_start; i < g->stack_count; i++) {
  633.       float cost, benefit;
  634.  
  635.       n = g->stack[i];
  636.       cost = g->nodes[n].spill_cost;
  637.  
  638.       if (cost <= 0.0)
  639.          continue;
  640.  
  641.       benefit = ra_get_spill_benefit(g, n);
  642.  
  643.       if (benefit / cost > best_benefit) {
  644.          best_benefit = benefit / cost;
  645.          best_node = n;
  646.       }
  647.    }
  648.  
  649.    return best_node;
  650. }
  651.  
  652. /**
  653.  * Only nodes with a spill cost set (cost != 0.0) will be considered
  654.  * for register spilling.
  655.  */
  656. void
  657. ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost)
  658. {
  659.    g->nodes[n].spill_cost = cost;
  660. }
  661.