static unsigned n_regs;
static unsigned *normal_regs;
-/** info about the current assignment for a register */
-struct assignment_t {
- ir_node *value; /**< currently assigned value */
-};
-typedef struct assignment_t assignment_t;
-
-/** currently active assignments (while processing a basic block) */
-static assignment_t *assignments;
+/** currently active assignments (while processing a basic block)
+ * maps registers to values(their current copies) */
+static ir_node **assignments;
/**
* allocation information: last_uses, register preferences
/** per basic-block information */
struct block_info_t {
- bool processed; /**< indicate wether block is processed */
- assignment_t assignments[0]; /**< register assignments at end of block */
+ bool processed; /**< indicate wether block is processed */
+ ir_node *assignments[0]; /**< register assignments at end of block */
};
typedef struct block_info_t block_info_t;
static void use_reg(ir_node *node, const arch_register_t *reg)
{
unsigned r = arch_register_get_index(reg);
- assignments[r].value = node;
+ assignments[r] = node;
arch_set_irn_register(node, reg);
}
static void free_reg_of_value(ir_node *node)
{
- assignment_t *assignment;
const arch_register_t *reg;
unsigned r;
reg = arch_get_irn_register(node);
r = arch_register_get_index(reg);
- assignment = &assignments[r];
/* assignment->value may be NULL if a value is used at 2 inputs
so it gets freed twice. */
- assert(assignment->value == node || assignment->value == NULL);
- assignment->value = NULL;
+ assert(assignments[r] == node || assignments[r] == NULL);
+ assignments[r] = NULL;
}
/**
continue;
if (rbitset_is_set(output_regs, r))
continue;
- if (assignments[r].value == NULL)
+ if (assignments[r] == NULL)
break;
}
if (i >= n_regs) {
/* if the value didn't die here then we should not propagate the
* should_be_same info */
- if (assignments[r].value == in)
+ if (assignments[r] == in)
continue;
info->prefs[r] += weight * AFF_SHOULD_BE_SAME;
r = reg_prefs[i].num;
if (!rbitset_is_set(allowed_regs, r))
continue;
- if (assignments[r].value == NULL)
+ if (assignments[r] == NULL)
break;
if (!is_Phi(node)) {
float pref = reg_prefs[i].pref;
float delta = i+1 < n_regs ? pref - reg_prefs[i+1].pref : 0;
ir_node *before = skip_Proj(node);
- bool res = try_optimistic_split(assignments[r].value, before,
+ bool res = try_optimistic_split(assignments[r], before,
pref, delta,
output_regs);
if (res)
unsigned old_reg = permutation[r];
ir_node *value;
- value = assignments[old_reg].value;
+ value = assignments[old_reg];
if (value == NULL) {
/* nothing to do here, reg is not live. Mark it as fixpoint
* so we ignore it in the next steps */
}
/* create a copy */
- src = assignments[old_r].value;
+ src = assignments[old_r];
copy = be_new_Copy(cls, block, src);
sched_add_before(before, copy);
reg = arch_register_for_index(cls, r);
/* exchange old_r and r2; after that old_r is a fixed point */
r2 = permutation[old_r];
- in[0] = assignments[r2].value;
- in[1] = assignments[old_r].value;
+ in[0] = assignments[r2];
+ in[1] = assignments[old_r];
perm = be_new_Perm(cls, block, 2, in);
sched_add_before(before, perm);
DB((dbg, LEVEL_2, "Perm %+F (perm %+F,%+F, before %+F)\n",
/* mark all used registers as potentially live-through */
for (r = 0; r < n_regs; ++r) {
- const assignment_t *assignment = &assignments[r];
- if (assignment->value == NULL)
+ if (assignments[r] == NULL)
continue;
if (!rbitset_is_set(normal_regs, r))
continue;
*/
static int find_value_in_block_info(block_info_t *info, ir_node *value)
{
- unsigned r;
- assignment_t *assignments = info->assignments;
+ unsigned r;
+ ir_node **assignments = info->assignments;
for (r = 0; r < n_regs; ++r) {
- const assignment_t *assignment = &assignments[r];
- ir_node *a_value = assignment->value;
+ ir_node *a_value = assignments[r];
if (a_value == NULL)
continue;
*/
static void add_phi_permutations(ir_node *block, int p)
{
- unsigned r;
- unsigned *permutation;
- assignment_t *old_assignments;
- bool need_permutation;
- ir_node *node;
- ir_node *pred = get_Block_cfgpred_block(block, p);
+ unsigned r;
+ unsigned *permutation;
+ ir_node **old_assignments;
+ bool need_permutation;
+ ir_node *node;
+ ir_node *pred = get_Block_cfgpred_block(block, p);
block_info_t *pred_info = get_block_info(pred);
simply query which value occupies the phis register in the
predecessor */
a = arch_register_get_index(arch_get_irn_register(node));
- op = pred_info->assignments[a].value;
+ op = pred_info->assignments[a];
set_Phi_pred(node, p, op);
}
}
/* must live out of predecessor */
assert(a >= 0);
- phi_ins[p] = pred_info->assignments[a].value;
+ phi_ins[p] = pred_info->assignments[a];
/* different value from last time? then we need a phi */
if (p > 0 && phi_ins[p-1] != phi_ins[p]) {
need_phi = true;
enforce_constraints(&live_nodes, node, output_regs);
/* we may not use registers occupied here for optimistic splits */
for (r = 0; r < n_regs; ++r) {
- if (assignments[r].value != NULL)
+ if (assignments[r] != NULL)
rbitset_set(output_regs, r);
}