]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AVR: Use INT_N to built-in define __int24.
authorGeorg-Johann Lay <avr@gjlay.de>
Thu, 16 Jan 2025 18:43:27 +0000 (19:43 +0100)
committerGeorg-Johann Lay <avr@gjlay.de>
Fri, 17 Jan 2025 11:36:46 +0000 (12:36 +0100)
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/pr115830-add.c (__int24, __uint24): Add __extension__
to respective typedefs.
* gcc.target/avr/pr115830-sub-ext.c: Same.
* gcc.target/avr/pr115830-sub.c: Same.
* gcc.target/avr/torture/get-mem.c: Same.
* gcc.target/avr/torture/set-mem.c: Same.
* gcc.target/avr/torture/ifelse-c.h: Same.
* gcc.target/avr/torture/ifelse-d.h: Same.
* gcc.target/avr/torture/ifelse-q.h: Same.
* gcc.target/avr/torture/ifelse-r.h: 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.
* gcc.target/avr/torture/shift-l-u24.c: Same.
* gcc.target/avr/torture/shift-r-i24.c: Same.
* gcc.target/avr/torture/shift-r-u24.c: Same.
* gcc.target/avr/torture/add-extend.c: Same.
* gcc.target/avr/torture/sub-extend.c: Same.
* gcc.target/avr/torture/sub-zerox.c: Same.
* gcc.target/avr/torture/test-gprs.h: Same.

22 files changed:
gcc/config/avr/avr-modes.def
gcc/config/avr/avr.cc
gcc/testsuite/gcc.target/avr/pr115830-add.c
gcc/testsuite/gcc.target/avr/pr115830-sub-ext.c
gcc/testsuite/gcc.target/avr/pr115830-sub.c
gcc/testsuite/gcc.target/avr/torture/add-extend.c
gcc/testsuite/gcc.target/avr/torture/get-mem.c
gcc/testsuite/gcc.target/avr/torture/ifelse-c.h
gcc/testsuite/gcc.target/avr/torture/ifelse-d.h
gcc/testsuite/gcc.target/avr/torture/ifelse-q.h
gcc/testsuite/gcc.target/avr/torture/ifelse-r.h
gcc/testsuite/gcc.target/avr/torture/int24-mul.c
gcc/testsuite/gcc.target/avr/torture/pr109907-2.c
gcc/testsuite/gcc.target/avr/torture/pr61443.c
gcc/testsuite/gcc.target/avr/torture/pr63633-ice-mult.c
gcc/testsuite/gcc.target/avr/torture/set-mem.c
gcc/testsuite/gcc.target/avr/torture/shift-l-u24.c
gcc/testsuite/gcc.target/avr/torture/shift-r-i24.c
gcc/testsuite/gcc.target/avr/torture/shift-r-u24.c
gcc/testsuite/gcc.target/avr/torture/sub-extend.c
gcc/testsuite/gcc.target/avr/torture/sub-zerox.c
gcc/testsuite/gcc.target/avr/torture/test-gprs.h

index c71138c8d3263d63e0b9f399d631b61b531bb7c8..95d3814a8129e56f52e7ecf077baa1e17edee967 100644 (file)
@@ -18,6 +18,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 FRACTIONAL_INT_MODE (PSI, 24, 3);
+INT_N (PSI, 24);
 
 /* Used when the N (and Z) flag(s) of SREG are set.
    The N flag indicates  whether the value is negative.
index 41899289c3f142a7b63d30b4041cf29ebdf29b1a..c44ed7424538a2551f8f6aef785dd698db07555b 100644 (file)
@@ -15336,11 +15336,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;
+      }
 }
 
 
index 99ac89cd0a60215694dbe501298a2723fd3e4911..89ce4847141c24002b5d0db4c564314b2dd744aa 100644 (file)
@@ -5,8 +5,8 @@ typedef __UINT8_TYPE__ u8;
 typedef __INT8_TYPE__  i8;
 typedef __UINT16_TYPE__ u16;
 typedef __INT16_TYPE__  i16;
-typedef __uint24 u24;
-typedef __int24  i24;
+__extension__ typedef __uint24 u24;
+__extension__ typedef __int24  i24;
 typedef __UINT32_TYPE__ u32;
 typedef __INT32_TYPE__  i32;
 
index 3fac6ddd0df95ac81ae0111f622fbf454372e879..3f959ab2cb9601ea1d628457a1ef0545699910e7 100644 (file)
@@ -5,8 +5,8 @@ typedef __UINT8_TYPE__ u8;
 typedef __INT8_TYPE__  i8;
 typedef __UINT16_TYPE__ u16;
 typedef __INT16_TYPE__  i16;
-typedef __uint24 u24;
-typedef __int24  i24;
+__extension__ typedef __uint24 u24;
+__extension__ typedef __int24  i24;
 typedef __UINT32_TYPE__ u32;
 typedef __INT32_TYPE__  i32;
 
index ef24e74752d145623c22ebd981633237a870df44..5ad5e8918a19f730539758b103b4bbf611f626d1 100644 (file)
@@ -5,8 +5,8 @@ typedef __UINT8_TYPE__ u8;
 typedef __INT8_TYPE__  i8;
 typedef __UINT16_TYPE__ u16;
 typedef __INT16_TYPE__  i16;
-typedef __uint24 u24;
-typedef __int24  i24;
+__extension__ typedef __uint24 u24;
+__extension__ typedef __int24  i24;
 typedef __UINT32_TYPE__ u32;
 typedef __INT32_TYPE__  i32;
 
index 320f510e677f267e3c8fc169fdf05c2796d9e012..d87077a218bea32dfad0cf0ba58e78600f4f8289 100644 (file)
@@ -2,12 +2,12 @@
 
 typedef __UINT8_TYPE__ u8;
 typedef __UINT16_TYPE__ u16;
-typedef __uint24 u24;
+__extension__ typedef __uint24 u24;
 typedef __UINT32_TYPE__ u32;
 
 typedef __INT8_TYPE__ s8;
 typedef __INT16_TYPE__ s16;
-typedef __int24 s24;
+__extension__ typedef __int24 s24;
 typedef __INT32_TYPE__ s32;
 
 #define NI __attribute__((noipa))
index 38425fe638f36841fbb11d9c63d03ed95dd60cb3..921d4ad26803866dde6d80fc859510d508467830 100644 (file)
@@ -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 };
index e742415d7fd42d96bfbf9f3a58abd80c324de791..1270155277608172f0a12db8c4a430dd1898c989 100644 (file)
@@ -5,12 +5,12 @@
 #ifdef __OPTIMIZE__
 
 typedef __UINT32_TYPE__ u32;
-typedef __uint24 u24;
+__extension__ typedef __uint24 u24;
 typedef __UINT16_TYPE__ u16;
 typedef __UINT8_TYPE__ u8;
 
 typedef __INT32_TYPE__ i32;
-typedef __int24 i24;
+__extension__ typedef __int24 i24;
 typedef __INT16_TYPE__ i16;
 typedef __INT8_TYPE__ i8;
 
index 3ff2494ea6a21d04c03721c4ae1524d09bed4cff..82e3e21d331db7fff92e958288ea7a4dc27cd032 100644 (file)
@@ -6,12 +6,12 @@
 #ifdef __OPTIMIZE__
 
 typedef __UINT32_TYPE__ u32;
-typedef __uint24 u24;
+__extension__ typedef __uint24 u24;
 typedef __UINT16_TYPE__ u16;
 typedef __UINT8_TYPE__ u8;
 
 typedef __INT32_TYPE__ i32;
-typedef __int24 i24;
+__extension__ typedef __int24 i24;
 typedef __INT16_TYPE__ i16;
 typedef __INT8_TYPE__ i8;
 
index 6dbb05990e0664dd2b54aa0b1739fa9862a4bf07..0b7c80e408f6c09a88f51a229977c60cd768cd62 100644 (file)
@@ -6,12 +6,12 @@
 #ifdef __OPTIMIZE__
 
 typedef __UINT32_TYPE__ u32;
-typedef __uint24 u24;
+__extension__ typedef __uint24 u24;
 typedef __UINT16_TYPE__ u16;
 typedef __UINT8_TYPE__ u8;
 
 typedef __INT32_TYPE__ i32;
-typedef __int24 i24;
+__extension__ typedef __int24 i24;
 typedef __INT16_TYPE__ i16;
 typedef __INT8_TYPE__ i8;
 
index 19cd1cc67c431f9c07aafbf0178ee3cfc2fb354f..588ad3a83b1fff60d79a2fbce638bda0fd9d3647 100644 (file)
@@ -5,12 +5,12 @@
 #ifdef __OPTIMIZE__
 
 typedef __UINT32_TYPE__ u32;
-typedef __uint24 u24;
+__extension__ typedef __uint24 u24;
 typedef __UINT16_TYPE__ u16;
 typedef __UINT8_TYPE__ u8;
 
 typedef __INT32_TYPE__ i32;
-typedef __int24 i24;
+__extension__ typedef __int24 i24;
 typedef __INT16_TYPE__ i16;
 typedef __INT8_TYPE__ i8;
 
index 9b29763738cc9e871ab95ed9981c2de2718ed5f9..98df1d0d3c307c80bf835dff105b39d589ea9c6c 100644 (file)
@@ -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++)
     {
index 813a0e083fa4d1b9ea28f4bd199fbd341deb71da..c867a2d0fc673b125c9056388e08cdd3794de111 100644 (file)
@@ -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;
index 2e2557b1c13030dec68280ece54aca4b2fe8e059..f70b9e5d88d803a20b3232a484eef38f30362ce0 100644 (file)
@@ -9,6 +9,8 @@
 #define __memx  /* empty */
 #endif
 
+__extension__ typedef __int24 int24_t;
+
 #define NC __attribute__((noipa))
 
 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;
 
index a523424c325324fb882edfdb873771d33a58ee7c..5568ed689f5d0adaf946ea64056f3799de925e87 100644 (file)
@@ -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));
 }
 
index ca0a29c44eb2a4d30ccd72bf6a469ed1a6c0023d..ec809f8be66ac7fe7963f83ae10c0f89207debd4 100644 (file)
@@ -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];
index 4fd66f3f621b03b67d16a7d31349633da7f3b871..859be0941af7410f156639a3fdf0c985a54d6ef1 100644 (file)
@@ -3,7 +3,7 @@
 
 #define OP <<
 #define BITS 24
-typedef __uint24 T;
+__extension__ typedef __uint24 T;
 
 #include "test-shift.h"
 
index 45e1b0bab883c2707f3673e4461035fcb7d755c3..1d92c14730e3a5ea9a743fbde827d174c3cc0e8a 100644 (file)
@@ -3,7 +3,7 @@
 
 #define OP >>
 #define BITS 24
-typedef __int24 T;
+__extension__ typedef __int24 T;
 
 #include "test-shift.h"
 
index 6acdd4e2672dec0dec459a9893314ecee9b0e88f..628ea77ade10726470bc39e16956633cdd017116 100644 (file)
@@ -3,7 +3,7 @@
 
 #define OP >>
 #define BITS 24
-typedef __uint24 T;
+__extension__ typedef __uint24 T;
 
 #include "test-shift.h"
 
index ebc403fa4793f696f02982e38b563a46759b0aeb..94ffef3b1f2183327e414e98bf820931ae731da1 100644 (file)
@@ -2,12 +2,12 @@
 
 typedef __UINT8_TYPE__ u8;
 typedef __UINT16_TYPE__ u16;
-typedef __uint24 u24;
+__extension__ typedef __uint24 u24;
 typedef __UINT32_TYPE__ u32;
 
 typedef __INT8_TYPE__ s8;
 typedef __INT16_TYPE__ s16;
-typedef __int24 s24;
+__extension__ typedef __int24 s24;
 typedef __INT32_TYPE__ s32;
 
 #define NI __attribute__((noipa))
index 435fc7065f0ffddb7c0f7a5580a27bf4eb470ff0..8152533d569cbb44f39b2c53ab72c1748b564aab 100644 (file)
@@ -2,7 +2,7 @@
 
 typedef __UINT8_TYPE__ u8;
 typedef __UINT16_TYPE__ u16;
-typedef __uint24 u24;
+__extension__ typedef __uint24 u24;
 typedef __UINT32_TYPE__ u32;
 
 u32 sub_32_8  (u32 a, u8 b)  { return a - b; }
index a982115e02a7d4cc64b0d1ad292fbf8555a33931..56f358f7c250a76991894e5bffa5556ec18e55da 100644 (file)
@@ -1,6 +1,6 @@
 typedef __UINT8_TYPE__   u8;
 typedef __UINT16_TYPE__  u16;
-typedef __uint24         u24;
+__extension__ typedef __uint24         u24;
 typedef __UINT32_TYPE__  u32;
 typedef __UINT64_TYPE__  u64;