Commit graph

1105 commits

Author SHA1 Message Date
Jiaxun Yang
05c4e3ecb5 [PATCH v2] sh: libgcc: Implement fenv rouding and exceptions for soft-fp [PR118257]
Implement fenv rouding and exceptions for soft-fp, as per SuperH
arch specification.

No new tests required, as it's already covered by many torture tests
with fenv_exceptions.

	PR target/118257

libgcc/ChangeLog:

	* config/sh/sfp-machine.h (_FPU_GETCW): Implement with builtin.
	(_FPU_SETCW): Likewise.
	(FP_EX_ENABLE_SHIFT): Derive from arch spec.
	(FP_EX_CAUSE_SHIFT): Likewise.
	(FP_RND_MASK): Likewise.
	(FP_EX_INVALID): Likewise.
	(FP_EX_DIVZERO): Likewise.
	(FP_EX_ALL): Likewise.
	(FP_EX_OVERFLOW): Likewise.
	(FP_EX_UNDERFLOW): Likewise.
	(FP_EX_INEXACT): Likewise.
	(_FP_DECL_EX): Declear default FCSR value.
	(FP_RND_NEAREST): Derive from arch spec.
	(FP_RND_ZERO): Likewise.
	(FP_INIT_ROUNDMODE): Likewise.
	(FP_ROUNDMODE): Likewise.
	(FP_TRAPPING_EXCEPTIONS): Likewise.
	(FP_HANDLE_EXCEPTIONS): Implement with _FPU_SETCW.
2025-04-19 08:12:07 -06:00
Jiaxun Yang
2a643f55f5 [PATCH v2] sh: Correct NaN signalling bit and propagation rules [PR111814]
As per architecture, SuperH has a reversed NaN signalling bit
vs IEEE754-2008, it also has a NaN propgation rule similar to
MIPS style.

Use mips style float format and mode for all float types, and
correct sfp-machine header accordingly.

	PR target/111814

gcc/ChangeLog:

	* config/sh/sh-modes.def (RESET_FLOAT_FORMAT): Use mips format.
	(FLOAT_MODE): Use mips mode.

libgcc/ChangeLog:

	* config/sh/sfp-machine.h (_FP_NANFRAC_B): Reverse signaling bit.
	(_FP_NANFRAC_H): Likewise.
	(_FP_NANFRAC_S): Likewise.
	(_FP_NANFRAC_D): Likewise.
	(_FP_NANFRAC_Q): Likewise.
	(_FP_KEEPNANFRACP): Enable for target.
	(_FP_QNANNEGATEDP): Enable for target.
	(_FP_CHOOSENAN): Port from MIPS.

gcc/testsuite/ChangeLog:

	* gcc.target/sh/pr111814.c: New test.
2025-04-19 08:07:58 -06:00
Thomas Schwinge
fe283dba77 GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]
With '-mfake-exceptions' enabled, the user-visible behavior in presence of
exception handling constructs changes such that the compile-time
'sorry, unimplemented: exception handling not supported' is skipped, code
generation proceeds, and instead, exception handling constructs 'abort' at
run time.  (..., or don't, if they're in dead code.)

	PR target/118794
	gcc/
	* config/gcn/gcn.opt (-mfake-exceptions): Support.
	* config/nvptx/nvptx.opt (-mfake-exceptions): Likewise.
	* config/gcn/gcn.md (define_expand "exception_receiver"): Use it.
	* config/nvptx/nvptx.md (define_expand "exception_receiver"):
	Likewise.
	* config/gcn/mkoffload.cc (main): Set it.
	* config/nvptx/mkoffload.cc (main): Likewise.
	* config/nvptx/nvptx.cc (nvptx_assemble_integer)
	<in_section == exception_section>: Special handling for
	'SYMBOL_REF's.
	* except.cc (expand_dw2_landing_pad_for_region): Don't generate
	bogus code for (default)
	'#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM'.
	libgcc/
	* config/gcn/unwind-gcn.c (_Unwind_Resume): New.
	* config/nvptx/unwind-nvptx.c (_Unwind_Resume): Likewise.
	gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-2.C: Set
	'-mno-fake-exceptions'.
	* g++.target/gcn/exceptions-pr118794-1.C: Likewise.
	* g++.target/gcn/exceptions-throw-2.C: Likewise.
	* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
	* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
	* g++.target/nvptx/exceptions-throw-2.C: Likewise.
	* g++.target/gcn/exceptions-bad_cast-2_-mfake-exceptions.C: New.
	* g++.target/gcn/exceptions-pr118794-1_-mfake-exceptions.C:
	Likewise.
	* g++.target/gcn/exceptions-throw-2_-mfake-exceptions.C: Likewise.
	* g++.target/nvptx/exceptions-bad_cast-2_-mfake-exceptions.C:
	Likewise.
	* g++.target/nvptx/exceptions-pr118794-1_-mfake-exceptions.C:
	Likewise.
	* g++.target/nvptx/exceptions-throw-2_-mfake-exceptions.C:
	Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C:
	Set '-foffload-options=-mno-fake-exceptions'.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Adjust.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2-O0.C: New.
2025-04-14 23:56:05 +02:00
Eric Botcazou
5c82694319 Fix implementation of Win32 thread model for C++ modules
This applies the same magic to config/i386/gthr-win32.h that was applied
to gthr-posix.h (https://gcc.gnu.org/cgit/gcc/commit/?id=6a4d1c374eed17)
for the sake of C++ modules.

libgcc/
	PR target/119673
	* config/i386/gthr-win32.h (__GTHREAD_ALWAYS_INLINE): New macro.
	(__GTHREAD_INLINE): Likewise.
	(__GTHR_W32_InterlockedCompareExchange): Delete.
	(__gthread_active_p): Mark as __GTHREAD_INLINE instead of
	static inline.
	(__gthread_create): Likewise.
	(__gthread_join): Likewise.
	(__gthread_self): Likewise.
	(__gthread_detach): Likewise.
	(__gthread_equal): Likewise.
	(__gthread_yield): Likewise.
	(__gthread_once): Likewise.
	(__gthread_key_create): Likewise.
	(__gthread_key_delete): Likewise.
	(__gthread_getspecific): Likewise.
	(__gthread_setspecific): Likewise.
	(__gthread_mutex_init_function): Likewise.
	(__gthread_mutex_destroy): Likewise.
	(__gthread_mutex_lock): Likewise.
	(__gthread_mutex_trylock): Likewise.
	(__gthread_mutex_timedlock): Likewise.
	(__gthread_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_trylock): Likewise.
	(__gthread_cond_init_function): Likewise.
	(__gthread_cond_broadcast): Likewise.
	(__gthread_cond_signal): Likewise.
	(__gthread_cond_wait): Likewise.
	(__gthread_cond_timedwait): Likewise.
	(__GTHREAD_WIN32_INLINE): Likewise.
	(__GTHREAD_WIN32_COND_INLINE): Likewise.
	(__gthread_recursive_mutex_init_function): Likewise.
	(__gthread_recursive_mutex_destroy): Likewise.
	(__gthread_recursive_mutex_lock): Likewise.
	(__gthread_recursive_mutex_unlock): Likewise.
	(__gthread_cond_destroy): Likewise.
	(__gthread_cond_wait_recursive): Likewise.
2025-04-14 09:37:51 +02:00
Thomas Schwinge
54ab0f6785 GCN, nvptx: Define '_Unwind_RaiseException', '_Unwind_Resume_or_Rethrow'
This resolves GCN:

    ld: error: undefined symbol: _Unwind_RaiseException
    >>> referenced by eh_throw.cc:93 ([...]/source-gcc/libstdc++-v3/libsupc++/eh_throw.cc:93)
    >>>               eh_throw.o:(__cxa_throw) in archive /srv/data/tschwinge/amd-instinct2/gcc/build/submit-light-target_gcn/build-gcc/amdgcn-amdhsa/gfx908/libstdc++-v3/src/.libs/libstdc++.a
    [...]
    collect2: error: ld returned 1 exit status

..., and/or:

    ld: error: undefined symbol: _Unwind_Resume_or_Rethrow
    >>> referenced by eh_throw.cc:129 ([...]/source-gcc/libstdc++-v3/libsupc++/eh_throw.cc:129)
    >>>               eh_throw.o:(__cxa_rethrow) in archive /srv/data/tschwinge/amd-instinct2/gcc/build/submit-light-target_gcn/build-gcc/amdgcn-amdhsa/gfx908/libstdc++-v3/src/.libs/libstdc++.a
    [...]
    collect2: error: ld returned 1 exit status

..., and nvptx:

    unresolved symbol _Unwind_RaiseException
    collect2: error: ld returned 1 exit status

..., or:

    unresolved symbol _Unwind_Resume_or_Rethrow
    collect2: error: ld returned 1 exit status

For both GCN, nvptx, this each progresses ~25 'check-gcc-c++',
and ~10 'check-target-libstdc++-v3' test cases:

    [-FAIL:-]{+PASS:+} [...] (test for excess errors)

..., with (if applicable, for most of them):

    [-UNRESOLVED:-]{+PASS:+} [...] [-compilation failed to produce executable-]{+execution test+}

..., or some 'FAIL: [...] execution test' where these test cases now FAIL when
attempting to use these interfaces, or, if applicable, FAIL due to run-time
'GCC/nvptx: sorry, unimplemented: dynamic stack allocation not supported'.

	libgcc/
	* config/gcn/unwind-gcn.c (_Unwind_RaiseException)
	(_Unwind_Resume_or_Rethrow): New.
	* config/nvptx/unwind-nvptx.c (_Unwind_RaiseException)
	(_Unwind_Resume_or_Rethrow): Likewise.
2025-04-08 12:17:02 +02:00
Thomas Schwinge
815abd6835 GCN, nvptx: Define '_Unwind_DeleteException'
This resolves GCN:

    ld: error: undefined symbol: _Unwind_DeleteException
    >>> referenced by eh_catch.cc:109 ([...]/source-gcc/libstdc++-v3/libsupc++/eh_catch.cc:109)
    >>>               eh_catch.o:(__cxa_end_catch) in archive [...]/build-gcc/amdgcn-amdhsa/libstdc++-v3/src/.libs/libstdc++.a
    [...]
    collect2: error: ld returned 1 exit status

..., and nvptx:

    unresolved symbol _Unwind_DeleteException
    collect2: error: ld returned 1 exit status

For both GCN, nvptx, this each progresses ~100 'check-gcc-c++',
and ~500 'check-target-libstdc++-v3' test cases:

    [-FAIL:-]{+PASS:+} [...] (test for excess errors)

..., with (if applicable, for most of them):

    [-UNRESOLVED:-]{+PASS:+} [...] [-compilation failed to produce executable-]{+execution test+}

..., or just a few 'FAIL: [...] execution test' where these test cases now
FAIL for unrelated reasons, or, if applicable, FAIL due to run-time
'GCC/nvptx: sorry, unimplemented: dynamic stack allocation not supported'.

	libgcc/
	* config/gcn/unwind-gcn.c (_Unwind_DeleteException): New.
	* config/nvptx/unwind-nvptx.c (_Unwind_DeleteException): Likewise.
2025-04-08 12:17:02 +02:00
Thomas Schwinge
199f1abeef nvptx: Support '-mfake-ptx-alloca': defer failure to run-time 'alloca' usage
Follow-up to commit 1146410c0f
"nvptx: Support '-mfake-ptx-alloca'".  '-mfake-ptx-alloca' is applicable only
for configurations where PTX 'alloca' is not supported, where target libraries
are built with it enabled (that is, libstdc++, libgfortran).

This change progresses:

    [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++17 (test for excess errors)
    [-UNRESOLVED:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++17 [-compilation failed to produce executable-]{+execution test+}
    [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++26 (test for excess errors)
    [-UNRESOLVED:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++26 [-compilation failed to produce executable-]{+execution test+}
    UNSUPPORTED: g++.dg/tree-ssa/pr20458.C  -std=gnu++98: exception handling not supported

..., and "enables" a few test cases:

    FAIL: g++.old-deja/g++.other/sibcall1.C  -std=gnu++17 (test for excess errors)
    [Etc.]

    FAIL: g++.old-deja/g++.other/unchanging1.C  -std=gnu++17 (test for excess errors)
    [Etc.]

..., which now (unrelatedly to 'alloca', and in the same way as configurations
where PTX 'alloca' is supported) FAIL due to:

    unresolved symbol _Unwind_DeleteException
    collect2: error: ld returned 1 exit status

Most importantly, it progresses ~830 libstdc++ test cases:

    [-FAIL:-]{+PASS:+} [...] (test for excess errors)

..., with (if applicable, for most of them):

    [-UNRESOLVED:-]{+PASS:+} [...] [-compilation failed to produce executable-]{+execution test+}

..., or just a few 'FAIL: [...] execution test' where these test cases also
FAIL in configurations where PTX 'alloca' is supported, or ~120 instances of
'FAIL: [...]  execution test' due to run-time
'GCC/nvptx: sorry, unimplemented: dynamic stack allocation not supported'.

This change also resolves the cases noted in
commit bac2d8a246
"nvptx: Build libgfortran with '-mfake-ptx-alloca' [PR107635]":

| With '-mfake-ptx-alloca', libgfortran again succeeds to build, and compared
| to before, we've got only a small number of regressions due to nvptx 'ld'
| complaining about 'unresolved symbol __GCC_nvptx__PTX_alloca_not_supported':
|
|     [-PASS:-]{+FAIL:+} gfortran.dg/coarray/codimension_2.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)

    [-FAIL:-]{+PASS:+} gfortran.dg/coarray/codimension_2.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)

|     [-PASS:-]{+FAIL:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
|     [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-FAIL:-]{+PASS:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-UNRESOLVED:-]{+PASS:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single [-compilation failed to produce executable-]{+execution test+}

|     [-PASS:-]{+FAIL:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
|     [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-FAIL:-]{+PASS:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-UNRESOLVED:-]{+PASS:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single [-compilation failed to produce executable-]{+execution test+}

|     [-PASS:-]{+FAIL:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
|     [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-FAIL:-]{+PASS:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-UNRESOLVED:-]{+PASS:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single [-compilation failed to produce executable-]{+execution test+}

|     [-PASS:-]{+FAIL:+} gfortran.dg/coarray_43.f90   -O  (test for excess errors)

    [-FAIL:-]{+PASS:+} gfortran.dg/coarray_43.f90   -O  (test for excess errors)

..., and further progresses:

    [-FAIL:-]{+PASS:+} gfortran.dg/coarray_lib_comm_1.f90   -O0  (test for excess errors)
    [-UNRESOLVED:-]{+FAIL:+} gfortran.dg/coarray_lib_comm_1.f90   -O0  [-compilation failed to produce executable-]{+execution test+}
    [Etc.]

..., which now (unrelatedly to 'alloca', and in the same way as configurations
where PTX 'alloca' is supported) FAILs due to:

    error   : Prototype doesn't match for '_gfortran_caf_transfer_between_remotes' in 'input file 9 at offset 159897', first defined in 'input file 9 at offset 159897'
    error   : Prototype doesn't match for '_gfortran_caf_stop_numeric' in 'input file 9 at offset 159897', first defined in 'input file 9 at offset 159897'
    nvptx-run: cuLinkAddData failed: device kernel image is invalid (CUDA_ERROR_INVALID_SOURCE, 300)

	gcc/
	* config/nvptx/nvptx.opt (-mfake-ptx-alloca): Update.
	gcc/testsuite/
	* gcc.target/nvptx/alloca-2-O0_-mfake-ptx-alloca.c: Adjust.
	libgcc/
	* config/nvptx/alloca.c: New.
	* config/nvptx/t-nvptx (LIB2ADD): Add it.
2025-04-07 15:57:02 +02:00
Georg-Johann Lay
29cc92348e AVRrc: Tweak __[u]mulhisi3.
When MUL is not available, then the __umulhisi3 and __mulhisi3
functions can use __mulhisi3_helper.  This improves code size,
stack footprint and runtime on AVRrc.

libgcc/
	* config/avr/lib1funcs.S (__mulhisi3, __umulhisi3): Use
	__mulhisi3_helper for better performance on AVRrc.
2025-04-07 12:50:04 +02:00
Georg-Johann Lay
939fa28d26 AVRrc: Support 8-bit and 16-bit fixed-point arith in libgcc.
With some minor changes, 8-bit and 16-bit fixed-point operations
can be supported on the reduced core.

libgcc/
	* config/avr/t-avr (LIB1ASMFUNCS): Add (and remove from
	FUNCS_notiny): _mulhisi3, _umulhisi3, _mulqq3, _mulhq3, _muluhq3,
	_mulha3, _muluha3 _muluha3_round, _usmuluha3, _ssmulha3,
	_divqq3, _udivuqq3, _divqq_helper, _divhq3, _udivuhq3.
	_divha3 _udivuha3, _ssneg_2, _ssabs_1, _ssabs_2,
	_mask1, _ret, _roundqq3 _rounduqq3,
	_round_s2, _round_u2, _round_2_const, _addmask_2.
	* config/avr/lib1funcs.S (__umulhisi3, __mulhisi3): Make
	work on AVRrc.
	* config/avr/lib1funcs-fixed.S: Build 8-bit and 16-bit functions
	on AVRrc, too.
2025-04-06 17:21:01 +02:00
Georg-Johann Lay
6753df43a0 AVR: Speed up __umulhisi3 for small devices with MUL.
__umulhisi3 had an "rcall 1f" to save 6 bytes, which is an unreasonable
size gain vs. cycle cost.  Just use the same code on all devices with MUL,
irrespective of program memory size.

libgcc/
	* config/avr/lib1funcs.S (__umulhisi3) [Have MUL]: Reduce call
	depth by 1.
2025-04-05 12:15:09 +02:00
GCC Administrator
d8d6a61d1c Daily bump. 2025-03-23 00:17:38 +00:00
Georg-Johann Lay
8736edca77 AVR: libgcc: Properly exclude object files for AVRrc.
There are many objects / functions that are not available on AVRrc,
the reduced core.  The old way to exclude some objects for AVRrc
did not work properly since it tested for MULTIFLAGS.
This does not work for, say MULTIFLAGS = "-mmcu=avrtiny -mdouble=64".
This patch uses $(findstring avrtiny,$(MULTIDIR)) in the condition.

libgcc/
	* config/avr/t-avr (LIB1ASMFUNCS, LIB2FUNCS_EXCLUDE):
	Properly handle avrtiny.
libgcc/config/avr/libf7/
	* t-libf7 (libgcc-objects): Only add objects when building
	for non-AVRrc.
2025-03-22 17:48:17 +01:00
Thomas Schwinge
fad9d58e05 Revert "GCN, nvptx: Basic '__cxa_guard_{acquire,abort,release}' for C++ static local variables support"
GCN, nvptx now has libstdc++-v3/libsupc++ proper.

This reverts commit c0bf7ea189.
2025-03-14 13:21:18 +01:00
Wilco Dijkstra
6e47e6d488 libgcc: Remove PREDRES and LS64 from AArch64 cpuinfo
Change AArch64 cpuinfo to follow the latest updates to the FMV spec [1]:
Remove FEAT_PREDRES and FEAT_LS64*.  Preserve the ordering in enum CPUFeatures.

[1] https://github.com/ARM-software/acle/pull/382

gcc:
	* common/config/aarch64/cpuinfo.h: Remove FEAT_PREDRES and FEAT_LS64*.
	* config/aarch64/aarch64-option-extensions.def: Remove FMV support
	for PREDRES.

libgcc:
	* config/aarch64/cpuinfo.c (__init_cpu_features_constructor):
	Remove FEAT_PREDRES and FEAT_LS64* support.
2025-03-13 13:30:31 +00:00
Jan Dubiec
898f22d158 [PATCH] H8/300, libgcc: PR target/114222 For HImode call internal ffs() implementation instead of an external one
When INT_TYPE_SIZE < BITS_PER_WORD gcc emits a call to an external ffs()
implementation instead of a call to "__builtin_ffs()" – see function
init_optabs() in <SRCROOT>/gcc/optabs-libfuncs.cc. External ffs()
(which is usually the one from newlib) in turn calls __builtin_ffs()
what causes infinite recursion and stack overflow. This patch overrides
default gcc bahaviour for H8/300H (and newer) and provides a generic
ffs() implementation for HImode.

	PR target/114222
gcc/ChangeLog:

	* config/h8300/h8300.cc (h8300_init_libfuncs): For HImode override
	calls to external ffs() (from newlib) with calls to __ffshi2() from
	libgcc. The implementation of ffs() in newlib calls __builtin_ffs()
	what causes infinite recursion and finally a stack overflow.

libgcc/ChangeLog:

	* config/h8300/t-h8300: Add __ffshi2().
	* config/h8300/ffshi2.c: New file.
2025-03-01 08:21:16 -07:00
Roman Kagan
e129b8d768 libgcc: i386/linux-unwind.h: always rely on sys/ucontext.h
When gcc is built for x86_64-linux-musl target, stack unwinding from
within signal handler stops at the innermost signal frame.  The reason
for this behaviro is that the signal trampoline is not accompanied with
appropiate CFI directives, and the fallback path in libgcc to recognize
it by the code sequence is only enabled for glibc except 2.0.  The
latter is motivated by the lack of sys/ucontext.h in that glibc version.

Given that all relevant libc-s ship sys/ucontext.h for over a decade,
and that other arches aren't shy of unconditionally using it, follow
suit and remove the preprocessor condition, too.

libgcc/ChangeLog:

	* config/i386/linux-unwind.h: Remove preprocessor
	condition to enable fallback path for all libc-s.

Signed-off-by: Roman Kagan <rkagan@amazon.de>
2025-02-18 20:35:42 +01:00
Lulu Cheng
ae14d7d04d LoongArch: Fix the issue of function jump out of range caused by crtbeginS.o [PR118844].
Due to the presence of R_LARCH_B26 in
/usr/lib/gcc/loongarch64-linux-gnu/14/crtbeginS.o, its addressing
range is [PC-128MiB, PC+128MiB-4]. This means that when the code
segment size exceeds 128MB, linking with lld will definitely fail
(ld will not fail because the order of the two is different).

The linking order:
  lld: crtbeginS.o + .text + .plt
  ld : .plt + crtbeginS.o + .text

To solve this issue, add '-mcmodel=extreme' when compiling crtbeginS.o.

	PR target/118844

libgcc/ChangeLog:

	* config/loongarch/t-crtstuff: Add '-mcmodel=extreme'
	to CRTSTUFF_T_CFLAGS_S.
2025-02-17 10:15:39 +08:00
Yangyu Chen
2605daa6b8 RISC-V: Drop __riscv_vendor_feature_bits
As discussed from RISC-V C-API PR #101 [1], As discussed in #96, current
interface is insufficient to support some cases, like a vendor buying a
CPU IP from the upstream vendor but using their own mvendorid and custom
features from the upstream vendor. In this case, we might need to add
these extensions for each downstream vendor many times. Thus, making
__riscv_vendor_feature_bits guarded by mvendorid is not a good idea. So,
drop __riscv_vendor_feature_bits for now, and we should have time to
discuss a better solution.

[1] https://github.com/riscv-non-isa/riscv-c-api-doc/pull/101

Signed-off-by: Yangyu Chen <cyy@cyyself.name>

gcc/ChangeLog:

	* config/riscv/riscv-feature-bits.h (RISCV_VENDOR_FEATURE_BITS_LENGTH): Drop.
	(struct riscv_vendor_feature_bits): Drop.

libgcc/ChangeLog:

	* config/riscv/feature_bits.c (RISCV_VENDOR_FEATURE_BITS_LENGTH): Drop.
	(__init_riscv_features_bits_linux): Drop.
2025-02-11 18:40:41 -07:00
Peter Bergner
c9b8a8fc55 rs6000: Add cast to avoid pointer to integer comparison warning [PR117674]
2025-02-07  Peter Bergner  <bergner@linux.ibm.com>

libgcc/
	PR target/117674
	* config/rs6000/linux-unwind.h (ppc_backchain_fallback): Add cast to
	avoid comparison between pointer and integer warning.
2025-02-07 13:40:15 -06:00
Georg-Johann Lay
1e819a997d AVR: Provide built-ins for strlen where the string lives in some AS.
This patch adds built-in functions __builtin_avr_strlen_flash,
__builtin_avr_strlen_flashx and __builtin_avr_strlen_memx.
Purpose is that higher-level functions can use __builtin_constant_p
on strlen without raising a diagnostic due to -Waddr-space-convert.

gcc/
	* config/avr/builtins.def (STRLEN_FLASH, STRLEN_FLASHX)
	(STRLEN_MEMX): New DEF_BUILTIN's.
	* config/avr/avr.cc (avr_ftype_strlen): New static function.
	(avr_builtin_supported_p): New built-ins are not for AVR_TINY.
	(avr_init_builtins) <strlen_flash_node, strlen_flashx_node,
	strlen_memx_node>: Provide new fntypes.
	(avr_fold_builtin) [AVR_BUILTIN_STRLEN_FLASH]
	[AVR_BUILTIN_STRLEN_FLASHX, AVR_BUILTIN_STRLEN_MEMX]: Fold if
	possible.
	* doc/extend.texi (AVR Built-in Functions): Document
	__builtin_avr_strlen_flash, __builtin_avr_strlen_flashx,
	__builtin_avr_strlen_memx.
libgcc/
	* config/avr/t-avr (LIB1ASMFUNCS): Add _strlen_memx.
	* config/avr/lib1funcs.S <L_strlen_memx, __strlen_memx>: Implement.
2025-01-30 20:43:14 +01:00
Richard Earnshaw
0204dcf930 arm: libgcc: make -spec=sync-*.specs compatible with LTO [PR118642]
The arm-none-eabi port provides some alternative implementations of
__sync_synchronize for different implementations of the architecture.
These can be selected using one of -specs=sync-{none,dmb,cp15dmb}.specs.

These specs fragments fail, however, when LTO is used because they
unconditionally add a --defsym=__sync_synchronize=<implementation> to
the linker arguments and that fails if libgcc is not added to the list
of libraries.

Fix this by only adding the defsym if libgcc will be passed to the
linker.

libgcc/

	PR target/118642
	* config/arm/sync-none.specs (link): Only add the defsym if
	libgcc will be used.
	* config/arm/sync-dmb.specs: Likewise.
	* config/arm/sync-cp15dmb.specs: Likewise.
2025-01-28 16:23:06 +00:00
Monk Chiang
2b3efe793e RISC-V: Add .note.gnu.property for ZICFILP and ZICFISS ISA extension
gcc/ChangeLog:
	* config/riscv/riscv.cc
	(riscv_file_end): Add .note.gnu.property.

libgcc/ChangeLog:
	* config/riscv/crti.S: Add lpad instructions.
	* config/riscv/crtn.S: Likewise.
	* config/riscv/save-restore.S: Likewise.
	* config/riscv/riscv-asm.h: Add GNU_PROPERTY for ZICFILP,
	ZICFISS.

	Co-Developed-by: Jesse Huang <jesse.huang@sifive.com>
2025-01-17 10:54:44 +08:00
Monk Chiang
dc76aa0e4d RISC-V: Add Zicfiss ISA extension.
This patch is implemented according to the RISC-V CFI specification.
It supports the generation of shadow stack instructions in the prologue,
epilogue, non-local gotos, and unwinding.

RISC-V CFI SPEC: https://github.com/riscv/riscv-cfi

gcc/ChangeLog:
	* common/config/riscv/riscv-common.cc: Add ZICFISS ISA string.
	* config/riscv/predicates.md: New predicate x1x5_operand.
	* config/riscv/riscv.cc
	(riscv_expand_prologue): Insert shadow stack instructions.
	(riscv_expand_epilogue): Likewise.
	(riscv_for_each_saved_reg): Assign t0 or ra register for
	sspopchk instruction.
	(need_shadow_stack_push_pop_p): New function. Omit shadow
	stack operation on leaf function.
	* config/riscv/riscv.h
	(need_shadow_stack_push_pop_p): Define.
	* config/riscv/riscv.md: Add shadow stack patterns.
	(save_stack_nonlocal): Add shadow stack instructions for setjump.
	(restore_stack_nonlocal): Add shadow stack instructions for longjump.
	* config/riscv/riscv.opt (TARGET_ZICFISS): Define.

libgcc/ChangeLog:
	* config/riscv/linux-unwind.h: Include shadow-stack-unwind.h.
	* config/riscv/shadow-stack-unwind.h
	(_Unwind_Frames_Extra): Define.
	(_Unwind_Frames_Increment): Define.

gcc/testsuite/ChangeLog:
	* gcc.target/riscv/ssp-1.c: New test.
	* gcc.target/riscv/ssp-2.c: New test.

	Co-Developed-by: Greg McGary <gkm@rivosinc.com>,
			Kito Cheng <kito.cheng@gmail.com>
2025-01-17 10:49:16 +08:00
Keith Packard
0115ef57ef [PATCH] libgcc/m68k: More fixes for soft float
Fix __extenddfxf2:

  * Remove bogus denorm handling block which would never execute --
    the converted exp value is always positive as EXCESSX > EXCESSD.

  * Compute the whole significand in dl instead of doing part of it in
    ldl.

    * Mask off exponent from dl.l.upper so the denorm shift test
      works.

    * Insert the hidden one bit into dl.l.upper as needed.

Fix __truncxfdf2 denorm handling. All that is required is to shift the
significand right by the correct amount; it already has all of the
necessary bits set including the explicit one. Compute the shift
amount, then perform the wide shift across both elements of the
significand.

Fix __fixxfsi:

  * The value  was off by a factor of two as the significand contains
    32 bits, not 31 so we need to shift by one more than the equivalent
    code in __fixdfsi.

  * Simplify the code having realized that the lower 32 bits of the
    significand can never appear in the results.

Return positive qNaN instead of negative. For floats, qNaN is 0x7fff_ffff. For
doubles, qNaN is 0x7fff_ffff_ffff_ffff.

Return correctly signed zero on float and double divide underflow. This means
that Ld$underflow now expects d7 to contain the sign bit, just like the other
return paths.

libgcc/
	* config/m68k/fpgnulib.c (extenddfxf2): Simplify code by removing code
	that should never execute.  Fix denorm shift test and insert hidden bit
	as needed.
	(__truncxfdf2): Properly compue and shift the significant right.
	* config/m68k/lb1sf68.S (__fixxfsi): Correct shift counts and simplify.
	(QUIET_NAN): Make it a positive quiet NaN and fix return values to inject
	sign properly.
2025-01-07 14:54:11 -07:00
Stafford Horne
803808b4ad or1k: add .note.GNU-stack section on linux
In the OpenRISC build we get the following warning:

    ld: warning: __modsi3_s.o: missing .note.GNU-stack section implies executable stack
    ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Fix this by adding a .note.GNU-stack to indicate the stack does not need to be
executable for the lib1funcs.

Note, this is also needed for the upcoming glibc 2.41.

libgcc/
	* config/or1k/lib1funcs.S: Add .note.GNU-stack section on linux.
2025-01-06 17:20:43 +00:00
Jakub Jelinek
6441eb6dc0 Update copyright years. 2025-01-02 11:59:57 +01:00
Jakub Jelinek
9cf2fb5db8 Update Copyright year in ChangeLog files
2024 -> 2025
2025-01-02 11:13:18 +01:00
Georg-Johann Lay
f8a602ce53 AVR: target/118001 - Add __flashx as 24-bit named address space.
This patch adds __flashx as a new named address space that allocates
objects in .progmemx.data.  The handling is mostly the same or similar
to that of 24-bit space __memx, except that the asm routines are
simpler and more efficient.  Loads are emit inline when ELPMX or
LPMX is available.  The address space uses a 24-bit addresses even
on devices with a program memory size of 64 KiB or less.

	PR target/118001
gcc/
	* doc/extend.texi (AVR Named Address Spaces): Document __flashx.
	* config/avr/avr.h (ADDR_SPACE_FLASHX): New enum value.
	* config/avr/avr-protos.h (avr_out_fload, avr_mem_flashx_p)
	(avr_fload_libgcc_p, avr_load_libgcc_mem_p)
	(avr_load_libgcc_insn_p): New.
	* config/avr/avr.cc (avr_addrspace): Add ADDR_SPACE_FLASHX.
	(avr_decl_flashx_p, avr_mem_flashx_p, avr_fload_libgcc_p)
	(avr_load_libgcc_mem_p, avr_load_libgcc_insn_p, avr_out_fload):
	New functions.
	(avr_adjust_insn_length) [ADJUST_LEN_FLOAD]: Handle case.
	(avr_progmem_p) [avr_decl_flashx_p]: return 2.
	(avr_addr_space_legitimate_address_p) [ADDR_SPACE_FLASHX]:
	Has same behavior like ADDR_SPACE_MEMX.
	(avr_addr_space_convert): Use pointer sizes rather then ASes.
	(avr_addr_space_contains): New function.
	(avr_convert_to_type): Use it.
	(avr_emit_cpymemhi): Handle ADDR_SPACE_FLASHX.
	* config/avr/avr.md (adjust_len) <fload>: New attr value.
	(gen_load<mode>_libgcc): Renamed from load<mode>_libgcc.
	(xload8<mode>_A): Iterate over MOVMODE rather than over ALL1.
	(fxmov<mode>_A): New from xloadv<mode>_A.
	(xmov<mode>_8): New from xload<mode>_A.
	(fmov<mode>): New insns.
	(fxload<mode>_A): New from xload<mode>_A.
	(fxload_<mode>_libgcc): New from xload_<mode>_libgcc.
	(*fxload_<mode>_libgcc): New from *xload_<mode>_libgcc.
	(mov<mode>) [avr_mem_flashx_p]: Hande ADDR_SPACE_FLASHX.
	(cpymemx_<mode>): Make sure the address space is not lost
	when splitting.
	(*cpymemx_<mode>) [ADDR_SPACE_FLASHX]: Use __movmemf_<mode> for asm.
	(*ashlqi.1.zextpsi_split): New combine pattern.
	* config/avr/predicates.md (nox_general_operand): Don't match
	when avr_mem_flashx_p is true.
	* config/avr/avr-passes.cc (AVR_LdSt_Props):
	ADDR_SPACE_FLASHX has no post_inc.

gcc/testsuite/
	* gcc.target/avr/torture/addr-space-1.h [AVR_HAVE_ELPM]:
	Use a function to bump .progmemx.data to a high address.
	* gcc.target/avr/torture/addr-space-2.h: Same.
	* gcc.target/avr/torture/addr-space-1-fx.c: New test.
	* gcc.target/avr/torture/addr-space-2-fx.c: New test.

libgcc/
	* config/avr/t-avr (LIB1ASMFUNCS): Add _fload_1, _fload_2,
	_fload_3, _fload_4, _movmemf.
	* config/avr/lib1funcs.S (.branch_plus): New .macro.
	(__xload_1, __xload_2, __xload_3, __xload_4): When the address is
	located in flash, then forward to...
	(__fload_1, __fload_2, __fload_3, __fload_4): ...these new
	functions, respectively.
	(__movmemx_hi): When the address is located in flash, forward to...
	(__movmemf_hi): ...this new function.
2024-12-12 14:58:48 +01:00
Yury Khrustalev
f3ee8bc1cb aarch64: Fix build failure due to missing header
Including the "arm_acle.h" header in aarch64-unwind.h requires
stdint.h to be present and it may not be available during the
first stage of cross-compilation of GCC.

When cross-building GCC for the aarch64-none-linux-gnu target
(on any supporting host) using the 3-stage bootstrap build
process when we build native compiler from source, libgcc fails
to compile due to missing header that has not been installed yet.

This could be worked around but it's better to fix the issue.

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h (_CHKFEAT_GCS): Add.
2024-11-29 16:30:51 +00:00
Yury Khrustalev
5a6af707f0 aarch64: add ACLE macro _CHKFEAT_GCS
gcc/ChangeLog:
	* config/aarch64/arm_acle.h (_CHKFEAT_GCS): New.

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h (_Unwind_Frames_Extra): Update.
	(_Unwind_Frames_Increment): Update

Reviewed-by: Richard Sandiford <richard.sandiford@arm.com>
2024-11-29 10:20:45 +00:00
Sandra Loosemore
e876acab6c nios2: Remove all support for Nios II target.
nios2 target support in GCC was deprecated in GCC 14 as the
architecture has been EOL'ed by the vendor.  This patch removes the
entire port for GCC 15

There are still references to "nios2" in libffi and libgo.  Since those
libraries are imported into the gcc sources from master copies maintained
by other projects, those will need to be addressed elsewhere.

ChangeLog:
	* MAINTAINERS: Remove references to nios2.
	* configure.ac: Likewise.
	* configure: Regenerated.

config/ChangeLog:
	* mt-nios2-elf: Deleted.

contrib/ChangeLog:
	* config-list.mk: Remove references to Nios II.

gcc/ChangeLog:
	* common/config/nios2/*: Delete entire directory.
	* config/nios2/*: Delete entire directory.
	* config.gcc: Remove references to nios2.
	* configure.ac: Likewise.
	* doc/extend.texi: Likewise.
	* doc/install.texi: Likewise.
	* doc/invoke.texi: Likewise.
	* doc/md.texi: Likewise.
	* regenerate-opt-urls.py: Likewise.
	* config.in: Regenerated.
	* configure: Regenerated.

gcc/testsuite/ChangeLog:
	* g++.target/nios2/*: Delete entire directory.
	* gcc.target/nios2/*: Delete entire directory.
	* g++.dg/cpp0x/constexpr-rom.C: Remove refences to nios2.
	* g++.old-deja/g++.jason/thunk3.C: Likewise.
	* gcc.c-torture/execute/20101011-1.c: Likewise.
	* gcc.c-torture/execute/pr47237.c: Likewise.
	* gcc.dg/20020312-2.c: Likewise.
	* gcc.dg/20021029-1.c: Likewise.
	* gcc.dg/debug/btf/btf-datasec-1.c: Likewise.
	* gcc.dg/ifcvt-4.c: Likewise.
	* gcc.dg/stack-usage-1.c: Likewise.
	* gcc.dg/struct-by-value-1.c: Likewise.
	* gcc.dg/tree-ssa/reassoc-33.c: Likewise.
	* gcc.dg/tree-ssa/reassoc-34.c: Likewise.
	* gcc.dg/tree-ssa/reassoc-35.c: Likewise.
	* gcc.dg/tree-ssa/reassoc-36.c: Likewise.
	* lib/target-supports.exp: Likewise.

libgcc/ChangeLog:
	* config/nios2/*: Delete entire directory.
	* config.host: Remove refences to nios2.
	* unwind-dw2-fde-dip.c: Likewise.
2024-11-25 18:07:35 +00:00
Evgeny Karpov
6c11f24532 aarch64: Bypass hidden attribute warnings in MinGW
The patch bypasses hidden attribute warnings in MinGW until it is
implemented.

libgcc/ChangeLog:

	* config.host: Update.
	* config/aarch64/t-mingw: New.
2024-11-19 14:27:33 +01:00
Jeff Law
1100c0576b Fix more c23 bool fallout
While these haven't shown up in my tester (not configs I test) and I think
we're likely going to be deprecating the nds32 target. we might as well go
ahead and fix them.

I'm going to include this under the pr117628 umbrella.

	PR target/117628

libgcc/
	* config/arm/freebsd-atomic.c (bool): Remove unnecessary typedef.
	* config/arm/linux-atomic-64bit.c: Likewise.
	* config/arm/linux-atomic.c: Likewise.
	* config/nds32/linux-atomic.c: Likewise.
	* config/nios2/linux-atomic.c: Likewise.
2024-11-18 10:11:01 -07:00
Jeff Law
39a39d1f38 [RFA] Fix csky and c6x build failures
csky fails to build libgcc after the c23 changes because it has a typedef for
bool.  AFAICT it's internal to the file, so removing the typedef isn't an ABI
change.

Similiarly for c6x which includes unwind-arm-common.inc.  I suspect most, if
not all of the arm-v7 and older targets are failing to build right now.

I've built and regression tested both csky-linux-gnu and c6x-elf with this
change.  OK for the trunk?

	PR target/117628
libgcc/
	* config/csky/linux-atomic.c (bool): Remove unnecessary typedef.
	* unwind-arm-common.inc (bool): Similarly.
2024-11-18 10:01:32 -07:00
John David Anglin
8f50a07940 hppa: Remove typedef for bool type
In C23, bool is now a keyword.  So, doing a typedef for it is invalid.

2024-11-17  John David Anglin  <danglin@gcc.gnu.org>

libgcc/ChangeLog:

	PR target/117627
	* config/pa/linux-atomic.c: Remove typedef for bool type.
2024-11-17 14:42:39 -05:00
GCC Administrator
a649efea00 Daily bump. 2024-11-17 00:21:19 +00:00
Georg-Johann Lay
307b11179a AVR: Fix building LibF7 after switching to C23.
Since r15-5327, GNU-C23 is being used as C language default.
libf7.h doesn't assume headers like stdbool.h are present
and defines bool, true and false on its own.

libgcc/config/avr/libf7/
	* libf7.h (bool, true, false): Don't define in C23 or higher.
2024-11-16 22:18:51 +01:00
GCC Administrator
5673fc0c7b Daily bump. 2024-11-14 17:20:15 +00:00
Szabolcs Nagy
d8374290e5 aarch64: libgcc: add GCS marking to asm
libgcc/ChangeLog:

	* config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define.
	(GCS_FLAG): Define if GCS is enabled.
	(GNU_PROPERTY): Add GCS_FLAG.
2024-11-14 16:15:12 +00:00
Szabolcs Nagy
2a330ec149 aarch64: Add GCS support to the unwinder
Follows the current linux ABI that uses single signal entry token
and shared shadow stack between thread and alt stack.
Could be behind __ARM_FEATURE_GCS_DEFAULT ifdef (only do anything
special with gcs compat codegen) but there is a runtime check anyway.

Change affected tests to be compatible with -mbranch-protection=standard

libgcc/ChangeLog:

	* config/aarch64/aarch64-unwind.h (_Unwind_Frames_Extra): Update.
	(_Unwind_Frames_Increment): Define.
2024-11-14 16:15:11 +00:00
Christophe Lyon
13a966d56f libgcc: Fix COPY_ARG_VAL initializer (PR 117537)
We recently forced -Werror when building libgcc for aarch64, to make
sure we'd catch and fix the kind of problem described in the PR.

In this case, when building for aarch64_be (so, big endian), gcc emits
this warning/error:
libgcc/config/libbid/bid_conf.h:847:25: error: missing braces around initializer [-Werror=missing-braces]
  847 |        UINT128 arg_name={ bid_##arg_name.w[1], bid_##arg_name.w[0]};
libgcc/config/libbid/bid_conf.h:871:8: note: in expansion of macro 'COPY_ARG_VAL'
  871 |        COPY_ARG_VAL(arg_name)

This patch fixes the problem by adding curly braces around the
initializer for COPY_ARG_VAL in the big endian case.

It seems that COPY_ARG_REF (just above COPY_ARG_VAL) has a similar
issue, but DECIMAL_CALL_BY_REFERENCE seems always defined to 0, so
COPY_ARG_REF is never used.  The patch fixes it too, though.

libgcc/config/libbid/ChangeLog:

	PR libgcc/117537
	* bid_conf.h (COPY_ARG_REF): Fix initializer.
	(COPY_ARG_VAL): Likewise.
2024-11-14 08:59:28 +00:00
GCC Administrator
c232f92161 Daily bump. 2024-10-26 00:19:39 +00:00
Jakub Jelinek
45ab93d9af non-gcc: Remove trailing whitespace
I've tried to build stage3 with
-Wleading-whitespace=blanks -Wtrailing-whitespace=blank -Wno-error=leading-whitespace=blanks -Wno-error=trailing-whitespace=blank
added to STRICT_WARN and that expectably resulted in about
2744 unique trailing whitespace warnings and 124837 leading whitespace
warnings when excluding *.md files (which obviously is in big part a
generator issue).  Others from that are generator related, I think those
need to be solved later.

The following patch just fixes up the easy case (trailing whitespace),
which could be easily automated:
for i in `find . -name \*.h -o -name \*.cc -o -name \*.c | xargs grep -l '[ 	]$' | grep -v testsuite/`; do sed -i -e 's/[ 	]*$//' $i; done
I've excluded files which I knew are obviously generated or go FE.

Is there anything else we'd want to avoid the changes?

Due to patch size, I've split it between gcc/ part
and rest (include/, libiberty/, libgcc/, libcpp/, libstdc++-v3/;
this part).

2024-10-24  Jakub Jelinek  <jakub@redhat.com>

include/
	* dyn-string.h: Remove trailing whitespace.
	* libiberty.h: Likewise.
	* xregex.h: Likewise.
	* splay-tree.h: Likewise.
	* partition.h: Likewise.
	* plugin-api.h: Likewise.
	* demangle.h: Likewise.
	* vtv-change-permission.h: Likewise.
	* fibheap.h: Likewise.
	* hsa_ext_image.h: Likewise.
	* hashtab.h: Likewise.
	* libcollector.h: Likewise.
	* sort.h: Likewise.
	* symcat.h: Likewise.
	* hsa_ext_amd.h: Likewise.
libcpp/
	* directives.cc: Remove trailing whitespace.
	* mkdeps.cc: Likewise.
	* line-map.cc: Likewise.
	* internal.h: Likewise.
	* files.cc: Likewise.
	* init.cc: Likewise.
	* makeucnid.cc: Likewise.
	* system.h: Likewise.
	* include/line-map.h: Likewise.
	* include/symtab.h: Likewise.
	* include/cpplib.h: Likewise.
	* expr.cc: Likewise.
	* charset.cc: Likewise.
	* macro.cc: Likewise.
	* errors.cc: Likewise.
	* lex.cc: Likewise.
	* traditional.cc: Likewise.
libgcc/
	* crtstuff.c: Remove trailing whitespace.
	* libgcov.h: Likewise.
	* config/alpha/crtfastmath.c: Likewise.
	* config/alpha/vms-gcc_shell_handler.c: Likewise.
	* config/alpha/vms-unwind.h: Likewise.
	* config/pa/linux-atomic.c: Likewise.
	* config/pa/linux-unwind.h: Likewise.
	* config/pa/quadlib.c: Likewise.
	* config/pa/fptr.c: Likewise.
	* config/s390/32/_fixsfdi.c: Likewise.
	* config/s390/32/_fixunssfdi.c: Likewise.
	* config/s390/32/_fixunsdfdi.c: Likewise.
	* config/c6x/pr-support.c: Likewise.
	* config/lm32/_udivsi3.c: Likewise.
	* config/lm32/libgcc_lm32.h: Likewise.
	* config/lm32/_udivmodsi4.c: Likewise.
	* config/lm32/_mulsi3.c: Likewise.
	* config/lm32/_modsi3.c: Likewise.
	* config/lm32/_umodsi3.c: Likewise.
	* config/lm32/_divsi3.c: Likewise.
	* config/darwin-crt3.c: Likewise.
	* config/msp430/mpy.c: Likewise.
	* config/ia64/tf-signs.c: Likewise.
	* config/ia64/fde-vms.c: Likewise.
	* config/ia64/unwind-ia64.c: Likewise.
	* config/ia64/vms-unwind.h: Likewise.
	* config/ia64/sfp-exceptions.c: Likewise.
	* config/ia64/quadlib.c: Likewise.
	* config/ia64/unwind-ia64.h: Likewise.
	* config/rl78/vregs.h: Likewise.
	* config/arm/bpabi.c: Likewise.
	* config/arm/unwind-arm.c: Likewise.
	* config/arm/pr-support.c: Likewise.
	* config/arm/linux-atomic.c: Likewise.
	* config/arm/bpabi-lib.h: Likewise.
	* config/frv/frvend.c: Likewise.
	* config/frv/cmovw.c: Likewise.
	* config/frv/frvbegin.c: Likewise.
	* config/frv/cmovd.c: Likewise.
	* config/frv/cmovh.c: Likewise.
	* config/aarch64/cpuinfo.c: Likewise.
	* config/i386/crtfastmath.c: Likewise.
	* config/i386/cygming-crtend.c: Likewise.
	* config/i386/32/tf-signs.c: Likewise.
	* config/i386/crtprec.c: Likewise.
	* config/i386/sfp-exceptions.c: Likewise.
	* config/i386/w32-unwind.h: Likewise.
	* config/m32r/initfini.c: Likewise.
	* config/sparc/crtfastmath.c: Likewise.
	* config/gcn/amdgcn_veclib.h: Likewise.
	* config/nios2/linux-atomic.c: Likewise.
	* config/nios2/linux-unwind.h: Likewise.
	* config/nios2/lib2-mul.c: Likewise.
	* config/nios2/lib2-nios2.h: Likewise.
	* config/xtensa/unwind-dw2-xtensa.c: Likewise.
	* config/rs6000/darwin-fallback.c: Likewise.
	* config/rs6000/ibm-ldouble.c: Likewise.
	* config/rs6000/sfp-machine.h: Likewise.
	* config/rs6000/darwin-asm.h: Likewise.
	* config/rs6000/darwin-crt2.c: Likewise.
	* config/rs6000/aix-unwind.h: Likewise.
	* config/rs6000/sfp-exceptions.c: Likewise.
	* config/gthr-vxworks.c: Likewise.
	* config/riscv/atomic.c: Likewise.
	* config/visium/memcpy.c: Likewise.
	* config/darwin-crt-tm.c: Likewise.
	* config/stormy16/lib2funcs.c: Likewise.
	* config/arc/ieee-754/divtab-arc-sf.c: Likewise.
	* config/arc/ieee-754/divtab-arc-df.c: Likewise.
	* config/arc/initfini.c: Likewise.
	* config/sol2/gmon.c: Likewise.
	* config/microblaze/divsi3_table.c: Likewise.
	* config/m68k/fpgnulib.c: Likewise.
	* libgcov-driver.c: Likewise.
	* unwind-dw2.c: Likewise.
	* fp-bit.c: Likewise.
	* dfp-bit.h: Likewise.
	* dfp-bit.c: Likewise.
	* libgcov-driver-system.c: Likewise.
libgcc/config/libbid/
	* _le_td.c: Remove trailing whitespace.
	* bid128_compare.c: Likewise.
	* bid_div_macros.h: Likewise.
	* bid64_to_bid128.c: Likewise.
	* bid64_to_uint32.c: Likewise.
	* bid128_to_uint64.c: Likewise.
	* bid64_div.c: Likewise.
	* bid128_round_integral.c: Likewise.
	* bid_binarydecimal.c: Likewise.
	* bid128_string.c: Likewise.
	* bid_flag_operations.c: Likewise.
	* bid128_to_int64.c: Likewise.
	* _mul_sd.c: Likewise.
	* bid64_mul.c: Likewise.
	* bid128_noncomp.c: Likewise.
	* _gt_dd.c: Likewise.
	* bid64_add.c: Likewise.
	* bid64_string.c: Likewise.
	* bid_from_int.c: Likewise.
	* bid128.c: Likewise.
	* _ge_dd.c: Likewise.
	* _ne_sd.c: Likewise.
	* _dd_to_td.c: Likewise.
	* _unord_sd.c: Likewise.
	* bid64_to_uint64.c: Likewise.
	* _gt_sd.c: Likewise.
	* _sd_to_td.c: Likewise.
	* _addsub_td.c: Likewise.
	* _ne_td.c: Likewise.
	* bid_dpd.c: Likewise.
	* bid128_add.c: Likewise.
	* bid128_next.c: Likewise.
	* _lt_sd.c: Likewise.
	* bid64_next.c: Likewise.
	* bid128_mul.c: Likewise.
	* _lt_dd.c: Likewise.
	* _ge_td.c: Likewise.
	* _unord_dd.c: Likewise.
	* bid64_sqrt.c: Likewise.
	* bid_sqrt_macros.h: Likewise.
	* bid64_fma.c: Likewise.
	* _sd_to_dd.c: Likewise.
	* bid_conf.h: Likewise.
	* bid64_noncomp.c: Likewise.
	* bid_gcc_intrinsics.h: Likewise.
	* _gt_td.c: Likewise.
	* _ge_sd.c: Likewise.
	* bid128_minmax.c: Likewise.
	* bid128_quantize.c: Likewise.
	* bid32_to_bid64.c: Likewise.
	* bid_round.c: Likewise.
	* _td_to_sd.c: Likewise.
	* bid_inline_add.h: Likewise.
	* bid128_fma.c: Likewise.
	* _eq_td.c: Likewise.
	* bid32_to_bid128.c: Likewise.
	* bid64_rem.c: Likewise.
	* bid128_2_str_tables.c: Likewise.
	* _mul_dd.c: Likewise.
	* _dd_to_sd.c: Likewise.
	* bid128_div.c: Likewise.
	* _lt_td.c: Likewise.
	* bid64_compare.c: Likewise.
	* bid64_to_int32.c: Likewise.
	* _unord_td.c: Likewise.
	* bid128_rem.c: Likewise.
	* bid_internal.h: Likewise.
	* bid64_to_int64.c: Likewise.
	* _eq_dd.c: Likewise.
	* _td_to_dd.c: Likewise.
	* bid128_to_int32.c: Likewise.
	* bid128_to_uint32.c: Likewise.
	* _ne_dd.c: Likewise.
	* bid64_quantize.c: Likewise.
	* _le_dd.c: Likewise.
	* bid64_round_integral.c: Likewise.
	* _le_sd.c: Likewise.
	* bid64_minmax.c: Likewise.
libgcc/config/avr/libf7/
	* f7-renames.h: Remove trailing whitespace.
libstdc++-v3/
	* include/debug/debug.h: Remove trailing whitespace.
	* include/parallel/base.h: Likewise.
	* include/parallel/types.h: Likewise.
	* include/parallel/settings.h: Likewise.
	* include/parallel/multiseq_selection.h: Likewise.
	* include/parallel/partition.h: Likewise.
	* include/parallel/random_number.h: Likewise.
	* include/parallel/find_selectors.h: Likewise.
	* include/parallel/partial_sum.h: Likewise.
	* include/parallel/list_partition.h: Likewise.
	* include/parallel/search.h: Likewise.
	* include/parallel/algorithmfwd.h: Likewise.
	* include/parallel/random_shuffle.h: Likewise.
	* include/parallel/multiway_mergesort.h: Likewise.
	* include/parallel/sort.h: Likewise.
	* include/parallel/algobase.h: Likewise.
	* include/parallel/numericfwd.h: Likewise.
	* include/parallel/multiway_merge.h: Likewise.
	* include/parallel/losertree.h: Likewise.
	* include/bits/basic_ios.h: Likewise.
	* include/bits/stringfwd.h: Likewise.
	* include/bits/ostream_insert.h: Likewise.
	* include/bits/stl_heap.h: Likewise.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/hashtable_policy.h: Likewise.
	* include/bits/stl_iterator_base_funcs.h: Likewise.
	* include/bits/valarray_before.h: Likewise.
	* include/bits/regex.h: Likewise.
	* include/bits/postypes.h: Likewise.
	* include/bits/stl_iterator.h: Likewise.
	* include/bits/localefwd.h: Likewise.
	* include/bits/stl_algo.h: Likewise.
	* include/bits/ios_base.h: Likewise.
	* include/bits/stl_function.h: Likewise.
	* include/bits/basic_string.h: Likewise.
	* include/bits/hashtable.h: Likewise.
	* include/bits/valarray_after.h: Likewise.
	* include/bits/char_traits.h: Likewise.
	* include/bits/gslice.h: Likewise.
	* include/bits/locale_facets_nonio.h: Likewise.
	* include/bits/mask_array.h: Likewise.
	* include/bits/specfun.h: Likewise.
	* include/bits/random.h: Likewise.
	* include/bits/slice_array.h: Likewise.
	* include/bits/valarray_array.h: Likewise.
	* include/tr1/float.h: Likewise.
	* include/tr1/functional_hash.h: Likewise.
	* include/tr1/math.h: Likewise.
	* include/tr1/hashtable_policy.h: Likewise.
	* include/tr1/stdio.h: Likewise.
	* include/tr1/complex.h: Likewise.
	* include/tr1/stdbool.h: Likewise.
	* include/tr1/stdarg.h: Likewise.
	* include/tr1/inttypes.h: Likewise.
	* include/tr1/fenv.h: Likewise.
	* include/tr1/stdlib.h: Likewise.
	* include/tr1/wchar.h: Likewise.
	* include/tr1/tgmath.h: Likewise.
	* include/tr1/limits.h: Likewise.
	* include/tr1/wctype.h: Likewise.
	* include/tr1/stdint.h: Likewise.
	* include/tr1/ctype.h: Likewise.
	* include/tr1/random.h: Likewise.
	* include/tr1/shared_ptr.h: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/sso_string_base.h: Likewise.
	* include/ext/debug_allocator.h: Likewise.
	* include/ext/vstring_fwd.h: Likewise.
	* include/ext/pointer.h: Likewise.
	* include/ext/pod_char_traits.h: Likewise.
	* include/ext/malloc_allocator.h: Likewise.
	* include/ext/vstring.h: Likewise.
	* include/ext/bitmap_allocator.h: Likewise.
	* include/ext/pool_allocator.h: Likewise.
	* include/ext/type_traits.h: Likewise.
	* include/ext/ropeimpl.h: Likewise.
	* include/ext/codecvt_specializations.h: Likewise.
	* include/ext/throw_allocator.h: Likewise.
	* include/ext/extptr_allocator.h: Likewise.
	* include/ext/atomicity.h: Likewise.
	* include/ext/concurrence.h: Likewise.
	* include/c_compatibility/wchar.h: Likewise.
	* include/c_compatibility/stdint.h: Likewise.
	* include/backward/hash_fun.h: Likewise.
	* include/backward/binders.h: Likewise.
	* include/backward/hashtable.h: Likewise.
	* include/backward/auto_ptr.h: Likewise.
	* libsupc++/eh_arm.cc: Likewise.
	* libsupc++/unwind-cxx.h: Likewise.
	* libsupc++/si_class_type_info.cc: Likewise.
	* libsupc++/vec.cc: Likewise.
	* libsupc++/class_type_info.cc: Likewise.
	* libsupc++/vmi_class_type_info.cc: Likewise.
	* libsupc++/guard_error.cc: Likewise.
	* libsupc++/bad_typeid.cc: Likewise.
	* libsupc++/eh_personality.cc: Likewise.
	* libsupc++/atexit_arm.cc: Likewise.
	* libsupc++/pmem_type_info.cc: Likewise.
	* libsupc++/vterminate.cc: Likewise.
	* libsupc++/eh_terminate.cc: Likewise.
	* libsupc++/bad_cast.cc: Likewise.
	* libsupc++/exception_ptr.h: Likewise.
	* libsupc++/eh_throw.cc: Likewise.
	* libsupc++/bad_alloc.cc: Likewise.
	* libsupc++/nested_exception.cc: Likewise.
	* libsupc++/pointer_type_info.cc: Likewise.
	* libsupc++/pbase_type_info.cc: Likewise.
	* libsupc++/bad_array_new.cc: Likewise.
	* libsupc++/pure.cc: Likewise.
	* libsupc++/eh_exception.cc: Likewise.
	* libsupc++/bad_array_length.cc: Likewise.
	* libsupc++/cxxabi.h: Likewise.
	* libsupc++/guard.cc: Likewise.
	* libsupc++/eh_catch.cc: Likewise.
	* libsupc++/cxxabi_forced.h: Likewise.
	* libsupc++/tinfo.h: Likewise.
2024-10-25 10:03:17 +02:00
Christophe Lyon
71c7b446b9 aarch64: libgcc: Use -Werror
This patch adds -Werror to LIBGCC2_CFLAGS so that aarch64 can catch
warnings during bootstrap, while not impacting other targets.

The patch also adds -Wno-prio-ctor-dtor to avoid a warning when
compiling lse_init.c

	libgcc/
	* config/aarch64/t-aarch64: Always use -Werror
	-Wno-prio-ctor-dtor.
2024-10-17 15:43:28 +00:00
Christophe Lyon
d806810f02 aarch64: libgcc: add prototypes in cpuinfo
Add prototypes for __init_cpu_features_resolver and
__init_cpu_features to avoid warnings due to -Wmissing-prototypes.

	libgcc/
	* config/aarch64/cpuinfo.c (__init_cpu_features_resolver): Add
	prototype.
	(__init_cpu_features): Likewise.
2024-10-17 15:43:27 +00:00
Christophe Lyon
e4d417417f aarch64: libgcc: Cleanup warnings in lse.S
Since
  Commit c608ada288
  Author:     Zac Walker <zacwalker@microsoft.com>
  CommitDate: 2024-01-23 15:32:30 +0000

  Ifdef `.hidden`, `.type`, and `.size` pseudo-ops for `aarch64-w64-mingw32` target

lse.S includes aarch64-asm.h, leading to a conflicting definition of macro 'L':
- in lse.S it expands to either '' or 'L'
- in aarch64-asm.h it is used to generate .L ## label

lse.S does not use the second, so this patch just undefines L after
the inclusion of aarch64-asm.h.

libgcc/
	* config/aarch64/lse.S: Undefine L() macro.
2024-10-17 15:43:27 +00:00
Yangyu Chen
1c507a02f2 RISC-V: Add detailed comments on processing implied extensions. [NFC]
In some cases, we don't need to handle implied extensions. Add detailed
comments to help developers understand what implied ISAs should be
considered.

libgcc/ChangeLog:

	* config/riscv/feature_bits.c (__init_riscv_features_bits_linux):
	Add detailed comments on processing implied extensions.

Signed-off-by: Yangyu Chen <chenyangyu@isrc.iscas.ac.cn>
2024-10-14 19:53:17 +08:00
Kito Cheng
ca44eb7f6a RISC-V: Implement __init_riscv_feature_bits, __riscv_feature_bits, and __riscv_vendor_feature_bits
This provides a common abstraction layer to probe the available extensions at
run-time. These functions can be used to implement function multi-versioning or
to detect available extensions.

The advantages of providing this abstraction layer are:
- Easy to port to other new platforms.
- Easier to maintain in GCC for function multi-versioning.
  - For example, maintaining platform-dependent code in C code/libgcc is much
    easier than maintaining it in GCC by creating GIMPLEs...

This API is intended to provide the capability to query minimal common available extensions on the system.

The API is defined in the riscv-c-api-doc:
https://github.com/riscv-non-isa/riscv-c-api-doc/blob/main/src/c-api.adoc

Proposal to use unsigned long long for marchid and mimpid:
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/91

Full function multi-versioning implementation will come later. We are posting
this first because we intend to backport it to the GCC 14 branch to unblock
LLVM 19 to use this with GCC 14.2, rather than waiting for GCC 15.

Changes since v7:
- Remove vendorID field in __riscv_vendor_feature_bits.
- Fix C implies Zcf only for RV32.
- Add more comments to kernel versions.

Changes since v6:
- Implement __riscv_cpu_model.
- Set new sub extension bits which implied from previous extensions.

Changes since v5:
- Minor fixes on indentation.

Changes since v4:
- Bump to newest riscv-c-api-doc with some new extensions like Zve*, Zc*
  Zimop, Zcmop, Zawrs.
- Rename the return variable name of hwprobe syscall.
- Minor fixes on indentation.

Changes since v3:
- Fix non-linux build.
- Let __init_riscv_feature_bits become constructor

Changes since v2:
- Prevent it initialize more than once.

Changes since v1:
- Fix the format.
- Prevented race conditions by introducing a local variable to avoid load/store
  operations during the computation of the feature bit.

Co-Developed-by: Yangyu Chen <chenyangyu@isrc.iscas.ac.cn>
Signed-off-by: Yangyu Chen <chenyangyu@isrc.iscas.ac.cn>

libgcc/ChangeLog:

	* config/riscv/feature_bits.c: New.
	* config/riscv/t-elf (LIB2ADD): Add feature_bits.c.
2024-10-14 17:36:14 +08:00
Sébastien Michelland
e95512e2d5 SH: Use softfp for sh-elf
libgcc/ChangeLog:

	PR target/29845
	* config.host (sh-*-elf*): Replace fdpbit with softfp.
	* config/sh/sfp-machine.h: New file.

Signed-off-by: Sébastien Michelland <sebastien.michelland@lcis.grenoble-inp.fr>
2024-10-10 09:29:33 +09:00
Tsung Chun Lin
78d2af1fa5 [PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in __riscv_save_[0-3] on ilp32e.
From 8b3c5ebe8aacbcc4ddf1be8dea9a555e7e1bcc39 Mon Sep 17 00:00:00 2001
From: Jim Lin <jim@andestech.com>
Date: Fri, 4 Oct 2024 14:48:12 +0800
Subject: [PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in
 __riscv_save_[0-3] on ilp32e.

libgcc/ChangeLog:

	* config/riscv/save-restore.S: Fix .cfi_offset for saving ra in
	__riscv_save_[0-3] on ilp32e.
2024-10-04 08:02:48 -06:00