From patchwork Fri Apr 9 07:36:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 49784 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 6FD63B7D0C for ; Fri, 9 Apr 2010 17:50:21 +1000 (EST) Received: from localhost ([127.0.0.1]:43223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O08x0-0006MO-U2 for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2010 03:48:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O08mP-0004og-9D for qemu-devel@nongnu.org; Fri, 09 Apr 2010 03:37:29 -0400 Received: from [140.186.70.92] (port=49454 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O08lu-0004iA-BU for qemu-devel@nongnu.org; Fri, 09 Apr 2010 03:37:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O08ld-0000KK-4w for qemu-devel@nongnu.org; Fri, 09 Apr 2010 03:36:57 -0400 Received: from moutng.kundenserver.de ([212.227.17.8]:53199) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O08lU-0000JH-Qz for qemu-devel@nongnu.org; Fri, 09 Apr 2010 03:36:33 -0400 Received: from flocke.weilnetz.de (p54ADF948.dip.t-dialin.net [84.173.249.72]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0La2aD-1NF0lM1j49-00mIFu; Fri, 09 Apr 2010 09:36:29 +0200 Received: from stefan by flocke.weilnetz.de with local (Exim 4.71) (envelope-from ) id 1O08lQ-0001r6-FS; Fri, 09 Apr 2010 09:36:28 +0200 From: Stefan Weil To: QEMU Developers Date: Fri, 9 Apr 2010 09:36:25 +0200 Message-Id: <1270798585-7100-1-git-send-email-weil@mail.berlios.de> X-Mailer: git-send-email 1.7.0 In-Reply-To: <4BBECC3F.7050207@mail.berlios.de> References: <4BBECC3F.7050207@mail.berlios.de> X-Provags-ID: V01U2FsdGVkX1+MOp0st4LTiGfUapekqM7flGVWxtJBXDAJW1m 7w4M6h/h0SooR9/P0x+ipRe88abNOhsZNBMuKDQQQdASDk9/yC VVvySREr0IfL1Bo0vXM8PuBGEbWQxCUb3e3ljjpu2lB/wJoq9L xLQ== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Aurelien Jarno Subject: [Qemu-devel] [PATCH] tcp/mips: Change TCG_AREG0 (fp -> s0) 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 Register fp (frame pointer) is a bad choice for compilations without optimisation, because the compiler makes heavy use of this register (so the resulting code crashes). Register s0 was used for TCG_AREG1 in earlier releases, but was no longer used and is now free for TCG_AREG0. The resulting code works for compilations without optimisation (tested with qemu mips in qemu mips on x86 host). v2: * Remove s0 from tcg_target_callee_save_regs and add fp there. Hint from Aurelien Jarno, thanks. * Add fp to list of reserved registers. Cc: Aurelien Jarno Signed-off-by: Stefan Weil --- dyngen-exec.h | 2 +- tcg/mips/tcg-target.c | 6 ++++-- tcg/mips/tcg-target.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dyngen-exec.h b/dyngen-exec.h index b9f6969..85a2616 100644 --- a/dyngen-exec.h +++ b/dyngen-exec.h @@ -61,7 +61,7 @@ extern int printf(const char *, ...); #elif defined(__hppa__) #define AREG0 "r17" #elif defined(__mips__) -#define AREG0 "fp" +#define AREG0 "s0" #elif defined(__sparc__) #ifdef CONFIG_SOLARIS #define AREG0 "g2" diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index f4fb615..c9094ee 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -1450,7 +1450,9 @@ static const TCGTargetOpDef mips_op_defs[] = { }; static int tcg_target_callee_save_regs[] = { +#if 0 /* used for the global env (TCG_AREG0), so no need to save */ TCG_REG_S0, +#endif TCG_REG_S1, TCG_REG_S2, TCG_REG_S3, @@ -1459,8 +1461,7 @@ static int tcg_target_callee_save_regs[] = { TCG_REG_S6, TCG_REG_S7, TCG_REG_GP, - /* TCG_REG_FP, */ /* currently used for the global env, so np - need to save */ + TCG_REG_FP, TCG_REG_RA, /* should be last for ABI compliance */ }; @@ -1524,6 +1525,7 @@ void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_AT); /* internal use */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_T0); /* internal use */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_RA); /* return address */ + tcg_regset_set_reg(s->reserved_regs, TCG_REG_FP); /* frame pointer */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); /* stack pointer */ tcg_add_target_add_op_defs(mips_op_defs); diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 0292d33..0028bfa 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -97,7 +97,7 @@ enum { #undef TCG_TARGET_HAS_ext16u_i32 /* andi rt, rs, 0xffff */ /* Note: must be synced with dyngen-exec.h */ -#define TCG_AREG0 TCG_REG_FP +#define TCG_AREG0 TCG_REG_S0 /* guest base is supported */ #define TCG_TARGET_HAS_GUEST_BASE