Commit 282248ea authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ia32: Use shorter 'xorb rh, rh' for 'r & 0xFFFF00FF'.

parent 9f575aed
......@@ -50,6 +50,7 @@ pmap *ia32_tv_ent; /**< A map of entities that store const tarvals */
ir_mode *ia32_mode_fpcw;
ir_mode *ia32_mode_flags;
ir_mode *ia32_mode_8h;
ir_mode *ia32_mode_gp;
ir_mode *ia32_mode_float64;
ir_mode *ia32_mode_float32;
......@@ -1410,6 +1411,7 @@ static void ia32_init(void)
ia32_mode_fpcw = new_non_arithmetic_mode("fpcw", 16);
ia32_mode_flags = new_non_arithmetic_mode("flags", 32);
ia32_mode_8h = new_non_arithmetic_mode("8h", 8);
ia32_mode_gp = new_int_mode("gp", irma_twos_complement, 32, 0, 32);
ia32_mode_float64 = new_float_mode("fp64", irma_ieee754, 11, 52,
ir_overflow_indefinite);
......
......@@ -45,6 +45,7 @@ extern pmap *ia32_tv_ent; /**< A map of entities that store const tarvals */
/** The mode for the floating point control word. */
extern ir_mode *ia32_mode_fpcw;
extern ir_mode *ia32_mode_8h; /**< Mode for high 8bit registers */
extern ir_mode *ia32_mode_gp;
extern ir_mode *ia32_mode_float64;
extern ir_mode *ia32_mode_float32;
......
......@@ -155,6 +155,8 @@ static const char *get_register_name_mode(const arch_register_t *reg,
{
if (mode == NULL)
return reg->name;
if (mode == ia32_mode_8h)
return get_register_name_8bit_high(reg);
unsigned size = get_mode_size_bits(mode);
if (size == 8)
return get_register_name_8bit_low(reg);
......@@ -226,7 +228,7 @@ static void emit_ia32_immediate_attr(bool const prefix, ir_node const *const nod
static void ia32_emit_mode_suffix_mode(const ir_mode *mode)
{
assert(mode_is_int(mode) || mode_is_reference(mode));
assert(mode_is_int(mode) || mode_is_reference(mode) || mode == ia32_mode_8h);
switch (get_mode_size_bits(mode)) {
case 8: be_emit_char('b'); return;
case 16: be_emit_char('w'); return;
......
......@@ -150,8 +150,9 @@ static void make_xor(ir_node *const and, ir_node *(*const cons)(dbg_info*, ir_no
/**
* Use shorter instructions:
* x & 0xFFFFFF00 -> xorb x, x (6 bytes -> 2 bytes)
* x & 0xFFFF0000 -> xorw x, x (6 bytes -> 3 bytes)
* r & 0xFFFFFF00 -> xorb rl, rl (6 bytes -> 2 bytes)
* r & 0xFFFF00FF -> xorb rh, rh (6 bytes -> 2 bytes)
* r & 0xFFFF0000 -> xorw rx, rx (6 bytes -> 3 bytes)
*/
static void peephole_ia32_And(ir_node *const node)
{
......@@ -172,8 +173,12 @@ static void peephole_ia32_And(ir_node *const node)
uint32_t const val = imm->imm.offset;
if (val == 0xFFFF0000) {
make_xor(node, &new_bd_ia32_Xor, mode_Hu, reg);
} else if (val == 0xFFFFFF00 && is_hl_register(reg)) {
make_xor(node, &new_bd_ia32_Xor_8bit, mode_Bu, reg);
} else if (is_hl_register(reg)) {
if (val == 0xFFFFFF00) {
make_xor(node, &new_bd_ia32_Xor_8bit, mode_Bu, reg);
} else if (val == 0xFFFF00FF) {
make_xor(node, &new_bd_ia32_Xor_8bit, ia32_mode_8h, reg);
}
}
}
......
......@@ -488,7 +488,7 @@ OrMem => {
Xor => {
template => $binop_commutative,
emit => "xor%M %#B",
emit => "xor%M %B",
latency => 1,
},
......
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