From patchwork Wed Apr 28 18:23:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 51202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 68571B7D55 for ; Thu, 29 Apr 2010 05:14:54 +1000 (EST) Received: from localhost ([127.0.0.1]:45787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7Cih-0003Lv-Hp for incoming@patchwork.ozlabs.org; Wed, 28 Apr 2010 15:14:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7C1p-0000PR-LA for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:33 -0400 Received: from [140.186.70.92] (port=46586 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7C1b-0000Es-El for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7C1S-0004Sm-Ak for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:19 -0400 Received: from are.twiddle.net ([75.149.56.221]:36493) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7C1S-0004S6-4Y for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:10 -0400 Received: by are.twiddle.net (Postfix, from userid 5000) id 9B6CD107F; Wed, 28 Apr 2010 11:30:06 -0700 (PDT) Message-Id: <3db58a6cdca2ce330bd61a8959270fb9671f4ffc.1272479073.git.rth@twiddle.net> In-Reply-To: References: From: Richard Henderson Date: Wed, 28 Apr 2010 11:23:19 -0700 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 22/22] tcg-i386: Tidy data16 prefixes. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-by: Aurelien Jarno --- tcg/i386/tcg-target.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 646a7b6..2f096fa 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -161,7 +161,8 @@ static inline int tcg_target_const_match(tcg_target_long val, return 0; } -#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_EvIb (0x83) @@ -267,8 +268,12 @@ static const uint8_t tcg_cond_to_jcc[10] = { 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, opc); } @@ -460,8 +465,8 @@ static inline void tcg_out_bswap32(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, reg, 8); + tcg_out_modrm(s, OPC_SHIFT_Ib | P_DATA16, SHIFT_ROL, reg); + tcg_out8(s, 8); } static inline void tgen_arithi(TCGContext *s, int c, int r0, @@ -1074,8 +1079,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, data_reg = r1; } /* movw */ - tcg_out8(s, 0x66); - tcg_out_modrm_offset(s, OPC_MOVL_EvGv, data_reg, r0, GUEST_BASE); + tcg_out_modrm_offset(s, OPC_MOVL_EvGv | P_DATA16, + data_reg, r0, GUEST_BASE); break; case 2: if (bswap) { @@ -1180,8 +1185,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_st16_i32: /* movw */ - tcg_out8(s, 0x66); - tcg_out_modrm_offset(s, OPC_MOVL_EvGv, args[0], args[1], args[2]); + tcg_out_modrm_offset(s, OPC_MOVL_EvGv | P_DATA16, + args[0], args[1], args[2]); break; case INDEX_op_st_i32: tcg_out_st(s, TCG_TYPE_I32, args[0], args[1], args[2]);