gcc/libgfortran/kinds-override.h

52 lines
2.0 KiB
C
Raw Normal View History

re PR fortran/32049 (Support on x86_64 also kind=16) / 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * Makefile.def: Add libquadmath; build it with language=fortran. * configure.ac: Add libquadmath. * Makefile.tpl: Handle multiple libs in check-[+language+]. * Makefile.in: Regenerate. * configure: Regenerate. libquadmath/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 Initial implementation and checkin. gcc/fortran/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * gfortranspec.c (find_spec_file): New function. (lang_specific_driver): Try to find .spec file and use it. * trans-io.c (iocall): Define * IOCALL_X_REAL128/COMPLEX128(,write). (gfc_build_io_library_fndecls): Build decl for __float128 I/O. (transfer_expr): Call __float128 I/O functions. * trans-types.c (gfc_init_kinds): Allow kind-16 belonging to __float128. gcc/testsuite/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * gfortran.dg/quad_1.f90: New. * lib/gcc-defs.exp (gcc-set-multilib-library-path): Use also compiler arguments. * lib/gfortran.exp (gfortran_link_flags): Add libquadmath to library search path; call gcc-set-multilib-library-path with arguments such that libgfortran.spec is found. (gfortran_init): Add path for libgfortran.spec to GFORTRAN_UNDER_TEST. libgomp/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * configure.ac: * configure: Regenerate. libgfortran/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * Makefile.am: Add missing pow_r16_i4.c, add transfer128.c, link libquadmath, if used. * acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Add. * configure.ac: Use it, touch spec file. * gfortran.map: Add pow_r16_i4 and transfer_(real,complex)128(,write) functions. * intrinsics/cshift0.c (cshift0): Handle __float128 type. * intrinsics/erfc_scaled_inc.c: Ditto. * intrinsics/pack_generic.c (pack): Ditto * intrinsics/spread_generic.c (spread): Ditto. * intrinsics/unpack_generic.c (unpack1): Ditto. * io/read.c (convert_real): Ditto. * io/transfer.c: Update comments. * io/transfer128.c: New file. * io/write_float.def (write_float): Handle __float128 type. * libgfortran.h: #include quadmath_weak.h, define __builtin_infq and nanq. * m4/mtype.m4: Handle __float128 type. * runtime/in_pack_generic.c (internal_pack): Ditto. * runtime/in_unpack_generic.c (internal_unpack): Ditto. * kinds-override.h: New file. * libgfortran.spec.in: Ditto. * generated/pow_r16_i4.c: Generated. * Makefile.in: Regenerate. * configure: Regenerate. * config.h: Regenerate. * bessel_r10.c: Regenerate. * bessel_r16.c: Regenerate. * bessel_r4.c: Regenerate. * bessel_r8.c: Regenerate. * exponent_r16.c: Regenerate. * fraction_r16.c: Regenerate. * nearest_r16.c: Regenerate. * norm2_r10.c: Regenerate. * norm2_r16.c: Regenerate. * norm2_r4.c: Regenerate. * norm2_r8.c: Regenerate. * rrspacing_r16.c: Regenerate. * set_exponent_r16.c: Regenerate. * spacing_r16.c: Regenerate. Co-Authored-By: Tobias Burnus <burnus@net-b.de> From-SVN: r166825
2010-11-16 21:23:19 +00:00
/* Header used to override things detected by the mk-kinds-h.sh script.
2024-01-03 11:19:35 +00:00
Copyright (C) 2010-2024 Free Software Foundation, Inc.
re PR fortran/32049 (Support on x86_64 also kind=16) / 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * Makefile.def: Add libquadmath; build it with language=fortran. * configure.ac: Add libquadmath. * Makefile.tpl: Handle multiple libs in check-[+language+]. * Makefile.in: Regenerate. * configure: Regenerate. libquadmath/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 Initial implementation and checkin. gcc/fortran/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * gfortranspec.c (find_spec_file): New function. (lang_specific_driver): Try to find .spec file and use it. * trans-io.c (iocall): Define * IOCALL_X_REAL128/COMPLEX128(,write). (gfc_build_io_library_fndecls): Build decl for __float128 I/O. (transfer_expr): Call __float128 I/O functions. * trans-types.c (gfc_init_kinds): Allow kind-16 belonging to __float128. gcc/testsuite/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * gfortran.dg/quad_1.f90: New. * lib/gcc-defs.exp (gcc-set-multilib-library-path): Use also compiler arguments. * lib/gfortran.exp (gfortran_link_flags): Add libquadmath to library search path; call gcc-set-multilib-library-path with arguments such that libgfortran.spec is found. (gfortran_init): Add path for libgfortran.spec to GFORTRAN_UNDER_TEST. libgomp/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * configure.ac: * configure: Regenerate. libgfortran/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * Makefile.am: Add missing pow_r16_i4.c, add transfer128.c, link libquadmath, if used. * acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Add. * configure.ac: Use it, touch spec file. * gfortran.map: Add pow_r16_i4 and transfer_(real,complex)128(,write) functions. * intrinsics/cshift0.c (cshift0): Handle __float128 type. * intrinsics/erfc_scaled_inc.c: Ditto. * intrinsics/pack_generic.c (pack): Ditto * intrinsics/spread_generic.c (spread): Ditto. * intrinsics/unpack_generic.c (unpack1): Ditto. * io/read.c (convert_real): Ditto. * io/transfer.c: Update comments. * io/transfer128.c: New file. * io/write_float.def (write_float): Handle __float128 type. * libgfortran.h: #include quadmath_weak.h, define __builtin_infq and nanq. * m4/mtype.m4: Handle __float128 type. * runtime/in_pack_generic.c (internal_pack): Ditto. * runtime/in_unpack_generic.c (internal_unpack): Ditto. * kinds-override.h: New file. * libgfortran.spec.in: Ditto. * generated/pow_r16_i4.c: Generated. * Makefile.in: Regenerate. * configure: Regenerate. * config.h: Regenerate. * bessel_r10.c: Regenerate. * bessel_r16.c: Regenerate. * bessel_r4.c: Regenerate. * bessel_r8.c: Regenerate. * exponent_r16.c: Regenerate. * fraction_r16.c: Regenerate. * nearest_r16.c: Regenerate. * norm2_r10.c: Regenerate. * norm2_r16.c: Regenerate. * norm2_r4.c: Regenerate. * norm2_r8.c: Regenerate. * rrspacing_r16.c: Regenerate. * set_exponent_r16.c: Regenerate. * spacing_r16.c: Regenerate. Co-Authored-By: Tobias Burnus <burnus@net-b.de> From-SVN: r166825
2010-11-16 21:23:19 +00:00
This file is part of the GNU Fortran runtime library (libgfortran).
Libgfortran 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 3, or (at your option)
any later version.
Libgfortran 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.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Ensure that TFmode is available under. */
#if defined(GFC_REAL_16_IS_FLOAT128) && !defined(HAVE_FLOAT128)
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.
2022-06-28 11:05:28 +00:00
# error "Where has _Float128 gone?"
re PR fortran/32049 (Support on x86_64 also kind=16) / 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * Makefile.def: Add libquadmath; build it with language=fortran. * configure.ac: Add libquadmath. * Makefile.tpl: Handle multiple libs in check-[+language+]. * Makefile.in: Regenerate. * configure: Regenerate. libquadmath/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 Initial implementation and checkin. gcc/fortran/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * gfortranspec.c (find_spec_file): New function. (lang_specific_driver): Try to find .spec file and use it. * trans-io.c (iocall): Define * IOCALL_X_REAL128/COMPLEX128(,write). (gfc_build_io_library_fndecls): Build decl for __float128 I/O. (transfer_expr): Call __float128 I/O functions. * trans-types.c (gfc_init_kinds): Allow kind-16 belonging to __float128. gcc/testsuite/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * gfortran.dg/quad_1.f90: New. * lib/gcc-defs.exp (gcc-set-multilib-library-path): Use also compiler arguments. * lib/gfortran.exp (gfortran_link_flags): Add libquadmath to library search path; call gcc-set-multilib-library-path with arguments such that libgfortran.spec is found. (gfortran_init): Add path for libgfortran.spec to GFORTRAN_UNDER_TEST. libgomp/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * configure.ac: * configure: Regenerate. libgfortran/ 2010-11-13 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32049 * Makefile.am: Add missing pow_r16_i4.c, add transfer128.c, link libquadmath, if used. * acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Add. * configure.ac: Use it, touch spec file. * gfortran.map: Add pow_r16_i4 and transfer_(real,complex)128(,write) functions. * intrinsics/cshift0.c (cshift0): Handle __float128 type. * intrinsics/erfc_scaled_inc.c: Ditto. * intrinsics/pack_generic.c (pack): Ditto * intrinsics/spread_generic.c (spread): Ditto. * intrinsics/unpack_generic.c (unpack1): Ditto. * io/read.c (convert_real): Ditto. * io/transfer.c: Update comments. * io/transfer128.c: New file. * io/write_float.def (write_float): Handle __float128 type. * libgfortran.h: #include quadmath_weak.h, define __builtin_infq and nanq. * m4/mtype.m4: Handle __float128 type. * runtime/in_pack_generic.c (internal_pack): Ditto. * runtime/in_unpack_generic.c (internal_unpack): Ditto. * kinds-override.h: New file. * libgfortran.spec.in: Ditto. * generated/pow_r16_i4.c: Generated. * Makefile.in: Regenerate. * configure: Regenerate. * config.h: Regenerate. * bessel_r10.c: Regenerate. * bessel_r16.c: Regenerate. * bessel_r4.c: Regenerate. * bessel_r8.c: Regenerate. * exponent_r16.c: Regenerate. * fraction_r16.c: Regenerate. * nearest_r16.c: Regenerate. * norm2_r10.c: Regenerate. * norm2_r16.c: Regenerate. * norm2_r4.c: Regenerate. * norm2_r8.c: Regenerate. * rrspacing_r16.c: Regenerate. * set_exponent_r16.c: Regenerate. * spacing_r16.c: Regenerate. Co-Authored-By: Tobias Burnus <burnus@net-b.de> From-SVN: r166825
2010-11-16 21:23:19 +00:00
#endif
Make sure the Fortran specifics have real(kind=16). This brings the library to compile with all specific functions. It also corrects the patsubst patterns so the right files get the flags. It was necessary to manually add -D__powerpc64__ because apparently this is not set for Fortran. libgfortran/ChangeLog: * Makefile.am: Correct files for compilation flags. Add -D__powerpc64__ for Fortran sources. Get kinds.inc from grep of kinds.h and kinds-override.h. * Makefile.in: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Add -mno-gnu-attribute to compile flags. * generated/_abs_c17.F90: Regenerate. * generated/_abs_r17.F90: Regenerate. * generated/_acos_r17.F90: Regenerate. * generated/_acosh_r17.F90: Regenerate. * generated/_aimag_c17.F90: Regenerate. * generated/_aint_r17.F90: Regenerate. * generated/_anint_r17.F90: Regenerate. * generated/_asin_r17.F90: Regenerate. * generated/_asinh_r17.F90: Regenerate. * generated/_atan2_r17.F90: Regenerate. * generated/_atan_r17.F90: Regenerate. * generated/_atanh_r17.F90: Regenerate. * generated/_conjg_c17.F90: Regenerate. * generated/_cos_c17.F90: Regenerate. * generated/_cos_r17.F90: Regenerate. * generated/_cosh_r17.F90: Regenerate. * generated/_dim_r17.F90: Regenerate. * generated/_exp_c17.F90: Regenerate. * generated/_exp_r17.F90: Regenerate. * generated/_log10_r17.F90: Regenerate. * generated/_log_c17.F90: Regenerate. * generated/_log_r17.F90: Regenerate. * generated/_mod_r17.F90: Regenerate. * generated/_sign_r17.F90: Regenerate. * generated/_sin_c17.F90: Regenerate. * generated/_sin_r17.F90: Regenerate. * generated/_sinh_r17.F90: Regenerate. * generated/_sqrt_c17.F90: Regenerate. * generated/_sqrt_r17.F90: Regenerate. * generated/_tan_r17.F90: Regenerate. * generated/_tanh_r17.F90: Regenerate. * kinds-override.h: Adjust to trunk. Change condition to single line so it can be grepped. * m4/specific.m4: Make sure that real=kind16 is used for _r17.F90 and _c17.F90 files. * m4/specific2.m4: Likewise.
2022-01-03 15:07:02 +00:00
/* Keep these conditions on one line so grep can filter it out. */
#if defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_LONG_DOUBLE__ == 16
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.
2022-06-28 11:05:28 +00:00
typedef _Float128 GFC_REAL_17;
typedef _Complex _Float128 GFC_COMPLEX_17;
Prepare library for REAL(KIND=17). This prepares the library side for REAL(KIND=17). It is not yet tested, but at least compiles cleanly on POWER 9 and x86_64. 2021-10-19 Thomas Koenig <tkoenig@gcc.gnu.org> * Makefile.am: Add _r17 and _c17 files. Build them with -mabi=ieeelongdouble on POWER. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: New flag HAVE_REAL_17. * kinds-override.h: (HAVE_GFC_REAL_17): New macro. (HAVE_GFC_COMPLEX_17): New macro. (GFC_REAL_17_HUGE): New macro. (GFC_REAL_17_LITERAL_SUFFIX): New macro. (GFC_REAL_17_LITERAL): New macro. (GFC_REAL_17_DIGITS): New macro. (GFC_REAL_17_RADIX): New macro. * libgfortran.h (POWER_IEEE128): New macro. (gfc_array_r17): Typedef. (GFC_DTYPE_REAL_17): New macro. (GFC_DTYPE_COMPLEX_17): New macro. (__acoshieee128): Prototype. (__acosieee128): Prototype. (__asinhieee128): Prototype. (__asinieee128): Prototype. (__atan2ieee128): Prototype. (__atanhieee128): Prototype. (__atanieee128): Prototype. (__coshieee128): Prototype. (__cosieee128): Prototype. (__erfieee128): Prototype. (__expieee128): Prototype. (__fabsieee128): Prototype. (__jnieee128): Prototype. (__log10ieee128): Prototype. (__logieee128): Prototype. (__powieee128): Prototype. (__sinhieee128): Prototype. (__sinieee128): Prototype. (__sqrtieee128): Prototype. (__tanhieee128): Prototype. (__tanieee128): Prototype. (__ynieee128): Prototype. * m4/mtype.m4: Make a bit more readable. Add KIND=17. * generated/_abs_c17.F90: New file. * generated/_abs_r17.F90: New file. * generated/_acos_r17.F90: New file. * generated/_acosh_r17.F90: New file. * generated/_aimag_c17.F90: New file. * generated/_aint_r17.F90: New file. * generated/_anint_r17.F90: New file. * generated/_asin_r17.F90: New file. * generated/_asinh_r17.F90: New file. * generated/_atan2_r17.F90: New file. * generated/_atan_r17.F90: New file. * generated/_atanh_r17.F90: New file. * generated/_conjg_c17.F90: New file. * generated/_cos_c17.F90: New file. * generated/_cos_r17.F90: New file. * generated/_cosh_r17.F90: New file. * generated/_dim_r17.F90: New file. * generated/_exp_c17.F90: New file. * generated/_exp_r17.F90: New file. * generated/_log10_r17.F90: New file. * generated/_log_c17.F90: New file. * generated/_log_r17.F90: New file. * generated/_mod_r17.F90: New file. * generated/_sign_r17.F90: New file. * generated/_sin_c17.F90: New file. * generated/_sin_r17.F90: New file. * generated/_sinh_r17.F90: New file. * generated/_sqrt_c17.F90: New file. * generated/_sqrt_r17.F90: New file. * generated/_tan_r17.F90: New file. * generated/_tanh_r17.F90: New file. * generated/bessel_r17.c: New file. * generated/cshift0_c17.c: New file. * generated/cshift0_r17.c: New file. * generated/cshift1_16_c17.c: New file. * generated/cshift1_16_r17.c: New file. * generated/cshift1_4_c17.c: New file. * generated/cshift1_4_r17.c: New file. * generated/cshift1_8_c17.c: New file. * generated/cshift1_8_r17.c: New file. * generated/findloc0_c17.c: New file. * generated/findloc0_r17.c: New file. * generated/findloc1_c17.c: New file. * generated/findloc1_r17.c: New file. * generated/in_pack_c17.c: New file. * generated/in_pack_r17.c: New file. * generated/in_unpack_c17.c: New file. * generated/in_unpack_r17.c: New file. * generated/matmul_c17.c: New file. * generated/matmul_r17.c: New file. * generated/matmulavx128_c17.c: New file. * generated/matmulavx128_r17.c: New file. * generated/maxloc0_16_r17.c: New file. * generated/maxloc0_4_r17.c: New file. * generated/maxloc0_8_r17.c: New file. * generated/maxloc1_16_r17.c: New file. * generated/maxloc1_4_r17.c: New file. * generated/maxloc1_8_r17.c: New file. * generated/maxval_r17.c: New file. * generated/minloc0_16_r17.c: New file. * generated/minloc0_4_r17.c: New file. * generated/minloc0_8_r17.c: New file. * generated/minloc1_16_r17.c: New file. * generated/minloc1_4_r17.c: New file. * generated/minloc1_8_r17.c: New file. * generated/minval_r17.c: New file. * generated/norm2_r17.c: New file. * generated/pack_c17.c: New file. * generated/pack_r17.c: New file. * generated/pow_c17_i16.c: New file. * generated/pow_c17_i4.c: New file. * generated/pow_c17_i8.c: New file. * generated/pow_r17_i16.c: New file. * generated/pow_r17_i4.c: New file. * generated/pow_r17_i8.c: New file. * generated/product_c17.c: New file. * generated/product_r17.c: New file. * generated/reshape_c17.c: New file. * generated/reshape_r17.c: New file. * generated/spread_c17.c: New file. * generated/spread_r17.c: New file. * generated/sum_c17.c: New file. * generated/sum_r17.c: New file. * generated/unpack_c17.c: New file. * generated/unpack_r17.c: New file.
2021-12-06 18:57:32 +00:00
#define HAVE_GFC_REAL_17
#define HAVE_GFC_COMPLEX_17
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.
2022-06-28 11:05:28 +00:00
#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
Prepare library for REAL(KIND=17). This prepares the library side for REAL(KIND=17). It is not yet tested, but at least compiles cleanly on POWER 9 and x86_64. 2021-10-19 Thomas Koenig <tkoenig@gcc.gnu.org> * Makefile.am: Add _r17 and _c17 files. Build them with -mabi=ieeelongdouble on POWER. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: New flag HAVE_REAL_17. * kinds-override.h: (HAVE_GFC_REAL_17): New macro. (HAVE_GFC_COMPLEX_17): New macro. (GFC_REAL_17_HUGE): New macro. (GFC_REAL_17_LITERAL_SUFFIX): New macro. (GFC_REAL_17_LITERAL): New macro. (GFC_REAL_17_DIGITS): New macro. (GFC_REAL_17_RADIX): New macro. * libgfortran.h (POWER_IEEE128): New macro. (gfc_array_r17): Typedef. (GFC_DTYPE_REAL_17): New macro. (GFC_DTYPE_COMPLEX_17): New macro. (__acoshieee128): Prototype. (__acosieee128): Prototype. (__asinhieee128): Prototype. (__asinieee128): Prototype. (__atan2ieee128): Prototype. (__atanhieee128): Prototype. (__atanieee128): Prototype. (__coshieee128): Prototype. (__cosieee128): Prototype. (__erfieee128): Prototype. (__expieee128): Prototype. (__fabsieee128): Prototype. (__jnieee128): Prototype. (__log10ieee128): Prototype. (__logieee128): Prototype. (__powieee128): Prototype. (__sinhieee128): Prototype. (__sinieee128): Prototype. (__sqrtieee128): Prototype. (__tanhieee128): Prototype. (__tanieee128): Prototype. (__ynieee128): Prototype. * m4/mtype.m4: Make a bit more readable. Add KIND=17. * generated/_abs_c17.F90: New file. * generated/_abs_r17.F90: New file. * generated/_acos_r17.F90: New file. * generated/_acosh_r17.F90: New file. * generated/_aimag_c17.F90: New file. * generated/_aint_r17.F90: New file. * generated/_anint_r17.F90: New file. * generated/_asin_r17.F90: New file. * generated/_asinh_r17.F90: New file. * generated/_atan2_r17.F90: New file. * generated/_atan_r17.F90: New file. * generated/_atanh_r17.F90: New file. * generated/_conjg_c17.F90: New file. * generated/_cos_c17.F90: New file. * generated/_cos_r17.F90: New file. * generated/_cosh_r17.F90: New file. * generated/_dim_r17.F90: New file. * generated/_exp_c17.F90: New file. * generated/_exp_r17.F90: New file. * generated/_log10_r17.F90: New file. * generated/_log_c17.F90: New file. * generated/_log_r17.F90: New file. * generated/_mod_r17.F90: New file. * generated/_sign_r17.F90: New file. * generated/_sin_c17.F90: New file. * generated/_sin_r17.F90: New file. * generated/_sinh_r17.F90: New file. * generated/_sqrt_c17.F90: New file. * generated/_sqrt_r17.F90: New file. * generated/_tan_r17.F90: New file. * generated/_tanh_r17.F90: New file. * generated/bessel_r17.c: New file. * generated/cshift0_c17.c: New file. * generated/cshift0_r17.c: New file. * generated/cshift1_16_c17.c: New file. * generated/cshift1_16_r17.c: New file. * generated/cshift1_4_c17.c: New file. * generated/cshift1_4_r17.c: New file. * generated/cshift1_8_c17.c: New file. * generated/cshift1_8_r17.c: New file. * generated/findloc0_c17.c: New file. * generated/findloc0_r17.c: New file. * generated/findloc1_c17.c: New file. * generated/findloc1_r17.c: New file. * generated/in_pack_c17.c: New file. * generated/in_pack_r17.c: New file. * generated/in_unpack_c17.c: New file. * generated/in_unpack_r17.c: New file. * generated/matmul_c17.c: New file. * generated/matmul_r17.c: New file. * generated/matmulavx128_c17.c: New file. * generated/matmulavx128_r17.c: New file. * generated/maxloc0_16_r17.c: New file. * generated/maxloc0_4_r17.c: New file. * generated/maxloc0_8_r17.c: New file. * generated/maxloc1_16_r17.c: New file. * generated/maxloc1_4_r17.c: New file. * generated/maxloc1_8_r17.c: New file. * generated/maxval_r17.c: New file. * generated/minloc0_16_r17.c: New file. * generated/minloc0_4_r17.c: New file. * generated/minloc0_8_r17.c: New file. * generated/minloc1_16_r17.c: New file. * generated/minloc1_4_r17.c: New file. * generated/minloc1_8_r17.c: New file. * generated/minval_r17.c: New file. * generated/norm2_r17.c: New file. * generated/pack_c17.c: New file. * generated/pack_r17.c: New file. * generated/pow_c17_i16.c: New file. * generated/pow_c17_i4.c: New file. * generated/pow_c17_i8.c: New file. * generated/pow_r17_i16.c: New file. * generated/pow_r17_i4.c: New file. * generated/pow_r17_i8.c: New file. * generated/product_c17.c: New file. * generated/product_r17.c: New file. * generated/reshape_c17.c: New file. * generated/reshape_r17.c: New file. * generated/spread_c17.c: New file. * generated/spread_r17.c: New file. * generated/sum_c17.c: New file. * generated/sum_r17.c: New file. * generated/unpack_c17.c: New file. * generated/unpack_r17.c: New file.
2021-12-06 18:57:32 +00:00
#define GFC_REAL_17_HUGE 1.18973149535723176508575932662800702e4932q
#define GFC_REAL_17_LITERAL_SUFFIX q
#define GFC_REAL_17_LITERAL(X) (X ## q)
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.
2022-06-28 11:05:28 +00:00
#endif
Prepare library for REAL(KIND=17). This prepares the library side for REAL(KIND=17). It is not yet tested, but at least compiles cleanly on POWER 9 and x86_64. 2021-10-19 Thomas Koenig <tkoenig@gcc.gnu.org> * Makefile.am: Add _r17 and _c17 files. Build them with -mabi=ieeelongdouble on POWER. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: New flag HAVE_REAL_17. * kinds-override.h: (HAVE_GFC_REAL_17): New macro. (HAVE_GFC_COMPLEX_17): New macro. (GFC_REAL_17_HUGE): New macro. (GFC_REAL_17_LITERAL_SUFFIX): New macro. (GFC_REAL_17_LITERAL): New macro. (GFC_REAL_17_DIGITS): New macro. (GFC_REAL_17_RADIX): New macro. * libgfortran.h (POWER_IEEE128): New macro. (gfc_array_r17): Typedef. (GFC_DTYPE_REAL_17): New macro. (GFC_DTYPE_COMPLEX_17): New macro. (__acoshieee128): Prototype. (__acosieee128): Prototype. (__asinhieee128): Prototype. (__asinieee128): Prototype. (__atan2ieee128): Prototype. (__atanhieee128): Prototype. (__atanieee128): Prototype. (__coshieee128): Prototype. (__cosieee128): Prototype. (__erfieee128): Prototype. (__expieee128): Prototype. (__fabsieee128): Prototype. (__jnieee128): Prototype. (__log10ieee128): Prototype. (__logieee128): Prototype. (__powieee128): Prototype. (__sinhieee128): Prototype. (__sinieee128): Prototype. (__sqrtieee128): Prototype. (__tanhieee128): Prototype. (__tanieee128): Prototype. (__ynieee128): Prototype. * m4/mtype.m4: Make a bit more readable. Add KIND=17. * generated/_abs_c17.F90: New file. * generated/_abs_r17.F90: New file. * generated/_acos_r17.F90: New file. * generated/_acosh_r17.F90: New file. * generated/_aimag_c17.F90: New file. * generated/_aint_r17.F90: New file. * generated/_anint_r17.F90: New file. * generated/_asin_r17.F90: New file. * generated/_asinh_r17.F90: New file. * generated/_atan2_r17.F90: New file. * generated/_atan_r17.F90: New file. * generated/_atanh_r17.F90: New file. * generated/_conjg_c17.F90: New file. * generated/_cos_c17.F90: New file. * generated/_cos_r17.F90: New file. * generated/_cosh_r17.F90: New file. * generated/_dim_r17.F90: New file. * generated/_exp_c17.F90: New file. * generated/_exp_r17.F90: New file. * generated/_log10_r17.F90: New file. * generated/_log_c17.F90: New file. * generated/_log_r17.F90: New file. * generated/_mod_r17.F90: New file. * generated/_sign_r17.F90: New file. * generated/_sin_c17.F90: New file. * generated/_sin_r17.F90: New file. * generated/_sinh_r17.F90: New file. * generated/_sqrt_c17.F90: New file. * generated/_sqrt_r17.F90: New file. * generated/_tan_r17.F90: New file. * generated/_tanh_r17.F90: New file. * generated/bessel_r17.c: New file. * generated/cshift0_c17.c: New file. * generated/cshift0_r17.c: New file. * generated/cshift1_16_c17.c: New file. * generated/cshift1_16_r17.c: New file. * generated/cshift1_4_c17.c: New file. * generated/cshift1_4_r17.c: New file. * generated/cshift1_8_c17.c: New file. * generated/cshift1_8_r17.c: New file. * generated/findloc0_c17.c: New file. * generated/findloc0_r17.c: New file. * generated/findloc1_c17.c: New file. * generated/findloc1_r17.c: New file. * generated/in_pack_c17.c: New file. * generated/in_pack_r17.c: New file. * generated/in_unpack_c17.c: New file. * generated/in_unpack_r17.c: New file. * generated/matmul_c17.c: New file. * generated/matmul_r17.c: New file. * generated/matmulavx128_c17.c: New file. * generated/matmulavx128_r17.c: New file. * generated/maxloc0_16_r17.c: New file. * generated/maxloc0_4_r17.c: New file. * generated/maxloc0_8_r17.c: New file. * generated/maxloc1_16_r17.c: New file. * generated/maxloc1_4_r17.c: New file. * generated/maxloc1_8_r17.c: New file. * generated/maxval_r17.c: New file. * generated/minloc0_16_r17.c: New file. * generated/minloc0_4_r17.c: New file. * generated/minloc0_8_r17.c: New file. * generated/minloc1_16_r17.c: New file. * generated/minloc1_4_r17.c: New file. * generated/minloc1_8_r17.c: New file. * generated/minval_r17.c: New file. * generated/norm2_r17.c: New file. * generated/pack_c17.c: New file. * generated/pack_r17.c: New file. * generated/pow_c17_i16.c: New file. * generated/pow_c17_i4.c: New file. * generated/pow_c17_i8.c: New file. * generated/pow_r17_i16.c: New file. * generated/pow_r17_i4.c: New file. * generated/pow_r17_i8.c: New file. * generated/product_c17.c: New file. * generated/product_r17.c: New file. * generated/reshape_c17.c: New file. * generated/reshape_r17.c: New file. * generated/spread_c17.c: New file. * generated/spread_r17.c: New file. * generated/sum_c17.c: New file. * generated/sum_r17.c: New file. * generated/unpack_c17.c: New file. * generated/unpack_r17.c: New file.
2021-12-06 18:57:32 +00:00
#define GFC_REAL_17_DIGITS 113
#define GFC_REAL_17_RADIX 2
#endif