@@ -1815,10 +1815,11 @@ static inline void setup_guest_base_seg(void) { }
static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi,
TCGReg base, int index, intptr_t ofs,
- int seg, TCGMemOp memop)
+ int seg, bool is64, TCGMemOp memop)
{
bool use_bswap = memop & MO_BSWAP;
bool use_movbe = false;
+ int rexw = is64 * P_REXW;
int movop = OPC_MOVL_GvEv;
/*
@@ -1843,7 +1844,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi,
base, index, 0, ofs);
break;
case MO_SB:
- tcg_out_modrm_sib_offset(s, OPC_MOVSBL + P_REXW + seg, datalo,
+ tcg_out_modrm_sib_offset(s, OPC_MOVSBL + rexw + seg, datalo,
base, index, 0, ofs);
break;
case MO_UW:
@@ -1871,14 +1872,15 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi,
if (use_movbe) {
tcg_out_modrm_sib_offset(s, OPC_MOVBE_GyMy + P_DATA16 + seg,
datalo, base, index, 0, ofs);
- tcg_out_ext16s(s, datalo, datalo, P_REXW);
- } else {
- tcg_out_modrm_sib_offset(s, OPC_MOVSWL + P_REXW + seg,
+ tcg_out_ext16s(s, datalo, datalo, rexw);
+ } else if (use_bswap) {
+ tcg_out_modrm_sib_offset(s, OPC_MOVSWL + seg,
+ datalo, base, index, 0, ofs);
+ tcg_out_rolw_8(s, datalo);
+ tcg_out_ext16s(s, datalo, datalo, rexw);
+ } else {
+ tcg_out_modrm_sib_offset(s, OPC_MOVSWL + rexw + seg,
datalo, base, index, 0, ofs);
- if (use_bswap) {
- tcg_out_rolw_8(s, datalo);
- tcg_out_ext16s(s, datalo, datalo, P_REXW);
- }
}
break;
case MO_UL:
@@ -2004,7 +2006,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64)
}
tcg_out_qemu_ld_direct(s, datalo, datahi,
- base, index, offset, seg, opc);
+ base, index, offset, seg, is64, opc);
}
#endif
}
@@ -2202,7 +2204,7 @@ static tcg_insn_unit *tcg_out_qemu_ldst_ool(TCGContext *s, bool is_ld,
/* TLB Hit. */
if (is_ld) {
- tcg_out_qemu_ld_direct(s, datalo, datahi, base, -1, 0, 0, opc);
+ tcg_out_qemu_ld_direct(s, datalo, datahi, base, -1, 0, 0, is_64, opc);
} else {
tcg_out_qemu_st_direct(s, datalo, datahi, base, 0, 0, opc);
}
This can save a few rex prefixes for qemu_ld_i32. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- tcg/i386/tcg-target.inc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) -- 2.17.2