*/
#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;
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 */
ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int r)
{
struct ra_reg *reg = ®s->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 = ®s->regs[c];
unsigned i;
for (i = 0; i < BITSET_WORDS(regs->count); i++)
* 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);
}
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;
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.