diff options
author | Richard Guenther <rguenther@suse.de> | 2006-01-31 11:56:46 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2006-01-31 11:56:46 +0000 |
commit | 0058967bb0b6d9395ceae3916f85ba7bcbfa3e8f (patch) | |
tree | 1bd09a73712c40d7c7750282692a1f094c832bba /libgcc-math/include | |
parent | 842173466d766db080cbc9e837988e31b453d05f (diff) | |
download | gcc-0058967bb0b6d9395ceae3916f85ba7bcbfa3e8f.zip gcc-0058967bb0b6d9395ceae3916f85ba7bcbfa3e8f.tar.gz gcc-0058967bb0b6d9395ceae3916f85ba7bcbfa3e8f.tar.bz2 |
Makefile.def (target_modules): Add libgcc-math target module.
2006-01-31 Richard Guenther <rguenther@suse.de>
Paolo Bonzini <bonzini@gnu.org>
* Makefile.def (target_modules): Add libgcc-math target module.
* configure.in (target_libraries): Add libgcc-math target library.
(--enable-libgcc-math): New configure switch.
* Makefile.in: Re-generate.
* configure: Re-generate.
* libgcc-math: New toplevel directory.
* doc/install.texi (--disable-libgcc-math): Document.
libgcc-math/
* configure.ac: New file.
* Makefile.am: Likewise.
* configure: New generated file.
* Makefile.in: Likewise.
* aclocal.m4: Likewise.
* libtool-version: New file.
* include/ieee754.h: New file.
* include/libc-symbols.h: Likewise.
* include/math_private.h: Likewise.
* i386/Makefile.am: New file.
* i386/Makefile.in: New generated file.
* i386/sse2.h: New file.
* i386/endian.h: Likewise.
* i386/sse2.map: Linker script for SSE2 ABI math intrinsics.
* flt-32/: Import from glibc.
* dbl-64/: Likewise.
Co-Authored-By: Paolo Bonzini <bonzini@gnu.org>
From-SVN: r110434
Diffstat (limited to 'libgcc-math/include')
-rw-r--r-- | libgcc-math/include/ieee754.h | 136 | ||||
-rw-r--r-- | libgcc-math/include/libc-symbols.h | 50 | ||||
-rw-r--r-- | libgcc-math/include/math_private.h | 322 |
3 files changed, 508 insertions, 0 deletions
diff --git a/libgcc-math/include/ieee754.h b/libgcc-math/include/ieee754.h new file mode 100644 index 0000000..30b1ac5 --- /dev/null +++ b/libgcc-math/include/ieee754.h @@ -0,0 +1,136 @@ +/* Copyright (C) 1992, 1995, 1996, 1999, 2006 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file into combinations with other programs, +and to distribute those combinations without any restriction coming +from the use of this file. (The General Public License restrictions +do apply in other respects; for example, they cover modification of +the file, and distribution when not linked into a combine +executable.) + +GCC 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 General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. */ + +#ifndef _IEEE754_H + +#define _IEEE754_H 1 +#include <endian.h> + +union ieee754_float + { + float f; + + /* This is the IEEE 754 single-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int mantissa:23; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int mantissa:23; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int quiet_nan:1; + unsigned int mantissa:22; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int mantissa:22; + unsigned int quiet_nan:1; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee_nan; + }; + +#define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */ + + +union ieee754_double + { + double d; + + /* This is the IEEE 754 double-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:20; + unsigned int mantissa1:32; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN +# if __FLOAT_WORD_ORDER == BIG_ENDIAN + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; + unsigned int mantissa1:32; +# else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; +# endif +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + unsigned int quiet_nan:1; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:19; + unsigned int mantissa1:32; +#else +# if __FLOAT_WORD_ORDER == BIG_ENDIAN + unsigned int mantissa0:19; + unsigned int quiet_nan:1; + unsigned int exponent:11; + unsigned int negative:1; + unsigned int mantissa1:32; +# else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:19; + unsigned int quiet_nan:1; + unsigned int exponent:11; + unsigned int negative:1; +# endif +#endif + } ieee_nan; + }; + +#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */ + + +#endif /* ieee754.h */ diff --git a/libgcc-math/include/libc-symbols.h b/libgcc-math/include/libc-symbols.h new file mode 100644 index 0000000..6d61614 --- /dev/null +++ b/libgcc-math/include/libc-symbols.h @@ -0,0 +1,50 @@ +/* Definitions for symbol handling done by flt-32 and dbl-64 sources. +Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file into combinations with other programs, +and to distribute those combinations without any restriction coming +from the use of this file. (The General Public License restrictions +do apply in other respects; for example, they cover modification of +the file, and distribution when not linked into a combine +executable.) + +GCC 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 General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. */ + + +/* Define ALIASNAME as a strong alias for NAME. */ +# define strong_alias(name, aliasname) _strong_alias(name, aliasname) +# define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); + +/* This comes between the return type and function name in + a function definition to make that definition weak. */ +# define weak_function __attribute__ ((weak)) +# define weak_const_function __attribute__ ((weak, __const__)) + +/* Define ALIASNAME as a weak alias for NAME. + If weak aliases are not available, this defines a strong alias. */ +# define weak_alias(name, aliasname) _weak_alias (name, aliasname) +# define _weak_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); + +/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */ +# define weak_extern(symbol) _weak_extern (weak symbol) +# define _weak_extern(expr) _Pragma (#expr) + diff --git a/libgcc-math/include/math_private.h b/libgcc-math/include/math_private.h new file mode 100644 index 0000000..413a0a8 --- /dev/null +++ b/libgcc-math/include/math_private.h @@ -0,0 +1,322 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * from: @(#)fdlibm.h 5.1 93/09/24 + * $Id: math_private.h,v 1.18 2003/08/28 00:10:15 drepper Exp $ + */ + +#ifndef _MATH_PRIVATE_H_ +#define _MATH_PRIVATE_H_ + +#include <endian.h> +#include <sys/types.h> + +/* The original fdlibm code used statements like: + n0 = ((*(int*)&one)>>29)^1; * index of high word * + ix0 = *(n0+(int*)&x); * high word of x * + ix1 = *((1-n0)+(int*)&x); * low word of x * + to dig two 32 bit words out of the 64 bit IEEE floating point + value. That is non-ANSI, and, moreover, the gcc instruction + scheduler gets it wrong. We instead use the following macros. + Unlike the original code, we determine the endianness at compile + time, not at run time; I don't see much benefit to selecting + endianness at run time. */ + +/* A union which permits us to convert between a double and two 32 bit + ints. */ + +#if __FLOAT_WORD_ORDER == BIG_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t msw; + u_int32_t lsw; + } parts; +} ieee_double_shape_type; + +#endif + +#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t lsw; + u_int32_t msw; + } parts; +} ieee_double_shape_type; + +#endif + +/* Get two 32 bit ints from a double. */ + +#define EXTRACT_WORDS(ix0,ix1,d) \ +do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ +} while (0) + +/* Get the more significant 32 bit int from a double. */ + +#define GET_HIGH_WORD(i,d) \ +do { \ + ieee_double_shape_type gh_u; \ + gh_u.value = (d); \ + (i) = gh_u.parts.msw; \ +} while (0) + +/* Get the less significant 32 bit int from a double. */ + +#define GET_LOW_WORD(i,d) \ +do { \ + ieee_double_shape_type gl_u; \ + gl_u.value = (d); \ + (i) = gl_u.parts.lsw; \ +} while (0) + +/* Set a double from two 32 bit ints. */ + +#define INSERT_WORDS(d,ix0,ix1) \ +do { \ + ieee_double_shape_type iw_u; \ + iw_u.parts.msw = (ix0); \ + iw_u.parts.lsw = (ix1); \ + (d) = iw_u.value; \ +} while (0) + +/* Set the more significant 32 bits of a double from an int. */ + +#define SET_HIGH_WORD(d,v) \ +do { \ + ieee_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts.msw = (v); \ + (d) = sh_u.value; \ +} while (0) + +/* Set the less significant 32 bits of a double from an int. */ + +#define SET_LOW_WORD(d,v) \ +do { \ + ieee_double_shape_type sl_u; \ + sl_u.value = (d); \ + sl_u.parts.lsw = (v); \ + (d) = sl_u.value; \ +} while (0) + +/* A union which permits us to convert between a float and a 32 bit + int. */ + +typedef union +{ + float value; + u_int32_t word; +} ieee_float_shape_type; + +/* Get a 32 bit int from a float. */ + +#define GET_FLOAT_WORD(i,d) \ +do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define SET_FLOAT_WORD(d,i) \ +do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +/* Get long double macros from a separate header. Not. */ +#define NO_LONG_DOUBLE + +/* ieee style elementary functions */ +extern double __ieee754_sqrt (double); +extern double __ieee754_acos (double); +extern double __ieee754_acosh (double); +extern double __ieee754_log (double); +extern double __ieee754_atanh (double); +extern double __ieee754_asin (double); +extern double __ieee754_atan2 (double,double); +extern double __ieee754_exp (double); +extern double __ieee754_exp2 (double); +extern double __ieee754_exp10 (double); +extern double __ieee754_cosh (double); +extern double __ieee754_fmod (double,double); +extern double __ieee754_pow (double,double); +extern double __ieee754_lgamma_r (double,int *); +extern double __ieee754_gamma_r (double,int *); +extern double __ieee754_lgamma (double); +extern double __ieee754_gamma (double); +extern double __ieee754_log10 (double); +extern double __ieee754_log2 (double); +extern double __ieee754_sinh (double); +extern double __ieee754_hypot (double,double); +extern double __ieee754_j0 (double); +extern double __ieee754_j1 (double); +extern double __ieee754_y0 (double); +extern double __ieee754_y1 (double); +extern double __ieee754_jn (int,double); +extern double __ieee754_yn (int,double); +extern double __ieee754_remainder (double,double); +extern int32_t __ieee754_rem_pio2 (double,double*); +extern double __ieee754_scalb (double,double); + +/* fdlibm kernel function */ +extern double __kernel_standard (double,double,int); +extern double __kernel_sin (double,double,int); +extern double __kernel_cos (double,double); +extern double __kernel_tan (double,double,int); +extern int __kernel_rem_pio2 (double*,double*,int,int,int, const int32_t*); + +/* internal functions. */ +extern double __copysign (double x, double __y); + + +/* ieee style elementary float functions */ +extern float __ieee754_sqrtf (float); +extern float __ieee754_acosf (float); +extern float __ieee754_acoshf (float); +extern float __ieee754_logf (float); +extern float __ieee754_atanhf (float); +extern float __ieee754_asinf (float); +extern float __ieee754_atan2f (float,float); +extern float __ieee754_expf (float); +extern float __ieee754_exp2f (float); +extern float __ieee754_exp10f (float); +extern float __ieee754_coshf (float); +extern float __ieee754_fmodf (float,float); +extern float __ieee754_powf (float,float); +extern float __ieee754_lgammaf_r (float,int *); +extern float __ieee754_gammaf_r (float,int *); +extern float __ieee754_lgammaf (float); +extern float __ieee754_gammaf (float); +extern float __ieee754_log10f (float); +extern float __ieee754_log2f (float); +extern float __ieee754_sinhf (float); +extern float __ieee754_hypotf (float,float); +extern float __ieee754_j0f (float); +extern float __ieee754_j1f (float); +extern float __ieee754_y0f (float); +extern float __ieee754_y1f (float); +extern float __ieee754_jnf (int,float); +extern float __ieee754_ynf (int,float); +extern float __ieee754_remainderf (float,float); +extern int32_t __ieee754_rem_pio2f (float,float*); +extern float __ieee754_scalbf (float,float); + + +/* float versions of fdlibm kernel functions */ +extern float __kernel_sinf (float,float,int); +extern float __kernel_cosf (float,float); +extern float __kernel_tanf (float,float,int); +extern int __kernel_rem_pio2f (float*,float*,int,int,int, const int32_t*); + +/* internal functions. */ +extern float __copysignf (float x, float __y); + + +/* ieee style elementary long double functions */ +extern long double __ieee754_sqrtl (long double); +extern long double __ieee754_acosl (long double); +extern long double __ieee754_acoshl (long double); +extern long double __ieee754_logl (long double); +extern long double __ieee754_atanhl (long double); +extern long double __ieee754_asinl (long double); +extern long double __ieee754_atan2l (long double,long double); +extern long double __ieee754_expl (long double); +extern long double __ieee754_exp2l (long double); +extern long double __ieee754_exp10l (long double); +extern long double __ieee754_coshl (long double); +extern long double __ieee754_fmodl (long double,long double); +extern long double __ieee754_powl (long double,long double); +extern long double __ieee754_lgammal_r (long double,int *); +extern long double __ieee754_gammal_r (long double,int *); +extern long double __ieee754_lgammal (long double); +extern long double __ieee754_gammal (long double); +extern long double __ieee754_log10l (long double); +extern long double __ieee754_log2l (long double); +extern long double __ieee754_sinhl (long double); +extern long double __ieee754_hypotl (long double,long double); +extern long double __ieee754_j0l (long double); +extern long double __ieee754_j1l (long double); +extern long double __ieee754_y0l (long double); +extern long double __ieee754_y1l (long double); +extern long double __ieee754_jnl (int,long double); +extern long double __ieee754_ynl (int,long double); +extern long double __ieee754_remainderl (long double,long double); +extern int __ieee754_rem_pio2l (long double,long double*); +extern long double __ieee754_scalbl (long double,long double); + +/* long double versions of fdlibm kernel functions */ +extern long double __kernel_sinl (long double,long double,int); +extern long double __kernel_cosl (long double,long double); +extern long double __kernel_tanl (long double,long double,int); +extern void __kernel_sincosl (long double,long double, + long double *,long double *, int); +extern int __kernel_rem_pio2l (long double*,long double*,int,int, + int,const int*); + +#ifndef NO_LONG_DOUBLE +/* prototypes required to compile the ldbl-96 support without warnings */ +extern int __finitel (long double); +extern int __ilogbl (long double); +extern int __isinfl (long double); +extern int __isnanl (long double); +extern long double __atanl (long double); +extern long double __copysignl (long double, long double); +extern long double __expm1l (long double); +extern long double __floorl (long double); +extern long double __frexpl (long double, int *); +extern long double __ldexpl (long double, int); +extern long double __log1pl (long double); +extern long double __nanl (const char *); +extern long double __rintl (long double); +extern long double __scalbnl (long double, int); +extern long double __sqrtl (long double x); +extern long double fabsl (long double x); +extern void __sincosl (long double, long double *, long double *); +extern long double __logbl (long double x); +extern long double __significandl (long double x); +#endif + +/* Prototypes for functions of the IBM Accurate Mathematical Library. */ +extern double __exp1 (double __x, double __xx, double __error); +extern double __sin (double __x); +extern double __cos (double __x); +extern int __branred (double __x, double *__a, double *__aa); +extern void __doasin (double __x, double __dx, double __v[]); +extern void __dubsin (double __x, double __dx, double __v[]); +extern void __dubcos (double __x, double __dx, double __v[]); +extern double __halfulp (double __x, double __y); +extern double __sin32 (double __x, double __res, double __res1); +extern double __cos32 (double __x, double __res, double __res1); +extern double __mpsin (double __x, double __dx); +extern double __mpcos (double __x, double __dx); +extern double __mpsin1 (double __x); +extern double __mpcos1 (double __x); +extern double __slowexp (double __x); +extern double __slowpow (double __x, double __y, double __z); +extern void __docos (double __x, double __dx, double __v[]); + +#endif /* _MATH_PRIVATE_H_ */ |