From 39be73d07bb667fd5d313a3398f5399e091f2c0c Mon Sep 17 00:00:00 2001 From: "Jose E. Marchesi" Date: Wed, 23 Feb 2022 20:48:30 +0100 Subject: bpf: do not --enable-gcov for bpf-*-* targets This patch changes the build machinery in order to disable the build of GCOV (both compiler and libgcc) in bpf-*-* targets. The reason for this change is that BPF is (currently) too restricted in order to support the coverage instrumentalization. Tested in bpf-unknown-none and x86_64-linux-gnu targets. 2022-02-23 Jose E. Marchesi gcc/ChangeLog PR target/104656 * configure.ac: --disable-gcov if targetting bpf-*. * configure: Regenerate. libgcc/ChangeLog PR target/104656 * configure.ac: --disable-gcov if targetting bpf-*. * configure: Regenerate. --- libgcc/configure | 31 +++++++++++++++++++------------ libgcc/configure.ac | 17 ++++++++++++----- 2 files changed, 31 insertions(+), 17 deletions(-) (limited to 'libgcc') diff --git a/libgcc/configure b/libgcc/configure index 4919a56..52bf25d 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 @@ -2713,6 +2704,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 diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 13a80b2..6f0b67c 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 -- cgit v1.1 From 157cc4e0117756503c7c63df97cf31de7570b088 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Fri, 25 Feb 2022 01:45:57 +0800 Subject: libgcc: fix a warning calling find_fde_tail The third parameter of find_fde_tail is an _Unwind_Ptr (which is an integer type instead of a pointer), but we are passing NULL to it. This causes a -Wint-conversion warning. libgcc/ * unwind-dw2-fde-dip.c (_Unwind_Find_FDE): Call find_fde_tail with 0 instead of NULL. --- libgcc/unwind-dw2-fde-dip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libgcc') 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 -- cgit v1.1 From 756a61851c11ffb6b5bcc21f147f6f102bf8e1f3 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 25 Feb 2022 00:16:20 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 035bfb5..d9da85d 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,14 @@ +2022-02-24 Xi Ruoyao + + * unwind-dw2-fde-dip.c (_Unwind_Find_FDE): Call find_fde_tail + with 0 instead of NULL. + +2022-02-24 Jose E. Marchesi + + PR target/104656 + * configure.ac: --disable-gcov if targetting bpf-*. + * configure: Regenerate. + 2022-01-25 Florian Weimer PR libgcc/104207 -- cgit v1.1 From c18ddb05b0391a397f8882fc6a12a1bab7e0df52 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Fri, 4 Mar 2022 12:34:15 +0000 Subject: Darwin, libgcc: Fix build errors on powerpc-darwin8. PowerPC Darwin8 is the last version to use an unwind frame fallback routine. This had been omitted from the new shared EH library, along with one more header dependency that only fires there. Signed-off-by: Iain Sandoe libgcc/ChangeLog: * config/rs6000/t-darwin-ehs: Add darwin-fallback.o. * config/t-darwin-ehs: Add dependency on unwind.h. --- libgcc/config/rs6000/t-darwin-ehs | 4 ++-- libgcc/config/t-darwin-ehs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libgcc') 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 -- cgit v1.1 From 8d96e14c1d61b04cd424cdbb6c830bb204dafbcf Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 5 Mar 2022 00:16:31 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index d9da85d..82d88ed 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2022-03-04 Iain Sandoe + + * config/rs6000/t-darwin-ehs: Add darwin-fallback.o. + * config/t-darwin-ehs: Add dependency on unwind.h. + 2022-02-24 Xi Ruoyao * unwind-dw2-fde-dip.c (_Unwind_Find_FDE): Call find_fde_tail -- cgit v1.1 From 450526551dcb97b7c0513699d4333efb79b8b490 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 9 Mar 2022 19:34:48 +0100 Subject: GCN: Implement __atomic_compare_exchange_{1,2} in libgcc [PR102215] libgcc/ChangeLog: 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}. --- libgcc/config/gcn/atomic.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'libgcc') 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) -- cgit v1.1 From 8cc4f9cd824d195178632569c749f96b306475f9 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 10 Mar 2022 00:16:28 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 82d88ed..f023ce2 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,11 @@ +2022-03-09 Tobias Burnus + + 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 * config/rs6000/t-darwin-ehs: Add darwin-fallback.o. -- cgit v1.1 From 638e630142b2cf691db890ab9eb6d77a65339c54 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 19 Mar 2022 15:09:36 -0400 Subject: libgcc: m68k: avoid TEXTRELs in shared library (PR 86224) libgcc/ 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. --- libgcc/config/m68k/lb1sf68.S | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'libgcc') 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 -- cgit v1.1 From d7f00da1c0ed414175305c41a07b3a50fa577cce Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 20 Mar 2022 00:16:30 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index f023ce2..b488ef2 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,11 @@ +2022-03-19 Sergei Trofimovich + + 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 PR target/102215 -- cgit v1.1 From bf291a4330d62bbe5b5ab6029d55216362d0dce9 Mon Sep 17 00:00:00 2001 From: chenglulu Date: Sat, 27 Nov 2021 15:05:47 +0800 Subject: LoongArch Port: libgcc 2022-03-29 Chenghua Xu Lulu Cheng libgcc/ChangeLog: * 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. --- libgcc/config.host | 28 +++++- libgcc/config/loongarch/crtfastmath.c | 52 +++++++++++ libgcc/config/loongarch/linux-unwind.h | 80 +++++++++++++++++ libgcc/config/loongarch/sfp-machine.h | 152 +++++++++++++++++++++++++++++++++ libgcc/config/loongarch/t-crtstuff | 5 ++ libgcc/config/loongarch/t-loongarch | 7 ++ libgcc/config/loongarch/t-loongarch64 | 1 + libgcc/config/loongarch/t-softfp-tf | 3 + libgcc/configure.ac | 2 +- 9 files changed, 328 insertions(+), 2 deletions(-) create mode 100644 libgcc/config/loongarch/crtfastmath.c create mode 100644 libgcc/config/loongarch/linux-unwind.h create mode 100644 libgcc/config/loongarch/sfp-machine.h create mode 100644 libgcc/config/loongarch/t-crtstuff create mode 100644 libgcc/config/loongarch/t-loongarch create mode 100644 libgcc/config/loongarch/t-loongarch64 create mode 100644 libgcc/config/loongarch/t-softfp-tf (limited to 'libgcc') diff --git a/libgcc/config.host b/libgcc/config.host index 094fd3a..8c56fca 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 ;; @@ -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" 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 . */ + +#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 +. */ + +#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 +#include +#include + +#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 +. */ + +#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/loongarch/t-loongarch64 b/libgcc/config/loongarch/t-loongarch64 new file mode 100644 index 0000000..a1e3513 --- /dev/null +++ b/libgcc/config/loongarch/t-loongarch64 @@ -0,0 +1 @@ +softfp_int_modes += ti 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/configure.ac b/libgcc/configure.ac index 6f0b67c..2fc9d5d 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -324,7 +324,7 @@ AC_CACHE_CHECK([whether assembler supports CFI directives], [libgcc_cv_cfi], # word size rather than the address size. cat > conftest.c < Date: Sat, 27 Nov 2021 15:06:34 +0800 Subject: LoongArch Port: Regenerate libgcc/configure. 2022-03-29 Chenghua Xu Lulu Cheng libgcc/ChangeLog: * configure: Regenerate file. --- libgcc/configure | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libgcc') diff --git a/libgcc/configure b/libgcc/configure index 52bf25d..1f9b2ac 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -2403,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. ;; @@ -5073,7 +5076,7 @@ $as_echo "$libgcc_cv_cfi" >&6; } # word size rather than the address size. cat > conftest.c < Date: Wed, 30 Mar 2022 00:16:49 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index b488ef2..8b2b9f4 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,21 @@ +2022-03-29 Chenghua Xu + Lulu Cheng + + * configure: Regenerate file. + +2022-03-29 Chenghua Xu + Lulu Cheng + + * 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 PR libgcc/86224 -- cgit v1.1 From cef03728234644b1a9ad5bd8e94daeac8650a71b Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 7 Apr 2022 08:36:23 +0100 Subject: libgcc: IA64: don't compile glibc-based unwinder without libc headers In --without-headers mode gcc fails to bootstrap on libgcc as: /build/build/./gcc/xgcc -B/build/build/./gcc/ ... -Dinhibit_libc -c fde-glibc.c ../../../gcc-12-20220403/libgcc/config/ia64/fde-glibc.c:33:10: fatal error: stdlib.h: No such file or directory Most other linux targets are able to build the --without-headers compiler without additional effort. This change adds IA64 to the fold. The change drops part of the code that relies on DYNAMIC glibc section traversal for backtraces. Tested bootstrap of ia64-unknown-linux-gnu with and without libc headers present. libgcc/ * config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode. --- libgcc/config/ia64/fde-glibc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libgcc') 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 #include #include @@ -159,3 +160,4 @@ _Unwind_FindTableEntry (void *pc, unw_word *segment_base, unw_word *gp, return data.ret; } +#endif -- cgit v1.1 From 405eda0d34b69fb6ee12ba6ed0f69c2c2411d8ee Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 9 Apr 2022 00:16:56 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 8b2b9f4..ce0cb32 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,7 @@ +2022-04-08 Sergei Trofimovich + + * config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode. + 2022-03-29 Chenghua Xu Lulu Cheng -- cgit v1.1 From 336ea18ad7f48d675fce8c97bf3b7a0ee3a5a450 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 23 Mar 2022 10:20:56 +0100 Subject: gcov-tool: Allow merging of empty profile lists The gcov_profile_merge() already had code to deal with profile information which had no counterpart to merge with. For profile information from files with no associated counterpart, the profile information is simply used as is with the weighting transformation applied. Make sure that gcov_profile_merge() works with an empty target profile list. Return the merged profile list. gcc/ * gcov-tool.cc (gcov_profile_merge): Adjust return type. (profile_merge): Allow merging of directories which contain no profile files. libgcc/ * libgcov-util.c (gcov_profile_merge): Return the list of merged profiles. Accept empty target and source profile lists. --- libgcc/libgcov-util.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index ba7fb92..100f1b1 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -674,16 +674,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 +703,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 +735,14 @@ 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; } typedef gcov_type (*counter_op_fn) (gcov_type, void*, void*); -- cgit v1.1 From d170ecc9fcb386bd5f62eb86dd6e411e6fcb4cef Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 24 Mar 2022 21:59:21 +0100 Subject: gcov: Add mode to all gcov_open() gcc/ * gcov-io.cc (gcov_open): Always use the mode parameter. * gcov-io.h (gcov_open): Declare it unconditionally. libgcc/ * 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. --- libgcc/libgcov-driver-system.c | 4 ++-- libgcc/libgcov-util.c | 2 +- libgcc/libgcov.h | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c index eef6e3c..9abb2fe 100644 --- a/libgcc/libgcov-driver-system.c +++ b/libgcc/libgcov-driver-system.c @@ -309,7 +309,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, 0)) { /* Open failed likely due to missed directory. Create directory and retry to open file. */ @@ -318,7 +318,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, 0)) { fprintf (stderr, "profiling:%s:Cannot open\n", gf->filename); return -1; diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index 100f1b1..db15722 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -268,7 +268,7 @@ read_gcda_file (const char *filename) k_ctrs_mask[i] = 0; k_ctrs_types = 0; - if (!gcov_open (filename)) + if (!gcov_open (filename, 1)) { fnotice (stderr, "%s:cannot open\n", filename); return NULL; diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index 40e845c..f190547 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -343,7 +343,6 @@ 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; -- cgit v1.1 From 1a6314b040877842ac71e6d9d786fe7a452e51e2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 31 Mar 2022 11:37:56 +0200 Subject: gcov: Add open mode parameter to gcov_do_dump() gcc/ * gcov-tool.cc (gcov_do_dump): Add mode parameter. (gcov_output_files): Open files for reading and writing. libgcc/ * 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. --- libgcc/libgcov-driver-system.c | 7 ++++--- libgcc/libgcov-driver.c | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c index 9abb2fe..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, 0)) + 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, 0)) + 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..10831e8 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -595,14 +595,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 +649,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 +678,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 +701,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; -- cgit v1.1 From 68a4673fe25e067df74373a45180d80c70da102f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 28 Mar 2022 12:50:44 +0200 Subject: gcov: Make gcov_seek() static This function is only used by gcov_write_length() in the gcov-io.cc file. gcc/ * gcov-io.cc (gcov_seek): Make it static. * gcov-io.h (struct gcov_summary): Do not mention gcov_seek(). libgcc/ * libgcov.h (gcov_seek): Remove define and declaration. --- libgcc/libgcov.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index f190547..487bd14 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 @@ -346,7 +345,6 @@ extern int __gcov_execve (const char *, char *const [], char *const []) 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 -- cgit v1.1 From 39d80300b3c769c3a7805a46ee5facc6adf1a4d0 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Mar 2022 21:45:23 +0200 Subject: gcov: Add __gcov_filename_to_gcfn() gcc/ * doc/invoke.texi (fprofile-info-section): Mention __gcov_filename_to_gcfn(). Use "freestanding" to match with C11 standard language. Fix minor example code issues. * gcov-io.h (GCOV_FILENAME_MAGIC): Define and document. gcc/testsuite/ * gcc.dg/gcov-info-to-gcda.c: Test __gcov_filename_to_gcfn(). libgcc/ * 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. --- libgcc/gcov.h | 17 ++++++++++++++++- libgcc/libgcov-driver.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) (limited to 'libgcc') 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.c b/libgcc/libgcov-driver.c index 10831e8..d4517d2 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -410,6 +410,23 @@ dump_counter (gcov_type counter, dump_unsigned (0, dump_fn, arg); } +/* Dump the STRING using the DUMP handler called with ARG. */ + +static inline void +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. */ @@ -768,7 +785,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 +797,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 */ -- cgit v1.1 From f9b59dd8e5586862cd3c2fa53901ee2e90226a3c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Mar 2022 21:49:51 +0200 Subject: gcov: Use xstrdup() Move duplication of filename to caller and use xstrdup() instead of custom code. This helps to reuse read_gcda_file() for other purposes. libgcc/ * libgcov-util.c (read_gcda_file): Do not duplicate filename. (ftw_read_file): Duplicate filename for read_gcda_file(). --- libgcc/libgcov-util.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index db15722..ae5712c 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -296,16 +296,11 @@ 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; - } /* Read stamp. */ obj_info->stamp = gcov_read_unsigned (); @@ -415,7 +410,7 @@ ftw_read_file (const char *filename, if (verbose) fnotice (stderr, "reading file: %s\n", filename); - obj_info = read_gcda_file (filename); + obj_info = read_gcda_file (xstrdup (filename)); if (!obj_info) return 0; -- cgit v1.1 From 76cae6482e0e618d1f8709b3c5d14642378281c7 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Mar 2022 21:54:36 +0200 Subject: gcov: Move prepend to list to read_gcda_file() This helps to reuse read_gcda_file(). libgcc/ * libgcov-util.c (read_gcda_file): Prepend new info object to global list. (ftw_read_file): Remove list append here. --- libgcc/libgcov-util.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index ae5712c..906ea64 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -301,6 +301,9 @@ read_gcda_file (const char *filename) num_fn_info = 0; curr_fn_info = 0; + /* 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 (); @@ -392,7 +395,6 @@ ftw_read_file (const char *filename, { int filename_len; int suffix_len; - struct gcov_info *obj_info; /* Only read regular files. */ if (type != FTW_F) @@ -410,12 +412,7 @@ ftw_read_file (const char *filename, if (verbose) fnotice (stderr, "reading file: %s\n", filename); - obj_info = read_gcda_file (xstrdup (filename)); - if (!obj_info) - return 0; - - obj_info->next = gcov_info_head; - gcov_info_head = obj_info; + (void)read_gcda_file (xstrdup (filename)); return 0; } -- cgit v1.1 From c190b0e65fe62e9fe58a8a04c6695a263da90161 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Mar 2022 21:59:43 +0200 Subject: gcov: Move gcov_open() to caller of read_gcda_file() This allows to reuse read_gcda_file() to read multiple objects from a single file. libgcc/ * libgcov-util.c (read_gcda_file): Do not open file. (ftw_read_file): Open file here. --- libgcc/libgcov-util.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index 906ea64..6093a74 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, 1)) - { - 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; } @@ -379,7 +371,6 @@ read_gcda_file (const char *filename) } read_gcda_finalize (obj_info); - gcov_close (); return obj_info; } @@ -412,7 +403,14 @@ ftw_read_file (const char *filename, if (verbose) fnotice (stderr, "reading file: %s\n", filename); + if (!gcov_open (filename, 1)) + { + fnotice (stderr, "%s:cannot open\n", filename); + return 0; + } + (void)read_gcda_file (xstrdup (filename)); + gcov_close (); return 0; } -- cgit v1.1 From 1ff8d194cbc6354d3c52d5362d22cc1f56b73ef7 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Mar 2022 22:05:12 +0200 Subject: gcov: Fix integer types in ftw_read_file() libgcc/ * libgcov-util.c (ftw_read_file): Use size_t for strlen() variables. --- libgcc/libgcov-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index 6093a74..bf96f50 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -384,8 +384,8 @@ ftw_read_file (const char *filename, const struct stat *status ATTRIBUTE_UNUSED, int type) { - int filename_len; - int suffix_len; + size_t filename_len; + size_t suffix_len; /* Only read regular files. */ if (type != FTW_F) -- cgit v1.1 From 210e32b60b9018e5db2d9741dc7aaa5d9b436999 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Mar 2022 16:53:29 +0200 Subject: gcov-tool: Add merge-stream subcommand gcc/ * doc/gcov-tool.texi: Document merge-stream subcommand. * doc/invoke.texi (fprofile-info-section): Mention merge-stream subcommand of gcov-tool. * gcov-tool.cc (gcov_profile_merge_stream): Declare. (print_merge_stream_usage_message): New. (merge_stream_usage): Likewise. (do_merge_stream): Likewise. (print_usage): Call print_merge_stream_usage_message(). (main): Call do_merge_stream() to execute merge-stream subcommand. libgcc/ * libgcov-util.c (consume_stream): New. (get_target_profiles_for_merge): Likewise. (gcov_profile_merge_stream): Likewise. --- libgcc/libgcov-util.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'libgcc') diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index bf96f50..250dddd 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -735,6 +735,101 @@ gcov_profile_merge (struct gcov_info *tgt_profile, struct gcov_info *src_profile 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\n", filename); + return NULL; + } + + src_profile = deserialize_profiles (filename ? filename : ""); + 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*); /* Performing FN upon arc counters. */ -- cgit v1.1 From 92475ea84f69ad2bb92dbecd6b5c33be174c4777 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 31 Mar 2022 10:50:50 +0200 Subject: gcov: Use xstrerror() libgcc/ * libgcov-util.c (ftw_read_file): Improve notice using xstrerror(). (gcov_profile_merge_stream): Likewise. --- libgcc/libgcov-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c index 250dddd..ba4670b 100644 --- a/libgcc/libgcov-util.c +++ b/libgcc/libgcov-util.c @@ -405,7 +405,7 @@ ftw_read_file (const char *filename, if (!gcov_open (filename, 1)) { - fnotice (stderr, "%s:cannot open\n", filename); + fnotice (stderr, "%s:cannot open:%s\n", filename, xstrerror (errno)); return 0; } @@ -819,7 +819,7 @@ gcov_profile_merge_stream (const char *filename, int w1, int w2) if (!gcov_open (filename, 1)) { - fnotice (stderr, "%s:cannot open\n", filename); + fnotice (stderr, "%s:cannot open:%s\n", filename, xstrerror (errno)); return NULL; } -- cgit v1.1 From 6b6f53d8afdb3744530a93e1f8dc00de69052493 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 29 Apr 2022 00:16:26 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index ce0cb32..f597666 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,68 @@ +2022-04-28 Sebastian Huber + + * libgcov-util.c (ftw_read_file): Improve notice using xstrerror(). + (gcov_profile_merge_stream): Likewise. + +2022-04-28 Sebastian Huber + + * libgcov-util.c (consume_stream): New. + (get_target_profiles_for_merge): Likewise. + (gcov_profile_merge_stream): Likewise. + +2022-04-28 Sebastian Huber + + * libgcov-util.c (ftw_read_file): Use size_t for strlen() variables. + +2022-04-28 Sebastian Huber + + * libgcov-util.c (read_gcda_file): Do not open file. + (ftw_read_file): Open file here. + +2022-04-28 Sebastian Huber + + * 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 + + * libgcov-util.c (read_gcda_file): Do not duplicate filename. + (ftw_read_file): Duplicate filename for read_gcda_file(). + +2022-04-28 Sebastian Huber + + * 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 + + * libgcov.h (gcov_seek): Remove define and declaration. + +2022-04-28 Sebastian Huber + + * 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 + + * 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 + + * libgcov-util.c (gcov_profile_merge): Return the list of merged + profiles. Accept empty target and source profile lists. + 2022-04-08 Sergei Trofimovich * config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode. -- cgit v1.1 From 28cfea987e12413a85a4fa1942800100c43d4b40 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 2 May 2022 06:46:05 +0200 Subject: libgcov: add ATTRIBUTE_UNUSED for dump_string Mitigates the following clang warning: libgcc/libgcov-driver.c:416:1: warning: unused function 'dump_string' [-Wunused-function] libgcc/ChangeLog: * libgcov-driver.c: Add ATTRIBUTE_UNUSED. --- libgcc/libgcov-driver.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libgcc') diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c index d4517d2..aba62d5 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -413,6 +413,7 @@ dump_counter (gcov_type counter, /* 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) -- cgit v1.1 From 6259d8aa73f6c4742c1aa22cccc325701307b3af Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 3 May 2022 00:16:25 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index f597666..5141ce5 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,7 @@ +2022-05-02 Martin Liska + + * libgcov-driver.c: Add ATTRIBUTE_UNUSED. + 2022-04-28 Sebastian Huber * libgcov-util.c (ftw_read_file): Improve notice using xstrerror(). -- cgit v1.1 From 1bac97ad0436afcbce24c82e6d57f11471cd8f10 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 10 May 2022 10:52:19 +0200 Subject: libgcov: use proper type for n_functions gcov_info::n_functions type is initialized by generated code in build_info_type: /* n_functions */ field = build_decl (BUILTINS_LOCATION, FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); It uses gcov_unsigned_t, but the struct definition in libgcov.h uses unsigned type. That brings troubled on 16-bit targets. PR gcov-profile/105535 libgcc/ChangeLog: * libgcov.h (struct gcov_info): Use gcov_unsigned_t for n_functions. Co-Authored-By: Hans-Peter Helfert --- libgcc/libgcov.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libgcc') diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index 487bd14..c7545cc 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -235,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 -- cgit v1.1 From e877898911574037af5aaa68ff6451ec5ced20e9 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 11 May 2022 00:16:40 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 5141ce5..25f5c19 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,10 @@ +2022-05-10 Martin Liska + Hans-Peter Helfert + + PR gcov-profile/105535 + * libgcov.h (struct gcov_info): Use gcov_unsigned_t for + n_functions. + 2022-05-02 Martin Liska * libgcov-driver.c: Add ATTRIBUTE_UNUSED. -- cgit v1.1 From bc25483c055d62f94f8c289f80843dda3c4a6ff4 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Mon, 18 Apr 2022 15:13:20 +0000 Subject: [AArch64] add barriers to ool __sync builtins 2022-05-13 Sebastian Pop gcc/ PR target/105162 * config/aarch64/aarch64-protos.h (atomic_ool_names): Increase dimension of str array. * config/aarch64/aarch64.cc (aarch64_atomic_ool_func): Call memmodel_from_int and handle MEMMODEL_SYNC_*. (DEF0): Add __aarch64_*_sync functions. gcc/testsuite/ PR target/105162 * gcc.target/aarch64/sync-comp-swap-ool.c: New. * gcc.target/aarch64/sync-op-acquire-ool.c: New. * gcc.target/aarch64/sync-op-full-ool.c: New. * gcc.target/aarch64/target_attr_20.c: Update check. * gcc.target/aarch64/target_attr_21.c: Same. libgcc/ 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. --- libgcc/config/aarch64/lse.S | 42 ++++++++++++++++++++++++++++++++++++++---- libgcc/config/aarch64/t-lse | 8 ++++---- 2 files changed, 42 insertions(+), 8 deletions(-) (limited to 'libgcc') 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 # . -# 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) -- cgit v1.1 From 9df4ffe493a4616b276c66e73df3b2e929db023b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 14 May 2022 00:17:19 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 25f5c19..5d351a6 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2022-05-13 Sebastian Pop + + 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 Hans-Peter Helfert -- cgit v1.1 From afd82c104b1038572ed4d473a0b5f6e2c778fa01 Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 9 Mar 2022 14:27:10 +0000 Subject: aarch64: Enable DFP (Decimal Floating-point) (BID format) This patch enables DFP support on aarch64, by updating config/dfp.m4 and regenerating the involved configure scripts. We enable the BID format. 2022-03-31 Christophe Lyon config/ * dfp.m4: Add aarch64 support. gcc/ * configure: Regenerate. libdecnumber/ * configure: Regenerate. libgcc/ * configure: Regenerate. --- libgcc/configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libgcc') diff --git a/libgcc/configure b/libgcc/configure index 1f9b2ac..61f3ace 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -4771,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* | \ @@ -4791,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 ;; *) -- cgit v1.1 From 43ccb7e445329dd9557b42e7289a87a8071ab0f7 Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 23 Mar 2022 15:26:14 +0000 Subject: libgcc: Enable XF mode conversions to/from DFP modes only if supported Some targets do not support XF mode (eg AArch64), so don't build the corresponding to/from DFP modes convertion routines if __LIBGCC_HAS_XF_MODE__ is not defined. 2022-03-31 Christophe Lyon libgcc/config/libbid/ * _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. --- libgcc/config/libbid/_dd_to_xf.c | 2 ++ libgcc/config/libbid/_sd_to_xf.c | 2 ++ libgcc/config/libbid/_td_to_xf.c | 2 ++ libgcc/config/libbid/_xf_to_dd.c | 2 ++ libgcc/config/libbid/_xf_to_sd.c | 2 ++ libgcc/config/libbid/_xf_to_td.c | 2 ++ 6 files changed, 12 insertions(+) (limited to 'libgcc') 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/_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_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 -- cgit v1.1 From 012310aafb24e8ccdc0d979e79bf7c867a52e615 Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 23 Mar 2022 15:25:16 +0000 Subject: libgcc: enable DFP for AArch64 DFP support on AArch64 relies on libgcc, so enable its DFP routines for all AArch64 targets. 2022-03-31 Christophe Lyon libgcc/ * config.host: Add t-dfprules to AArch64 targets. --- libgcc/config.host | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libgcc') diff --git a/libgcc/config.host b/libgcc/config.host index 8c56fca..927d34a 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -382,6 +382,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*) @@ -389,18 +390,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" @@ -408,6 +412,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" @@ -415,6 +420,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" -- cgit v1.1 From 308a0af4f913243023ee52332f7cc513745c9203 Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 4 May 2022 16:13:35 +0100 Subject: libgcc: Add support for HF mode (aka _Float16) in libbid This patch adds support for trunc and extend operations between HF mode (_Float16) and Decimal Floating Point formats (_Decimal32, _Decimal64 and _Decimal128). For simplicity we rely on the implicit conversions inserted by the compiler between HF and SD/DF/TF modes. The existing bid*_to_binary* and binary*_to_bid* functions are non-trivial and at this stage it is not clear if there is a performance-critical use case involving _Float16 and _Decimal* formats. The patch also adds two executable tests, to make sure the right functions are called, available (link phase) and functional. Tested on aarch64 and x86_64. The number of symbol matches in the testcases includes the .global XXX to avoid having to match different call instructions for different targets. 2022-05-04 Christophe Lyon libgcc/ChangeLog: * 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. libgcc/config/libbid/ChangeLog: * 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. gcc/testsuite/ChangeLog: * gcc.dg/torture/convert-dfp-2.c: New test. * gcc.dg/torture/convert-dfp.c: New test. --- libgcc/Makefile.in | 9 +++++--- libgcc/config/libbid/_dd_to_hf.c | 38 +++++++++++++++++++++++++++++++ libgcc/config/libbid/_hf_to_dd.c | 36 +++++++++++++++++++++++++++++ libgcc/config/libbid/_hf_to_sd.c | 36 +++++++++++++++++++++++++++++ libgcc/config/libbid/_hf_to_td.c | 36 +++++++++++++++++++++++++++++ libgcc/config/libbid/_sd_to_hf.c | 38 +++++++++++++++++++++++++++++++ libgcc/config/libbid/_td_to_hf.c | 38 +++++++++++++++++++++++++++++++ libgcc/config/libbid/bid_gcc_intrinsics.h | 30 ++++++++++++++++++++++-- 8 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 libgcc/config/libbid/_dd_to_hf.c create mode 100644 libgcc/config/libbid/_hf_to_dd.c create mode 100644 libgcc/config/libbid/_hf_to_sd.c create mode 100644 libgcc/config/libbid/_hf_to_td.c create mode 100644 libgcc/config/libbid/_sd_to_hf.c create mode 100644 libgcc/config/libbid/_td_to_hf.c (limited to 'libgcc') 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/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 +. */ + +#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/_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 +. */ + +#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 +. */ + +#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 +. */ + +#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 +. */ + +#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/_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 +. */ + +#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/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); -- cgit v1.1 From 5143faee0d0edfd5849c5f54677cb699bf84a5db Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Thu, 5 May 2022 09:25:14 +0100 Subject: libgcc: use __builtin_clz and __builtin_ctz in libbid This patch replaces libbid's implementations of clz and ctz for 32 and 64 bits inputs which used several masks, and switches to the corresponding builtins. This will provide a better implementation, especially on targets with clz/ctz instructions. 2022-05-06 Christophe Lyon libgcc/config/libbid/ChangeLog: * 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. --- libgcc/config/libbid/bid_binarydecimal.c | 51 +++----------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) (limited to 'libgcc') 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 -- cgit v1.1 From 57f2ce6a87802906826501b8843013ff2b50713b Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 21 May 2022 00:16:32 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 14 ++++++++++++ libgcc/config/libbid/ChangeLog | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 5d351a6..cd82a1d 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,17 @@ +2022-05-20 Christophe Lyon + + * 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 + + * config.host: Add t-dfprules to AArch64 targets. + +2022-05-20 Christophe Lyon + + * configure: Regenerate. + 2022-05-13 Sebastian Pop PR target/105162 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 + + * 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 + + * 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 + + * _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 PR tree-optimization/97164 -- cgit v1.1 From 0d344b557604e966dc7f91739881f03e1f221efd Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Thu, 10 Feb 2022 17:42:56 +0000 Subject: aarch64: Fix pac-ret with unusual dwarf in libgcc unwinder [PR104689] The RA_SIGN_STATE dwarf pseudo-register is normally only set using the DW_CFA_AARCH64_negate_ra_state (== DW_CFA_window_save) operation which toggles the return address signedness state (the default state is 0). (It may be set by remember/restore_state CFI too, those save/restore the state of all registers.) However RA_SIGN_STATE can be set directly via DW_CFA_val_expression too. GCC does not generate such CFI but some other compilers reportedly do. Note: the toggle operation must not be mixed with other dwarf register rule CFI within the same CIE and FDE. In libgcc we assume REG_UNSAVED means the RA_STATE is set using toggle operations, otherwise we assume its value is set by other CFI. libgcc/ChangeLog: 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. gcc/testsuite/ChangeLog: PR target/104689 * gcc.target/aarch64/pr104689.c: New test. --- libgcc/config/aarch64/aarch64-unwind.h | 8 +++++++- libgcc/unwind-dw2.c | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'libgcc') 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/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) -- cgit v1.1 From 75c4e4909ae2667f56487434f99c2915b4570794 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Wed, 25 May 2022 14:29:03 +0100 Subject: AArch64: Prioritise init_have_lse_atomics constructor [PR 105708] Increase the priority of the init_have_lse_atomics constructor so it runs before other constructors. This improves chances that rr works when LSE atomics are supported. libgcc/ PR libgcc/105708 * config/aarch64/lse-init.c: Increase constructor priority. --- libgcc/config/aarch64/lse-init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libgcc') 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); -- cgit v1.1 From 3dff965cae6709a5fd1b7b05c51c3c8aba786961 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 26 May 2022 00:16:30 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index cd82a1d..621cf08 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,15 @@ +2022-05-25 Wilco Dijkstra + + PR libgcc/105708 + * config/aarch64/lse-init.c: Increase constructor priority. + +2022-05-25 Szabolcs Nagy + + 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 * Makefile.in (D32PBIT_FUNCS): Add _hf_to_sd and _sd_to_hf. -- cgit v1.1 From 2d546ff69455f7deadab65309de89d19380a8864 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 17 Jan 2022 16:18:56 -0800 Subject: libgcc: Align __EH_FRAME_BEGIN__ to pointer size Aligne __EH_FRAME_BEGIN__ to pointer size since gcc/unwind-dw2-fde.h has /* The first few fields of a CIE. The CIE_id field is 0 for a CIE, to distinguish it from a valid FDE. FDEs are aligned to an addressing unit boundary, but the fields within are unaligned. */ struct dwarf_cie { uword length; sword CIE_id; ubyte version; unsigned char augmentation[]; } __attribute__ ((packed, aligned (__alignof__ (void *)))); /* The first few fields of an FDE. */ struct dwarf_fde { uword length; sword CIE_delta; unsigned char pc_begin[]; } __attribute__ ((packed, aligned (__alignof__ (void *)))); which indicates that CIE/FDE should be aligned at the pointer size. PR libgcc/27576 * crtstuff.c (__EH_FRAME_BEGIN__): Aligned to pointer size. --- libgcc/crtstuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libgcc') 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 */ -- cgit v1.1 From 3164de6ac1b8473e60f6b85e94b15930694c80d7 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 2 Jun 2022 00:16:32 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 621cf08..6e858b5 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2022-06-01 H.J. Lu + + PR libgcc/27576 + * crtstuff.c (__EH_FRAME_BEGIN__): Aligned to pointer size. + 2022-05-25 Wilco Dijkstra PR libgcc/105708 -- cgit v1.1 From 29dc90a580bf45f503ed89eb1dc63b5676db776b Mon Sep 17 00:00:00 2001 From: Takayuki 'January June' Suwa Date: Sun, 29 May 2022 19:57:35 +0900 Subject: xtensa: Add clrsbsi2 insn pattern > (clrsb:m x) > Represents the number of redundant leading sign bits in x, represented > as an integer of mode m, starting at the most significant bit position. This explanation is just what the NSA instruction (not ever emitted before) calculates in Xtensa ISA. gcc/ChangeLog: * config/xtensa/xtensa.md (clrsbsi2): New insn pattern. libgcc/ChangeLog: * config/xtensa/lib1funcs.S (__clrsbsi2): New function. * config/xtensa/t-xtensa (LIB1ASMFUNCS): Add _clrsbsi2. --- libgcc/config/xtensa/lib1funcs.S | 23 +++++++++++++++++++++++ libgcc/config/xtensa/t-xtensa | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'libgcc') 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 \ -- cgit v1.1 From e3bba42fb5d64d2b49a9cd3511f8f57e36d46dfe Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 10 Jun 2022 00:16:43 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 6e858b5..88c860b 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2022-06-09 Takayuki 'January June' Suwa + + * config/xtensa/lib1funcs.S (__clrsbsi2): New function. + * config/xtensa/t-xtensa (LIB1ASMFUNCS): Add _clrsbsi2. + 2022-06-01 H.J. Lu PR libgcc/27576 -- cgit v1.1 From fc259b522c0f8b7bbca8e7adcd3da63330094a34 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sat, 25 Jun 2022 12:36:55 -0400 Subject: Remove long deprecated tilegx and tilepro ports / * MAINTAINERS: Remove tilegx and tilepro entries. * configure.ac: Remove tilegx and tilepro stanzas. * configure: Rebuilt. contrib/ * config-list.mk: Remove tilegx and tilepro entries. * gcc_update: Remove tilegx and tilepro entries. gcc/ * common/config/tilegx/tilegx-common.cc: Removed. * common/config/tilepro/tilepro-common.cc: Removed. * config.gcc: Remove tilegx and tilepro entries. * config/tilegx/constraints.md: Removed. * config/tilegx/feedback.h: Removed. * config/tilegx/linux.h: Removed. * config/tilegx/mul-tables.cc: Removed. * config/tilegx/predicates.md: Removed. * config/tilegx/sync.md: Removed. * config/tilegx/t-tilegx: Removed. * config/tilegx/tilegx-builtins.h: Removed. * config/tilegx/tilegx-c.cc: Removed. * config/tilegx/tilegx-generic.md: Removed. * config/tilegx/tilegx-modes.def: Removed. * config/tilegx/tilegx-multiply.h: Removed. * config/tilegx/tilegx-opts.h: Removed. * config/tilegx/tilegx-protos.h: Removed. * config/tilegx/tilegx.cc: Removed. * config/tilegx/tilegx.h: Removed. * config/tilegx/tilegx.md: Removed. * config/tilegx/tilegx.opt: Removed. * config/tilepro/constraints.md: Removed. * config/tilepro/feedback.h: Removed. * config/tilepro/gen-mul-tables.cc: Removed. * config/tilepro/linux.h: Removed. * config/tilepro/mul-tables.cc: Removed. * config/tilepro/predicates.md: Removed. * config/tilepro/t-tilepro: Removed. * config/tilepro/tilepro-builtins.h: Removed. * config/tilepro/tilepro-c.cc: Removed. * config/tilepro/tilepro-generic.md: Removed. * config/tilepro/tilepro-modes.def: Removed. * config/tilepro/tilepro-multiply.h: Removed. * config/tilepro/tilepro-protos.h: Removed. * config/tilepro/tilepro.cc: Removed. * config/tilepro/tilepro.h: Removed. * config/tilepro/tilepro.md: Removed. * config/tilepro/tilepro.opt: Removed. * configure.ac: Remove tilegx and tilepro entries. * configure: Rebuilt. * doc/extend.texi: Remove tilegx and tilepro entries. * doc/install.texi: Remove tilegx and tilepro entries. * doc/invoke.texi: Remove tilegx and tilepro entries. * doc/md.texi: Remove tilegx and tilepro entries. gcc/testsuite/ * gcc.dg/lower-subreg-1.c: Remove tilegx and tilepro entries. * gcc.misc-tests/linkage.exp: Remove tilegx and tilepro entries. libgcc/ * 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. --- libgcc/config.host | 17 -- libgcc/config/tilegx/sfp-machine.h | 5 - libgcc/config/tilegx/sfp-machine32.h | 68 ------ libgcc/config/tilegx/sfp-machine64.h | 68 ------ libgcc/config/tilegx/t-crtstuff | 8 - libgcc/config/tilegx/t-softfp | 1 - libgcc/config/tilegx/t-tilegx | 26 --- libgcc/config/tilepro/atomic.c | 397 ------------------------------- libgcc/config/tilepro/atomic.h | 437 ----------------------------------- libgcc/config/tilepro/linux-unwind.h | 99 -------- libgcc/config/tilepro/sfp-machine.h | 59 ----- libgcc/config/tilepro/softdivide.c | 353 ---------------------------- libgcc/config/tilepro/softmpy.S | 94 -------- libgcc/config/tilepro/t-crtstuff | 4 - libgcc/config/tilepro/t-tilepro | 33 --- 15 files changed, 1669 deletions(-) delete mode 100644 libgcc/config/tilegx/sfp-machine.h delete mode 100644 libgcc/config/tilegx/sfp-machine32.h delete mode 100644 libgcc/config/tilegx/sfp-machine64.h delete mode 100644 libgcc/config/tilegx/t-crtstuff delete mode 100644 libgcc/config/tilegx/t-softfp delete mode 100644 libgcc/config/tilegx/t-tilegx delete mode 100644 libgcc/config/tilepro/atomic.c delete mode 100644 libgcc/config/tilepro/atomic.h delete mode 100644 libgcc/config/tilepro/linux-unwind.h delete mode 100644 libgcc/config/tilepro/sfp-machine.h delete mode 100644 libgcc/config/tilepro/softdivide.c delete mode 100644 libgcc/config/tilepro/softmpy.S delete mode 100644 libgcc/config/tilepro/t-crtstuff delete mode 100644 libgcc/config/tilepro/t-tilepro (limited to 'libgcc') diff --git a/libgcc/config.host b/libgcc/config.host index 927d34a..b2a0a8e 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -212,12 +212,6 @@ s390*-*-*) sh[123456789lbe]*-*-*) cpu_type=sh ;; -tilegx*-*-*) - cpu_type=tilegx - ;; -tilepro*-*-*) - cpu_type=tilepro - ;; v850*-*-*) cpu_type=v850 ;; @@ -1487,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/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-softfp b/libgcc/config/tilegx/t-softfp deleted file mode 100644 index a1e3513..0000000 --- a/libgcc/config/tilegx/t-softfp +++ /dev/null @@ -1 +0,0 @@ -softfp_int_modes += ti 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 - . */ - -#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 - . */ - - -/* 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 -. */ - -#ifndef inhibit_libc - -#include -#include -#include -#include - -/* 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 - . */ - -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 - . */ - -/* 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 -- cgit v1.1 From 87509781849b6a64d1c049599d75a06c0fa68d01 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sun, 26 Jun 2022 00:16:33 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 88c860b..f4591e1 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,21 @@ +2022-06-25 Jeff Law + + * 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 * config/xtensa/lib1funcs.S (__clrsbsi2): New function. -- cgit v1.1 From c8697735abaca3b3dfe8ae4188a086d1fd7048eb Mon Sep 17 00:00:00 2001 From: Claudiu Zissulescu Date: Mon, 18 Jul 2022 14:54:38 +0300 Subject: libgcc/arc: Update udivmodsi4 and make the lib safe for rf16 The ARC soft udivmodsi4 algorithm and as well as using umodsi3 for reduced register set configurations are wrong. libgcc/ * config/arc/lib2funcs.c (udivmodsi4): Update AND mask. * config/arc/lib1funcs.S (umodsi3): Don't use it for RF16 configurations. --- libgcc/config/arc/lib1funcs.S | 2 ++ libgcc/config/arc/lib2funcs.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'libgcc') 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; -- cgit v1.1 From 79fb1124c8c31da3ca70ee3a07bf15f3d2d87ab7 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 19 Jul 2022 00:16:32 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index f4591e1..fcae8df 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2022-07-18 Claudiu Zissulescu + + * 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 * config.host: Removed tilegx and tilepro entries. -- cgit v1.1