diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2010-08-28 22:10:52 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2010-08-28 22:10:52 +0000 |
commit | 08fd13d44702391da6e367876b74ce8ed71c0bab (patch) | |
tree | 0834fa07275fef77737822694da3a4ad8215b389 /libgfortran/m4 | |
parent | bf321310b19598f6151b217e160f1c05ba18f994 (diff) | |
download | gcc-08fd13d44702391da6e367876b74ce8ed71c0bab.zip gcc-08fd13d44702391da6e367876b74ce8ed71c0bab.tar.gz gcc-08fd13d44702391da6e367876b74ce8ed71c0bab.tar.bz2 |
mtype.m4 (upcase, [...]): New macros.
* m4/mtype.m4 (upcase, hasmathfunc, mathfunc_macro): New macros.
* m4/fraction.m4: Use new macros to support quad-float types.
* m4/set_exponent.m4: Likewise.
* m4/spacing.m4: Likewise.
* m4/exponent.m4: Likewise.
* m4/nearest.m4: Likewise.
* m4/norm2.m4: Likewise.
* m4/bessel.m4: Likewise.
* m4/rrspacing.m4: Likewise.
* generated/bessel_r4.c:Regenerated.
* generated/bessel_r8.c: Regenerated.
* generated/bessel_r10.c: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/exponent_r4.c: Regenerated.
* generated/exponent_r8.c: Regenerated.
* generated/exponent_r10.c: Regenerated.
* generated/exponent_r16.c: Regenerated.
* generated/fraction_r4.c: Regenerated.
* generated/fraction_r8.c: Regenerated.
* generated/fraction_r10.c: Regenerated.
* generated/fraction_r16.c: Regenerated.
* generated/nearest_r4.c: Regenerated.
* generated/nearest_r8.c: Regenerated.
* generated/nearest_r10.c: Regenerated.
* generated/nearest_r16.c: Regenerated.
* generated/norm2_r4.c: Regenerated.
* generated/norm2_r8.c: Regenerated.
* generated/norm2_r10.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/rrspacing_r4.c: Regenerated.
* generated/rrspacing_r8.c: Regenerated.
* generated/rrspacing_r10.c: Regenerated.
* generated/rrspacing_r16.c: Regenerated.
* generated/set_exponent_r4.c: Regenerated.
* generated/set_exponent_r8.c: Regenerated.
* generated/set_exponent_r10.c: Regenerated.
* generated/set_exponent_r16.c: Regenerated.
* generated/spacing_r4.c: Regenerated.
* generated/spacing_r8.c: Regenerated.
* generated/spacing_r10.c: Regenerated.
* generated/spacing_r16.c: Regenerated.
From-SVN: r163620
Diffstat (limited to 'libgfortran/m4')
-rw-r--r-- | libgfortran/m4/bessel.m4 | 26 | ||||
-rw-r--r-- | libgfortran/m4/exponent.m4 | 6 | ||||
-rw-r--r-- | libgfortran/m4/fraction.m4 | 6 | ||||
-rw-r--r-- | libgfortran/m4/mtype.m4 | 7 | ||||
-rw-r--r-- | libgfortran/m4/nearest.m4 | 10 | ||||
-rw-r--r-- | libgfortran/m4/norm2.m4 | 18 | ||||
-rw-r--r-- | libgfortran/m4/rrspacing.m4 | 14 | ||||
-rw-r--r-- | libgfortran/m4/set_exponent.m4 | 6 | ||||
-rw-r--r-- | libgfortran/m4/spacing.m4 | 12 |
9 files changed, 64 insertions, 41 deletions
diff --git a/libgfortran/m4/bessel.m4 b/libgfortran/m4/bessel.m4 index a4790dd..3df8f1d 100644 --- a/libgfortran/m4/bessel.m4 +++ b/libgfortran/m4/bessel.m4 @@ -31,11 +31,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see include(iparm.m4)dnl include(`mtype.m4')dnl +mathfunc_macro + `#if defined (HAVE_'rtype_name`) -#if defined (HAVE_JN'Q`) +#if 'hasmathfunc(jn)` extern void bessel_jn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, 'rtype_name` x); export_proto(bessel_jn_r'rtype_kind`); @@ -69,28 +71,28 @@ bessel_jn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, 'rtype_na stride = GFC_DESCRIPTOR_STRIDE(ret,0); - if (unlikely (x == 0.0'Q`)) + if (unlikely (x == 0)) { - ret->data[0] = 1.0'Q`; + ret->data[0] = 1; for (i = 1; i <= n2-n1; i++) - ret->data[i*stride] = 0.0'Q`; + ret->data[i*stride] = 0; return; } ret->data = ret->data; - last1 = jn'q` (n2, x); + last1 = MATHFUNC(jn) (n2, x); ret->data[(n2-n1)*stride] = last1; if (n1 == n2) return; - last2 = jn'q` (n2 - 1, x); + last2 = MATHFUNC(jn) (n2 - 1, x); ret->data[(n2-n1-1)*stride] = last2; if (n1 + 1 == n2) return; - x2rev = 2.0'Q`/x; + x2rev = GFC_REAL_'rtype_kind`_LITERAL(2.)/x; for (i = n2-n1-2; i >= 0; i--) { @@ -102,7 +104,7 @@ bessel_jn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, 'rtype_na #endif -#if defined (HAVE_YN'Q`) +#if 'hasmathfunc(yn)` extern void bessel_yn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, 'rtype_name` x); export_proto(bessel_yn_r'rtype_kind`); @@ -137,7 +139,7 @@ bessel_yn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, stride = GFC_DESCRIPTOR_STRIDE(ret,0); - if (unlikely (x == 0.0'Q`)) + if (unlikely (x == 0)) { for (i = 0; i <= n2-n1; i++) #if defined('rtype_name`_INFINITY) @@ -149,19 +151,19 @@ bessel_yn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, } ret->data = ret->data; - last1 = yn'q` (n1, x); + last1 = MATHFUNC(yn) (n1, x); ret->data[0] = last1; if (n1 == n2) return; - last2 = yn'q` (n1 + 1, x); + last2 = MATHFUNC(yn) (n1 + 1, x); ret->data[1*stride] = last2; if (n1 + 1 == n2) return; - x2rev = 2.0'Q`/x; + x2rev = GFC_REAL_'rtype_kind`_LITERAL(2.)/x; for (i = 2; i <= n1+n2; i++) { diff --git a/libgfortran/m4/exponent.m4 b/libgfortran/m4/exponent.m4 index bb9cda8..7302eb8 100644 --- a/libgfortran/m4/exponent.m4 +++ b/libgfortran/m4/exponent.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see include(`mtype.m4')dnl -`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`) +mathfunc_macro + +`#if defined (HAVE_'real_type`) && 'hasmathfunc(frexp)` extern GFC_INTEGER_4 exponent_r'kind` ('real_type` s); export_proto(exponent_r'kind`); @@ -36,7 +38,7 @@ GFC_INTEGER_4 exponent_r'kind` ('real_type` s) { int ret; - frexp'q` (s, &ret); + MATHFUNC(frexp) (s, &ret); return ret; } diff --git a/libgfortran/m4/fraction.m4 b/libgfortran/m4/fraction.m4 index 2878127..419e801 100644 --- a/libgfortran/m4/fraction.m4 +++ b/libgfortran/m4/fraction.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see include(`mtype.m4')dnl -`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`) +mathfunc_macro + +`#if defined (HAVE_'real_type`) && 'hasmathfunc(frexp)` extern 'real_type` fraction_r'kind` ('real_type` s); export_proto(fraction_r'kind`); @@ -36,7 +38,7 @@ export_proto(fraction_r'kind`); fraction_r'kind` ('real_type` s) { int dummy_exp; - return frexp'q` (s, &dummy_exp); + return MATHFUNC(frexp) (s, &dummy_exp); } #endif' diff --git a/libgfortran/m4/mtype.m4 b/libgfortran/m4/mtype.m4 index 8e7e889..fc4ceca 100644 --- a/libgfortran/m4/mtype.m4 +++ b/libgfortran/m4/mtype.m4 @@ -2,5 +2,12 @@ dnl Get type kind from filename. define(kind,regexp(file, `_.\([0-9]+\).c$', `\1'))dnl define(complex_type, `GFC_COMPLEX_'kind)dnl define(real_type, `GFC_REAL_'kind)dnl +define(`upcase', `translit(`$*', `a-z', `A-Z')')dnl define(q,ifelse(kind,4,f,ifelse(kind,8,`',ifelse(kind,10,l,ifelse(kind,16,l,`_'kind)))))dnl define(Q,translit(q,`a-z',`A-Z'))dnl +define(hasmathfunc,`ifelse(kind,4,`defined (HAVE_'upcase($1)`F)',ifelse(kind,8,`defined (HAVE_'upcase($1)`)',ifelse(kind,10,`defined (HAVE_'upcase($1)`L)',ifelse(kind,16,`(defined(GFC_WITH_QUAD_LIB) || defined(HAVE_'upcase($1)`L))',`error out'))))') +define(mathfunc_macro,`ifelse(kind,16,`#if defined(GFC_REAL_16_IS_FLOAT128) +#define MATHFUNC(funcname) funcname ## q +#else +#define MATHFUNC(funcname) funcname ## l +#endif',ifelse(kind,8,``#''`define MATHFUNC(funcname) funcname',```#'''`define MATHFUNC(funcname) funcname '```#'''```#'''` 'q))')dnl diff --git a/libgfortran/m4/nearest.m4 b/libgfortran/m4/nearest.m4 index 98b417f..8fbe500 100644 --- a/libgfortran/m4/nearest.m4 +++ b/libgfortran/m4/nearest.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see include(`mtype.m4')dnl -`#if defined (HAVE_'real_type`) && defined (HAVE_COPYSIGN'Q`) && defined (HAVE_NEXTAFTER'Q`) +mathfunc_macro + +`#if defined (HAVE_'real_type`) && 'hasmathfunc(copysign) && hasmathfunc(nextafter)` extern 'real_type` nearest_r'kind` ('real_type` s, 'real_type` dir); export_proto(nearest_r'kind`); @@ -35,15 +37,15 @@ export_proto(nearest_r'kind`); 'real_type` nearest_r'kind` ('real_type` s, 'real_type` dir) { - dir = copysign'q` (__builtin_inf'q` (), dir); + dir = MATHFUNC(copysign) (MATHFUNC(__builtin_inf) (), dir); if (FLT_EVAL_METHOD != 0) { /* ??? Work around glibc bug on x86. */ - volatile 'real_type` r = nextafter'q` (s, dir); + volatile 'real_type` r = MATHFUNC(nextafter) (s, dir); return r; } else - return nextafter'q` (s, dir); + return MATHFUNC(nextafter) (s, dir); } #endif' diff --git a/libgfortran/m4/norm2.m4 b/libgfortran/m4/norm2.m4 index e1d6b97..b2162ac 100644 --- a/libgfortran/m4/norm2.m4 +++ b/libgfortran/m4/norm2.m4 @@ -32,20 +32,22 @@ include(iparm.m4)dnl include(ifunction.m4)dnl include(`mtype.m4')dnl -`#if defined (HAVE_'atype_name`) && defined (HAVE_'rtype_name`)' +`#if defined (HAVE_'atype_name`) && defined (HAVE_'rtype_name`) && 'hasmathfunc(sqrt) && hasmathfunc(fabs) -ARRAY_FUNCTION(`0.0'Q, +mathfunc_macro + +ARRAY_FUNCTION(0, ` 'rtype_name` scale; - result = 0.0'Q`; - scale = 1.0'Q`;', -` if (*src != 0.0'Q`) + result = 0; + scale = 1;', +` if (*src != 0) { 'rtype_name` absX, val; - absX = fabs'q` (*src); + absX = MATHFUNC(fabs) (*src); if (scale < absX) { val = scale / absX; - result = 1.0'Q` + result * val * val; + result = 1 + result * val * val; scale = absX; } else @@ -54,6 +56,6 @@ ARRAY_FUNCTION(`0.0'Q, result += val * val; } }', -` result = scale * sqrt'q` (result);') +` result = scale * MATHFUNC(sqrt) (result);') #endif diff --git a/libgfortran/m4/rrspacing.m4 b/libgfortran/m4/rrspacing.m4 index f66bb3b..3d75c66 100644 --- a/libgfortran/m4/rrspacing.m4 +++ b/libgfortran/m4/rrspacing.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see include(`mtype.m4')dnl -`#if defined (HAVE_'real_type`) && defined (HAVE_FABS'Q`) && defined (HAVE_FREXP'Q`) +mathfunc_macro + +`#if defined (HAVE_'real_type`) && 'hasmathfunc(fabs) && hasmathfunc(frexp)` extern 'real_type` rrspacing_r'kind` ('real_type` s, int p); export_proto(rrspacing_r'kind`); @@ -37,14 +39,14 @@ rrspacing_r'kind` ('real_type` s, int p) { int e; 'real_type` x; - x = fabs'q` (s); + x = MATHFUNC(fabs) (s); if (x == 0.) return 0.; - frexp'q` (s, &e); -#if defined (HAVE_LDEXP'Q`) - return ldexp'q` (x, p - e); + MATHFUNC(frexp) (s, &e); +#if 'hasmathfunc(ldexp)` + return MATHFUNC(ldexp) (x, p - e); #else - return scalbn'q` (x, p - e); + return MATHFUNC(scalbn) (x, p - e); #endif } diff --git a/libgfortran/m4/set_exponent.m4 b/libgfortran/m4/set_exponent.m4 index 84200fd..0d35d11c 100644 --- a/libgfortran/m4/set_exponent.m4 +++ b/libgfortran/m4/set_exponent.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see include(`mtype.m4')dnl -`#if defined (HAVE_'real_type`) && defined (HAVE_SCALBN'Q`) && defined (HAVE_FREXP'Q`) +mathfunc_macro + +`#if defined (HAVE_'real_type`) && 'hasmathfunc(scalbn) && hasmathfunc(frexp)` extern 'real_type` set_exponent_r'kind` ('real_type` s, GFC_INTEGER_4 i); export_proto(set_exponent_r'kind`); @@ -36,7 +38,7 @@ export_proto(set_exponent_r'kind`); set_exponent_r'kind` ('real_type` s, GFC_INTEGER_4 i) { int dummy_exp; - return scalbn'q` (frexp'q` (s, &dummy_exp), i); + return MATHFUNC(scalbn) (MATHFUNC(frexp) (s, &dummy_exp), i); } #endif' diff --git a/libgfortran/m4/spacing.m4 b/libgfortran/m4/spacing.m4 index 62fa739..9b43b74 100644 --- a/libgfortran/m4/spacing.m4 +++ b/libgfortran/m4/spacing.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see include(`mtype.m4')dnl -`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`) +mathfunc_macro + +`#if defined (HAVE_'real_type`) && 'hasmathfunc(frexp)` extern 'real_type` spacing_r'kind` ('real_type` s, int p, int emin, 'real_type` tiny); export_proto(spacing_r'kind`); @@ -38,13 +40,13 @@ spacing_r'kind` ('real_type` s, int p, int emin, 'real_type` tiny) int e; if (s == 0.) return tiny; - frexp'q` (s, &e); + MATHFUNC(frexp) (s, &e); e = e - p; e = e > emin ? e : emin; -#if defined (HAVE_LDEXP'Q`) - return ldexp'q` (1., e); +#if 'hasmathfunc(ldexp)` + return MATHFUNC(ldexp) (1., e); #else - return scalbn'q` (1., e); + return MATHFUNC(scalbn) (1., e); #endif } |