aco: implement 16-bit nir_op_fsat
[mesa.git] / src / util / register_allocate.c
index 352736304599100178c71a84dae40f7dbe289e66..af43c2fbb434e525d1da326747277bb3fdc6c4af 100644 (file)
  */
 
 #include <stdbool.h>
+#include <limits.h>
 
 #include "ralloc.h"
-#include "main/imports.h"
-#include "main/macros.h"
+#include "util/imports.h"
 #include "util/bitset.h"
+#include "u_math.h"
 #include "register_allocate.h"
 
-#define NO_REG ~0U
-
 struct ra_reg {
    BITSET_WORD *conflicts;
    unsigned int *conflict_list;
@@ -171,8 +170,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 */
@@ -342,10 +340,9 @@ void
 ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int r)
 {
    struct ra_reg *reg = &regs->regs[r];
-   BITSET_WORD tmp;
    int c;
 
-   BITSET_FOREACH_SET(c, tmp, reg->conflicts, regs->count) {
+   BITSET_FOREACH_SET(c, reg->conflicts, regs->count) {
       struct ra_reg *other = &regs->regs[c];
       unsigned i;
       for (i = 0; i < BITSET_WORDS(regs->count); i++)
@@ -500,7 +497,7 @@ ra_realloc_interference_graph(struct ra_graph *g, unsigned int alloc)
     * easier to memset the top of the growing bitsets.
     */
    assert(g->alloc % BITSET_WORDBITS == 0);
-   alloc = ALIGN(alloc, BITSET_WORDBITS);
+   alloc = align64(alloc, BITSET_WORDBITS);
 
    g->nodes = reralloc(g, g->nodes, struct ra_node, alloc);
 
@@ -566,9 +563,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;
@@ -869,7 +864,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.