Commit b5bbe9e5 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Add and use be_peephole_replace().

It combines sched_add_before() and be_peephole_exchange().
parent 44f42188
......@@ -137,6 +137,12 @@ void be_peephole_exchange(ir_node *old, ir_node *nw)
be_liveness_introduce(lv, nw);
}
void be_peephole_replace(ir_node *const old, ir_node *const nw)
{
sched_add_before(old, nw);
be_peephole_exchange(old, nw);
}
ir_node *be_peephole_to_tuple(ir_node *const node)
{
be_liveness_remove(lv, node);
......
......@@ -38,6 +38,12 @@ typedef void (*peephole_opt_func) (ir_node *node);
*/
void be_peephole_exchange(ir_node *old, ir_node *nw);
/**
* Same as be_peephole_exchange(), but also replace @p old in the schedule
* by @p nw.
*/
void be_peephole_replace(ir_node *old, ir_node *nw);
ir_node *be_peephole_to_tuple(ir_node *node);
/**
......
......@@ -60,9 +60,8 @@ static void copy_mark(const ir_node *old, ir_node *newn)
static void replace(ir_node *const old, ir_node *const newn)
{
sched_add_before(old, newn);
copy_mark(old, newn);
be_peephole_exchange(old, newn);
be_peephole_replace(old, newn);
}
typedef enum produces_flag_t {
......@@ -883,8 +882,7 @@ static void peephole_ia32_Conv_I2I(ir_node *node)
ir_node *block = get_nodes_block(node);
ir_node *cwtl = new_bd_ia32_Cwtl(dbgi, block, val);
arch_set_irn_register(cwtl, eax);
sched_add_before(node, cwtl);
be_peephole_exchange(node, cwtl);
be_peephole_replace(node, cwtl);
}
/* Replace rolw $8, %[abcd]x by shorter xchgb %[abcd]l, %[abcd]h */
......@@ -898,8 +896,7 @@ static void peephole_ia32_Rol(ir_node *node)
ir_node *const val = get_irn_n(node, n_ia32_Rol_val);
ir_node *const xchg = new_bd_ia32_Bswap16(dbgi, block, val);
arch_set_irn_register_out(xchg, pn_ia32_Bswap16_res, reg);
sched_add_before(node, xchg);
be_peephole_exchange(node, xchg);
be_peephole_replace(node, xchg);
}
}
}
......
......@@ -234,9 +234,8 @@ static void finish_sparc_Save(ir_node *node)
/* we have a Save with immediate */
assert(get_irn_arity(node) == 1);
sched_add_before(node, new_save);
arch_set_irn_register(new_save, reg);
be_peephole_exchange(node, new_save);
be_peephole_replace(node, new_save);
}
}
......@@ -256,9 +255,8 @@ static void finish_be_IncSP(ir_node *node)
ir_node *constant = create_constant_from_immediate(node, offset);
ir_node *sub = new_bd_sparc_Sub_reg(dbgi, block, sp, constant);
sched_add_before(node, sub);
arch_set_irn_register(sub, &sparc_registers[REG_SP]);
be_peephole_exchange(node, sub);
be_peephole_replace(node, sub);
}
}
......@@ -280,9 +278,8 @@ static void finish_sparc_FrameAddr(ir_node *node)
ir_node *new_frameaddr = new_bd_sparc_Add_reg(dbgi, block, base, constant);
const arch_register_t *reg = arch_get_irn_register(node);
sched_add_before(node, new_frameaddr);
arch_set_irn_register(new_frameaddr, reg);
be_peephole_exchange(node, new_frameaddr);
be_peephole_replace(node, new_frameaddr);
}
}
......@@ -295,8 +292,7 @@ static void finish_load_store(ir_node *const old, ir_node *const nw, sparc_load_
be_foreach_out(old, i) {
arch_set_irn_register_out(nw, i, arch_get_irn_register_out(old, i));
}
sched_add_before(old, nw);
be_peephole_exchange(old, nw);
be_peephole_replace(old, nw);
}
static void finish_sparc_Ld(ir_node *node)
......
Supports Markdown
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