From patchwork Wed Nov 9 18:40:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 692913 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 3tDZml3NKTz9t1B for ; Thu, 10 Nov 2016 05:42:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="PvqUU6d7"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=igL/uboxLhrTCcqqXmhSKsBtIvE+nGG tsJW+vx4aWuYa9oU0qifrhiqCectesUCLCf4josiOwMcmc9zpAstzXO1B0brQLPT 4qUHwTZ0ki4xGGeiXUn1xYm9AgljiJ16zHUQsS2dcnBBEaQwIQKzrU4n94C9n5t/ UpkIe9BchTQk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:in-reply-to:references :message-id; s=default; bh=6RjnuXFzVLOjf1luljO5B5Bkip8=; b=PvqUU 6d7fhSa5FE9T8dsdqJmrYpT64FXi8sMZqN3XL0JHaqwB9Jmu9y9FUWggY239ztY3 BuvwL3CdazQS6ZERSGbHFz71xbv0kvd0hwfN/ju+T+2IfCoPsgwGR/oFeD2XZASz gYf8brRe0l4s+R2c1dkClhwhpeLPlf5YVQM82M= Received: (qmail 15838 invoked by alias); 9 Nov 2016 18:41:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15747 invoked by uid 89); 9 Nov 2016 18:41:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=murphy, supplement, __typeof, 2411 X-HELO: mx0a-001b2d01.pphosted.com From: "Gabriel F. T. Gomes" To: libc-alpha@sourceware.org Subject: [PATCH 7/8] float128: Add private _Float128 declarations for libm. Date: Wed, 9 Nov 2016 16:40:58 -0200 In-Reply-To: <1478716859-3246-1-git-send-email-gftg@linux.vnet.ibm.com> References: <1478716859-3246-1-git-send-email-gftg@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110918-0020-0000-0000-0000026276A9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110918-0021-0000-0000-000030758838 Message-Id: <1478716859-3246-8-git-send-email-gftg@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-09_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611090343 From: "Paul E. Murphy" Add the necessary bits to the private headers to support building the _Float128 libm functions. A local override for float.h is provided to include the missing *FLT128 macros implied by TS 18661-3 for this type when compiling prior to GCC 7. * bits/libm-simd-decl-stubs.h (__DECL_SIMD_cosf128): New macro. (__DECL_SIMD_sinf128): Likewise. (__DECL_SIMD_sincosf128): Likewise. (__DECL_SIMD_logf128): Likewise. (__DECL_SIMD_expf128): Likewise. (__DECL_SIMD_powf128): Likewise. * include/complex.h (__kernel_casinhf128): New declaration. * include/float.h: New file. * include/math.h (__finitef128): Add a hidden def. (__isinff128): Likewise. (__isnanf128): Likewise. (__fpclassify): Likewise. (__issignalling): Likewise. (__expf128): Likewise. (__expm1f128): Likewise. * sysdeps/generic/fix-fp-int-convert-overflow.h: (FIX_FLT128_LONG_CONVERT_OVERFLOW): New macro. (FIX_FLT128_LLONG_CONVERT_OVERFLOW): Likewise. * sysdeps/generic/math-type-macros-float128.h: New file. * sysdeps/generic/math_private.h (__EXPR_FLT128): New macro. (fabs_tg): Optionally include _Float128 types too. (min_of_type): Likewise. * sysdeps/ieee754/ldbl-opt/s_sin.c: * (__DECL_SIMD_sincos_disablef128): New macro. --- bits/libm-simd-decl-stubs.h | 6 ++ include/complex.h | 7 ++ include/float.h | 31 +++++++ include/math.h | 13 +++ sysdeps/generic/fix-fp-int-convert-overflow.h | 2 + sysdeps/generic/math-type-macros-float128.h | 49 ++++++++++++ sysdeps/generic/math_private.h | 111 +++++++++++++++++++++++++- sysdeps/ieee754/ldbl-opt/s_sin.c | 1 + 8 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 include/float.h create mode 100644 sysdeps/generic/math-type-macros-float128.h diff --git a/bits/libm-simd-decl-stubs.h b/bits/libm-simd-decl-stubs.h index 541cb3f..c72d693 100644 --- a/bits/libm-simd-decl-stubs.h +++ b/bits/libm-simd-decl-stubs.h @@ -36,24 +36,30 @@ #define __DECL_SIMD_cos #define __DECL_SIMD_cosf #define __DECL_SIMD_cosl +#define __DECL_SIMD_cosf128 #define __DECL_SIMD_sin #define __DECL_SIMD_sinf #define __DECL_SIMD_sinl +#define __DECL_SIMD_sinf128 #define __DECL_SIMD_sincos #define __DECL_SIMD_sincosf #define __DECL_SIMD_sincosl +#define __DECL_SIMD_sincosf128 #define __DECL_SIMD_log #define __DECL_SIMD_logf #define __DECL_SIMD_logl +#define __DECL_SIMD_logf128 #define __DECL_SIMD_exp #define __DECL_SIMD_expf #define __DECL_SIMD_expl +#define __DECL_SIMD_expf128 #define __DECL_SIMD_pow #define __DECL_SIMD_powf #define __DECL_SIMD_powl +#define __DECL_SIMD_powf128 #endif diff --git a/include/complex.h b/include/complex.h index 082e71f..8eec3a0 100644 --- a/include/complex.h +++ b/include/complex.h @@ -8,6 +8,13 @@ extern complex float __kernel_casinhf (complex float z, int adj); extern complex double __kernel_casinh (complex double z, int adj); extern complex long double __kernel_casinhl (complex long double z, int adj); +# if __USE_FLOAT128 +# ifdef __CFLOAT128 +extern __CFLOAT128 __kernel_casinhf128 (__CFLOAT128 z, int adj); +# else +extern _Complex _Float128 __kernel_casinhf128 (_Complex _Float128 z, int adj); +# endif +# endif # endif #endif diff --git a/include/float.h b/include/float.h new file mode 100644 index 0000000..f792158 --- /dev/null +++ b/include/float.h @@ -0,0 +1,31 @@ +#ifndef _LIBC_FLOAT_H +#define _LIBC_FLOAT_H + +#ifndef _ISOMAC +# define __STDC_WANT_IEC_60559_TYPES_EXT__ +#endif + +#include_next + +/* Supplement float.h macros for _Float128 for older compilers + which do not yet support the type. These are described in + TS 18661-3. */ +#ifndef _ISOMAC +# include +# include +# if !__GNUC_PREREQ (7,0) && __USE_FLOAT128 +# define FLT128_MANT_DIG 113 +# define FLT128_DECIMAL_DIG 36 +# define FLT128_DIG 33 +# define FLT128_MIN_EXP (-16381) +# define FLT128_MIN_10_EXP (-4931) +# define FLT128_MAX_EXP 16384 +# define FLT128_MAX_10_EXP 4932 +# define FLT128_MAX 1.18973149535723176508575932662800702e+4932Q +# define FLT128_EPSILON 1.92592994438723585305597794258492732e-34Q +# define FLT128_MIN 3.36210314311209350626267781732175260e-4932Q +# define FLT128_TRUE_MIN 6.47517511943802511092443895822764655e-4966Q +# endif +#endif + +#endif /* _LIBC_FLOAT_H */ diff --git a/include/math.h b/include/math.h index ba7bba0..df82ee9 100644 --- a/include/math.h +++ b/include/math.h @@ -21,6 +21,12 @@ hidden_proto (__finitel) hidden_proto (__isinfl) hidden_proto (__isnanl) # endif + +# if __USE_FLOAT128 +hidden_proto (__finitef128) +hidden_proto (__isinff128) +hidden_proto (__isnanf128) +# endif # endif libm_hidden_proto (__fpclassify) @@ -37,5 +43,12 @@ libm_hidden_proto (__expl) libm_hidden_proto (__expm1l) # endif +# if __USE_FLOAT128 +libm_hidden_proto (__fpclassifyf128) +libm_hidden_proto (__issignalingf128) +libm_hidden_proto (__expf128) +libm_hidden_proto (__expm1f128) +# endif + #endif #endif diff --git a/sysdeps/generic/fix-fp-int-convert-overflow.h b/sysdeps/generic/fix-fp-int-convert-overflow.h index fb68114..ff55dbf 100644 --- a/sysdeps/generic/fix-fp-int-convert-overflow.h +++ b/sysdeps/generic/fix-fp-int-convert-overflow.h @@ -29,5 +29,7 @@ #define FIX_DBL_LLONG_CONVERT_OVERFLOW 0 #define FIX_LDBL_LONG_CONVERT_OVERFLOW 0 #define FIX_LDBL_LLONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LLONG_CONVERT_OVERFLOW 0 #endif /* fix-fp-int-convert-overflow.h */ diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h new file mode 100644 index 0000000..20582e4 --- /dev/null +++ b/sysdeps/generic/math-type-macros-float128.h @@ -0,0 +1,49 @@ +/* Helper macros for _Float128 variants of type generic functions of libm. + Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_TYPE_MACROS_FLOAT128 +#define _MATH_TYPE_MACROS_FLOAT128 + +#include +#include + +#define M_LIT(c) __f128 (c) +#define M_PFX FLT128 +#define M_SUF(c) c ## f128 +#define FLOAT _Float128 +#define M_STRTO_NAN __strtof128_nan + +#ifdef __CFLOAT128 +# define CFLOAT __CFLOAT128 +#else +# define CFLOAT _Complex _Float128 +#endif + +#define M_MLIT(c) c ## f128 + + +/* Supply the generic macros. */ +#include + +/* A hack, but an honest one. */ +#if __GNUC_PREREQ(6,2) +# define __builtin_huge_valf128 __builtin_huge_valq +# define __builtin_nanf128 __builtin_nanq +#endif + +#endif diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h index cc9681c..d85737f 100644 --- a/sysdeps/generic/math_private.h +++ b/sysdeps/generic/math_private.h @@ -23,6 +23,9 @@ #include #include +/* Gather machine dependent _Floatn support. */ +#include + /* The original fdlibm code used statements like: n0 = ((*(int*)&one)>>29)^1; * index of high word * ix0 = *(n0+(int*)&x); * high word of x * @@ -181,6 +184,100 @@ do { \ } while (0) #endif +/* Float128 variants. */ +#if __USE_FLOAT128 +extern _Float128 __ieee754_sqrtf128 (_Float128); +extern _Float128 __ieee754_acosf128 (_Float128); +extern _Float128 __ieee754_acoshf128 (_Float128); +extern _Float128 __ieee754_logf128 (_Float128); +extern _Float128 __ieee754_atanhf128 (_Float128); +extern _Float128 __ieee754_asinf128 (_Float128); +extern _Float128 __ieee754_atan2f128 (_Float128,_Float128); +extern _Float128 __ieee754_expf128 (_Float128); +extern _Float128 __ieee754_exp2f128 (_Float128); +extern _Float128 __ieee754_exp10f128 (_Float128); +extern _Float128 __ieee754_coshf128 (_Float128); +extern _Float128 __ieee754_fmodf128 (_Float128,_Float128); +extern _Float128 __ieee754_powf128 (_Float128,_Float128); +extern _Float128 __ieee754_lgammaf128_r (_Float128,int *); +extern _Float128 __ieee754_gammaf128_r (_Float128,int *); +extern _Float128 __ieee754_lgammaf128 (_Float128); +extern _Float128 __ieee754_gammaf128 (_Float128); +extern _Float128 __ieee754_log10f128 (_Float128); +extern _Float128 __ieee754_log2f128 (_Float128); +extern _Float128 __ieee754_sinhf128 (_Float128); +extern _Float128 __ieee754_hypotf128 (_Float128,_Float128); +extern _Float128 __ieee754_j0f128 (_Float128); +extern _Float128 __ieee754_j1f128 (_Float128); +extern _Float128 __ieee754_y0f128 (_Float128); +extern _Float128 __ieee754_y1f128 (_Float128); +extern _Float128 __ieee754_jnf128 (int,_Float128); +extern _Float128 __ieee754_ynf128 (int,_Float128); +extern _Float128 __ieee754_remainderf128 (_Float128,_Float128); +extern int __ieee754_rem_pio2f128 (_Float128,_Float128*); +extern _Float128 __ieee754_scalbf128 (_Float128,_Float128); +extern int __ieee754_ilogbf128 (_Float128); +extern _Float128 __kernel_sinf128 (_Float128,_Float128,int); +extern _Float128 __kernel_cosf128 (_Float128,_Float128); +extern _Float128 __kernel_tanf128 (_Float128,_Float128,int); +extern void __kernel_sincosf128 (_Float128,_Float128, + _Float128 *,_Float128 *, int); +extern int __kernel_rem_pio2f128 (_Float128*,_Float128*,int,int, + int,const int*); +extern int __finitef128 (_Float128); +extern int __ilogbf128 (_Float128); +extern int __isinff128 (_Float128); +extern int __isnanf128 (_Float128); +extern _Float128 __atanf128 (_Float128); +extern _Float128 __copysignf128 (_Float128, _Float128); +extern _Float128 __expm1f128 (_Float128); +extern _Float128 __floorf128 (_Float128); +extern _Float128 __frexpf128 (_Float128, int *); +extern _Float128 __ldexpf128 (_Float128, int); +extern _Float128 __log1pf128 (_Float128); +extern _Float128 __nanf128 (const char *); +extern _Float128 __rintf128 (_Float128); +extern _Float128 __scalbnf128 (_Float128, int); +extern _Float128 __sqrtf128 (_Float128 x); +extern _Float128 fabsf128 (_Float128 x); +extern void __sincosf128 (_Float128, _Float128 *, _Float128 *); +extern _Float128 __logbf128 (_Float128 x); +extern _Float128 __significandf128 (_Float128 x); +extern _Float128 __x2y2m1f128 (_Float128 x, _Float128 y); +extern _Float128 __gamma_productf128 (_Float128 x, _Float128 x_eps, + int n, _Float128 *eps); +extern _Float128 __lgamma_negf128 (_Float128 x, int *signgamp); +extern _Float128 __lgamma_productf128 (_Float128 t, _Float128 x, + _Float128 x_eps, int n); + +/* Fixup some builtins on compilers which support __float128 and not + _Float128. */ +# if __GNUC_PREREQ (7, 0) +# define BUILTIN_FABSF128 __builtin_fabsf128 +# define BUILTIN_COPYSIGNF128 __builtin_copysignf128 +# else +# define BUILTIN_FABSF128 __builtin_fabsq +# define BUILTIN_COPYSIGNF128 __builtin_copysignq + + +/* __builtin_isinf_sign is broken in GCC < 7 for float128. */ +# include +extern inline int __isinff128(_Float128 x) +{ + int64_t hx,lx; + GET_FLOAT128_WORDS64 (hx,lx,x); + lx |= (hx & 0x7fffffffffffffffLL) ^ 0x7fff000000000000LL; + lx |= -lx; + return ~(lx >> 63) & (hx >> 62); +} +# endif + +extern inline _Float128 __copysignf128 (_Float128 x, _Float128 y) +{ return BUILTIN_COPYSIGNF128 (x, y); } +extern inline _Float128 fabsf128 (_Float128 x) +{ return BUILTIN_FABSF128 (x); } +#endif + /* We need to guarantee an expansion of name when building ldbl-128 files as another type (e.g _Float128). */ #define mathx_hidden_def(name) hidden_def(name) @@ -431,18 +528,28 @@ extern long double __lgamma_productl (long double t, long double x, }) #endif +#if __USE_FLOAT128 +# define __EXPR_FLT128(x, yes, no) \ + __builtin_choose_expr (__builtin_types_compatible_p \ + (__typeof (x), long double), no, yes) +#else +# define __EXPR_FLT128(x, yes, no) no +#endif + #define fabs_tg(x) __builtin_choose_expr \ (__builtin_types_compatible_p (__typeof (x), float), \ __builtin_fabsf (x), \ __builtin_choose_expr \ (__builtin_types_compatible_p (__typeof (x), double), \ - __builtin_fabs (x), __builtin_fabsl (x))) + __builtin_fabs (x), \ + __EXPR_FLT128 (x, BUILTIN_FABSF128 (x), __builtin_fabsl (x)))) #define min_of_type(type) __builtin_choose_expr \ (__builtin_types_compatible_p (type, float), \ FLT_MIN, \ __builtin_choose_expr \ (__builtin_types_compatible_p (type, double), \ - DBL_MIN, LDBL_MIN)) + DBL_MIN, \ + __EXPR_FLT128 (x, FLT128_MIN, LDBL_MIN))) /* If X (which is not a NaN) is subnormal, force an underflow exception. */ diff --git a/sysdeps/ieee754/ldbl-opt/s_sin.c b/sysdeps/ieee754/ldbl-opt/s_sin.c index 04e60e2..6932ccc 100644 --- a/sysdeps/ieee754/ldbl-opt/s_sin.c +++ b/sysdeps/ieee754/ldbl-opt/s_sin.c @@ -4,6 +4,7 @@ #define __DECL_SIMD_sincos_disable #define __DECL_SIMD_sincos_disablef #define __DECL_SIMD_sincos_disablel +#define __DECL_SIMD_sincos_disablef128 #include #undef NAN #undef sincos