Commit d6b4ea8c authored by Matthias Braun's avatar Matthias Braun
Browse files

ia32: use short encoding for Shl,Shr,Sar,Rol,Ror with immediate 1

parent 525efbbb
......@@ -355,7 +355,8 @@ typedef enum ia32_emit_mod_t {
EMIT_LONG = 1U << 2,
EMIT_HIGH_REG = 1U << 3,
EMIT_LOW_REG = 1U << 4,
EMIT_16BIT_REG = 1U << 5
EMIT_16BIT_REG = 1U << 5,
EMIT_SHIFT_COMMA = 1U << 6,
} ia32_emit_mod_t;
ENUM_BITSET(ia32_emit_mod_t)
......@@ -459,6 +460,7 @@ void ia32_emitf(ir_node const *const node, char const *fmt, ...)
case '>': mod |= EMIT_HIGH_REG; break;
case '<': mod |= EMIT_LOW_REG; break;
case '^': mod |= EMIT_16BIT_REG; break;
case ',': mod |= EMIT_SHIFT_COMMA; break;
default:
goto end_of_mods;
}
......@@ -582,9 +584,18 @@ destination_operand:
case 'I':
imm = node;
emit_I:
if (mod & EMIT_SHIFT_COMMA) {
const ia32_immediate_attr_t *attr
= get_ia32_immediate_attr_const(imm);
if (attr->symconst == NULL && attr->offset == 1)
break;
}
if (!(mod & EMIT_ALTERNATE_AM))
be_emit_char('$');
emit_ia32_Immediate_no_prefix(imm);
if (mod & EMIT_SHIFT_COMMA) {
be_emit_char(',');
}
break;
case 'L':
......@@ -634,6 +645,9 @@ emit_R:
} else {
emit_register(reg, mod & EMIT_RESPECT_LS ? get_ia32_ls_mode(node) : NULL);
}
if (mod & EMIT_SHIFT_COMMA) {
be_emit_char(',');
}
break;
emit_S:
......
......@@ -45,6 +45,8 @@
* l modifier for %lu and %ld
* > modifier to output high 8bit register (ah, bh)
* < modifier to output low 8bit register (al, bl)
* , modifier output comma after operand, leave out operand if it is 1
* (used for shift nodes)
*/
void ia32_emitf(ir_node const *node, char const *fmt, ...);
......
......@@ -487,7 +487,7 @@ Shl => {
out => [ "in_r1 !in_r2", "flags" ] },
ins => [ "val", "count" ],
outs => [ "res", "flags" ],
emit => "shl%M %<S1, %D0",
emit => "shl%M %<,S1 %D0",
latency => 1,
mode => $mode_gp,
modified_flags => $status_flags
......@@ -498,7 +498,7 @@ ShlMem => {
state => "exc_pinned",
reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
ins => [ "base", "index", "mem", "count" ],
emit => "shl%M %<S3, %AM",
emit => "shl%M %<,S3 %AM",
latency => 1,
mode => "mode_M",
modified_flags => $status_flags
......@@ -522,7 +522,7 @@ Shr => {
out => [ "in_r1 !in_r2", "flags" ] },
ins => [ "val", "count" ],
outs => [ "res", "flags" ],
emit => "shr%M %<S1, %D0",
emit => "shr%M %<,S1 %D0",
mode => $mode_gp,
latency => 1,
modified_flags => $status_flags
......@@ -533,7 +533,7 @@ ShrMem => {
state => "exc_pinned",
reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
ins => [ "base", "index", "mem", "count" ],
emit => "shr%M %<S3, %AM",
emit => "shr%M %<,S3 %AM",
mode => "mode_M",
latency => 1,
modified_flags => $status_flags
......@@ -557,7 +557,7 @@ Sar => {
out => [ "in_r1 !in_r2", "flags" ] },
ins => [ "val", "count" ],
outs => [ "res", "flags" ],
emit => "sar%M %<S1, %D0",
emit => "sar%M %<,S1 %D0",
latency => 1,
mode => $mode_gp,
modified_flags => $status_flags
......@@ -568,7 +568,7 @@ SarMem => {
state => "exc_pinned",
reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
ins => [ "base", "index", "mem", "count" ],
emit => "sar%M %<S3, %AM",
emit => "sar%M %<,S3 %AM",
latency => 1,
mode => "mode_M",
modified_flags => $status_flags
......@@ -580,7 +580,7 @@ Ror => {
out => [ "in_r1 !in_r2", "flags" ] },
ins => [ "val", "count" ],
outs => [ "res", "flags" ],
emit => "ror%M %<S1, %D0",
emit => "ror%M %<,S1 %D0",
latency => 1,
mode => $mode_gp,
modified_flags => $status_flags
......@@ -591,7 +591,7 @@ RorMem => {
state => "exc_pinned",
reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
ins => [ "base", "index", "mem", "count" ],
emit => "ror%M %<S3, %AM",
emit => "ror%M %<,S3 %AM",
latency => 1,
mode => "mode_M",
modified_flags => $status_flags
......@@ -603,7 +603,7 @@ Rol => {
out => [ "in_r1 !in_r2", "flags" ] },
ins => [ "val", "count" ],
outs => [ "res", "flags" ],
emit => "rol%M %<S1, %D0",
emit => "rol%M %<,S1 %D0",
latency => 1,
mode => $mode_gp,
modified_flags => $status_flags
......@@ -614,7 +614,7 @@ RolMem => {
state => "exc_pinned",
reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
ins => [ "base", "index", "mem", "count" ],
emit => "rol%M %<S3, %AM",
emit => "rol%M %<,S3 %AM",
latency => 1,
mode => "mode_M",
modified_flags => $status_flags
......
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