From patchwork Mon Feb 9 08:40:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 437809 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9F2AC14009B for ; Mon, 9 Feb 2015 19:44:02 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=vIzGJHXbRiVtEYEIoWkSIqUXvX9QJyKkdcm6PpdwqENr4+ 46okUIL1ZpUtC+dZyF4Z4HYScbezXXD1XhoBOz6DGZxRpo48UBEfpAtBolKtNj9o DqV+wRBkSlVPlLtRdBaYLj0v6bPQ4yCCGtOAfCAp3+OJrGlsEUDEfGR6wsJW4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=2/pYFVXZf4tXACiGmbB7tySnXws=; b=dNuAWAB2LFL8la4b4hkG PHxjCU/a+8r6gKsezfj8DO39XOVhuPZGAAN+ccHu3LqcYLj8oW8qTpX1EMXY62R8 bJo4eTuhMUVzr2a2nCm8OH2SZHqFiYXOPfWfO48PF+SKADyaUnSc+qlUQYDxgLr9 kdR400PFLApIcgoGl5Zk/FQ= Received: (qmail 15549 invoked by alias); 9 Feb 2015 08:40:36 -0000 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 Received: (qmail 15526 invoked by uid 89); 9 Feb 2015 08:40:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f46.google.com Received: from mail-la0-f46.google.com (HELO mail-la0-f46.google.com) (209.85.215.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 09 Feb 2015 08:40:34 +0000 Received: by labgf13 with SMTP id gf13so11863914lab.3 for ; Mon, 09 Feb 2015 00:40:31 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.152.28.227 with SMTP id e3mr14936132lah.117.1423471231106; Mon, 09 Feb 2015 00:40:31 -0800 (PST) Received: by 10.25.21.213 with HTTP; Mon, 9 Feb 2015 00:40:30 -0800 (PST) Date: Mon, 9 Feb 2015 00:40:30 -0800 Message-ID: Subject: [PATCH] Implement libffi for AARCH64:ILP32 From: Andrew Pinski To: GCC Patches , "libffi-discuss@sourceware.org" X-IsSubscribed: yes Hi, The following GCC patch (I don't have the libffi code git checked out) implements libffi for AARCH64:ILP32. The majority of the AARCH64 code works correctly for ILP32. For ILP32, we need to use long long types for ffi_arg and ffi_sarg. And then we need to fix up the closure code to load cif, fn, and user_data by 32bit instead of 64bits as they are stored as pointers in C code. With this patch, I got no failures in the libffi testsuite that is included with GCC. OK? Built and tested on aarch64 with no regressions. Thanks, Andrew Pinski ChangeLog: * src/aarch64/ffitarget.h (ffi_arg): Use unsigned long long for ILP32. (ffi_sarg): Use signed long long for ILP32. * src/aarch64/sysv.S (PTR_REG): New macro. (PTR_SIZE): New macro. (ffi_closure_SYSV): Load cif, fn and user_data using PTR_REG. (ffi_go_closure_SYSV): Load cif and fn using PTR_REG. diff --git a/libffi/src/aarch64/ffitarget.h b/libffi/src/aarch64/ffitarget.h index fca2811..c134fe3 100644 --- a/libffi/src/aarch64/ffitarget.h +++ b/libffi/src/aarch64/ffitarget.h @@ -27,8 +27,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #endif #ifndef LIBFFI_ASM +#ifdef __ILP32__ +typedef unsigned long long ffi_arg; +typedef signed long long ffi_sarg; +#else typedef unsigned long ffi_arg; typedef signed long ffi_sarg; +#endif typedef enum ffi_abi { diff --git a/libffi/src/aarch64/sysv.S b/libffi/src/aarch64/sysv.S index 46f50b9..c1bf9b9 100644 --- a/libffi/src/aarch64/sysv.S +++ b/libffi/src/aarch64/sysv.S @@ -45,6 +45,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ # define BE(X) 0 #endif +#ifdef __ILP32__ +#define PTR_REG(n) w##n +#else +#define PTR_REG(n) x##n +#endif + +#ifdef __ILP32__ +#define PTR_SIZE 4 +#else +#define PTR_SIZE 8 +#endif + .text .align 4 @@ -248,8 +260,8 @@ CNAME(ffi_closure_SYSV): stp x6, x7, [sp, #16 + 16*N_V_ARG_REG + 48] /* Load ffi_closure_inner arguments. */ - ldp x0, x1, [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET] /* load cif, fn */ - ldr x2, [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET+16] /* load user_data */ + ldp PTR_REG(0), PTR_REG(1), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET] /* load cif, fn */ + ldr PTR_REG(2), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET+PTR_SIZE*2] /* load user_data */ .Ldo_closure: add x3, sp, #16 /* load context */ add x4, sp, #ffi_closure_SYSV_FS /* load stack */ @@ -403,7 +415,7 @@ CNAME(ffi_go_closure_SYSV): stp x6, x7, [sp, #16 + 16*N_V_ARG_REG + 48] /* Load ffi_closure_inner arguments. */ - ldp x0, x1, [x18, #8] /* load cif, fn */ + ldp PTR_REG(0), PTR_REG(1), [x18, #PTR_SIZE]/* load cif, fn */ mov x2, x18 /* load user_data */ b .Ldo_closure cfi_endproc