From patchwork Fri May 21 15:30:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 53165 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 9B348B7D1B for ; Sat, 22 May 2010 01:32:32 +1000 (EST) Received: from localhost ([127.0.0.1]:36148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFUD6-0000wI-GW for incoming@patchwork.ozlabs.org; Fri, 21 May 2010 11:32:28 -0400 Received: from [140.186.70.92] (port=53092 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFUBW-0000rV-2Z for qemu-devel@nongnu.org; Fri, 21 May 2010 11:30:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OFUBR-0003KA-2m for qemu-devel@nongnu.org; Fri, 21 May 2010 11:30:49 -0400 Received: from are.twiddle.net ([75.149.56.221]:52872) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OFUBQ-0003Jo-Mz for qemu-devel@nongnu.org; Fri, 21 May 2010 11:30:45 -0400 Received: from anchor.twiddle.home (anchor.twiddle.home [172.31.0.4]) by are.twiddle.net (Postfix) with ESMTPS id 33E3CF1F; Fri, 21 May 2010 08:30:44 -0700 (PDT) Received: from anchor.twiddle.home (anchor.twiddle.home [127.0.0.1]) by anchor.twiddle.home (8.14.4/8.14.4) with ESMTP id o4LFUhfj018054; Fri, 21 May 2010 08:30:43 -0700 Received: (from rth@localhost) by anchor.twiddle.home (8.14.4/8.14.4/Submit) id o4LFUhCj018053; Fri, 21 May 2010 08:30:43 -0700 From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 21 May 2010 08:30:26 -0700 Message-Id: X-Mailer: git-send-email 1.7.0.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 06/15] 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 | 48 ++++++++++++++++++++++++++++++------------------ 1 files changed, 30 insertions(+), 18 deletions(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 1d227db..a487375 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -178,6 +178,10 @@ static inline int tcg_target_const_match(tcg_target_long val, #define OPC_MOVSWL (0xbf | P_EXT) #define OPC_MOVZBL (0xb6 | P_EXT) #define OPC_MOVZWL (0xb7 | 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) @@ -306,6 +310,27 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, } } +static inline 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); + } +} + +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) { @@ -891,8 +916,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); @@ -917,10 +941,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); @@ -938,8 +961,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); @@ -1352,16 +1374,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) {