From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32678 invoked by alias); 28 Oct 2014 18:54:12 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 32621 invoked by uid 89); 28 Oct 2014 18:54:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f172.google.com Received: from mail-qc0-f172.google.com (HELO mail-qc0-f172.google.com) (209.85.216.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 28 Oct 2014 18:54:10 +0000 Received: by mail-qc0-f172.google.com with SMTP id i17so1105940qcy.31 for ; Tue, 28 Oct 2014 11:54:08 -0700 (PDT) X-Received: by 10.140.108.182 with SMTP id j51mr7588202qgf.27.1414522448371; Tue, 28 Oct 2014 11:54:08 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id 69sm1717430qgy.19.2014.10.28.11.54.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Oct 2014 11:54:07 -0700 (PDT) From: Richard Henderson To: libffi-discuss@sourceware.org Cc: Richard Henderson Subject: [PATCH 14/16] aarch64: Add support for complex types Date: Tue, 28 Oct 2014 18:54:00 -0000 Message-Id: <1414522393-19169-15-git-send-email-rth@twiddle.net> In-Reply-To: <1414522393-19169-1-git-send-email-rth@twiddle.net> References: <1414522393-19169-1-git-send-email-rth@twiddle.net> X-SW-Source: 2014/txt/msg00148.txt.bz2 From: Richard Henderson --- src/aarch64/ffi.c | 34 +++++++++++++++++++++++++--------- src/aarch64/ffitarget.h | 2 ++ testsuite/libffi.call/call.exp | 10 +++------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index b3e0b16..4f85140 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -85,7 +85,7 @@ is_hfa0 (const ffi_type *ty) for (i = 0; elements[i]; ++i) { ret = elements[i]->type; - if (ret == FFI_TYPE_STRUCT) + if (ret == FFI_TYPE_STRUCT || ret == FFI_TYPE_COMPLEX) { ret = is_hfa0 (elements[i]); if (ret < 0) @@ -110,7 +110,7 @@ is_hfa1 (const ffi_type *ty, int candidate) for (i = 0; elements[i]; ++i) { int t = elements[i]->type; - if (t == FFI_TYPE_STRUCT) + if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) { if (!is_hfa1 (elements[i], candidate)) return 0; @@ -138,16 +138,27 @@ is_vfp_type (const ffi_type *ty) size_t size, ele_count; /* Quickest tests first. */ - switch (ty->type) + candidate = ty->type; + switch (candidate) { default: return 0; case FFI_TYPE_FLOAT: - return AARCH64_RET_S1; case FFI_TYPE_DOUBLE: - return AARCH64_RET_D1; case FFI_TYPE_LONGDOUBLE: - return AARCH64_RET_Q1; + ele_count = 1; + goto done; + case FFI_TYPE_COMPLEX: + candidate = ty->elements[0]->type; + switch (candidate) + { + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + ele_count = 2; + goto done; + } + return 0; case FFI_TYPE_STRUCT: break; } @@ -160,7 +171,7 @@ is_vfp_type (const ffi_type *ty) /* Find the type of the first non-structure member. */ elements = ty->elements; candidate = elements[0]->type; - if (candidate == FFI_TYPE_STRUCT) + if (candidate == FFI_TYPE_STRUCT || candidate == FFI_TYPE_COMPLEX) { for (i = 0; ; ++i) { @@ -198,16 +209,18 @@ is_vfp_type (const ffi_type *ty) /* Finally, make sure that all scalar elements are the same type. */ for (i = 0; elements[i]; ++i) { - if (elements[i]->type == FFI_TYPE_STRUCT) + int t = elements[i]->type; + if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX) { if (!is_hfa1 (elements[i], candidate)) return 0; } - else if (elements[i]->type != candidate) + else if (t != candidate) return 0; } /* All tests succeeded. Encode the result. */ + done: return candidate * 4 + (4 - ele_count); } @@ -474,6 +487,7 @@ ffi_prep_cif_machdep (ffi_cif *cif) case FFI_TYPE_DOUBLE: case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: flags = is_vfp_type (rtype); if (flags == 0) { @@ -618,6 +632,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, void **avalue) case FFI_TYPE_DOUBLE: case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: { void *dest; @@ -788,6 +803,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif, case FFI_TYPE_DOUBLE: case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: h = is_vfp_type (ty); if (h) { diff --git a/src/aarch64/ffitarget.h b/src/aarch64/ffitarget.h index 6d6d3e6..7461386 100644 --- a/src/aarch64/ffitarget.h +++ b/src/aarch64/ffitarget.h @@ -52,4 +52,6 @@ typedef enum ffi_abi #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs #endif +#define FFI_TARGET_HAS_COMPLEX_TYPE + #endif diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index 5177f07..ceacd49 100644 --- a/testsuite/libffi.call/call.exp +++ b/testsuite/libffi.call/call.exp @@ -24,16 +24,12 @@ set ctlist [lsearch -inline -all -glob [lsort [glob -nocomplain -- $srcdir/$subd run-many-tests $tlist "" -if { ![istarget s390*] } { - +if { [istarget s390*] || [istarget aarch64*] } { + run-many-tests $ctlist "" +} else { foreach test $ctlist { unsupported "$test" } - -} else { - - run-many-tests $ctlist "" - } dg-finish -- 1.9.3