From patchwork Wed Apr 14 15:38:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 50182 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 1A59BB7D1D for ; Thu, 15 Apr 2010 07:05:31 +1000 (EST) Received: from localhost ([127.0.0.1]:37819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O29m3-00042k-9p for incoming@patchwork.ozlabs.org; Wed, 14 Apr 2010 17:05:27 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O29XV-0004qb-Vj for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:26 -0400 Received: from [140.186.70.92] (port=35511 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O29XN-0004hd-OU for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O29XH-0001R3-J1 for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:17 -0400 Received: from are.twiddle.net ([75.149.56.221]:41953) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O29XH-0001QT-8U for qemu-devel@nongnu.org; Wed, 14 Apr 2010 16:50:11 -0400 Received: by are.twiddle.net (Postfix, from userid 5000) id AD2B7EC7; Wed, 14 Apr 2010 13:50:10 -0700 (PDT) Message-Id: <5ecdb09849a42ad5e6fbd8e6ec0181c604cebc57.1271277329.git.rth@twiddle.net> In-Reply-To: References: From: Richard Henderson Date: Wed, 14 Apr 2010 08:38:34 -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 10/21] tcg-i386: Tidy immediate arithmetic 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_ARITH_EvI[bz]; use throughout. Use tcg_out_ext8u directly in setcond. Use tgen_arithi in qemu_ld/st. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c | 28 +++++++++++----------------- 1 files changed, 11 insertions(+), 17 deletions(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 9d728f5..fb553f4 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -163,6 +163,8 @@ static inline int tcg_target_const_match(tcg_target_long val, #define P_EXT 0x100 /* 0x0f opcode prefix */ +#define OPC_ARITH_EvIz (0x81) +#define OPC_ARITH_EvIb (0x83) #define OPC_BSWAP (0xc8 | P_EXT) #define OPC_JCC_long (0x80 | P_EXT) /* ... plus condition code */ #define OPC_JCC_short (0x70) /* ... plus condition code */ @@ -324,7 +326,7 @@ static void tcg_out_ext8u(TCGContext *s, int dest, int src) if (src >= 4) { tcg_out_mov(s, dest, src); if (dest >= 4) { - tcg_out_modrm(s, 0x81, ARITH_AND, dest); + tcg_out_modrm(s, OPC_ARITH_EvIz, ARITH_AND, dest); tcg_out32(s, 0xff); return; } @@ -384,14 +386,14 @@ static inline void tgen_arithi(TCGContext *s, int c, int r0, int32_t val, int cf /* dec */ tcg_out_opc(s, 0x48 + r0); } else if (val == (int8_t)val) { - tcg_out_modrm(s, 0x83, c, r0); + tcg_out_modrm(s, OPC_ARITH_EvIb, c, r0); tcg_out8(s, val); } else if (c == ARITH_AND && val == 0xffu && r0 < 4) { tcg_out_ext8u(s, r0, r0); } else if (c == ARITH_AND && val == 0xffffu) { tcg_out_ext16u(s, r0, r0); } else { - tcg_out_modrm(s, 0x81, c, r0); + tcg_out_modrm(s, OPC_ARITH_EvIz, c, r0); tcg_out32(s, val); } } @@ -560,7 +562,7 @@ static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGArg dest, tcg_out_cmp(s, arg1, arg2, const_arg2); /* setcc */ tcg_out_modrm(s, 0x90 | tcg_cond_to_jcc[cond] | P_EXT, 0, dest); - tgen_arithi(s, ARITH_AND, dest, 0xff, 0); + tcg_out_ext8u(s, dest, dest); } static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, @@ -662,16 +664,12 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, #if defined(CONFIG_SOFTMMU) tcg_out_mov(s, r1, addr_reg); - tcg_out_mov(s, r0, addr_reg); - + tcg_out_shifti(s, SHIFT_SHR, r1, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); - tcg_out_modrm(s, 0x81, 4, r0); /* andl $x, r0 */ - tcg_out32(s, TARGET_PAGE_MASK | ((1 << s_bits) - 1)); - - tcg_out_modrm(s, 0x81, 4, r1); /* andl $x, r1 */ - tcg_out32(s, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS); + tgen_arithi(s, ARITH_AND, r0, TARGET_PAGE_MASK | ((1 << s_bits) - 1), 0); + tgen_arithi(s, ARITH_AND, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0); tcg_out_opc(s, 0x8d); /* lea offset(r1, %ebp), r1 */ tcg_out8(s, 0x80 | (r1 << 3) | 0x04); @@ -855,16 +853,12 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, #if defined(CONFIG_SOFTMMU) tcg_out_mov(s, r1, addr_reg); - tcg_out_mov(s, r0, addr_reg); tcg_out_shifti(s, SHIFT_SHR, r1, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); - tcg_out_modrm(s, 0x81, 4, r0); /* andl $x, r0 */ - tcg_out32(s, TARGET_PAGE_MASK | ((1 << s_bits) - 1)); - - tcg_out_modrm(s, 0x81, 4, r1); /* andl $x, r1 */ - tcg_out32(s, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS); + tgen_arithi(s, ARITH_AND, r0, TARGET_PAGE_MASK | ((1 << s_bits) - 1), 0); + tgen_arithi(s, ARITH_AND, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0); tcg_out_opc(s, 0x8d); /* lea offset(r1, %ebp), r1 */ tcg_out8(s, 0x80 | (r1 << 3) | 0x04);