diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /libgcc | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'libgcc')
68 files changed, 1632 insertions, 409 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index a99aaa0..04d17ac 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,306 @@ +2021-09-08 liuhongt <hongtao.liu@intel.com> + + * config/i386/t-softfp: Compile __{mul,div}hc3 into + libgcc_s.so.1. + +2021-09-08 Jakub Jelinek <jakub@redhat.com> + Iain Sandoe <iain@sandoe.co.uk> + + * config/i386/libgcc-glibc.ver: Add %inherit GCC_12.0.0 GCC_7.0.0 + and export *hf* and *hc* functions at GCC_12.0.0. + +2021-09-06 liuhongt <hongtao.liu@intel.com> + + * Makefile.in: Adjust to support specific CFLAGS for each + libgcc source file. + * config/i386/64/t-softfp: Explicitly add -msse2 for HF + related libgcc source files. + * config/i386/t-softfp: Ditto. + * config/i386/_divhc3.c: New file. + * config/i386/_mulhc3.c: New file. + +2021-09-03 Iain Sandoe <iain@sandoe.co.uk> + + * config/i386/sfp-machine.h (alias_HFtype, alias_SFtype + alias_DFtype, alias_TFtype): New. + (ALIAS_SELECTOR): New. + (strong_alias): Use __typeof and a _Generic selector to + provide the type to the synthesized function. + +2021-09-02 liuhongt <hongtao.liu@intel.com> + + * config/i386/32/sfp-machine.h (_FP_NANFRAC_H): New macro. + * config/i386/64/sfp-machine.h (_FP_NANFRAC_H): Ditto. + * config/i386/sfp-machine.h (_FP_NANSIGN_H): Ditto. + * config/i386/t-softfp: Add hf soft-fp. + * config.host: Add i386/64/t-softfp. + * config/i386/64/t-softfp: New file. + +2021-09-02 liuhongt <hongtao.liu@intel.com> + + * soft-fp/eqhf2.c: New file. + * soft-fp/extendhfdf2.c: New file. + * soft-fp/extendhfsf2.c: New file. + * soft-fp/half.h (FP_CMP_EQ_H): New marco. + * soft-fp/truncdfhf2.c: New file + * soft-fp/truncsfhf2.c: New file + +2021-09-01 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * unwind-arm-common.inc (abort): Remove. + +2021-08-31 Richard Sandiford <richard.sandiford@arm.com> + + * config/aarch64/value-unwind.h: Add missing runtime exception + paragraph. + * config/frv/frv-abi.h: Likewise. + * config/i386/value-unwind.h: Likewise. + * config/pa/pa64-hpux-lib.h: Likewise. + +2021-08-26 David Edelsohn <dje.gcc@gmail.com> + + * config/rs6000/ibm-ldouble.c (ldouble_qadd_internal): Rename from + __gcc_qadd. + (__gcc_qadd): Call ldouble_qadd_internal. + (__gcc_qsub): Call ldouble_qadd_internal with second long double + argument negated. + +2021-08-26 Jonathan Yong <10walls@gmail.com> + + * config/i386/cygming-crtend.c: Fix register_frame_ctor + and register_frame_dtor warnings. + +2021-08-24 Richard Earnshaw <rearnsha@arm.com> + + PR target/102035 + * config/arm/cmse_nonsecure_call.S (__gnu_cmse_nonsecure_call): + Add vlldm erratum work-around. + +2021-08-21 John David Anglin <danglin@gcc.gnu.org> + + * config.host: Remove extra_parts from hppa[12]*-*-hpux11* case. + +2021-08-16 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov.h (gcov_type): Define using __LIBGCC_GCOV_TYPE_SIZE. + (gcov_type_unsigned): Likewise. + +2021-08-14 Stafford Horne <shorne@gmail.com> + + PR target/99783 + * config.host (or1k-*, tmake_file): Add or1k/t-crtstuff. + * config/or1k/t-crtstuff: New file. + +2021-08-06 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-driver.c (#include <stdint.h>): Remove. + (write_topn_counters): Use __INTPTR_TYPE__ instead of intptr_t. + +2021-08-06 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * Makefile.in (LIBGCOV_DRIVER): Add _gcov_info_to_gcda. + * gcov.h (gcov_info): Declare. + (__gcov_info_to_gdca): Likewise. + * libgcov.h (gcov_write_counter): Remove. + (gcov_write_tag_length): Likewise. + * libgcov-driver.c (#include <stdint.h>): New. + (#include <string.h>): Remove. + (NEED_L_GCOV): Conditionally define. + (NEED_L_GCOV_INFO_TO_GCDA): Likewise. + (are_all_counters_zero): New. + (gcov_dump_handler): Likewise. + (gcov_allocate_handler): Likewise. + (dump_unsigned): Likewise. + (dump_counter): Likewise. + (write_topn_counters): Add dump_fn, allocate_fn, and arg parameters. + Use dump_unsigned() and dump_counter(). + (write_one_data): Add dump_fn, allocate_fn, and arg parameters. Use + dump_unsigned(), dump_counter(), and are_all_counters_zero(). + (__gcov_info_to_gcda): New. + +2021-08-05 Jakub Jelinek <jakub@redhat.com> + + * config/t-slibgcc (SHLIB_LINK): Add $(LDFLAGS). + * config/t-slibgcc-darwin (SHLIB_LINK): Likewise. + * config/t-slibgcc-vms (SHLIB_LINK): Likewise. + * config/t-slibgcc-fuchsia (SHLIB_LDFLAGS): Remove $(LDFLAGS). + +2021-08-04 Jakub Jelinek <jakub@redhat.com> + + * config/t-slibgcc-fuchsia: Undo doubly applied patch. + +2021-07-15 Alan Modra <amodra@gmail.com> + + * config/rs6000/morestack.S (R2_SAVE): Define. + (__morestack): Save and restore r2. Set up r2 for called + functions. + +2021-07-01 H.J. Lu <hjl.tools@gmail.com> + + * soft-fp/extendhfxf2.c: New file. + * soft-fp/truncxfhf2.c: Likewise. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/lib2-bswapti2.c: New file. + * config/gcn/lib2-divmod-di.c: New file. + * config/gcn/lib2-gcn.h (DItype, UDItype, TItype, UTItype): Add + typedefs. + (__divdi3, __moddi3, __udivdi3, __umoddi3): Add prototypes. + * config/gcn/t-amdgcn (LIB2ADD): Add lib2-divmod-di.c and + lib2-bswapti2.c. + +2021-06-29 Julian Brown <julian@codesourcery.com> + + * config/gcn/lib2-divmod.c (__udivsi3, __umodsi3): Change argument and + return types to USItype. + * config/gcn/lib2-gcn.h (__udivsi3, __umodsi3): Update prototypes. + +2021-06-23 Kewen Lin <linkw@linux.ibm.com> + + * configure: Regenerate. + * configure.ac (test for libgcc_cv_powerpc_3_1_float128_hw): Fix + typos among the name, CFLAGS and the test. + * config/rs6000/t-float128-hw (fp128_3_1_hw_funcs, fp128_3_1_hw_src, + fp128_3_1_hw_static_obj, fp128_3_1_hw_shared_obj, fp128_3_1_hw_obj): + Remove. + * config/rs6000/t-float128-p10-hw (FLOAT128_HW_INSNS): Append + macro FLOAT128_HW_INSNS_ISA3_1. + (FP128_3_1_CFLAGS_HW): Fix option typo. + * config/rs6000/float128-ifunc.c (SW_OR_HW_ISA3_1): Guard this with + FLOAT128_HW_INSNS_ISA3_1. + (__floattikf_resolve): Likewise. + (__floatuntikf_resolve): Likewise. + (__fixkfti_resolve): Likewise. + (__fixunskfti_resolve): Likewise. + (__floattikf): Likewise. + (__floatuntikf): Likewise. + (__fixkfti): Likewise. + (__fixunskfti): Likewise. + +2021-06-11 Srinath Parvathaneni <srinath.parvathaneni@arm.com> + + PR target/99939 + * config/arm/cmse_nonsecure_call.S: Add __ARM_FEATURE_MVE + macro. + * config/arm/t-arm: To link cmse.o and cmse_nonsecure_call.o + on passing -mcmse option. + +2021-06-10 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/quad-float128.h: Guard all uses of [U]TItype_ppc by + _ARCH_PPC64 . + +2021-06-09 Carl Love <cel@us.ibm.com> + + * config.host: Add if test and set for + libgcc_cv_powerpc_3_1_float128_hw. + * config/rs6000/fixkfti.c: Renamed to fixkfti-sw.c. + Change calls of __fixkfti to __fixkfti_sw. + * config/rs6000/fixunskfti.c: Renamed to fixunskfti-sw.c. + Change calls of __fixunskfti to __fixunskfti_sw. + * config/rs6000/float128-p10.c (__floattikf_hw, + __floatuntikf_hw, __fixkfti_hw, __fixunskfti_hw): New file. + * config/rs6000/float128-ifunc.c (SW_OR_HW_ISA3_1): New macro. + (__floattikf_resolve, __floatuntikf_resolve, __fixkfti_resolve, + __fixunskfti_resolve): Add resolve functions. + (__floattikf, __floatuntikf, __fixkfti, __fixunskfti): New functions. + * config/rs6000/float128-sed (floattitf, __floatuntitf, + __fixtfti, __fixunstfti): Add editor commands to change names. + * config/rs6000/float128-sed-hw (__floattitf, + __floatuntitf, __fixtfti, __fixunstfti): Add editor commands to + change names. + * config/rs6000/floattikf.c: Renamed to floattikf-sw.c. + * config/rs6000/floatuntikf.c: Renamed to floatuntikf-sw.c. + * config/rs6000/quad-float128.h (__floattikf_sw, + __floatuntikf_sw, __fixkfti_sw, __fixunskfti_sw, __floattikf_hw, + __floatuntikf_hw, __fixkfti_hw, __fixunskfti_hw, __floattikf, + __floatuntikf, __fixkfti, __fixunskfti): New extern declarations. + * config/rs6000/t-float128 (floattikf, floatuntikf, + fixkfti, fixunskfti): Remove file names from fp128_ppc_funcs. + (floattikf-sw, floatuntikf-sw, fixkfti-sw, fixunskfti-sw): Add + file names to fp128_ppc_funcs. + * config/rs6000/t-float128-hw(fp128_3_1_hw_funcs, + fp128_3_1_hw_src, fp128_3_1_hw_static_obj, fp128_3_1_hw_shared_obj, + fp128_3_1_hw_obj): Add variables for ISA 3.1 support. + * config/rs6000/t-float128-p10-hw: New file. + * configure: Update script for isa 3.1 128-bit float support. + * configure.ac: Add check for 128-bit float hardware support. + * config/rs6000/fixkfti-sw.c: New file. + * config/rs6000/fixunskfti-sw.c: New file. + * config/rs6000/floattikf-sw.c: New file. + * config/rs6000/floatuntikf-sw.c: New file. + +2021-05-13 Dimitar Dimitrov <dimitar@dinux.eu> + + * config/pru/mpyll.S (__pruabi_mpyll): Place into own section. + +2021-05-13 Martin Liska <mliska@suse.cz> + + * libgcov-driver.c: Fix GNU coding style. + +2021-05-10 Martin Liska <mliska@suse.cz> + + * libgcov-driver.c (gcov_version): Use different name that does + not clash with newly introduced macro. + +2021-04-29 Eric Botcazou <ebotcazou@adacore.com> + + * libgcov.h: For the target, define GCOV_LOCKED_WITH_LOCKING + if __MSVCRT__ and, for the host, define it if HOST_HAS_LK_LOCK. + * libgcov-driver.c: Add directives if GCOV_LOCKED_WITH_LOCKING. + +2021-04-28 Patrick McGehearty <patrick.mcgehearty@oracle.com> + + * libgcc2.c (XMTYPE, XCTYPE, RBIG, RMIN, RMIN2, RMINSCAL, RMAX2): + Define. + (__divsc3, __divdc3, __divxc3, __divtc3): Improve complex divide. + * config/rs6000/_divkc3.c (RBIG, RMIN, RMIN2, RMINSCAL, RMAX2): + Define. + (__divkc3): Improve complex divide. + +2021-04-23 Michael Meissner <meissner@linux.ibm.com> + + PR target/98952 + * config/rs6000/tramp.S (__trampoline_setup, elfv1 #ifdef): Fix + trampoline size comparison in 32-bit by reversing test and + combining load immediate with compare. + (__trampoline_setup, elfv2 #ifdef): Fix trampoline size comparison + in 32-bit by reversing test and combining load immediate with + compare. + +2021-04-05 Florian Weimer <fweimer@redhat.com> + Michael Meissner <meissner@linux.ibm.com> + + * config/rs6000/t-float128 (fp128_ppc_funcs): Add decimal floating + point functions for $(decimal_float) only. + +2021-04-03 Jakub Jelinek <jakub@redhat.com> + + PR target/97653 + * config/rs6000/t-linux (IBM128_STATIC_OBJS): Fix spelling, use + $(objext) instead of $(object). Use _floatunditf instead of + _floatunsditf. Add tf <-> ti conversion objects. + (IBM128_SHARED_OBJS): Use proper substitution reference syntax. + +2021-03-29 Michael Meissner <meissner@linux.ibm.com> + + * config/rs6000/t-float128 (fp128_decstr_funcs): Delete. + (fp128_ppc_funcs): Do not add $(fp128_decstr_funcs). + (fp128_decstr_objs): Delete. + * dfp-bit.h: Call __sprintfieee128 to do conversions from + _Float128 to a Decimal type. Call __strtoieee128 to do + conversions from a Decimal type to _Float128. + * config/rs6000/_sprintfkf.c: Delete file. + * config/rs6000/_sprintfkf.h: Delete file. + * config/rs6000/_strtokf.c: Delete file. + * config/rs6000/_strtokf.h: Delete file. + +2021-03-23 Marcus Comstedt <marcus@mc.pp.se> + + * config/riscv/sfp-machine.h (__BYTE_ORDER): Set according + to __BYTE_ORDER__. + 2021-03-06 Jakub Jelinek <jakub@redhat.com> PR gcov-profile/99406 diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 2c8be56..32e329f 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -314,7 +314,7 @@ MULTIOSSUBDIR := $(shell if test $(MULTIOSDIR) != .; then echo /$(MULTIOSDIR); f inst_libdir = $(libsubdir)$(MULTISUBDIR) inst_slibdir = $(slibdir)$(MULTIOSSUBDIR) -gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS) +gcc_compile_bare = $(CC) $(INTERNAL_CFLAGS) $(CFLAGS-$(<F)) compile_deps = -MT $@ -MD -MP -MF $(basename $@).dep gcc_compile = $(gcc_compile_bare) -o $@ $(compile_deps) gcc_s_compile = $(gcc_compile) -DSHARED @@ -908,7 +908,7 @@ LIBGCOV_INTERFACE = _gcov_dump _gcov_fork \ _gcov_execl _gcov_execlp \ _gcov_execle _gcov_execv _gcov_execvp _gcov_execve _gcov_reset \ _gcov_lock_unlock -LIBGCOV_DRIVER = _gcov +LIBGCOV_DRIVER = _gcov _gcov_info_to_gcda libgcov-merge-objects = $(patsubst %,%$(objext),$(LIBGCOV_MERGE)) libgcov-profiler-objects = $(patsubst %,%$(objext),$(LIBGCOV_PROFILER)) diff --git a/libgcc/config.host b/libgcc/config.host index f808b61..432a3e1 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -667,7 +667,6 @@ hppa[12]*-*-hpux11*) tmake_file="$tmake_file pa/t-slibgcc-dwarf-ver" fi tmake_file="$tmake_file pa/t-slibgcc-hpux t-slibgcc-hpux" - extra_parts="libgcc_stub.a" md_unwind_header=pa/hpux-unwind.h ;; hppa*-*-openbsd*) @@ -927,12 +926,6 @@ m32r-*-elf*) m32rle-*-elf*) tmake_file=t-fdpbit ;; -m32r-*-linux*) - tmake_file="$tmake_file m32r/t-linux t-fdpbit" - ;; -m32rle-*-linux*) - tmake_file="$tmake_file m32r/t-linux t-fdpbit" - ;; m68k-*-elf* | fido-*-elf) tmake_file="$tmake_file m68k/t-floatlib" ;; @@ -1119,12 +1112,12 @@ nios2-*-*) extra_parts="$extra_parts crti.o crtn.o" ;; or1k-*-linux*) - tmake_file="$tmake_file or1k/t-or1k" + tmake_file="$tmake_file or1k/t-or1k or1k/t-crtstuff" tmake_file="$tmake_file t-softfp-sfdf t-softfp" md_unwind_header=or1k/linux-unwind.h ;; or1k-*-*) - tmake_file="$tmake_file or1k/t-or1k" + tmake_file="$tmake_file or1k/t-or1k or1k/t-crtstuff" tmake_file="$tmake_file t-softfp-sfdf t-softfp" ;; pdp11-*-*) @@ -1224,6 +1217,10 @@ powerpc*-*-linux*) tmake_file="${tmake_file} rs6000/t-float128-hw" fi + if test $libgcc_cv_powerpc_3_1_float128_hw = yes; then + tmake_file="${tmake_file} rs6000/t-float128-p10-hw" + fi + extra_parts="$extra_parts ecrti.o ecrtn.o ncrti.o ncrtn.o" md_unwind_header=rs6000/linux-unwind.h ;; @@ -1536,10 +1533,7 @@ i[34567]86-*-elfiamcu | i[34567]86-*-rtems*) ;; i[34567]86-*-* | x86_64-*-*) tmake_file="${tmake_file} t-softfp-tf" - if test "${host_address}" = 32; then - tmake_file="${tmake_file} i386/${host_address}/t-softfp" - fi - tmake_file="${tmake_file} i386/t-softfp t-softfp" + tmake_file="${tmake_file} i386/${host_address}/t-softfp i386/t-softfp t-softfp" ;; esac diff --git a/libgcc/config/aarch64/value-unwind.h b/libgcc/config/aarch64/value-unwind.h index 1f50a47..041ca13 100644 --- a/libgcc/config/aarch64/value-unwind.h +++ b/libgcc/config/aarch64/value-unwind.h @@ -13,6 +13,10 @@ 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 diff --git a/libgcc/config/arm/cmse_nonsecure_call.S b/libgcc/config/arm/cmse_nonsecure_call.S index 146f3ed..c8e0fbb 100644 --- a/libgcc/config/arm/cmse_nonsecure_call.S +++ b/libgcc/config/arm/cmse_nonsecure_call.S @@ -25,7 +25,7 @@ .syntax unified #ifdef __ARM_PCS_VFP -# if __ARM_FP & 0x8 +# if (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) .fpu fpv5-d16 # else .fpu fpv4-sp-d16 @@ -59,7 +59,7 @@ vmov s24, s25, r5, r5 vmov s26, s27, r5, r5 vmov s28, s29, r5, r5 vmov s30, s31, r5, r5 -#elif __ARM_FP & 0x08 +#elif (__ARM_FP & 0x8) || (__ARM_FEATURE_MVE & 1) vmov.f64 d9, d8 vmov.f64 d10, d8 vmov.f64 d11, d8 @@ -102,6 +102,11 @@ blxns r4 #ifdef __ARM_PCS_VFP vpop.f64 {d8-d15} #else +/* VLLDM erratum mitigation sequence. */ +mrs r5, control +tst r5, #8 /* CONTROL_S.SFPA */ +it ne +.inst.w 0xeeb00a40 /* vmovne s0, s0 */ vlldm sp /* Lazy restore of d0-d16 and FPSCR. */ add sp, sp, #0x88 /* Free space used to save floating point registers. */ #endif /* __ARM_PCS_VFP */ diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm index 3625a25..c1553d4 100644 --- a/libgcc/config/arm/t-arm +++ b/libgcc/config/arm/t-arm @@ -3,18 +3,17 @@ LIB1ASMFUNCS = _thumb1_case_sqi _thumb1_case_uqi _thumb1_case_shi \ _thumb1_case_uhi _thumb1_case_si _speculation_barrier HAVE_CMSE:=$(findstring __ARM_FEATURE_CMSE,$(shell $(gcc_compile_bare) -dM -E - </dev/null)) -HAVE_V81M:=$(findstring armv8.1-m.main,$(gcc_compile_bare)) ifeq ($(shell $(gcc_compile_bare) -E -mcmse - </dev/null >/dev/null 2>/dev/null; echo $$?),0) CMSE_OPTS:=-mcmse endif ifdef HAVE_CMSE -ifndef HAVE_V81M + libgcc-objects += cmse.o cmse_nonsecure_call.o cmse.o: $(srcdir)/config/arm/cmse.c $(gcc_compile) -c $(CMSE_OPTS) $< + cmse_nonsecure_call.o: $(srcdir)/config/arm/cmse_nonsecure_call.S $(gcc_compile) -c $< endif -endif diff --git a/libgcc/config/frv/frv-abi.h b/libgcc/config/frv/frv-abi.h index 9af4ea4..0f7ed83 100644 --- a/libgcc/config/frv/frv-abi.h +++ b/libgcc/config/frv/frv-abi.h @@ -14,6 +14,10 @@ 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 diff --git a/libgcc/config/gcn/lib2-bswapti2.c b/libgcc/config/gcn/lib2-bswapti2.c new file mode 100644 index 0000000..c19b70b --- /dev/null +++ b/libgcc/config/gcn/lib2-bswapti2.c @@ -0,0 +1,47 @@ +/* Copyright (C) 2021 Free Software Foundation, Inc. + +This file 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. + +This file 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/>. */ + +#include "lib2-gcn.h" + +UTItype +__bswapti2 (UTItype x) +{ + UDItype lo, hi, outlo, outhi; + lo = (UDItype) x; + hi = (UDItype) (x >> 64); + outhi = (lo >> 56) & 0xff; + outhi |= ((lo >> 48) & 0xff) << 8; + outhi |= ((lo >> 40) & 0xff) << 16; + outhi |= ((lo >> 32) & 0xff) << 24; + outhi |= ((lo >> 24) & 0xff) << 32; + outhi |= ((lo >> 16) & 0xff) << 40; + outhi |= ((lo >> 8) & 0xff) << 48; + outhi |= (lo & 0xff) << 56; + outlo = (hi >> 56) & 0xff; + outlo |= ((hi >> 48) & 0xff) << 8; + outlo |= ((hi >> 40) & 0xff) << 16; + outlo |= ((hi >> 32) & 0xff) << 24; + outlo |= ((hi >> 24) & 0xff) << 32; + outlo |= ((hi >> 16) & 0xff) << 40; + outlo |= ((hi >> 8) & 0xff) << 48; + outlo |= (hi & 0xff) << 56; + return ((UTItype) outhi << 64) | outlo; +} diff --git a/libgcc/config/gcn/lib2-divmod-di.c b/libgcc/config/gcn/lib2-divmod-di.c new file mode 100644 index 0000000..ceb3962 --- /dev/null +++ b/libgcc/config/gcn/lib2-divmod-di.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2021 Free Software Foundation, Inc. + Contributed by Mentor Graphics, Inc. + +This file 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. + +This file 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/>. */ + +#include "lib2-gcn.h" + +/* We really want DImode here: override LIBGCC2_UNITS_PER_WORD. */ +#define LIBGCC2_UNITS_PER_WORD 4 +#define TARGET_HAS_NO_HW_DIVIDE + +#define L_divmoddi4 +#define L_divdi3 +#define L_moddi3 +#define L_udivdi3 +#define L_umoddi3 + +#include "libgcc2.c" diff --git a/libgcc/config/gcn/lib2-divmod.c b/libgcc/config/gcn/lib2-divmod.c index 0d6ca44..7c72e24 100644 --- a/libgcc/config/gcn/lib2-divmod.c +++ b/libgcc/config/gcn/lib2-divmod.c @@ -102,15 +102,15 @@ __modsi3 (SItype a, SItype b) } -SItype -__udivsi3 (SItype a, SItype b) +USItype +__udivsi3 (USItype a, USItype b) { return udivmodsi4 (a, b, 0); } -SItype -__umodsi3 (SItype a, SItype b) +USItype +__umodsi3 (USItype a, USItype b) { return udivmodsi4 (a, b, 1); } diff --git a/libgcc/config/gcn/lib2-gcn.h b/libgcc/config/gcn/lib2-gcn.h index 11476c4..155cf7c 100644 --- a/libgcc/config/gcn/lib2-gcn.h +++ b/libgcc/config/gcn/lib2-gcn.h @@ -33,13 +33,21 @@ typedef short HItype __attribute__ ((mode (HI))); typedef unsigned short UHItype __attribute__ ((mode (HI))); typedef int SItype __attribute__ ((mode (SI))); typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); +typedef int TItype __attribute__ ((mode (TI))); +typedef unsigned int UTItype __attribute__ ((mode (TI))); typedef int word_type __attribute__ ((mode (__word__))); /* Exported functions. */ +extern DItype __divdi3 (DItype, DItype); +extern DItype __moddi3 (DItype, DItype); +extern UDItype __udivdi3 (UDItype, UDItype); +extern UDItype __umoddi3 (UDItype, UDItype); extern SItype __divsi3 (SItype, SItype); extern SItype __modsi3 (SItype, SItype); -extern SItype __udivsi3 (SItype, SItype); -extern SItype __umodsi3 (SItype, SItype); +extern USItype __udivsi3 (USItype, USItype); +extern USItype __umodsi3 (USItype, USItype); extern HItype __divhi3 (HItype, HItype); extern HItype __modhi3 (HItype, HItype); extern UHItype __udivhi3 (UHItype, UHItype); diff --git a/libgcc/config/gcn/t-amdgcn b/libgcc/config/gcn/t-amdgcn index fe7b5fa..38bde54 100644 --- a/libgcc/config/gcn/t-amdgcn +++ b/libgcc/config/gcn/t-amdgcn @@ -1,6 +1,8 @@ LIB2ADD += $(srcdir)/config/gcn/atomic.c \ $(srcdir)/config/gcn/lib2-divmod.c \ $(srcdir)/config/gcn/lib2-divmod-hi.c \ + $(srcdir)/config/gcn/lib2-divmod-di.c \ + $(srcdir)/config/gcn/lib2-bswapti2.c \ $(srcdir)/config/gcn/unwind-gcn.c LIB2ADDEH= diff --git a/libgcc/config/i386/32/sfp-machine.h b/libgcc/config/i386/32/sfp-machine.h index 1fa282d..e24cbc8 100644 --- a/libgcc/config/i386/32/sfp-machine.h +++ b/libgcc/config/i386/32/sfp-machine.h @@ -86,6 +86,7 @@ #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y) #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y) +#define _FP_NANFRAC_H _FP_QNANBIT_H #define _FP_NANFRAC_S _FP_QNANBIT_S #define _FP_NANFRAC_D _FP_QNANBIT_D, 0 /* Even if XFmode is 12byte, we have to pad it to diff --git a/libgcc/config/i386/64/sfp-machine.h b/libgcc/config/i386/64/sfp-machine.h index 1ff94c2..e1c6166 100644 --- a/libgcc/config/i386/64/sfp-machine.h +++ b/libgcc/config/i386/64/sfp-machine.h @@ -13,6 +13,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y) +#define _FP_NANFRAC_H _FP_QNANBIT_H #define _FP_NANFRAC_S _FP_QNANBIT_S #define _FP_NANFRAC_D _FP_QNANBIT_D #define _FP_NANFRAC_E _FP_QNANBIT_E, 0 diff --git a/libgcc/config/i386/64/t-softfp b/libgcc/config/i386/64/t-softfp new file mode 100644 index 0000000..3bec464 --- /dev/null +++ b/libgcc/config/i386/64/t-softfp @@ -0,0 +1,6 @@ +softfp_extras := fixhfti fixunshfti floattihf floatuntihf + +CFLAGS-fixhfti.c += -msse2 +CFLAGS-fixunshfti.c += -msse2 +CFLAGS-floattihf.c += -msse2 +CFLAGS-floatunstihf.c += -msse2 diff --git a/libgcc/config/i386/_divhc3.c b/libgcc/config/i386/_divhc3.c new file mode 100644 index 0000000..4cf92aa --- /dev/null +++ b/libgcc/config/i386/_divhc3.c @@ -0,0 +1,4 @@ +#ifdef __SSE2__ +#define L_divhc3 +#include "libgcc2.c" +#endif diff --git a/libgcc/config/i386/_mulhc3.c b/libgcc/config/i386/_mulhc3.c new file mode 100644 index 0000000..85a8a2f --- /dev/null +++ b/libgcc/config/i386/_mulhc3.c @@ -0,0 +1,4 @@ +#ifdef __SSE2__ +#define L_mulhc3 +#include "libgcc2.c" +#endif diff --git a/libgcc/config/i386/cygming-crtend.c b/libgcc/config/i386/cygming-crtend.c index c7ba109..4ab6342 100644 --- a/libgcc/config/i386/cygming-crtend.c +++ b/libgcc/config/i386/cygming-crtend.c @@ -56,7 +56,10 @@ static EH_FRAME_SECTION_CONST int __FRAME_END__[] extern void __gcc_register_frame (void); extern void __gcc_deregister_frame (void); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wprio-ctor-dtor" static void register_frame_ctor (void) __attribute__ ((constructor (0))); +#pragma GCC diagnostic pop static void register_frame_ctor (void) @@ -65,7 +68,10 @@ register_frame_ctor (void) } #if !DEFAULT_USE_CXA_ATEXIT +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wprio-ctor-dtor" static void deregister_frame_dtor (void) __attribute__ ((destructor (0))); +#pragma GCC diagnostic pop static void deregister_frame_dtor (void) diff --git a/libgcc/config/i386/libgcc-glibc.ver b/libgcc/config/i386/libgcc-glibc.ver index 06e5d37..5bed104 100644 --- a/libgcc/config/i386/libgcc-glibc.ver +++ b/libgcc/config/i386/libgcc-glibc.ver @@ -194,3 +194,23 @@ GCC_4.8.0 { __cpu_indicator_init } %endif + +%inherit GCC_12.0.0 GCC_7.0.0 +GCC_12.0.0 { + __divhc3 + __mulhc3 + __eqhf2 + __nehf2 + __extendhfdf2 + __extendhfsf2 + __extendhftf2 + __extendhfxf2 + __fixhfti + __fixunshfti + __floattihf + __floatuntihf + __truncdfhf2 + __truncsfhf2 + __trunctfhf2 + __truncxfhf2 +} diff --git a/libgcc/config/i386/sfp-machine.h b/libgcc/config/i386/sfp-machine.h index 8319f05..172ebc7 100644 --- a/libgcc/config/i386/sfp-machine.h +++ b/libgcc/config/i386/sfp-machine.h @@ -17,6 +17,7 @@ typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); #define _FP_KEEPNANFRACP 1 #define _FP_QNANNEGATEDP 0 +#define _FP_NANSIGN_H 1 #define _FP_NANSIGN_S 1 #define _FP_NANSIGN_D 1 #define _FP_NANSIGN_E 1 @@ -74,10 +75,24 @@ void __sfp_handle_exceptions (int); /* Define ALIASNAME as a strong alias for NAME. */ #if defined __MACH__ -/* Mach-O doesn't support aliasing. If these functions ever return - anything but CMPtype we need to revisit this... */ +/* Mach-O doesn't support aliasing, so we build a secondary function for + the alias - we need to do a bit of a dance to find out what the type of + the arguments is and then apply that to the secondary function. + If these functions ever return anything but CMPtype we need to revisit + this... */ +typedef float alias_HFtype __attribute__ ((mode (HF))); +typedef float alias_SFtype __attribute__ ((mode (SF))); +typedef float alias_DFtype __attribute__ ((mode (DF))); +typedef float alias_TFtype __attribute__ ((mode (TF))); +#define ALIAS_SELECTOR \ + CMPtype (*) (alias_HFtype, alias_HFtype): (alias_HFtype) 0, \ + CMPtype (*) (alias_SFtype, alias_SFtype): (alias_SFtype) 0, \ + CMPtype (*) (alias_DFtype, alias_DFtype): (alias_DFtype) 0, \ + CMPtype (*) (alias_TFtype, alias_TFtype): (alias_TFtype) 0 #define strong_alias(name, aliasname) \ - CMPtype aliasname (TFtype a, TFtype b) { return name(a, b); } + CMPtype aliasname (__typeof (_Generic (name, ALIAS_SELECTOR)) a, \ + __typeof (_Generic (name, ALIAS_SELECTOR)) b) \ + { return name (a, b); } #else # define strong_alias(name, aliasname) _strong_alias(name, aliasname) # define _strong_alias(name, aliasname) \ diff --git a/libgcc/config/i386/t-softfp b/libgcc/config/i386/t-softfp index 685d9cf..7620cc0 100644 --- a/libgcc/config/i386/t-softfp +++ b/libgcc/config/i386/t-softfp @@ -1 +1,25 @@ LIB2ADD += $(srcdir)/config/i386/sfp-exceptions.c + +# Replace _divhc3 and _mulhc3. +libgcc2-hf-functions = _divhc3 _mulhc3 +libgcc2-hf-extras = $(addsuffix .c, $(libgcc2-hf-functions)) +LIB2ADD += $(addprefix $(srcdir)/config/i386/, $(libgcc2-hf-extras)) + +softfp_extensions := hfsf hfdf hftf hfxf sfdf sftf dftf xftf +softfp_truncations := tfhf xfhf dfhf sfhf tfsf dfsf tfdf tfxf + +softfp_extras += eqhf2 + +CFLAGS-extendhfsf2.c += -msse2 +CFLAGS-extendhfdf2.c += -msse2 +CFLAGS-extendhftf2.c += -msse2 +CFLAGS-extendhfxf2.c += -msse2 + +CFLAGS-truncsfhf2.c += -msse2 +CFLAGS-truncdfhf2.c += -msse2 +CFLAGS-truncxfhf2.c += -msse2 +CFLAGS-trunctfhf2.c += -msse2 + +CFLAGS-eqhf2.c += -msse2 +CFLAGS-_divhc3.c += -msse2 +CFLAGS-_mulhc3.c += -msse2 diff --git a/libgcc/config/i386/value-unwind.h b/libgcc/config/i386/value-unwind.h index 66f76bb..80267ee 100644 --- a/libgcc/config/i386/value-unwind.h +++ b/libgcc/config/i386/value-unwind.h @@ -13,6 +13,10 @@ 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 diff --git a/libgcc/config/m32r/libgcc-glibc.ver b/libgcc/config/m32r/libgcc-glibc.ver deleted file mode 100644 index cb52aa1..0000000 --- a/libgcc/config/m32r/libgcc-glibc.ver +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2004-2021 Free Software Foundation, Inc. -# -# This file is part of GCC. -# -# GCC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GCC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# <http://www.gnu.org/licenses/>. - -# In order to work around the very problems that force us to now generally -# create a libgcc.so, glibc reexported a number of routines from libgcc.a. -# By now choosing the same version tags for these specific routines, we -# maintain enough binary compatibility to allow future versions of glibc -# to defer implementation of these routines to libgcc.so via DT_AUXILIARY. - -# Note that we cannot use the default libgcc-glibc.ver file on sh, -# because GLIBC_2.0 does not exist on this architecture, as the first -# ever glibc release on the platform was GLIBC_2.3. - -%exclude { - __register_frame - __register_frame_table - __deregister_frame - __register_frame_info - __deregister_frame_info - __frame_state_for - __register_frame_info_table -} - -%inherit GCC_3.0 GLIBC_2.3 -GLIBC_2.3 { - __register_frame - __register_frame_table - __deregister_frame - __register_frame_info - __deregister_frame_info - __frame_state_for - __register_frame_info_table -} diff --git a/libgcc/config/m32r/t-linux b/libgcc/config/m32r/t-linux deleted file mode 100644 index 5223b73..0000000 --- a/libgcc/config/m32r/t-linux +++ /dev/null @@ -1,5 +0,0 @@ -# Turn off the SDA while compiling libgcc2. There are no headers for it -# and we want maximal upward compatibility here. -HOST_LIBGCC2_CFLAGS += -G 0 - -SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/m32r/libgcc-glibc.ver diff --git a/libgcc/config/or1k/t-crtstuff b/libgcc/config/or1k/t-crtstuff new file mode 100644 index 0000000..dcae7f3 --- /dev/null +++ b/libgcc/config/or1k/t-crtstuff @@ -0,0 +1,2 @@ +# Compile crtbeginS.o and crtendS.o with -mcmodel=large +CRTSTUFF_T_CFLAGS_S += -mcmodel=large diff --git a/libgcc/config/pa/pa64-hpux-lib.h b/libgcc/config/pa/pa64-hpux-lib.h index 85d5826..eeab98f 100644 --- a/libgcc/config/pa/pa64-hpux-lib.h +++ b/libgcc/config/pa/pa64-hpux-lib.h @@ -14,8 +14,13 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see +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/>. */ /* We use DTOR_LIST_BEGIN to carry a bunch of hacks to allow us to use diff --git a/libgcc/config/pru/mpyll.S b/libgcc/config/pru/mpyll.S index 1aa12a6..cd093bb 100644 --- a/libgcc/config/pru/mpyll.S +++ b/libgcc/config/pru/mpyll.S @@ -29,6 +29,8 @@ #include "pru-asm.h" + .section .text.__pruabi_mpyll, "ax" + .global SYM(__pruabi_mpyll) FUNC(__pruabi_mpyll) SYM(__pruabi_mpyll): diff --git a/libgcc/config/riscv/sfp-machine.h b/libgcc/config/riscv/sfp-machine.h index db26971..8adbf4b 100644 --- a/libgcc/config/riscv/sfp-machine.h +++ b/libgcc/config/riscv/sfp-machine.h @@ -128,7 +128,11 @@ do { \ #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#define __BYTE_ORDER __BIG_ENDIAN +#else #define __BYTE_ORDER __LITTLE_ENDIAN +#endif /* Define ALIASNAME as a strong alias for NAME. */ diff --git a/libgcc/config/rs6000/_divkc3.c b/libgcc/config/rs6000/_divkc3.c index d261f40..a1d29d2 100644 --- a/libgcc/config/rs6000/_divkc3.c +++ b/libgcc/config/rs6000/_divkc3.c @@ -37,29 +37,122 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define __divkc3 __divkc3_sw #endif +#ifndef __LONG_DOUBLE_IEEE128__ +#define RBIG (__LIBGCC_KF_MAX__ / 2) +#define RMIN (__LIBGCC_KF_MIN__) +#define RMIN2 (__LIBGCC_KF_EPSILON__) +#define RMINSCAL (1 / __LIBGCC_KF_EPSILON__) +#define RMAX2 (RBIG * RMIN2) +#else +#define RBIG (__LIBGCC_TF_MAX__ / 2) +#define RMIN (__LIBGCC_TF_MIN__) +#define RMIN2 (__LIBGCC_TF_EPSILON__) +#define RMINSCAL (1 / __LIBGCC_TF_EPSILON__) +#define RMAX2 (RBIG * RMIN2) +#endif + TCtype __divkc3 (TFtype a, TFtype b, TFtype c, TFtype d) { TFtype denom, ratio, x, y; TCtype res; - /* ??? We can get better behavior from logarithmic scaling instead of - the division. But that would mean starting to link libgcc against - libm. We could implement something akin to ldexp/frexp as gcc builtins - fairly easily... */ + /* long double has significant potential underflow/overflow errors that + can be greatly reduced with a limited number of tests and adjustments. + */ + + /* Scale by max(c,d) to reduce chances of denominator overflowing. */ if (FABS (c) < FABS (d)) { + /* Prevent underflow when denominator is near max representable. */ + if (FABS (d) >= RBIG) + { + a = a / 2; + b = b / 2; + c = c / 2; + d = d / 2; + } + /* Avoid overflow/underflow issues when c and d are small. + Scaling up helps avoid some underflows. + No new overflow possible since c&d < RMIN2. */ + if (FABS (d) < RMIN2) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + else + { + if (((FABS (a) < RMIN) && (FABS (b) < RMAX2) && (FABS (d) < RMAX2)) + || ((FABS (b) < RMIN) && (FABS (a) < RMAX2) + && (FABS (d) < RMAX2))) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + } ratio = c / d; denom = (c * ratio) + d; - x = ((a * ratio) + b) / denom; - y = ((b * ratio) - a) / denom; + /* Choose alternate order of computation if ratio is subnormal. */ + if (FABS (ratio) > RMIN) + { + x = ((a * ratio) + b) / denom; + y = ((b * ratio) - a) / denom; + } + else + { + x = ((c * (a / d)) + b) / denom; + y = ((c * (b / d)) - a) / denom; + } } else { + /* Prevent underflow when denominator is near max representable. */ + if (FABS (c) >= RBIG) + { + a = a / 2; + b = b / 2; + c = c / 2; + d = d / 2; + } + /* Avoid overflow/underflow issues when both c and d are small. + Scaling up helps avoid some underflows. + No new overflow possible since both c&d are less than RMIN2. */ + if (FABS (c) < RMIN2) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + else + { + if (((FABS (a) < RMIN) && (FABS (b) < RMAX2) && (FABS (c) < RMAX2)) + || ((FABS (b) < RMIN) && (FABS (a) < RMAX2) + && (FABS (c) < RMAX2))) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + } ratio = d / c; denom = (d * ratio) + c; - x = ((b * ratio) + a) / denom; - y = (b - (a * ratio)) / denom; + /* Choose alternate order of computation if ratio is subnormal. */ + if (FABS (ratio) > RMIN) + { + x = ((b * ratio) + a) / denom; + y = (b - (a * ratio)) / denom; + } + else + { + x = (a + (d * (b / c))) / denom; + y = (b - (d * (a / c))) / denom; + } } /* Recover infinities and zeros that computed as NaN+iNaN; the only cases diff --git a/libgcc/config/rs6000/_sprintfkf.c b/libgcc/config/rs6000/_sprintfkf.c deleted file mode 100644 index 2d624f1..0000000 --- a/libgcc/config/rs6000/_sprintfkf.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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/>. */ - -/* Conversion to IEEE 128-bit floating point from string using snprintf. */ - -#include <stddef.h> -#include <stdlib.h> -#include <soft-fp.h> -#include <quad-float128.h> -#include <stdio.h> -#include <_sprintfkf.h> - -/* This function must be built with IBM 128-bit as long double, so that we can - access the strfroml function if do not have an IEEE 128-bit version, and if - that is not available, use sprintf. */ -#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IBM128__) -#error "Long double is not IBM 128-bit" -#endif - -/* If the user is using GLIBC 2.32, we can use the __snprintfieee128 function. - - If we are linked against an earlier library, we will have fake it by - converting the value to long double, and using sprintf to do the conversion. - This isn't ideal, as IEEE 128-bit has more exponent range than IBM - 128-bit. */ - -extern int __sprintfieee128 (char *restrict, const char *restrict, ...) - __attribute__ ((__weak__)); - -int __sprintfkf (char *restrict string, - const char *restrict format, - _Float128 number) -{ - if (__sprintfieee128) - return __sprintfieee128 (string, format, number); - - return sprintf (string, format, (long double) number); -} diff --git a/libgcc/config/rs6000/_sprintfkf.h b/libgcc/config/rs6000/_sprintfkf.h deleted file mode 100644 index de9d713..0000000 --- a/libgcc/config/rs6000/_sprintfkf.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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/>. */ - -/* Declaration of the conversion function to IEEE 128-bit floating point from - string using snprintf. */ - -extern int __sprintfkf (char *restrict, const char *restrict, _Float128); diff --git a/libgcc/config/rs6000/_strtokf.c b/libgcc/config/rs6000/_strtokf.c deleted file mode 100644 index dc13534..0000000 --- a/libgcc/config/rs6000/_strtokf.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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/>. */ - -/* Conversion to IEEE 128-bit floating point from string. */ - -#include <stddef.h> -#include <stdlib.h> -#include <soft-fp.h> -#include <quad-float128.h> - -/* This function must be built with IBM 128-bit as long double, so that we can - access the strtold function if do not have an IEEE 128-bit version. */ -#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IBM128__) -#error "Long double is not IBM 128-bit" -#endif - -/* If the user is using GLIBC 2.32, we can use the __strtoieee128 function. - - If we are linked against an earlier library, we will have fake it by - converting the string to IBM 128-bit long double, and then converting that to - __float128. This isn't ideal, as IEEE 128-bit has more exponent range than - IBM 128-bit. */ - -extern _Float128 __strtoieee128 (const char *, char **) __attribute__ ((__weak__)); - -_Float128 -__strtokf (const char *string, char **endptr) -{ - if (__strtoieee128) - return __strtoieee128 (string, endptr); - - return strtold (string, endptr); -} diff --git a/libgcc/config/rs6000/_strtokf.h b/libgcc/config/rs6000/_strtokf.h deleted file mode 100644 index a7ca8e0..0000000 --- a/libgcc/config/rs6000/_strtokf.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1989-2021 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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/>. */ - -/* Declaration of the conversion function to IEEE 128-bit floating point from - string. */ - -extern _Float128 __strtokf (const char *, char **); diff --git a/libgcc/config/rs6000/fixkfti.c b/libgcc/config/rs6000/fixkfti-sw.c index 0d965bc..cc000fc 100644 --- a/libgcc/config/rs6000/fixkfti.c +++ b/libgcc/config/rs6000/fixkfti-sw.c @@ -5,7 +5,7 @@ This file is part of the GNU C Library. Contributed by Steven Munroe (munroesj@linux.vnet.ibm.com) Code is based on the main soft-fp library written by: - Uros Bizjak (ubizjak@gmail.com). + Uros Bizjak (ubizjak@gmail.com). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -35,7 +35,7 @@ #include "quad-float128.h" TItype -__fixkfti (TFtype a) +__fixkfti_sw (TFtype a) { FP_DECL_EX; FP_DECL_Q (A); diff --git a/libgcc/config/rs6000/fixunskfti.c b/libgcc/config/rs6000/fixunskfti-sw.c index f285b4e..7a04d1a 100644 --- a/libgcc/config/rs6000/fixunskfti.c +++ b/libgcc/config/rs6000/fixunskfti-sw.c @@ -5,7 +5,7 @@ This file is part of the GNU C Library. Contributed by Steven Munroe (munroesj@linux.vnet.ibm.com) Code is based on the main soft-fp library written by: - Uros Bizjak (ubizjak@gmail.com). + Uros Bizjak (ubizjak@gmail.com). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -35,7 +35,7 @@ #include "quad-float128.h" UTItype -__fixunskfti (TFtype a) +__fixunskfti_sw (TFtype a) { FP_DECL_EX; FP_DECL_Q (A); diff --git a/libgcc/config/rs6000/float128-ifunc.c b/libgcc/config/rs6000/float128-ifunc.c index 8538047..ef7f731 100644 --- a/libgcc/config/rs6000/float128-ifunc.c +++ b/libgcc/config/rs6000/float128-ifunc.c @@ -46,14 +46,11 @@ #endif #define SW_OR_HW(SW, HW) (__builtin_cpu_supports ("ieee128") ? HW : SW) +#ifdef FLOAT128_HW_INSNS_ISA3_1 +#define SW_OR_HW_ISA3_1(SW, HW) (__builtin_cpu_supports ("arch_3_1") ? HW : SW) +#endif /* Resolvers. */ - -/* We do not provide ifunc resolvers for __fixkfti, __fixunskfti, __floattikf, - and __floatuntikf. There is no ISA 3.0 instruction that converts between - 128-bit integer types and 128-bit IEEE floating point, or vice versa. So - use the emulator functions for these conversions. */ - static __typeof__ (__addkf3_sw) * __addkf3_resolve (void) { @@ -102,6 +99,20 @@ __floatdikf_resolve (void) return SW_OR_HW (__floatdikf_sw, __floatdikf_hw); } +#ifdef FLOAT128_HW_INSNS_ISA3_1 +static __typeof__ (__floattikf_sw) * +__floattikf_resolve (void) +{ + return SW_OR_HW_ISA3_1 (__floattikf_sw, __floattikf_hw); +} + +static __typeof__ (__floatuntikf_sw) * +__floatuntikf_resolve (void) +{ + return SW_OR_HW_ISA3_1 (__floatuntikf_sw, __floatuntikf_hw); +} +#endif + static __typeof__ (__floatunsikf_sw) * __floatunsikf_resolve (void) { @@ -114,6 +125,20 @@ __floatundikf_resolve (void) return SW_OR_HW (__floatundikf_sw, __floatundikf_hw); } +#ifdef FLOAT128_HW_INSNS_ISA3_1 +static __typeof__ (__fixkfti_sw) * +__fixkfti_resolve (void) +{ + return SW_OR_HW_ISA3_1 (__fixkfti_sw, __fixkfti_hw); +} + +static __typeof__ (__fixunskfti_sw) * +__fixunskfti_resolve (void) +{ + return SW_OR_HW_ISA3_1 (__fixunskfti_sw, __fixunskfti_hw); +} +#endif + static __typeof__ (__fixkfsi_sw) * __fixkfsi_resolve (void) { @@ -303,6 +328,20 @@ TFtype __floatsikf (SItype_ppc) TFtype __floatdikf (DItype_ppc) __attribute__ ((__ifunc__ ("__floatdikf_resolve"))); +#ifdef FLOAT128_HW_INSNS_ISA3_1 +TFtype __floattikf (TItype_ppc) + __attribute__ ((__ifunc__ ("__floattikf_resolve"))); + +TFtype __floatuntikf (UTItype_ppc) + __attribute__ ((__ifunc__ ("__floatuntikf_resolve"))); + +TItype_ppc __fixkfti (TFtype) + __attribute__ ((__ifunc__ ("__fixkfti_resolve"))); + +UTItype_ppc __fixunskfti (TFtype) + __attribute__ ((__ifunc__ ("__fixunskfti_resolve"))); +#endif + TFtype __floatunsikf (USItype_ppc) __attribute__ ((__ifunc__ ("__floatunsikf_resolve"))); diff --git a/libgcc/config/rs6000/float128-p10.c b/libgcc/config/rs6000/float128-p10.c new file mode 100644 index 0000000..7f5d317 --- /dev/null +++ b/libgcc/config/rs6000/float128-p10.c @@ -0,0 +1,71 @@ +/* Automatic switching between software and hardware IEEE 128-bit + ISA 3.1 floating-point emulation for PowerPC. + + Copyright (C) 2016-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Carl Love (cel@us.ibm.com) + Code is based on the main soft-fp library written by: + Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Note, the hardware conversion instructions for 128-bit integers are + supported for ISA 3.1 and later. Only compile this file with -mcpu=power10 + or newer support. */ + +#include <soft-fp.h> +#include <quad-float128.h> + +#ifndef __FLOAT128_HARDWARE__ +#error "This module must be compiled with IEEE 128-bit hardware support" +#endif + +#ifndef _ARCH_PWR10 +#error "This module must be compiled for Power 10 support" +#endif + +TFtype +__floattikf_hw (TItype_ppc a) +{ + return (TFtype) a; +} + +TFtype +__floatuntikf_hw (UTItype_ppc a) +{ + return (TFtype) a; +} + +TItype_ppc +__fixkfti_hw (TFtype a) +{ + return (TItype_ppc) a; +} + +UTItype_ppc +__fixunskfti_hw (TFtype a) +{ + return (UTItype_ppc) a; +} diff --git a/libgcc/config/rs6000/float128-sed b/libgcc/config/rs6000/float128-sed index d9a089f..c0fcddb 100644 --- a/libgcc/config/rs6000/float128-sed +++ b/libgcc/config/rs6000/float128-sed @@ -8,6 +8,10 @@ s/__fixtfsi/__fixkfsi/g s/__fixunstfdi/__fixunskfdi/g s/__fixunstfsi/__fixunskfsi/g s/__floatditf/__floatdikf/g +s/__floattitf/__floattikf/g +s/__floatuntitf/__floatuntikf/g +s/__fixtfti/__fixkfti/g +s/__fixunstfti/__fixunskfti/g s/__floatsitf/__floatsikf/g s/__floatunditf/__floatundikf/g s/__floatunsitf/__floatunsikf/g diff --git a/libgcc/config/rs6000/float128-sed-hw b/libgcc/config/rs6000/float128-sed-hw index acf36b0..3d2bf55 100644 --- a/libgcc/config/rs6000/float128-sed-hw +++ b/libgcc/config/rs6000/float128-sed-hw @@ -8,6 +8,10 @@ s/__fixtfsi/__fixkfsi_sw/g s/__fixunstfdi/__fixunskfdi_sw/g s/__fixunstfsi/__fixunskfsi_sw/g s/__floatditf/__floatdikf_sw/g +s/__floattitf/__floattikf_sw/g +s/__floatuntitf/__floatuntikf_sw/g +s/__fixtfti/__fixkfti_sw/g +s/__fixunstfti/__fixunskfti_sw/g s/__floatsitf/__floatsikf_sw/g s/__floatunditf/__floatundikf_sw/g s/__floatunsitf/__floatunsikf_sw/g diff --git a/libgcc/config/rs6000/floattikf.c b/libgcc/config/rs6000/floattikf-sw.c index cc5c7ca..4e1786c 100644 --- a/libgcc/config/rs6000/floattikf.c +++ b/libgcc/config/rs6000/floattikf-sw.c @@ -5,7 +5,7 @@ This file is part of the GNU C Library. Contributed by Steven Munroe (munroesj@linux.vnet.ibm.com) Code is based on the main soft-fp library written by: - Uros Bizjak (ubizjak@gmail.com). + Uros Bizjak (ubizjak@gmail.com). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -35,7 +35,7 @@ #include "quad-float128.h" TFtype -__floattikf (TItype i) +__floattikf_sw (TItype i) { FP_DECL_EX; FP_DECL_Q (A); diff --git a/libgcc/config/rs6000/floatuntikf.c b/libgcc/config/rs6000/floatuntikf-sw.c index 96f2d3b..c4b814d 100644 --- a/libgcc/config/rs6000/floatuntikf.c +++ b/libgcc/config/rs6000/floatuntikf-sw.c @@ -5,7 +5,7 @@ This file is part of the GNU C Library. Contributed by Steven Munroe (munroesj@linux.vnet.ibm.com) Code is based on the main soft-fp library written by: - Uros Bizjak (ubizjak@gmail.com). + Uros Bizjak (ubizjak@gmail.com). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -35,7 +35,7 @@ #include "quad-float128.h" TFtype -__floatuntikf (UTItype i) +__floatuntikf_sw (UTItype i) { FP_DECL_EX; FP_DECL_Q (A); diff --git a/libgcc/config/rs6000/ibm-ldouble.c b/libgcc/config/rs6000/ibm-ldouble.c index 4c13453..0b385aa 100644 --- a/libgcc/config/rs6000/ibm-ldouble.c +++ b/libgcc/config/rs6000/ibm-ldouble.c @@ -118,8 +118,8 @@ pack_ldouble (double dh, double dl) } /* Add two 'IBM128_TYPE' values and return the result. */ -IBM128_TYPE -__gcc_qadd (double a, double aa, double c, double cc) +static inline IBM128_TYPE +ldouble_qadd_internal (double a, double aa, double c, double cc) { double xh, xl, z, q, zz; @@ -158,9 +158,15 @@ __gcc_qadd (double a, double aa, double c, double cc) } IBM128_TYPE -__gcc_qsub (double a, double b, double c, double d) +__gcc_qadd (double a, double aa, double c, double cc) +{ + return ldouble_qadd_internal (a, aa, c, cc); +} + +IBM128_TYPE +__gcc_qsub (double a, double aa, double c, double cc) { - return __gcc_qadd (a, b, -c, -d); + return ldouble_qadd_internal (a, aa, -c, -cc); } #ifdef __NO_FPRS__ diff --git a/libgcc/config/rs6000/morestack.S b/libgcc/config/rs6000/morestack.S index 4a07de9..a2e255e 100644 --- a/libgcc/config/rs6000/morestack.S +++ b/libgcc/config/rs6000/morestack.S @@ -31,6 +31,7 @@ #define PARAMS 48 #endif #define MORESTACK_FRAMESIZE (PARAMS+96) +#define R2_SAVE -MORESTACK_FRAMESIZE+PARAMS-8 #define PARAMREG_SAVE -MORESTACK_FRAMESIZE+PARAMS+0 #define STATIC_CHAIN_SAVE -MORESTACK_FRAMESIZE+PARAMS+64 #define R29_SAVE -MORESTACK_FRAMESIZE+PARAMS+72 @@ -143,6 +144,17 @@ ENTRY0(__morestack_non_split) # cr7 must also be preserved. ENTRY0(__morestack) + +#if _CALL_ELF == 2 +# Functions with localentry bits of zero cannot make calls if those +# calls might change r2. This is true generally, and also true for +# __morestack with its special calling convention. When __morestack's +# caller is non-pcrel but libgcc is pcrel, the functions called here +# might modify r2. r2 must be preserved on exit, and also restored +# for the call back to our caller. + std %r2,R2_SAVE(%r1) +#endif + # Save parameter passing registers, our arguments, lr, r29 # and use r29 as a frame pointer. std %r3,PARAMREG_SAVE+0(%r1) @@ -161,10 +173,24 @@ ENTRY0(__morestack) std %r12,LINKREG_SAVE(%r1) std %r3,NEWSTACKSIZE_SAVE(%r1) # new stack size mr %r29,%r1 +#if _CALL_ELF == 2 + .cfi_offset %r2,R2_SAVE +#endif .cfi_offset %r29,R29_SAVE .cfi_def_cfa_register %r29 stdu %r1,-MORESTACK_FRAMESIZE(%r1) +#if _CALL_ELF == 2 && !defined __PCREL__ +# If this isn't a pcrel libgcc then the functions we call here will +# require r2 to be valid. If __morestack is called from pcrel code r2 +# won't be valid. Set it up. + bcl 20,31,1f +1: + mflr %r12 + addis %r2,%r12,.TOC.-1b@ha + addi %r2,%r2,.TOC.-1b@l +#endif + # void __morestack_block_signals (void) bl JUMP_TARGET(__morestack_block_signals) @@ -199,6 +225,9 @@ ENTRY0(__morestack) # instructions after __morestack's return address. # ld %r12,LINKREG_SAVE(%r29) +#if _CALL_ELF == 2 + ld %r2,R2_SAVE(%r29) +#endif ld %r3,PARAMREG_SAVE+0(%r29) # restore arg regs ld %r4,PARAMREG_SAVE+8(%r29) ld %r5,PARAMREG_SAVE+16(%r29) @@ -228,6 +257,15 @@ ENTRY0(__morestack) std %r10,PARAMREG_SAVE+56(%r29) #endif +#if _CALL_ELF == 2 && !defined __PCREL__ +# r2 was restored for calling back into our caller. Set it up again. + bcl 20,31,1f +1: + mflr %r12 + addis %r2,%r12,.TOC.-1b@ha + addi %r2,%r2,.TOC.-1b@l +#endif + bl JUMP_TARGET(__morestack_block_signals) # void *__generic_releasestack (size_t *pavailable) @@ -249,6 +287,9 @@ ENTRY0(__morestack) # Restore return value regs, and return. ld %r0,LINKREG_SAVE(%r29) mtlr %r0 +#if _CALL_ELF == 2 + ld %r2,R2_SAVE(%r29) +#endif ld %r3,PARAMREG_SAVE+0(%r29) ld %r4,PARAMREG_SAVE+8(%r29) ld %r5,PARAMREG_SAVE+16(%r29) diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h index 5beb153..c7f2b77 100644 --- a/libgcc/config/rs6000/quad-float128.h +++ b/libgcc/config/rs6000/quad-float128.h @@ -88,19 +88,22 @@ extern USItype_ppc __fixunskfsi_sw (TFtype); extern UDItype_ppc __fixunskfdi_sw (TFtype); extern TFtype __floatsikf_sw (SItype_ppc); extern TFtype __floatdikf_sw (DItype_ppc); +#ifdef _ARCH_PPC64 +extern TFtype __floattikf_sw (TItype_ppc); +#endif extern TFtype __floatunsikf_sw (USItype_ppc); extern TFtype __floatundikf_sw (UDItype_ppc); +#ifdef _ARCH_PPC64 +extern TFtype __floatuntikf_sw (UTItype_ppc); +extern TItype_ppc __fixkfti_sw (TFtype); +extern UTItype_ppc __fixunskfti_sw (TFtype); +#endif extern IBM128_TYPE __extendkftf2_sw (TFtype); extern TFtype __trunctfkf2_sw (IBM128_TYPE); extern TCtype __mulkc3_sw (TFtype, TFtype, TFtype, TFtype); extern TCtype __divkc3_sw (TFtype, TFtype, TFtype, TFtype); #ifdef _ARCH_PPC64 -/* We do not provide ifunc resolvers for __fixkfti, __fixunskfti, __floattikf, - and __floatuntikf. There is no ISA 3.0 instruction that converts between - 128-bit integer types and 128-bit IEEE floating point, or vice versa. So - use the emulator functions for these conversions. */ - extern TItype_ppc __fixkfti (TFtype); extern UTItype_ppc __fixunskfti (TFtype); extern TFtype __floattikf (TItype_ppc); @@ -131,8 +134,16 @@ extern USItype_ppc __fixunskfsi_hw (TFtype); extern UDItype_ppc __fixunskfdi_hw (TFtype); extern TFtype __floatsikf_hw (SItype_ppc); extern TFtype __floatdikf_hw (DItype_ppc); +#ifdef _ARCH_PPC64 +extern TFtype __floattikf_hw (TItype_ppc); +#endif extern TFtype __floatunsikf_hw (USItype_ppc); extern TFtype __floatundikf_hw (UDItype_ppc); +#ifdef _ARCH_PPC64 +extern TFtype __floatuntikf_hw (UTItype_ppc); +extern TItype_ppc __fixkfti_hw (TFtype); +extern UTItype_ppc __fixunskfti_hw (TFtype); +#endif extern IBM128_TYPE __extendkftf2_hw (TFtype); extern TFtype __trunctfkf2_hw (IBM128_TYPE); extern TCtype __mulkc3_hw (TFtype, TFtype, TFtype, TFtype); @@ -163,8 +174,16 @@ extern USItype_ppc __fixunskfsi (TFtype); extern UDItype_ppc __fixunskfdi (TFtype); extern TFtype __floatsikf (SItype_ppc); extern TFtype __floatdikf (DItype_ppc); +#ifdef _ARCH_PPC64 +extern TFtype __floattikf (TItype_ppc); +#endif extern TFtype __floatunsikf (USItype_ppc); extern TFtype __floatundikf (UDItype_ppc); +#ifdef _ARCH_PPC64 +extern TFtype __floatuntikf (UTItype_ppc); +extern TItype_ppc __fixkfti (TFtype); +extern UTItype_ppc __fixunskfti (TFtype); +#endif extern IBM128_TYPE __extendkftf2 (TFtype); extern TFtype __trunctfkf2 (IBM128_TYPE); diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128 index 6fb1a3d..b09b566 100644 --- a/libgcc/config/rs6000/t-float128 +++ b/libgcc/config/rs6000/t-float128 @@ -26,19 +26,19 @@ fp128_softfp_obj = $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj) fp128_dec_funcs = _kf_to_sd _kf_to_dd _kf_to_td \ _sd_to_kf _dd_to_kf _td_to_kf -# _Float128 to/from string conversions that must be compiled with IBM 128-bit -# long double. -fp128_decstr_funcs = _strtokf _sprintfkf - # Decimal <-> __ibm128 conversions ibm128_dec_funcs = _tf_to_sd _tf_to_dd _tf_to_td \ _sd_to_tf _dd_to_tf _td_to_tf # New functions for software emulation -fp128_ppc_funcs = floattikf floatuntikf fixkfti fixunskfti \ +fp128_ppc_funcs = floattikf-sw floatuntikf-sw \ + fixkfti-sw fixunskfti-sw \ extendkftf2-sw trunctfkf2-sw \ - sfp-exceptions _mulkc3 _divkc3 _powikf2 \ - $(fp128_dec_funcs) $(fp128_decstr_funcs) + sfp-exceptions _mulkc3 _divkc3 _powikf2 + +ifeq ($(decimal_float),yes) +fp128_ppc_funcs += $(fp128_dec_funcs) +endif fp128_ppc_src = $(addprefix $(srcdir)/config/rs6000/,$(addsuffix \ .c,$(fp128_ppc_funcs))) @@ -48,13 +48,16 @@ fp128_ppc_obj = $(fp128_ppc_static_obj) $(fp128_ppc_shared_obj) # All functions fp128_funcs = $(fp128_softfp_funcs) $(fp128_ppc_funcs) \ - $(fp128_hw_funcs) $(fp128_ifunc_funcs) + $(fp128_hw_funcs) $(fp128_ifunc_funcs) \ + $(fp128_3_1_hw_funcs) fp128_src = $(fp128_softfp_src) $(fp128_ppc_src) \ - $(fp128_hw_src) $(fp128_ifunc_src) + $(fp128_hw_src) $(fp128_ifunc_src) \ + $(fp128_3_1_hw_src) fp128_obj = $(fp128_softfp_obj) $(fp128_ppc_obj) \ - $(fp128_hw_obj) $(fp128_ifunc_obj) + $(fp128_hw_obj) $(fp128_ifunc_obj) \ + $(fp128_3_1_hw_obj) fp128_sed = $(srcdir)/config/rs6000/float128-sed$(fp128_sed_hw) fp128_dep = $(fp128_sed) $(srcdir)/config/rs6000/t-float128 @@ -88,9 +91,6 @@ $(fp128_obj) : $(srcdir)/config/rs6000/quad-float128.h fp128_dec_objs = $(addsuffix $(objext),$(fp128_dec_funcs)) \ $(addsuffix _s$(objext),$(fp128_dec_funcs)) -fp128_decstr_objs = $(addsuffix $(objext),$(fp128_decstr_funcs)) \ - $(addsuffix _s$(objext),$(fp128_decstr_funcs)) - ibm128_dec_objs = $(addsuffix $(objext),$(ibm128_dec_funcs)) \ $(addsuffix _s$(objext),$(ibm128_dec_funcs)) @@ -98,12 +98,8 @@ FP128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ieeelongdouble IBM128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ibmlongdouble $(fp128_dec_objs) : INTERNAL_CFLAGS += $(FP128_CFLAGS_DECIMAL) -$(fp128_decstr_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) $(ibm128_dec_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL) -$(fp128_decstr_objs) : $(srcdir)/config/rs6000/_strtokf.h \ - $(srcdir)/config/rs6000/_sprintfkf.h \ - $(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep) @src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \ echo "Create $@"; \ diff --git a/libgcc/config/rs6000/t-float128-p10-hw b/libgcc/config/rs6000/t-float128-p10-hw new file mode 100644 index 0000000..edaaee0 --- /dev/null +++ b/libgcc/config/rs6000/t-float128-p10-hw @@ -0,0 +1,24 @@ +# Support for adding __float128 hardware support to the powerpc. +# Tell the float128 functions that the ISA 3.1 hardware support can +# be compiled it to be selected via IFUNC functions. + +FLOAT128_HW_INSNS += -DFLOAT128_HW_INSNS_ISA3_1 + +# New functions for hardware support + +fp128_3_1_hw_funcs = float128-p10 +fp128_3_1_hw_src = $(srcdir)/config/rs6000/float128-p10.c +fp128_3_1_hw_static_obj = $(addsuffix $(objext),$(fp128_3_1_hw_funcs)) +fp128_3_1_hw_shared_obj = $(addsuffix _s$(objext),$(fp128_3_1_hw_funcs)) +fp128_3_1_hw_obj = $(fp128_3_1_hw_static_obj) $(fp128_3_1_hw_shared_obj) + +# Build the hardware support functions with appropriate hardware support +FP128_3_1_CFLAGS_HW = -Wno-type-limits -mvsx -mfloat128 \ + -mcpu=power10 \ + -mfloat128-hardware -mno-gnu-attribute \ + -I$(srcdir)/soft-fp \ + -I$(srcdir)/config/rs6000 \ + $(FLOAT128_HW_INSNS) + +$(fp128_3_1_hw_obj) : INTERNAL_CFLAGS += $(FP128_3_1_CFLAGS_HW) +$(fp128_3_1_hw_obj) : $(srcdir)/config/rs6000/t-float128-p10-hw diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux index 72e9c27..500210d 100644 --- a/libgcc/config/rs6000/t-linux +++ b/libgcc/config/rs6000/t-linux @@ -11,10 +11,12 @@ HOST_LIBGCC2_CFLAGS += -mno-minimal-toc # the IBM extended double format. Also turn off gnu attributes on the static # modules. IBM128_STATIC_OBJS = ibm-ldouble$(objext) _powitf2$(objext) \ - ppc64-fp$(objext) _divtc3$(object) _multc3$(object) \ - _fixtfdi$(object) _fixunstfdi$(object) \ - _floatditf$(objext) _floatunsditf$(objext) -IBM128_SHARED_OBJS = $(IBM128_STATIC_OBJS:$(objext):_s$(objext)) + ppc64-fp$(objext) _divtc3$(objext) _multc3$(objext) \ + _fixtfdi$(objext) _fixunstfdi$(objext) \ + _floatditf$(objext) _floatunditf$(objext) \ + _fixtfti$(objext) _fixunstfti$(objext) \ + _floattitf$(objext) _floatuntitf$(objext) +IBM128_SHARED_OBJS = $(IBM128_STATIC_OBJS:$(objext)=_s$(objext)) IBM128_OBJS = $(IBM128_STATIC_OBJS) $(IBM128_SHARED_OBJS) IBM128_CFLAGS = -Wno-psabi -mabi=ibmlongdouble -mno-gnu-attribute diff --git a/libgcc/config/rs6000/tramp.S b/libgcc/config/rs6000/tramp.S index 4236a82..68baf16 100644 --- a/libgcc/config/rs6000/tramp.S +++ b/libgcc/config/rs6000/tramp.S @@ -64,8 +64,7 @@ FUNC_START(__trampoline_setup) mflr r11 addi r7,r11,trampoline_initial-4-.LCF0 /* trampoline address -4 */ - li r8,trampoline_size /* verify that the trampoline is big enough */ - cmpw cr1,r8,r4 + cmpwi cr1,r4,trampoline_size /* verify that the trampoline is big enough */ srwi r4,r4,2 /* # words to move */ addi r9,r3,-4 /* adjust pointer for lwzu */ mtctr r4 @@ -156,8 +155,7 @@ FUNC_START(__trampoline_setup) ld 7,.LC0@toc@l(7) /* trampoline address -8 */ #endif - li r8,trampoline_size /* verify that the trampoline is big enough */ - cmpw cr1,r8,r4 + cmpwi cr1,r4,trampoline_size /* verify that the trampoline is big enough */ srwi r4,r4,3 /* # doublewords to move */ addi r9,r3,-8 /* adjust pointer for stdu */ mtctr r4 diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc index c59b43b..50f13c2 100644 --- a/libgcc/config/t-slibgcc +++ b/libgcc/config/t-slibgcc @@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \ $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK) SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \ - $(SHLIB_LDFLAGS) \ + $(SHLIB_LDFLAGS) $(LDFLAGS) \ -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \ $(SHLIB_OBJS) $(SHLIB_LC) && \ rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \ diff --git a/libgcc/config/t-slibgcc-darwin b/libgcc/config/t-slibgcc-darwin index 9970d00..a6ada45 100644 --- a/libgcc/config/t-slibgcc-darwin +++ b/libgcc/config/t-slibgcc-darwin @@ -15,7 +15,7 @@ SHLIB_LC = -lc # Note that this version is used for the loader, not the linker; the linker # uses the stub versions named by the versioned members of $(INSTALL_FILES). -SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \ +SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \ -install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \ -single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \ -Wl,-exported_symbols_list,$(SHLIB_MAP) \ diff --git a/libgcc/config/t-slibgcc-fuchsia b/libgcc/config/t-slibgcc-fuchsia index ed56473..97f1803 100644 --- a/libgcc/config/t-slibgcc-fuchsia +++ b/libgcc/config/t-slibgcc-fuchsia @@ -18,27 +18,4 @@ # Fuchsia-specific shared library overrides. -SHLIB_LDFLAGS = -Wl,--soname=$(SHLIB_SONAME) \ - $(LDFLAGS) -# Copyright (C) 2017-2021 Free Software Foundation, Inc. -# -# This file is part of GCC. -# -# GCC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GCC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# <http://www.gnu.org/licenses/>. - -# Fuchsia-specific shared library overrides. - -SHLIB_LDFLAGS = -Wl,--soname=$(SHLIB_SONAME) \ - $(LDFLAGS) +SHLIB_LDFLAGS = -Wl,--soname=$(SHLIB_SONAME) diff --git a/libgcc/config/t-slibgcc-vms b/libgcc/config/t-slibgcc-vms index d01c343..c305975 100644 --- a/libgcc/config/t-slibgcc-vms +++ b/libgcc/config/t-slibgcc-vms @@ -22,7 +22,7 @@ SHLIB_LINK = \ objdump --syms $(SHLIB_OBJS) | \ $(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt ; \ echo "case_sensitive=NO" >> SYMVEC_$$$$.opt; \ - $(CC) $(LIBGCC2_CFLAGS) -nodefaultlibs \ + $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -nodefaultlibs \ -shared --for-linker=/noinform -o $(SHLIB_NAME) $(SHLIB_OBJS) \ --for-linker=SYMVEC_$$$$.opt \ --for-linker=gsmatch=equal,$(shlib_version) diff --git a/libgcc/configure b/libgcc/configure index dd3afb2..4919a56 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -5263,6 +5263,43 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float128_hw" >&5 $as_echo "$libgcc_cv_powerpc_float128_hw" >&6; } CFLAGS="$saved_CFLAGS" + + saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mcpu=power10 -mfloat128-hardware" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PowerPC ISA 3.1 to build hardware __float128 libraries" >&5 +$as_echo_n "checking for PowerPC ISA 3.1 to build hardware __float128 libraries... " >&6; } +if ${libgcc_cv_powerpc_3_1_float128_hw+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <sys/auxv.h> + #ifndef AT_PLATFORM + #error "AT_PLATFORM is not defined" + #endif + #ifndef __BUILTIN_CPU_SUPPORTS__ + #error "__builtin_cpu_supports is not available" + #endif + vector unsigned char conv (vector unsigned char qs) + { + vector unsigned char ret; + __asm__ ("xscvsqqp %0,%1" : "=v" (ret) : "v" (qs)); + return ret; + } + void *conv_resolver (void) { return (void *) conv; } + __float128 conv_ifunc (__float128) + __attribute__ ((__ifunc__ ("conv_resolver"))); +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libgcc_cv_powerpc_3_1_float128_hw=yes +else + libgcc_cv_powerpc_3_1_float128_hw=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_3_1_float128_hw" >&5 +$as_echo "$libgcc_cv_powerpc_3_1_float128_hw" >&6; } + CFLAGS="$saved_CFLAGS" esac # Collect host-machine-specific information. diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 10ffb04..13a80b2 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -458,6 +458,31 @@ powerpc*-*-linux*) [libgcc_cv_powerpc_float128_hw=yes], [libgcc_cv_powerpc_float128_hw=no])]) CFLAGS="$saved_CFLAGS" + + saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mcpu=power10 -mfloat128-hardware" + AC_CACHE_CHECK([for PowerPC ISA 3.1 to build hardware __float128 libraries], + [libgcc_cv_powerpc_3_1_float128_hw], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([#include <sys/auxv.h> + #ifndef AT_PLATFORM + #error "AT_PLATFORM is not defined" + #endif + #ifndef __BUILTIN_CPU_SUPPORTS__ + #error "__builtin_cpu_supports is not available" + #endif + vector unsigned char conv (vector unsigned char qs) + { + vector unsigned char ret; + __asm__ ("xscvsqqp %0,%1" : "=v" (ret) : "v" (qs)); + return ret; + } + void *conv_resolver (void) { return (void *) conv; } + __float128 conv_ifunc (__float128) + __attribute__ ((__ifunc__ ("conv_resolver")));])], + [libgcc_cv_powerpc_3_1_float128_hw=yes], + [libgcc_cv_powerpc_3_1_float128_hw=no])]) + CFLAGS="$saved_CFLAGS" esac # Collect host-machine-specific information. diff --git a/libgcc/dfp-bit.h b/libgcc/dfp-bit.h index 5e3bfa6..e04cb83 100644 --- a/libgcc/dfp-bit.h +++ b/libgcc/dfp-bit.h @@ -298,8 +298,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define BFP_TYPE _Float128 #define BFP_FMT "%.36Le" #define BFP_VIA_TYPE _Float128 -#define STR_TO_BFP __strtokf -#include <_strtokf.h> +#define STR_TO_BFP __strtoieee128 +extern _Float128 __strtoieee128 (const char *, char **); #endif /* BFP_KIND */ @@ -647,8 +647,8 @@ extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE); #elif defined (L_kf_to_sd) || defined (L_kf_to_dd) || defined (L_kf_to_td) extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE); -#include <_sprintfkf.h> -#define BFP_SPRINTF __sprintfkf +extern int __sprintfieee128 (char *restrict, const char *restrict, ...); +#define BFP_SPRINTF __sprintfieee128 #endif #endif /* _DFPBIT_H */ diff --git a/libgcc/gcov.h b/libgcc/gcov.h index e6492cd..66d03bf 100644 --- a/libgcc/gcov.h +++ b/libgcc/gcov.h @@ -25,6 +25,8 @@ #ifndef GCC_GCOV_H #define GCC_GCOV_H +struct gcov_info; + /* Set all counters to zero. */ extern void __gcov_reset (void); @@ -33,4 +35,21 @@ extern void __gcov_reset (void); extern void __gcov_dump (void); +/* Convert the gcov information referenced by INFO to a gcda data stream. + The FILENAME_FN callback is called exactly once with the filename associated + with the gcov information. The filename may be NULL. Afterwards, the + DUMP_FN callback is subsequently called with chunks (the begin and length of + the chunk are passed as the first two callback parameters) of the gcda data + stream. The ALLOCATE_FN callback shall allocate memory with a size in + characters specified by the first callback parameter. The ARG parameter is + a user-provided argument passed as the last argument to the callback + functions. */ + +extern void +__gcov_info_to_gcda (const struct gcov_info *__info, + void (*__filename_fn) (const char *, void *), + void (*__dump_fn) (const void *, unsigned, void *), + void *(*__allocate_fn) (unsigned, void *), + void *__arg); + #endif /* GCC_GCOV_H */ diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index 17de0a7..38f935e 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -1860,33 +1860,55 @@ NAME (TYPE x, int m) #if defined(L_mulhc3) || defined(L_divhc3) # define MTYPE HFtype # define CTYPE HCtype +# define AMTYPE SFtype # define MODE hc # define CEXT __LIBGCC_HF_FUNC_EXT__ # define NOTRUNC (!__LIBGCC_HF_EXCESS_PRECISION__) #elif defined(L_mulsc3) || defined(L_divsc3) # define MTYPE SFtype # define CTYPE SCtype +# define AMTYPE DFtype # define MODE sc # define CEXT __LIBGCC_SF_FUNC_EXT__ # define NOTRUNC (!__LIBGCC_SF_EXCESS_PRECISION__) +# define RBIG (__LIBGCC_SF_MAX__ / 2) +# define RMIN (__LIBGCC_SF_MIN__) +# define RMIN2 (__LIBGCC_SF_EPSILON__) +# define RMINSCAL (1 / __LIBGCC_SF_EPSILON__) +# define RMAX2 (RBIG * RMIN2) #elif defined(L_muldc3) || defined(L_divdc3) # define MTYPE DFtype # define CTYPE DCtype # define MODE dc # define CEXT __LIBGCC_DF_FUNC_EXT__ # define NOTRUNC (!__LIBGCC_DF_EXCESS_PRECISION__) +# define RBIG (__LIBGCC_DF_MAX__ / 2) +# define RMIN (__LIBGCC_DF_MIN__) +# define RMIN2 (__LIBGCC_DF_EPSILON__) +# define RMINSCAL (1 / __LIBGCC_DF_EPSILON__) +# define RMAX2 (RBIG * RMIN2) #elif defined(L_mulxc3) || defined(L_divxc3) # define MTYPE XFtype # define CTYPE XCtype # define MODE xc # define CEXT __LIBGCC_XF_FUNC_EXT__ # define NOTRUNC (!__LIBGCC_XF_EXCESS_PRECISION__) +# define RBIG (__LIBGCC_XF_MAX__ / 2) +# define RMIN (__LIBGCC_XF_MIN__) +# define RMIN2 (__LIBGCC_XF_EPSILON__) +# define RMINSCAL (1 / __LIBGCC_XF_EPSILON__) +# define RMAX2 (RBIG * RMIN2) #elif defined(L_multc3) || defined(L_divtc3) # define MTYPE TFtype # define CTYPE TCtype # define MODE tc # define CEXT __LIBGCC_TF_FUNC_EXT__ # define NOTRUNC (!__LIBGCC_TF_EXCESS_PRECISION__) +# define RBIG (__LIBGCC_TF_MAX__ / 2) +# define RMIN (__LIBGCC_TF_MIN__) +# define RMIN2 (__LIBGCC_TF_EPSILON__) +# define RMINSCAL (1 / __LIBGCC_TF_EPSILON__) +# define RMAX2 (RBIG * RMIN2) #else # error #endif @@ -1994,30 +2016,136 @@ CONCAT3(__mul,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d) CTYPE CONCAT3(__div,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d) { +#if defined(L_divhc3) \ + || (defined(L_divsc3) && defined(__LIBGCC_HAVE_HWDBL__) ) + + /* Half precision is handled with float precision. + float is handled with double precision when double precision + hardware is available. + Due to the additional precision, the simple complex divide + method (without Smith's method) is sufficient to get accurate + answers and runs slightly faster than Smith's method. */ + + AMTYPE aa, bb, cc, dd; + AMTYPE denom; + MTYPE x, y; + CTYPE res; + aa = a; + bb = b; + cc = c; + dd = d; + + denom = (cc * cc) + (dd * dd); + x = ((aa * cc) + (bb * dd)) / denom; + y = ((bb * cc) - (aa * dd)) / denom; + +#else MTYPE denom, ratio, x, y; CTYPE res; - /* ??? We can get better behavior from logarithmic scaling instead of - the division. But that would mean starting to link libgcc against - libm. We could implement something akin to ldexp/frexp as gcc builtins - fairly easily... */ + /* double, extended, long double have significant potential + underflow/overflow errors that can be greatly reduced with + a limited number of tests and adjustments. float is handled + the same way when no HW double is available. + */ + + /* Scale by max(c,d) to reduce chances of denominator overflowing. */ if (FABS (c) < FABS (d)) { + /* Prevent underflow when denominator is near max representable. */ + if (FABS (d) >= RBIG) + { + a = a / 2; + b = b / 2; + c = c / 2; + d = d / 2; + } + /* Avoid overflow/underflow issues when c and d are small. + Scaling up helps avoid some underflows. + No new overflow possible since c&d < RMIN2. */ + if (FABS (d) < RMIN2) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + else + { + if (((FABS (a) < RMIN) && (FABS (b) < RMAX2) && (FABS (d) < RMAX2)) + || ((FABS (b) < RMIN) && (FABS (a) < RMAX2) + && (FABS (d) < RMAX2))) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + } ratio = c / d; denom = (c * ratio) + d; - x = ((a * ratio) + b) / denom; - y = ((b * ratio) - a) / denom; + /* Choose alternate order of computation if ratio is subnormal. */ + if (FABS (ratio) > RMIN) + { + x = ((a * ratio) + b) / denom; + y = ((b * ratio) - a) / denom; + } + else + { + x = ((c * (a / d)) + b) / denom; + y = ((c * (b / d)) - a) / denom; + } } else { + /* Prevent underflow when denominator is near max representable. */ + if (FABS (c) >= RBIG) + { + a = a / 2; + b = b / 2; + c = c / 2; + d = d / 2; + } + /* Avoid overflow/underflow issues when both c and d are small. + Scaling up helps avoid some underflows. + No new overflow possible since both c&d are less than RMIN2. */ + if (FABS (c) < RMIN2) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + else + { + if (((FABS (a) < RMIN) && (FABS (b) < RMAX2) && (FABS (c) < RMAX2)) + || ((FABS (b) < RMIN) && (FABS (a) < RMAX2) + && (FABS (c) < RMAX2))) + { + a = a * RMINSCAL; + b = b * RMINSCAL; + c = c * RMINSCAL; + d = d * RMINSCAL; + } + } ratio = d / c; denom = (d * ratio) + c; - x = ((b * ratio) + a) / denom; - y = (b - (a * ratio)) / denom; + /* Choose alternate order of computation if ratio is subnormal. */ + if (FABS (ratio) > RMIN) + { + x = ((b * ratio) + a) / denom; + y = (b - (a * ratio)) / denom; + } + else + { + x = (a + (d * (b / c))) / denom; + y = (b - (d * (a / c))) / denom; + } } +#endif - /* Recover infinities and zeros that computed as NaN+iNaN; the only cases - are nonzero/zero, infinite/finite, and finite/infinite. */ + /* Recover infinities and zeros that computed as NaN+iNaN; the only + cases are nonzero/zero, infinite/finite, and finite/infinite. */ if (isnan (x) && isnan (y)) { if (c == 0.0 && d == 0.0 && (!isnan (a) || !isnan (b))) diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c index a1338b6..087f71e 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -26,6 +26,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "libgcov.h" #include "gcov-io.h" +/* Return 1, if all counter values are zero, otherwise 0. */ + +static inline int +are_all_counters_zero (const struct gcov_ctr_info *ci_ptr) +{ + for (unsigned i = 0; i < ci_ptr->num; i++) + if (ci_ptr->values[i] != 0) + return 0; + + return 1; +} + #if defined(inhibit_libc) /* If libc and its header files are not available, provide dummy functions. */ @@ -35,19 +47,31 @@ void __gcov_init (struct gcov_info *p __attribute__ ((unused))) {} #else /* inhibit_libc */ -#include <string.h> #if GCOV_LOCKED #include <fcntl.h> #include <errno.h> #include <sys/stat.h> +#elif GCOV_LOCKED_WITH_LOCKING +#include <fcntl.h> +#include <sys/locking.h> +#include <sys/stat.h> #endif #if HAVE_SYS_MMAN_H #include <sys/mman.h> #endif -#ifdef L_gcov +#endif /* inhibit_libc */ + +#if defined(L_gcov) && !defined(inhibit_libc) +#define NEED_L_GCOV +#endif + +#if defined(L_gcov_info_to_gcda) && !IN_GCOV_TOOL +#define NEED_L_GCOV_INFO_TO_GCDA +#endif +#ifdef NEED_L_GCOV /* A utility function for outputting errors. */ static int gcov_error (const char *, ...); @@ -196,7 +220,7 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned_t version, if (version != GCOV_VERSION) { char v[4], e[4]; - char version_string[128], expected_string[128]; + char ver_string[128], expected_string[128]; GCOV_UNSIGNED2STRING (v, version); GCOV_UNSIGNED2STRING (e, GCOV_VERSION); @@ -205,7 +229,7 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned_t version, "got %s (%.4s)\n", filename? filename : ptr->filename, gcov_version_string (expected_string, e), e, - gcov_version_string (version_string, v), v); + gcov_version_string (ver_string, v), v); return 0; } return 1; @@ -338,6 +362,51 @@ read_error: return -1; } +/* Write the DATA of LENGTH characters to the gcov file. */ + +static void +gcov_dump_handler (const void *data, + unsigned length, + void *arg ATTRIBUTE_UNUSED) +{ + gcov_write (data, length); +} + +/* Allocate SIZE characters and return the address of the allocated memory. */ + +static void * +gcov_allocate_handler (unsigned size, void *arg ATTRIBUTE_UNUSED) +{ + return xmalloc (size); +} +#endif /* NEED_L_GCOV */ + +#if defined(NEED_L_GCOV) || defined(NEED_L_GCOV_INFO_TO_GCDA) +/* Dump the WORD using the DUMP handler called with ARG. */ + +static inline void +dump_unsigned (gcov_unsigned_t word, + void (*dump_fn) (const void *, unsigned, void *), + void *arg) +{ + (*dump_fn) (&word, sizeof (word), arg); +} + +/* Dump the COUNTER using the DUMP handler called with ARG. */ + +static inline void +dump_counter (gcov_type counter, + void (*dump_fn) (const void *, unsigned, void *), + void *arg) +{ + dump_unsigned ((gcov_unsigned_t)counter, dump_fn, arg); + + if (sizeof (counter) > sizeof (gcov_unsigned_t)) + dump_unsigned ((gcov_unsigned_t)(counter >> 32), dump_fn, arg); + else + dump_unsigned (0, dump_fn, arg); +} + #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) /* Store all TOP N counters where each has a dynamic length. */ @@ -345,7 +414,10 @@ read_error: static void write_topn_counters (const struct gcov_ctr_info *ci_ptr, unsigned t_ix, - gcov_unsigned_t n_counts) + gcov_unsigned_t n_counts, + void (*dump_fn) (const void *, unsigned, void *), + void *(*allocate_fn)(unsigned, void *), + void *arg) { unsigned counters = n_counts / GCOV_TOPN_MEM_COUNTERS; gcc_assert (n_counts % GCOV_TOPN_MEM_COUNTERS == 0); @@ -360,46 +432,49 @@ write_topn_counters (const struct gcov_ctr_info *ci_ptr, if (list_sizes == NULL || counters > list_size_length) { list_size_length = MAX (LIST_SIZE_MIN_LENGTH, 2 * counters); -#if HAVE_SYS_MMAN_H +#if !defined(inhibit_libc) && HAVE_SYS_MMAN_H list_sizes = (unsigned *)malloc_mmap (list_size_length * sizeof (unsigned)); #endif /* Malloc fallback. */ if (list_sizes == NULL) - list_sizes = (unsigned *)xmalloc (list_size_length * sizeof (unsigned)); + list_sizes = + (unsigned *)(*allocate_fn) (list_size_length * sizeof (unsigned), + arg); } - memset (list_sizes, 0, counters * sizeof (unsigned)); unsigned pair_total = 0; for (unsigned i = 0; i < counters; i++) { gcov_type start = ci_ptr->values[GCOV_TOPN_MEM_COUNTERS * i + 2]; - for (struct gcov_kvp *node = (struct gcov_kvp *)(intptr_t)start; + unsigned sizes = 0; + + for (struct gcov_kvp *node = (struct gcov_kvp *)(__INTPTR_TYPE__)start; node != NULL; node = node->next) - { - ++pair_total; - ++list_sizes[i]; - } + ++sizes; + + pair_total += sizes; + list_sizes[i] = sizes; } unsigned disk_size = GCOV_TOPN_DISK_COUNTERS * counters + 2 * pair_total; - gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix), - GCOV_TAG_COUNTER_LENGTH (disk_size)); + dump_unsigned (GCOV_TAG_FOR_COUNTER (t_ix), dump_fn, arg), + dump_unsigned (GCOV_TAG_COUNTER_LENGTH (disk_size), dump_fn, arg); for (unsigned i = 0; i < counters; i++) { - gcov_write_counter (ci_ptr->values[GCOV_TOPN_MEM_COUNTERS * i]); - gcov_write_counter (list_sizes[i]); + dump_counter (ci_ptr->values[GCOV_TOPN_MEM_COUNTERS * i], dump_fn, arg); + dump_counter (list_sizes[i], dump_fn, arg); gcov_type start = ci_ptr->values[GCOV_TOPN_MEM_COUNTERS * i + 2]; unsigned j = 0; - for (struct gcov_kvp *node = (struct gcov_kvp *)(intptr_t)start; + for (struct gcov_kvp *node = (struct gcov_kvp *)(__INTPTR_TYPE__)start; j < list_sizes[i]; node = node->next, j++) { - gcov_write_counter (node->value); - gcov_write_counter (node->count); + dump_counter (node->value, dump_fn, arg); + dump_counter (node->count, dump_fn, arg); } } } @@ -410,25 +485,34 @@ write_topn_counters (const struct gcov_ctr_info *ci_ptr, static void write_one_data (const struct gcov_info *gi_ptr, - const struct gcov_summary *prg_p) + const struct gcov_summary *prg_p ATTRIBUTE_UNUSED, + void (*dump_fn) (const void *, unsigned, void *), + void *(*allocate_fn) (unsigned, void *), + void *arg) { unsigned f_ix; - gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION); - gcov_write_unsigned (gi_ptr->stamp); + dump_unsigned (GCOV_DATA_MAGIC, dump_fn, arg); + dump_unsigned (GCOV_VERSION, dump_fn, arg); + dump_unsigned (gi_ptr->stamp, dump_fn, arg); +#ifdef NEED_L_GCOV /* Generate whole program statistics. */ gcov_write_summary (GCOV_TAG_OBJECT_SUMMARY, prg_p); +#endif /* Write execution counts for each function. */ for (f_ix = 0; f_ix != gi_ptr->n_functions; f_ix++) { +#ifdef NEED_L_GCOV unsigned buffered = 0; +#endif const struct gcov_fn_info *gfi_ptr; const struct gcov_ctr_info *ci_ptr; gcov_unsigned_t length; unsigned t_ix; +#ifdef NEED_L_GCOV if (fn_buffer && fn_buffer->fn_ix == f_ix) { /* Buffered data from another program. */ @@ -437,6 +521,7 @@ write_one_data (const struct gcov_info *gi_ptr, length = GCOV_TAG_FUNCTION_LENGTH; } else +#endif { gfi_ptr = gi_ptr->functions[f_ix]; if (gfi_ptr && gfi_ptr->key == gi_ptr) @@ -445,13 +530,14 @@ write_one_data (const struct gcov_info *gi_ptr, length = 0; } - gcov_write_tag_length (GCOV_TAG_FUNCTION, length); + dump_unsigned (GCOV_TAG_FUNCTION, dump_fn, arg); + dump_unsigned (length, dump_fn, arg); if (!length) continue; - gcov_write_unsigned (gfi_ptr->ident); - gcov_write_unsigned (gfi_ptr->lineno_checksum); - gcov_write_unsigned (gfi_ptr->cfg_checksum); + dump_unsigned (gfi_ptr->ident, dump_fn, arg); + dump_unsigned (gfi_ptr->lineno_checksum, dump_fn, arg); + dump_unsigned (gfi_ptr->cfg_checksum, dump_fn, arg); ci_ptr = gfi_ptr->ctrs; for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) @@ -464,39 +550,37 @@ write_one_data (const struct gcov_info *gi_ptr, n_counts = ci_ptr->num; if (t_ix == GCOV_COUNTER_V_TOPN || t_ix == GCOV_COUNTER_V_INDIR) - write_topn_counters (ci_ptr, t_ix, n_counts); + write_topn_counters (ci_ptr, t_ix, n_counts, dump_fn, allocate_fn, + arg); else { - /* Do not stream when all counters are zero. */ - int all_zeros = 1; - for (unsigned i = 0; i < n_counts; i++) - if (ci_ptr->values[i] != 0) - { - all_zeros = 0; - break; - } - - if (all_zeros) - gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix), - GCOV_TAG_COUNTER_LENGTH (-n_counts)); + dump_unsigned (GCOV_TAG_FOR_COUNTER (t_ix), dump_fn, arg); + if (are_all_counters_zero (ci_ptr)) + /* Do not stream when all counters are zero. */ + dump_unsigned (GCOV_TAG_COUNTER_LENGTH (-n_counts), + dump_fn, arg); else { - gcov_write_tag_length (GCOV_TAG_FOR_COUNTER (t_ix), - GCOV_TAG_COUNTER_LENGTH (n_counts)); + dump_unsigned (GCOV_TAG_COUNTER_LENGTH (n_counts), + dump_fn, arg); for (unsigned i = 0; i < n_counts; i++) - gcov_write_counter (ci_ptr->values[i]); + dump_counter (ci_ptr->values[i], dump_fn, arg); } } ci_ptr++; } +#ifdef NEED_L_GCOV if (buffered) fn_buffer = free_fn_data (gi_ptr, fn_buffer, GCOV_COUNTERS); +#endif } - gcov_write_unsigned (0); + dump_unsigned (0, dump_fn, arg); } +#endif /* NEED_L_GCOV || NEED_L_GCOV_INFO_TO_GCDA */ +#ifdef NEED_L_GCOV /* Dump the coverage counts for one gcov_info object. We merge with existing counts when possible, to avoid growing the .da files ad infinitum. We use this program's checksum to make sure we only accumulate whole program @@ -545,7 +629,8 @@ dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf, summary = gi_ptr->summary; #endif - write_one_data (gi_ptr, &summary); + write_one_data (gi_ptr, &summary, gcov_dump_handler, gcov_allocate_handler, + NULL); /* fall through */ read_fatal:; @@ -553,10 +638,8 @@ read_fatal:; fn_buffer = free_fn_data (gi_ptr, fn_buffer, GCOV_COUNTERS); if ((error = gcov_close ())) - gcov_error (error < 0 ? - GCOV_PROF_PREFIX "Overflow writing\n" : - GCOV_PROF_PREFIX "Error writing\n", - gf->filename); + gcov_error ((error < 0 ? GCOV_PROF_PREFIX "Overflow writing\n" + : GCOV_PROF_PREFIX "Error writing\n"), gf->filename); } @@ -677,5 +760,20 @@ __gcov_init (struct gcov_info *info) } } #endif /* !IN_GCOV_TOOL */ -#endif /* L_gcov */ -#endif /* inhibit_libc */ +#endif /* NEED_L_GCOV */ + +#ifdef NEED_L_GCOV_INFO_TO_GCDA +/* Convert the gcov info to a gcda data stream. It is intended for + free-standing environments which do not support the C library file I/O. */ + +void +__gcov_info_to_gcda (const struct gcov_info *gi_ptr, + void (*filename_fn) (const char *, void *), + void (*dump_fn) (const void *, unsigned, void *), + void *(*allocate_fn) (unsigned, void *), + void *arg) +{ + (*filename_fn) (gi_ptr->filename, arg); + write_one_data (gi_ptr, NULL, dump_fn, allocate_fn, arg); +} +#endif /* NEED_L_GCOV_INFO_TO_GCDA */ diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index 7b0d367..f6354a7 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -52,7 +52,7 @@ #if __CHAR_BIT__ == 8 typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI))); typedef unsigned gcov_position_t __attribute__ ((mode (SI))); -#if LONG_LONG_TYPE_SIZE > 32 +#if __LIBGCC_GCOV_TYPE_SIZE > 32 typedef signed gcov_type __attribute__ ((mode (DI))); typedef unsigned gcov_type_unsigned __attribute__ ((mode (DI))); #else @@ -63,7 +63,7 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI))); #if __CHAR_BIT__ == 16 typedef unsigned gcov_unsigned_t __attribute__ ((mode (HI))); typedef unsigned gcov_position_t __attribute__ ((mode (HI))); -#if LONG_LONG_TYPE_SIZE > 32 +#if __LIBGCC_GCOV_TYPE_SIZE > 32 typedef signed gcov_type __attribute__ ((mode (SI))); typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI))); #else @@ -73,7 +73,7 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI))); #else typedef unsigned gcov_unsigned_t __attribute__ ((mode (QI))); typedef unsigned gcov_position_t __attribute__ ((mode (QI))); -#if LONG_LONG_TYPE_SIZE > 32 +#if __LIBGCC_GCOV_TYPE_SIZE > 32 typedef signed gcov_type __attribute__ ((mode (HI))); typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI))); #else @@ -89,6 +89,12 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI))); #define GCOV_LOCKED 0 #endif +#if defined (__MSVCRT__) +#define GCOV_LOCKED_WITH_LOCKING 1 +#else +#define GCOV_LOCKED_WITH_LOCKING 0 +#endif + #ifndef GCOV_SUPPORTS_ATOMIC /* Detect whether target can support atomic update of profilers. */ #if __SIZEOF_LONG_LONG__ == 4 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 @@ -108,13 +114,11 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI))); #define gcov_var __gcov_var #define gcov_open __gcov_open #define gcov_close __gcov_close -#define gcov_write_tag_length __gcov_write_tag_length #define gcov_position __gcov_position #define gcov_seek __gcov_seek #define gcov_rewrite __gcov_rewrite #define gcov_is_error __gcov_is_error #define gcov_write_unsigned __gcov_write_unsigned -#define gcov_write_counter __gcov_write_counter #define gcov_write_summary __gcov_write_summary #define gcov_read_unsigned __gcov_read_unsigned #define gcov_read_counter __gcov_read_counter @@ -133,12 +137,19 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI))); typedef unsigned gcov_unsigned_t; typedef unsigned gcov_position_t; /* gcov_type is typedef'd elsewhere for the compiler */ + #if defined (HOST_HAS_F_SETLKW) #define GCOV_LOCKED 1 #else #define GCOV_LOCKED 0 #endif +#if defined (HOST_HAS_LK_LOCK) +#define GCOV_LOCKED_WITH_LOCKING 1 +#else +#define GCOV_LOCKED_WITH_LOCKING 0 +#endif + /* Some Macros specific to gcov-tool. */ #define L_gcov 1 @@ -332,9 +343,6 @@ extern int __gcov_execve (const char *, char *const [], char *const []) /* Functions that only available in libgcov. */ GCOV_LINKAGE int gcov_open (const char */*name*/) ATTRIBUTE_HIDDEN; -GCOV_LINKAGE void gcov_write_counter (gcov_type) ATTRIBUTE_HIDDEN; -GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t) - ATTRIBUTE_HIDDEN; GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/, const struct gcov_summary *) ATTRIBUTE_HIDDEN; diff --git a/libgcc/soft-fp/eqhf2.c b/libgcc/soft-fp/eqhf2.c new file mode 100644 index 0000000..6d6634e --- /dev/null +++ b/libgcc/soft-fp/eqhf2.c @@ -0,0 +1,49 @@ +/* Software floating-point emulation. + Return 0 iff a == b, 1 otherwise + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "half.h" + +CMPtype +__eqhf2 (HFtype a, HFtype b) +{ + FP_DECL_EX; + FP_DECL_H (A); + FP_DECL_H (B); + CMPtype r; + + FP_INIT_EXCEPTIONS; + FP_UNPACK_RAW_H (A, a); + FP_UNPACK_RAW_H (B, b); + FP_CMP_EQ_H (r, A, B, 1); + FP_HANDLE_EXCEPTIONS; + + return r; +} + +strong_alias (__eqhf2, __nehf2); diff --git a/libgcc/soft-fp/extendhfdf2.c b/libgcc/soft-fp/extendhfdf2.c new file mode 100644 index 0000000..337ba79 --- /dev/null +++ b/libgcc/soft-fp/extendhfdf2.c @@ -0,0 +1,53 @@ +/* Software floating-point emulation. + Return an IEEE half converted to IEEE double + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define FP_NO_EXACT_UNDERFLOW +#include "soft-fp.h" +#include "half.h" +#include "double.h" + +DFtype +__extendhfdf2 (HFtype a) +{ + FP_DECL_EX; + FP_DECL_H (A); + FP_DECL_D (R); + DFtype r; + + FP_INIT_EXCEPTIONS; + FP_UNPACK_RAW_H (A, a); +#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D + FP_EXTEND (D, H, 2, 1, R, A); +#else + FP_EXTEND (D, H, 1, 1, R, A); +#endif + FP_PACK_RAW_D (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/libgcc/soft-fp/extendhfsf2.c b/libgcc/soft-fp/extendhfsf2.c new file mode 100644 index 0000000..a02f46d --- /dev/null +++ b/libgcc/soft-fp/extendhfsf2.c @@ -0,0 +1,49 @@ +/* Software floating-point emulation. + Return an IEEE half converted to IEEE single + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define FP_NO_EXACT_UNDERFLOW +#include "soft-fp.h" +#include "half.h" +#include "single.h" + +SFtype +__extendhfsf2 (HFtype a) +{ + FP_DECL_EX; + FP_DECL_H (A); + FP_DECL_S (R); + SFtype r; + + FP_INIT_EXCEPTIONS; + FP_UNPACK_RAW_H (A, a); + FP_EXTEND (S, H, 1, 1, R, A); + FP_PACK_RAW_S (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/libgcc/soft-fp/extendhfxf2.c b/libgcc/soft-fp/extendhfxf2.c new file mode 100644 index 0000000..1cb5fef --- /dev/null +++ b/libgcc/soft-fp/extendhfxf2.c @@ -0,0 +1,53 @@ +/* Software floating-point emulation. + Return an IEEE half converted to IEEE extended. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define FP_NO_EXACT_UNDERFLOW +#include "soft-fp.h" +#include "half.h" +#include "extended.h" + +XFtype +__extendhfxf2 (HFtype a) +{ + FP_DECL_EX; + FP_DECL_H (A); + FP_DECL_E (R); + XFtype r; + + FP_INIT_EXCEPTIONS; + FP_UNPACK_RAW_H (A, a); +#if _FP_W_TYPE_SIZE < 64 + FP_EXTEND (E, H, 4, 1, R, A); +#else + FP_EXTEND (E, H, 2, 1, R, A); +#endif + FP_PACK_RAW_E (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/libgcc/soft-fp/half.h b/libgcc/soft-fp/half.h index c7823ac..4108f5c 100644 --- a/libgcc/soft-fp/half.h +++ b/libgcc/soft-fp/half.h @@ -167,4 +167,5 @@ union _FP_UNION_H #define _FP_FRAC_HIGH_RAW_H(X) _FP_FRAC_HIGH_1 (X) #define _FP_FRAC_HIGH_DW_H(X) _FP_FRAC_HIGH_1 (X) +#define FP_CMP_EQ_H(r, X, Y, ex) _FP_CMP_EQ (H, 1, (r), X, Y, (ex)) #endif /* !SOFT_FP_HALF_H */ diff --git a/libgcc/soft-fp/truncdfhf2.c b/libgcc/soft-fp/truncdfhf2.c new file mode 100644 index 0000000..8bcb278 --- /dev/null +++ b/libgcc/soft-fp/truncdfhf2.c @@ -0,0 +1,52 @@ +/* Software floating-point emulation. + Truncate IEEE double into IEEE half. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "half.h" +#include "double.h" + +HFtype +__truncdfhf2 (DFtype a) +{ + FP_DECL_EX; + FP_DECL_D (A); + FP_DECL_H (R); + HFtype r; + + FP_INIT_ROUNDMODE; + FP_UNPACK_SEMIRAW_D (A, a); +#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D + FP_TRUNC (H, D, 1, 2, R, A); +#else + FP_TRUNC (H, D, 1, 1, R, A); +#endif + FP_PACK_SEMIRAW_H (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/libgcc/soft-fp/truncsfhf2.c b/libgcc/soft-fp/truncsfhf2.c new file mode 100644 index 0000000..25bee29 --- /dev/null +++ b/libgcc/soft-fp/truncsfhf2.c @@ -0,0 +1,48 @@ +/* Software floating-point emulation. + Truncate IEEE single into IEEE half. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "half.h" +#include "single.h" + +HFtype +__truncsfhf2 (SFtype a) +{ + FP_DECL_EX; + FP_DECL_S (A); + FP_DECL_H (R); + HFtype r; + + FP_INIT_ROUNDMODE; + FP_UNPACK_SEMIRAW_S (A, a); + FP_TRUNC (H, S, 1, 1, R, A); + FP_PACK_SEMIRAW_H (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/libgcc/soft-fp/truncxfhf2.c b/libgcc/soft-fp/truncxfhf2.c new file mode 100644 index 0000000..688ad24 --- /dev/null +++ b/libgcc/soft-fp/truncxfhf2.c @@ -0,0 +1,52 @@ +/* Software floating-point emulation. + Truncate IEEE extended into IEEE half. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "half.h" +#include "extended.h" + +HFtype +__truncxfhf2 (XFtype a) +{ + FP_DECL_EX; + FP_DECL_E (A); + FP_DECL_H (R); + HFtype r; + + FP_INIT_ROUNDMODE; + FP_UNPACK_SEMIRAW_E (A, a); +#if _FP_W_TYPE_SIZE < 64 + FP_TRUNC (H, E, 1, 4, R, A); +#else + FP_TRUNC (H, E, 1, 2, R, A); +#endif + FP_PACK_SEMIRAW_H (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/libgcc/unwind-arm-common.inc b/libgcc/unwind-arm-common.inc index c9b70c1..77ec02e 100644 --- a/libgcc/unwind-arm-common.inc +++ b/libgcc/unwind-arm-common.inc @@ -50,10 +50,6 @@ #define ARM_SIGCONTEXT_R0 0xc #endif -/* We add a prototype for abort here to avoid creating a dependency on - target headers. */ -extern void abort (void); - /* Definitions for C++ runtime support routines. We make these weak declarations to avoid pulling in libsupc++ unnecessarily. */ typedef unsigned char bool; |