From c50eee19c447d3f2c182dc3a22f2b01a053dca41 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Tue, 28 Jun 2016 08:49:23 -0500 Subject: Convert _Complex sine functions to generated code Refactor s_c{,a}sin{,h}{f,,l} into a single templated macro. --- sysdeps/alpha/fpu/s_casinf.c | 12 ++++-- sysdeps/alpha/fpu/s_casinhf.c | 12 ++++-- sysdeps/alpha/fpu/s_csinf.c | 12 ++++-- sysdeps/alpha/fpu/s_csinhf.c | 12 ++++-- sysdeps/ieee754/ldbl-opt/s_casin.c | 6 --- sysdeps/ieee754/ldbl-opt/s_casinh.c | 6 --- sysdeps/ieee754/ldbl-opt/s_casinhl.c | 6 --- sysdeps/ieee754/ldbl-opt/s_casinl.c | 6 --- sysdeps/ieee754/ldbl-opt/s_csin.c | 6 --- sysdeps/ieee754/ldbl-opt/s_csinh.c | 6 --- sysdeps/ieee754/ldbl-opt/s_csinhl.c | 6 --- sysdeps/ieee754/ldbl-opt/s_csinl.c | 6 --- sysdeps/m68k/m680x0/fpu/s_csin.c | 67 ----------------------------- sysdeps/m68k/m680x0/fpu/s_csin_template.c | 59 +++++++++++++++++++++++++ sysdeps/m68k/m680x0/fpu/s_csinf.c | 3 -- sysdeps/m68k/m680x0/fpu/s_csinh.c | 69 ------------------------------ sysdeps/m68k/m680x0/fpu/s_csinh_template.c | 62 +++++++++++++++++++++++++++ sysdeps/m68k/m680x0/fpu/s_csinhf.c | 3 -- sysdeps/m68k/m680x0/fpu/s_csinhl.c | 3 -- sysdeps/m68k/m680x0/fpu/s_csinl.c | 3 -- 20 files changed, 153 insertions(+), 212 deletions(-) delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casin.c delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casinh.c delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casinhl.c delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casinl.c delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csin.c delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csinh.c delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csinhl.c delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csinl.c delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csin.c create mode 100644 sysdeps/m68k/m680x0/fpu/s_csin_template.c delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinf.c delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinh.c create mode 100644 sysdeps/m68k/m680x0/fpu/s_csinh_template.c delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinhf.c delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinhl.c delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinl.c (limited to 'sysdeps') diff --git a/sysdeps/alpha/fpu/s_casinf.c b/sysdeps/alpha/fpu/s_casinf.c index f85f524c48..08d0a6d167 100644 --- a/sysdeps/alpha/fpu/s_casinf.c +++ b/sysdeps/alpha/fpu/s_casinf.c @@ -24,14 +24,18 @@ #undef __casinf #undef casinf -#define __casinf internal_casinf static _Complex float internal_casinf (_Complex float x); -#include -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_casinf +#include -#undef __casinf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include +#include "cfloat-compat.h" c1_cfloat_rettype __c1_casinf (c1_cfloat_decl (x)) diff --git a/sysdeps/alpha/fpu/s_casinhf.c b/sysdeps/alpha/fpu/s_casinhf.c index 720294ea00..11faf9a0ab 100644 --- a/sysdeps/alpha/fpu/s_casinhf.c +++ b/sysdeps/alpha/fpu/s_casinhf.c @@ -24,14 +24,18 @@ #undef __casinhf #undef casinhf -#define __casinhf internal_casinhf static _Complex float internal_casinhf (_Complex float x); -#include -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_casinhf +#include -#undef __casinhf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include +#include "cfloat-compat.h" c1_cfloat_rettype __c1_casinhf (c1_cfloat_decl (x)) diff --git a/sysdeps/alpha/fpu/s_csinf.c b/sysdeps/alpha/fpu/s_csinf.c index abe2d3ab45..fc49244c10 100644 --- a/sysdeps/alpha/fpu/s_csinf.c +++ b/sysdeps/alpha/fpu/s_csinf.c @@ -24,14 +24,18 @@ #undef __csinf #undef csinf -#define __csinf internal_csinf static _Complex float internal_csinf (_Complex float x); -#include -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_csinf +#include -#undef __csinf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include +#include "cfloat-compat.h" c1_cfloat_rettype __c1_csinf (c1_cfloat_decl (x)) diff --git a/sysdeps/alpha/fpu/s_csinhf.c b/sysdeps/alpha/fpu/s_csinhf.c index a6d470a438..6263cd04f0 100644 --- a/sysdeps/alpha/fpu/s_csinhf.c +++ b/sysdeps/alpha/fpu/s_csinhf.c @@ -24,14 +24,18 @@ #undef __csinhf #undef csinhf -#define __csinhf internal_csinhf static _Complex float internal_csinhf (_Complex float x); -#include -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_csinhf +#include -#undef __csinhf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include +#include "cfloat-compat.h" c1_cfloat_rettype __c1_csinhf (c1_cfloat_decl (x)) diff --git a/sysdeps/ieee754/ldbl-opt/s_casin.c b/sysdeps/ieee754/ldbl-opt/s_casin.c deleted file mode 100644 index 04c47ca602..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_casin.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#include -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __casin, casinl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_casinh.c b/sysdeps/ieee754/ldbl-opt/s_casinh.c deleted file mode 100644 index 19c4fa30f8..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_casinh.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#include -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __casinh, casinhl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_casinhl.c b/sysdeps/ieee754/ldbl-opt/s_casinhl.c deleted file mode 100644 index 976fa8e5b0..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_casinhl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#undef weak_alias -#define weak_alias(n,a) -#include -long_double_symbol (libm, __casinhl, casinhl); diff --git a/sysdeps/ieee754/ldbl-opt/s_casinl.c b/sysdeps/ieee754/ldbl-opt/s_casinl.c deleted file mode 100644 index 7afb77cd4d..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_casinl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#undef weak_alias -#define weak_alias(n,a) -#include -long_double_symbol (libm, __casinl, casinl); diff --git a/sysdeps/ieee754/ldbl-opt/s_csin.c b/sysdeps/ieee754/ldbl-opt/s_csin.c deleted file mode 100644 index 7017c95450..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_csin.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#include -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __csin, csinl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_csinh.c b/sysdeps/ieee754/ldbl-opt/s_csinh.c deleted file mode 100644 index a1fa6671db..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_csinh.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#include -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __csinh, csinhl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_csinhl.c b/sysdeps/ieee754/ldbl-opt/s_csinhl.c deleted file mode 100644 index 484d466ce8..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_csinhl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#undef weak_alias -#define weak_alias(n,a) -#include -long_double_symbol (libm, __csinhl, csinhl); diff --git a/sysdeps/ieee754/ldbl-opt/s_csinl.c b/sysdeps/ieee754/ldbl-opt/s_csinl.c deleted file mode 100644 index f71642e886..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_csinl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#undef weak_alias -#define weak_alias(n,a) -#include -long_double_symbol (libm, __csinl, csinl); diff --git a/sysdeps/m68k/m680x0/fpu/s_csin.c b/sysdeps/m68k/m680x0/fpu/s_csin.c deleted file mode 100644 index b8419be897..0000000000 --- a/sysdeps/m68k/m680x0/fpu/s_csin.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Complex sine function. m68k fpu version - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Andreas Schwab . - - 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 - . */ - -#include -#include -#include "mathimpl.h" - -#ifndef SUFF -#define SUFF -#endif -#ifndef float_type -#define float_type double -#endif - -#define CONCATX(a,b) __CONCAT(a,b) -#define s(name) CONCATX(name,SUFF) -#define m81(func) __m81_u(s(func)) - -__complex__ float_type -s(__csin) (__complex__ float_type x) -{ - __complex__ float_type retval; - unsigned long rx_cond = __m81_test (__real__ x); - - if ((rx_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0) - { - /* Real part is finite. */ - float_type sin_rx, cos_rx; - - __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx) - : "f" (__real__ x)); - if (rx_cond & __M81_COND_ZERO) - __real__ retval = __real__ x; - else - __real__ retval = sin_rx * m81(__ieee754_cosh) (__imag__ x); - __imag__ retval = cos_rx * m81(__ieee754_sinh) (__imag__ x); - } - else - { - unsigned long ix_cond = __m81_test (__imag__ x); - - __real__ retval = __real__ x - __real__ x; - if (ix_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN)) - __imag__ retval = __imag__ x; - else - __imag__ retval = __real__ retval; - } - - return retval; -} -weak_alias (s(__csin), s(csin)) diff --git a/sysdeps/m68k/m680x0/fpu/s_csin_template.c b/sysdeps/m68k/m680x0/fpu/s_csin_template.c new file mode 100644 index 0000000000..628d0d519b --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_csin_template.c @@ -0,0 +1,59 @@ +/* Complex sine function. m68k fpu version + Copyright (C) 1997-2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab . + + 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 + . */ + +#include +#include +#include "mathimpl.h" + +#define s(name) M_SUF (name) +#define m81(func) __m81_u(s(func)) + +CFLOAT +s(__csin) (CFLOAT x) +{ + CFLOAT retval; + unsigned long rx_cond = __m81_test (__real__ x); + + if ((rx_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0) + { + /* Real part is finite. */ + FLOAT sin_rx, cos_rx; + + __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx) + : "f" (__real__ x)); + if (rx_cond & __M81_COND_ZERO) + __real__ retval = __real__ x; + else + __real__ retval = sin_rx * m81(__ieee754_cosh) (__imag__ x); + __imag__ retval = cos_rx * m81(__ieee754_sinh) (__imag__ x); + } + else + { + unsigned long ix_cond = __m81_test (__imag__ x); + + __real__ retval = __real__ x - __real__ x; + if (ix_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN)) + __imag__ retval = __imag__ x; + else + __imag__ retval = __real__ retval; + } + + return retval; +} +weak_alias (s(__csin), s(csin)) diff --git a/sysdeps/m68k/m680x0/fpu/s_csinf.c b/sysdeps/m68k/m680x0/fpu/s_csinf.c deleted file mode 100644 index b760e192c3..0000000000 --- a/sysdeps/m68k/m680x0/fpu/s_csinf.c +++ /dev/null @@ -1,3 +0,0 @@ -#define SUFF f -#define float_type float -#include diff --git a/sysdeps/m68k/m680x0/fpu/s_csinh.c b/sysdeps/m68k/m680x0/fpu/s_csinh.c deleted file mode 100644 index c633cd8875..0000000000 --- a/sysdeps/m68k/m680x0/fpu/s_csinh.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Complex sine hyperbole function. m68k fpu version - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Andreas Schwab . - - 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 - . */ - -#include -#include -#include "mathimpl.h" - -#ifndef SUFF -#define SUFF -#endif -#ifndef float_type -#define float_type double -#endif - -#define CONCATX(a,b) __CONCAT(a,b) -#define s(name) CONCATX(name,SUFF) -#define m81(func) __m81_u(s(func)) - -__complex__ float_type -s(__csinh) (__complex__ float_type x) -{ - __complex__ float_type retval; - unsigned long ix_cond; - - ix_cond = __m81_test (__imag__ x); - - if ((ix_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0) - { - /* Imaginary part is finite. */ - float_type sin_ix, cos_ix; - - __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix) - : "f" (__imag__ x)); - __real__ retval = cos_ix * m81(__ieee754_sinh) (__real__ x); - if (ix_cond & __M81_COND_ZERO) - __imag__ retval = __imag__ x; - else - __imag__ retval = sin_ix * m81(__ieee754_cosh) (__real__ x); - } - else - { - unsigned long rx_cond = __m81_test (__real__ x); - - __imag__ retval = __imag__ x - __imag__ x; - if (rx_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN)) - __real__ retval = __real__ x; - else - __real__ retval = __imag__ retval; - } - - return retval; -} -weak_alias (s(__csinh), s(csinh)) diff --git a/sysdeps/m68k/m680x0/fpu/s_csinh_template.c b/sysdeps/m68k/m680x0/fpu/s_csinh_template.c new file mode 100644 index 0000000000..56f3babd95 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_csinh_template.c @@ -0,0 +1,62 @@ +/* Complex sine hyperbole function. m68k fpu version + Copyright (C) 1997-2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab . + + 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 + . */ + +#include +#include +#include "mathimpl.h" + +#define CONCATX(a,b) __CONCAT(a,b) +#define s(name) M_SUF (name) +#define m81(func) __m81_u(s(func)) + +CFLOAT +s(__csinh) (CFLOAT x) +{ + CFLOAT retval; + unsigned long ix_cond; + + ix_cond = __m81_test (__imag__ x); + + if ((ix_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0) + { + /* Imaginary part is finite. */ + FLOAT sin_ix, cos_ix; + + __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix) + : "f" (__imag__ x)); + __real__ retval = cos_ix * m81(__ieee754_sinh) (__real__ x); + if (ix_cond & __M81_COND_ZERO) + __imag__ retval = __imag__ x; + else + __imag__ retval = sin_ix * m81(__ieee754_cosh) (__real__ x); + } + else + { + unsigned long rx_cond = __m81_test (__real__ x); + + __imag__ retval = __imag__ x - __imag__ x; + if (rx_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN)) + __real__ retval = __real__ x; + else + __real__ retval = __imag__ retval; + } + + return retval; +} +weak_alias (s(__csinh), s(csinh)) diff --git a/sysdeps/m68k/m680x0/fpu/s_csinhf.c b/sysdeps/m68k/m680x0/fpu/s_csinhf.c deleted file mode 100644 index 2f7a43e6a8..0000000000 --- a/sysdeps/m68k/m680x0/fpu/s_csinhf.c +++ /dev/null @@ -1,3 +0,0 @@ -#define SUFF f -#define float_type float -#include diff --git a/sysdeps/m68k/m680x0/fpu/s_csinhl.c b/sysdeps/m68k/m680x0/fpu/s_csinhl.c deleted file mode 100644 index 026a20e7be..0000000000 --- a/sysdeps/m68k/m680x0/fpu/s_csinhl.c +++ /dev/null @@ -1,3 +0,0 @@ -#define SUFF l -#define float_type long double -#include diff --git a/sysdeps/m68k/m680x0/fpu/s_csinl.c b/sysdeps/m68k/m680x0/fpu/s_csinl.c deleted file mode 100644 index ea2dad0556..0000000000 --- a/sysdeps/m68k/m680x0/fpu/s_csinl.c +++ /dev/null @@ -1,3 +0,0 @@ -#define SUFF l -#define float_type long double -#include -- cgit v1.2.3