From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21852 invoked by alias); 25 Aug 2008 18:11:02 -0000 Received: (qmail 21831 invoked by uid 22791); 25 Aug 2008 18:11:00 -0000 X-Spam-Check-By: sourceware.org Received: from mail.fgznet.ch (HELO smtp.fgznet.ch) (81.92.96.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 25 Aug 2008 18:10:06 +0000 Received: from wolfram.andreas.nets ([91.190.8.131]) by smtp.fgznet.ch (8.13.8/8.13.8/Submit_SMTPAUTH) with ESMTP id m7PIA1wt019811; Mon, 25 Aug 2008 20:10:02 +0200 (CEST) (envelope-from andreast-list@fgznet.ch) Message-ID: <48B2F579.3040702@fgznet.ch> Date: Mon, 25 Aug 2008 19:45:00 -0000 From: Andreas Tobler User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707) MIME-Version: 1.0 To: David Edelsohn CC: GCC Patches , Java Patches Subject: Re: [patch] libffi, fix powerpc-unknown-freebsd References: <303e1d290808200807p62fd1a4btc253c532e749da30@mail.gmail.com> <48ADE3EE.3080807@fgznet.ch> <303e1d290808211732l4fe287dfmb4c73ae3233dbd5c@mail.gmail.com> <48B1BFB1.6010407@fgznet.ch> <303e1d290808241503k22ecababm5ed70bb37b1f69c5@mail.gmail.com> In-Reply-To: <303e1d290808241503k22ecababm5ed70bb37b1f69c5@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------070100010706070403020703" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg01890.txt.bz2 This is a multi-part message in MIME format. --------------070100010706070403020703 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1497 David Edelsohn wrote: > On Sun, Aug 24, 2008 at 4:08 PM, Andreas Tobler wrote: > >> I have an understanding issue here, what bits are you referring to? The >> FLAG_SYSV_SMST_R4 and FLAG_SYSV_SMST_R3 from ffi.c? >> Or the situation that I use FFI_SYSV_TYPE_SMALL_STRUCT and the two flags? >> If the former, then my impression is that they don't need to be mentioned in >> ffitarget.h, otherwise we'd have to describe every flag used in ffi.c in >> ffitarget.h as well. >> If the latter, I can put a note into ffitarget.h mentioning that we need >> additional separation in ffi.c to clearly distinguish what we return. > > FLAG_SYSV_TYPE_SMALL_STRUCT uses two bits in flags, if I understand > the code correctly. I think it would be helpful to note that in > ffitarget.h I will commit the attached to trunk in a few minutes. For 4.3 I'll wait until 4.3.3 opens, ok? Thank you for review. Regards, Andreas 2008-08-25 Andreas Tobler * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum. Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT. Adjust copyright notice. * src/powerpc/ffi.c: Add two new flags to indicate if we have one register or two register to use for FFI_SYSV structs. (ffi_prep_cif_machdep): Pass the right register flag introduced above. (ffi_closure_helper_SYSV): Fix the return type for FFI_SYSV_TYPE_SMALL_STRUCT. Comment. Adjust copyright notice. --------------070100010706070403020703 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="fbsd_ffi4.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fbsd_ffi4.diff" Content-length: 3548 Index: src/powerpc/ffi.c =================================================================== --- src/powerpc/ffi.c (revision 139412) +++ src/powerpc/ffi.c (working copy) @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- ffi.c - Copyright (c) 1998 Geoffrey Keating - Copyright (C) 2007 Free Software Foundation, Inc + Copyright (C) 2007, 2008 Free Software Foundation, Inc PowerPC Foreign Function Interface @@ -43,6 +43,10 @@ FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */ + FLAG_SYSV_SMST_R4 = 1 << (31-16), /* cr4, use r4 for FFI_SYSV 8 byte + structs. */ + FLAG_SYSV_SMST_R3 = 1 << (31-15), /* cr3, use r3 for FFI_SYSV 4 byte + structs. */ FLAG_ARG_NEEDS_COPY = 1 << (31- 7), FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), @@ -679,14 +683,14 @@ The same applies for the structs returned in r3/r4. */ if (size <= 4) { - flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 1); + flags |= FLAG_SYSV_SMST_R3; flags |= 8 * (4 - size) << 4; break; } /* These structs are returned in r3 and r4. See above. */ if (size <= 8) { - flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 2); + flags |= FLAG_SYSV_SMST_R4; flags |= 8 * (8 - size) << 4; break; } @@ -1248,10 +1252,15 @@ /* Tell ffi_closure_SYSV how to perform return type promotions. Because the FFI_SYSV ABI returns the structures <= 8 bytes in r3/r4 - we have to tell ffi_closure_SYSV how to treat them. */ + we have to tell ffi_closure_SYSV how to treat them. We combine the base + type FFI_SYSV_TYPE_SMALL_STRUCT - 1 with the size of the struct. + So a one byte struct gets the return type 16. Return type 1 to 15 are + already used and we never have a struct with size zero. That is the reason + for the subtraction of 1. See the comment in ffitarget.h about ordering. + */ if (cif->abi == FFI_SYSV && cif->rtype->type == FFI_TYPE_STRUCT && size <= 8) - return FFI_SYSV_TYPE_SMALL_STRUCT + size; + return (FFI_SYSV_TYPE_SMALL_STRUCT - 1) + size; #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE else if (cif->rtype->type == FFI_TYPE_LONGDOUBLE && cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT) Index: src/powerpc/ffitarget.h =================================================================== --- src/powerpc/ffitarget.h (revision 139412) +++ src/powerpc/ffitarget.h (working copy) @@ -1,6 +1,6 @@ /* -----------------------------------------------------------------*-C-*- ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. - Copyright (C) 2007 Free Software Foundation, Inc + Copyright (C) 2007, 2008 Free Software Foundation, Inc Target configuration macros for PowerPC. Permission is hereby granted, free of charge, to any person obtaining @@ -77,6 +77,8 @@ FFI_SYSV, FFI_GCC_SYSV, FFI_LINUX64, + FFI_LINUX, + FFI_LINUX_SOFT_FLOAT, FFI_DEFAULT_ABI = FFI_SYSV, #endif @@ -95,7 +97,9 @@ /* Needed for soft-float long-double-128 support. */ #define FFI_TYPE_UINT128 (FFI_TYPE_LAST + 1) -/* Needed for FFI_SYSV small structure returns. */ +/* Needed for FFI_SYSV small structure returns. + We use two flag bits, (FLAG_SYSV_SMST_R3, FLAG_SYSV_SMST_R4) which are + defined in ffi.c, to determine the exact return type and its size. */ #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2) #if defined(POWERPC64) || defined(POWERPC_AIX) --------------070100010706070403020703--