diff options
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/ChangeLog | 36 | ||||
-rw-r--r-- | libgcc/config/avr/lib1funcs-fixed.S | 66 | ||||
-rw-r--r-- | libgcc/config/avr/lib1funcs.S | 36 | ||||
-rw-r--r-- | libgcc/config/avr/t-avr | 32 | ||||
-rw-r--r-- | libgcc/config/gcn/unwind-gcn.c | 21 | ||||
-rw-r--r-- | libgcc/config/i386/gthr-win32.h | 81 | ||||
-rw-r--r-- | libgcc/config/nvptx/alloca.c | 38 | ||||
-rw-r--r-- | libgcc/config/nvptx/t-nvptx | 3 | ||||
-rw-r--r-- | libgcc/config/nvptx/unwind-nvptx.c | 21 |
9 files changed, 254 insertions, 80 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index c505e88..9df44ba 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,39 @@ +2025-04-08 Thomas Schwinge <tschwinge@baylibre.com> + + * 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 Thomas Schwinge <tschwinge@baylibre.com> + + * config/gcn/unwind-gcn.c (_Unwind_DeleteException): New. + * config/nvptx/unwind-nvptx.c (_Unwind_DeleteException): Likewise. + +2025-04-07 Thomas Schwinge <tschwinge@baylibre.com> + + * config/nvptx/alloca.c: New. + * config/nvptx/t-nvptx (LIB2ADD): Add it. + +2025-04-07 Georg-Johann Lay <avr@gjlay.de> + + * config/avr/lib1funcs.S (__mulhisi3, __umulhisi3): Use + __mulhisi3_helper for better performance on AVRrc. + +2025-04-06 Georg-Johann Lay <avr@gjlay.de> + + * 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-05 Georg-Johann Lay <avr@gjlay.de> * config/avr/lib1funcs.S (__umulhisi3) [Have MUL]: Reduce call diff --git a/libgcc/config/avr/lib1funcs-fixed.S b/libgcc/config/avr/lib1funcs-fixed.S index 278ee1b..4115589 100644 --- a/libgcc/config/avr/lib1funcs-fixed.S +++ b/libgcc/config/avr/lib1funcs-fixed.S @@ -31,14 +31,6 @@ ;; Fixed point library routines for AVR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#if defined __AVR_TINY__ -#define __zero_reg__ r17 -#define __tmp_reg__ r16 -#else -#define __zero_reg__ r1 -#define __tmp_reg__ r0 -#endif - .section .text.libgcc.fixed, "ax", @progbits #ifndef __AVR_TINY__ @@ -251,6 +243,7 @@ DEFUN __fractsfusa ENDF __fractsfusa #endif /* L_fractsfusa */ +#endif /* ! AVR_TINY */ ;; For multiplication the functions here are called directly from ;; avr-fixed.md instead of using the standard libcall mechanisms. @@ -295,8 +288,14 @@ DEFUN __mulhq3 rol r25 brvs 1f ;; Round +#ifndef __AVR_TINY__ sbrc r23, 7 adiw r24, 1 +#else + lsl r23 + adc r24, __zero_reg__ + adc r25, __zero_reg__ +#endif /* AVR_TINY? */ ret 1: ;; Overflow. TR 18037 requires (-1)^2 not to overflow ldi r24, lo8 (0x7fff) @@ -315,8 +314,14 @@ ENDF __mulhq3 DEFUN __muluhq3 XCALL __umulhisi3 ;; Round +#ifndef __AVR_TINY__ sbrc r23, 7 adiw r24, 1 +#else + lsl r23 + adc r24, __zero_reg__ + adc r25, __zero_reg__ +#endif /* AVR_TINY? */ ret ENDF __muluhq3 #endif /* L_muluhq3 */ @@ -361,8 +366,14 @@ DEFUN __muluha3_round mov r25, r24 mov r24, r23 ;; Round +#ifndef __AVR_TINY__ sbrc r22, 7 adiw r24, 1 +#else + lsl r22 + adc r24, __zero_reg__ + adc r25, __zero_reg__ +#endif /* AVR_TINY? */ ret ENDF __muluha3_round #endif /* L_muluha3_round */ @@ -372,6 +383,8 @@ ENDF __muluha3_round Fixed Multiplication 16.16 x 16.16 *******************************************************/ +#ifndef __AVR_TINY__ + ;; Bits outside the result (below LSB), used in the signed version #define GUARD __tmp_reg__ @@ -679,6 +692,8 @@ ENDF __mulusa3_round #undef GUARD +#endif /* ! AVR_TINY */ + /*********************************************************** Fixed unsigned saturated Multiplication 8.8 x 8.8 ***********************************************************/ @@ -762,8 +777,14 @@ DEFUN __ssmulha3 ;; SS = 0 --> 0x7fff ldi C3, 0x7f ldi C2, 0xff +#ifndef __AVR_TINY__ sbrc SS, 7 adiw C2, 1 +#else + lsl SS + adc C2, __zero_reg__ + adc C3, __zero_reg__ +#endif /* AVR_TINY? */ ret ENDF __ssmulha3 #endif /* L_ssmulha3 */ @@ -778,6 +799,8 @@ ENDF __ssmulha3 Fixed unsigned saturated Multiplication 16.16 x 16.16 ***********************************************************/ +#ifndef __AVR_TINY__ + #define C0 18 #define C1 C0+1 #define C2 C0+2 @@ -883,6 +906,8 @@ ENDF __ssmulsa3 #undef C7 #undef SS +#endif /* ! AVR_TINY */ + /******************************************************* Fractional Division 8 / 8 *******************************************************/ @@ -962,8 +987,8 @@ ENDF __divqq_helper #if defined (L_divhq3) DEFUN __divhq3 - mov r0, r_divdH - eor r0, r_divH + mov __tmp_reg__, r_divdH + eor __tmp_reg__, r_divH sbrs r_divH, 7 rjmp 1f NEG2 r_divL @@ -1027,8 +1052,8 @@ ENDF __udivuha3_common *******************************************************/ #if defined (L_divha3) DEFUN __divha3 - mov r0, r_divdH - eor r0, r_divH + mov __tmp_reg__, r_divdH + eor __tmp_reg__, r_divH sbrs r_divH, 7 rjmp 1f NEG2 r_divL @@ -1040,7 +1065,7 @@ DEFUN __divha3 XCALL __udivuha3 lsr r_quoH ; adjust to 7 fractional bits ror r_quoL - sbrs r0, 7 ; negate result if needed + sbrs __tmp_reg__, 7 ; negate result if needed ret NEG2 r_quoL ret @@ -1069,6 +1094,8 @@ ENDF __udivuha3 Fixed Division 16.16 / 16.16 *******************************************************/ +#ifndef __AVR_TINY__ + #define r_arg1L 24 /* arg1 gets passed already in place */ #define r_arg1H 25 #define r_arg1HL 26 @@ -1171,6 +1198,8 @@ ENDF __udivusa3 #undef r_divHH #undef r_cnt +#endif /* ! AVR_TINY */ + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Saturation, 1 Byte @@ -1206,7 +1235,7 @@ ENDF __ssabs_1 DEFUN __ssneg_2 NEG2 A0 brvc 0f - sbiw A0, 1 + wsubi A0, 1 0: ret ENDF __ssneg_2 #endif /* L_ssneg_2 */ @@ -1228,6 +1257,8 @@ ENDF __ssabs_2 ;; Saturation, 4 Bytes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +#ifndef __AVR_TINY__ + ;; First Argument and Return Register #define A0 22 #define A1 A0+1 @@ -1413,6 +1444,8 @@ ENDF __sssub_8 #undef B6 #undef B7 +#endif /* ! AVR_TINY */ + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Rounding Helpers @@ -1613,6 +1646,8 @@ ENDF __round_u2_const ;; Rounding, 4 Bytes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +#ifndef __AVR_TINY__ + #define A0 18 #define A1 A0 + 1 #define A2 A0 + 2 @@ -1915,6 +1950,7 @@ ENDF __round_x8 #undef RP #undef FBITm1 +#endif /* ! AVR_TINY */ ;; Supply implementations / symbols for the bit-banging functions ;; __builtin_avr_bitsfx and __builtin_avr_fxbits @@ -1923,5 +1959,3 @@ DEFUN __ret ret ENDF __ret #endif /* L_ret */ - -#endif /* if not __AVR_TINY__ */ diff --git a/libgcc/config/avr/lib1funcs.S b/libgcc/config/avr/lib1funcs.S index 0120892..dfe99b1 100644 --- a/libgcc/config/avr/lib1funcs.S +++ b/libgcc/config/avr/lib1funcs.S @@ -395,45 +395,57 @@ ENDF __mulhi3 #if defined (L_umulhisi3) DEFUN __umulhisi3 +#ifdef __AVR_TINY__ + ;; Save callee saved regs. + push B0 + push B1 +#endif /* AVR_TINY */ wmov B0, 24 ;; Zero-extend B clr B2 clr B3 ;; Zero-extend A wmov A2, B2 +#ifdef __AVR_TINY__ + ;; Clear hi16 of the result so we can use __mulsi3_helper. + wmov CC2, B2 + XJMP __mulsi3_helper +#else XJMP __mulsi3 +#endif /* AVR_TINY? */ ENDF __umulhisi3 #endif /* L_umulhisi3 */ #if defined (L_mulhisi3) DEFUN __mulhisi3 +#ifdef __AVR_TINY__ + ;; Save callee saved regs. + push B0 + push B1 +#endif /* AVR_TINY */ wmov B0, 24 ;; Sign-extend B lsl r25 sbc B2, B2 mov B3, B2 -#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ - ;; Sign-extend A - clr A2 - sbrc A1, 7 - com A2 - mov A3, A2 - XJMP __mulsi3 -#else /* no __AVR_ERRATA_SKIP_JMP_CALL__ */ ;; Zero-extend A and __mulsi3 will run at least twice as fast ;; compared to a sign-extended A. clr A2 clr A3 + ;; Clear hi16 of the result so we can use __mulsi3_helper. + wmov CC2, A2 sbrs A1, 7 - XJMP __mulsi3 +#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ + rjmp 1f +#else + XJMP __mulsi3_helper +#endif /* ERRATA_SKIP */ ;; If A < 0 then perform the B * 0xffff.... before the ;; very multiplication by initializing the high part of the ;; result CC with -B. - wmov CC2, A2 sub CC2, B0 sbc CC3, B1 - XJMP __mulsi3_helper -#endif /* __AVR_ERRATA_SKIP_JMP_CALL__ */ +1: XJMP __mulsi3_helper ENDF __mulhisi3 #endif /* L_mulhisi3 */ diff --git a/libgcc/config/avr/t-avr b/libgcc/config/avr/t-avr index b10542c..d181784 100644 --- a/libgcc/config/avr/t-avr +++ b/libgcc/config/avr/t-avr @@ -4,6 +4,7 @@ LIB1ASMFUNCS = \ _mulhi3 \ _mulqihi3 _umulqihi3 \ _mulpsi3 \ + _mulhisi3 _umulhisi3 \ _mulsi3 \ _udivmodqi4 \ _divmodqi4 \ @@ -33,12 +34,23 @@ LIB1ASMFUNCS = \ _popcountsi2 \ _popcountqi2 \ _bswapsi2 \ - _fmul _fmuls _fmulsu + _fmul _fmuls _fmulsu \ + _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 \ # The below functions either use registers that are not present # in tiny core, or use a different register convention (don't save # callee saved regs, for example) -# _mulhisi3 and variations - clobber R18, R19 # All *di funcs - use regs < R16 or expect args in regs < R20 # _prologue and _epilogue save registers < R16 # _load, __fload and _xload variations - expect lpm and elpm support @@ -46,8 +58,6 @@ LIB1ASMFUNCS = \ FUNCS_notiny = \ _mulsqipsi3 \ - _mulhisi3 \ - _umulhisi3 \ _usmulhisi3 \ _muluhisi3 \ _mulshisi3 \ @@ -81,24 +91,14 @@ FUNCS_notiny += \ _fractsfqq _fractsfuqq \ _fractsfhq _fractsfuhq _fractsfha _fractsfuha \ _fractsfsq _fractsfusq _fractsfsa _fractsfusa \ - _mulqq3 \ - _mulhq3 _muluhq3 \ - _mulha3 _muluha3 _muluha3_round \ _mulsa3 _mulusa3 \ - _usmuluha3 _ssmulha3 \ _usmulusa3 _ssmulsa3 \ - _divqq3 _udivuqq3 _divqq_helper \ - _divhq3 _udivuhq3 \ - _divha3 _udivuha3 \ _divsa3 _udivusa3 \ _clr_8 \ - _ssneg_2 _ssneg_4 _ssneg_8 \ - _ssabs_1 _ssabs_2 _ssabs_4 _ssabs_8 \ + _ssneg_4 _ssneg_8 \ + _ssabs_4 _ssabs_8 \ _ssadd_8 _sssub_8 \ _usadd_8 _ussub_8 \ - _mask1 _ret \ - _roundqq3 _rounduqq3 \ - _round_s2 _round_u2 _round_2_const _addmask_2 \ _round_s4 _round_u4 _round_4_const _addmask_4 \ _round_x8 \ _rounddq3 _roundudq3 \ diff --git a/libgcc/config/gcn/unwind-gcn.c b/libgcc/config/gcn/unwind-gcn.c index 44657ae..eae741c 100644 --- a/libgcc/config/gcn/unwind-gcn.c +++ b/libgcc/config/gcn/unwind-gcn.c @@ -25,6 +25,27 @@ #include "unwind.h" _Unwind_Reason_Code +_Unwind_RaiseException(struct _Unwind_Exception *exc __attribute__ ((__unused__))) +{ + __builtin_abort (); + return 0; +} + +void +_Unwind_DeleteException (struct _Unwind_Exception *exc) +{ + if (exc->exception_cleanup) + (*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc); +} + +_Unwind_Reason_Code +_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc __attribute__ ((__unused__))) +{ + __builtin_abort (); + return 0; +} + +_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument) { return 0; diff --git a/libgcc/config/i386/gthr-win32.h b/libgcc/config/i386/gthr-win32.h index 98e11b4..34988d4 100644 --- a/libgcc/config/i386/gthr-win32.h +++ b/libgcc/config/i386/gthr-win32.h @@ -71,6 +71,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #error Timed lock primitives are not supported on Windows targets #endif +#ifdef __has_attribute +# if __has_attribute(__always_inline__) +# define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__)) +# endif +#endif +#ifndef __GTHREAD_ALWAYS_INLINE +# define __GTHREAD_ALWAYS_INLINE +#endif + +#ifdef __cplusplus +# define __GTHREAD_INLINE inline __GTHREAD_ALWAYS_INLINE +#else +# define __GTHREAD_INLINE static inline +#endif + /* Make sure CONST_CAST2 (origin in system.h) is declared. */ #ifndef CONST_CAST2 #ifdef __cplusplus @@ -398,11 +413,7 @@ extern int _CRT_MT; extern int __mingwthr_key_dtor (unsigned long, void (*) (void *)); #endif /* _WIN32 && !__CYGWIN__ */ -/* __GTHR_W32_InterlockedCompareExchange is left over from win95, - which did not support InterlockedCompareExchange. */ -#define __GTHR_W32_InterlockedCompareExchange InterlockedCompareExchange - -static inline int +__GTHREAD_INLINE int __gthread_active_p (void) { #ifdef MINGW32_SUPPORTS_MT_EH @@ -438,20 +449,20 @@ extern int __gthr_win32_cond_timedwait (__gthread_cond_t *, __gthread_mutex_t *, const __gthread_time_t *); #endif -static inline int +__GTHREAD_INLINE int __gthread_create (__gthread_t *__thr, void *(*__func) (void*), void *__args) { return __gthr_win32_create (__thr, __func, __args); } -static inline int +__GTHREAD_INLINE int __gthread_join (__gthread_t __thr, void **__value_ptr) { return __gthr_win32_join (__thr, __value_ptr); } -static inline __gthread_t +__GTHREAD_INLINE __gthread_t __gthread_self (void) { return __gthr_win32_self (); @@ -463,25 +474,25 @@ __gthread_self (void) Only stubs are exposed to avoid polluting the C++ namespace with Win32 API definitions. */ -static inline int +__GTHREAD_INLINE int __gthread_detach (__gthread_t __thr) { return __gthr_win32_detach (__thr); } -static inline int +__GTHREAD_INLINE int __gthread_equal (__gthread_t __thr1, __gthread_t __thr2) { return __gthr_win32_equal (__thr1, __thr2); } -static inline int +__GTHREAD_INLINE int __gthread_yield (void) { return __gthr_win32_yield (); } -static inline int +__GTHREAD_INLINE int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) @@ -490,43 +501,43 @@ __gthread_once (__gthread_once_t *__once, void (*__func) (void)) return -1; } -static inline int +__GTHREAD_INLINE int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthr_win32_key_create (__key, __dtor); } -static inline int +__GTHREAD_INLINE int __gthread_key_delete (__gthread_key_t __key) { return __gthr_win32_key_delete (__key); } -static inline void * +__GTHREAD_INLINE void * __gthread_getspecific (__gthread_key_t __key) { return __gthr_win32_getspecific (__key); } -static inline int +__GTHREAD_INLINE int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthr_win32_setspecific (__key, __ptr); } -static inline void +__GTHREAD_INLINE void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { __gthr_win32_mutex_init_function (__mutex); } -static inline void +__GTHREAD_INLINE void __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { __gthr_win32_mutex_destroy (__mutex); } -static inline int +__GTHREAD_INLINE int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) @@ -535,7 +546,7 @@ __gthread_mutex_lock (__gthread_mutex_t *__mutex) return 0; } -static inline int +__GTHREAD_INLINE int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) @@ -544,7 +555,7 @@ __gthread_mutex_trylock (__gthread_mutex_t *__mutex) return 0; } -static inline int +__GTHREAD_INLINE int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) @@ -553,7 +564,7 @@ __gthread_mutex_unlock (__gthread_mutex_t *__mutex) return 0; } -static inline int +__GTHREAD_INLINE int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) @@ -564,31 +575,31 @@ __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) #if __GTHREAD_HAS_COND -static inline void +__GTHREAD_INLINE void __gthread_cond_init_function (__gthread_cond_t *__cond) { __gthr_win32_cond_init_function (__cond); } -static inline int +__GTHREAD_INLINE int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthr_win32_cond_broadcast (__cond); } -static inline int +__GTHREAD_INLINE int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthr_win32_cond_signal (__cond); } -static inline int +__GTHREAD_INLINE int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthr_win32_cond_wait (__cond, __mutex); } -static inline int +__GTHREAD_INLINE int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_time) { @@ -600,11 +611,11 @@ __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, #else /* ! __GTHREAD_HIDE_WIN32API */ #ifndef __GTHREAD_WIN32_INLINE -#define __GTHREAD_WIN32_INLINE static inline +#define __GTHREAD_WIN32_INLINE __GTHREAD_INLINE #endif #ifndef __GTHREAD_WIN32_COND_INLINE -#define __GTHREAD_WIN32_COND_INLINE static inline +#define __GTHREAD_WIN32_COND_INLINE __GTHREAD_INLINE #endif #ifndef __GTHREAD_WIN32_ACTIVE_P @@ -828,25 +839,25 @@ __gthread_cond_timedwait (__gthread_cond_t *__cond, #endif /* __GTHREAD_HIDE_WIN32API */ -static inline void +__GTHREAD_INLINE void __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { __gthread_mutex_init_function (__mutex); } -static inline void +__GTHREAD_INLINE void __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { __gthread_mutex_destroy (__mutex); } -static inline int +__GTHREAD_INLINE int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } -static inline int +__GTHREAD_INLINE int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); @@ -854,13 +865,13 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) #if __GTHREAD_HAS_COND -static inline int +__GTHREAD_INLINE int __gthread_cond_destroy (__gthread_cond_t *__cond ATTRIBUTE_UNUSED) { return 0; } -static inline int +__GTHREAD_INLINE int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { diff --git a/libgcc/config/nvptx/alloca.c b/libgcc/config/nvptx/alloca.c new file mode 100644 index 0000000..09bdeb6 --- /dev/null +++ b/libgcc/config/nvptx/alloca.c @@ -0,0 +1,38 @@ +/* Fake 'alloca' implementation. + + Copyright (C) 2025 Free Software Foundation, Inc. + + This file is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3, or (at your option) any + later version. + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + +/* For '-mfake-ptx-alloca', in case real PTX 'alloca' is not available. + With this function defined, we don't get a link-time failure + (unresolved symbol '__GCC_nvptx__PTX_alloca_not_supported'), but rather: + successful execution, in case that 'alloca' is not attempted (if only used + in error code paths, for example), and a run-time failure only in case that + 'alloca' is actually attempted. */ + +void * +__GCC_nvptx__PTX_alloca_not_supported (__SIZE_TYPE__ size __attribute__ ((unused))) +{ + __builtin_printf ("GCC/nvptx: sorry, unimplemented:" + " dynamic stack allocation not supported\n"); + __builtin_abort (); + return 0; +} diff --git a/libgcc/config/nvptx/t-nvptx b/libgcc/config/nvptx/t-nvptx index f295898..5e2e278 100644 --- a/libgcc/config/nvptx/t-nvptx +++ b/libgcc/config/nvptx/t-nvptx @@ -1,7 +1,8 @@ LIB2ADD=$(srcdir)/config/nvptx/reduction.c \ $(srcdir)/config/nvptx/mgomp.c \ $(srcdir)/config/nvptx/atomic.c \ - $(srcdir)/config/nvptx/unwind-nvptx.c + $(srcdir)/config/nvptx/unwind-nvptx.c \ + $(srcdir)/config/nvptx/alloca.c LIB2ADDEH= LIB2FUNCS_EXCLUDE= diff --git a/libgcc/config/nvptx/unwind-nvptx.c b/libgcc/config/nvptx/unwind-nvptx.c index 44657ae..eae741c 100644 --- a/libgcc/config/nvptx/unwind-nvptx.c +++ b/libgcc/config/nvptx/unwind-nvptx.c @@ -25,6 +25,27 @@ #include "unwind.h" _Unwind_Reason_Code +_Unwind_RaiseException(struct _Unwind_Exception *exc __attribute__ ((__unused__))) +{ + __builtin_abort (); + return 0; +} + +void +_Unwind_DeleteException (struct _Unwind_Exception *exc) +{ + if (exc->exception_cleanup) + (*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc); +} + +_Unwind_Reason_Code +_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc __attribute__ ((__unused__))) +{ + __builtin_abort (); + return 0; +} + +_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument) { return 0; |