From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19417 invoked by alias); 29 Oct 2014 20:06: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 19361 invoked by uid 89); 29 Oct 2014 20:06: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-f182.google.com Received: from mail-qc0-f182.google.com (HELO mail-qc0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 29 Oct 2014 20:06:10 +0000 Received: by mail-qc0-f182.google.com with SMTP id m20so3105411qcx.27 for ; Wed, 29 Oct 2014 13:06:08 -0700 (PDT) X-Received: by 10.224.114.135 with SMTP id e7mr9572073qaq.68.1414613167783; Wed, 29 Oct 2014 13:06:07 -0700 (PDT) Received: from pike.twiddle.home.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id a12sm5020495qai.1.2014.10.29.13.06.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2014 13:06:07 -0700 (PDT) From: Richard Henderson To: libffi-discuss@sourceware.org Subject: [PATCH 08/10] arm: Add support for complex types Date: Wed, 29 Oct 2014 20:06:00 -0000 Message-Id: <1414613147-10917-9-git-send-email-rth@twiddle.net> In-Reply-To: <1414613147-10917-1-git-send-email-rth@twiddle.net> References: <1414613147-10917-1-git-send-email-rth@twiddle.net> X-SW-Source: 2014/txt/msg00164.txt.bz2 --- src/arm/ffi.c | 28 +++++++++++++++++++++------- src/arm/ffitarget.h | 1 + testsuite/libffi.call/call.exp | 10 +++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/arm/ffi.c b/src/arm/ffi.c index 395af97..9a11e8f 100644 --- a/src/arm/ffi.c +++ b/src/arm/ffi.c @@ -87,9 +87,12 @@ ffi_put_arg (ffi_type *ty, void *src, void *dst) break; case FFI_TYPE_STRUCT: - default: + case FFI_TYPE_COMPLEX: memcpy (dst, src, z); break; + + default: + abort(); } return ALIGN (z, 4); @@ -249,6 +252,7 @@ ffi_prep_cif_machdep (ffi_cif *cif) break; case FFI_TYPE_STRUCT: + case FFI_TYPE_COMPLEX: if (cabi == FFI_VFP) { int h = vfp_type_p (cif->rtype); @@ -790,7 +794,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) @@ -815,7 +819,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; @@ -842,13 +846,21 @@ vfp_type_p (const ffi_type *ty) size_t size, ele_count; /* Quickest tests first. */ + candidate = ty->type; switch (ty->type) { default: return 0; case FFI_TYPE_FLOAT: case FFI_TYPE_DOUBLE: - return 0x100 + ty->type; + ele_count = 1; + goto done; + case FFI_TYPE_COMPLEX: + candidate = ty->elements[0]->type; + if (candidate != FFI_TYPE_FLOAT && candidate != FFI_TYPE_DOUBLE) + return 0; + ele_count = 2; + goto done; case FFI_TYPE_STRUCT: break; } @@ -861,7 +873,7 @@ vfp_type_p (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) { @@ -894,16 +906,18 @@ vfp_type_p (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 (ele_count << 8) | candidate; } diff --git a/src/arm/ffitarget.h b/src/arm/ffitarget.h index bf36750..744a1e1 100644 --- a/src/arm/ffitarget.h +++ b/src/arm/ffitarget.h @@ -57,6 +57,7 @@ typedef enum ffi_abi { signed char vfp_args[16] \ #define FFI_TARGET_SPECIFIC_VARIADIC +#define FFI_TARGET_HAS_COMPLEX_TYPE /* ---- Definitions for closures ----------------------------------------- */ diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index 5177f07..5864fc0 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 arm*] } { + run-many-tests $ctlist "" +} else { foreach test $ctlist { unsupported "$test" } - -} else { - - run-many-tests $ctlist "" - } dg-finish -- 1.9.3