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

ia32: Invert the sense of '#' in ia32_emitf() when emitting registers.

Now the ls_mode is respected by default, wich is more sensible, and '#' is used to emit a 32 bit register.
parent a1daf895
...@@ -343,12 +343,12 @@ void x86_emit_condition_code(x86_condition_code_t cc) ...@@ -343,12 +343,12 @@ void x86_emit_condition_code(x86_condition_code_t cc)
typedef enum ia32_emit_mod_t { typedef enum ia32_emit_mod_t {
EMIT_NONE = 0, EMIT_NONE = 0,
EMIT_RESPECT_LS = 1U << 0, EMIT_ALTERNATE_AM = 1U << 0,
EMIT_ALTERNATE_AM = 1U << 1, EMIT_LONG = 1U << 1,
EMIT_LONG = 1U << 2, EMIT_LOW_REG = 1U << 2,
EMIT_HIGH_REG = 1U << 3, EMIT_HIGH_REG = 1U << 3,
EMIT_LOW_REG = 1U << 4, EMIT_16BIT_REG = 1U << 4,
EMIT_16BIT_REG = 1U << 5, EMIT_32BIT_REG = 1U << 5,
EMIT_SHIFT_COMMA = 1U << 6, EMIT_SHIFT_COMMA = 1U << 6,
} ia32_emit_mod_t; } ia32_emit_mod_t;
ENUM_BITSET(ia32_emit_mod_t) ENUM_BITSET(ia32_emit_mod_t)
...@@ -444,11 +444,11 @@ void ia32_emitf(ir_node const *const node, char const *fmt, ...) ...@@ -444,11 +444,11 @@ void ia32_emitf(ir_node const *const node, char const *fmt, ...)
for (;;) { for (;;) {
switch (*fmt) { switch (*fmt) {
case '*': mod |= EMIT_ALTERNATE_AM; break; case '*': mod |= EMIT_ALTERNATE_AM; break;
case '#': mod |= EMIT_RESPECT_LS; break;
case 'l': mod |= EMIT_LONG; break; case 'l': mod |= EMIT_LONG; break;
case '>': mod |= EMIT_HIGH_REG; break;
case '<': mod |= EMIT_LOW_REG; break; case '<': mod |= EMIT_LOW_REG; break;
case '>': mod |= EMIT_HIGH_REG; break;
case '^': mod |= EMIT_16BIT_REG; break; case '^': mod |= EMIT_16BIT_REG; break;
case '#': mod |= EMIT_32BIT_REG; break;
case ',': mod |= EMIT_SHIFT_COMMA; break; case ',': mod |= EMIT_SHIFT_COMMA; break;
default: default:
goto end_of_mods; goto end_of_mods;
...@@ -600,7 +600,7 @@ emit_I: ...@@ -600,7 +600,7 @@ emit_I:
ir_mode *mode = get_ia32_ls_mode(node); ir_mode *mode = get_ia32_ls_mode(node);
if (!mode) if (!mode)
mode = ia32_mode_gp; mode = ia32_mode_gp;
if (mod & EMIT_RESPECT_LS) { if (mod & EMIT_32BIT_REG) {
if (get_mode_size_bits(mode) == 32) if (get_mode_size_bits(mode) == 32)
break; break;
be_emit_char(mode_is_signed(mode) ? 's' : 'z'); be_emit_char(mode_is_signed(mode) ? 's' : 'z');
...@@ -636,10 +636,10 @@ emit_R: ...@@ -636,10 +636,10 @@ emit_R:
name = get_register_name_8bit_low(reg); name = get_register_name_8bit_low(reg);
} else if (mod & EMIT_16BIT_REG) { } else if (mod & EMIT_16BIT_REG) {
name = get_register_name_16bit(reg); name = get_register_name_16bit(reg);
} else if (mod & EMIT_32BIT_REG) {
name = reg->name;
} else { } else {
name = mod & EMIT_RESPECT_LS name = get_register_name_mode(reg, get_ia32_ls_mode(node));
? get_register_name_mode(reg, get_ia32_ls_mode(node))
: reg->name;
} }
be_emit_char('%'); be_emit_char('%');
be_emit_string(name); be_emit_string(name);
...@@ -870,7 +870,7 @@ static void emit_ia32_Setcc(const ir_node *node) ...@@ -870,7 +870,7 @@ static void emit_ia32_Setcc(const ir_node *node)
ia32_emitf(node, "andb %>R, %<R", dreg, dreg); ia32_emitf(node, "andb %>R, %<R", dreg, dreg);
} }
} else { } else {
ia32_emitf(node, "set%PX %#R", (int)cc, dreg); ia32_emitf(node, "set%PX %R", (int)cc, dreg);
} }
} }
...@@ -1062,9 +1062,9 @@ static void emit_be_IncSP(const ir_node *node) ...@@ -1062,9 +1062,9 @@ static void emit_be_IncSP(const ir_node *node)
return; return;
if (offs > 0) { if (offs > 0) {
ia32_emitf(node, "subl $%u, %D0", offs); ia32_emitf(node, "subl $%u, %#D0", offs);
} else { } else {
ia32_emitf(node, "addl $%u, %D0", -offs); ia32_emitf(node, "addl $%u, %#D0", -offs);
} }
} }
...@@ -1082,7 +1082,7 @@ static void Copy_emitter(const ir_node *node, const ir_node *op) ...@@ -1082,7 +1082,7 @@ static void Copy_emitter(const ir_node *node, const ir_node *op)
if (in->cls == &ia32_reg_classes[CLASS_ia32_fp]) if (in->cls == &ia32_reg_classes[CLASS_ia32_fp])
return; return;
ia32_emitf(node, "movl %R, %R", in, out); ia32_emitf(node, "movl %#R, %#R", in, out);
} }
static void emit_be_Copy(const ir_node *node) static void emit_be_Copy(const ir_node *node)
...@@ -1107,11 +1107,11 @@ static void emit_be_Perm(const ir_node *node) ...@@ -1107,11 +1107,11 @@ static void emit_be_Perm(const ir_node *node)
assert(cls == reg1->cls && "Register class mismatch at Perm"); assert(cls == reg1->cls && "Register class mismatch at Perm");
if (cls == &ia32_reg_classes[CLASS_ia32_gp]) { if (cls == &ia32_reg_classes[CLASS_ia32_gp]) {
ia32_emitf(node, "xchg %R, %R", reg1, reg0); ia32_emitf(node, "xchg %#R, %#R", reg1, reg0);
} else if (cls == &ia32_reg_classes[CLASS_ia32_xmm]) { } else if (cls == &ia32_reg_classes[CLASS_ia32_xmm]) {
ia32_emitf(NULL, "xorpd %R, %R", reg1, reg0); ia32_emitf(NULL, "xorpd %#R, %#R", reg1, reg0);
ia32_emitf(NULL, "xorpd %R, %R", reg0, reg1); ia32_emitf(NULL, "xorpd %#R, %#R", reg0, reg1);
ia32_emitf(node, "xorpd %R, %R", reg1, reg0); ia32_emitf(node, "xorpd %#R, %#R", reg1, reg0);
} else if (cls == &ia32_reg_classes[CLASS_ia32_fp]) { } else if (cls == &ia32_reg_classes[CLASS_ia32_fp]) {
/* is a NOP */ /* is a NOP */
} else { } else {
...@@ -1966,9 +1966,9 @@ static void bemit_perm(const ir_node *node) ...@@ -1966,9 +1966,9 @@ static void bemit_perm(const ir_node *node)
bemit_xchg(reg0, reg1); bemit_xchg(reg0, reg1);
} else if (cls == &ia32_reg_classes[CLASS_ia32_xmm]) { } else if (cls == &ia32_reg_classes[CLASS_ia32_xmm]) {
panic("unimplemented"); // TODO implement panic("unimplemented"); // TODO implement
//ia32_emitf(NULL, "xorpd %R, %R", reg1, reg0); //ia32_emitf(NULL, "xorpd %#R, %#R", reg1, reg0);
//ia32_emitf(NULL, "xorpd %R, %R", reg0, reg1); //ia32_emitf(NULL, "xorpd %#R, %#R", reg0, reg1);
//ia32_emitf(node, "xorpd %R, %R", reg1, reg0); //ia32_emitf(node, "xorpd %#R, %#R", reg1, reg0);
} else if (cls == &ia32_reg_classes[CLASS_ia32_fp]) { } else if (cls == &ia32_reg_classes[CLASS_ia32_fp]) {
/* is a NOP */ /* is a NOP */
} else { } else {
...@@ -3196,7 +3196,7 @@ void ia32_emit_thunks(void) ...@@ -3196,7 +3196,7 @@ void ia32_emit_thunks(void)
be_gas_emit_function_prolog(entity, ia32_cg_config.function_alignment, be_gas_emit_function_prolog(entity, ia32_cg_config.function_alignment,
NULL); NULL);
ia32_emitf(NULL, "movl (%%esp), %R", reg); ia32_emitf(NULL, "movl (%%esp), %#R", reg);
ia32_emitf(NULL, "ret"); ia32_emitf(NULL, "ret");
be_gas_emit_function_epilog(entity); be_gas_emit_function_epilog(entity);
} }
......
...@@ -390,7 +390,7 @@ Add => { ...@@ -390,7 +390,7 @@ Add => {
AddMem => { AddMem => {
template => $binop_mem, template => $binop_mem,
emit => "add%M %#S3, %AM", emit => "add%M %S3, %AM",
latency => 1, latency => 1,
}, },
...@@ -442,7 +442,7 @@ IMul => { ...@@ -442,7 +442,7 @@ IMul => {
IMulImm => { IMulImm => {
template => $binop_commutative, template => $binop_commutative,
out_reqs => [ "gp", "flags", "mem" ], out_reqs => [ "gp", "flags", "mem" ],
emit => "imul%M %#S4, %#AS3, %#D0", emit => "imul%M %S4, %AS3, %D0",
latency => 5, latency => 5,
}, },
...@@ -467,7 +467,7 @@ And => { ...@@ -467,7 +467,7 @@ And => {
AndMem => { AndMem => {
template => $binop_mem, template => $binop_mem,
emit => "and%M %#S3, %AM", emit => "and%M %S3, %AM",
latency => 1, latency => 1,
}, },
...@@ -479,7 +479,7 @@ Or => { ...@@ -479,7 +479,7 @@ Or => {
OrMem => { OrMem => {
template => $binop_mem, template => $binop_mem,
emit => "or%M %#S3, %AM", emit => "or%M %S3, %AM",
latency => 1, latency => 1,
}, },
...@@ -501,7 +501,7 @@ Xor0 => { ...@@ -501,7 +501,7 @@ Xor0 => {
XorMem => { XorMem => {
template => $binop_mem, template => $binop_mem,
emit => "xor%M %#S3, %AM", emit => "xor%M %S3, %AM",
latency => 1, latency => 1,
}, },
...@@ -520,7 +520,7 @@ Sub => { ...@@ -520,7 +520,7 @@ Sub => {
SubMem => { SubMem => {
template => $binop_mem, template => $binop_mem,
emit => "sub%M %#S3, %AM", emit => "sub%M %S3, %AM",
latency => 1, latency => 1,
}, },
...@@ -636,7 +636,7 @@ RorMem => { ...@@ -636,7 +636,7 @@ RorMem => {
Rol => { Rol => {
template => $shiftop, template => $shiftop,
emit => "rol%M %<,S1 %#D0", emit => "rol%M %<,S1 %D0",
latency => 1, latency => 1,
}, },
...@@ -797,7 +797,7 @@ CMovcc => { ...@@ -797,7 +797,7 @@ CMovcc => {
am => "source,binary", am => "source,binary",
attr_type => "ia32_condcode_attr_t", attr_type => "ia32_condcode_attr_t",
attr => "x86_condition_code_t condition_code", attr => "x86_condition_code_t condition_code",
emit => "cmov%P5 %#AS4, %#D0", emit => "cmov%P5 %AS4, %D0",
latency => 1, latency => 1,
mode => "first", mode => "first",
}, },
...@@ -945,7 +945,7 @@ Load => { ...@@ -945,7 +945,7 @@ Load => {
ins => [ "base", "index", "mem" ], ins => [ "base", "index", "mem" ],
outs => [ "res", "unused", "M", "X_regular", "X_except" ], outs => [ "res", "unused", "M", "X_regular", "X_except" ],
latency => 0, latency => 0,
emit => "mov%#Ml %AM, %D0", emit => "mov%#Ml %AM, %#D0",
}, },
Store => { Store => {
...@@ -958,7 +958,7 @@ Store => { ...@@ -958,7 +958,7 @@ Store => {
out_reqs => [ "mem", "exec", "exec" ], out_reqs => [ "mem", "exec", "exec" ],
ins => [ "base", "index", "mem", "val" ], ins => [ "base", "index", "mem", "val" ],
outs => [ "M", "X_regular", "X_except" ], outs => [ "M", "X_regular", "X_except" ],
emit => "mov%M %#S3, %AM", emit => "mov%M %S3, %AM",
latency => 2, latency => 2,
}, },
...@@ -1173,7 +1173,7 @@ CmpXChgMem => { ...@@ -1173,7 +1173,7 @@ CmpXChgMem => {
out_reqs => [ "eax", "flags", "mem" ], out_reqs => [ "eax", "flags", "mem" ],
ins => [ "base", "index", "mem", "old", "new" ], ins => [ "base", "index", "mem", "old", "new" ],
outs => [ "res", "flags", "M" ], outs => [ "res", "flags", "M" ],
emit => "lock cmpxchg%M %#S4, %AM", emit => "lock cmpxchg%M %S4, %AM",
latency => 2, latency => 2,
}, },
...@@ -1193,7 +1193,7 @@ Xor0Low => { ...@@ -1193,7 +1193,7 @@ Xor0Low => {
out_reqs => [ "in_r0" ], out_reqs => [ "in_r0" ],
ins => [ "src" ], ins => [ "src" ],
outs => [ "res" ], outs => [ "res" ],
emit => "xor%M %#D0, %#D0", emit => "xor%M %D0, %D0",
latency => 1, latency => 1,
}, },
...@@ -1216,7 +1216,7 @@ Outport => { ...@@ -1216,7 +1216,7 @@ Outport => {
in_reqs => [ "edx", "eax", "mem" ], in_reqs => [ "edx", "eax", "mem" ],
out_reqs => [ "mem" ], out_reqs => [ "mem" ],
ins => [ "port", "value", "mem" ], ins => [ "port", "value", "mem" ],
emit => "out%M %#S1, %^S0", emit => "out%M %S1, %^S0",
latency => 1, latency => 1,
}, },
...@@ -1227,7 +1227,7 @@ Inport => { ...@@ -1227,7 +1227,7 @@ Inport => {
out_reqs => [ "eax", "mem" ], out_reqs => [ "eax", "mem" ],
ins => [ "port", "mem" ], ins => [ "port", "mem" ],
outs => [ "res", "M" ], outs => [ "res", "M" ],
emit => "in%M %^S0, %#D0", emit => "in%M %^S0, %D0",
latency => 1, latency => 1,
}, },
...@@ -1298,21 +1298,21 @@ xAllOnes => { ...@@ -1298,21 +1298,21 @@ xAllOnes => {
# integer shift left, dword # integer shift left, dword
xPslld => { xPslld => {
template => $xshiftop, template => $xshiftop,
emit => "pslld %#S1, %D0", emit => "pslld %S1, %D0",
latency => 3, latency => 3,
}, },
# integer shift left, qword # integer shift left, qword
xPsllq => { xPsllq => {
template => $xshiftop, template => $xshiftop,
emit => "psllq %#S1, %D0", emit => "psllq %S1, %D0",
latency => 3, latency => 3,
}, },
# integer shift right, dword # integer shift right, dword
xPsrld => { xPsrld => {
template => $xshiftop, template => $xshiftop,
emit => "psrld %#S1, %D0", emit => "psrld %S1, %D0",
latency => 1, latency => 1,
}, },
...@@ -1499,7 +1499,7 @@ Conv_I2I => { ...@@ -1499,7 +1499,7 @@ Conv_I2I => {
out_reqs => [ "gp", "none", "mem", "exec", "exec" ], out_reqs => [ "gp", "none", "mem", "exec", "exec" ],
ins => [ "base", "index", "mem", "val" ], ins => [ "base", "index", "mem", "val" ],
outs => [ "res", "unused", "M", "X_regular", "X_except" ], outs => [ "res", "unused", "M", "X_regular", "X_except" ],
emit => "mov%#Ml %#AS3, %D0", emit => "mov%#Ml %AS3, %#D0",
am => "source,unary", am => "source,unary",
latency => 1, latency => 1,
attr => "ir_mode *smaller_mode", attr => "ir_mode *smaller_mode",
......
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