return live;
} /* vfp_liveness_end_of_block */
+/** get the register mask from an arch_register */
+#define REGMASK(reg) (1 << (reg)->index)
+
/**
- * Return a bitset of registers which are live at a node.
+ * Return a bitset of argument registers which are live at the end of a node.
*
* @param sim the simulator handle
* @param pos the node
+ * @param kill kill mask for the output registers
*
* @return The live bitset.
*/
-static unsigned vfp_liveness_nodes_live_at(x87_simulator *sim, const ir_node *pos)
+static unsigned vfp_live_args_after(x87_simulator *sim, const ir_node *pos, unsigned kill)
{
unsigned idx = get_irn_idx(pos);
assert(idx < sim->n_idx);
- return sim->live[idx];
-} /* vfp_liveness_nodes_live_at */
+ return sim->live[idx] & ~kill;
+} /* vfp_live_args_after */
/**
* Calculate the liveness for a whole block and cache it.
/* now iterate through the block backward and cache the results */
sched_foreach_reverse(blk, irn) {
+ /* stop at the first Phi: this produces the live-in */
+ if (is_Phi(irn))
+ break;
+
idx = get_irn_idx(irn);
sim->live[idx] = live;
const arch_register_t *op1 = arch_get_irn_register(env, get_irn_n(n, BINOP_IDX_1));
const arch_register_t *op2 = arch_get_irn_register(env, get_irn_n(n, BINOP_IDX_2));
const arch_register_t *out = arch_get_irn_register(env, n);
- unsigned live = vfp_liveness_nodes_live_at(state->sim, n);
+ unsigned live = vfp_live_args_after(state->sim, n, REGMASK(out));
- DB((dbg, LEVEL_1, ">>> %s %s, %s -> %s\n", get_irn_opname(n),
+ DB((dbg, LEVEL_1, ">>> %+F %s, %s -> %s\n", n,
arch_register_get_name(op1), arch_register_get_name(op2),
arch_register_get_name(out)));
DEBUG_ONLY(vfp_dump_live(live));
const arch_register_t *op1 = arch_get_irn_register(env, get_irn_n(n, UNOP_IDX));
const arch_register_t *out = arch_get_irn_register(env, n);
ia32_attr_t *attr;
- unsigned live = vfp_liveness_nodes_live_at(state->sim, n);
+ unsigned live = vfp_live_args_after(state->sim, n, REGMASK(out));
- DB((dbg, LEVEL_1, ">>> %s -> %s\n", get_irn_opname(n), out->name));
+ DB((dbg, LEVEL_1, ">>> %+F -> %s\n", n, out->name));
DEBUG_ONLY(vfp_dump_live(live));
op1_idx = x87_on_stack(state, arch_register_get_index(op1));
const arch_register_t *out = arch_get_irn_register(env, n);
ia32_attr_t *attr;
- DB((dbg, LEVEL_1, ">>> %s -> %s\n", get_irn_opname(n), arch_register_get_name(out)));
+ DB((dbg, LEVEL_1, ">>> %+F -> %s\n", n, arch_register_get_name(out)));
x87_push(state, arch_register_get_index(out), x87_patch_insn(n, op));
attr = get_ia32_attr(n);
attr->x87[2] = out = &ia32_st_regs[0];
static int sim_store(x87_state *state, ir_node *n, const arch_env_t *env, ir_op *op, ir_op *op_p) {
ir_node *val = get_irn_n(n, STORE_VAL_IDX);
const arch_register_t *op2 = arch_get_irn_register(env, val);
- unsigned live = vfp_liveness_nodes_live_at(state->sim, n);
+ unsigned live = vfp_live_args_after(state->sim, n, 0);
int insn = 0;
ia32_attr_t *attr;
int op2_idx, depth;
op2_idx = x87_on_stack(state, arch_register_get_index(op2));
assert(op2_idx >= 0);
- DB((dbg, LEVEL_1, ">>> %s %s ->\n", get_irn_opname(n), arch_register_get_name(op2)));
+ DB((dbg, LEVEL_1, ">>> %+F %s ->\n", n, arch_register_get_name(op2)));
mode = get_ia32_ls_mode(n);
depth = x87_get_depth(state);
ir_op *dst;
const arch_register_t *op1 = arch_get_irn_register(env, get_irn_n(n, BINOP_IDX_1));
const arch_register_t *op2 = arch_get_irn_register(env, get_irn_n(n, BINOP_IDX_2));
- unsigned live = vfp_liveness_nodes_live_at(state->sim, n);
+ unsigned live = vfp_live_args_after(state->sim, n, 0);
- DB((dbg, LEVEL_1, ">>> %s %s, %s\n", get_irn_opname(n),
+ DB((dbg, LEVEL_1, ">>> %+F %s, %s\n", n,
arch_register_get_name(op1), arch_register_get_name(op2)));
DEBUG_ONLY(vfp_dump_live(live));
ir_node *node, *next;
ia32_attr_t *attr;
int op1_idx, out_idx;
- unsigned live = vfp_liveness_nodes_live_at(state->sim, n);
+ unsigned live = vfp_live_args_after(state->sim, n, REGMASK(out));
op1_idx = x87_on_stack(state, arch_register_get_index(op1));
- DB((dbg, LEVEL_1, ">>> %s %s -> %s\n", get_irn_opname(n),
+ DB((dbg, LEVEL_1, ">>> %+F %s -> %s\n", n,
arch_register_get_name(op1), arch_register_get_name(out)));
DEBUG_ONLY(vfp_dump_live(live));
sched_remove(n);
exchange(n, node);
sched_add_before(next, node);
- DB((dbg, LEVEL_1, ">>> %s %s -> %s\n", get_irn_opname(node), op1->name, out->name));
+ DB((dbg, LEVEL_1, ">>> %+F %s -> %s\n", node, op1->name, out->name));
}
else {
out_idx = x87_on_stack(state, arch_register_get_index(out));
x87_pop(state);
x87_set_st(state, arch_register_get_index(out), n, out_idx - 1);
}
- DB((dbg, LEVEL_1, ">>> %s %s\n", get_irn_opname(n), op1->name));
+ DB((dbg, LEVEL_1, ">>> %+F %s\n", n, op1->name));
}
else {
/* just a virtual copy */
x87_state *state = start_state;
ir_node *first_insn = sched_first(block);
ir_node *keep = NULL;
- unsigned live = vfp_liveness_nodes_live_at(sim, block);
+ unsigned live = vfp_live_args_after(sim, block, 0);
unsigned kill_mask;
int i, depth, num_pop;