Commit d2a666fc authored by Christian Würdig's avatar Christian Würdig
Browse files

return real x87 register (st0-st7) if node is patched to keep verifier happy

parent ada1f44f
......@@ -130,25 +130,14 @@ static const arch_register_req_t *ia32_get_irn_reg_req(const void *self, arch_re
return NULL;
}
if (pos == -1) {
node_pos = ia32_translate_proj_pos(irn);
}
else {
node_pos = pos;
}
irn = skip_Proj(irn);
node_pos = (pos == -1) ? get_Proj_proj(irn) : pos;
irn = skip_Proj(irn);
DB((mod, LEVEL_1, "skipping Proj, going to %+F at pos %d ... ", irn, node_pos));
}
if (is_ia32_irn(irn)) {
if (pos >= 0) {
irn_req = get_ia32_in_req(irn, pos);
}
else {
irn_req = get_ia32_out_req(irn, node_pos);
}
irn_req = (pos >= 0) ? get_ia32_in_req(irn, pos) : get_ia32_out_req(irn, node_pos);
DB((mod, LEVEL_1, "returning reqs for %+F at pos %d\n", irn, pos));
......@@ -203,7 +192,7 @@ static void ia32_set_irn_reg(const void *self, ir_node *irn, const arch_register
DBG((ops->cg->mod, LEVEL_1, "ia32 assigned register %s to node %+F\n", reg->name, irn));
if (is_Proj(irn)) {
pos = ia32_translate_proj_pos(irn);
pos = get_Proj_proj(irn);
irn = skip_Proj(irn);
}
......@@ -228,14 +217,19 @@ static const arch_register_t *ia32_get_irn_reg(const void *self, const ir_node *
return NULL;
}
pos = ia32_translate_proj_pos(irn);
pos = get_Proj_proj(irn);
irn = skip_Proj(irn);
}
if (is_ia32_irn(irn)) {
const arch_register_t **slots;
slots = get_ia32_slots(irn);
reg = slots[pos];
/* retrieve "real" x87 register */
if (ia32_has_x87_register(irn))
reg = get_ia32_attr(irn)->x87[pos + 2];
else {
const arch_register_t **slots;
slots = get_ia32_slots(irn);
reg = slots[pos];
}
}
else {
reg = ia32_get_firm_reg(irn, cur_reg_set);
......@@ -1022,9 +1016,8 @@ static void transform_to_Load(ia32_transform_env_t *env) {
else
new_op = new_rd_ia32_vfld(env->dbg, env->irg, env->block, ptr, noreg, mem);
}
else {
else
new_op = new_rd_ia32_Load(env->dbg, env->irg, env->block, ptr, noreg, mem);
}
set_ia32_am_support(new_op, ia32_am_Source);
set_ia32_op_type(new_op, ia32_AddrModeS);
......@@ -1035,7 +1028,7 @@ static void transform_to_Load(ia32_transform_env_t *env) {
DBG_OPT_RELOAD2LD(irn, new_op);
proj = new_rd_Proj(env->dbg, env->irg, env->block, new_op, mode, pn_Load_res);
proj = new_rd_Proj(env->dbg, env->irg, env->block, new_op, mode, pn_ia32_Load_res);
if (sched_point) {
sched_add_after(sched_point, new_op);
......
......@@ -128,13 +128,6 @@ static void ia32_dump_function_size(FILE *F, const char *name)
* |_| |_|
*************************************************************/
/**
* returns true if a node has x87 registers
*/
static INLINE int has_x87_register(const ir_node *n) {
return is_irn_machine_user(n, 0);
}
/* We always pass the ir_node which is a pointer. */
static int ia32_get_arg_type(const lc_arg_occ_t *occ) {
return lc_arg_type_ptr;
......@@ -627,7 +620,7 @@ const char *ia32_emit_am(const ir_node *n, ia32_emit_env_t *env) {
/* obstack_free with NULL results in an uninitialized obstack */
obstack_init(obst);
p = pointer_size(mode, has_x87_register(n) || is_ia32_GetST0(n) || is_ia32_SetST0(n));
p = pointer_size(mode, ia32_has_x87_register(n) || is_ia32_GetST0(n) || is_ia32_SetST0(n));
if (p)
obstack_printf(obst, "%s ", p);
......@@ -693,7 +686,7 @@ const char *ia32_emit_adr(const ir_node *irn, ia32_emit_env_t *env)
static char buf[SNPRINTF_BUF_LEN];
ir_mode *mode = get_ia32_ls_mode(irn);
const char *adr = get_ia32_cnst(irn);
const char *pref = pointer_size(mode, has_x87_register(irn));
const char *pref = pointer_size(mode, ia32_has_x87_register(irn));
snprintf(buf, SNPRINTF_BUF_LEN, "%s %s", pref ? pref : "", adr);
return buf;
......
......@@ -69,7 +69,13 @@ static ident *get_sc_ident(ir_node *symc) {
return NULL;
}
/**
* returns true if a node has x87 registers
*/
int ia32_has_x87_register(const ir_node *n) {
assert(is_ia32_irn(n) && "Need ia32 node.");
return is_irn_machine_user(n, 0);
}
/***********************************************************************************
* _ _ _ __
......@@ -225,7 +231,15 @@ static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
slots = get_ia32_slots(n);
if (slots && n_res > 0) {
for (i = 0; i < n_res; i++) {
fprintf(F, "reg #%d = %s\n", i, slots[i] ? slots[i]->name : "n/a");
const arch_register_t *reg;
/* retrieve "real" x87 register */
if (ia32_has_x87_register(n))
reg = get_ia32_attr(n)->x87[i + 2];
else
reg = slots[i];
fprintf(F, "reg #%d = %s\n", i, reg ? arch_register_get_name(reg) : "n/a");
}
fprintf(F, "\n");
}
......
......@@ -21,6 +21,11 @@
* |___/
***************************************************************************************************/
/**
* returns true if a node has x87 registers
*/
int ia32_has_x87_register(const ir_node *n);
/**
* Returns the attributes of an ia32 node.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment