From ebc4cd54b2378147d7041fd05ff03bd0e1a61e48 Mon Sep 17 00:00:00 2001 From: Stefan Kanthak Date: Tue, 10 Nov 2020 08:22:28 -0700 Subject: Improve generated code for various libgcc2.c routines libgcc/ * libgcc2.c (__addvSI3): Use overflow builtins. (__addvsi3, __addvDI3 ,__subvSI3, __subvsi3): Likewise. (__subvDI3 __mulvSI3, __mulvsi3, __negvSI2): Likewise. (__negvsi2, __negvDI2): Likewise. (__cmpdi2, __ucmpdi2): Adjust implementation to improve generated code. * libgcc2.h (__ucmpdi2): Adjust prototype. --- libgcc/libgcc2.c | 82 ++++++++++++++++++++------------------------------------ libgcc/libgcc2.h | 2 +- 2 files changed, 30 insertions(+), 54 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index e0a9fd7..4e4defb 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -75,9 +75,9 @@ __negdi2 (DWtype u) Wtype __addvSI3 (Wtype a, Wtype b) { - const Wtype w = (UWtype) a + (UWtype) b; + Wtype w; - if (b >= 0 ? w < a : w > a) + if (__builtin_add_overflow(a, b, &w)) abort (); return w; @@ -86,9 +86,9 @@ __addvSI3 (Wtype a, Wtype b) SItype __addvsi3 (SItype a, SItype b) { - const SItype w = (USItype) a + (USItype) b; + SItype w; - if (b >= 0 ? w < a : w > a) + if (__builtin_add_overflow(a, b, &w)) abort (); return w; @@ -100,9 +100,9 @@ __addvsi3 (SItype a, SItype b) DWtype __addvDI3 (DWtype a, DWtype b) { - const DWtype w = (UDWtype) a + (UDWtype) b; + DWtype w; - if (b >= 0 ? w < a : w > a) + if (__builtin_add_overflow(a, b, &w)) abort (); return w; @@ -113,9 +113,9 @@ __addvDI3 (DWtype a, DWtype b) Wtype __subvSI3 (Wtype a, Wtype b) { - const Wtype w = (UWtype) a - (UWtype) b; + Wtype w; - if (b >= 0 ? w > a : w < a) + if (__builtin_sub_overflow(a, b, &w)) abort (); return w; @@ -124,9 +124,9 @@ __subvSI3 (Wtype a, Wtype b) SItype __subvsi3 (SItype a, SItype b) { - const SItype w = (USItype) a - (USItype) b; + SItype w; - if (b >= 0 ? w > a : w < a) + if (__builtin_sub_overflow(a, b, &w)) abort (); return w; @@ -138,9 +138,9 @@ __subvsi3 (SItype a, SItype b) DWtype __subvDI3 (DWtype a, DWtype b) { - const DWtype w = (UDWtype) a - (UDWtype) b; + DWtype w; - if (b >= 0 ? w > a : w < a) + if (__builtin_sub_overflow(a, b, &w)) abort (); return w; @@ -151,22 +151,20 @@ __subvDI3 (DWtype a, DWtype b) Wtype __mulvSI3 (Wtype a, Wtype b) { - const DWtype w = (DWtype) a * (DWtype) b; + Wtype w; - if ((Wtype) (w >> W_TYPE_SIZE) != (Wtype) w >> (W_TYPE_SIZE - 1)) + if (__builtin_mul_overflow(a, b, &w)) abort (); return w; } #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC -#undef WORD_SIZE -#define WORD_SIZE (sizeof (SItype) * __CHAR_BIT__) SItype __mulvsi3 (SItype a, SItype b) { - const DItype w = (DItype) a * (DItype) b; + SItype w; - if ((SItype) (w >> WORD_SIZE) != (SItype) w >> (WORD_SIZE-1)) + if (__builtin_mul_overflow(a, b, &w)) abort (); return w; @@ -178,23 +176,23 @@ __mulvsi3 (SItype a, SItype b) Wtype __negvSI2 (Wtype a) { - const Wtype w = -(UWtype) a; + Wtype w; - if (a >= 0 ? w > 0 : w < 0) + if (__builtin_sub_overflow(0, a, &w)) abort (); - return w; + return w; } #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC SItype __negvsi2 (SItype a) { - const SItype w = -(USItype) a; + SItype w; - if (a >= 0 ? w > 0 : w < 0) + if (__builtin_sub_overflow(0, a, &w)) abort (); - return w; + return w; } #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */ #endif @@ -203,9 +201,9 @@ __negvsi2 (SItype a) DWtype __negvDI2 (DWtype a) { - const DWtype w = -(UDWtype) a; + DWtype w; - if (a >= 0 ? w > 0 : w < 0) + if (__builtin_sub_overflow(0, a, &w)) abort (); return w; @@ -953,7 +951,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) aligns the divisor under the dividend and then perform number of test-subtract iterations which shift the dividend left. Number of iterations is k + 1 where k is the number of bit positions the - divisor must be shifted left to align it under the dividend. + divisor must be shifted left to align it under the dividend. quotient bits can be saved in the rightmost positions of the dividend as it shifts left on each test-subtract iteration. */ @@ -965,7 +963,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) k = lz1 - lz2; y = (y << k); - /* Dividend can exceed 2 ^ (width − 1) − 1 but still be less than the + /* Dividend can exceed 2 ^ (width - 1) - 1 but still be less than the aligned divisor. Normal iteration can drops the high order bit of the dividend. Therefore, first test-subtract iteration is a special case, saving its quotient bit in a separate location and @@ -1325,37 +1323,15 @@ __udivdi3 (UDWtype n, UDWtype d) cmp_return_type __cmpdi2 (DWtype a, DWtype b) { - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - if ((UWtype) au.s.low < (UWtype) bu.s.low) - return 0; - else if ((UWtype) au.s.low > (UWtype) bu.s.low) - return 2; - return 1; + return (a > b) - (a < b) + 1; } #endif #ifdef L_ucmpdi2 cmp_return_type -__ucmpdi2 (DWtype a, DWtype b) +__ucmpdi2 (UDWtype a, UDWtype b) { - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; - - if ((UWtype) au.s.high < (UWtype) bu.s.high) - return 0; - else if ((UWtype) au.s.high > (UWtype) bu.s.high) - return 2; - if ((UWtype) au.s.low < (UWtype) bu.s.low) - return 0; - else if ((UWtype) au.s.low > (UWtype) bu.s.low) - return 2; - return 1; + return (a > b) - (a < b) + 1; } #endif diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h index 1c20ffc..22a2706 100644 --- a/libgcc/libgcc2.h +++ b/libgcc/libgcc2.h @@ -402,7 +402,7 @@ extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype); #endif extern cmp_return_type __cmpdi2 (DWtype, DWtype); -extern cmp_return_type __ucmpdi2 (DWtype, DWtype); +extern cmp_return_type __ucmpdi2 (UDWtype, UDWtype); #if MIN_UNITS_PER_WORD > 1 extern SItype __bswapsi2 (SItype); -- cgit v1.1 From 831f24a778a016c6ce1ae739235e3f7e1f28ed8c Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Tue, 10 Nov 2020 09:07:24 -0700 Subject: Fix minor whitespace issues libgcc/ * libgcc2.c: Fix whitespace issues in most recent change. --- libgcc/libgcc2.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index 4e4defb..cf0ca29 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -77,7 +77,7 @@ __addvSI3 (Wtype a, Wtype b) { Wtype w; - if (__builtin_add_overflow(a, b, &w)) + if (__builtin_add_overflow (a, b, &w)) abort (); return w; @@ -88,7 +88,7 @@ __addvsi3 (SItype a, SItype b) { SItype w; - if (__builtin_add_overflow(a, b, &w)) + if (__builtin_add_overflow (a, b, &w)) abort (); return w; @@ -102,7 +102,7 @@ __addvDI3 (DWtype a, DWtype b) { DWtype w; - if (__builtin_add_overflow(a, b, &w)) + if (__builtin_add_overflow (a, b, &w)) abort (); return w; @@ -115,7 +115,7 @@ __subvSI3 (Wtype a, Wtype b) { Wtype w; - if (__builtin_sub_overflow(a, b, &w)) + if (__builtin_sub_overflow (a, b, &w)) abort (); return w; @@ -126,7 +126,7 @@ __subvsi3 (SItype a, SItype b) { SItype w; - if (__builtin_sub_overflow(a, b, &w)) + if (__builtin_sub_overflow (a, b, &w)) abort (); return w; @@ -140,7 +140,7 @@ __subvDI3 (DWtype a, DWtype b) { DWtype w; - if (__builtin_sub_overflow(a, b, &w)) + if (__builtin_sub_overflow (a, b, &w)) abort (); return w; @@ -153,7 +153,7 @@ __mulvSI3 (Wtype a, Wtype b) { Wtype w; - if (__builtin_mul_overflow(a, b, &w)) + if (__builtin_mul_overflow (a, b, &w)) abort (); return w; @@ -164,7 +164,7 @@ __mulvsi3 (SItype a, SItype b) { SItype w; - if (__builtin_mul_overflow(a, b, &w)) + if (__builtin_mul_overflow (a, b, &w)) abort (); return w; @@ -178,7 +178,7 @@ __negvSI2 (Wtype a) { Wtype w; - if (__builtin_sub_overflow(0, a, &w)) + if (__builtin_sub_overflow (0, a, &w)) abort (); return w; @@ -189,7 +189,7 @@ __negvsi2 (SItype a) { SItype w; - if (__builtin_sub_overflow(0, a, &w)) + if (__builtin_sub_overflow (0, a, &w)) abort (); return w; @@ -203,7 +203,7 @@ __negvDI2 (DWtype a) { DWtype w; - if (__builtin_sub_overflow(0, a, &w)) + if (__builtin_sub_overflow (0, a, &w)) abort (); return w; -- cgit v1.1 From bb6226419f566bb9f68d9f2dc7d3aca501efaa98 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 11 Nov 2020 00:16:36 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index fa70f2f7..4cc579f 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,17 @@ +2020-11-10 Jeff Law + + * libgcc2.c: Fix whitespace issues in most recent change. + +2020-11-10 Stefan Kanthak + + * libgcc2.c (__addvSI3): Use overflow builtins. + (__addvsi3, __addvDI3 ,__subvSI3, __subvsi3): Likewise. + (__subvDI3 __mulvSI3, __mulvsi3, __negvSI2): Likewise. + (__negvsi2, __negvDI2): Likewise. + (__cmpdi2, __ucmpdi2): Adjust implementation to improve + generated code. + * libgcc2.h (__ucmpdi2): Adjust prototype. + 2020-11-03 Pat Bernardi Olivier Hainque -- cgit v1.1 From c746fc40f4ec8cfc1092efd49d567751858d2099 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Sun, 15 Nov 2020 21:03:06 +0000 Subject: MSP430: Fix inconsistent naming of hwmult libfuncs The naming scheme used by GCC to reference MSP430 hardware multiply library functions is inconsistent. Sometimes the "GCC" names (e.g. mulsi2) are used, other times the "MSPABI" names (e.g. __mspabi_mpyl) are used. Also, sometimes an identifier for the hardware multiply support is appended to the GCC name, when the functions are defined, but this is not required. This patch fixes those issues, so the names used to refer to the hardware multiply library functions follow a consistent pattern. gcc/ChangeLog: * config/msp430/msp430.c (msp430_output_labelref): Don't process mspabi hwmult library function names into GCC-style names. libgcc/ChangeLog: * config/msp430/lib2hw_mul.S: Omit _hw* suffix from GCC names for hwmult library functions. gcc/testsuite/ChangeLog: * gcc.target/msp430/rtx-cost-Os-f5series.c: Adjust test to use new hwmult library function name. --- libgcc/config/msp430/lib2hw_mul.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libgcc') diff --git a/libgcc/config/msp430/lib2hw_mul.S b/libgcc/config/msp430/lib2hw_mul.S index de840d9..0fbafcd 100644 --- a/libgcc/config/msp430/lib2hw_mul.S +++ b/libgcc/config/msp430/lib2hw_mul.S @@ -353,9 +353,9 @@ mult1632 MPY, OP2, RESLO, RESHI end_func __umulhisi2 - start_func __mulsi2_hw32 __mspabi_mpyl __mspabi_mpyl_hw32 + start_func __mulsi2 __mspabi_mpyl __mspabi_mpyl_hw32 mult32_hw MPY32L, MPY32H, OP2L, OP2H, RES0, RES1 - end_func __mulsi2_hw32 + end_func __mulsi2 start_func __mulsidi2 __mspabi_mpysll __mspabi_mpysll_hw32 mult3264_hw MPYS32L, MPYS32H, OP2L, OP2H, RES0, RES1, RES2, RES3 @@ -373,9 +373,9 @@ as the second generation hardware, but they are accessed from different memory registers. */ - start_func __mulhi2_f5 __mspabi_mpyi __mspabi_mpyi_f5hw + start_func __mulhi2 __mspabi_mpyi __mspabi_mpyi_f5hw mult16 MPY_F5, OP2_F5, RESLO_F5 - end_func __mulhi2_f5 + end_func __mulhi2 start_func __mulhisi2 __mspabi_mpysl __mspabi_mpysl_f5hw mult1632 MPYS_F5, OP2_F5, RESLO_F5, RESHI_F5 @@ -385,9 +385,9 @@ mult1632 MPY_F5, OP2_F5, RESLO_F5, RESHI_F5 end_func __umulhisi2 - start_func __mulsi2_f5 __mspabi_mpyl __mspabi_mpyl_f5hw + start_func __mulsi2 __mspabi_mpyl __mspabi_mpyl_f5hw mult32_hw MPY32L_F5, MPY32H_F5, OP2L_F5, OP2H_F5, RES0_F5, RES1_F5 - end_func __mulsi2_f5 + end_func __mulsi2 start_func __mulsidi2 __mspabi_mpysll __mspabi_mpysll_f5hw mult3264_hw MPYS32L_F5, MPYS32H_F5, OP2L_F5, OP2H_F5, RES0_F5, RES1_F5, RES2_F5, RES3_F5 -- cgit v1.1 From cba306519ce803c55d298c8d972109de602b19c6 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Mon, 16 Nov 2020 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 4cc579f..7836cdd 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2020-11-15 Jozef Lawrynowicz + + * config/msp430/lib2hw_mul.S: Omit _hw* suffix from GCC names for + hwmult library functions. + 2020-11-10 Jeff Law * libgcc2.c: Fix whitespace issues in most recent change. -- cgit v1.1 From 948ef14225368651f2f4fe1fccb6b6704affc9fa Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 10 Nov 2020 21:45:58 +1030 Subject: [RS6000] Use LIB2_SIDITI_CONV_FUNCS in place of ppc64-fp.c This patch retires ppc64-fp.c in favour of using "LIB2_SIDITI_CONV_FUNCS = yes", which is a lot better solution than having a copy of selected libgcc2.c functions. * config/rs6000/t-ppc64-fp (LIB2ADD): Delete. (LIB2_SIDITI_CONV_FUNCS): Define. * config/rs6000/ppc64-fp.c: Delete file. --- libgcc/config/rs6000/ppc64-fp.c | 237 ---------------------------------------- libgcc/config/rs6000/t-ppc64-fp | 3 +- 2 files changed, 1 insertion(+), 239 deletions(-) delete mode 100644 libgcc/config/rs6000/ppc64-fp.c (limited to 'libgcc') diff --git a/libgcc/config/rs6000/ppc64-fp.c b/libgcc/config/rs6000/ppc64-fp.c deleted file mode 100644 index 9ca3c71..0000000 --- a/libgcc/config/rs6000/ppc64-fp.c +++ /dev/null @@ -1,237 +0,0 @@ -/* Functions needed for soft-float on powerpc64-linux, copied from - libgcc2.c with macros expanded to force the use of specific types. - - Copyright (C) 1989-2020 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 -. */ - -#if defined(__powerpc64__) || defined (__64BIT__) || defined(__ppc64__) -#define TMODES -#include "fp-bit.h" - -extern DItype __fixtfdi (TFtype); -extern DItype __fixdfdi (DFtype); -extern DItype __fixsfdi (SFtype); -extern USItype __fixunsdfsi (DFtype); -extern USItype __fixunssfsi (SFtype); -extern TFtype __floatditf (DItype); -extern TFtype __floatunditf (UDItype); -extern DFtype __floatdidf (DItype); -extern DFtype __floatundidf (UDItype); -extern SFtype __floatdisf (DItype); -extern SFtype __floatundisf (UDItype); -extern DItype __fixunstfdi (TFtype); - -static DItype local_fixunssfdi (SFtype); -static DItype local_fixunsdfdi (DFtype); - -DItype -__fixtfdi (TFtype a) -{ - if (a < 0) - return - __fixunstfdi (-a); - return __fixunstfdi (a); -} - -DItype -__fixdfdi (DFtype a) -{ - if (a < 0) - return - local_fixunsdfdi (-a); - return local_fixunsdfdi (a); -} - -DItype -__fixsfdi (SFtype a) -{ - if (a < 0) - return - local_fixunssfdi (-a); - return local_fixunssfdi (a); -} - -USItype -__fixunsdfsi (DFtype a) -{ - if (a >= - (DFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) - return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) - - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1); - return (SItype) a; -} - -USItype -__fixunssfsi (SFtype a) -{ - if (a >= - (SFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) - return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) - - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1); - return (SItype) a; -} - -TFtype -__floatditf (DItype u) -{ - DFtype dh, dl; - - dh = (SItype) (u >> (sizeof (SItype) * 8)); - dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); - dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); - - return (TFtype) dh + (TFtype) dl; -} - -TFtype -__floatunditf (UDItype u) -{ - DFtype dh, dl; - - dh = (USItype) (u >> (sizeof (SItype) * 8)); - dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); - dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); - - return (TFtype) dh + (TFtype) dl; -} - -DFtype -__floatdidf (DItype u) -{ - DFtype d; - - d = (SItype) (u >> (sizeof (SItype) * 8)); - d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); - d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); - - return d; -} - -DFtype -__floatundidf (UDItype u) -{ - DFtype d; - - d = (USItype) (u >> (sizeof (SItype) * 8)); - d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); - d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); - - return d; -} - -SFtype -__floatdisf (DItype u) -{ - DFtype f; - - if (53 < (sizeof (DItype) * 8) - && 53 > ((sizeof (DItype) * 8) - 53 + 24)) - { - if (! (- ((DItype) 1 << 53) < u - && u < ((DItype) 1 << 53))) - { - if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1)) - { - u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1); - u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53)); - } - } - } - f = (SItype) (u >> (sizeof (SItype) * 8)); - f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); - f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); - - return (SFtype) f; -} - -SFtype -__floatundisf (UDItype u) -{ - DFtype f; - - if (53 < (sizeof (DItype) * 8) - && 53 > ((sizeof (DItype) * 8) - 53 + 24)) - { - if (u >= ((UDItype) 1 << 53)) - { - if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1)) - { - u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1); - u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53)); - } - } - } - f = (USItype) (u >> (sizeof (SItype) * 8)); - f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); - f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); - - return (SFtype) f; -} - -DItype -__fixunstfdi (TFtype a) -{ - if (a < 0) - return 0; - - /* Compute high word of result, as a flonum. */ - const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8))); - /* Convert that to fixed (but not to DItype!), - and shift it into the high word. */ - UDItype v = (USItype) b; - v <<= (sizeof (SItype) * 8); - /* Remove high part from the TFtype, leaving the low part as flonum. */ - a -= (TFtype) v; - /* Convert that to fixed (but not to DItype!) and add it in. - Sometimes A comes out negative. This is significant, since - A has more bits than a long int does. */ - if (a < 0) - v -= (USItype) (-a); - else - v += (USItype) a; - return v; -} - -/* This version is needed to prevent recursion; fixunsdfdi in libgcc - calls fixdfdi, which in turn calls calls fixunsdfdi. */ - -static DItype -local_fixunsdfdi (DFtype a) -{ - USItype hi, lo; - - hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); - lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); - return ((UDItype) hi << (sizeof (SItype) * 8)) | lo; -} - -/* This version is needed to prevent recursion; fixunssfdi in libgcc - calls fixsfdi, which in turn calls calls fixunssfdi. */ - -static DItype -local_fixunssfdi (SFtype original_a) -{ - DFtype a = original_a; - USItype hi, lo; - - hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); - lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); - return ((UDItype) hi << (sizeof (SItype) * 8)) | lo; -} - -#endif /* __powerpc64__ */ diff --git a/libgcc/config/rs6000/t-ppc64-fp b/libgcc/config/rs6000/t-ppc64-fp index 26d1730..999679f 100644 --- a/libgcc/config/rs6000/t-ppc64-fp +++ b/libgcc/config/rs6000/t-ppc64-fp @@ -1,2 +1 @@ -# Can be used unconditionally, wrapped in __powerpc64__ || __64BIT__ __ppc64__. -LIB2ADD += $(srcdir)/config/rs6000/ppc64-fp.c +LIB2_SIDITI_CONV_FUNCS = yes -- cgit v1.1 From 29c5d9ceb9bf7416b6f6b976879ac0dc60701904 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 17 Nov 2020 00:16:27 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 7836cdd..3f3ec99 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2020-11-17 Alan Modra + + * config/rs6000/t-ppc64-fp (LIB2ADD): Delete. + (LIB2_SIDITI_CONV_FUNCS): Define. + * config/rs6000/ppc64-fp.c: Delete file. + 2020-11-15 Jozef Lawrynowicz * config/msp430/lib2hw_mul.S: Omit _hw* suffix from GCC names for -- cgit v1.1 From bf7b94d40739428fda3d798b4add833054f7d012 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Sun, 15 Nov 2020 21:03:14 +0000 Subject: MSP430: Add 64-bit hardware multiply support Hardware multipliers that support widening 32-bit multiplication can be used to perform a 64-bit * 64-bit multiplication more efficiently than a software implementation. The following equation is used to perform 64-bit multiplication for devices with "32bit" or "f5series" hardware multiply versions: 64bit_result = (low32_op0 * lop32_op1) + ((low32_op0 * high32_op1) << 32) + ((high32_op0 * low32_op1) << 32) libgcc/ChangeLog: * config/msp430/lib2hw_mul.S (mult64_hw): New. (if MUL_32): Use mult64_hw for __muldi3. (if MUL_F5): Use mult64_hw for __muldi3. * config/msp430/lib2mul.c (__muldi3): New. * config/msp430/t-msp430 (LIB2FUNCS_EXCLUDE): Define. --- libgcc/config/msp430/lib2hw_mul.S | 77 +++++++++++++++++++++++++++++++++++++-- libgcc/config/msp430/lib2mul.c | 52 ++++++++++++++++++++++++++ libgcc/config/msp430/t-msp430 | 5 +++ 3 files changed, 130 insertions(+), 4 deletions(-) (limited to 'libgcc') diff --git a/libgcc/config/msp430/lib2hw_mul.S b/libgcc/config/msp430/lib2hw_mul.S index 0fbafcd..855dcd8 100644 --- a/libgcc/config/msp430/lib2hw_mul.S +++ b/libgcc/config/msp430/lib2hw_mul.S @@ -207,6 +207,73 @@ MOV.W &\RES3, R15 ; Ready high 16-bits for return .endm +.macro mult64_hw MPY32_LO MPY32_HI OP2_LO OP2_HI RES0 RES1 RES2 RES3 +;* * 64-bit hardware multiply with a 64-bit result +;* int64 = int64 * int64 +;* +;* - Operand 1 is in R8, R9, R10, R11 +;* - Operand 2 is in R12, R13, R14, R15 +;* - Result is in R12, R13, R14, R15 +;* +;* 64-bit multiplication is achieved using the 32-bit hardware multiplier with +;* the following equation: +;* R12:R15 = (R8:R9 * R12:R13) + ((R8:R9 * R14:R15) << 32) + ((R10:R11 * R12:R13) << 32) +;* +;* The left shift by 32 is handled with minimal cost by saving the two low +;* words and discarding the two high words. +;* +;* To ensure that the multiply is performed atomically, interrupts are +;* disabled upon routine entry. Interrupt state is restored upon exit. +;* +;* Registers used: R6, R7, R8, R9, R10, R11, R12, R13, R14, R15 +;* +;* Macro arguments are the memory locations of the hardware registers. +;* +#if defined(__MSP430X_LARGE__) + PUSHM.A #5, R10 +#elif defined(__MSP430X__) + PUSHM.W #5, R10 +#else + PUSH R10 { PUSH R9 { PUSH R8 { PUSH R7 { PUSH R6 +#endif + ; Multiply the low 32-bits of op0 and the high 32-bits of op1. + MOV.W R8, &\MPY32_LO + MOV.W R9, &\MPY32_HI + MOV.W R14, &\OP2_LO + MOV.W R15, &\OP2_HI + ; Save the low 32-bits of the result. + MOV.W &\RES0, R6 + MOV.W &\RES1, R7 + ; Multiply the high 32-bits of op0 and the low 32-bits of op1. + MOV.W R10, &\MPY32_LO + MOV.W R11, &\MPY32_HI + MOV.W R12, &\OP2_LO + MOV.W R13, &\OP2_HI + ; Add the low 32-bits of the result to the previously saved result. + ADD.W &\RES0, R6 + ADDC.W &\RES1, R7 + ; Multiply the low 32-bits of op0 and op1. + MOV.W R8, &\MPY32_LO + MOV.W R9, &\MPY32_HI + MOV.W R12, &\OP2_LO + MOV.W R13, &\OP2_HI + ; Write the return values + MOV.W &\RES0, R12 + MOV.W &\RES1, R13 + MOV.W &\RES2, R14 + MOV.W &\RES3, R15 + ; Add the saved low 32-bit results from earlier to the high 32-bits of + ; this result, effectively shifting those two results left by 32 bits. + ADD.W R6, R14 + ADDC.W R7, R15 +#if defined(__MSP430X_LARGE__) + POPM.A #5, R10 +#elif defined(__MSP430X__) + POPM.W #5, R10 +#else + POP R6 { POP R7 { POP R8 { POP R9 { POP R10 +#endif +.endm ;; EABI mandated names: ;; @@ -365,8 +432,9 @@ mult3264_hw MPY32L, MPY32H, OP2L, OP2H, RES0, RES1, RES2, RES3 end_func __umulsidi2 - ;; FIXME: Add a hardware version of this function. - fake_func __muldi3 __mspabi_mpyll __mspabi_mpyll_hw32 + start_func __muldi3 __mspabi_mpyll __mspabi_mpyll_hw32 + mult64_hw MPY32L, MPY32H, OP2L, OP2H, RES0, RES1, RES2, RES3 + end_func __muldi3 #elif defined MUL_F5 /* The F5xxx series of MCUs support the same 16-bit and 32-bit multiply @@ -397,8 +465,9 @@ mult3264_hw MPY32L_F5, MPY32H_F5, OP2L_F5, OP2H_F5, RES0_F5, RES1_F5, RES2_F5, RES3_F5 end_func __umulsidi2 - ;; FIXME: Add a hardware version of this function. - fake_func __muldi3 __mspabi_mpyll __mspabi_mpyll_f5hw + start_func __muldi3 __mspabi_mpyll __mspabi_mpyll_f5hw + mult64_hw MPY32L_F5, MPY32H_F5, OP2L_F5, OP2H_F5, RES0_F5, RES1_F5, RES2_F5, RES3_F5 + end_func __muldi3 #else #error MUL type not defined diff --git a/libgcc/config/msp430/lib2mul.c b/libgcc/config/msp430/lib2mul.c index 955e7bb..ca022b9 100644 --- a/libgcc/config/msp430/lib2mul.c +++ b/libgcc/config/msp430/lib2mul.c @@ -30,6 +30,58 @@ typedef unsigned int uint08_type __attribute__ ((mode (QI))); #define C3B(a,b,c) a##b##c #define C3(a,b,c) C3B(a,b,c) +#if defined (MUL_NONE) || defined (MUL_16) +/* __muldi3 must be excluded from libgcc.a to prevent multiple-definition + errors for the hwmult configurations that have their own definition. + However, for MUL_NONE and MUL_16, the software version is still required, so + the necessary preprocessed output from libgcc2.c to compile that + software version of __muldi3 is below. */ +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef int SItype __attribute__ ((mode (SI))); +struct DWstruct {SItype low, high;}; + +typedef union +{ + struct DWstruct s; + DItype ll; +} DWunion; + +DItype __muldi3 (DItype u, DItype v); + +DItype +__muldi3 (DItype u, DItype v) +{ + const DWunion uu = {.ll = u}; + const DWunion vv = {.ll = v}; + /* The next block of code is expanded from the following line: + DWunion w = {.ll = __umulsidi3 (uu.s.low, vv.s.low)}; */ + DWunion w; + USItype __x0, __x1, __x2, __x3; + USItype __ul, __vl, __uh, __vh; + __ul = ((USItype) (uu.s.low) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); + __uh = ((USItype) (uu.s.low) >> ((4 * 8) / 2)); + __vl = ((USItype) (vv.s.low) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); + __vh = ((USItype) (vv.s.low) >> ((4 * 8) / 2)); + __x0 = (USItype) __ul * __vl; + __x1 = (USItype) __ul * __vh; + __x2 = (USItype) __uh * __vl; + __x3 = (USItype) __uh * __vh; + __x1 += ((USItype) (__x0) >> ((4 * 8) / 2)); + __x1 += __x2; + if (__x1 < __x2) + __x3 += ((USItype) 1 << ((4 * 8) / 2)); + (w.s.high) = __x3 + ((USItype) (__x1) >> ((4 * 8) / 2)); + (w.s.low) = ((USItype) (__x1) & (((USItype) 1 << ((4 * 8) / 2)) - 1)) + * ((USItype) 1 << ((4 * 8) / 2)) + + ((USItype) (__x0) & (((USItype) 1 << ((4 * 8) / 2)) - 1)); + + w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high + + (USItype) uu.s.high * (USItype) vv.s.low); + return w.ll; +} +#endif + #if defined MUL_NONE /* The software multiply library needs __mspabi_mpyll. */ diff --git a/libgcc/config/msp430/t-msp430 b/libgcc/config/msp430/t-msp430 index be56e88..9a79b5b 100644 --- a/libgcc/config/msp430/t-msp430 +++ b/libgcc/config/msp430/t-msp430 @@ -40,6 +40,11 @@ LIB2ADD = \ $(srcdir)/config/msp430/floathisf.c \ $(srcdir)/config/msp430/cmpd.c +# 32-bit and F5series hardware multiply have their own version of this function. +# To handle the case when there is no hardware multiply or only 16-bit hardware +# multiply, the libgcc version has been copied to lib2mul.c. +LIB2FUNCS_EXCLUDE += _muldi3 + HOST_LIBGCC2_CFLAGS += -Os -ffunction-sections -fdata-sections -mhwmult=none crtbegin_no_eh.o: $(srcdir)/crtstuff.c -- cgit v1.1 From 25bb75f841c552cfd27a4344b7487efbe35b4481 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 19 Nov 2020 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 3f3ec99..7ebed64 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,11 @@ +2020-11-18 Jozef Lawrynowicz + + * config/msp430/lib2hw_mul.S (mult64_hw): New. + (if MUL_32): Use mult64_hw for __muldi3. + (if MUL_F5): Use mult64_hw for __muldi3. + * config/msp430/lib2mul.c (__muldi3): New. + * config/msp430/t-msp430 (LIB2FUNCS_EXCLUDE): Define. + 2020-11-17 Alan Modra * config/rs6000/t-ppc64-fp (LIB2ADD): Delete. -- cgit v1.1 From f50c417a036697eccfad5a1d6ce777246c77635a Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Fri, 20 Nov 2020 21:11:22 +0000 Subject: NetBSD/libgcc: Check for TARGET_DL_ITERATE_PHDR in the unwinder Disable USE_PT_GNU_EH_FRAME frame unwinder support for old OS versions, fixing compilation errors: .../libgcc/unwind-dw2-fde-dip.c:75:21: error: unknown type name 'Elf_Phdr' 75 | # define ElfW(type) Elf_##type | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:132:9: note: in expansion of macro 'ElfW' 132 | const ElfW(Phdr) *p_eh_frame_hdr; | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:75:21: error: unknown type name 'Elf_Phdr' 75 | # define ElfW(type) Elf_##type | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:133:9: note: in expansion of macro 'ElfW' 133 | const ElfW(Phdr) *p_dynamic; | ^~~~ .../libgcc/unwind-dw2-fde-dip.c:165:37: warning: 'struct dl_phdr_info' declared inside parameter list will not be visible outside of this definition or declaration 165 | _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr) | ^~~~~~~~~~~~ [...] and producing a working cross-compiler at least with VAX/NetBSD 1.6.2. libgcc/ * unwind-dw2-fde-dip.c [__OpenBSD__ || __NetBSD__] (USE_PT_GNU_EH_FRAME): Do not define if !TARGET_DL_ITERATE_PHDR. --- libgcc/unwind-dw2-fde-dip.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libgcc') diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c index 6e50405..e60c9fe 100644 --- a/libgcc/unwind-dw2-fde-dip.c +++ b/libgcc/unwind-dw2-fde-dip.c @@ -71,6 +71,7 @@ #endif #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ + && defined(TARGET_DL_ITERATE_PHDR) \ && (defined(__OpenBSD__) || defined(__NetBSD__)) # define ElfW(type) Elf_##type # define USE_PT_GNU_EH_FRAME -- cgit v1.1 From 82e5048e70ef790559ba768132b4afd266a30fee Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 21 Nov 2020 00:16:29 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 7ebed64..62a6914 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2020-11-20 Maciej W. Rozycki + + * unwind-dw2-fde-dip.c [__OpenBSD__ || __NetBSD__] + (USE_PT_GNU_EH_FRAME): Do not define if !TARGET_DL_ITERATE_PHDR. + 2020-11-18 Jozef Lawrynowicz * config/msp430/lib2hw_mul.S (mult64_hw): New. -- cgit v1.1 From 4919ed711c1d02845f2843f6b0a70c27f9e6d434 Mon Sep 17 00:00:00 2001 From: Stefan Kanthak Date: Wed, 25 Nov 2020 11:36:51 -0700 Subject: Improve abs with overflow implementations libgcc/ * libgcc2.c (absvSI2): Simplify/improve implementation by using builtin_add_overflow. (absvsi2, absvDI2): Likewise. --- libgcc/libgcc2.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index cf0ca29..1921d80 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -214,37 +214,25 @@ __negvDI2 (DWtype a) Wtype __absvSI2 (Wtype a) { - Wtype w = a; - - if (a < 0) -#ifdef L_negvsi2 - w = __negvSI2 (a); -#else - w = -(UWtype) a; + const Wtype v = 0 - (a < 0); + Wtype w; - if (w < 0) + if (__builtin_add_overflow (a, v, &w)) abort (); -#endif - return w; + return v ^ w; } #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC SItype __absvsi2 (SItype a) { - SItype w = a; - - if (a < 0) -#ifdef L_negvsi2 - w = __negvsi2 (a); -#else - w = -(USItype) a; + const SItype v = 0 - (a < 0); + SItype w; - if (w < 0) + if (__builtin_add_overflow (a, v, &w)) abort (); -#endif - return w; + return v ^ w; } #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */ #endif @@ -253,19 +241,13 @@ __absvsi2 (SItype a) DWtype __absvDI2 (DWtype a) { - DWtype w = a; - - if (a < 0) -#ifdef L_negvdi2 - w = __negvDI2 (a); -#else - w = -(UDWtype) a; + const DWtype v = 0 - (a < 0); + DWtype w; - if (w < 0) + if (__builtin_add_overflow (a, v, &w)) abort (); -#endif - return w; + return v ^ w; } #endif -- cgit v1.1 From 360258daf5d8d56fa4e1707aef27028546039401 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 26 Nov 2020 00:16:41 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 62a6914..6127fbf 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2020-11-25 Stefan Kanthak + + * libgcc2.c (absvSI2): Simplify/improve implementation by using + builtin_add_overflow. + (absvsi2, absvDI2): Likewise. + 2020-11-20 Maciej W. Rozycki * unwind-dw2-fde-dip.c [__OpenBSD__ || __NetBSD__] -- cgit v1.1 From a8ae23920f9c954ed66bd92ddbdbb1b8486b950f Mon Sep 17 00:00:00 2001 From: Stefan Kanthak Date: Sun, 29 Nov 2020 18:05:46 -0700 Subject: fixed _bswapsi2 function libgcc * libgcc2.c (bswapsi2): Make constants unsigned. --- libgcc/libgcc2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libgcc') diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index 1921d80..61de3b4 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -468,10 +468,10 @@ __ashrdi3 (DWtype u, shift_count_type b) SItype __bswapsi2 (SItype u) { - return ((((u) & 0xff000000) >> 24) - | (((u) & 0x00ff0000) >> 8) - | (((u) & 0x0000ff00) << 8) - | (((u) & 0x000000ff) << 24)); + return ((((u) & 0xff000000u) >> 24) + | (((u) & 0x00ff0000u) >> 8) + | (((u) & 0x0000ff00u) << 8) + | (((u) & 0x000000ffu) << 24)); } #endif #ifdef L_bswapdi2 -- cgit v1.1 From 94358e4770e6e4c52f101f8f74fdc27187fd0050 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Tue, 1 Dec 2020 00:16:38 +0000 Subject: Daily bump. --- libgcc/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 6127fbf..20b77fd 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,7 @@ +2020-11-30 Stefan Kanthak + + * libgcc2.c (bswapsi2): Make constants unsigned. + 2020-11-25 Stefan Kanthak * libgcc2.c (absvSI2): Simplify/improve implementation by using -- cgit v1.1 From c05ece92c6153289fd6055e31e791e59b8ac4121 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Wed, 2 Dec 2020 22:10:32 -0300 Subject: introduce overridable clear_cache emitter This patch introduces maybe_emit_call_builtin___clear_cache for the builtin expander machinery and the trampoline initializers to use to clear the instruction cache, removing a source of inconsistencies and subtle errors in low-level machinery. I've adjusted all trampoline_init implementations that used to issue explicit calls to __clear_cache or similar to use this new primitive. Specifically on vxworks targets, we needed to drop the __clear_cache symbol in libgcc, for reasons related with linking that I didn't need to understand, and we wanted to call cacheTextUpdate directly, despite the different calling conventions: the second argument is a length rather than the end address. So I introduced a target hook to enable target OS-level overriding of builtin __clear_cache call emission, retaining nearly (*) the same logic to govern the decision on whether to emit a call (or nothing, or a machine-dependent insn) but enabling a call to a target system-defined function with different calling conventions to be issued, without having to modify .md files of the various architectures supported by the target system to introduce or modify clear_cache insns. (*) I write "nearly" mainly because, when not optimizing, we'd issue a call regardless, but since the call may now be overridden, I added it to the set of builtins that are not directly turned into calls when not optimizing, following the normal expansion path instead. It wouldn't be hard to skip the emission of cache-clearing insns when not optimizing, but it didn't seem very important, especially for the new uses from trampoline init. Another difference that might be relevant is that now we expand the begin and end arguments unconditionally. This might make a difference if they have side effects. That's prettty much impossible at expand time, but I thought I'd mention it. I have NOT modified targets that did not issue cache-clearing calls in trampoline init to use the new clear_cache-calling infrastructure even if it would expand to nothing. I have considered doing so, to have __builtin___clear_cache and trampoline init call cacheTextUpdate on all vxworks targets, but decided not to, since on targets that don't do any cache clearing, cacheTextUpdate ought to be a no-op, even though rs6000 seems to use icbi and dcbf instructions in the function called to initialize a trampoline, but AFAICT not in the __clear_cache builtin. Hopefully target maintainers will have a look and take advantage of this new piece of infrastructure to remove such (apparent?) inconsistencies. Not rs6000 and other that call asm-coded trampoline setup instructions, for sure, but they might wish to introduce a CLEAR_INSN_CACHE macro or a clear_cache expander if they don't have one. for gcc/ChangeLog * builtins.c (default_emit_call_builtin___clear_cache): New. (maybe_emit_call_builtin___clear_cache): New. (expand_builtin___clear_cache): Split into the above. (expand_builtin): Do not issue clear_cache call any more. * builtins.h (maybe_emit_call_builtin___clear_cache): Declare. * config/aarch64/aarch64.c (aarch64_trampoline_init): Use maybe_emit_call_builtin___clear_cache. * config/arc/arc.c (arc_trampoline_init): Likewise. * config/arm/arm.c (arm_trampoline_init): Likewise. * config/c6x/c6x.c (c6x_initialize_trampoline): Likewise. * config/csky/csky.c (csky_trampoline_init): Likewise. * config/m68k/linux.h (FInALIZE_TRAMPOLINE): Likewise. * config/tilegx/tilegx.c (tilegx_trampoline_init): Likewise. * config/tilepro/tilepro.c (tilepro_trampoline_init): Ditto. * config/vxworks.c: Include rtl.h, memmodel.h, and optabs.h. (vxworks_emit_call_builtin___clear_cache): New. * config/vxworks.h (CLEAR_INSN_CACHE): Drop. (TARGET_EMIT_CALL_BUILTIN___CLEAR_CACHE): Define. * target.def (trampoline_init): In the documentation, refer to maybe_emit_call_builtin___clear_cache. (emit_call_builtin___clear_cache): New. * doc/tm.texi.in: Add new hook point. (CLEAR_CACHE_INSN): Remove duplicate 'both'. * doc/tm.texi: Rebuilt. * targhooks.h (default_meit_call_builtin___clear_cache): Declare. * tree.h (BUILTIN_ASM_NAME_PTR): New. for libgcc/ChangeLog * config/t-vxworks (LIB2ADD): Drop. * config/t-vxworks7 (LIB2ADD): Likewise. * config/vxcache.c: Remove. --- libgcc/config/t-vxworks | 1 - libgcc/config/t-vxworks7 | 1 - libgcc/config/vxcache.c | 35 ----------------------------------- 3 files changed, 37 deletions(-) delete mode 100644 libgcc/config/vxcache.c (limited to 'libgcc') diff --git a/libgcc/config/t-vxworks b/libgcc/config/t-vxworks index 02e2efa..b4bb85b 100644 --- a/libgcc/config/t-vxworks +++ b/libgcc/config/t-vxworks @@ -4,7 +4,6 @@ LIBGCC2_DEBUG_CFLAGS = # We provide our own implementation for __clear_cache, using a # VxWorks specific entry point. LIB2FUNCS_EXCLUDE += _clear_cache -LIB2ADD += $(srcdir)/config/vxcache.c # This ensures that the correct target headers are used; some VxWorks # system headers have names that collide with GCC's internal (host) diff --git a/libgcc/config/t-vxworks7 b/libgcc/config/t-vxworks7 index 20c72f4..6ddd3e8 100644 --- a/libgcc/config/t-vxworks7 +++ b/libgcc/config/t-vxworks7 @@ -4,7 +4,6 @@ LIBGCC2_DEBUG_CFLAGS = # We provide our own implementation for __clear_cache, using a # VxWorks specific entry point. LIB2FUNCS_EXCLUDE += _clear_cache -LIB2ADD += $(srcdir)/config/vxcache.c # This ensures that the correct target headers are used; some VxWorks # system headers have names that collide with GCC's internal (host) diff --git a/libgcc/config/vxcache.c b/libgcc/config/vxcache.c deleted file mode 100644 index e25e0cc..0000000 --- a/libgcc/config/vxcache.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2018-2020 Free Software Foundation, Inc. - Contributed by Alexandre Oliva - -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 -. */ - -/* Instruction cache invalidation routine using VxWorks' cacheLib. */ - -#include -#include - -void -__clear_cache (char *beg __attribute__((__unused__)), - char *end __attribute__((__unused__))) -{ - cacheTextUpdate (beg, end - beg); -} -- cgit v1.1 From 9f1a6501994a2d18ec4fe2a6664637f48021b210 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Thu, 3 Dec 2020 14:50:26 -0500 Subject: PowerPC: PR libgcc/97543 and libgcc/97643, fix long double issues If you use a compiler with long double defaulting to 64-bit instead of 128-bit with IBM extended double, you get linker warnings about mis-matches in the gnu attributes for long double (PR libgcc/97543). Even if the compiler is configured to have long double be 64 bit as the default with the configuration option '--without-long-double-128' you get the warnings. You also get the same issues if you use a compiler with long double defaulting to IEEE 128-bit instead of IBM extended double (PR libgcc/97643). The issue is the way libgcc.a/libgcc.so is built. Right now when building libgcc under Linux, the long double size is set to 128-bits when building libgcc. However, the gnu attributes are set, leading to the warnings. One feature of the current GNU attribute implementation is if you have a shared library (such as libgcc_s.so), the GNU attributes for the shared library is an inclusive OR of all of the objects within the library. This means if any object file that uses the -mlong-double-128 option and uses long double, the GNU attributes for the library will indicate that it uses 128-bit IBM long doubles. If you have a static library, you will get the warning only if you actually reference an object file with the attribute set. This patch does two things: 1) All of the object files that support IBM 128-bit long doubles explicitly set the ABI to IBM extended double. 2) I turned off GNU attributes for building the shared library or for building the IBM 128-bit long double support. libgcc/ 2020-12-03 Michael Meissner PR libgcc/97543 PR libgcc/97643 * config/rs6000/t-linux (IBM128_STATIC_OBJS): New make variable. (IBM128_SHARED_OBJS): New make variable. (IBM128_OBJS): New make variable. Set all objects to use the explicit IBM format, and disable gnu attributes. (IBM128_CFLAGS): New make variable. (gcc_s_compile): Add -mno-gnu-attribute to all shared library modules. --- libgcc/config/rs6000/t-linux | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libgcc') diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux index ed82194..72e9c27 100644 --- a/libgcc/config/rs6000/t-linux +++ b/libgcc/config/rs6000/t-linux @@ -6,3 +6,25 @@ HOST_LIBGCC2_CFLAGS += -mlong-double-128 # smaller and faster libgcc code. Directly specifying -mcmodel=small # would need to take into account targets for which -mcmodel is invalid. HOST_LIBGCC2_CFLAGS += -mno-minimal-toc + +# On the modules that deal with IBM 128-bit values, make sure that TFmode uses +# the IBM extended double format. Also turn off gnu attributes on the static +# modules. +IBM128_STATIC_OBJS = ibm-ldouble$(objext) _powitf2$(objext) \ + ppc64-fp$(objext) _divtc3$(object) _multc3$(object) \ + _fixtfdi$(object) _fixunstfdi$(object) \ + _floatditf$(objext) _floatunsditf$(objext) +IBM128_SHARED_OBJS = $(IBM128_STATIC_OBJS:$(objext):_s$(objext)) +IBM128_OBJS = $(IBM128_STATIC_OBJS) $(IBM128_SHARED_OBJS) + +IBM128_CFLAGS = -Wno-psabi -mabi=ibmlongdouble -mno-gnu-attribute + +$(IBM128_OBJS) : INTERNAL_CFLAGS += $(IBM128_CFLAGS) + +# Turn off gnu attributes for long double size on all of the shared library +# modules, but leave it on for the static modules, except for the functions +# that explicitly process IBM 128-bit floating point. Shared libraries only +# have one gnu attribute for the whole library, and it can lead to warnings if +# somebody changes the long double format. We leave it on for the static +# modules to catch mis-compilation errors. +gcc_s_compile += -mno-gnu-attribute -- cgit v1.1