fortran, libgfortran: Avoid using libquadmath for glibc 2.26+

As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.

The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.

We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.

The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf.  In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* .  The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.

As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.

The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either.  User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.

2022-06-28  Jakub Jelinek  <jakub@redhat.com>

gcc/fortran/
	* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
	* trans-types.h (gfc_real16_use_iec_60559): Declare.
	* trans-types.cc (gfc_real16_use_iec_60559): Define.
	(gfc_init_kinds): When building powerpc64le-linux libgfortran
	on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
	use_iec_60559.
	(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
	on glibc 2.26 or later.
	* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
	comment.  Handle gfc_real16_use_iec_60559.
	(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
	* configure.ac: Check for strtof128 and strfromf128.
	Check for math and complex *f128 functions.  Set
	have_iec_60559_libc_support to yes if *f128 support is around, for
	--enable-libquadmath-support default to "default" rather than yes if
	have_iec_60559_libc_support is yes.
	* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
	_Float128/_Complex _Float128 rather than __float128 and
	_Complex float __attribute__((mode(TC))).  If libquadmath support
	is defaulted and have_iec_60559_libc_support is yes, define and subst
	USE_IEC_60559.  Remove unused LIBGFOR_BUILD_QUAD conditional.
	* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
	mk-kinds-h.sh argument.
	* mk-kinds-h.sh: Accept 4th use_iec_60559 argument.  Use
	_Float128/_Complex _Float128 types instead of __float128 and
	_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
	use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
	* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
	__float128 and _Complex float __attribute__((mode(TC))), if
	USE_IEC_60559 is defined, use f128 suffixes instead of q and
	define GFC_REAL_17_USE_IEC_60559.
	* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
	defined.
	(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
	for GFC_REAL_16_USE_IEC_60559 differently.
	* caf/single.c (convert_type): Use _Float128/_Complex _Float128
	instead of __float128 and _Complex float __attribute__((mode(TC))).
	For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
	_Complex long double instead of long double.
	* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
	_Float128 instead of __float128.
	(__issignalingf128): Change argument type to _Float128.
	(issignaling): Use _Float128 instead of __float128 in _Generic.
	* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
	in a comment.  Fix a comment typo, logn double -> long double.
	* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
	Use different definitions if GFC_REAL_16_USE_IEC_60559.
	(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
	(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
	* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
	instead of __float128 in a comment.  Fix a comment typo,
	logn double -> long double.
	* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
	GFC_REAL_16_USE_IEC_60559.
	* intrinsics/pack_generic.c (pack): Use _Float128 instead of
	__float128 in a comment.  Fix a comment typo, logn double ->
	long double.
	* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
	* runtime/in_pack_generic.c (internal_pack): Likewise.
	* runtime/in_unpack_generic.c (internal_unpack): Likewise.
	* io/read.c (convert_real, convert_infnan): Handle
	GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
	* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
	isn't needed.
	* io/write_float.def (gfor_strfromf128): New function.
	(DTOA2Q, FDTOA2Q): Define differently if
	GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
	* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
	or GFC_REAL_17_USE_IEC_60559.
	* config.h.in: Regenerated.
	* configure: Regenerated.
	* Makefile.in: Regenerated.
	* generated/bessel_r16.c: Regenerated.
	* generated/bessel_r17.c: Regenerated.
	* generated/norm2_r16.c: Regenerated.
	* generated/norm2_r17.c: Regenerated.
This commit is contained in:
Jakub Jelinek 2022-06-28 13:05:28 +02:00
parent 8354d0abeb
commit 133d0d422e
31 changed files with 3576 additions and 133 deletions

View File

@ -2665,6 +2665,9 @@ typedef struct
unsigned int c_double : 1;
unsigned int c_long_double : 1;
unsigned int c_float128 : 1;
/* True if for _Float128 C2X IEC 60559 *f128 APIs should be used
instead of libquadmath *q APIs. */
unsigned int use_iec_60559 : 1;
}
gfc_real_info;

View File

@ -692,7 +692,7 @@ gfc_build_intrinsic_lib_fndecls (void)
{
/* If we have soft-float types, we create the decls for their
C99-like library functions. For now, we only handle _Float128
q-suffixed functions. */
q-suffixed or IEC 60559 f128-suffixed functions. */
tree type, complex_type, func_1, func_2, func_cabs, func_frexp;
tree func_iround, func_lround, func_llround, func_scalbn, func_cpow;
@ -739,7 +739,10 @@ gfc_build_intrinsic_lib_fndecls (void)
builtin_decl_for_float_type(). The others are all constructed by
gfc_get_intrinsic_lib_fndecl(). */
#define OTHER_BUILTIN(ID, NAME, TYPE, CONST) \
quad_decls[BUILT_IN_ ## ID] = define_quad_builtin (NAME "q", func_ ## TYPE, CONST);
quad_decls[BUILT_IN_ ## ID] \
= define_quad_builtin (gfc_real16_use_iec_60559 \
? NAME "f128" : NAME "q", func_ ## TYPE, \
CONST);
#include "mathbuiltins.def"
@ -751,8 +754,9 @@ gfc_build_intrinsic_lib_fndecls (void)
/* There is one built-in we defined manually, because it gets called
with builtin_decl_for_precision() or builtin_decl_for_float_type()
even though it is not an OTHER_BUILTIN: it is SQRT. */
quad_decls[BUILT_IN_SQRT] = define_quad_builtin ("sqrtq", func_1, true);
quad_decls[BUILT_IN_SQRT]
= define_quad_builtin (gfc_real16_use_iec_60559
? "sqrtf128" : "sqrtq", func_1, true);
}
/* Add GCC builtin functions. */
@ -875,7 +879,8 @@ gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr)
ts->type == BT_COMPLEX ? "c" : "", m->name, "l");
else if (gfc_real_kinds[n].c_float128)
snprintf (name, sizeof (name), "%s%s%s",
ts->type == BT_COMPLEX ? "c" : "", m->name, "q");
ts->type == BT_COMPLEX ? "c" : "", m->name,
gfc_real_kinds[n].use_iec_60559 ? "f128" : "q");
else
gcc_unreachable ();
}

View File

@ -72,6 +72,7 @@ tree gfc_float128_type_node = NULL_TREE;
tree gfc_complex_float128_type_node = NULL_TREE;
bool gfc_real16_is_float128 = false;
bool gfc_real16_use_iec_60559 = false;
static GTY(()) tree gfc_desc_dim_type;
static GTY(()) tree gfc_max_array_element_size;
@ -522,6 +523,11 @@ gfc_init_kinds (void)
&& (TARGET_GLIBC_MAJOR < 2
|| (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR < 32)))
{
if (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 26)
{
gfc_real16_use_iec_60559 = true;
gfc_real_kinds[i].use_iec_60559 = 1;
}
gfc_real16_is_float128 = true;
gfc_real_kinds[i].c_float128 = 1;
}
@ -878,6 +884,12 @@ gfc_build_real_type (gfc_real_info *info)
/* TODO: see PR101835. */
info->c_float128 = 1;
gfc_real16_is_float128 = true;
if (TARGET_GLIBC_MAJOR > 2
|| (TARGET_GLIBC_MAJOR == 2 && TARGET_GLIBC_MINOR >= 26))
{
info->use_iec_60559 = 1;
gfc_real16_use_iec_60559 = true;
}
}
if (TYPE_PRECISION (float_type_node) == mode_precision)

View File

@ -58,6 +58,10 @@ extern GTY(()) tree gfc_charlen_type_node;
and _Float128. */
extern bool gfc_real16_is_float128;
/* True if IEC 60559 *f128 APIs should be used for _Float128 rather than
libquadmath *q APIs. */
extern bool gfc_real16_use_iec_60559;
enum gfc_packed {
PACKED_NO = 0,
PACKED_PARTIAL,

View File

@ -1167,7 +1167,9 @@ I_M4_DEPS8=$(I_M4_DEPS) m4/ifindloc1.m4
I_M4_DEPS9=$(I_M4_DEPS) m4/ifindloc2.m4
kinds.h: $(srcdir)/mk-kinds-h.sh
$(SHELL) $(srcdir)/mk-kinds-h.sh '@LIBGOMP_CHECKED_INT_KINDS@' '@LIBGOMP_CHECKED_REAL_KINDS@' '$(FCCOMPILE)' > $@ || rm $@
$(SHELL) $(srcdir)/mk-kinds-h.sh '@LIBGOMP_CHECKED_INT_KINDS@' \
'@LIBGOMP_CHECKED_REAL_KINDS@' \
'$(FCCOMPILE)' '@USE_IEC_60559@' > $@ || rm $@
kinds.inc: kinds.h $(srcdir)/kinds-override.h
cat kinds.h $(srcdir)/kinds-override.h | grep '^#' | grep -v include > $@

View File

@ -664,6 +664,7 @@ SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_IEC_60559 = @USE_IEC_60559@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
@ -7674,7 +7675,9 @@ ieee_arithmetic.mod: ieee_arithmetic.lo
@onestep_TRUE@ $(LTCOMPILE) -c -o $@ $^ -combine
kinds.h: $(srcdir)/mk-kinds-h.sh
$(SHELL) $(srcdir)/mk-kinds-h.sh '@LIBGOMP_CHECKED_INT_KINDS@' '@LIBGOMP_CHECKED_REAL_KINDS@' '$(FCCOMPILE)' > $@ || rm $@
$(SHELL) $(srcdir)/mk-kinds-h.sh '@LIBGOMP_CHECKED_INT_KINDS@' \
'@LIBGOMP_CHECKED_REAL_KINDS@' \
'$(FCCOMPILE)' '@USE_IEC_60559@' > $@ || rm $@
kinds.inc: kinds.h $(srcdir)/kinds-override.h
cat kinds.h $(srcdir)/kinds-override.h | grep '^#' | grep -v include > $@

View File

@ -264,31 +264,35 @@ __mingw_snprintf (NULL, 0, "%d\n", 1);
dnl Check whether we have a __float128 type
AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
LIBQUADSPEC=
LIBQUADLIB=
LIBQUADLIB_DEP=
LIBQUADINCLUDE=
USE_IEC_60559=no
if test "x$enable_libquadmath_support" != xno; then
AC_CACHE_CHECK([whether we have a usable __float128 type],
AC_CACHE_CHECK([whether we have a usable _Float128 type],
libgfor_cv_have_float128, [
GCC_TRY_COMPILE_OR_LINK([
typedef _Complex float __attribute__((mode(TC))) __complex128;
__float128 foo (__float128 x)
_Float128 foo (_Float128 x)
{
__complex128 z1, z2;
_Complex _Float128 z1, z2;
z1 = x;
z2 = x / 7.Q;
z2 = x / 7.F128;
z2 /= z1;
return (__float128) z2;
return (_Float128) z2;
}
__float128 bar (__float128 x)
_Float128 bar (_Float128 x)
{
return x * __builtin_huge_valq ();
return x * __builtin_huge_valf128 ();
}
],[
foo (1.2F128);
bar (1.2F128);
foo (1.2Q);
bar (1.2Q);
],[
@ -297,8 +301,16 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
libgfor_cv_have_float128=no
])])
if test "x$have_iec_60559_libc_support$enable_libquadmath_support$libgfor_cv_have_float128" = xyesdefaultyes; then
USE_IEC_60559=yes
fi
if test "x$libgfor_cv_have_float128" = xyes; then
AC_DEFINE(HAVE_FLOAT128, 1, [Define if have a usable __float128 type.])
if test "x$USE_IEC_60559" = xyes; then
AC_DEFINE(USE_IEC_60559, 1, [Define if IEC 60559 *f128 APIs should be used for _Float128.])
fi
AC_DEFINE(HAVE_FLOAT128, 1, [Define if have a usable _Float128 type.])
dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
dnl
@ -339,26 +351,30 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
])
dnl For static libgfortran linkage, depend on libquadmath only if needed.
dnl If using *f128 APIs from libc/libm, depend on libquadmath only if needed
dnl even for dynamic libgfortran linkage, and don't link libgfortran against
dnl -lquadmath.
if test "x$libgfor_cv_have_as_needed" = xyes; then
LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
if test "x$USE_IEC_60559" = xyes; then
LIBQUADSPEC="$libgfor_cv_as_needed_option -lquadmath $libgfor_cv_no_as_needed_option"
else
LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
fi
else
LIBQUADSPEC="-lquadmath"
fi
if test -f ../libquadmath/libquadmath.la; then
LIBQUADLIB=../libquadmath/libquadmath.la
LIBQUADLIB_DEP=../libquadmath/libquadmath.la
LIBQUADINCLUDE='-I$(srcdir)/../libquadmath'
else
LIBQUADLIB="-lquadmath"
LIBQUADLIB_DEP=
LIBQUADINCLUDE=
if test "x$USE_IEC_60559" != xyes; then
if test -f ../libquadmath/libquadmath.la; then
LIBQUADLIB=../libquadmath/libquadmath.la
LIBQUADLIB_DEP=../libquadmath/libquadmath.la
LIBQUADINCLUDE='-I$(srcdir)/../libquadmath'
else
LIBQUADLIB="-lquadmath"
fi
fi
fi
else
# for --disable-quadmath
LIBQUADLIB=
LIBQUADLIB_DEP=
LIBQUADINCLUDE=
USE_IEC_60559=no
fi
fi
dnl For the spec file
@ -366,9 +382,7 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
AC_SUBST(LIBQUADLIB)
AC_SUBST(LIBQUADLIB_DEP)
AC_SUBST(LIBQUADINCLUDE)
dnl We need a conditional for the Makefile
AM_CONDITIONAL(LIBGFOR_BUILD_QUAD, [test "x$libgfor_cv_have_float128" = xyes])
AC_SUBST(USE_IEC_60559)
])

View File

@ -478,12 +478,11 @@ convert_type (void *dst, int dst_type, int dst_kind, void *src, int src_type,
typedef long double real128t;
typedef _Complex long double complex128t;
#elif defined(HAVE_GFC_REAL_16)
typedef _Complex float __attribute__((mode(TC))) __complex128;
typedef __float128 real128t;
typedef __complex128 complex128t;
typedef _Float128 real128t;
typedef _Complex _Float128 complex128t;
#elif defined(HAVE_GFC_REAL_10)
typedef long double real128t;
typedef long double complex128t;
typedef _Complex long double complex128t;
#else
typedef double real128t;
typedef _Complex double complex128t;

View File

@ -12,12 +12,18 @@
/* Define to 1 if you have the `acosf' function. */
#undef HAVE_ACOSF
/* Define to 1 if you have the `acosf128' function. */
#undef HAVE_ACOSF128
/* Define to 1 if you have the `acosh' function. */
#undef HAVE_ACOSH
/* Define to 1 if you have the `acoshf' function. */
#undef HAVE_ACOSHF
/* Define to 1 if you have the `acoshf128' function. */
#undef HAVE_ACOSHF128
/* Define to 1 if you have the `acoshl' function. */
#undef HAVE_ACOSHL
@ -33,12 +39,18 @@
/* Define to 1 if you have the `asinf' function. */
#undef HAVE_ASINF
/* Define to 1 if you have the `asinf128' function. */
#undef HAVE_ASINF128
/* Define to 1 if you have the `asinh' function. */
#undef HAVE_ASINH
/* Define to 1 if you have the `asinhf' function. */
#undef HAVE_ASINHF
/* Define to 1 if you have the `asinhf128' function. */
#undef HAVE_ASINHF128
/* Define to 1 if you have the `asinhl' function. */
#undef HAVE_ASINHL
@ -54,18 +66,27 @@
/* Define to 1 if you have the `atan2f' function. */
#undef HAVE_ATAN2F
/* Define to 1 if you have the `atan2f128' function. */
#undef HAVE_ATAN2F128
/* Define to 1 if you have the `atan2l' function. */
#undef HAVE_ATAN2L
/* Define to 1 if you have the `atanf' function. */
#undef HAVE_ATANF
/* Define to 1 if you have the `atanf128' function. */
#undef HAVE_ATANF128
/* Define to 1 if you have the `atanh' function. */
#undef HAVE_ATANH
/* Define to 1 if you have the `atanhf' function. */
#undef HAVE_ATANHF
/* Define to 1 if you have the `atanhf128' function. */
#undef HAVE_ATANHF128
/* Define to 1 if you have the `atanhl' function. */
#undef HAVE_ATANHL
@ -99,6 +120,9 @@
/* Define to 1 if you have the `cabsf' function. */
#undef HAVE_CABSF
/* Define to 1 if you have the `cabsf128' function. */
#undef HAVE_CABSF128
/* Define to 1 if you have the `cabsl' function. */
#undef HAVE_CABSL
@ -108,12 +132,18 @@
/* Define to 1 if you have the `cacosf' function. */
#undef HAVE_CACOSF
/* Define to 1 if you have the `cacosf128' function. */
#undef HAVE_CACOSF128
/* Define to 1 if you have the `cacosh' function. */
#undef HAVE_CACOSH
/* Define to 1 if you have the `cacoshf' function. */
#undef HAVE_CACOSHF
/* Define to 1 if you have the `cacoshf128' function. */
#undef HAVE_CACOSHF128
/* Define to 1 if you have the `cacoshl' function. */
#undef HAVE_CACOSHL
@ -126,6 +156,9 @@
/* Define to 1 if you have the `cargf' function. */
#undef HAVE_CARGF
/* Define to 1 if you have the `cargf128' function. */
#undef HAVE_CARGF128
/* Define to 1 if you have the `cargl' function. */
#undef HAVE_CARGL
@ -135,12 +168,18 @@
/* Define to 1 if you have the `casinf' function. */
#undef HAVE_CASINF
/* Define to 1 if you have the `casinf128' function. */
#undef HAVE_CASINF128
/* Define to 1 if you have the `casinh' function. */
#undef HAVE_CASINH
/* Define to 1 if you have the `casinhf' function. */
#undef HAVE_CASINHF
/* Define to 1 if you have the `casinhf128' function. */
#undef HAVE_CASINHF128
/* Define to 1 if you have the `casinhl' function. */
#undef HAVE_CASINHL
@ -153,12 +192,18 @@
/* Define to 1 if you have the `catanf' function. */
#undef HAVE_CATANF
/* Define to 1 if you have the `catanf128' function. */
#undef HAVE_CATANF128
/* Define to 1 if you have the `catanh' function. */
#undef HAVE_CATANH
/* Define to 1 if you have the `catanhf' function. */
#undef HAVE_CATANHF
/* Define to 1 if you have the `catanhf128' function. */
#undef HAVE_CATANHF128
/* Define to 1 if you have the `catanhl' function. */
#undef HAVE_CATANHL
@ -171,12 +216,18 @@
/* Define to 1 if you have the `ccosf' function. */
#undef HAVE_CCOSF
/* Define to 1 if you have the `ccosf128' function. */
#undef HAVE_CCOSF128
/* Define to 1 if you have the `ccosh' function. */
#undef HAVE_CCOSH
/* Define to 1 if you have the `ccoshf' function. */
#undef HAVE_CCOSHF
/* Define to 1 if you have the `ccoshf128' function. */
#undef HAVE_CCOSHF128
/* Define to 1 if you have the `ccoshl' function. */
#undef HAVE_CCOSHL
@ -189,6 +240,9 @@
/* Define to 1 if you have the `ceilf' function. */
#undef HAVE_CEILF
/* Define to 1 if you have the `ceilf128' function. */
#undef HAVE_CEILF128
/* Define to 1 if you have the `ceill' function. */
#undef HAVE_CEILL
@ -198,6 +252,9 @@
/* Define to 1 if you have the `cexpf' function. */
#undef HAVE_CEXPF
/* Define to 1 if you have the `cexpf128' function. */
#undef HAVE_CEXPF128
/* Define to 1 if you have the `cexpl' function. */
#undef HAVE_CEXPL
@ -222,12 +279,18 @@
/* Define to 1 if you have the `clog10f' function. */
#undef HAVE_CLOG10F
/* Define to 1 if you have the `clog10f128' function. */
#undef HAVE_CLOG10F128
/* Define to 1 if you have the `clog10l' function. */
#undef HAVE_CLOG10L
/* Define to 1 if you have the `clogf' function. */
#undef HAVE_CLOGF
/* Define to 1 if you have the `clogf128' function. */
#undef HAVE_CLOGF128
/* Define to 1 if you have the `clogl' function. */
#undef HAVE_CLOGL
@ -240,6 +303,9 @@
/* Define to 1 if you have the `copysignf' function. */
#undef HAVE_COPYSIGNF
/* Define to 1 if you have the `copysignf128' function. */
#undef HAVE_COPYSIGNF128
/* Define to 1 if you have the `copysignl' function. */
#undef HAVE_COPYSIGNL
@ -249,12 +315,18 @@
/* Define to 1 if you have the `cosf' function. */
#undef HAVE_COSF
/* Define to 1 if you have the `cosf128' function. */
#undef HAVE_COSF128
/* Define to 1 if you have the `cosh' function. */
#undef HAVE_COSH
/* Define to 1 if you have the `coshf' function. */
#undef HAVE_COSHF
/* Define to 1 if you have the `coshf128' function. */
#undef HAVE_COSHF128
/* Define to 1 if you have the `coshl' function. */
#undef HAVE_COSHL
@ -267,6 +339,9 @@
/* Define to 1 if you have the `cpowf' function. */
#undef HAVE_CPOWF
/* Define to 1 if you have the `cpowf128' function. */
#undef HAVE_CPOWF128
/* Define to 1 if you have the `cpowl' function. */
#undef HAVE_CPOWL
@ -279,12 +354,18 @@
/* Define to 1 if you have the `csinf' function. */
#undef HAVE_CSINF
/* Define to 1 if you have the `csinf128' function. */
#undef HAVE_CSINF128
/* Define to 1 if you have the `csinh' function. */
#undef HAVE_CSINH
/* Define to 1 if you have the `csinhf' function. */
#undef HAVE_CSINHF
/* Define to 1 if you have the `csinhf128' function. */
#undef HAVE_CSINHF128
/* Define to 1 if you have the `csinhl' function. */
#undef HAVE_CSINHL
@ -297,6 +378,9 @@
/* Define to 1 if you have the `csqrtf' function. */
#undef HAVE_CSQRTF
/* Define to 1 if you have the `csqrtf128' function. */
#undef HAVE_CSQRTF128
/* Define to 1 if you have the `csqrtl' function. */
#undef HAVE_CSQRTL
@ -306,12 +390,18 @@
/* Define to 1 if you have the `ctanf' function. */
#undef HAVE_CTANF
/* Define to 1 if you have the `ctanf128' function. */
#undef HAVE_CTANF128
/* Define to 1 if you have the `ctanh' function. */
#undef HAVE_CTANH
/* Define to 1 if you have the `ctanhf' function. */
#undef HAVE_CTANHF
/* Define to 1 if you have the `ctanhf128' function. */
#undef HAVE_CTANHF128
/* Define to 1 if you have the `ctanhl' function. */
#undef HAVE_CTANHL
@ -333,18 +423,27 @@
/* Define to 1 if you have the `erfcf' function. */
#undef HAVE_ERFCF
/* Define to 1 if you have the `erfcf128' function. */
#undef HAVE_ERFCF128
/* Define to 1 if you have the `erfcl' function. */
#undef HAVE_ERFCL
/* Define to 1 if you have the `erff' function. */
#undef HAVE_ERFF
/* Define to 1 if you have the `erff128' function. */
#undef HAVE_ERFF128
/* Define to 1 if you have the `exp' function. */
#undef HAVE_EXP
/* Define to 1 if you have the `expf' function. */
#undef HAVE_EXPF
/* Define to 1 if you have the `expf128' function. */
#undef HAVE_EXPF128
/* Define to 1 if you have the `expl' function. */
#undef HAVE_EXPL
@ -354,6 +453,9 @@
/* Define to 1 if you have the `fabsf' function. */
#undef HAVE_FABSF
/* Define to 1 if you have the `fabsf128' function. */
#undef HAVE_FABSF128
/* Define to 1 if you have the `fabsl' function. */
#undef HAVE_FABSL
@ -366,7 +468,7 @@
/* Define to 1 if you have the <fenv.h> header file. */
#undef HAVE_FENV_H
/* Define if have a usable __float128 type. */
/* Define if have a usable _Float128 type. */
#undef HAVE_FLOAT128
/* Define to 1 if you have the <floatingpoint.h> header file. */
@ -378,6 +480,9 @@
/* Define to 1 if you have the `floorf' function. */
#undef HAVE_FLOORF
/* Define to 1 if you have the `floorf128' function. */
#undef HAVE_FLOORF128
/* Define to 1 if you have the `floorl' function. */
#undef HAVE_FLOORL
@ -393,6 +498,9 @@
/* Define to 1 if you have the `fmaf' function. */
#undef HAVE_FMAF
/* Define to 1 if you have the `fmaf128' function. */
#undef HAVE_FMAF128
/* Define to 1 if you have the `fmal' function. */
#undef HAVE_FMAL
@ -402,6 +510,9 @@
/* Define to 1 if you have the `fmodf' function. */
#undef HAVE_FMODF
/* Define to 1 if you have the `fmodf128' function. */
#undef HAVE_FMODF128
/* Define to 1 if you have the `fmodl' function. */
#undef HAVE_FMODL
@ -450,6 +561,9 @@
/* Define to 1 if you have the `frexpf' function. */
#undef HAVE_FREXPF
/* Define to 1 if you have the `frexpf128' function. */
#undef HAVE_FREXPF128
/* Define to 1 if you have the `frexpl' function. */
#undef HAVE_FREXPL
@ -507,6 +621,9 @@
/* Define to 1 if you have the `hypotf' function. */
#undef HAVE_HYPOTF
/* Define to 1 if you have the `hypotf128' function. */
#undef HAVE_HYPOTF128
/* Define to 1 if you have the `hypotl' function. */
#undef HAVE_HYPOTL
@ -537,18 +654,27 @@
/* Define to 1 if you have the `j0f' function. */
#undef HAVE_J0F
/* Define to 1 if you have the `j0f128' function. */
#undef HAVE_J0F128
/* Define to 1 if you have the `j1' function. */
#undef HAVE_J1
/* Define to 1 if you have the `j1f' function. */
#undef HAVE_J1F
/* Define to 1 if you have the `j1f128' function. */
#undef HAVE_J1F128
/* Define to 1 if you have the `jn' function. */
#undef HAVE_JN
/* Define to 1 if you have the `jnf' function. */
#undef HAVE_JNF
/* Define to 1 if you have the `jnf128' function. */
#undef HAVE_JNF128
/* Define to 1 if you have the `jnl' function. */
#undef HAVE_JNL
@ -561,6 +687,9 @@
/* Define to 1 if you have the `ldexpf' function. */
#undef HAVE_LDEXPF
/* Define to 1 if you have the `ldexpf128' function. */
#undef HAVE_LDEXPF128
/* Define to 1 if you have the `ldexpl' function. */
#undef HAVE_LDEXPL
@ -570,6 +699,9 @@
/* Define to 1 if you have the `lgammaf' function. */
#undef HAVE_LGAMMAF
/* Define to 1 if you have the `lgammaf128' function. */
#undef HAVE_LGAMMAF128
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
@ -582,6 +714,9 @@
/* Define to 1 if you have the `llroundf' function. */
#undef HAVE_LLROUNDF
/* Define to 1 if you have the `llroundf128' function. */
#undef HAVE_LLROUNDF128
/* Define to 1 if you have the `llroundl' function. */
#undef HAVE_LLROUNDL
@ -597,12 +732,18 @@
/* Define to 1 if you have the `log10f' function. */
#undef HAVE_LOG10F
/* Define to 1 if you have the `log10f128' function. */
#undef HAVE_LOG10F128
/* Define to 1 if you have the `log10l' function. */
#undef HAVE_LOG10L
/* Define to 1 if you have the `logf' function. */
#undef HAVE_LOGF
/* Define to 1 if you have the `logf128' function. */
#undef HAVE_LOGF128
/* Define to 1 if you have the `logl' function. */
#undef HAVE_LOGL
@ -612,6 +753,9 @@
/* Define to 1 if you have the `lroundf' function. */
#undef HAVE_LROUNDF
/* Define to 1 if you have the `lroundf128' function. */
#undef HAVE_LROUNDF128
/* Define to 1 if you have the `lroundl' function. */
#undef HAVE_LROUNDL
@ -642,6 +786,9 @@
/* Define to 1 if you have the `nextafterf' function. */
#undef HAVE_NEXTAFTERF
/* Define to 1 if you have the `nextafterf128' function. */
#undef HAVE_NEXTAFTERF128
/* Define to 1 if you have the `nextafterl' function. */
#undef HAVE_NEXTAFTERL
@ -657,6 +804,9 @@
/* Define to 1 if you have the `powf' function. */
#undef HAVE_POWF
/* Define to 1 if you have the `powf128' function. */
#undef HAVE_POWF128
/* Define to 1 if the system has the type `ptrdiff_t'. */
#undef HAVE_PTRDIFF_T
@ -672,6 +822,9 @@
/* Define to 1 if you have the `roundf' function. */
#undef HAVE_ROUNDF
/* Define to 1 if you have the `roundf128' function. */
#undef HAVE_ROUNDF128
/* Define to 1 if you have the `roundl' function. */
#undef HAVE_ROUNDL
@ -681,6 +834,9 @@
/* Define to 1 if you have the `scalbnf' function. */
#undef HAVE_SCALBNF
/* Define to 1 if you have the `scalbnf128' function. */
#undef HAVE_SCALBNF128
/* Define to 1 if you have the `scalbnl' function. */
#undef HAVE_SCALBNL
@ -699,12 +855,18 @@
/* Define to 1 if you have the `sinf' function. */
#undef HAVE_SINF
/* Define to 1 if you have the `sinf128' function. */
#undef HAVE_SINF128
/* Define to 1 if you have the `sinh' function. */
#undef HAVE_SINH
/* Define to 1 if you have the `sinhf' function. */
#undef HAVE_SINHF
/* Define to 1 if you have the `sinhf128' function. */
#undef HAVE_SINHF128
/* Define to 1 if you have the `sinhl' function. */
#undef HAVE_SINHL
@ -723,6 +885,9 @@
/* Define to 1 if you have the `sqrtf' function. */
#undef HAVE_SQRTF
/* Define to 1 if you have the `sqrtf128' function. */
#undef HAVE_SQRTF128
/* Define to 1 if you have the `sqrtl' function. */
#undef HAVE_SQRTL
@ -744,6 +909,9 @@
/* Define if strerror_r takes two arguments and is available in <string.h>. */
#undef HAVE_STRERROR_R_2ARGS
/* Define to 1 if you have the `strfromf128' function. */
#undef HAVE_STRFROMF128
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
@ -759,6 +927,9 @@
/* Define to 1 if you have the `strtof' function. */
#undef HAVE_STRTOF
/* Define to 1 if you have the `strtof128' function. */
#undef HAVE_STRTOF128
/* Define to 1 if you have the `strtold' function. */
#undef HAVE_STRTOLD
@ -804,12 +975,18 @@
/* Define to 1 if you have the `tanf' function. */
#undef HAVE_TANF
/* Define to 1 if you have the `tanf128' function. */
#undef HAVE_TANF128
/* Define to 1 if you have the `tanh' function. */
#undef HAVE_TANH
/* Define to 1 if you have the `tanhf' function. */
#undef HAVE_TANHF
/* Define to 1 if you have the `tanhf128' function. */
#undef HAVE_TANHF128
/* Define to 1 if you have the `tanhl' function. */
#undef HAVE_TANHL
@ -822,6 +999,9 @@
/* Define to 1 if you have the `tgammaf' function. */
#undef HAVE_TGAMMAF
/* Define to 1 if you have the `tgammaf128' function. */
#undef HAVE_TGAMMAF128
/* Define to 1 if you have the `times' function. */
#undef HAVE_TIMES
@ -831,6 +1011,9 @@
/* Define to 1 if you have the `truncf' function. */
#undef HAVE_TRUNCF
/* Define to 1 if you have the `truncf128' function. */
#undef HAVE_TRUNCF128
/* Define to 1 if you have the `truncl' function. */
#undef HAVE_TRUNCL
@ -876,18 +1059,27 @@
/* Define to 1 if you have the `y0f' function. */
#undef HAVE_Y0F
/* Define to 1 if you have the `y0f128' function. */
#undef HAVE_Y0F128
/* Define to 1 if you have the `y1' function. */
#undef HAVE_Y1
/* Define to 1 if you have the `y1f' function. */
#undef HAVE_Y1F
/* Define to 1 if you have the `y1f128' function. */
#undef HAVE_Y1F128
/* Define to 1 if you have the `yn' function. */
#undef HAVE_YN
/* Define to 1 if you have the `ynf' function. */
#undef HAVE_YNF
/* Define to 1 if you have the `ynf128' function. */
#undef HAVE_YNF128
/* Define to 1 if you have the `ynl' function. */
#undef HAVE_YNL
@ -1006,6 +1198,9 @@
/* Define to 1 if the target supports weakref */
#undef SUPPORTS_WEAKREF
/* Define if IEC 60559 *f128 APIs should be used for _Float128. */
#undef USE_IEC_60559
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE

3099
libgfortran/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -356,7 +356,7 @@ else
getcwd localtime_r gmtime_r getpwuid_r ttyname_r clock_gettime \
getgid getpid getuid geteuid umask getegid \
secure_getenv __secure_getenv mkostemp strnlen strndup newlocale \
freelocale uselocale strerror_l)
freelocale uselocale strerror_l strtof128 strfromf128)
fi
# Check strerror_r, cannot be above as versions with two and three arguments exist
@ -582,24 +582,101 @@ GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2([copysignl], [long double])
GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([fabs], [double])
GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([fabsl], [long double])
GCC_CHECK_MATH_FUNC([acosf128])
GCC_CHECK_MATH_FUNC([acoshf128])
GCC_CHECK_MATH_FUNC([asinf128])
GCC_CHECK_MATH_FUNC([asinhf128])
GCC_CHECK_MATH_FUNC([atan2f128])
GCC_CHECK_MATH_FUNC([atanf128])
GCC_CHECK_MATH_FUNC([atanhf128])
GCC_CHECK_MATH_FUNC([cargf128])
GCC_CHECK_MATH_FUNC([ceilf128])
GCC_CHECK_MATH_FUNC([copysignf128])
GCC_CHECK_MATH_FUNC([cosf128])
GCC_CHECK_MATH_FUNC([ccosf128])
GCC_CHECK_MATH_FUNC([coshf128])
GCC_CHECK_MATH_FUNC([ccoshf128])
GCC_CHECK_MATH_FUNC([expf128])
GCC_CHECK_MATH_FUNC([cexpf128])
GCC_CHECK_MATH_FUNC([fabsf128])
GCC_CHECK_MATH_FUNC([cabsf128])
GCC_CHECK_MATH_FUNC([floorf128])
GCC_CHECK_MATH_FUNC([fmaf128])
GCC_CHECK_MATH_FUNC([fmodf128])
GCC_CHECK_MATH_FUNC([frexpf128])
GCC_CHECK_MATH_FUNC([hypotf128])
GCC_CHECK_MATH_FUNC([ldexpf128])
GCC_CHECK_MATH_FUNC([logf128])
GCC_CHECK_MATH_FUNC([clogf128])
GCC_CHECK_MATH_FUNC([log10f128])
GCC_CHECK_MATH_FUNC([clog10f128])
GCC_CHECK_MATH_FUNC([nextafterf128])
GCC_CHECK_MATH_FUNC([powf128])
GCC_CHECK_MATH_FUNC([cpowf128])
GCC_CHECK_MATH_FUNC([roundf128])
GCC_CHECK_MATH_FUNC([lroundf128])
GCC_CHECK_MATH_FUNC([llroundf128])
GCC_CHECK_MATH_FUNC([scalbnf128])
GCC_CHECK_MATH_FUNC([sinf128])
GCC_CHECK_MATH_FUNC([csinf128])
GCC_CHECK_MATH_FUNC([sinhf128])
GCC_CHECK_MATH_FUNC([csinhf128])
GCC_CHECK_MATH_FUNC([sqrtf128])
GCC_CHECK_MATH_FUNC([csqrtf128])
GCC_CHECK_MATH_FUNC([tanf128])
GCC_CHECK_MATH_FUNC([ctanf128])
GCC_CHECK_MATH_FUNC([tanhf128])
GCC_CHECK_MATH_FUNC([ctanhf128])
GCC_CHECK_MATH_FUNC([truncf128])
GCC_CHECK_MATH_FUNC([erff128])
GCC_CHECK_MATH_FUNC([erfcf128])
GCC_CHECK_MATH_FUNC([j0f128])
GCC_CHECK_MATH_FUNC([j1f128])
GCC_CHECK_MATH_FUNC([jnf128])
GCC_CHECK_MATH_FUNC([y0f128])
GCC_CHECK_MATH_FUNC([y1f128])
GCC_CHECK_MATH_FUNC([ynf128])
GCC_CHECK_MATH_FUNC([tgammaf128])
GCC_CHECK_MATH_FUNC([lgammaf128])
GCC_CHECK_MATH_FUNC([cacosf128])
GCC_CHECK_MATH_FUNC([cacoshf128])
GCC_CHECK_MATH_FUNC([casinf128])
GCC_CHECK_MATH_FUNC([casinhf128])
GCC_CHECK_MATH_FUNC([catanf128])
GCC_CHECK_MATH_FUNC([catanhf128])
# Check whether the system has a working stat()
LIBGFOR_CHECK_WORKING_STAT
# Check whether __mingw_snprintf() is present
LIBGFOR_CHECK_MINGW_SNPRINTF
have_iec_60559_libc_support=no
if test "x$ac_cv_func_strtof128$ac_cv_func_strfromf128" = xyesyes \
&& test "x$gcc_cv_math_func_sinf128$gcc_cv_math_func_cacosf128" = xyesyes; then
have_iec_60559_libc_support=yes
fi
# Check whether libquadmath should be used
AC_ARG_ENABLE(libquadmath-support,
AS_HELP_STRING([--disable-libquadmath-support],
[disable libquadmath support for Fortran]),
ENABLE_LIBQUADMATH_SUPPORT=$enableval,
ENABLE_LIBQUADMATH_SUPPORT=yes)
if test "x$have_iec_60559_libc_support" = xyes; then
ENABLE_LIBQUADMATH_SUPPORT=default
else
ENABLE_LIBQUADMATH_SUPPORT=yes
fi)
enable_libquadmath_support=
if test "${ENABLE_LIBQUADMATH_SUPPORT}" = "no" ; then
enable_libquadmath_support=no
elif test "${ENABLE_LIBQUADMATH_SUPPORT}" = "default" ; then
enable_libquadmath_support=default
fi
# Check whether we have a __float128 type, depends on enable_libquadmath_support
# Check whether we have a _Float128 type, depends on enable_libquadmath_support
# and have_iec_60559_libc_support.
LIBGFOR_CHECK_FLOAT128
# Check for GNU libc feenableexcept

View File

@ -29,7 +29,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined(GFC_REAL_16_IS_FLOAT128)
#if defined(GFC_REAL_16_USE_IEC_60559)
#define MATHFUNC(funcname) funcname ## f128
#else
#define MATHFUNC(funcname) funcname ## q
#endif
#else
#define MATHFUNC(funcname) funcname ## l
#endif

View File

@ -30,6 +30,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined(POWER_IEEE128)
#define MATHFUNC(funcname) __ ## funcname ## ieee128
#elif defined(GFC_REAL_17_USE_IEC_60559)
#define MATHFUNC(funcname) funcname ## f128
#else
#define MATHFUNC(funcname) funcname ## q
#endif

View File

@ -30,7 +30,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_REAL_16) && (defined(GFC_REAL_16_IS_FLOAT128) || defined(HAVE_SQRTL)) && (defined(GFC_REAL_16_IS_FLOAT128) || defined(HAVE_FABSL))
#if defined(GFC_REAL_16_IS_FLOAT128)
#if defined(GFC_REAL_16_USE_IEC_60559)
#define MATHFUNC(funcname) funcname ## f128
#else
#define MATHFUNC(funcname) funcname ## q
#endif
#else
#define MATHFUNC(funcname) funcname ## l
#endif

View File

@ -31,6 +31,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined(POWER_IEEE128)
#define MATHFUNC(funcname) __ ## funcname ## ieee128
#elif defined(GFC_REAL_17_USE_IEC_60559)
#define MATHFUNC(funcname) funcname ## f128
#else
#define MATHFUNC(funcname) funcname ## q
#endif

View File

@ -197,11 +197,11 @@ __issignalingl (long double x)
#if defined(GFC_REAL_16_IS_FLOAT128)
/* We have a __float128 type. */
/* We have a _Float128 type. */
typedef union
{
__float128 value;
_Float128 value;
struct
{
#if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
@ -215,7 +215,7 @@ typedef union
} ieee854_float128_shape_type;
static inline int
__issignalingf128 (__float128 x)
__issignalingf128 (_Float128 x)
{
uint64_t hxi, lxi;
ieee854_float128_shape_type u;
@ -237,7 +237,7 @@ __issignalingf128 (__float128 x)
#if defined(GFC_REAL_16_IS_FLOAT128)
# define issignaling(X) \
_Generic ((X), \
__float128: __issignalingf128, \
_Float128: __issignalingf128, \
float: __issignalingf, \
double: __issignaling, \
long double: __issignalingl)(X)

View File

@ -132,7 +132,7 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -162,7 +162,7 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)

View File

@ -52,11 +52,19 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#ifdef GFC_REAL_16_IS_FLOAT128
# define _THRESH -106.566990228185312813205074546585730Q
# define _M_2_SQRTPI M_2_SQRTPIq
# define _INF __builtin_infq()
# define _ERFC(x) erfcq(x)
# define _EXP(x) expq(x)
# ifdef GFC_REAL_16_USE_IEC_60559
# define _THRESH -106.566990228185312813205074546585730F128
# define _M_2_SQRTPI M_2_SQRTPIf128
# define _INF __builtin_inff128()
# define _ERFC(x) erfcf128(x)
# define _EXP(x) expf128(x)
# else
# define _THRESH -106.566990228185312813205074546585730Q
# define _M_2_SQRTPI M_2_SQRTPIq
# define _INF __builtin_infq()
# define _ERFC(x) erfcq(x)
# define _EXP(x) expq(x)
# endif
#else
@ -139,12 +147,15 @@ ERFC_SCALED(16)
/* For quadruple-precision, netlib's implementation is
not accurate enough. We provide another one. */
# define _THRESH -106.566990228185312813205074546585730Q
# define _M_2_SQRTPI M_2_SQRTPIq
# define _THRESH GFC_REAL_17_LITERAL(-106.566990228185312813205074546585730)
# define _M_2_SQRTPI GFC_REAL_17_LITERAL(M_2_SQRTPI)
# define _INF __builtin_inff128()
# ifdef POWER_IEEE128
# define _ERFC(x) __erfcieee128(x)
# define _EXP(x) __expieee128(x)
# elif defined(GFC_REAL_17_USE_IEC_60559)
# define _ERFC(x) erfcf128(x)
# define _EXP(x) expf128(x)
# else
# define _ERFC(x) erfcq(x)
# define _EXP(x) expq(x)

View File

@ -307,7 +307,7 @@ pack (gfc_array_char *ret, const gfc_array_char *array,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -339,7 +339,7 @@ pack (gfc_array_char *ret, const gfc_array_char *array,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)

View File

@ -320,7 +320,7 @@ spread (gfc_array_char *ret, const gfc_array_char *source,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -352,7 +352,7 @@ spread (gfc_array_char *ret, const gfc_array_char *source,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -524,7 +524,7 @@ spread_scalar (gfc_array_char *ret, const char *source,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -556,7 +556,7 @@ spread_scalar (gfc_array_char *ret, const char *source,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)

View File

@ -261,6 +261,24 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#endif /* HAVE_FABSL && HAVE_FMODL && HAVE_COPYSIGNL */
#elif defined(GFC_REAL_16_USE_IEC_60559)
#if defined(HAVE_FABSF128) && defined(HAVE_FMODF128) && defined(HAVE_COPYSIGNF128)
#ifdef HAVE_SINF128
#define ENABLE_SIND
#endif
#ifdef HAVE_COSF128
#define ENABLE_COSD
#endif
#ifdef HAVE_TANF128
#define ENABLE_TAND
#endif
#endif /* HAVE_FABSF128 && HAVE_FMODF128 && HAVE_COPYSIGNF128 */
#else
/* libquadmath: HAVE_*Q are never defined. They must be available. */

View File

@ -265,7 +265,7 @@ unpack1 (gfc_array_char *ret, const gfc_array_char *vector,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -297,7 +297,7 @@ unpack1 (gfc_array_char *ret, const gfc_array_char *vector,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -486,7 +486,7 @@ unpack0 (gfc_array_char *ret, const gfc_array_char *vector,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -518,7 +518,7 @@ unpack0 (gfc_array_char *ret, const gfc_array_char *vector,
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)

View File

@ -186,7 +186,11 @@ convert_real (st_parameter_dt *dtp, void *dest, const char *buffer, int length)
#if defined(HAVE_GFC_REAL_16)
# if defined(GFC_REAL_16_IS_FLOAT128)
case 16:
# if defined(GFC_REAL_16_USE_IEC_60559)
*((GFC_REAL_16*) dest) = strtof128 (buffer, &endptr);
# else
*((GFC_REAL_16*) dest) = __qmath_(strtoflt128) (buffer, &endptr);
# endif
break;
# elif defined(HAVE_STRTOLD)
case 16:
@ -199,6 +203,8 @@ convert_real (st_parameter_dt *dtp, void *dest, const char *buffer, int length)
case 17:
# if defined(POWER_IEEE128)
*((GFC_REAL_17*) dest) = __strtoieee128 (buffer, &endptr);
# elif defined(GFC_REAL_17_USE_IEC_60559)
*((GFC_REAL_17*) dest) = strtof128 (buffer, &endptr);
# else
*((GFC_REAL_17*) dest) = __qmath_(strtoflt128) (buffer, &endptr);
# endif
@ -272,7 +278,14 @@ convert_infnan (st_parameter_dt *dtp, void *dest, const char *buffer,
#if defined(HAVE_GFC_REAL_16)
# if defined(GFC_REAL_16_IS_FLOAT128)
case 16:
# if defined(GFC_REAL_16_USE_IEC_60559)
if (is_inf)
*((GFC_REAL_16*) dest) = plus ? __builtin_inff128 () : -__builtin_inff128 ();
else
*((GFC_REAL_16*) dest) = plus ? __builtin_nanf128 ("") : -__builtin_nanf128 ("");
# else
*((GFC_REAL_16*) dest) = __qmath_(strtoflt128) (buffer, NULL);
# endif
break;
# else
case 16:

View File

@ -65,7 +65,9 @@ export_proto(transfer_complex128_write);
write_float; the pointer assignment with USED attribute make sure
that there is a non-weakref dependence if the quadmath functions
are used. That avoids segfault when libquadmath is statically linked. */
# if !defined(HAVE_GFC_REAL_17) || !defined(POWER_IEEE128)
# if (defined(HAVE_GFC_REAL_17) && !defined(POWER_IEEE128) \
&& !defined(GFC_REAL_17_USE_IEC_60559)) \
|| (!defined(HAVE_GFC_REAL_17) && !defined(GFC_REAL_16_USE_IEC_60559))
static void __attribute__((used)) *tmp1 = strtoflt128;
static void __attribute__((used)) *tmp2 = quadmath_snprintf;
# endif

View File

@ -837,18 +837,60 @@ snprintf (buffer, size, "%+-#.*e", (prec), (val))
#define DTOA2L(prec,val) \
snprintf (buffer, size, "%+-#.*Le", (prec), (val))
#if defined(GFC_REAL_16_USE_IEC_60559) || defined(GFC_REAL_17_USE_IEC_60559)
/* strfromf128 unfortunately doesn't allow +, - and # modifiers
nor .* (only allows .number). For +, work around it by adding
leading + manually for !signbit values. For - I don't see why
we need it, when we don't specify field minimum width.
For #, add . if it is missing. Assume size is at least 2. */
static int
gfor_strfromf128 (char *buffer, size_t size, int kind, int prec, _Float128 val)
{
int ret, n = 0;
char fmt[sizeof (int) * 3 + 5];
snprintf (fmt, sizeof fmt, "%%.%d%c", prec, kind);
if (!__builtin_signbit (val))
{
n = 1;
buffer[0] = '+';
}
ret = strfromf128 (buffer + n, size - n, fmt, val) + n;
if ((size_t) ret < size - 1)
{
size_t s = strcspn (buffer, ".e");
if (buffer[s] != '.')
{
if (buffer[s] == '\0')
buffer[s + 1] = '\0';
else
memmove (buffer + s + 1, buffer + s, ret + 1 - s);
buffer[s] = '.';
++ret;
}
}
return ret;
}
#endif
#if defined(HAVE_GFC_REAL_17)
# if defined(POWER_IEEE128)
# define DTOA2Q(prec,val) \
__snprintfieee128 (buffer, size, "%+-#.*Le", (prec), (val))
# elif defined(GFC_REAL_17_USE_IEC_60559)
# define DTOA2Q(prec,val) \
gfor_strfromf128 (buffer, size, 'e', (prec), (val))
# else
# define DTOA2Q(prec,val) \
quadmath_snprintf (buffer, size, "%+-#.*Qe", (prec), (val))
# endif
#elif defined(GFC_REAL_16_IS_FLOAT128)
# define DTOA2Q(prec,val) \
# if defined(GFC_REAL_16_USE_IEC_60559)
# define DTOA2Q(prec,val) \
gfor_strfromf128 (buffer, size, 'e', (prec), (val))
# else
# define DTOA2Q(prec,val) \
quadmath_snprintf (buffer, size, "%+-#.*Qe", (prec), (val))
# endif
#endif
#define FDTOA(suff,prec,val) TOKENPASTE(FDTOA2,suff)(prec,val)
@ -865,13 +907,21 @@ snprintf (buffer, size, "%+-#.*Lf", (prec), (val))
# if defined(POWER_IEEE128)
# define FDTOA2Q(prec,val) \
__snprintfieee128 (buffer, size, "%+-#.*Lf", (prec), (val))
# elif defined(GFC_REAL_17_USE_IEC_60559)
# define FDTOA2Q(prec,val) \
gfor_strfromf128 (buffer, size, 'f', (prec), (val))
# else
# define FDTOA2Q(prec,val) \
quadmath_snprintf (buffer, size, "%+-#.*Qf", (prec), (val))
# endif
#elif defined(GFC_REAL_16_IS_FLOAT128)
# define FDTOA2Q(prec,val) \
# if defined(GFC_REAL_16_USE_IEC_60559)
# define FDTOA2Q(prec,val) \
gfor_strfromf128 (buffer, size, 'f', (prec), (val))
# else
# define FDTOA2Q(prec,val) \
quadmath_snprintf (buffer, size, "%+-#.*Qf", (prec), (val))
# endif
#endif

View File

@ -26,18 +26,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Ensure that TFmode is available under. */
#if defined(GFC_REAL_16_IS_FLOAT128) && !defined(HAVE_FLOAT128)
# error "Where has __float128 gone?"
# error "Where has _Float128 gone?"
#endif
/* Keep these conditions on one line so grep can filter it out. */
#if defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_LONG_DOUBLE__ == 16
typedef __float128 GFC_REAL_17;
typedef _Complex float __attribute__((mode(KC))) GFC_COMPLEX_17;
typedef _Float128 GFC_REAL_17;
typedef _Complex _Float128 GFC_COMPLEX_17;
#define HAVE_GFC_REAL_17
#define HAVE_GFC_COMPLEX_17
#define GFC_REAL_17_IS_FLOAT128
#ifdef USE_IEC_60559
#define GFC_REAL_17_USE_IEC_60559
#define GFC_REAL_17_HUGE 1.18973149535723176508575932662800702e4932f128
#define GFC_REAL_17_LITERAL_SUFFIX f128
#define GFC_REAL_17_LITERAL(X) (X ## f128)
#else
#define GFC_REAL_17_HUGE 1.18973149535723176508575932662800702e4932q
#define GFC_REAL_17_LITERAL_SUFFIX q
#define GFC_REAL_17_LITERAL(X) (X ## q)
#endif
#define GFC_REAL_17_DIGITS 113
#define GFC_REAL_17_RADIX 2
#endif

View File

@ -58,8 +58,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* If we're support quad-precision floating-point type, include the
header to our support library. */
#ifdef HAVE_FLOAT128
# include "quadmath_weak.h"
#if defined(HAVE_FLOAT128) && !defined(USE_IEC_60559)
# include "quadmath_weak.h"
#endif
#ifdef __MINGW32__
@ -322,6 +322,8 @@ typedef GFC_UINTEGER_4 gfc_char4_t;
# ifdef HAVE_GFC_REAL_16
# ifdef GFC_REAL_16_IS_LONG_DOUBLE
# define GFC_REAL_16_INFINITY __builtin_infl ()
# elif defined GFC_REAL_16_USE_IEC_60559
# define GFC_REAL_16_INFINITY __builtin_inff128 ()
# else
# define GFC_REAL_16_INFINITY __builtin_infq ()
# endif
@ -343,6 +345,8 @@ typedef GFC_UINTEGER_4 gfc_char4_t;
# ifdef HAVE_GFC_REAL_16
# ifdef GFC_REAL_16_IS_LONG_DOUBLE
# define GFC_REAL_16_QUIET_NAN __builtin_nanl ("")
# elif defined GFC_REAL_16_USE_IEC_60559
# define GFC_REAL_16_QUIET_NAN __builtin_nanf128 ("")
# else
# define GFC_REAL_16_QUIET_NAN nanq ("")
# endif

View File

@ -15,12 +15,18 @@ ifelse(kind,17,`1 /* FIXME: figure this out later. */',dnl
define(mathfunc_macro,`ifelse(kind,17,dnl
`#if defined(POWER_IEEE128)
#define MATHFUNC(funcname) __ ## funcname ## ieee128
#elif defined(GFC_REAL_17_USE_IEC_60559)
#define MATHFUNC(funcname) funcname ## f128
#else
#define MATHFUNC(funcname) funcname ## q
#endif',dnl
`ifelse(kind,16,dnl
`#if defined(GFC_REAL_16_IS_FLOAT128)
#if defined(GFC_REAL_16_USE_IEC_60559)
#define MATHFUNC(funcname) funcname ## f128
#else
#define MATHFUNC(funcname) funcname ## q
#endif
#else
#define MATHFUNC(funcname) funcname ## l
#endif',dnl

View File

@ -2,8 +2,8 @@
LC_ALL=C
export LC_ALL
if test "$#" -ne 3; then
echo "Usage $0 int_kinds real_kinds compile"
if test "$#" -ne 4; then
echo "Usage $0 int_kinds real_kinds compile use_iec_60559"
exit 1
fi
@ -11,6 +11,7 @@ fi
possible_integer_kinds="$1"
possible_real_kinds="$2"
compile="$3"
use_iec_60559="$4"
largest=""
smallest=""
@ -49,7 +50,7 @@ echo ""
# Get the kind value for long double, so we may disambiguate it
# from __float128.
# from _Float128.
echo "use iso_c_binding; print *, c_long_double ; end" > tmq$$.f90
long_double_kind=`$compile -S -fdump-parse-tree tmq$$.f90 | grep TRANSFER \
| sed 's/ *TRANSFER *//'`
@ -68,10 +69,15 @@ for k in $possible_real_kinds; do
10) ctype="long double" ; cplxtype="complex long double" ; suffix="l" ;;
# If we have a REAL(KIND=16), it is either long double or __float128
16) if [ $long_double_kind -ne 16 ]; then
ctype="__float128"
cplxtype="_Complex float __attribute__((mode(TC)))"
suffix="q"
ctype="_Float128"
cplxtype="_Complex _Float128"
echo "#define GFC_REAL_16_IS_FLOAT128"
if [ x$use_iec_60559 = xyes ]; then
suffix="f128"
echo "#define GFC_REAL_16_USE_IEC_60559"
else
suffix="q"
fi
else
ctype="long double"
cplxtype="complex long double"

View File

@ -82,7 +82,7 @@ internal_pack (gfc_array_char * source)
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -106,7 +106,7 @@ internal_pack (gfc_array_char * source)
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)

View File

@ -89,7 +89,7 @@ internal_unpack (gfc_array_char * d, const void * s)
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)
@ -117,7 +117,7 @@ internal_unpack (gfc_array_char * d, const void * s)
/* FIXME: This here is a hack, which will have to be removed when
the array descriptor is reworked. Currently, we don't store the
kind value for the type, but only the size. Because on targets with
__float128, we have sizeof(logn double) == sizeof(__float128),
_Float128, we have sizeof(long double) == sizeof(_Float128),
we cannot discriminate here and have to fall back to the generic
handling (which is suboptimal). */
#if !defined(GFC_REAL_16_IS_FLOAT128)