From patchwork Wed Apr 14 14:58:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 50188 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 1C31DB7D40 for ; Thu, 15 Apr 2010 07:17:32 +1000 (EST) Received: from localhost ([127.0.0.1]:48155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O29xg-0005He-My for incoming@patchwork.ozlabs.org; Wed, 14 Apr 2010 17:17:28 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O29XX-0004od-LU for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:30 -0400 Received: from [140.186.70.92] (port=35453 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O29XK-0004dS-8C for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O29XE-0001PV-EK for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:13 -0400 Received: from are.twiddle.net ([75.149.56.221]:41946) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O29XE-0001PD-4G for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:08 -0400 Received: by are.twiddle.net (Postfix, from userid 5000) id 8D64BEC6; Wed, 14 Apr 2010 13:50:07 -0700 (PDT) Message-Id: In-Reply-To: References: From: Richard Henderson Date: Wed, 14 Apr 2010 07:58:59 -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 07/21] tcg-i386: Tidy move operations. 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 Define OPC_MOVB* and OPC_MOVL*; use them throughout. Use tcg_out_ld/st instead of bare tcg_out_modrm_offset when it makes sense. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c | 51 +++++++++++++++++++++++------------------------- 1 files changed, 24 insertions(+), 27 deletions(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 2df45bf..4f7df70 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -164,6 +164,9 @@ static inline int tcg_target_const_match(tcg_target_long val, #define P_EXT 0x100 /* 0x0f opcode prefix */ #define OPC_BSWAP (0xc8 | P_EXT) +#define OPC_MOVB_EvGv (0x88) /* stores, more or less */ +#define OPC_MOVL_EvGv (0x89) /* stores, more or less */ +#define OPC_MOVL_GvEv (0x8b) /* loads, more or less */ #define OPC_MOVZBL (0xb6 | P_EXT) #define OPC_MOVZWL (0xb7 | P_EXT) #define OPC_MOVSBL (0xbe | P_EXT) @@ -267,8 +270,9 @@ static inline void tcg_out_modrm_offset(TCGContext *s, int opc, int r, int rm, static inline void tcg_out_mov(TCGContext *s, int ret, int arg) { - if (arg != ret) - tcg_out_modrm(s, 0x8b, ret, arg); + if (arg != ret) { + tcg_out_modrm(s, OPC_MOVL_GvEv, ret, arg); + } } static inline void tcg_out_movi(TCGContext *s, TCGType type, @@ -286,15 +290,13 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, int arg1, tcg_target_long arg2) { - /* movl */ - tcg_out_modrm_offset(s, 0x8b, ret, arg1, arg2); + tcg_out_modrm_offset(s, OPC_MOVL_GvEv, ret, arg1, arg2); } static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, int arg1, tcg_target_long arg2) { - /* movl */ - tcg_out_modrm_offset(s, 0x89, arg, arg1, arg2); + tcg_out_modrm_offset(s, OPC_MOVL_EvGv, arg, arg1, arg2); } static void tcg_out_shifti(TCGContext *s, int subopc, int reg, int count) @@ -779,8 +781,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, } break; case 2: - /* movl (r0), data_reg */ - tcg_out_modrm_offset(s, 0x8b, data_reg, r0, GUEST_BASE); + tcg_out_ld(s, TCG_TYPE_I32, data_reg, r0, GUEST_BASE); if (bswap) { tcg_out_bswap32(s, data_reg); } @@ -795,13 +796,13 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, r0 = r1; } if (!bswap) { - tcg_out_modrm_offset(s, 0x8b, data_reg, r0, GUEST_BASE); - tcg_out_modrm_offset(s, 0x8b, data_reg2, r0, GUEST_BASE + 4); + tcg_out_ld(s, TCG_TYPE_I32, data_reg, r0, GUEST_BASE); + tcg_out_ld(s, TCG_TYPE_I32, data_reg2, r0, GUEST_BASE + 4); } else { - tcg_out_modrm_offset(s, 0x8b, data_reg, r0, GUEST_BASE + 4); + tcg_out_ld(s, TCG_TYPE_I32, data_reg, r0, GUEST_BASE + 4); tcg_out_bswap32(s, data_reg); - tcg_out_modrm_offset(s, 0x8b, data_reg2, r0, GUEST_BASE); + tcg_out_ld(s, TCG_TYPE_I32, data_reg2, r0, GUEST_BASE); tcg_out_bswap32(s, data_reg2); } break; @@ -975,8 +976,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, #endif switch(opc) { case 0: - /* movb */ - tcg_out_modrm_offset(s, 0x88, data_reg, r0, GUEST_BASE); + tcg_out_modrm_offset(s, OPC_MOVB_EvGv, data_reg, r0, GUEST_BASE); break; case 1: if (bswap) { @@ -987,7 +987,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, } /* movw */ tcg_out8(s, 0x66); - tcg_out_modrm_offset(s, 0x89, data_reg, r0, GUEST_BASE); + tcg_out_modrm_offset(s, OPC_MOVL_EvGv, data_reg, r0, GUEST_BASE); break; case 2: if (bswap) { @@ -995,20 +995,19 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, tcg_out_bswap32(s, r1); data_reg = r1; } - /* movl */ - tcg_out_modrm_offset(s, 0x89, data_reg, r0, GUEST_BASE); + tcg_out_st(s, TCG_TYPE_I32, data_reg, r0, GUEST_BASE); break; case 3: if (bswap) { tcg_out_mov(s, r1, data_reg2); tcg_out_bswap32(s, r1); - tcg_out_modrm_offset(s, 0x89, r1, r0, GUEST_BASE); + tcg_out_st(s, TCG_TYPE_I32, r1, r0, GUEST_BASE); tcg_out_mov(s, r1, data_reg); tcg_out_bswap32(s, r1); - tcg_out_modrm_offset(s, 0x89, r1, r0, GUEST_BASE + 4); + tcg_out_st(s, TCG_TYPE_I32, r1, r0, GUEST_BASE + 4); } else { - tcg_out_modrm_offset(s, 0x89, data_reg, r0, GUEST_BASE); - tcg_out_modrm_offset(s, 0x89, data_reg2, r0, GUEST_BASE + 4); + tcg_out_st(s, TCG_TYPE_I32, data_reg, r0, GUEST_BASE); + tcg_out_st(s, TCG_TYPE_I32, data_reg2, r0, GUEST_BASE + 4); } break; default: @@ -1085,21 +1084,19 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_modrm_offset(s, OPC_MOVSWL, args[0], args[1], args[2]); break; case INDEX_op_ld_i32: - /* movl */ - tcg_out_modrm_offset(s, 0x8b, args[0], args[1], args[2]); + tcg_out_ld(s, TCG_TYPE_I32, args[0], args[1], args[2]); break; case INDEX_op_st8_i32: /* movb */ - tcg_out_modrm_offset(s, 0x88, args[0], args[1], args[2]); + tcg_out_modrm_offset(s, OPC_MOVB_EvGv, args[0], args[1], args[2]); break; case INDEX_op_st16_i32: /* movw */ tcg_out8(s, 0x66); - tcg_out_modrm_offset(s, 0x89, args[0], args[1], args[2]); + tcg_out_modrm_offset(s, OPC_MOVL_EvGv, args[0], args[1], args[2]); break; case INDEX_op_st_i32: - /* movl */ - tcg_out_modrm_offset(s, 0x89, args[0], args[1], args[2]); + tcg_out_st(s, TCG_TYPE_I32, args[0], args[1], args[2]); break; case INDEX_op_sub_i32: c = ARITH_SUB;