From patchwork Tue Nov 30 06:36:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Lin Tang X-Patchwork-Id: 73560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BC5C31007E0 for ; Tue, 30 Nov 2010 17:37:06 +1100 (EST) Received: (qmail 16767 invoked by alias); 30 Nov 2010 06:37:04 -0000 Received: (qmail 16633 invoked by uid 22791); 30 Nov 2010 06:37:03 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_DM, TW_VF, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Nov 2010 06:36:57 +0000 Received: (qmail 14995 invoked from network); 30 Nov 2010 06:36:54 -0000 Received: from unknown (HELO ?192.168.1.16?) (cltang@127.0.0.2) by mail.codesourcery.com with ESMTPA; 30 Nov 2010 06:36:54 -0000 Message-ID: <4CF49B84.2070305@codesourcery.com> Date: Tue, 30 Nov 2010 14:36:52 +0800 From: Chung-Lin Tang User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 To: Mikael Pettersson CC: Anthony Green , gcc-patches@gcc.gnu.org Subject: Re: [Patch, libffi, ARM] VFP hard-float calling convention support References: <19687.49614.673307.930816@pilspetsen.it.uu.se> In-Reply-To: <19687.49614.673307.930816@pilspetsen.it.uu.se> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 2010/11/20 20:40, Mikael Pettersson wrote: > On Thu, 28 Oct 2010 14:11:12 -0400, Anthony Green wrote: > > > > I'm committing this patch from Chung-Lin Tang, who provided the > > following description: > > > > "this patch implements VFP hard-float calling conventions, as a new ABI > > for ARM. Asides from VFP calling convention bits, some additional > > optimizations have been added to the current softfp assembly code > > paths too. > ... > > 2010-10-28 Chung-Lin Tang > ... > > This commit, r166032, caused a build error on ARM: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46508 > > In short, you can't unconditionally use VFP instructions because the > target CPU may not support them and the assembler will (rightfully) > error out if you try. > > /Mikael I think I missed this earlier because my toolchain happened to be configured with --with-fpu=vfp. Here's a patch that moves the VFP related functions together, and adds a '.fpu vfp' directive in front of them. The VFP hard-float support is always compiled in for more runtime flexibility, however VFP insns will only be executed if you use that hard-float functionality (which will be assumed you know you have a VFP unit) Also added two missing conditional UNWINDs in the closure routines. Anthony, is this patch okay? Thanks, Chung-Lin diff --git a/ChangeLog b/ChangeLog index b4a0a93..00aebba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-11-30 Chung-Lin Tang + + * src/arm/sysv.S (ffi_closure_SYSV): Add UNWIND to .pad directive. + (ffi_closure_VFP): Same. + (ffi_call_VFP): Move down to before ffi_closure_VFP. Add '.fpu vfp' + directive. + 2010-11-22 Jacek Caban * configure.ac: Check for symbol underscores on mingw-w64. diff --git a/src/arm/sysv.S b/src/arm/sysv.S index 7bce727..72f0ee0 100644 --- a/src/arm/sysv.S +++ b/src/arm/sysv.S @@ -229,6 +229,83 @@ LSYM(Lepilogue): .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) +/* + unsigned int FFI_HIDDEN + ffi_closure_SYSV_inner (closure, respp, args) + ffi_closure *closure; + void **respp; + void *args; +*/ + +ARM_FUNC_START ffi_closure_SYSV + UNWIND .pad #16 + add ip, sp, #16 + stmfd sp!, {ip, lr} + UNWIND .save {r0, lr} + add r2, sp, #8 + UNWIND .pad #16 + sub sp, sp, #16 + str sp, [sp, #8] + add r1, sp, #8 + bl ffi_closure_SYSV_inner + cmp r0, #FFI_TYPE_INT + beq .Lretint + + cmp r0, #FFI_TYPE_FLOAT +#if defined(__SOFTFP__) || defined(__ARM_EABI__) + beq .Lretint +#else + beq .Lretfloat +#endif + + cmp r0, #FFI_TYPE_DOUBLE +#if defined(__SOFTFP__) || defined(__ARM_EABI__) + beq .Lretlonglong +#else + beq .Lretdouble +#endif + + cmp r0, #FFI_TYPE_LONGDOUBLE +#if defined(__SOFTFP__) || defined(__ARM_EABI__) + beq .Lretlonglong +#else + beq .Lretlongdouble +#endif + + cmp r0, #FFI_TYPE_SINT64 + beq .Lretlonglong +.Lclosure_epilogue: + add sp, sp, #16 + ldmfd sp, {sp, pc} +.Lretint: + ldr r0, [sp] + b .Lclosure_epilogue +.Lretlonglong: + ldr r0, [sp] + ldr r1, [sp, #4] + b .Lclosure_epilogue + +#if !defined(__SOFTFP__) && !defined(__ARM_EABI__) +.Lretfloat: + ldfs f0, [sp] + b .Lclosure_epilogue +.Lretdouble: + ldfd f0, [sp] + b .Lclosure_epilogue +.Lretlongdouble: + ldfd f0, [sp] + b .Lclosure_epilogue +#endif + +.ffi_closure_SYSV_end: + UNWIND .fnend + .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) + + +/* Below are VFP hard-float ABI call and closure implementations. + Add VFP FPU directive here. */ + .fpu vfp + @ r0: fn @ r1: &ecif @ r2: cif->bytes @@ -321,79 +398,6 @@ LSYM(Lepilogue_vfp): .ffi_call_VFP_end: UNWIND .fnend .size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP) - - -/* - unsigned int FFI_HIDDEN - ffi_closure_SYSV_inner (closure, respp, args) - ffi_closure *closure; - void **respp; - void *args; -*/ - -ARM_FUNC_START ffi_closure_SYSV - UNWIND .pad #16 - add ip, sp, #16 - stmfd sp!, {ip, lr} - UNWIND .save {r0, lr} - add r2, sp, #8 - .pad #16 - sub sp, sp, #16 - str sp, [sp, #8] - add r1, sp, #8 - bl ffi_closure_SYSV_inner - cmp r0, #FFI_TYPE_INT - beq .Lretint - - cmp r0, #FFI_TYPE_FLOAT -#if defined(__SOFTFP__) || defined(__ARM_EABI__) - beq .Lretint -#else - beq .Lretfloat -#endif - - cmp r0, #FFI_TYPE_DOUBLE -#if defined(__SOFTFP__) || defined(__ARM_EABI__) - beq .Lretlonglong -#else - beq .Lretdouble -#endif - - cmp r0, #FFI_TYPE_LONGDOUBLE -#if defined(__SOFTFP__) || defined(__ARM_EABI__) - beq .Lretlonglong -#else - beq .Lretlongdouble -#endif - - cmp r0, #FFI_TYPE_SINT64 - beq .Lretlonglong -.Lclosure_epilogue: - add sp, sp, #16 - ldmfd sp, {sp, pc} -.Lretint: - ldr r0, [sp] - b .Lclosure_epilogue -.Lretlonglong: - ldr r0, [sp] - ldr r1, [sp, #4] - b .Lclosure_epilogue - -#if !defined(__SOFTFP__) && !defined(__ARM_EABI__) -.Lretfloat: - ldfs f0, [sp] - b .Lclosure_epilogue -.Lretdouble: - ldfd f0, [sp] - b .Lclosure_epilogue -.Lretlongdouble: - ldfd f0, [sp] - b .Lclosure_epilogue -#endif - -.ffi_closure_SYSV_end: - UNWIND .fnend - .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) ARM_FUNC_START ffi_closure_VFP @@ -405,7 +409,7 @@ ARM_FUNC_START ffi_closure_VFP UNWIND .save {r0, lr} add r2, sp, #72 add r3, sp, #8 - .pad #72 + UNWIND .pad #72 sub sp, sp, #72 str sp, [sp, #64] add r1, sp, #64