From patchwork Wed Apr 14 17:59:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 51208 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 B183CB7D43 for ; Thu, 29 Apr 2010 05:25:20 +1000 (EST) Received: from localhost ([127.0.0.1]:48774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7C8F-0003xL-2a for incoming@patchwork.ozlabs.org; Wed, 28 Apr 2010 14:37:11 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7C1c-0000Il-Rb for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:20 -0400 Received: from [140.186.70.92] (port=46613 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7C1W-0000FW-Lx for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7C1R-0004R6-Lp for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:14 -0400 Received: from are.twiddle.net ([75.149.56.221]:36488) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7C1R-0004Qr-Dz for qemu-devel@nongnu.org; Wed, 28 Apr 2010 14:30:09 -0400 Received: by are.twiddle.net (Postfix, from userid 5000) id 4F1DA1071; Wed, 28 Apr 2010 11:30:06 -0700 (PDT) Message-Id: <2423c13baa12737f6bc296973ba3d7266b4f8dfd.1272479073.git.rth@twiddle.net> In-Reply-To: References: From: Richard Henderson Date: Wed, 14 Apr 2010 10:59:48 -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 13/22] tcg-i386: Tidy push/pop. 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 Move tcg_out_push/pop up in the file so that they can be used by qemu_ld/st. Define a tcg_out_pushi to be used as well. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c | 50 +++++++++++++++++++++++++++++++----------------- 1 files changed, 32 insertions(+), 18 deletions(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 06946e5..58fcd23 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -183,6 +183,10 @@ static inline int tcg_target_const_match(tcg_target_long val, #define OPC_MOVZWL (0xb7 | P_EXT) #define OPC_MOVSBL (0xbe | P_EXT) #define OPC_MOVSWL (0xbf | P_EXT) +#define OPC_POP_r32 (0x58) +#define OPC_PUSH_r32 (0x50) +#define OPC_PUSH_Iv (0x68) +#define OPC_PUSH_Ib (0x6a) #define OPC_SHIFT_1 (0xd1) #define OPC_SHIFT_Ib (0xc1) #define OPC_SHIFT_cl (0xd3) @@ -311,6 +315,29 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, } } +#if defined(CONFIG_SOFTMMU) +static void tcg_out_pushi(TCGContext *s, tcg_target_long val) +{ + if (val == (int8_t)val) { + tcg_out_opc(s, OPC_PUSH_Ib); + tcg_out8(s, val); + } else { + tcg_out_opc(s, OPC_PUSH_Iv); + tcg_out32(s, val); + } +} +#endif + +static inline void tcg_out_push(TCGContext *s, int reg) +{ + tcg_out_opc(s, OPC_PUSH_r32 + reg); +} + +static inline void tcg_out_pop(TCGContext *s, int reg) +{ + tcg_out_opc(s, OPC_POP_r32 + reg); +} + static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, int arg1, tcg_target_long arg2) { @@ -910,8 +937,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, if (opc == 3) { tcg_out_mov(s, TCG_REG_EDX, data_reg); tcg_out_mov(s, TCG_REG_ECX, data_reg2); - tcg_out8(s, 0x6a); /* push Ib */ - tcg_out8(s, mem_index); + tcg_out_pushi(s, mem_index); tcg_out8(s, 0xe8); tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] - (tcg_target_long)s->code_ptr - 4); @@ -936,10 +962,9 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, #else if (opc == 3) { tcg_out_mov(s, TCG_REG_EDX, addr_reg2); - tcg_out8(s, 0x6a); /* push Ib */ - tcg_out8(s, mem_index); - tcg_out_opc(s, 0x50 + data_reg2); /* push */ - tcg_out_opc(s, 0x50 + data_reg); /* push */ + tcg_out_pushi(s, mem_index); + tcg_out_push(s, data_reg2); + tcg_out_push(s, data_reg); tcg_out8(s, 0xe8); tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] - (tcg_target_long)s->code_ptr - 4); @@ -957,8 +982,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, tcg_out_mov(s, TCG_REG_ECX, data_reg); break; } - tcg_out8(s, 0x6a); /* push Ib */ - tcg_out8(s, mem_index); + tcg_out_pushi(s, mem_index); tcg_out8(s, 0xe8); tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] - (tcg_target_long)s->code_ptr - 4); @@ -1371,16 +1395,6 @@ static int tcg_target_callee_save_regs[] = { TCG_REG_EDI, }; -static inline void tcg_out_push(TCGContext *s, int reg) -{ - tcg_out_opc(s, 0x50 + reg); -} - -static inline void tcg_out_pop(TCGContext *s, int reg) -{ - tcg_out_opc(s, 0x58 + reg); -} - /* Generate global QEMU prologue and epilogue code */ void tcg_target_qemu_prologue(TCGContext *s) {