diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-07-27 10:15:41 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-07-27 10:15:41 -0700 |
commit | 9f62ed218fa656607740b386c0caa03e65dcd283 (patch) | |
tree | 6bde49bc5e4c4241266b108e4277baef4b85535d /libgcc | |
parent | 71e955da39cea0ebffcfee3432effa622d14ca99 (diff) | |
parent | 5eb9f117a361538834b9740d59219911680717d1 (diff) | |
download | gcc-9f62ed218fa656607740b386c0caa03e65dcd283.zip gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.gz gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.bz2 |
Merge from trunk revision 5eb9f117a361538834b9740d59219911680717d1.
Diffstat (limited to 'libgcc')
61 files changed, 1196 insertions, 1811 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 035bfb5..fcae8df 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,199 @@ +2022-07-18 Claudiu Zissulescu <claziss@synopsys.com> + + * config/arc/lib2funcs.c (udivmodsi4): Update AND mask. + * config/arc/lib1funcs.S (umodsi3): Don't use it for RF16 + configurations. + +2022-06-25 Jeff Law <jeffreyalaw@gmail.com> + + * config.host: Removed tilegx and tilepro entries. + * config/tilegx/sfp-machine.h: Removed. + * config/tilegx/sfp-machine32.h: Removed. + * config/tilegx/sfp-machine64.h: Removed. + * config/tilegx/t-crtstuff: Removed. + * config/tilegx/t-softfp: Removed. + * config/tilegx/t-tilegx: Removed. + * config/tilepro/atomic.c: Removed. + * config/tilepro/atomic.h: Removed. + * config/tilepro/linux-unwind.h: Removed. + * config/tilepro/sfp-machine.h: Removed. + * config/tilepro/softdivide.c: Removed. + * config/tilepro/softmpy.S: Removed. + * config/tilepro/t-crtstuff: Removed. + * config/tilepro/t-tilepro: Removed. + +2022-06-09 Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp> + + * config/xtensa/lib1funcs.S (__clrsbsi2): New function. + * config/xtensa/t-xtensa (LIB1ASMFUNCS): Add _clrsbsi2. + +2022-06-01 H.J. Lu <hjl.tools@gmail.com> + + PR libgcc/27576 + * crtstuff.c (__EH_FRAME_BEGIN__): Aligned to pointer size. + +2022-05-25 Wilco Dijkstra <wilco.dijkstra@arm.com> + + PR libgcc/105708 + * config/aarch64/lse-init.c: Increase constructor priority. + +2022-05-25 Szabolcs Nagy <szabolcs.nagy@arm.com> + + PR target/104689 + * config/aarch64/aarch64-unwind.h (aarch64_frob_update_context): + Handle the !REG_UNSAVED case. + * unwind-dw2.c (execute_cfa_program): Fail toggle if !REG_UNSAVED. + +2022-05-20 Christophe Lyon <christophe.lyon@arm.com> + + * Makefile.in (D32PBIT_FUNCS): Add _hf_to_sd and _sd_to_hf. + (D64PBIT_FUNCS): Add _hf_to_dd and _dd_to_hf. + (D128PBIT_FUNCS): Add _hf_to_td _td_to_hf. + +2022-05-20 Christophe Lyon <christophe.lyon@arm.com> + + * config.host: Add t-dfprules to AArch64 targets. + +2022-05-20 Christophe Lyon <christophe.lyon@arm.com> + + * configure: Regenerate. + +2022-05-13 Sebastian Pop <spop@amazon.com> + + PR target/105162 + * config/aarch64/lse.S: Define BARRIER and handle memory MODEL 5. + * config/aarch64/t-lse: Add a 5th memory model for _sync functions. + +2022-05-10 Martin Liska <mliska@suse.cz> + Hans-Peter Helfert <peter-helfert@t-online.de> + + PR gcov-profile/105535 + * libgcov.h (struct gcov_info): Use gcov_unsigned_t for + n_functions. + +2022-05-02 Martin Liska <mliska@suse.cz> + + * libgcov-driver.c: Add ATTRIBUTE_UNUSED. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-util.c (ftw_read_file): Improve notice using xstrerror(). + (gcov_profile_merge_stream): Likewise. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-util.c (consume_stream): New. + (get_target_profiles_for_merge): Likewise. + (gcov_profile_merge_stream): Likewise. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-util.c (ftw_read_file): Use size_t for strlen() variables. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-util.c (read_gcda_file): Do not open file. + (ftw_read_file): Open file here. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-util.c (read_gcda_file): Prepend new info object to global + list. + (ftw_read_file): Remove list append here. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-util.c (read_gcda_file): Do not duplicate filename. + (ftw_read_file): Duplicate filename for read_gcda_file(). + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * gcov.h (__gcov_info_to_gcda): Mention __gcov_filename_to_gcfn(). + (__gcov_filename_to_gcfn): Declare and document. + * libgcov-driver.c (dump_string): New. + (__gcov_filename_to_gcfn): Likewise. + (__gcov_info_to_gcda): Adjust comment to match C11 standard language. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov.h (gcov_seek): Remove define and declaration. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-driver-system.c (gcov_exit_open_gcda_file): Add mode + parameter. Pass mode to gcov_open() calls. + * libgcov-driver.c (dump_one_gcov): Add mode parameter. Pass mode to + gcov_exit_open_gcda_file() call. + (gcov_do_dump): Add mode parameter. Pass mode to dump_one_gcov() + calls. + (__gcov_dump_one): Open file for reading and writing. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-driver-system.c (gcov_exit_open_gcda_file): Open file for + reading and writing. + * libgcov-util.c (read_gcda_file): Open file for reading. + * libgcov.h (gcov_open): Delete declaration. + +2022-04-28 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libgcov-util.c (gcov_profile_merge): Return the list of merged + profiles. Accept empty target and source profile lists. + +2022-04-08 Sergei Trofimovich <siarheit@google.com> + + * config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode. + +2022-03-29 Chenghua Xu <xuchenghua@loongson.cn> + Lulu Cheng <chenglulu@loongson.cn> + + * configure: Regenerate file. + +2022-03-29 Chenghua Xu <xuchenghua@loongson.cn> + Lulu Cheng <chenglulu@loongson.cn> + + * config/loongarch/crtfastmath.c: New file. + * config/loongarch/linux-unwind.h: Like wise. + * config/loongarch/sfp-machine.h: Like wise. + * config/loongarch/t-crtstuff: Like wise. + * config/loongarch/t-loongarch: Like wise. + * config/loongarch/t-loongarch64: Like wise. + * config/loongarch/t-softfp-tf: Like wise. + * config.host: Add LoongArch tuples. + * configure.ac: Add LoongArch support. + +2022-03-19 Sergei Trofimovich <slyfox at gentoo dot org> + + PR libgcc/86224 + * config/m68k/lb1sf68.S (__mulsi3_internal): Internal, hidden alias + for __mulsi3. + (__udivsi3_internal, __divsi3_internal): Similarly. + (__umodsi3, __modsi3): Use the internal function names. + +2022-03-09 Tobias Burnus <tobias@codesourcery.com> + + PR target/102215 + * config/gcn/atomic.c (__sync_val_compare_and_swap_##SIZE): Move + a line up to non-arg-dependent value first. + (__ATOMIC_COMPARE_EXCHANGE): Define + call to generate + __atomic_compare_exchange_{1,2}. + +2022-03-04 Iain Sandoe <iain@sandoe.co.uk> + + * config/rs6000/t-darwin-ehs: Add darwin-fallback.o. + * config/t-darwin-ehs: Add dependency on unwind.h. + +2022-02-24 Xi Ruoyao <xry111@mengyan1223.wang> + + * unwind-dw2-fde-dip.c (_Unwind_Find_FDE): Call find_fde_tail + with 0 instead of NULL. + +2022-02-24 Jose E. Marchesi <jose.marchesi@oracle.com> + + PR target/104656 + * configure.ac: --disable-gcov if targetting bpf-*. + * configure: Regenerate. + 2022-01-25 Florian Weimer <fweimer@redhat.com> PR libgcc/104207 diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 09b3ec8..1fe708a 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -677,7 +677,8 @@ D32PBIT_FUNCS = _addsub_sd _div_sd _mul_sd _plus_sd _minus_sd \ _si_to_sd _di_to_sd _usi_to_sd _udi_to_sd \ _sd_to_sf _sd_to_df _sd_to_xf _sd_to_tf \ _sf_to_sd _df_to_sd _xf_to_sd _tf_to_sd \ - _sd_to_dd _sd_to_td _unord_sd _conv_sd + _sd_to_dd _sd_to_td _unord_sd _conv_sd \ + _hf_to_sd _sd_to_hf D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \ _eq_dd _ne_dd _lt_dd _gt_dd _le_dd _ge_dd \ @@ -685,7 +686,8 @@ D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \ _si_to_dd _di_to_dd _usi_to_dd _udi_to_dd \ _dd_to_sf _dd_to_df _dd_to_xf _dd_to_tf \ _sf_to_dd _df_to_dd _xf_to_dd _tf_to_dd \ - _dd_to_sd _dd_to_td _unord_dd _conv_dd + _dd_to_sd _dd_to_td _unord_dd _conv_dd \ + _hf_to_dd _dd_to_hf D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \ _eq_td _ne_td _lt_td _gt_td _le_td _ge_td \ @@ -693,7 +695,8 @@ D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \ _si_to_td _di_to_td _usi_to_td _udi_to_td \ _td_to_sf _td_to_df _td_to_xf _td_to_tf \ _sf_to_td _df_to_td _xf_to_td _tf_to_td \ - _td_to_sd _td_to_dd _unord_td _conv_td + _td_to_sd _td_to_dd _unord_td _conv_td \ + _hf_to_td _td_to_hf ifeq ($(enable_decimal_float),bid) ifneq ($(D32PBIT),) diff --git a/libgcc/config.host b/libgcc/config.host index 094fd3a..b2a0a8e 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -138,6 +138,22 @@ hppa*-*-*) lm32*-*-*) cpu_type=lm32 ;; +loongarch*-*-*) + cpu_type=loongarch + tmake_file="loongarch/t-loongarch" + if test "${libgcc_cv_loongarch_hard_float}" = yes; then + tmake_file="${tmake_file} t-hardfp-sfdf t-hardfp" + else + tmake_file="${tmake_file} t-softfp-sfdf" + fi + if test "${ac_cv_sizeof_long_double}" = 16; then + tmake_file="${tmake_file} loongarch/t-softfp-tf" + fi + if test "${host_address}" = 64; then + tmake_file="${tmake_file} loongarch/t-loongarch64" + fi + tmake_file="${tmake_file} t-softfp" + ;; m32r*-*-*) cpu_type=m32r ;; @@ -196,12 +212,6 @@ s390*-*-*) sh[123456789lbe]*-*-*) cpu_type=sh ;; -tilegx*-*-*) - cpu_type=tilegx - ;; -tilepro*-*-*) - cpu_type=tilepro - ;; v850*-*-*) cpu_type=v850 ;; @@ -366,6 +376,7 @@ aarch64*-*-elf | aarch64*-*-rtems*) tmake_file="${tmake_file} ${cpu_type}/t-aarch64" tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + tmake_file="${tmake_file} t-dfprules" md_unwind_header=aarch64/aarch64-unwind.h ;; aarch64*-*-freebsd*) @@ -373,18 +384,21 @@ aarch64*-*-freebsd*) tmake_file="${tmake_file} ${cpu_type}/t-aarch64" tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + tmake_file="${tmake_file} t-dfprules" md_unwind_header=aarch64/freebsd-unwind.h ;; aarch64*-*-netbsd*) extra_parts="$extra_parts crtfastmath.o" tmake_file="${tmake_file} ${cpu_type}/t-aarch64" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + tmake_file="${tmake_file} t-dfprules" md_unwind_header=aarch64/aarch64-unwind.h ;; aarch64*-*-fuchsia*) tmake_file="${tmake_file} ${cpu_type}/t-aarch64" tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp" + tmake_file="${tmake_file} t-dfprules" ;; aarch64*-*-linux*) extra_parts="$extra_parts crtfastmath.o" @@ -392,6 +406,7 @@ aarch64*-*-linux*) tmake_file="${tmake_file} ${cpu_type}/t-aarch64" tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + tmake_file="${tmake_file} t-dfprules" ;; aarch64*-*-vxworks7*) extra_parts="$extra_parts crtfastmath.o" @@ -399,6 +414,7 @@ aarch64*-*-vxworks7*) tmake_file="${tmake_file} ${cpu_type}/t-aarch64" tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + tmake_file="${tmake_file} t-dfprules" ;; alpha*-*-linux*) tmake_file="${tmake_file} alpha/t-alpha alpha/t-ieee t-crtfm alpha/t-linux" @@ -925,7 +941,17 @@ lm32-*-rtems*) lm32-*-uclinux*) extra_parts="$extra_parts crtbegin.o crtendS.o crtbeginT.o" tmake_file="lm32/t-lm32 lm32/t-uclinux t-libgcc-pic t-softfp-sfdf t-softfp" - ;; + ;; +loongarch*-*-linux*) + extra_parts="$extra_parts crtfastmath.o" + tmake_file="${tmake_file} t-crtfm loongarch/t-crtstuff" + case ${host} in + *) + tmake_file="${tmake_file} t-slibgcc-libgcc" + ;; + esac + md_unwind_header=loongarch/linux-unwind.h + ;; m32r-*-elf*) tmake_file="$tmake_file m32r/t-m32r t-fdpbit" extra_parts="$extra_parts crtinit.o crtfini.o" @@ -1455,17 +1481,6 @@ tic6x-*-elf) extra_parts="$extra_parts crtbeginS.o crtendS.o crti.o crtn.o" unwind_header=config/c6x/unwind-c6x.h ;; -tilegx*-*-linux*) - if test "${host_address}" = 64; then - tmake_file="${tmake_file} tilegx/t-softfp" - fi - tmake_file="${tmake_file} tilegx/t-crtstuff t-softfp-sfdf t-softfp tilegx/t-tilegx" - md_unwind_header=tilepro/linux-unwind.h - ;; -tilepro*-*-linux*) - tmake_file="${tmake_file} tilepro/t-crtstuff t-softfp-sfdf t-softfp tilepro/t-tilepro t-slibgcc-libgcc" - md_unwind_header=tilepro/linux-unwind.h - ;; v850*-*-*) tmake_file="${tmake_file} v850/t-v850 t-fdpbit" ;; diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h index 40b22d3..e082e95 100644 --- a/libgcc/config/aarch64/aarch64-unwind.h +++ b/libgcc/config/aarch64/aarch64-unwind.h @@ -78,7 +78,13 @@ static inline void aarch64_frob_update_context (struct _Unwind_Context *context, _Unwind_FrameState *fs) { - if (fs->regs.reg[DWARF_REGNUM_AARCH64_RA_STATE].loc.offset & 0x1) + const int reg = DWARF_REGNUM_AARCH64_RA_STATE; + int ra_signed; + if (fs->regs.reg[reg].how == REG_UNSAVED) + ra_signed = fs->regs.reg[reg].loc.offset & 0x1; + else + ra_signed = _Unwind_GetGR (context, reg) & 0x1; + if (ra_signed) /* The flag is used for re-authenticating EH handler's address. */ context->flags |= RA_SIGNED_BIT; else diff --git a/libgcc/config/aarch64/lse-init.c b/libgcc/config/aarch64/lse-init.c index fc875b7..33b97c8 100644 --- a/libgcc/config/aarch64/lse-init.c +++ b/libgcc/config/aarch64/lse-init.c @@ -38,7 +38,9 @@ _Bool __aarch64_have_lse_atomics unsigned long int __getauxval (unsigned long int); -static void __attribute__((constructor)) +/* Use a higher priority to ensure it runs before user constructors + and library constructors with priority 100. */ +static void __attribute__((constructor (90))) init_have_lse_atomics (void) { unsigned long hwcap = __getauxval (AT_HWCAP); diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S index c353ec2..9c29cf0 100644 --- a/libgcc/config/aarch64/lse.S +++ b/libgcc/config/aarch64/lse.S @@ -87,24 +87,44 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define L # define M 0x000000 # define N 0x000000 +# define BARRIER #elif MODEL == 2 # define SUFF _acq # define A a # define L # define M 0x400000 # define N 0x800000 +# define BARRIER #elif MODEL == 3 # define SUFF _rel # define A # define L l # define M 0x008000 # define N 0x400000 +# define BARRIER #elif MODEL == 4 # define SUFF _acq_rel # define A a # define L l # define M 0x408000 # define N 0xc00000 +# define BARRIER +#elif MODEL == 5 +# define SUFF _sync +#ifdef L_swp +/* swp has _acq semantics. */ +# define A a +# define L +# define M 0x400000 +# define N 0x800000 +#else +/* All other _sync functions have _seq semantics. */ +# define A a +# define L l +# define M 0x408000 +# define N 0xc00000 +#endif +# define BARRIER dmb ish #else # error #endif @@ -127,7 +147,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif #define NAME(BASE) glue4(__aarch64_, BASE, SIZE, SUFF) -#define LDXR glue4(ld, A, xr, S) +#if MODEL == 5 +/* Drop A for _sync functions. */ +# define LDXR glue3(ld, xr, S) +#else +# define LDXR glue4(ld, A, xr, S) +#endif #define STXR glue4(st, L, xr, S) /* Temporary registers used. Other than these, only the return value @@ -183,10 +208,16 @@ STARTFN NAME(cas) bne 1f STXR w(tmp1), s(1), [x2] cbnz w(tmp1), 0b -1: ret +1: BARRIER + ret #else -#define LDXP glue3(ld, A, xp) +#if MODEL == 5 +/* Drop A for _sync functions. */ +# define LDXP glue2(ld, xp) +#else +# define LDXP glue3(ld, A, xp) +#endif #define STXP glue3(st, L, xp) #ifdef HAVE_AS_LSE # define CASP glue3(casp, A, L) x0, x1, x2, x3, [x4] @@ -205,7 +236,8 @@ STARTFN NAME(cas) bne 1f STXP w(tmp2), x2, x3, [x4] cbnz w(tmp2), 0b -1: ret +1: BARRIER + ret #endif @@ -229,6 +261,7 @@ STARTFN NAME(swp) 0: LDXR s(0), [x1] STXR w(tmp1), s(tmp0), [x1] cbnz w(tmp1), 0b + BARRIER ret ENDFN NAME(swp) @@ -273,6 +306,7 @@ STARTFN NAME(LDNM) OP s(tmp1), s(0), s(tmp0) STXR w(tmp2), s(tmp1), [x1] cbnz w(tmp2), 0b + BARRIER ret ENDFN NAME(LDNM) diff --git a/libgcc/config/aarch64/t-lse b/libgcc/config/aarch64/t-lse index 790cada..624daf7 100644 --- a/libgcc/config/aarch64/t-lse +++ b/libgcc/config/aarch64/t-lse @@ -18,13 +18,13 @@ # along with GCC; see the file COPYING3. If not see # <http://www.gnu.org/licenses/>. -# Compare-and-swap has 5 sizes and 4 memory models. +# Compare-and-swap has 5 sizes and 5 memory models. S0 := $(foreach s, 1 2 4 8 16, $(addsuffix _$(s), cas)) -O0 := $(foreach m, 1 2 3 4, $(addsuffix _$(m)$(objext), $(S0))) +O0 := $(foreach m, 1 2 3 4 5, $(addsuffix _$(m)$(objext), $(S0))) -# Swap, Load-and-operate have 4 sizes and 4 memory models +# Swap, Load-and-operate have 4 sizes and 5 memory models S1 := $(foreach s, 1 2 4 8, $(addsuffix _$(s), swp ldadd ldclr ldeor ldset)) -O1 := $(foreach m, 1 2 3 4, $(addsuffix _$(m)$(objext), $(S1))) +O1 := $(foreach m, 1 2 3 4 5, $(addsuffix _$(m)$(objext), $(S1))) LSE_OBJS := $(O0) $(O1) diff --git a/libgcc/config/arc/lib1funcs.S b/libgcc/config/arc/lib1funcs.S index 14fd1d2..b063612 100644 --- a/libgcc/config/arc/lib1funcs.S +++ b/libgcc/config/arc/lib1funcs.S @@ -936,6 +936,7 @@ SYM(__divsi3): #endif /* L_divsi3 */ +#ifndef __ARC_RF16__ #ifdef L_umodsi3 .section .text .align 4 @@ -950,6 +951,7 @@ SYM(__umodsi3): ENDFUNC(__umodsi3) #endif /* L_umodsi3 */ +#endif /* !__ARC_RF16__ */ #ifdef L_modsi3 .section .text diff --git a/libgcc/config/arc/lib2funcs.c b/libgcc/config/arc/lib2funcs.c index 70727b5..8cba451 100644 --- a/libgcc/config/arc/lib2funcs.c +++ b/libgcc/config/arc/lib2funcs.c @@ -59,7 +59,7 @@ udivmodsi4 (nint32_t num, nint32_t den, word_t modwanted) nint32_t bit = 1; nint32_t res = 0; - while (den < num && bit && !(den & (1LL << 63))) + while (den < num && bit && !(den & (1L << 31))) { den <<= 1; bit <<= 1; diff --git a/libgcc/config/gcn/atomic.c b/libgcc/config/gcn/atomic.c index 8784f90..cf29fa8 100644 --- a/libgcc/config/gcn/atomic.c +++ b/libgcc/config/gcn/atomic.c @@ -28,9 +28,9 @@ TYPE \ __sync_val_compare_and_swap_##SIZE (TYPE *ptr, TYPE oldval, TYPE newval) \ { \ + unsigned int valmask = (1 << (SIZE * 8)) - 1; \ unsigned int *wordptr = (unsigned int *)((__UINTPTR_TYPE__ ) ptr & ~3UL); \ int shift = ((__UINTPTR_TYPE__ ) ptr & 3UL) * 8; \ - unsigned int valmask = (1 << (SIZE * 8)) - 1; \ unsigned int wordmask = ~(valmask << shift); \ unsigned int oldword = *wordptr; \ for (;;) \ @@ -57,3 +57,30 @@ __sync_bool_compare_and_swap_##SIZE (TYPE *ptr, TYPE oldval, TYPE newval) \ __SYNC_SUBWORD_COMPARE_AND_SWAP (unsigned char, 1) __SYNC_SUBWORD_COMPARE_AND_SWAP (unsigned short, 2) + +#define __ATOMIC_COMPARE_EXCHANGE(TYPE,SIZE) \ +bool \ +__atomic_compare_exchange_##SIZE (TYPE *ptr, TYPE *expected, \ + TYPE desired, bool weak, \ + int success_memorder, int failure_memorder) \ +{ \ + unsigned int valmask = (1 << (SIZE * 8)) - 1; \ + \ + unsigned int *wordptr = (unsigned int *)((__UINTPTR_TYPE__ ) ptr & ~3UL); \ + int ptrshift = ((__UINTPTR_TYPE__ ) ptr & 3UL) * 8; \ + unsigned int wordmask = ~(valmask << ptrshift); \ + \ + unsigned int ptrword = *wordptr; \ + unsigned int exptword = ptrword & wordmask; \ + unsigned int newword = ptrword & wordmask; \ + exptword |= ((unsigned int) *expected) << ptrshift; \ + newword |= ((unsigned int) desired) << ptrshift; \ + if (__atomic_compare_exchange_4 (wordptr, &exptword, newword, weak, \ + success_memorder, failure_memorder)) \ + return true; \ + *expected = (TYPE) ((exptword >> ptrshift) & valmask); \ + return false; \ +} + +__ATOMIC_COMPARE_EXCHANGE (unsigned char, 1) +__ATOMIC_COMPARE_EXCHANGE (unsigned short, 2) diff --git a/libgcc/config/ia64/fde-glibc.c b/libgcc/config/ia64/fde-glibc.c index 9caac2b..bd74847 100644 --- a/libgcc/config/ia64/fde-glibc.c +++ b/libgcc/config/ia64/fde-glibc.c @@ -29,6 +29,7 @@ #define _GNU_SOURCE 1 #endif #include "config.h" +#ifndef inhibit_libc #include <stddef.h> #include <stdlib.h> #include <link.h> @@ -159,3 +160,4 @@ _Unwind_FindTableEntry (void *pc, unw_word *segment_base, unw_word *gp, return data.ret; } +#endif diff --git a/libgcc/config/libbid/ChangeLog b/libgcc/config/libbid/ChangeLog index b26ca33..d3cec76 100644 --- a/libgcc/config/libbid/ChangeLog +++ b/libgcc/config/libbid/ChangeLog @@ -1,3 +1,51 @@ +2022-05-20 Christophe Lyon <christophe.lyon@arm.com> + + * bid_binarydecimal.c (CLZ32_MASK16): Delete. + (CLZ32_MASK8): Delete. + (CLZ32_MASK4): Delete. + (CLZ32_MASK2): Delete. + (CLZ32_MASK1): Delete. + (clz32_nz): Use __builtin_clz. + (ctz32_1bit): Delete. + (ctz32): Use __builtin_ctz. + (CLZ64_MASK32): Delete. + (CLZ64_MASK16): Delete. + (CLZ64_MASK8): Delete. + (CLZ64_MASK4): Delete. + (CLZ64_MASK2): Delete. + (CLZ64_MASK1): Delete. + (clz64_nz): Use __builtin_clzl. + (ctz64_1bit): Delete. + (ctz64): Use __builtin_ctzl. + +2022-05-20 Christophe Lyon <christophe.lyon@arm.com> + + * bid_gcc_intrinsics.h (LIBGCC2_HAS_HF_MODE): Define according to + __LIBGCC_HAS_HF_MODE__. + (BID_HAS_HF_MODE): Define. + (HFtype): Define. + (__bid_extendhfsd): New prototype. + (__bid_extendhfdd): Likewise. + (__bid_extendhftd): Likewise. + (__bid_truncsdhf): Likewise. + (__bid_truncddhf): Likewise. + (__bid_trunctdhf): Likewise. + * _dd_to_hf.c: New file. + * _hf_to_dd.c: New file. + * _hf_to_sd.c: New file. + * _hf_to_td.c: New file. + * _sd_to_hf.c: New file. + * _td_to_hf.c: New file. + +2022-05-20 Christophe Lyon <christophe.lyon@arm.com> + + * _dd_to_xf.c: Check __LIBGCC_HAS_XF_MODE__. + * _sd_to_xf.c: Likewise. + * _td_to_xf.c: Likewise. + * _xf_to_dd.c: Likewise. + * _xf_to_sd.c: Likewise. + * _xf_to_td.c: Likewise. + 2020-10-23 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97164 diff --git a/libgcc/config/libbid/_dd_to_hf.c b/libgcc/config/libbid/_dd_to_hf.c new file mode 100644 index 0000000..5e58288 --- /dev/null +++ b/libgcc/config/libbid/_dd_to_hf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2022 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/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +HFtype +__bid_truncddhf (_Decimal64 x) { + HFtype res; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_binary32 (ux.i); + return (res); +} +#endif diff --git a/libgcc/config/libbid/_dd_to_xf.c b/libgcc/config/libbid/_dd_to_xf.c index 5a2abbb..e4b12e8 100644 --- a/libgcc/config/libbid/_dd_to_xf.c +++ b/libgcc/config/libbid/_dd_to_xf.c @@ -25,6 +25,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "bid_functions.h" #include "bid_gcc_intrinsics.h" +#ifdef __LIBGCC_HAS_XF_MODE__ XFtype __bid_extendddxf (_Decimal64 x) { XFtype res; @@ -34,3 +35,4 @@ __bid_extendddxf (_Decimal64 x) { res = __bid64_to_binary80 (ux.i); return (res); } +#endif diff --git a/libgcc/config/libbid/_hf_to_dd.c b/libgcc/config/libbid/_hf_to_dd.c new file mode 100644 index 0000000..f85100e --- /dev/null +++ b/libgcc/config/libbid/_hf_to_dd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2022 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/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +_Decimal64 +__bid_extendhfdd (HFtype x) { + union decimal64 res; + SFtype xsf = x; + res.i = __binary32_to_bid64 (xsf); + return (res.d); +} +#endif diff --git a/libgcc/config/libbid/_hf_to_sd.c b/libgcc/config/libbid/_hf_to_sd.c new file mode 100644 index 0000000..285b80c --- /dev/null +++ b/libgcc/config/libbid/_hf_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2022 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/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +_Decimal32 +__bid_extendhfsd (HFtype x) { + union decimal32 res; + SFtype xsf = x; + res.i = __binary32_to_bid32 (xsf); + return (res.d); +} +#endif diff --git a/libgcc/config/libbid/_hf_to_td.c b/libgcc/config/libbid/_hf_to_td.c new file mode 100644 index 0000000..99b661e --- /dev/null +++ b/libgcc/config/libbid/_hf_to_td.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2022 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/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +_Decimal128 +__bid_extendhftd (HFtype x) { + union decimal128 res; + SFtype xsf = x; + res.i = __binary32_to_bid128 (xsf); + return (res.d); +} +#endif diff --git a/libgcc/config/libbid/_sd_to_hf.c b/libgcc/config/libbid/_sd_to_hf.c new file mode 100644 index 0000000..e4e3125 --- /dev/null +++ b/libgcc/config/libbid/_sd_to_hf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2022 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/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +HFtype +__bid_truncsdhf (_Decimal32 x) { + HFtype res; + union decimal32 ux; + + ux.d = x; + res = __bid32_to_binary32 (ux.i); + return (res); +} +#endif diff --git a/libgcc/config/libbid/_sd_to_xf.c b/libgcc/config/libbid/_sd_to_xf.c index 9af0991..288ccb2 100644 --- a/libgcc/config/libbid/_sd_to_xf.c +++ b/libgcc/config/libbid/_sd_to_xf.c @@ -25,6 +25,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "bid_functions.h" #include "bid_gcc_intrinsics.h" +#ifdef __LIBGCC_HAS_XF_MODE__ XFtype __bid_extendsdxf (_Decimal32 x) { XFtype res; @@ -34,3 +35,4 @@ __bid_extendsdxf (_Decimal32 x) { res = __bid32_to_binary80 (ux.i); return (res); } +#endif diff --git a/libgcc/config/libbid/_td_to_hf.c b/libgcc/config/libbid/_td_to_hf.c new file mode 100644 index 0000000..c4ebe58 --- /dev/null +++ b/libgcc/config/libbid/_td_to_hf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2022 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/>. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +HFtype +__bid_trunctdhf (_Decimal128 x) { + HFtype res; + union decimal128 ux; + + ux.d = x; + res = __bid128_to_binary32 (ux.i); + return (res); +} +#endif diff --git a/libgcc/config/libbid/_td_to_xf.c b/libgcc/config/libbid/_td_to_xf.c index b0c76a7..e990282 100644 --- a/libgcc/config/libbid/_td_to_xf.c +++ b/libgcc/config/libbid/_td_to_xf.c @@ -25,6 +25,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "bid_functions.h" #include "bid_gcc_intrinsics.h" +#ifdef __LIBGCC_HAS_XF_MODE__ XFtype __bid_trunctdxf (_Decimal128 x) { XFtype res; @@ -34,3 +35,4 @@ __bid_trunctdxf (_Decimal128 x) { res = __bid128_to_binary80 (ux.i); return (res); } +#endif diff --git a/libgcc/config/libbid/_xf_to_dd.c b/libgcc/config/libbid/_xf_to_dd.c index 9feb0f2..e3246a1 100644 --- a/libgcc/config/libbid/_xf_to_dd.c +++ b/libgcc/config/libbid/_xf_to_dd.c @@ -25,9 +25,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "bid_functions.h" #include "bid_gcc_intrinsics.h" +#ifdef __LIBGCC_HAS_XF_MODE__ _Decimal64 __bid_truncxfdd (XFtype x) { union decimal64 res; res.i = __binary80_to_bid64 (x); return (res.d); } +#endif diff --git a/libgcc/config/libbid/_xf_to_sd.c b/libgcc/config/libbid/_xf_to_sd.c index 7d46548..9147e97 100644 --- a/libgcc/config/libbid/_xf_to_sd.c +++ b/libgcc/config/libbid/_xf_to_sd.c @@ -25,9 +25,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "bid_functions.h" #include "bid_gcc_intrinsics.h" +#ifdef __LIBGCC_HAS_XF_MODE__ _Decimal32 __bid_truncxfsd (XFtype x) { union decimal32 res; res.i = __binary80_to_bid32 (x); return (res.d); } +#endif diff --git a/libgcc/config/libbid/_xf_to_td.c b/libgcc/config/libbid/_xf_to_td.c index 07987fd..c8d102b 100644 --- a/libgcc/config/libbid/_xf_to_td.c +++ b/libgcc/config/libbid/_xf_to_td.c @@ -25,9 +25,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "bid_functions.h" #include "bid_gcc_intrinsics.h" +#ifdef __LIBGCC_HAS_XF_MODE__ _Decimal128 __bid_extendxftd (XFtype x) { union decimal128 res; res.i = __binary80_to_bid128 (x); return (res.d); } +#endif diff --git a/libgcc/config/libbid/bid_binarydecimal.c b/libgcc/config/libbid/bid_binarydecimal.c index e156ea6..5413acc 100644 --- a/libgcc/config/libbid/bid_binarydecimal.c +++ b/libgcc/config/libbid/bid_binarydecimal.c @@ -26,65 +26,22 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // Counting leading zeros in an unsigned 32-bit word // The "_nz" version will return the wrong answer (31) for zero inputs -#define CLZ32_MASK16 0xFFFF0000ul -#define CLZ32_MASK8 0xFF00FF00ul -#define CLZ32_MASK4 0xF0F0F0F0ul -#define CLZ32_MASK2 0xCCCCCCCCul -#define CLZ32_MASK1 0xAAAAAAAAul - -#define clz32_nz(n) \ - (((((n) & CLZ32_MASK16) <= ((n) & ~CLZ32_MASK16)) ? 16 : 0) + \ - ((((n) & CLZ32_MASK8) <= ((n) & ~CLZ32_MASK8)) ? 8 : 0) + \ - ((((n) & CLZ32_MASK4) <= ((n) & ~CLZ32_MASK4)) ? 4 : 0) + \ - ((((n) & CLZ32_MASK2) <= ((n) & ~CLZ32_MASK2)) ? 2 : 0) + \ - ((((n) & CLZ32_MASK1) <= ((n) & ~CLZ32_MASK1)) ? 1 : 0)) - +#define clz32_nz(n) (__builtin_clz (n)) #define clz32(n) (((n)==0) ? 32 : clz32_nz(n)) // Counting trailing zeros in an unsigned 32-bit word -// The ctz32_1bit version is for a single bit - -#define ctz32_1bit(n) \ - ((((n) & ~CLZ32_MASK16) ? 0 : 16) + \ - (((n) & ~CLZ32_MASK8) ? 0 : 8) + \ - (((n) & ~CLZ32_MASK4) ? 0 : 4) + \ - (((n) & ~CLZ32_MASK2) ? 0 : 2) + \ - (((n) & ~CLZ32_MASK1) ? 0 : 1)) +#define ctz32(n) (__builtin_ctz (n)) -#define ctz32(n) (((n) == 0) ? 32 : ctz32_1bit((n) & -(n))) // Counting leading zeros in an unsigned 64-bit word // The "_nz" version will return the wrong answer (63) for zero inputs -#define CLZ64_MASK32 0xFFFFFFFF00000000ull -#define CLZ64_MASK16 0xFFFF0000FFFF0000ull -#define CLZ64_MASK8 0xFF00FF00FF00FF00ull -#define CLZ64_MASK4 0xF0F0F0F0F0F0F0F0ull -#define CLZ64_MASK2 0xCCCCCCCCCCCCCCCCull -#define CLZ64_MASK1 0xAAAAAAAAAAAAAAAAull - -#define clz64_nz(n) \ - (((((n) & CLZ64_MASK32) <= ((n) & ~CLZ64_MASK32)) ? 32 : 0) + \ - ((((n) & CLZ64_MASK16) <= ((n) & ~CLZ64_MASK16)) ? 16 : 0) + \ - ((((n) & CLZ64_MASK8) <= ((n) & ~CLZ64_MASK8)) ? 8 : 0) + \ - ((((n) & CLZ64_MASK4) <= ((n) & ~CLZ64_MASK4)) ? 4 : 0) + \ - ((((n) & CLZ64_MASK2) <= ((n) & ~CLZ64_MASK2)) ? 2 : 0) + \ - ((((n) & CLZ64_MASK1) <= ((n) & ~CLZ64_MASK1)) ? 1 : 0)) \ - +#define clz64_nz(n) ( (__SIZEOF_LONG__ == 8) ?__builtin_clzl(n) : __builtin_clzll(n) ) #define clz64(n) (((n)==0) ? 64 : clz64_nz(n)) // Counting trailing zeros in an unsigned 64-bit word -// The ctz64_1bit version is for a single bit - -#define ctz64_1bit(n) \ - ((((n) & ~CLZ64_MASK32) ? 0 : 32) + \ - (((n) & ~CLZ64_MASK16) ? 0 : 16) + \ - (((n) & ~CLZ64_MASK8) ? 0 : 8) + \ - (((n) & ~CLZ64_MASK4) ? 0 : 4) + \ - (((n) & ~CLZ64_MASK2) ? 0 : 2) + \ - (((n) & ~CLZ64_MASK1) ? 0 : 1)) +#define ctz64(n) ( (__SIZEOF_LONG__ == 8) ?__builtin_ctzl(n) : __builtin_ctzll(n) ) -#define ctz64(n) (((n) == 0) ? 64 : ctz64_1bit((n) & -(n))) // Counting leading zeros in an unsigned 2-part 128-bit word diff --git a/libgcc/config/libbid/bid_gcc_intrinsics.h b/libgcc/config/libbid/bid_gcc_intrinsics.h index b0a23de..15c0507 100644 --- a/libgcc/config/libbid/bid_gcc_intrinsics.h +++ b/libgcc/config/libbid/bid_gcc_intrinsics.h @@ -31,6 +31,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "tm.h" #include "libgcc_tm.h" +#ifdef __LIBGCC_HAS_HF_MODE__ +#define LIBGCC2_HAS_HF_MODE 1 +#else +#define LIBGCC2_HAS_HF_MODE 0 +#endif + #ifdef __LIBGCC_HAS_XF_MODE__ #define LIBGCC2_HAS_XF_MODE 1 #else @@ -43,6 +49,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define LIBGCC2_HAS_TF_MODE 0 #endif +#ifndef BID_HAS_HF_MODE +#define BID_HAS_HF_MODE LIBGCC2_HAS_HF_MODE +#endif + #ifndef BID_HAS_XF_MODE #define BID_HAS_XF_MODE LIBGCC2_HAS_XF_MODE #endif @@ -53,6 +63,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* Some handy typedefs. */ +#if LIBGCC2_HAS_HF_MODE +typedef float HFtype __attribute__ ((mode (HF))); +#endif /* LIBGCC2_HAS_HF_MODE */ typedef float SFtype __attribute__ ((mode (SF))); typedef float DFtype __attribute__ ((mode (DF))); #if LIBGCC2_HAS_XF_MODE @@ -98,6 +111,12 @@ typedef __attribute__ ((aligned(16))) struct #endif #endif +#if BID_HAS_HF_MODE +#ifndef HFtype +#define HFtype _Float16 +#endif +#endif + #ifndef SFtype #define SFtype float #endif @@ -110,8 +129,7 @@ typedef __attribute__ ((aligned(16))) struct #ifndef XFtype #define XFtype long double #endif - -#endif /* IN_LIBGCC2 */ +#endif #if BID_HAS_TF_MODE #ifndef TFtype @@ -249,6 +267,14 @@ extern _Decimal128 __bid_extendxftd (XFtype); extern int isinfd32 (_Decimal32); extern int isinfd64 (_Decimal64); extern int isinfd128 (_Decimal128); +#if BID_HAS_HF_MODE +extern _Decimal32 __bid_extendhfsd (HFtype); +extern _Decimal64 __bid_extendhfdd (HFtype); +extern _Decimal128 __bid_extendhftd (HFtype); +extern HFtype __bid_truncsdhf (_Decimal32); +extern HFtype __bid_truncddhf (_Decimal64); +extern HFtype __bid_trunctdhf (_Decimal128); +#endif #endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ extern void __dfp_set_round (int); diff --git a/libgcc/config/loongarch/crtfastmath.c b/libgcc/config/loongarch/crtfastmath.c new file mode 100644 index 0000000..52b0d6d --- /dev/null +++ b/libgcc/config/loongarch/crtfastmath.c @@ -0,0 +1,52 @@ +/* Copyright (C) 2021-2022 Free Software Foundation, Inc. + Contributed by Loongson Ltd. + Based on MIPS target for GNU compiler. + +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/>. */ + +#ifdef __loongarch_hard_float + +/* Rounding control. */ +#define _FPU_RC_NEAREST 0x000 /* RECOMMENDED. */ +#define _FPU_RC_ZERO 0x100 +#define _FPU_RC_UP 0x200 +#define _FPU_RC_DOWN 0x300 + +/* Enable interrupts for IEEE exceptions. */ +#define _FPU_IEEE 0x0000001F + +/* Macros for accessing the hardware control word. */ +#define _FPU_GETCW(cw) __asm__ volatile ("movfcsr2gr %0,$r0" : "=r" (cw)) +#define _FPU_SETCW(cw) __asm__ volatile ("movgr2fcsr $r0,%0" : : "r" (cw)) + +static void __attribute__((constructor)) +set_fast_math (void) +{ + unsigned int fcr; + + /* Flush to zero, round to nearest, IEEE exceptions disabled. */ + fcr = _FPU_RC_NEAREST; + + _FPU_SETCW (fcr); +} + +#endif /* __loongarch_hard_float */ diff --git a/libgcc/config/loongarch/linux-unwind.h b/libgcc/config/loongarch/linux-unwind.h new file mode 100644 index 0000000..89c168c --- /dev/null +++ b/libgcc/config/loongarch/linux-unwind.h @@ -0,0 +1,80 @@ +/* DWARF2 EH unwinding support for LoongArch Linux. + Copyright (C) 2021-2022 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/>. */ + +#ifndef inhibit_libc +/* Do code reading to identify a signal frame, and set the frame + state data appropriately. See unwind-dw2.c for the structs. */ + +#include <signal.h> +#include <sys/syscall.h> +#include <sys/ucontext.h> + +#define MD_FALLBACK_FRAME_STATE_FOR loongarch_fallback_frame_state + +static _Unwind_Reason_Code +loongarch_fallback_frame_state (struct _Unwind_Context *context, + _Unwind_FrameState *fs) +{ + u_int32_t *pc = (u_int32_t *) context->ra; + struct sigcontext *sc; + _Unwind_Ptr new_cfa; + int i; + + /* 03822c0b li.d a7, 0x8b (sigreturn) */ + /* 002b0000 syscall 0 */ + if (pc[1] != 0x002b0000) + return _URC_END_OF_STACK; + if (pc[0] == 0x03822c0b) + { + struct rt_sigframe + { + siginfo_t info; + ucontext_t uc; + } *rt_ = context->cfa; + sc = (struct sigcontext *) (void *) &rt_->uc.uc_mcontext; + } + else + return _URC_END_OF_STACK; + + new_cfa = (_Unwind_Ptr) sc; + fs->regs.cfa_how = CFA_REG_OFFSET; + fs->regs.cfa_reg = __LIBGCC_STACK_POINTER_REGNUM__; + fs->regs.cfa_offset = new_cfa - (_Unwind_Ptr) context->cfa; + + for (i = 0; i < 32; i++) + { + fs->regs.reg[i].how = REG_SAVED_OFFSET; + fs->regs.reg[i].loc.offset = (_Unwind_Ptr) & (sc->sc_regs[i]) - new_cfa; + } + + fs->signal_frame = 1; + fs->regs.reg[__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__].how + = REG_SAVED_VAL_OFFSET; + fs->regs.reg[__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__].loc.offset + = (_Unwind_Ptr) (sc->sc_pc) - new_cfa; + fs->retaddr_column = __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__; + + return _URC_NO_REASON; +} +#endif diff --git a/libgcc/config/loongarch/sfp-machine.h b/libgcc/config/loongarch/sfp-machine.h new file mode 100644 index 0000000..c81be71 --- /dev/null +++ b/libgcc/config/loongarch/sfp-machine.h @@ -0,0 +1,152 @@ +/* softfp machine description for LoongArch. + Copyright (C) 2021-2022 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/>. */ + +#ifdef __loongarch64 +#define _FP_W_TYPE_SIZE 64 +#define _FP_W_TYPE unsigned long long +#define _FP_WS_TYPE signed long long +#define _FP_I_TYPE long long + +typedef int TItype __attribute__ ((mode (TI))); +typedef unsigned int UTItype __attribute__ ((mode (TI))); +#define TI_BITS (__CHAR_BIT__ * (int) sizeof (TItype)) + +#define _FP_MUL_MEAT_S(R, X, Y) \ + _FP_MUL_MEAT_1_wide (_FP_WFRACBITS_S, R, X, Y, umul_ppmm) +#define _FP_MUL_MEAT_D(R, X, Y) \ + _FP_MUL_MEAT_1_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm) +#define _FP_MUL_MEAT_Q(R, X, Y) \ + _FP_MUL_MEAT_2_wide (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm) + +#define _FP_DIV_MEAT_S(R, X, Y) _FP_DIV_MEAT_1_udiv_norm (S, R, X, Y) +#define _FP_DIV_MEAT_D(R, X, Y) _FP_DIV_MEAT_1_udiv_norm (D, R, X, Y) +#define _FP_DIV_MEAT_Q(R, X, Y) _FP_DIV_MEAT_2_udiv (Q, R, X, Y) + +#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1) +#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1) +#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1 +#else +#define _FP_W_TYPE_SIZE 32 +#define _FP_W_TYPE unsigned int +#define _FP_WS_TYPE signed int +#define _FP_I_TYPE int + +#define _FP_MUL_MEAT_S(R, X, Y) \ + _FP_MUL_MEAT_1_wide (_FP_WFRACBITS_S, R, X, Y, umul_ppmm) +#define _FP_MUL_MEAT_D(R, X, Y) \ + _FP_MUL_MEAT_2_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm) +#define _FP_MUL_MEAT_Q(R, X, Y) \ + _FP_MUL_MEAT_4_wide (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm) + +#define _FP_DIV_MEAT_S(R, X, Y) _FP_DIV_MEAT_1_udiv_norm (S, R, X, Y) +#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_S ((_FP_QNANBIT_S << 1) - 1) +#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1 +#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1 +#endif + +/* The type of the result of a floating point comparison. This must + match __libgcc_cmp_return__ in GCC for the target. */ +typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); +#define CMPtype __gcc_CMPtype + +#define _FP_NANSIGN_S 0 +#define _FP_NANSIGN_D 0 +#define _FP_NANSIGN_Q 0 + +#define _FP_KEEPNANFRACP 1 +#define _FP_QNANNEGATEDP 0 + +/* NaN payloads should be preserved for NAN2008. */ +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ + do \ + { \ + R##_s = X##_s; \ + _FP_FRAC_COPY_##wc (R, X); \ + R##_c = FP_CLS_NAN; \ + } \ + while (0) + +#ifdef __loongarch_hard_float +#define FP_EX_INVALID 0x100000 +#define FP_EX_DIVZERO 0x080000 +#define FP_EX_OVERFLOW 0x040000 +#define FP_EX_UNDERFLOW 0x020000 +#define FP_EX_INEXACT 0x010000 +#define FP_EX_ALL \ + (FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \ + | FP_EX_INEXACT) + +#define FP_EX_ENABLE_SHIFT 16 +#define FP_EX_CAUSE_SHIFT 8 + +#define FP_RND_NEAREST 0x000 +#define FP_RND_ZERO 0x100 +#define FP_RND_PINF 0x200 +#define FP_RND_MINF 0x300 +#define FP_RND_MASK 0x300 + +#define _FP_DECL_EX \ + unsigned long int _fcsr __attribute__ ((unused)) = FP_RND_NEAREST + +#define FP_INIT_ROUNDMODE \ + do \ + { \ + _fcsr = __builtin_loongarch_movfcsr2gr (0); \ + } \ + while (0) + +#define FP_ROUNDMODE (_fcsr & FP_RND_MASK) + +#define FP_TRAPPING_EXCEPTIONS ((_fcsr << FP_EX_ENABLE_SHIFT) & FP_EX_ALL) + +#define FP_HANDLE_EXCEPTIONS \ + do \ + { \ + _fcsr &= ~(FP_EX_ALL << FP_EX_CAUSE_SHIFT); \ + _fcsr |= _fex | (_fex << FP_EX_CAUSE_SHIFT); \ + __builtin_loongarch_movgr2fcsr (0, _fcsr); \ + } \ + while (0) + +#else +#define FP_EX_INVALID (1 << 4) +#define FP_EX_DIVZERO (1 << 3) +#define FP_EX_OVERFLOW (1 << 2) +#define FP_EX_UNDERFLOW (1 << 1) +#define FP_EX_INEXACT (1 << 0) +#endif + +#define _FP_TININESS_AFTER_ROUNDING 1 + +#define __LITTLE_ENDIAN 1234 + +#define __BYTE_ORDER __LITTLE_ENDIAN + +/* Define ALIASNAME as a strong alias for NAME. */ +#define strong_alias(name, aliasname) _strong_alias (name, aliasname) +#define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); diff --git a/libgcc/config/loongarch/t-crtstuff b/libgcc/config/loongarch/t-crtstuff new file mode 100644 index 0000000..b8c36eb --- /dev/null +++ b/libgcc/config/loongarch/t-crtstuff @@ -0,0 +1,5 @@ +# -fasynchronous-unwind-tables is on by default for LoongArch. +# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point +# to .eh_frame data from crtbeginT.o instead of the user-defined object +# during static linking. +CRTSTUFF_T_CFLAGS += -fno-omit-frame-pointer -fno-asynchronous-unwind-tables diff --git a/libgcc/config/loongarch/t-loongarch b/libgcc/config/loongarch/t-loongarch new file mode 100644 index 0000000..2a7dbf6 --- /dev/null +++ b/libgcc/config/loongarch/t-loongarch @@ -0,0 +1,7 @@ +LIB2_SIDITI_CONV_FUNCS = yes + +softfp_float_modes := +softfp_int_modes := si di +softfp_extensions := +softfp_truncations := +softfp_exclude_libgcc2 := n diff --git a/libgcc/config/tilegx/t-softfp b/libgcc/config/loongarch/t-loongarch64 index a1e3513..a1e3513 100644 --- a/libgcc/config/tilegx/t-softfp +++ b/libgcc/config/loongarch/t-loongarch64 diff --git a/libgcc/config/loongarch/t-softfp-tf b/libgcc/config/loongarch/t-softfp-tf new file mode 100644 index 0000000..306677b --- /dev/null +++ b/libgcc/config/loongarch/t-softfp-tf @@ -0,0 +1,3 @@ +softfp_float_modes += tf +softfp_extensions += sftf dftf +softfp_truncations += tfsf tfdf diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S index 177ce87..dc6e6dd 100644 --- a/libgcc/config/m68k/lb1sf68.S +++ b/libgcc/config/m68k/lb1sf68.S @@ -435,7 +435,10 @@ $_exception_handler: .text FUNC(__mulsi3) .globl SYM (__mulsi3) + .globl SYM (__mulsi3_internal) + .hidden SYM (__mulsi3_internal) SYM (__mulsi3): +SYM (__mulsi3_internal): movew sp@(4), d0 /* x0 -> d0 */ muluw sp@(10), d0 /* x0*y1 */ movew sp@(6), d1 /* x1 -> d1 */ @@ -458,7 +461,10 @@ SYM (__mulsi3): .text FUNC(__udivsi3) .globl SYM (__udivsi3) + .globl SYM (__udivsi3_internal) + .hidden SYM (__udivsi3_internal) SYM (__udivsi3): +SYM (__udivsi3_internal): #ifndef __mcoldfire__ movel d2, sp@- movel sp@(12), d1 /* d1 = divisor */ @@ -534,7 +540,10 @@ L2: subql IMM (1),d4 .text FUNC(__divsi3) .globl SYM (__divsi3) + .globl SYM (__divsi3_internal) + .hidden SYM (__divsi3_internal) SYM (__divsi3): +SYM (__divsi3_internal): movel d2, sp@- moveq IMM (1), d2 /* sign of result stored in d2 (=1 or =-1) */ @@ -557,7 +566,7 @@ L1: movel sp@(8), d0 /* d0 = dividend */ L2: movel d1, sp@- movel d0, sp@- - PICCALL SYM (__udivsi3) /* divide abs(dividend) by abs(divisor) */ + PICCALL SYM (__udivsi3_internal) /* divide abs(dividend) by abs(divisor) */ addql IMM (8), sp tstb d2 @@ -577,13 +586,13 @@ SYM (__umodsi3): movel sp@(4), d0 /* d0 = dividend */ movel d1, sp@- movel d0, sp@- - PICCALL SYM (__udivsi3) + PICCALL SYM (__udivsi3_internal) addql IMM (8), sp movel sp@(8), d1 /* d1 = divisor */ #ifndef __mcoldfire__ movel d1, sp@- movel d0, sp@- - PICCALL SYM (__mulsi3) /* d0 = (a/b)*b */ + PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */ addql IMM (8), sp #else mulsl d1,d0 @@ -603,13 +612,13 @@ SYM (__modsi3): movel sp@(4), d0 /* d0 = dividend */ movel d1, sp@- movel d0, sp@- - PICCALL SYM (__divsi3) + PICCALL SYM (__divsi3_internal) addql IMM (8), sp movel sp@(8), d1 /* d1 = divisor */ #ifndef __mcoldfire__ movel d1, sp@- movel d0, sp@- - PICCALL SYM (__mulsi3) /* d0 = (a/b)*b */ + PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */ addql IMM (8), sp #else mulsl d1,d0 diff --git a/libgcc/config/rs6000/t-darwin-ehs b/libgcc/config/rs6000/t-darwin-ehs index 42f5214..581344e 100644 --- a/libgcc/config/rs6000/t-darwin-ehs +++ b/libgcc/config/rs6000/t-darwin-ehs @@ -1,3 +1,3 @@ -# We need the save_world code for the EH library. +# We need the save_world and anu unwind fallback code for the EH library. -LIBEHSOBJS += darwin-world_s.o +LIBEHSOBJS += darwin-world_s.o darwin-fallback.o diff --git a/libgcc/config/t-darwin-ehs b/libgcc/config/t-darwin-ehs index 9527502..df46f8a 100644 --- a/libgcc/config/t-darwin-ehs +++ b/libgcc/config/t-darwin-ehs @@ -3,5 +3,5 @@ LIBEHSOBJS = unwind-dw2_s.o unwind-dw2-fde-darwin_s.o unwind-c_s.o -unwind-dw2_s.o: gthr-default.h md-unwind-support.h +unwind-dw2_s.o: gthr-default.h md-unwind-support.h unwind.h $(LIBEHSOBJS): libgcc_tm.h diff --git a/libgcc/config/tilegx/sfp-machine.h b/libgcc/config/tilegx/sfp-machine.h deleted file mode 100644 index 1ce84e1..0000000 --- a/libgcc/config/tilegx/sfp-machine.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef __tilegx32__ -#include "config/tilegx/sfp-machine32.h" -#else -#include "config/tilegx/sfp-machine64.h" -#endif diff --git a/libgcc/config/tilegx/sfp-machine32.h b/libgcc/config/tilegx/sfp-machine32.h deleted file mode 100644 index 9fc281c..0000000 --- a/libgcc/config/tilegx/sfp-machine32.h +++ /dev/null @@ -1,68 +0,0 @@ -#define _FP_W_TYPE_SIZE 32 -#define _FP_W_TYPE unsigned long -#define _FP_WS_TYPE signed long -#define _FP_I_TYPE long - -typedef int TItype __attribute__ ((mode (TI))); -typedef unsigned int UTItype __attribute__ ((mode (TI))); - -#define TI_BITS (__CHAR_BIT__ * (int)sizeof(TItype)) - -/* The type of the result of a floating point comparison. This must - match `__libgcc_cmp_return__' in GCC for the target. */ -typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); -#define CMPtype __gcc_CMPtype - -#define _FP_MUL_MEAT_S(R,X,Y) \ - _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) -#define _FP_MUL_MEAT_D(R,X,Y) \ - _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) -#define _FP_MUL_MEAT_Q(R,X,Y) \ - _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) - -#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y) -#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_S _FP_QNANBIT_S -#define _FP_NANFRAC_D _FP_QNANBIT_D, 0 -#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0 -#define _FP_NANSIGN_S 1 -#define _FP_NANSIGN_D 1 -#define _FP_NANSIGN_Q 1 - -#define _FP_KEEPNANFRACP 1 -#define _FP_QNANNEGATEDP 0 - -#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ - do { \ - if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ - && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ - { \ - R##_s = Y##_s; \ - _FP_FRAC_COPY_##wc(R,Y); \ - } \ - else \ - { \ - R##_s = X##_s; \ - _FP_FRAC_COPY_##wc(R,X); \ - } \ - R##_c = FP_CLS_NAN; \ - } while (0) - -#define _FP_TININESS_AFTER_ROUNDING 0 - -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 - -#if defined __BIG_ENDIAN__ -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif - -/* Define ALIASNAME as a strong alias for NAME. */ -# define strong_alias(name, aliasname) _strong_alias(name, aliasname) -# define _strong_alias(name, aliasname) \ - extern __typeof (name) aliasname __attribute__ ((alias (#name))); - diff --git a/libgcc/config/tilegx/sfp-machine64.h b/libgcc/config/tilegx/sfp-machine64.h deleted file mode 100644 index 5dbbe60..0000000 --- a/libgcc/config/tilegx/sfp-machine64.h +++ /dev/null @@ -1,68 +0,0 @@ -#define _FP_W_TYPE_SIZE 64 -#define _FP_W_TYPE unsigned long -#define _FP_WS_TYPE signed long -#define _FP_I_TYPE long - -typedef int TItype __attribute__ ((mode (TI))); -typedef unsigned int UTItype __attribute__ ((mode (TI))); - -#define TI_BITS (__CHAR_BIT__ * (int)sizeof(TItype)) - -/* The type of the result of a floating point comparison. This must - match `__libgcc_cmp_return__' in GCC for the target. */ -typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); -#define CMPtype __gcc_CMPtype - -#define _FP_MUL_MEAT_S(R,X,Y) \ - _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y) -#define _FP_MUL_MEAT_D(R,X,Y) \ - _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) -#define _FP_MUL_MEAT_Q(R,X,Y) \ - _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) - -#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm) -#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y) -#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y) - -#define _FP_NANFRAC_S _FP_QNANBIT_S -#define _FP_NANFRAC_D _FP_QNANBIT_D -#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0 -#define _FP_NANSIGN_S 1 -#define _FP_NANSIGN_D 1 -#define _FP_NANSIGN_Q 1 - -#define _FP_KEEPNANFRACP 1 -#define _FP_QNANNEGATEDP 0 - -#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ - do { \ - if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ - && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ - { \ - R##_s = Y##_s; \ - _FP_FRAC_COPY_##wc(R,Y); \ - } \ - else \ - { \ - R##_s = X##_s; \ - _FP_FRAC_COPY_##wc(R,X); \ - } \ - R##_c = FP_CLS_NAN; \ - } while (0) - -#define _FP_TININESS_AFTER_ROUNDING 0 - -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 - -#if defined __BIG_ENDIAN__ -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif - -/* Define ALIASNAME as a strong alias for NAME. */ -# define strong_alias(name, aliasname) _strong_alias(name, aliasname) -# define _strong_alias(name, aliasname) \ - extern __typeof (name) aliasname __attribute__ ((alias (#name))); - diff --git a/libgcc/config/tilegx/t-crtstuff b/libgcc/config/tilegx/t-crtstuff deleted file mode 100644 index 870318c..0000000 --- a/libgcc/config/tilegx/t-crtstuff +++ /dev/null @@ -1,8 +0,0 @@ -# crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables, -# because then __FRAME_END__ might not be the last thing in .eh_frame -# section. -CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -CRTSTUFF_T_CFLAGS_S += -fno-asynchronous-unwind-tables - -# Compile crtbeginS.o and crtendS.o with -mcmodel=large -CRTSTUFF_T_CFLAGS_S += -mcmodel=large diff --git a/libgcc/config/tilegx/t-tilegx b/libgcc/config/tilegx/t-tilegx deleted file mode 100644 index 2fb6445..0000000 --- a/libgcc/config/tilegx/t-tilegx +++ /dev/null @@ -1,26 +0,0 @@ -LIB2ADD += \ - $(srcdir)/config/tilepro/atomic.c - -SOFTDIVIDE_FUNCS := \ - _tile_udivsi3 \ - _tile_divsi3 \ - _tile_udivdi3 \ - _tile_divdi3 \ - _tile_umodsi3 \ - _tile_modsi3 \ - _tile_umoddi3 \ - _tile_moddi3 - -softdivide-o = $(patsubst %,%$(objext),$(SOFTDIVIDE_FUNCS)) -$(softdivide-o): %$(objext): $(srcdir)/config/tilepro/softdivide.c - $(gcc_compile) -ffunction-sections -DMAYBE_STATIC= -DL$* -c $< \ - $(vis_hide) -libgcc-objects += $(softdivide-o) - -ifeq ($(enable_shared),yes) -softdivide-s-o = $(patsubst %,%_s$(objext),$(SOFTDIVIDE_FUNCS)) -$(softdivide-s-o): %_s$(objext): $(srcdir)/config/tilepro/softdivide.c - $(gcc_s_compile) -ffunction-sections -DMAYBE_STATIC= -DL$* -c $< -libgcc-s-objects += $(softdivide-s-o) -libgcc-eh-objects += _tile_divdi3.o _tile_umoddi3.o -endif diff --git a/libgcc/config/tilepro/atomic.c b/libgcc/config/tilepro/atomic.c deleted file mode 100644 index 5de2b7c..0000000 --- a/libgcc/config/tilepro/atomic.c +++ /dev/null @@ -1,397 +0,0 @@ -/* TILE atomics. - Copyright (C) 2011-2022 Free Software Foundation, Inc. - Contributed by Walter Lee (walt@tilera.com) - - 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 "tconfig.h" -#include "coretypes.h" -#include "atomic.h" - -#define bool unsigned char - -/* This code should be inlined by the compiler, but for now support - it as out-of-line methods in libgcc. */ - -static inline void -pre_atomic_barrier (int model) -{ - switch (model) - { - case __ATOMIC_RELEASE: - case __ATOMIC_ACQ_REL: - case __ATOMIC_SEQ_CST: - __atomic_thread_fence (model); - break; - default: - break; - } - return; -} - -static inline void -post_atomic_barrier (int model) -{ - switch (model) - { - case __ATOMIC_ACQUIRE: - case __ATOMIC_ACQ_REL: - case __ATOMIC_SEQ_CST: - __atomic_thread_fence (model); - break; - default: - break; - } - return; -} - -#define __unused __attribute__((unused)) - -#define __fetch_and_do(proto, type, size, opname, top, bottom) \ -proto \ -{ \ - top; \ - type rv = arch_atomic_##opname(p, i); \ - bottom; \ - return rv; \ -} - -#define __atomic_fetch_and_do(type, size, opname) \ - __fetch_and_do(type __atomic_fetch_##opname##_##size(type* p, type i, int model), \ - type, size, opname, \ - pre_atomic_barrier(model), \ - post_atomic_barrier(model)) \ - -__atomic_fetch_and_do (int, 4, add) -__atomic_fetch_and_do (int, 4, sub) -__atomic_fetch_and_do (int, 4, or) -__atomic_fetch_and_do (int, 4, and) -__atomic_fetch_and_do (int, 4, xor) -__atomic_fetch_and_do (int, 4, nand) -__atomic_fetch_and_do (long long, 8, add) -__atomic_fetch_and_do (long long, 8, sub) -__atomic_fetch_and_do (long long, 8, or) -__atomic_fetch_and_do (long long, 8, and) -__atomic_fetch_and_do (long long, 8, xor) -__atomic_fetch_and_do (long long, 8, nand) - -#define __sync_fetch_and_do(type, size, opname) \ - __fetch_and_do(type __sync_fetch_and_##opname##_##size(type* p, type i), \ - type, size, opname, \ - arch_atomic_write_barrier(), \ - arch_atomic_read_barrier()) - -__sync_fetch_and_do (int, 4, add) -__sync_fetch_and_do (int, 4, sub) -__sync_fetch_and_do (int, 4, or) -__sync_fetch_and_do (int, 4, and) -__sync_fetch_and_do (int, 4, xor) -__sync_fetch_and_do (int, 4, nand) -__sync_fetch_and_do (long long, 8, add) -__sync_fetch_and_do (long long, 8, sub) -__sync_fetch_and_do (long long, 8, or) -__sync_fetch_and_do (long long, 8, and) -__sync_fetch_and_do (long long, 8, xor) -__sync_fetch_and_do (long long, 8, nand) - -#define __do_and_fetch(proto, type, size, opname, op, op2, top, bottom) \ -proto \ -{ \ - top; \ - type rv = op2 (arch_atomic_##opname(p, i) op i); \ - bottom; \ - return rv; \ -} - -#define __atomic_do_and_fetch(type, size, opname, op, op2) \ - __do_and_fetch(type __atomic_##opname##_fetch_##size(type* p, type i, int model), \ - type, size, opname, op, op2, \ - pre_atomic_barrier(model), \ - post_atomic_barrier(model)) \ - -__atomic_do_and_fetch (int, 4, add, +, ) -__atomic_do_and_fetch (int, 4, sub, -, ) -__atomic_do_and_fetch (int, 4, or, |, ) -__atomic_do_and_fetch (int, 4, and, &, ) -__atomic_do_and_fetch (int, 4, xor, |, ) -__atomic_do_and_fetch (int, 4, nand, &, ~) -__atomic_do_and_fetch (long long, 8, add, +, ) -__atomic_do_and_fetch (long long, 8, sub, -, ) -__atomic_do_and_fetch (long long, 8, or, |, ) -__atomic_do_and_fetch (long long, 8, and, &, ) -__atomic_do_and_fetch (long long, 8, xor, |, ) -__atomic_do_and_fetch (long long, 8, nand, &, ~) - -#define __sync_do_and_fetch(type, size, opname, op, op2) \ - __do_and_fetch(type __sync_##opname##_and_fetch_##size(type* p, type i), \ - type, size, opname, op, op2, \ - arch_atomic_write_barrier(), \ - arch_atomic_read_barrier()) \ - -__sync_do_and_fetch (int, 4, add, +, ) -__sync_do_and_fetch (int, 4, sub, -, ) -__sync_do_and_fetch (int, 4, or, |, ) -__sync_do_and_fetch (int, 4, and, &, ) -__sync_do_and_fetch (int, 4, xor, |, ) -__sync_do_and_fetch (int, 4, nand, &, ~) -__sync_do_and_fetch (long long, 8, add, +, ) -__sync_do_and_fetch (long long, 8, sub, -, ) -__sync_do_and_fetch (long long, 8, or, |, ) -__sync_do_and_fetch (long long, 8, and, &, ) -__sync_do_and_fetch (long long, 8, xor, |, ) -__sync_do_and_fetch (long long, 8, nand, &, ~) - -#define __atomic_exchange_methods(type, size) \ -bool \ -__atomic_compare_exchange_##size(volatile type* ptr, type* oldvalp, \ - type newval, bool weak __unused, \ - int models, int modelf __unused) \ -{ \ - type oldval = *oldvalp; \ - pre_atomic_barrier(models); \ - type retval = arch_atomic_val_compare_and_exchange(ptr, oldval, newval); \ - post_atomic_barrier(models); \ - bool success = (retval == oldval); \ - *oldvalp = retval; \ - return success; \ -} \ - \ -type \ -__atomic_exchange_##size(volatile type* ptr, type val, int model) \ -{ \ - pre_atomic_barrier(model); \ - type retval = arch_atomic_exchange(ptr, val); \ - post_atomic_barrier(model); \ - return retval; \ -} - -__atomic_exchange_methods (int, 4) -__atomic_exchange_methods (long long, 8) - -#define __sync_exchange_methods(type, size) \ -type \ -__sync_val_compare_and_swap_##size(type* ptr, type oldval, type newval) \ -{ \ - arch_atomic_write_barrier(); \ - type retval = arch_atomic_val_compare_and_exchange(ptr, oldval, newval); \ - arch_atomic_read_barrier(); \ - return retval; \ -} \ - \ -bool \ -__sync_bool_compare_and_swap_##size(type* ptr, type oldval, type newval) \ -{ \ - arch_atomic_write_barrier(); \ - bool retval = arch_atomic_bool_compare_and_exchange(ptr, oldval, newval); \ - arch_atomic_read_barrier(); \ - return retval; \ -} \ - \ -type \ -__sync_lock_test_and_set_##size(type* ptr, type val) \ -{ \ - type retval = arch_atomic_exchange(ptr, val); \ - arch_atomic_acquire_barrier_value(retval); \ - return retval; \ -} - -__sync_exchange_methods (int, 4) -__sync_exchange_methods (long long, 8) - -#ifdef __LITTLE_ENDIAN__ -#define BIT_OFFSET(n, type) ((n) * 8) -#else -#define BIT_OFFSET(n, type) ((4 - sizeof(type) - (n)) * 8) -#endif - -/* Subword methods require the same approach for both TILEPro and - TILE-Gx. We load the background data for the word, insert the - desired subword piece, then compare-and-exchange it into place. */ -#define u8 unsigned char -#define u16 unsigned short - -#define __subword_cmpxchg_body(type, size, ptr, guess, val) \ - ({ \ - unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \ - const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type); \ - const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1; \ - const unsigned int bgmask = ~(valmask << shift); \ - unsigned int oldword = *p; \ - type oldval = (oldword >> shift) & valmask; \ - if (__builtin_expect((oldval == guess), 1)) { \ - unsigned int word = (oldword & bgmask) | ((val & valmask) << shift); \ - oldword = arch_atomic_val_compare_and_exchange(p, oldword, word); \ - oldval = (oldword >> shift) & valmask; \ - } \ - oldval; \ - }) \ - -#define __atomic_subword_cmpxchg(type, size) \ - \ -bool \ -__atomic_compare_exchange_##size(volatile type* ptr, type* guess_ptr, \ - type val, bool weak __unused, int models, \ - int modelf __unused) \ -{ \ - pre_atomic_barrier(models); \ - type guess = *guess_ptr; \ - type oldval = __subword_cmpxchg_body(type, size, ptr, guess, val); \ - post_atomic_barrier(models); \ - bool success = (oldval == guess); \ - *guess_ptr = oldval; \ - return success; \ -} - -__atomic_subword_cmpxchg (u8, 1) -__atomic_subword_cmpxchg (u16, 2) - -#define __sync_subword_cmpxchg(type, size) \ - \ -type \ -__sync_val_compare_and_swap_##size(type* ptr, type guess, type val) \ -{ \ - arch_atomic_write_barrier(); \ - type oldval = __subword_cmpxchg_body(type, size, ptr, guess, val); \ - arch_atomic_read_barrier(); \ - return oldval; \ -} \ - \ -bool \ -__sync_bool_compare_and_swap_##size(type* ptr, type guess, type val) \ -{ \ - type oldval = __sync_val_compare_and_swap_##size(ptr, guess, val); \ - return oldval == guess; \ -} - -__sync_subword_cmpxchg (u8, 1) -__sync_subword_cmpxchg (u16, 2) - -/* For the atomic-update subword methods, we use the same approach as - above, but we retry until we succeed if the compare-and-exchange - fails. */ -#define __subword(type, proto, top, expr, bottom) \ -proto \ -{ \ - top \ - unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \ - const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type); \ - const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1; \ - const unsigned int bgmask = ~(valmask << shift); \ - unsigned int oldword, xword = *p; \ - type val, oldval; \ - do { \ - oldword = xword; \ - oldval = (oldword >> shift) & valmask; \ - val = expr; \ - unsigned int word = (oldword & bgmask) | ((val & valmask) << shift); \ - xword = arch_atomic_val_compare_and_exchange(p, oldword, word); \ - } while (__builtin_expect(xword != oldword, 0)); \ - bottom \ -} - -#define __atomic_subword_fetch(type, funcname, expr, retval) \ - __subword(type, \ - type __atomic_ ## funcname(volatile type *ptr, type i, int model), \ - pre_atomic_barrier(model);, \ - expr, \ - post_atomic_barrier(model); return retval;) - -__atomic_subword_fetch (u8, fetch_add_1, oldval + i, oldval) -__atomic_subword_fetch (u8, fetch_sub_1, oldval - i, oldval) -__atomic_subword_fetch (u8, fetch_or_1, oldval | i, oldval) -__atomic_subword_fetch (u8, fetch_and_1, oldval & i, oldval) -__atomic_subword_fetch (u8, fetch_xor_1, oldval ^ i, oldval) -__atomic_subword_fetch (u8, fetch_nand_1, ~(oldval & i), oldval) - -__atomic_subword_fetch (u16, fetch_add_2, oldval + i, oldval) -__atomic_subword_fetch (u16, fetch_sub_2, oldval - i, oldval) -__atomic_subword_fetch (u16, fetch_or_2, oldval | i, oldval) -__atomic_subword_fetch (u16, fetch_and_2, oldval & i, oldval) -__atomic_subword_fetch (u16, fetch_xor_2, oldval ^ i, oldval) -__atomic_subword_fetch (u16, fetch_nand_2, ~(oldval & i), oldval) - -__atomic_subword_fetch (u8, add_fetch_1, oldval + i, val) -__atomic_subword_fetch (u8, sub_fetch_1, oldval - i, val) -__atomic_subword_fetch (u8, or_fetch_1, oldval | i, val) -__atomic_subword_fetch (u8, and_fetch_1, oldval & i, val) -__atomic_subword_fetch (u8, xor_fetch_1, oldval ^ i, val) -__atomic_subword_fetch (u8, nand_fetch_1, ~(oldval & i), val) - -__atomic_subword_fetch (u16, add_fetch_2, oldval + i, val) -__atomic_subword_fetch (u16, sub_fetch_2, oldval - i, val) -__atomic_subword_fetch (u16, or_fetch_2, oldval | i, val) -__atomic_subword_fetch (u16, and_fetch_2, oldval & i, val) -__atomic_subword_fetch (u16, xor_fetch_2, oldval ^ i, val) -__atomic_subword_fetch (u16, nand_fetch_2, ~(oldval & i), val) - -#define __sync_subword_fetch(type, funcname, expr, retval) \ - __subword(type, \ - type __sync_ ## funcname(type *ptr, type i), \ - arch_atomic_read_barrier();, \ - expr, \ - arch_atomic_write_barrier(); return retval;) - -__sync_subword_fetch (u8, fetch_and_add_1, oldval + i, oldval) -__sync_subword_fetch (u8, fetch_and_sub_1, oldval - i, oldval) -__sync_subword_fetch (u8, fetch_and_or_1, oldval | i, oldval) -__sync_subword_fetch (u8, fetch_and_and_1, oldval & i, oldval) -__sync_subword_fetch (u8, fetch_and_xor_1, oldval ^ i, oldval) -__sync_subword_fetch (u8, fetch_and_nand_1, ~(oldval & i), oldval) - -__sync_subword_fetch (u16, fetch_and_add_2, oldval + i, oldval) -__sync_subword_fetch (u16, fetch_and_sub_2, oldval - i, oldval) -__sync_subword_fetch (u16, fetch_and_or_2, oldval | i, oldval) -__sync_subword_fetch (u16, fetch_and_and_2, oldval & i, oldval) -__sync_subword_fetch (u16, fetch_and_xor_2, oldval ^ i, oldval) -__sync_subword_fetch (u16, fetch_and_nand_2, ~(oldval & i), oldval) - -__sync_subword_fetch (u8, add_and_fetch_1, oldval + i, val) -__sync_subword_fetch (u8, sub_and_fetch_1, oldval - i, val) -__sync_subword_fetch (u8, or_and_fetch_1, oldval | i, val) -__sync_subword_fetch (u8, and_and_fetch_1, oldval & i, val) -__sync_subword_fetch (u8, xor_and_fetch_1, oldval ^ i, val) -__sync_subword_fetch (u8, nand_and_fetch_1, ~(oldval & i), val) - -__sync_subword_fetch (u16, add_and_fetch_2, oldval + i, val) -__sync_subword_fetch (u16, sub_and_fetch_2, oldval - i, val) -__sync_subword_fetch (u16, or_and_fetch_2, oldval | i, val) -__sync_subword_fetch (u16, and_and_fetch_2, oldval & i, val) -__sync_subword_fetch (u16, xor_and_fetch_2, oldval ^ i, val) -__sync_subword_fetch (u16, nand_and_fetch_2, ~(oldval & i), val) - -#define __atomic_subword_lock(type, size) \ - __subword(type, \ - type __atomic_exchange_##size(volatile type* ptr, type nval, int model), \ - pre_atomic_barrier(model);, \ - nval, \ - post_atomic_barrier(model); return oldval;) - -__atomic_subword_lock (u8, 1) -__atomic_subword_lock (u16, 2) - -#define __sync_subword_lock(type, size) \ - __subword(type, \ - type __sync_lock_test_and_set_##size(type* ptr, type nval), \ - , \ - nval, \ - arch_atomic_acquire_barrier_value(oldval); return oldval;) - -__sync_subword_lock (u8, 1) -__sync_subword_lock (u16, 2) diff --git a/libgcc/config/tilepro/atomic.h b/libgcc/config/tilepro/atomic.h deleted file mode 100644 index 34547bb..0000000 --- a/libgcc/config/tilepro/atomic.h +++ /dev/null @@ -1,437 +0,0 @@ -/* Macros for atomic functionality for tile. - Copyright (C) 2011-2022 Free Software Foundation, Inc. - Contributed by Walter Lee (walt@tilera.com) - - 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/>. */ - - -/* Provides macros for common atomic functionality. */ - -#ifndef _ATOMIC_H_ -#define _ATOMIC_H_ - -#ifdef __tilegx__ -/* Atomic instruction macros - - The macros provided by atomic.h simplify access to the TILE-Gx - architecture's atomic instructions. The architecture provides a - variety of atomic instructions, including "exchange", "compare and - exchange", "fetch and ADD", "fetch and AND", "fetch and OR", and - "fetch and ADD if greater than or equal to zero". - - No barrier or fence semantics are implied by any of the atomic - instructions for manipulating memory; you must specify the barriers - that you wish explicitly, using the provided macros. - - Any integral 32- or 64-bit value can be used as the argument - to these macros, such as "int", "long long", "unsigned long", etc. - The pointers must be aligned to 4 or 8 bytes for 32- or 64-bit data. - The "exchange" and "compare and exchange" macros may also take - pointer values. We use the pseudo-type "VAL" in the documentation - to indicate the use of an appropriate type. */ -#else -/* Atomic instruction macros - - The macros provided by atomic.h simplify access to the Tile - architecture's atomic instructions. Since the architecture - supports test-and-set as its only in-silicon atomic operation, many - of the operations provided by this header are implemented as - fast-path calls to Linux emulation routines. - - Using the kernel for atomic operations allows userspace to take - advantage of the kernel's existing atomic-integer support (managed - by a distributed array of locks). The kernel provides proper - ordering among simultaneous atomic operations on different cores, - and guarantees a process cannot be context-switched part way - through an atomic operation. By virtue of sharing the kernel - atomic implementation, the userspace atomic operations - are compatible with the atomic methods provided by the kernel's - futex() syscall API. Note that these operations never cause Linux - kernel scheduling, and are in fact invisible to the kernel; they - simply act as regular function calls but with an elevated privilege - level. Note that the kernel's distributed lock array is hashed by - using only VA bits from the atomic value's address (to avoid the - performance hit of page table locking and multiple page-table - lookups to get the PA) and only the VA bits that are below page - granularity (to properly lock simultaneous accesses to the same - page mapped at different VAs). As a result, simultaneous atomic - operations on values whose addresses are at the same offset on a - page will contend in the kernel for the same lock array element. - - No barrier or fence semantics are implied by any of the atomic - instructions for manipulating memory; you must specify the barriers - that you wish explicitly, using the provided macros. - - Any integral 32- or 64-bit value can be used as the argument - to these macros, such as "int", "long long", "unsigned long", etc. - The pointers must be aligned to 4 or 8 bytes for 32- or 64-bit data. - The "exchange" and "compare and exchange" macros may also take - pointer values. We use the pseudo-type "VAL" in the documentation - to indicate the use of an appropriate type. - - The 32-bit routines are implemented using a single kernel fast - syscall, as is the 64-bit compare-and-exchange. The other 64-bit - routines are implemented by looping over the 64-bit - compare-and-exchange routine, so may be potentially less efficient. */ -#endif - -#ifdef __tilegx__ -#define SPR_CMPEXCH_VALUE 0x2780 -#else -#define __NR_FAST_cmpxchg -1 -#define __NR_FAST_atomic_update -2 -#define __NR_FAST_cmpxchg64 -3 -#endif - - -/* 32-bit integer compare-and-exchange. */ -static __inline __attribute__ ((always_inline)) - int arch_atomic_val_compare_and_exchange_4 (volatile int *mem, - int oldval, int newval) -{ -#ifdef __tilegx__ - __insn_mtspr (SPR_CMPEXCH_VALUE, oldval); - return __insn_cmpexch4 (mem, newval); -#else - int result; - __asm__ __volatile__ ("swint1":"=R00" (result), - "=m" (*mem):"R10" (__NR_FAST_cmpxchg), "R00" (mem), - "R01" (oldval), "R02" (newval), "m" (*mem):"r20", - "r21", "r22", "r23", "r24", "r25", "r26", "r27", - "r28", "r29", "memory"); - return result; -#endif -} - -/* 64-bit integer compare-and-exchange. */ -static __inline __attribute__ ((always_inline)) - long long arch_atomic_val_compare_and_exchange_8 (volatile long long - *mem, long long oldval, - long long newval) -{ -#ifdef __tilegx__ - __insn_mtspr (SPR_CMPEXCH_VALUE, oldval); - return __insn_cmpexch (mem, newval); -#else - unsigned int result_lo, result_hi; - unsigned int oldval_lo = oldval & 0xffffffffu, oldval_hi = oldval >> 32; - unsigned int newval_lo = newval & 0xffffffffu, newval_hi = newval >> 32; - __asm__ __volatile__ ("swint1":"=R00" (result_lo), "=R01" (result_hi), - "=m" (*mem):"R10" (__NR_FAST_cmpxchg64), "R00" (mem), - "R02" (oldval_lo), "R03" (oldval_hi), - "R04" (newval_lo), "R05" (newval_hi), - "m" (*mem):"r20", "r21", "r22", "r23", "r24", "r25", - "r26", "r27", "r28", "r29", "memory"); - return ((long long) result_hi) << 32 | result_lo; -#endif -} - -/* This non-existent symbol is called for sizes other than "4" and "8", - indicating a bug in the caller. */ -extern int __arch_atomic_error_bad_argument_size (void) - __attribute__ ((warning ("sizeof atomic argument not 4 or 8"))); - - -#define arch_atomic_val_compare_and_exchange(mem, o, n) \ - __extension__ ({ \ - (__typeof(*(mem)))(__typeof(*(mem)-*(mem))) \ - ((sizeof(*(mem)) == 8) ? \ - arch_atomic_val_compare_and_exchange_8( \ - (volatile long long*)(mem), (__typeof((o)-(o)))(o), \ - (__typeof((n)-(n)))(n)) : \ - (sizeof(*(mem)) == 4) ? \ - arch_atomic_val_compare_and_exchange_4( \ - (volatile int*)(mem), (__typeof((o)-(o)))(o), \ - (__typeof((n)-(n)))(n)) : \ - __arch_atomic_error_bad_argument_size()); \ - }) - -#define arch_atomic_bool_compare_and_exchange(mem, o, n) \ - __extension__ ({ \ - __typeof(o) __o = (o); \ - __builtin_expect( \ - __o == arch_atomic_val_compare_and_exchange((mem), __o, (n)), 1); \ - }) - - -/* Loop with compare_and_exchange until we guess the correct value. - Normally "expr" will be an expression using __old and __value. */ -#define __arch_atomic_update_cmpxchg(mem, value, expr) \ - __extension__ ({ \ - __typeof(value) __value = (value); \ - __typeof(*(mem)) *__mem = (mem), __old = *__mem, __guess; \ - do { \ - __guess = __old; \ - __old = arch_atomic_val_compare_and_exchange(__mem, __old, (expr)); \ - } while (__builtin_expect(__old != __guess, 0)); \ - __old; \ - }) - -#ifdef __tilegx__ - -/* Generic atomic op with 8- or 4-byte variant. - The _mask, _addend, and _expr arguments are ignored on tilegx. */ -#define __arch_atomic_update(mem, value, op, _mask, _addend, _expr) \ - __extension__ ({ \ - ((__typeof(*(mem))) \ - ((sizeof(*(mem)) == 8) ? (__typeof(*(mem)-*(mem)))__insn_##op( \ - (volatile void *)(mem), \ - (long long)(__typeof((value)-(value)))(value)) : \ - (sizeof(*(mem)) == 4) ? (int)__insn_##op##4( \ - (volatile void *)(mem), \ - (int)(__typeof((value)-(value)))(value)) : \ - __arch_atomic_error_bad_argument_size())); \ - }) - -#else - -/* This uses TILEPro's fast syscall support to atomically compute: - - int old = *ptr; - *ptr = (old & mask) + addend; - return old; - - This primitive can be used for atomic exchange, add, or, and. - Only 32-bit support is provided. */ -static __inline __attribute__ ((always_inline)) - int - __arch_atomic_update_4 (volatile int *mem, int mask, int addend) -{ - int result; - __asm__ __volatile__ ("swint1":"=R00" (result), - "=m" (*mem):"R10" (__NR_FAST_atomic_update), - "R00" (mem), "R01" (mask), "R02" (addend), - "m" (*mem):"r20", "r21", "r22", "r23", "r24", "r25", - "r26", "r27", "r28", "r29", "memory"); - return result; -} - -/* Generic atomic op with 8- or 4-byte variant. - The _op argument is ignored on tilepro. */ -#define __arch_atomic_update(mem, value, _op, mask, addend, expr) \ - __extension__ ({ \ - (__typeof(*(mem)))(__typeof(*(mem)-*(mem))) \ - ((sizeof(*(mem)) == 8) ? \ - __arch_atomic_update_cmpxchg((mem), (value), (expr)) : \ - (sizeof(*(mem)) == 4) ? \ - __arch_atomic_update_4((volatile int*)(mem), \ - (__typeof((mask)-(mask)))(mask), \ - (__typeof((addend)-(addend)))(addend)) : \ - __arch_atomic_error_bad_argument_size()); \ - }) - -#endif /* __tilegx__ */ - - -#define arch_atomic_exchange(mem, newvalue) \ - __arch_atomic_update(mem, newvalue, exch, 0, newvalue, __value) - -#define arch_atomic_add(mem, value) \ - __arch_atomic_update(mem, value, fetchadd, -1, value, __old + __value) - -#define arch_atomic_sub(mem, value) arch_atomic_add((mem), -(value)) - -#define arch_atomic_increment(mem) arch_atomic_add((mem), 1) - -#define arch_atomic_decrement(mem) arch_atomic_add((mem), -1) - -#define arch_atomic_and(mem, mask) \ - __arch_atomic_update(mem, mask, fetchand, mask, 0, __old & __value) - -#define arch_atomic_or(mem, mask) \ - __arch_atomic_update(mem, mask, fetchor, ~mask, mask, __old | __value) - -#define arch_atomic_xor(mem, mask) \ - __arch_atomic_update_cmpxchg(mem, mask, __old ^ __value) - -#define arch_atomic_nand(mem, mask) \ - __arch_atomic_update_cmpxchg(mem, mask, ~(__old & __value)) - -#define arch_atomic_bit_set(mem, bit) \ - __extension__ ({ \ - __typeof(*(mem)) __mask = (__typeof(*(mem)))1 << (bit); \ - __mask & arch_atomic_or((mem), __mask); \ - }) - -#define arch_atomic_bit_clear(mem, bit) \ - __extension__ ({ \ - __typeof(*(mem)) __mask = (__typeof(*(mem)))1 << (bit); \ - __mask & arch_atomic_and((mem), ~__mask); \ - }) - -#ifdef __tilegx__ -/* Atomically store a new value to memory. - Note that you can freely use types of any size here, unlike the - other atomic routines, which require 32- or 64-bit types. - This accessor is provided for compatibility with TILEPro, which - required an explicit atomic operation for stores that needed - to be atomic with respect to other atomic methods in this header. */ -#define arch_atomic_write(mem, value) ((void) (*(mem) = (value))) -#else -#define arch_atomic_write(mem, value) \ - do { \ - __typeof(mem) __aw_mem = (mem); \ - __typeof(value) __aw_val = (value); \ - unsigned int *__aw_mem32, __aw_intval, __aw_val32, __aw_off, __aw_mask; \ - __aw_intval = (__typeof((value) - (value)))__aw_val; \ - switch (sizeof(*__aw_mem)) { \ - case 8: \ - __arch_atomic_update_cmpxchg(__aw_mem, __aw_val, __value); \ - break; \ - case 4: \ - __arch_atomic_update_4((int *)__aw_mem, 0, __aw_intval); \ - break; \ - case 2: \ - __aw_off = 8 * ((long)__aw_mem & 0x2); \ - __aw_mask = 0xffffU << __aw_off; \ - __aw_mem32 = (unsigned int *)((long)__aw_mem & ~0x2); \ - __aw_val32 = (__aw_intval << __aw_off) & __aw_mask; \ - __arch_atomic_update_cmpxchg(__aw_mem32, __aw_val32, \ - (__old & ~__aw_mask) | __value); \ - break; \ - case 1: \ - __aw_off = 8 * ((long)__aw_mem & 0x3); \ - __aw_mask = 0xffU << __aw_off; \ - __aw_mem32 = (unsigned int *)((long)__aw_mem & ~0x3); \ - __aw_val32 = (__aw_intval << __aw_off) & __aw_mask; \ - __arch_atomic_update_cmpxchg(__aw_mem32, __aw_val32, \ - (__old & ~__aw_mask) | __value); \ - break; \ - } \ - } while (0) -#endif - -/* Compiler barrier. - - This macro prevents loads or stores from being moved by the compiler - across the macro. Any loaded value that was loaded before this - macro must then be reloaded by the compiler. */ -#define arch_atomic_compiler_barrier() __asm__ __volatile__("" ::: "memory") - -/* Full memory barrier. - - This macro has the semantics of arch_atomic_compiler_barrer(), but also - ensures that previous stores are visible to other cores, and that - all previous loaded values have been placed into their target - register on this core. */ -#define arch_atomic_full_barrier() __insn_mf() - -/* Read memory barrier. - - Ensure that all reads by this processor that occurred prior to the - read memory barrier have completed, and that no reads that occur - after the read memory barrier on this processor are initiated - before the barrier. - - On current TILE chips a read barrier is implemented as a full barrier, - but this may not be true in later versions of the architecture. - - See also arch_atomic_acquire_barrier() for the appropriate idiom to use - to ensure no reads are lifted above an atomic lock instruction. */ -#define arch_atomic_read_barrier() arch_atomic_full_barrier() - -/* Write memory barrier. - - Ensure that all writes by this processor that occurred prior to the - write memory barrier have completed, and that no writes that occur - after the write memory barrier on this processor are initiated - before the barrier. - - On current TILE chips a write barrier is implemented as a full barrier, - but this may not be true in later versions of the architecture. - - See also arch_atomic_release_barrier() for the appropriate idiom to use - to ensure all writes are complete prior to an atomic unlock instruction. */ -#define arch_atomic_write_barrier() arch_atomic_full_barrier() - -/* Lock acquisition barrier. - - Ensure that no load operations that follow this macro in the - program can issue prior to the barrier. Without such a barrier, - the compiler can reorder them to issue earlier, or the hardware can - issue them speculatively. The latter is not currently done in the - Tile microarchitecture, but using this operation improves - portability to future implementations. - - This operation is intended to be used as part of the "acquire" - path for locking, that is, when entering a critical section. - This should be done after the atomic operation that actually - acquires the lock, and in conjunction with a "control dependency" - that checks the atomic operation result to see if the lock was - in fact acquired. See the arch_atomic_read_barrier() macro - for a heavier-weight barrier to use in certain unusual constructs, - or arch_atomic_acquire_barrier_value() if no control dependency exists. */ -#define arch_atomic_acquire_barrier() arch_atomic_compiler_barrier() - -/* Lock release barrier. - - Ensure that no store operations that precede this macro in the - program complete subsequent to the barrier. Without such a - barrier, the compiler can reorder stores to issue later, or stores - can be still outstanding in the memory network. - - This operation is intended to be used as part of the "release" path - for locking, that is, when leaving a critical section. This should - be done before the operation (such as a store of zero) that - actually releases the lock. */ -#define arch_atomic_release_barrier() arch_atomic_write_barrier() - -/* Barrier until the read of a particular value is complete. - - This is occasionally useful when constructing certain locking - scenarios. For example, you might write a routine that issues an - atomic instruction to enter a critical section, then reads one or - more values within the critical section without checking to see if - the critical section was in fact acquired, and only later checks - the atomic instruction result to see if the lock was acquired. If - so the routine could properly release the lock and know that the - values that were read were valid. - - In this scenario, it is required to wait for the result of the - atomic instruction, even if the value itself is not checked. This - guarantees that if the atomic instruction succeeded in taking the lock, - the lock was held before any reads in the critical section issued. */ -#define arch_atomic_acquire_barrier_value(val) \ - __asm__ __volatile__("move %0, %0" :: "r"(val)) - -/* Access the given variable in memory exactly once. - - In some contexts, an algorithm may need to force access to memory, - since otherwise the compiler may think it can optimize away a - memory load or store; for example, in a loop when polling memory to - see if another cpu has updated it yet. Generally this is only - required for certain very carefully hand-tuned algorithms; using it - unnecessarily may result in performance losses. - - A related use of this macro is to ensure that the compiler does not - rematerialize the value of "x" by reloading it from memory - unexpectedly; the "volatile" marking will prevent the compiler from - being able to rematerialize. This is helpful if an algorithm needs - to read a variable without locking, but needs it to have the same - value if it ends up being used several times within the algorithm. - - Note that multiple uses of this macro are guaranteed to be ordered, - i.e. the compiler will not reorder stores or loads that are wrapped - in arch_atomic_access_once(). */ -#define arch_atomic_access_once(x) (*(volatile __typeof(x) *)&(x)) - - - -#endif /* !_ATOMIC_H_ */ diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h deleted file mode 100644 index a6874e8..0000000 --- a/libgcc/config/tilepro/linux-unwind.h +++ /dev/null @@ -1,99 +0,0 @@ -/* DWARF2 EH unwinding support for TILEPro. - Copyright (C) 2011-2022 Free Software Foundation, Inc. - Contributed by Walter Lee (walt@tilera.com) - -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/>. */ - -#ifndef inhibit_libc - -#include <arch/abi.h> -#include <signal.h> -#include <sys/ucontext.h> -#include <linux/unistd.h> - -/* Macro to define a copy of the kernel's __rt_sigreturn function - (in arch/tile/kernel/entry.S). If that function is changed, - this one needs to be changed to match it. */ -#define _sigreturn_asm(REG, NR) asm( \ - ".pushsection .text.__rt_sigreturn,\"a\"\n" \ - ".global __rt_sigreturn\n" \ - ".type __rt_sigreturn,@function\n" \ - "__rt_sigreturn:\n" \ - "moveli " #REG ", " #NR "\n" \ - "swint1\n" \ - ".size __rt_sigreturn, . - __rt_sigreturn\n" \ - ".popsection") -#define sigreturn_asm(REG, NR) _sigreturn_asm(REG, NR) -sigreturn_asm (TREG_SYSCALL_NR_NAME, __NR_rt_sigreturn); -#define SIGRETURN_LEN 16 -extern char __rt_sigreturn[]; - -#define MD_FALLBACK_FRAME_STATE_FOR tile_fallback_frame_state - -static _Unwind_Reason_Code -tile_fallback_frame_state (struct _Unwind_Context *context, - _Unwind_FrameState *fs) -{ - unsigned char *pc = context->ra; - struct sigcontext *sc; - long new_cfa; - int i; - - struct rt_sigframe { - unsigned char save_area[C_ABI_SAVE_AREA_SIZE]; - siginfo_t info; - ucontext_t uc; - } *rt_; - - /* Return if this is not a signal handler. */ - if (memcmp (pc, __rt_sigreturn, SIGRETURN_LEN) != 0) - return _URC_END_OF_STACK; - - /* It was a signal handler; update the reported PC to point to our - copy, since that will be findable with dladdr() and therefore - somewhat easier to help understand what actually happened. */ - context->ra = __rt_sigreturn; - - rt_ = context->cfa; - sc = &rt_->uc.uc_mcontext; - - new_cfa = sc->sp; - fs->regs.cfa_how = CFA_REG_OFFSET; - fs->regs.cfa_reg = __LIBGCC_STACK_POINTER_REGNUM__; - fs->regs.cfa_offset = new_cfa - (long) context->cfa; - - for (i = 0; i < 56; ++i) - { - fs->regs.reg[i].how = REG_SAVED_OFFSET; - fs->regs.reg[i].loc.offset - = (long)&sc->gregs[i] - new_cfa; - } - - fs->regs.reg[56].how = REG_SAVED_OFFSET; - fs->regs.reg[56].loc.offset = (long)&sc->pc - new_cfa; - fs->retaddr_column = 56; - fs->signal_frame = 1; - - return _URC_NO_REASON; -} - -#endif /* ifdef inhibit_libc */ diff --git a/libgcc/config/tilepro/sfp-machine.h b/libgcc/config/tilepro/sfp-machine.h deleted file mode 100644 index 6953d8d..0000000 --- a/libgcc/config/tilepro/sfp-machine.h +++ /dev/null @@ -1,59 +0,0 @@ -#define _FP_W_TYPE_SIZE 32 -#define _FP_W_TYPE unsigned long -#define _FP_WS_TYPE signed long -#define _FP_I_TYPE long - -/* The type of the result of a floating point comparison. This must - match `__libgcc_cmp_return__' in GCC for the target. */ -typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); -#define CMPtype __gcc_CMPtype - -#define _FP_MUL_MEAT_S(R,X,Y) \ - _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) -#define _FP_MUL_MEAT_D(R,X,Y) \ - _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) -#define _FP_MUL_MEAT_Q(R,X,Y) \ - _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) - -#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y) -#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_S _FP_QNANBIT_S -#define _FP_NANFRAC_D _FP_QNANBIT_D, 0 -#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0 -#define _FP_NANSIGN_S 1 -#define _FP_NANSIGN_D 1 -#define _FP_NANSIGN_Q 1 - -#define _FP_KEEPNANFRACP 1 -#define _FP_QNANNEGATEDP 0 - -#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ - do { \ - if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ - && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ - { \ - R##_s = Y##_s; \ - _FP_FRAC_COPY_##wc(R,Y); \ - } \ - else \ - { \ - R##_s = X##_s; \ - _FP_FRAC_COPY_##wc(R,X); \ - } \ - R##_c = FP_CLS_NAN; \ - } while (0) - -#define _FP_TININESS_AFTER_ROUNDING 0 - -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 - -#define __BYTE_ORDER __LITTLE_ENDIAN - -/* Define ALIASNAME as a strong alias for NAME. */ -# define strong_alias(name, aliasname) _strong_alias(name, aliasname) -# define _strong_alias(name, aliasname) \ - extern __typeof (name) aliasname __attribute__ ((alias (#name))); - diff --git a/libgcc/config/tilepro/softdivide.c b/libgcc/config/tilepro/softdivide.c deleted file mode 100644 index fea45bd..0000000 --- a/libgcc/config/tilepro/softdivide.c +++ /dev/null @@ -1,353 +0,0 @@ -/* Division and remainder routines for Tile. - Copyright (C) 2011-2022 Free Software Foundation, Inc. - Contributed by Walter Lee (walt@tilera.com) - - 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/>. */ - -typedef int int32_t; -typedef unsigned uint32_t; -typedef long long int64_t; -typedef unsigned long long uint64_t; - -/* Raise signal 8 (SIGFPE) with code 1 (FPE_INTDIV). */ -static inline void -raise_intdiv (void) -{ - asm ("{ raise; moveli zero, 8 + (1 << 6) }"); -} - - -#ifndef __tilegx__ -/*__udivsi3 - 32 bit integer unsigned divide */ -static inline uint32_t __attribute__ ((always_inline)) -__udivsi3_inline (uint32_t dividend, uint32_t divisor) -{ - /* Divide out any power of two factor from dividend and divisor. - Note that when dividing by zero the divisor will remain zero, - which is all we need to detect that case below. */ - const int power_of_two_factor = __insn_ctz (divisor); - divisor >>= power_of_two_factor; - dividend >>= power_of_two_factor; - - /* Checks for division by power of two or division by zero. */ - if (divisor <= 1) - { - if (divisor == 0) - { - raise_intdiv (); - return 0; - } - return dividend; - } - - /* Compute (a / b) by repeatedly finding the largest N - such that (b << N) <= a. For each such N, set bit N in the - quotient, subtract (b << N) from a, and keep going. Think of this as - the reverse of the "shift-and-add" that a multiply does. The values - of N are precisely those shift counts. - - Finding N is easy. First, use clz(b) - clz(a) to find the N - that lines up the high bit of (b << N) with the high bit of a. - Any larger value of N would definitely make (b << N) > a, - which is too big. - - Then, if (b << N) > a (because it has larger low bits), decrement - N by one. This adjustment will definitely make (b << N) less - than a, because a's high bit is now one higher than b's. */ - - /* Precomputing the max_ values allows us to avoid a subtract - in the inner loop and just right shift by clz(remainder). */ - const int divisor_clz = __insn_clz (divisor); - const uint32_t max_divisor = divisor << divisor_clz; - const uint32_t max_qbit = 1 << divisor_clz; - - uint32_t quotient = 0; - uint32_t remainder = dividend; - - while (remainder >= divisor) - { - int shift = __insn_clz (remainder); - uint32_t scaled_divisor = max_divisor >> shift; - uint32_t quotient_bit = max_qbit >> shift; - - int too_big = (scaled_divisor > remainder); - scaled_divisor >>= too_big; - quotient_bit >>= too_big; - remainder -= scaled_divisor; - quotient |= quotient_bit; - } - return quotient; -} -#endif /* !__tilegx__ */ - - -/* __udivdi3 - 64 bit integer unsigned divide */ -static inline uint64_t __attribute__ ((always_inline)) -__udivdi3_inline (uint64_t dividend, uint64_t divisor) -{ - /* Divide out any power of two factor from dividend and divisor. - Note that when dividing by zero the divisor will remain zero, - which is all we need to detect that case below. */ - const int power_of_two_factor = __builtin_ctzll (divisor); - divisor >>= power_of_two_factor; - dividend >>= power_of_two_factor; - - /* Checks for division by power of two or division by zero. */ - if (divisor <= 1) - { - if (divisor == 0) - { - raise_intdiv (); - return 0; - } - return dividend; - } - -#ifndef __tilegx__ - if (((uint32_t) (dividend >> 32) | ((uint32_t) (divisor >> 32))) == 0) - { - /* Operands both fit in 32 bits, so use faster 32 bit algorithm. */ - return __udivsi3_inline ((uint32_t) dividend, (uint32_t) divisor); - } -#endif /* !__tilegx__ */ - - /* See algorithm description in __udivsi3 */ - - const int divisor_clz = __builtin_clzll (divisor); - const uint64_t max_divisor = divisor << divisor_clz; - const uint64_t max_qbit = 1ULL << divisor_clz; - - uint64_t quotient = 0; - uint64_t remainder = dividend; - - while (remainder >= divisor) - { - int shift = __builtin_clzll (remainder); - uint64_t scaled_divisor = max_divisor >> shift; - uint64_t quotient_bit = max_qbit >> shift; - - int too_big = (scaled_divisor > remainder); - scaled_divisor >>= too_big; - quotient_bit >>= too_big; - remainder -= scaled_divisor; - quotient |= quotient_bit; - } - return quotient; -} - - -#ifndef __tilegx__ -/* __umodsi3 - 32 bit integer unsigned modulo */ -static inline uint32_t __attribute__ ((always_inline)) -__umodsi3_inline (uint32_t dividend, uint32_t divisor) -{ - /* Shortcircuit mod by a power of two (and catch mod by zero). */ - const uint32_t mask = divisor - 1; - if ((divisor & mask) == 0) - { - if (divisor == 0) - { - raise_intdiv (); - return 0; - } - return dividend & mask; - } - - /* We compute the remainder (a % b) by repeatedly subtracting off - multiples of b from a until a < b. The key is that subtracting - off a multiple of b does not affect the result mod b. - - To make the algorithm run efficiently, we need to subtract - off a large multiple of b at each step. We subtract the largest - (b << N) that is <= a. - - Finding N is easy. First, use clz(b) - clz(a) to find the N - that lines up the high bit of (b << N) with the high bit of a. - Any larger value of N would definitely make (b << N) > a, - which is too big. - - Then, if (b << N) > a (because it has larger low bits), decrement - N by one. This adjustment will definitely make (b << N) less - than a, because a's high bit is now one higher than b's. */ - const uint32_t max_divisor = divisor << __insn_clz (divisor); - - uint32_t remainder = dividend; - while (remainder >= divisor) - { - const int shift = __insn_clz (remainder); - uint32_t scaled_divisor = max_divisor >> shift; - scaled_divisor >>= (scaled_divisor > remainder); - remainder -= scaled_divisor; - } - - return remainder; -} -#endif /* !__tilegx__ */ - - -/* __umoddi3 - 64 bit integer unsigned modulo */ -static inline uint64_t __attribute__ ((always_inline)) -__umoddi3_inline (uint64_t dividend, uint64_t divisor) -{ -#ifndef __tilegx__ - if (((uint32_t) (dividend >> 32) | ((uint32_t) (divisor >> 32))) == 0) - { - /* Operands both fit in 32 bits, so use faster 32 bit algorithm. */ - return __umodsi3_inline ((uint32_t) dividend, (uint32_t) divisor); - } -#endif /* !__tilegx__ */ - - /* Shortcircuit mod by a power of two (and catch mod by zero). */ - const uint64_t mask = divisor - 1; - if ((divisor & mask) == 0) - { - if (divisor == 0) - { - raise_intdiv (); - return 0; - } - return dividend & mask; - } - - /* See algorithm description in __umodsi3 */ - const uint64_t max_divisor = divisor << __builtin_clzll (divisor); - - uint64_t remainder = dividend; - while (remainder >= divisor) - { - const int shift = __builtin_clzll (remainder); - uint64_t scaled_divisor = max_divisor >> shift; - scaled_divisor >>= (scaled_divisor > remainder); - remainder -= scaled_divisor; - } - - return remainder; -} - - -uint32_t __udivsi3 (uint32_t dividend, uint32_t divisor); -#ifdef L_tile_udivsi3 -uint32_t -__udivsi3 (uint32_t dividend, uint32_t divisor) -{ -#ifndef __tilegx__ - return __udivsi3_inline (dividend, divisor); -#else /* !__tilegx__ */ - uint64_t n = __udivdi3_inline (((uint64_t) dividend), ((uint64_t) divisor)); - return (uint32_t) n; -#endif /* !__tilegx__ */ -} -#endif - -#define ABS(x) ((x) >= 0 ? (x) : -(x)) - -int32_t __divsi3 (int32_t dividend, int32_t divisor); -#ifdef L_tile_divsi3 -/* __divsi3 - 32 bit integer signed divide */ -int32_t -__divsi3 (int32_t dividend, int32_t divisor) -{ -#ifndef __tilegx__ - uint32_t n = __udivsi3_inline (ABS (dividend), ABS (divisor)); -#else /* !__tilegx__ */ - uint64_t n = - __udivdi3_inline (ABS ((int64_t) dividend), ABS ((int64_t) divisor)); -#endif /* !__tilegx__ */ - if ((dividend ^ divisor) < 0) - n = -n; - return (int32_t) n; -} -#endif - - -uint64_t __udivdi3 (uint64_t dividend, uint64_t divisor); -#ifdef L_tile_udivdi3 -uint64_t -__udivdi3 (uint64_t dividend, uint64_t divisor) -{ - return __udivdi3_inline (dividend, divisor); -} -#endif - -/*__divdi3 - 64 bit integer signed divide */ -int64_t __divdi3 (int64_t dividend, int64_t divisor); -#ifdef L_tile_divdi3 -int64_t -__divdi3 (int64_t dividend, int64_t divisor) -{ - uint64_t n = __udivdi3_inline (ABS (dividend), ABS (divisor)); - if ((dividend ^ divisor) < 0) - n = -n; - return (int64_t) n; -} -#endif - - -uint32_t __umodsi3 (uint32_t dividend, uint32_t divisor); -#ifdef L_tile_umodsi3 -uint32_t -__umodsi3 (uint32_t dividend, uint32_t divisor) -{ -#ifndef __tilegx__ - return __umodsi3_inline (dividend, divisor); -#else /* !__tilegx__ */ - return __umoddi3_inline ((uint64_t) dividend, (uint64_t) divisor); -#endif /* !__tilegx__ */ -} -#endif - - -/* __modsi3 - 32 bit integer signed modulo */ -int32_t __modsi3 (int32_t dividend, int32_t divisor); -#ifdef L_tile_modsi3 -int32_t -__modsi3 (int32_t dividend, int32_t divisor) -{ -#ifndef __tilegx__ - uint32_t remainder = __umodsi3_inline (ABS (dividend), ABS (divisor)); -#else /* !__tilegx__ */ - uint64_t remainder = - __umoddi3_inline (ABS ((int64_t) dividend), ABS ((int64_t) divisor)); -#endif /* !__tilegx__ */ - return (int32_t) ((dividend >= 0) ? remainder : -remainder); -} -#endif - - -uint64_t __umoddi3 (uint64_t dividend, uint64_t divisor); -#ifdef L_tile_umoddi3 -uint64_t -__umoddi3 (uint64_t dividend, uint64_t divisor) -{ - return __umoddi3_inline (dividend, divisor); -} -#endif - - -/* __moddi3 - 64 bit integer signed modulo */ -int64_t __moddi3 (int64_t dividend, int64_t divisor); -#ifdef L_tile_moddi3 -int64_t -__moddi3 (int64_t dividend, int64_t divisor) -{ - uint64_t remainder = __umoddi3_inline (ABS (dividend), ABS (divisor)); - return (int64_t) ((dividend >= 0) ? remainder : -remainder); -} -#endif diff --git a/libgcc/config/tilepro/softmpy.S b/libgcc/config/tilepro/softmpy.S deleted file mode 100644 index 0554a6f..0000000 --- a/libgcc/config/tilepro/softmpy.S +++ /dev/null @@ -1,94 +0,0 @@ -/* 64-bit multiplication support for TILEPro. - Copyright (C) 2011-2022 Free Software Foundation, Inc. - Contributed by Walter Lee (walt@tilera.com) - - 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/>. */ - -/* 64-bit multiplication support. */ - - .file "softmpy.S" - -/* Parameters */ -#define lo0 r9 /* low 32 bits of n0 */ -#define hi0 r1 /* high 32 bits of n0 */ -#define lo1 r2 /* low 32 bits of n1 */ -#define hi1 r3 /* high 32 bits of n1 */ - -/* temps */ -#define result1_a r4 -#define result1_b r5 - -#define tmp0 r6 -#define tmp0_left_16 r7 -#define tmp1 r8 - - .section .text.__muldi3, "ax" - .align 8 - .globl __muldi3 - .type __muldi3, @function -__muldi3: - { - move lo0, r0 /* so we can write "out r0" while "in r0" alive */ - mulhl_uu tmp0, lo1, r0 - } - { - mulll_uu result1_a, lo1, hi0 - } - { - move tmp1, tmp0 - mulhla_uu tmp0, lo0, lo1 - } - { - mulhlsa_uu result1_a, lo1, hi0 - } - { - mulll_uu result1_b, lo0, hi1 - slt_u tmp1, tmp0, tmp1 - } - { - mulhlsa_uu result1_a, lo0, hi1 - shli r0, tmp0, 16 - } - { - move tmp0_left_16, r0 - mulhha_uu result1_b, lo0, lo1 - } - { - mullla_uu r0, lo1, lo0 - shli tmp1, tmp1, 16 - } - { - mulhlsa_uu result1_b, hi0, lo1 - inthh tmp1, tmp1, tmp0 - } - { - mulhlsa_uu result1_a, hi1, lo0 - slt_u tmp0, r0, tmp0_left_16 - } - /* NOTE: this will stall for a cycle here. Oh well. */ - { - add r1, tmp0, tmp1 - add result1_a, result1_a, result1_b - } - { - add r1, r1, result1_a - jrp lr - } - .size __muldi3,.-__muldi3 diff --git a/libgcc/config/tilepro/t-crtstuff b/libgcc/config/tilepro/t-crtstuff deleted file mode 100644 index eddc45c..0000000 --- a/libgcc/config/tilepro/t-crtstuff +++ /dev/null @@ -1,4 +0,0 @@ -# crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables, -# because then __FRAME_END__ might not be the last thing in .eh_frame -# section. -CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables diff --git a/libgcc/config/tilepro/t-tilepro b/libgcc/config/tilepro/t-tilepro deleted file mode 100644 index eb6894c..0000000 --- a/libgcc/config/tilepro/t-tilepro +++ /dev/null @@ -1,33 +0,0 @@ -LIB2ADD += \ - $(srcdir)/config/tilepro/softmpy.S \ - $(srcdir)/config/tilepro/atomic.c - -LIB2FUNCS_EXCLUDE += \ - _divdi3 \ - _moddi3 \ - _muldi3 \ - _udivdi3 \ - _umoddi3 - -SOFTDIVIDE_FUNCS := \ - _tile_udivsi3 \ - _tile_divsi3 \ - _tile_udivdi3 \ - _tile_divdi3 \ - _tile_umodsi3 \ - _tile_modsi3 \ - _tile_umoddi3 \ - _tile_moddi3 - -softdivide-o = $(patsubst %,%$(objext),$(SOFTDIVIDE_FUNCS)) -$(softdivide-o): %$(objext): $(srcdir)/config/tilepro/softdivide.c - $(gcc_compile) -ffunction-sections -DMAYBE_STATIC= -DL$* -c $< \ - $(vis_hide) -libgcc-objects += $(softdivide-o) - -ifeq ($(enable_shared),yes) -softdivide-s-o = $(patsubst %,%_s$(objext),$(SOFTDIVIDE_FUNCS)) -$(softdivide-s-o): %_s$(objext): $(srcdir)/config/tilepro/softdivide.c - $(gcc_s_compile) -ffunction-sections -DMAYBE_STATIC= -DL$* -c $< -libgcc-s-objects += $(softdivide-s-o) -endif diff --git a/libgcc/config/xtensa/lib1funcs.S b/libgcc/config/xtensa/lib1funcs.S index 5a2bd20..3932d20 100644 --- a/libgcc/config/xtensa/lib1funcs.S +++ b/libgcc/config/xtensa/lib1funcs.S @@ -456,6 +456,29 @@ __nsau_data: #endif /* L_clz */ +#ifdef L_clrsbsi2 + .align 4 + .global __clrsbsi2 + .type __clrsbsi2, @function +__clrsbsi2: + leaf_entry sp, 16 +#if XCHAL_HAVE_NSA + nsa a2, a2 +#else + srai a3, a2, 31 + xor a3, a3, a2 + movi a2, 31 + beqz a3, .Lreturn + do_nsau a2, a3, a4, a5 + addi a2, a2, -1 +.Lreturn: +#endif + leaf_return + .size __clrsbsi2, . - __clrsbsi2 + +#endif /* L_clrsbsi2 */ + + #ifdef L_clzsi2 .align 4 .global __clzsi2 diff --git a/libgcc/config/xtensa/t-xtensa b/libgcc/config/xtensa/t-xtensa index 9836c96..084618b 100644 --- a/libgcc/config/xtensa/t-xtensa +++ b/libgcc/config/xtensa/t-xtensa @@ -1,6 +1,6 @@ LIB1ASMSRC = xtensa/lib1funcs.S LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 _udivsi3 _umodsi3 \ - _umulsidi3 _clz _clzsi2 _ctzsi2 _ffssi2 \ + _umulsidi3 _clz _clrsbsi2 _clzsi2 _ctzsi2 _ffssi2 \ _ashldi3 _ashrdi3 _lshrdi3 \ _bswapsi2 _bswapdi2 \ _negsf2 _addsubsf3 _mulsf3 _divsf3 _cmpsf2 _fixsfsi _fixsfdi \ diff --git a/libgcc/configure b/libgcc/configure index 4919a56..61f3ace 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -630,6 +630,7 @@ LIPO AR toolexeclibdir toolexecdir +enable_gcov target_subdir host_subdir build_subdir @@ -653,7 +654,6 @@ build_cpu build with_aix_soname enable_vtable_verify -enable_gcov enable_shared libgcc_topdir target_alias @@ -701,7 +701,6 @@ with_target_subdir with_cross_host with_ld enable_shared -enable_gcov enable_vtable_verify with_aix_soname enable_version_specific_runtime_libs @@ -709,6 +708,7 @@ with_toolexeclibdir with_slibdir enable_maintainer_mode with_build_libsubdir +enable_gcov enable_largefile enable_decimal_float with_system_libunwind @@ -1342,12 +1342,12 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-shared don't provide a shared libgcc - --disable-gcov don't provide libgcov and related host tools --enable-vtable-verify Enable vtable verification feature --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer + --disable-gcov don't provide libgcov and related host tools --disable-largefile omit support for large files --enable-decimal-float={no,yes,bid,dpd} enable decimal float extension to C. Selecting 'bid' @@ -2252,15 +2252,6 @@ fi -# Check whether --enable-gcov was given. -if test "${enable_gcov+set}" = set; then : - enableval=$enable_gcov; -else - enable_gcov=yes -fi - - - # Check whether --enable-vtable-verify was given. if test "${enable_vtable_verify+set}" = set; then : enableval=$enable_vtable_verify; case "$enableval" in @@ -2412,6 +2403,9 @@ case "${host}" in # sets the default TLS model and affects inlining. PICFLAG=-fPIC ;; + loongarch*-*-*) + PICFLAG=-fpic + ;; mips-sgi-irix6*) # PIC is the default. ;; @@ -2713,6 +2707,22 @@ fi target_subdir=${target_noncanonical} +# Check whether --enable-gcov was given. +if test "${enable_gcov+set}" = set; then : + enableval=$enable_gcov; +else + case $target in + bpf-*-*) + enable_gcov=no + ;; + *) + enable_gcov=yes + ;; + esac +fi + + + # Calculate toolexeclibdir # Also toolexecdir, though it's only used in toolexeclibdir case ${version_specific_libs} in @@ -4761,6 +4771,7 @@ Valid choices are 'yes', 'bid', 'dpd', and 'no'." "$LINENO" 5 ;; else case $host in + aarch64* | \ powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | \ i?86*-*-elfiamcu | i?86*-*-gnu* | x86_64*-*-gnu* | \ i?86*-*-mingw* | x86_64*-*-mingw* | \ @@ -4781,7 +4792,7 @@ fi case x$enable_decimal_float in xyes) case $host in - i?86*-*-* | x86_64*-*-*) + aarch64* | i?86*-*-* | x86_64*-*-*) enable_decimal_float=bid ;; *) @@ -5066,7 +5077,7 @@ $as_echo "$libgcc_cv_cfi" >&6; } # word size rather than the address size. cat > conftest.c <<EOF #if defined(__x86_64__) || (!defined(__i386__) && defined(__LP64__)) \ - || defined(__mips64) + || defined(__mips64) || defined(__loongarch64) host_address=64 #else host_address=32 diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 13a80b2..2fc9d5d 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -68,11 +68,6 @@ AC_ARG_ENABLE(shared, ], [enable_shared=yes]) AC_SUBST(enable_shared) -AC_ARG_ENABLE(gcov, -[ --disable-gcov don't provide libgcov and related host tools], -[], [enable_gcov=yes]) -AC_SUBST(enable_gcov) - AC_ARG_ENABLE(vtable-verify, [ --enable-vtable-verify Enable vtable verification feature ], [case "$enableval" in @@ -163,6 +158,18 @@ ACX_NONCANONICAL_HOST ACX_NONCANONICAL_TARGET GCC_TOPLEV_SUBDIRS +AC_ARG_ENABLE(gcov, +[ --disable-gcov don't provide libgcov and related host tools], +[], [case $target in + bpf-*-*) + enable_gcov=no + ;; + *) + enable_gcov=yes + ;; + esac]) +AC_SUBST(enable_gcov) + # Calculate toolexeclibdir # Also toolexecdir, though it's only used in toolexeclibdir case ${version_specific_libs} in @@ -317,7 +324,7 @@ AC_CACHE_CHECK([whether assembler supports CFI directives], [libgcc_cv_cfi], # word size rather than the address size. cat > conftest.c <<EOF #if defined(__x86_64__) || (!defined(__i386__) && defined(__LP64__)) \ - || defined(__mips64) + || defined(__mips64) || defined(__loongarch64) host_address=64 #else host_address=32 diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c index b98b86a..b0d0062 100644 --- a/libgcc/crtstuff.c +++ b/libgcc/crtstuff.c @@ -261,7 +261,8 @@ STATIC func_ptr __DTOR_LIST__[1] /* Stick a label at the beginning of the frame unwind info so we can register and deregister it with the exception handling library code. */ STATIC EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[] - __attribute__((section(__LIBGCC_EH_FRAME_SECTION_NAME__), aligned(4))) + __attribute__((section(__LIBGCC_EH_FRAME_SECTION_NAME__), + aligned(__alignof__ (void *)))) = { }; #endif /* USE_EH_FRAME_REGISTRY */ diff --git a/libgcc/gcov.h b/libgcc/gcov.h index cea9302..cdd4206 100644 --- a/libgcc/gcov.h +++ b/libgcc/gcov.h @@ -43,7 +43,8 @@ extern void __gcov_dump (void); 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. */ + functions. It is recommended to use the __gcov_filename_to_gcfn() + in the filename callback function. */ extern void __gcov_info_to_gcda (const struct gcov_info *__info, @@ -52,4 +53,18 @@ __gcov_info_to_gcda (const struct gcov_info *__info, void *(*__allocate_fn) (unsigned, void *), void *__arg); +/* Convert the FILENAME to a gcfn data stream. 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 gcfn data stream. + The ARG parameter is a user-provided argument passed as the last + argument to the DUMP_FN callback function. This function is intended + to be used by the filename callback of __gcov_info_to_gcda(). The gcfn + data stream is used by the merge-stream subcommand of the gcov-tool to + get the filename associated with a gcda data stream. */ + +extern void +__gcov_filename_to_gcfn (const char *__filename, + void (*__dump_fn) (const void *, unsigned, void *), + void *__arg); + #endif /* GCC_GCOV_H */ diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c index eef6e3c..ac405c3 100644 --- a/libgcc/libgcov-driver-system.c +++ b/libgcc/libgcov-driver-system.c @@ -261,7 +261,8 @@ allocate_filename_struct (struct gcov_filename *gf) static int gcov_exit_open_gcda_file (struct gcov_info *gi_ptr, - struct gcov_filename *gf) + struct gcov_filename *gf, + int mode) { int append_slash = 0; const char *fname = gi_ptr->filename; @@ -309,7 +310,7 @@ gcov_exit_open_gcda_file (struct gcov_info *gi_ptr, gf->filename = replace_filename_variables (gf->filename); - if (!gcov_open (gf->filename)) + if (!gcov_open (gf->filename, mode)) { /* Open failed likely due to missed directory. Create directory and retry to open file. */ @@ -318,7 +319,7 @@ gcov_exit_open_gcda_file (struct gcov_info *gi_ptr, fprintf (stderr, "profiling:%s:Skip\n", gf->filename); return -1; } - if (!gcov_open (gf->filename)) + if (!gcov_open (gf->filename, mode)) { fprintf (stderr, "profiling:%s:Cannot open\n", gf->filename); return -1; diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c index 7e52c56..aba62d5 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -410,6 +410,24 @@ dump_counter (gcov_type counter, dump_unsigned (0, dump_fn, arg); } +/* Dump the STRING using the DUMP handler called with ARG. */ + +static inline void +ATTRIBUTE_UNUSED +dump_string (const char *string, + void (*dump_fn) (const void *, unsigned, void *), + void *arg) +{ + unsigned length = 0; + + if (string) + length = strlen (string) + 1; + + dump_unsigned (length, dump_fn, arg); + if (string) + (*dump_fn) (string, length, arg); +} + #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) /* Store all TOP N counters where each has a dynamic length. */ @@ -595,14 +613,14 @@ write_one_data (const struct gcov_info *gi_ptr, static void dump_one_gcov (struct gcov_info *gi_ptr, struct gcov_filename *gf, unsigned run_counted ATTRIBUTE_UNUSED, - gcov_type run_max ATTRIBUTE_UNUSED) + gcov_type run_max ATTRIBUTE_UNUSED, int mode) { struct gcov_summary summary = {}; int error; gcov_unsigned_t tag; fn_buffer = 0; - error = gcov_exit_open_gcda_file (gi_ptr, gf); + error = gcov_exit_open_gcda_file (gi_ptr, gf, mode); if (error == -1) return; @@ -649,13 +667,13 @@ read_fatal:; /* Dump all the coverage counts for the program. It first computes program summary and then traverses gcov_list list and dumps the gcov_info - objects one by one. */ + objects one by one. Use MODE to open files. */ #if !IN_GCOV_TOOL static #endif void -gcov_do_dump (struct gcov_info *list, int run_counted) +gcov_do_dump (struct gcov_info *list, int run_counted, int mode) { struct gcov_info *gi_ptr; struct gcov_filename gf; @@ -678,7 +696,7 @@ gcov_do_dump (struct gcov_info *list, int run_counted) /* Now merge each file. */ for (gi_ptr = list; gi_ptr; gi_ptr = gi_ptr->next) { - dump_one_gcov (gi_ptr, &gf, run_counted, run_max); + dump_one_gcov (gi_ptr, &gf, run_counted, run_max, mode); free (gf.filename); } @@ -701,7 +719,7 @@ __gcov_dump_one (struct gcov_root *root) if (root->dumped) return; - gcov_do_dump (root->list, root->run_counted); + gcov_do_dump (root->list, root->run_counted, 0); root->dumped = 1; root->run_counted = 1; @@ -768,7 +786,7 @@ __gcov_init (struct gcov_info *info) #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. */ + freestanding environments which do not support the C library file I/O. */ void __gcov_info_to_gcda (const struct gcov_info *gi_ptr, @@ -780,4 +798,17 @@ __gcov_info_to_gcda (const struct gcov_info *gi_ptr, (*filename_fn) (gi_ptr->filename, arg); write_one_data (gi_ptr, NULL, dump_fn, allocate_fn, arg); } + +/* Convert the filename to a gcfn data stream. It is intended for + freestanding environments which do not support the C library file I/O. */ + +void +__gcov_filename_to_gcfn (const char *filename, + void (*dump_fn) (const void *, unsigned, void *), + void *arg) +{ + dump_unsigned (GCOV_FILENAME_MAGIC, dump_fn, arg); + dump_unsigned (GCOV_VERSION, dump_fn, arg); + dump_string (filename, dump_fn, arg); +} #endif /* NEED_L_GCOV_INFO_TO_GCDA */ diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index ba7fb92..ba4670b 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -268,17 +268,10 @@ read_gcda_file (const char *filename) k_ctrs_mask[i] = 0; k_ctrs_types = 0; - if (!gcov_open (filename)) - { - fnotice (stderr, "%s:cannot open\n", filename); - return NULL; - } - /* Read magic. */ if (!gcov_magic (gcov_read_unsigned (), GCOV_DATA_MAGIC)) { fnotice (stderr, "%s:not a gcov data file\n", filename); - gcov_close (); return NULL; } @@ -287,7 +280,6 @@ read_gcda_file (const char *filename) if (version != GCOV_VERSION) { fnotice (stderr, "%s:incorrect gcov version %d vs %d \n", filename, version, GCOV_VERSION); - gcov_close (); return NULL; } @@ -296,16 +288,14 @@ read_gcda_file (const char *filename) sizeof (struct gcov_ctr_info) * GCOV_COUNTERS, 1); obj_info->version = version; + obj_info->filename = filename; obstack_init (&fn_info); num_fn_info = 0; curr_fn_info = 0; - { - size_t len = strlen (filename) + 1; - char *str_dup = (char*) xmalloc (len); - memcpy (str_dup, filename, len); - obj_info->filename = str_dup; - } + /* Prepend to global gcov info list. */ + obj_info->next = gcov_info_head; + gcov_info_head = obj_info; /* Read stamp. */ obj_info->stamp = gcov_read_unsigned (); @@ -381,7 +371,6 @@ read_gcda_file (const char *filename) } read_gcda_finalize (obj_info); - gcov_close (); return obj_info; } @@ -395,9 +384,8 @@ ftw_read_file (const char *filename, const struct stat *status ATTRIBUTE_UNUSED, int type) { - int filename_len; - int suffix_len; - struct gcov_info *obj_info; + size_t filename_len; + size_t suffix_len; /* Only read regular files. */ if (type != FTW_F) @@ -415,12 +403,14 @@ ftw_read_file (const char *filename, if (verbose) fnotice (stderr, "reading file: %s\n", filename); - obj_info = read_gcda_file (filename); - if (!obj_info) - return 0; + if (!gcov_open (filename, 1)) + { + fnotice (stderr, "%s:cannot open:%s\n", filename, xstrerror (errno)); + return 0; + } - obj_info->next = gcov_info_head; - gcov_info_head = obj_info; + (void)read_gcda_file (xstrdup (filename)); + gcov_close (); return 0; } @@ -674,16 +664,16 @@ find_match_gcov_info (struct gcov_info **array, int size, } /* Merge the list of gcov_info objects from SRC_PROFILE to TGT_PROFILE. - Return 0 on success: without mismatch. - Reutrn 1 on error. */ + Return the list of merged gcov_info objects. Return NULL if the list is + empty. */ -int +struct gcov_info * gcov_profile_merge (struct gcov_info *tgt_profile, struct gcov_info *src_profile, int w1, int w2) { struct gcov_info *gi_ptr; struct gcov_info **tgt_infos; - struct gcov_info *tgt_tail; + struct gcov_info **tgt_tail; struct gcov_info **in_src_not_tgt; unsigned tgt_cnt = 0, src_cnt = 0; unsigned unmatch_info_cnt = 0; @@ -703,7 +693,10 @@ gcov_profile_merge (struct gcov_info *tgt_profile, struct gcov_info *src_profile for (gi_ptr = tgt_profile, i = 0; gi_ptr; gi_ptr = gi_ptr->next, i++) tgt_infos[i] = gi_ptr; - tgt_tail = tgt_infos[tgt_cnt - 1]; + if (tgt_cnt) + tgt_tail = &tgt_infos[tgt_cnt - 1]->next; + else + tgt_tail = &tgt_profile; /* First pass on tgt_profile, we multiply w1 to all counters. */ if (w1 > 1) @@ -732,14 +725,109 @@ gcov_profile_merge (struct gcov_info *tgt_profile, struct gcov_info *src_profile gi_ptr = in_src_not_tgt[i]; gcov_merge (gi_ptr, gi_ptr, w2 - 1); gi_ptr->next = NULL; - tgt_tail->next = gi_ptr; - tgt_tail = gi_ptr; + *tgt_tail = gi_ptr; + tgt_tail = &gi_ptr->next; } free (in_src_not_tgt); free (tgt_infos); - return 0; + return tgt_profile; +} + +/* Deserialize gcov_info objects and associated filenames from the file + specified by FILENAME to create a profile list. When FILENAME is NULL, read + from stdin. Return the profile list. */ + +struct gcov_info * +deserialize_profiles (const char *filename) +{ + read_profile_dir_init (); + + while (true) + { + unsigned version; + const char *filename_of_info; + struct gcov_info *obj_info; + + if (!gcov_magic (gcov_read_unsigned (), GCOV_FILENAME_MAGIC)) + { + if (gcov_is_error () != 2) + fnotice (stderr, "%s:not a gcfn stream\n", filename); + break; + } + + version = gcov_read_unsigned (); + if (version != GCOV_VERSION) + { + fnotice (stderr, "%s:incorrect gcov version %d vs %d \n", + filename, version, GCOV_VERSION); + break; + } + + filename_of_info = gcov_read_string (); + if (!filename_of_info) + { + fnotice (stderr, "%s:no filename in gcfn stream\n", + filename); + break; + } + + obj_info = read_gcda_file (filename); + if (!obj_info) + break; + + obj_info->filename = filename_of_info; + } + + return gcov_info_head; +} + +/* For each profile of the list specified by SRC_PROFILE, read the GCDA file of + the profile. If a GCDA file exists, add the profile to a list. Return the + profile list. */ + +struct gcov_info * +get_target_profiles_for_merge (struct gcov_info *src_profile) +{ + struct gcov_info *gi_ptr; + + read_profile_dir_init (); + + for (gi_ptr = src_profile; gi_ptr; gi_ptr = gi_ptr->next) + if (gcov_open (gi_ptr->filename, 1)) + { + (void)read_gcda_file (gi_ptr->filename); + gcov_close (); + } + + return gcov_info_head; +} + +/* Deserialize gcov_info objects and associated filenames from the file + specified by FILENAME to create a source profile list. When FILENAME is + NULL, read from stdin. Use the filenames of the source profile list to get + a target profile list. Merge the source profile list into the target + profile list using weights W1 and W2. Return the list of merged gcov_info + objects. Return NULL if the list is empty. */ + +struct gcov_info * +gcov_profile_merge_stream (const char *filename, int w1, int w2) +{ + struct gcov_info *tgt_profile; + struct gcov_info *src_profile; + + if (!gcov_open (filename, 1)) + { + fnotice (stderr, "%s:cannot open:%s\n", filename, xstrerror (errno)); + return NULL; + } + + src_profile = deserialize_profiles (filename ? filename : "<stdin>"); + gcov_close (); + tgt_profile = get_target_profiles_for_merge (src_profile); + + return gcov_profile_merge (tgt_profile, src_profile, w1, w2); } typedef gcov_type (*counter_op_fn) (gcov_type, void*, void*); diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index 40e845c..c7545cc 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -115,7 +115,6 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI))); #define gcov_open __gcov_open #define gcov_close __gcov_close #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 @@ -236,7 +235,7 @@ struct gcov_info gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for unused) */ - unsigned n_functions; /* number of functions */ + gcov_unsigned_t n_functions; /* number of functions */ #ifndef IN_GCOV_TOOL const struct gcov_fn_info *const *functions; /* pointer to pointers @@ -343,11 +342,9 @@ extern int __gcov_execve (const char *, char *const [], char *const []) ATTRIBUTE_HIDDEN; /* Functions that only available in libgcov. */ -GCOV_LINKAGE int gcov_open (const char */*name*/) ATTRIBUTE_HIDDEN; GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/, const struct gcov_summary *) ATTRIBUTE_HIDDEN; -GCOV_LINKAGE void gcov_seek (gcov_position_t /*position*/) ATTRIBUTE_HIDDEN; GCOV_LINKAGE void gcov_rewrite (void) ATTRIBUTE_HIDDEN; /* "Counts" stored in gcda files can be a real counter value, or diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c index 3d6f39f..7f9be5e 100644 --- a/libgcc/unwind-dw2-fde-dip.c +++ b/libgcc/unwind-dw2-fde-dip.c @@ -514,7 +514,7 @@ _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases) # if DLFO_STRUCT_HAS_EH_DBASE (_Unwind_Ptr) dlfo.dlfo_eh_dbase, # else - NULL, + 0, # endif bases); else diff --git a/libgcc/unwind-dw2.c b/libgcc/unwind-dw2.c index 6ccd885..a2eb66d 100644 --- a/libgcc/unwind-dw2.c +++ b/libgcc/unwind-dw2.c @@ -1204,7 +1204,9 @@ execute_cfa_program (const unsigned char *insn_ptr, #if defined (__aarch64__) && !defined (__ILP32__) /* This CFA is multiplexed with Sparc. On AArch64 it's used to toggle return address signing status. */ - fs->regs.reg[DWARF_REGNUM_AARCH64_RA_STATE].loc.offset ^= 1; + reg = DWARF_REGNUM_AARCH64_RA_STATE; + gcc_assert (fs->regs.reg[reg].how == REG_UNSAVED); + fs->regs.reg[reg].loc.offset ^= 1; #else /* ??? Hardcoded for SPARC register window configuration. */ if (__LIBGCC_DWARF_FRAME_REGISTERS__ >= 32) |