https://gcc.gnu.org/g:1ba0d18323f4ddacc3dfd218287b7904f80034fe
commit r14-11222-g1ba0d18323f4ddacc3dfd218287b7904f80034fe Author: Georg-Johann Lay <a...@gjlay.de> Date: Thu Jan 16 19:43:27 2025 +0100 AVR: Use INT_N to built-in define __int24. This patch uses the INT_N interface to define __int24 in avr-modes.def. Since the testsuite uses -Wpedantic and __int24 is a C/C++ extension, uses of __int24 and __uint24 is now marked as __extension__. PR target/118329 gcc/ * config/avr/avr-modes.def: Add INT_N (PSI, 24). * config/avr/avr.cc (avr_init_builtin_int24) <__int24>: Remove definition. <__uint24>: Adjust definition to INT_N interface. gcc/testsuite/ * gcc.target/avr/torture/get-mem.c: (__int24, __uint24): Add __extension__ to respective typedefs. * gcc.target/avr/torture/set-mem.c: Same. * gcc.target/avr/torture/int24-mul.c: Same. * gcc.target/avr/torture/pr109907-2.c: Same. * gcc.target/avr/torture/pr61443.c: Same. * gcc.target/avr/torture/pr63633-ice-mult.c: Same. (cherry picked from commit 6580b89957ccabbb5aaf43736b36b9bd399fbc13) Diff: --- gcc/config/avr/avr-modes.def | 1 + gcc/config/avr/avr.cc | 12 +++++++----- gcc/testsuite/gcc.target/avr/torture/get-mem.c | 2 +- gcc/testsuite/gcc.target/avr/torture/int24-mul.c | 9 ++++++--- gcc/testsuite/gcc.target/avr/torture/pr109907-2.c | 2 +- gcc/testsuite/gcc.target/avr/torture/pr61443.c | 16 +++++++++------- gcc/testsuite/gcc.target/avr/torture/pr63633-ice-mult.c | 12 +++++++----- gcc/testsuite/gcc.target/avr/torture/set-mem.c | 2 +- 8 files changed, 33 insertions(+), 23 deletions(-) diff --git a/gcc/config/avr/avr-modes.def b/gcc/config/avr/avr-modes.def index e0633d680d54..6b1c11a40d3b 100644 --- a/gcc/config/avr/avr-modes.def +++ b/gcc/config/avr/avr-modes.def @@ -17,6 +17,7 @@ <http://www.gnu.org/licenses/>. */ FRACTIONAL_INT_MODE (PSI, 24, 3); +INT_N (PSI, 24); /* Make TA and UTA 64 bits wide. 128 bit wide modes would be insane on a 8-bit machine. diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 32b43be1bc35..461776d45c95 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -15651,11 +15651,13 @@ avr_builtin_decl (unsigned id, bool /*initialize_p*/) static void avr_init_builtin_int24 (void) { - tree int24_type = make_signed_type (GET_MODE_BITSIZE (PSImode)); - tree uint24_type = make_unsigned_type (GET_MODE_BITSIZE (PSImode)); - - lang_hooks.types.register_builtin_type (int24_type, "__int24"); - lang_hooks.types.register_builtin_type (uint24_type, "__uint24"); + for (int i = 0; i < NUM_INT_N_ENTS; ++i) + if (int_n_data[i].bitsize == 24) + { + tree uint24_type = int_n_trees[i].unsigned_type; + lang_hooks.types.register_builtin_type (uint24_type, "__uint24"); + break; + } } diff --git a/gcc/testsuite/gcc.target/avr/torture/get-mem.c b/gcc/testsuite/gcc.target/avr/torture/get-mem.c index 46f47f10429e..a71d03aee565 100644 --- a/gcc/testsuite/gcc.target/avr/torture/get-mem.c +++ b/gcc/testsuite/gcc.target/avr/torture/get-mem.c @@ -4,7 +4,7 @@ typedef __INT8_TYPE__ s8; typedef __INT16_TYPE__ s16; -typedef __int24 s24; +__extension__ typedef __int24 s24; typedef __INT32_TYPE__ s32; static const s8 arr8[] = { 12, 23, 34 }; diff --git a/gcc/testsuite/gcc.target/avr/torture/int24-mul.c b/gcc/testsuite/gcc.target/avr/torture/int24-mul.c index 9b29763738cc..98df1d0d3c30 100644 --- a/gcc/testsuite/gcc.target/avr/torture/int24-mul.c +++ b/gcc/testsuite/gcc.target/avr/torture/int24-mul.c @@ -7,7 +7,10 @@ #define __flash /* empty */ #endif -const __flash __int24 vals[] = +__extension__ typedef __uint24 uint24_t; +__extension__ typedef __int24 int24_t; + +const __flash int24_t vals[] = { 0, 1, 2, 3, -1, -2, -3, 0xff, 0x100, 0x101, 0xffL * 0xff, 0xfffL * 0xfff, 0x101010L, 0xaaaaaaL @@ -17,7 +20,7 @@ void test_u (void) { unsigned int i; unsigned long la, lb, lc; - __uint24 a, b, c; + uint24_t a, b, c; int S = sizeof (vals) / sizeof (*vals); @@ -58,7 +61,7 @@ void test_nu (void) unsigned long la; unsigned int i; int S = sizeof (vals) / sizeof (*vals); - __uint24 a; + uint24_t a; for (i = 0; i < 500; i++) { diff --git a/gcc/testsuite/gcc.target/avr/torture/pr109907-2.c b/gcc/testsuite/gcc.target/avr/torture/pr109907-2.c index db0cc72e590a..26cce5d5a426 100644 --- a/gcc/testsuite/gcc.target/avr/torture/pr109907-2.c +++ b/gcc/testsuite/gcc.target/avr/torture/pr109907-2.c @@ -5,7 +5,7 @@ typedef __UINT8_TYPE__ uint8_t; typedef __UINT16_TYPE__ uint16_t; -typedef __uint24 uint24_t; +__extension__ typedef __uint24 uint24_t; typedef __UINT32_TYPE__ uint32_t; typedef __INT32_TYPE__ int32_t; diff --git a/gcc/testsuite/gcc.target/avr/torture/pr61443.c b/gcc/testsuite/gcc.target/avr/torture/pr61443.c index 36df852a012f..22514f4765b9 100644 --- a/gcc/testsuite/gcc.target/avr/torture/pr61443.c +++ b/gcc/testsuite/gcc.target/avr/torture/pr61443.c @@ -9,7 +9,9 @@ #define __memx /* empty */ #endif -#define NC __attribute__((noinline,noclone)) +#define NC __attribute__((noipa)) + +__extension__ typedef __int24 int24_t; void NC vfun (char n, ...) { @@ -30,7 +32,7 @@ void NC vfun (char n, ...) abort(); break; case 3: - if (333333 != va_arg (ap, __int24)) + if (333333 != va_arg (ap, int24_t)) abort(); break; case 4: @@ -67,12 +69,12 @@ void NC boox_hi (const __memx int *p) vfun (2, *p); } -void NC boo_psi (const __flash __int24 *p) +void NC boo_psi (const __flash int24_t *p) { vfun (3, *p); } -void NC boox_psi (const __memx __int24 *p) +void NC boox_psi (const __memx int24_t *p) { vfun (3, *p); } @@ -99,19 +101,19 @@ void NC boox_di (const __memx long long *p) const __flash char f_qi = 11; const __flash int f_hi = 2222; -const __flash __int24 f_psi = 333333; +const __flash int24_t f_psi = 333333; const __flash long f_si = 44444444; const __flash long long f_di = 8888888888888888; const __memx char x_qi = 11; const __memx int x_hi = 2222; -const __memx __int24 x_psi = 333333; +const __memx int24_t x_psi = 333333; const __memx long x_si = 44444444; const __memx long long x_di = 8888888888888888; char r_qi = 11; int r_hi = 2222; -__int24 r_psi = 333333; +int24_t r_psi = 333333; long r_si = 44444444; long long r_di = 8888888888888888; diff --git a/gcc/testsuite/gcc.target/avr/torture/pr63633-ice-mult.c b/gcc/testsuite/gcc.target/avr/torture/pr63633-ice-mult.c index a523424c3253..5568ed689f5d 100644 --- a/gcc/testsuite/gcc.target/avr/torture/pr63633-ice-mult.c +++ b/gcc/testsuite/gcc.target/avr/torture/pr63633-ice-mult.c @@ -6,21 +6,23 @@ void ice_mult32 (int x) __asm volatile (" " :: "r" (reg = 0x12345 * x)); } +__extension__ typedef __int24 i24; + void ice_mult24 (int x) { - register __int24 reg __asm ("20"); + register i24 reg __asm ("20"); __asm volatile (" " :: "r" (reg = 0x12345 * x)); } -void ice_sh24 (__int24 x) +void ice_sh24 (i24 x) { - register __int24 reg __asm ("20"); + register i24 reg __asm ("20"); __asm volatile (" " :: "r" (reg = x << 3)); } -void ice_sh24b (__int24 x) +void ice_sh24b (i24 x) { - register __int24 reg __asm ("20"); + register i24 reg __asm ("20"); __asm volatile (" " :: "r" (reg = x << 22)); } diff --git a/gcc/testsuite/gcc.target/avr/torture/set-mem.c b/gcc/testsuite/gcc.target/avr/torture/set-mem.c index 60ded19d4b64..11961e132183 100644 --- a/gcc/testsuite/gcc.target/avr/torture/set-mem.c +++ b/gcc/testsuite/gcc.target/avr/torture/set-mem.c @@ -4,7 +4,7 @@ typedef __INT8_TYPE__ s8; typedef __INT16_TYPE__ s16; -typedef __int24 s24; +__extension__ typedef __int24 s24; typedef __INT32_TYPE__ s32; static s8 arr8[3];