From patchwork Sun Dec 6 15:21:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 40427 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 B8D63B7BCA for ; Mon, 7 Dec 2009 02:25:29 +1100 (EST) Received: from localhost ([127.0.0.1]:59753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHIzG-0008SS-Nx for incoming@patchwork.ozlabs.org; Sun, 06 Dec 2009 10:25:26 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHIwt-0007ma-MT for qemu-devel@nongnu.org; Sun, 06 Dec 2009 10:22:59 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHIwp-0007ls-MU for qemu-devel@nongnu.org; Sun, 06 Dec 2009 10:22:59 -0500 Received: from [199.232.76.173] (port=57551 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHIwp-0007lm-Fy for qemu-devel@nongnu.org; Sun, 06 Dec 2009 10:22:55 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:42312) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHIwo-0005Mx-Vv for qemu-devel@nongnu.org; Sun, 06 Dec 2009 10:22:55 -0500 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate02.web.de (Postfix) with ESMTP id BFC14146FA969; Sun, 6 Dec 2009 16:21:27 +0100 (CET) Received: from [84.148.107.181] (helo=localhost.localdomain) by smtp06.web.de with asmtp (WEB.DE 4.110 #314) id 1NHIvP-0002Jd-00; Sun, 06 Dec 2009 16:21:27 +0100 From: Andreas Faerber To: qemu-devel@nongnu.org Date: Sun, 6 Dec 2009 16:21:20 +0100 Message-Id: <1260112882-1799-1-git-send-email-andreas.faerber@web.de> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: References: X-Sender: Andreas.Faerber@web.de X-Provags-ID: V01U2FsdGVkX19ZhplIxIszDiZDNc4EBXYNifahYDVnxnI2Giea 3pCh7I/ZYvW3zQUU2SdquFGSdXg9BJbUBE/xx30ehx1I+oiV1Q 4THRP+hNkiqbIZEKHFwg== X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Andreas Faerber Subject: [Qemu-devel] [PATCH v3 1/3] TCG: Mac OS X support for ppc64 target 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 Darwin/ppc64 does not use function descriptors, adapt prologue and tcg_out_call accordingly. GPR2 is available for general use, so let's use it. http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/LowLevelABI/110-64-bit_PowerPC_Function_Calling_Conventions/64bitPowerPC.html v2: - Don't mark reserved GPR13 as callee-save. - Move tcg_out_b up. - Fix unused variable warning in prologue. Signed-off-by: Andreas Faerber Cc: malc --- tcg/ppc64/tcg-target.c | 55 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 41 insertions(+), 14 deletions(-) diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index a612e10..0c11917 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -104,6 +104,9 @@ static const int tcg_target_reg_alloc_order[] = { TCG_REG_R29, TCG_REG_R30, TCG_REG_R31, +#ifdef __APPLE__ + TCG_REG_R2, +#endif TCG_REG_R3, TCG_REG_R4, TCG_REG_R5, @@ -112,7 +115,9 @@ static const int tcg_target_reg_alloc_order[] = { TCG_REG_R8, TCG_REG_R9, TCG_REG_R10, +#ifndef __APPLE__ TCG_REG_R11, +#endif TCG_REG_R12, TCG_REG_R24, TCG_REG_R25, @@ -136,6 +141,9 @@ static const int tcg_target_call_oarg_regs[2] = { }; static const int tcg_target_callee_save_regs[] = { +#ifdef __APPLE__ + TCG_REG_R11, +#endif TCG_REG_R14, TCG_REG_R15, TCG_REG_R16, @@ -477,8 +485,31 @@ static void tcg_out_movi (TCGContext *s, TCGType type, } } +static void tcg_out_b (TCGContext *s, int mask, tcg_target_long target) +{ + tcg_target_long disp; + + disp = target - (tcg_target_long) s->code_ptr; + if ((disp << 38) >> 38 == disp) + tcg_out32 (s, B | (disp & 0x3fffffc) | mask); + else { + tcg_out_movi (s, TCG_TYPE_I64, 0, (tcg_target_long) target); + tcg_out32 (s, MTSPR | RS (0) | CTR); + tcg_out32 (s, BCCTR | BO_ALWAYS | mask); + } +} + static void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg) { +#ifdef __APPLE__ + if (const_arg) { + tcg_out_b (s, LK, arg); + } + else { + tcg_out32 (s, MTSPR | RS (arg) | LR); + tcg_out32 (s, BCLR | BO_ALWAYS | LK); + } +#else int reg; if (const_arg) { @@ -492,6 +523,7 @@ static void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg) tcg_out32 (s, LD | RT (11) | RA (reg) | 16); tcg_out32 (s, LD | RT (2) | RA (reg) | 8); tcg_out32 (s, BCCTR | BO_ALWAYS | LK); +#endif } static void tcg_out_ldst (TCGContext *s, int ret, int addr, @@ -516,20 +548,6 @@ static void tcg_out_ldsta (TCGContext *s, int ret, int addr, } } -static void tcg_out_b (TCGContext *s, int mask, tcg_target_long target) -{ - tcg_target_long disp; - - disp = target - (tcg_target_long) s->code_ptr; - if ((disp << 38) >> 38 == disp) - tcg_out32 (s, B | (disp & 0x3fffffc) | mask); - else { - tcg_out_movi (s, TCG_TYPE_I64, 0, (tcg_target_long) target); - tcg_out32 (s, MTSPR | RS (0) | CTR); - tcg_out32 (s, BCCTR | BO_ALWAYS | mask); - } -} - #if defined (CONFIG_SOFTMMU) #include "../../softmmu_defs.h" @@ -845,7 +863,9 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc) void tcg_target_qemu_prologue (TCGContext *s) { int i, frame_size; +#ifndef __APPLE__ uint64_t addr; +#endif frame_size = 0 + 8 /* back chain */ @@ -859,10 +879,12 @@ void tcg_target_qemu_prologue (TCGContext *s) ; frame_size = (frame_size + 15) & ~15; +#ifndef __APPLE__ /* First emit adhoc function descriptor */ addr = (uint64_t) s->code_ptr + 24; tcg_out32 (s, addr >> 32); tcg_out32 (s, addr); /* entry point */ s->code_ptr += 16; /* skip TOC and environment pointer */ +#endif /* Prologue */ tcg_out32 (s, MFSPR | RT (0) | LR); @@ -1516,6 +1538,9 @@ void tcg_target_init (TCGContext *s) tcg_regset_set32 (tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffffffff); tcg_regset_set32 (tcg_target_call_clobber_regs, 0, (1 << TCG_REG_R0) | +#ifdef __APPLE__ + (1 << TCG_REG_R2) | +#endif (1 << TCG_REG_R3) | (1 << TCG_REG_R4) | (1 << TCG_REG_R5) | @@ -1531,7 +1556,9 @@ void tcg_target_init (TCGContext *s) tcg_regset_clear (s->reserved_regs); tcg_regset_set_reg (s->reserved_regs, TCG_REG_R0); tcg_regset_set_reg (s->reserved_regs, TCG_REG_R1); +#ifndef __APPLE__ tcg_regset_set_reg (s->reserved_regs, TCG_REG_R2); +#endif tcg_regset_set_reg (s->reserved_regs, TCG_REG_R13); #ifdef CONFIG_USE_GUEST_BASE