tcg-i386: Tidy data16 prefixes.

Include it in the opcode as an extension, as with P_EXT
or the REX bits in the x86-64 port.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Richard Henderson 2010-05-21 09:03:00 -07:00 committed by Aurelien Jarno
parent fb170183e7
commit 96b4cf38f0
1 changed files with 18 additions and 10 deletions

View File

@ -157,6 +157,7 @@ static inline int tcg_target_const_match(tcg_target_long val,
} }
#define P_EXT 0x100 /* 0x0f opcode prefix */ #define P_EXT 0x100 /* 0x0f opcode prefix */
#define P_DATA16 0x200 /* 0x66 opcode prefix */
#define OPC_ARITH_EvIz (0x81) #define OPC_ARITH_EvIz (0x81)
#define OPC_ARITH_EvIb (0x83) #define OPC_ARITH_EvIb (0x83)
@ -262,8 +263,12 @@ static const uint8_t tcg_cond_to_jcc[10] = {
static inline void tcg_out_opc(TCGContext *s, int opc) static inline void tcg_out_opc(TCGContext *s, int opc)
{ {
if (opc & P_EXT) if (opc & P_DATA16) {
tcg_out8(s, 0x66);
}
if (opc & P_EXT) {
tcg_out8(s, 0x0f); tcg_out8(s, 0x0f);
}
tcg_out8(s, opc); tcg_out8(s, opc);
} }
@ -396,10 +401,14 @@ static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
static void tcg_out_shifti(TCGContext *s, int subopc, int reg, int count) static void tcg_out_shifti(TCGContext *s, int subopc, int reg, int count)
{ {
/* Propagate an opcode prefix, such as P_DATA16. */
int ext = subopc & ~0x7;
subopc &= 0x7;
if (count == 1) { if (count == 1) {
tcg_out_modrm(s, OPC_SHIFT_1, subopc, reg); tcg_out_modrm(s, OPC_SHIFT_1 | ext, subopc, reg);
} else { } else {
tcg_out_modrm(s, OPC_SHIFT_Ib, subopc, reg); tcg_out_modrm(s, OPC_SHIFT_Ib | ext, subopc, reg);
tcg_out8(s, count); tcg_out8(s, count);
} }
} }
@ -411,8 +420,7 @@ static inline void tcg_out_bswap32(TCGContext *s, int reg)
static inline void tcg_out_rolw_8(TCGContext *s, int reg) static inline void tcg_out_rolw_8(TCGContext *s, int reg)
{ {
tcg_out8(s, 0x66); tcg_out_shifti(s, SHIFT_ROL | P_DATA16, reg, 8);
tcg_out_shifti(s, SHIFT_ROL, reg, 8);
} }
static inline void tcg_out_ext8u(TCGContext *s, int dest, int src) static inline void tcg_out_ext8u(TCGContext *s, int dest, int src)
@ -1053,8 +1061,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
data_reg = r1; data_reg = r1;
} }
/* movw */ /* movw */
tcg_out8(s, 0x66); tcg_out_modrm_offset(s, OPC_MOVL_EvGv | P_DATA16,
tcg_out_modrm_offset(s, OPC_MOVL_EvGv, data_reg, r0, GUEST_BASE); data_reg, r0, GUEST_BASE);
break; break;
case 2: case 2:
if (bswap) { if (bswap) {
@ -1159,8 +1167,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
break; break;
case INDEX_op_st16_i32: case INDEX_op_st16_i32:
/* movw */ /* movw */
tcg_out8(s, 0x66); tcg_out_modrm_offset(s, OPC_MOVL_EvGv | P_DATA16,
tcg_out_modrm_offset(s, OPC_MOVL_EvGv, args[0], args[1], args[2]); args[0], args[1], args[2]);
break; break;
case INDEX_op_st_i32: case INDEX_op_st_i32:
tcg_out_st(s, TCG_TYPE_I32, args[0], args[1], args[2]); tcg_out_st(s, TCG_TYPE_I32, args[0], args[1], args[2]);