public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Georg-Johann Lay <gjl@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9083] AVR: Use types of exact size and signedness in built-ins.
Date: Tue, 20 Feb 2024 14:32:48 +0000 (GMT)	[thread overview]
Message-ID: <20240220143248.9C29D3858D20@sourceware.org> (raw)

https://gcc.gnu.org/g:4238100cdd5f5eba10e71adbf60054d29a9a4480

commit r14-9083-g4238100cdd5f5eba10e71adbf60054d29a9a4480
Author: Georg-Johann Lay <avr@gjlay.de>
Date:   Tue Feb 20 14:54:44 2024 +0100

    AVR: Use types of exact size and signedness in built-ins.
    
    The AVR built-ins used types like "int" or "char" that don't
    have exact signedness or type size which depend on -mint8
    and -f[no-][un-]signed-char etc.  As the built-ins are modelling
    machine instructions of given type sizes and signedness, also
    use according types in their prototypes.
    
    gcc/
            * config/avr/builtins.def: Use function prototypes of given size
            and signedness.
            * config/avr/avr.cc (avr_init_builtins): Adjust types required
            by builtins.def.
            * doc/extend.texi (AVR Built-in Functions): Adjust accordingly.

Diff:
---
 gcc/config/avr/avr.cc       | 48 ++++++++++++++++++++++-----------------------
 gcc/config/avr/builtins.def | 16 +++++++--------
 gcc/doc/extend.texi         | 16 +++++++--------
 3 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 4a55f14bff7f..d3756a2f0369 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -14605,35 +14605,35 @@ avr_init_builtins (void)
 {
   tree void_ftype_void
     = build_function_type_list (void_type_node, NULL_TREE);
-  tree uchar_ftype_uchar
-    = build_function_type_list (unsigned_char_type_node,
-				unsigned_char_type_node,
+  tree uintQI_ftype_uintQI
+    = build_function_type_list (unsigned_intQI_type_node,
+				unsigned_intQI_type_node,
 				NULL_TREE);
-  tree uint_ftype_uchar_uchar
-    = build_function_type_list (unsigned_type_node,
-				unsigned_char_type_node,
-				unsigned_char_type_node,
+  tree uintHI_ftype_uintQI_uintQI
+    = build_function_type_list (unsigned_intHI_type_node,
+				unsigned_intQI_type_node,
+				unsigned_intQI_type_node,
 				NULL_TREE);
-  tree int_ftype_char_char
-    = build_function_type_list (integer_type_node,
-				char_type_node,
-				char_type_node,
+  tree intHI_ftype_intQI_intQI
+    = build_function_type_list (intHI_type_node,
+				intQI_type_node,
+				intQI_type_node,
 				NULL_TREE);
-  tree int_ftype_char_uchar
-    = build_function_type_list (integer_type_node,
-				char_type_node,
-				unsigned_char_type_node,
+  tree intHI_ftype_intQI_uintQI
+    = build_function_type_list (intHI_type_node,
+				intQI_type_node,
+				unsigned_intQI_type_node,
 				NULL_TREE);
-  tree void_ftype_ulong
+  tree void_ftype_uintSI
     = build_function_type_list (void_type_node,
-				long_unsigned_type_node,
+				unsigned_intSI_type_node,
 				NULL_TREE);
 
-  tree uchar_ftype_ulong_uchar_uchar
-    = build_function_type_list (unsigned_char_type_node,
-				long_unsigned_type_node,
-				unsigned_char_type_node,
-				unsigned_char_type_node,
+  tree uintQI_ftype_uintSI_uintQI_uintQI
+    = build_function_type_list (unsigned_intQI_type_node,
+				unsigned_intSI_type_node,
+				unsigned_intQI_type_node,
+				unsigned_intQI_type_node,
 				NULL_TREE);
 
   tree const_memx_void_node
@@ -14644,8 +14644,8 @@ avr_init_builtins (void)
   tree const_memx_ptr_type_node
     = build_pointer_type_for_mode (const_memx_void_node, PSImode, false);
 
-  tree char_ftype_const_memx_ptr
-    = build_function_type_list (char_type_node,
+  tree intQI_ftype_const_memx_ptr
+    = build_function_type_list (intQI_type_node,
 				const_memx_ptr_type_node,
 				NULL);
 
diff --git a/gcc/config/avr/builtins.def b/gcc/config/avr/builtins.def
index b4bf7beb5907..316bdebe4980 100644
--- a/gcc/config/avr/builtins.def
+++ b/gcc/config/avr/builtins.def
@@ -43,17 +43,17 @@ DEF_BUILTIN (SLEEP, 0, void_ftype_void, sleep, NULL)
 /* Mapped to respective instruction but might also be folded away
    or emit as libgcc call if ISA does not provide the instruction.  */
 
-DEF_BUILTIN (SWAP,   1, uchar_ftype_uchar,      rotlqi3_4, NULL)
-DEF_BUILTIN (FMUL,   2, uint_ftype_uchar_uchar, fmul, NULL)
-DEF_BUILTIN (FMULS,  2, int_ftype_char_char,    fmuls, NULL)
-DEF_BUILTIN (FMULSU, 2, int_ftype_char_uchar,   fmulsu, NULL)
+DEF_BUILTIN (SWAP,   1, uintQI_ftype_uintQI,        rotlqi3_4, NULL)
+DEF_BUILTIN (FMUL,   2, uintHI_ftype_uintQI_uintQI, fmul, NULL)
+DEF_BUILTIN (FMULS,  2, intHI_ftype_intQI_intQI,    fmuls, NULL)
+DEF_BUILTIN (FMULSU, 2, intHI_ftype_intQI_uintQI,   fmulsu, NULL)
 
 /* More complex stuff that cannot be mapped 1:1 to an instruction.  */
 
-DEF_BUILTIN (DELAY_CYCLES, -1, void_ftype_ulong, nothing, NULL)
-DEF_BUILTIN (NOPS,         -1, void_ftype_ulong, nothing, NULL)
-DEF_BUILTIN (INSERT_BITS, 3, uchar_ftype_ulong_uchar_uchar, insert_bits, NULL)
-DEF_BUILTIN (FLASH_SEGMENT, 1, char_ftype_const_memx_ptr, flash_segment, NULL)
+DEF_BUILTIN (DELAY_CYCLES, -1, void_ftype_uintSI, nothing, NULL)
+DEF_BUILTIN (NOPS,         -1, void_ftype_uintSI, nothing, NULL)
+DEF_BUILTIN (INSERT_BITS, 3, uintQI_ftype_uintSI_uintQI_uintQI, insert_bits, NULL)
+DEF_BUILTIN (FLASH_SEGMENT, 1, intQI_ftype_const_memx_ptr, flash_segment, NULL)
 
 /* ISO/IEC TR 18037 "Embedded C"
    The following builtins are undocumented and used by stdfix.h.  */
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index b2383b556668..2135dfde9c81 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -16783,32 +16783,30 @@ or if not a specific built-in is implemented or not. For example, if
 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
 
 @defbuiltin{void __builtin_avr_nop (void)}
-@defbuiltinx{void __builtin_avr_nop (void)}
 @defbuiltinx{void __builtin_avr_sei (void)}
 @defbuiltinx{void __builtin_avr_cli (void)}
 @defbuiltinx{void __builtin_avr_sleep (void)}
 @defbuiltinx{void __builtin_avr_wdr (void)}
-@defbuiltinx{{unsigned char} __builtin_avr_swap (unsigned char)}
-@defbuiltinx{{unsigned int} __builtin_avr_fmul (unsigned char, unsigned char)}
-@defbuiltinx{int __builtin_avr_fmuls (char, char)}
-@defbuiltinx{int __builtin_avr_fmulsu (char, unsigned char)}
+@defbuiltinx{uint8_t __builtin_avr_swap (uint8_t)}
+@defbuiltinx{uint16_t __builtin_avr_fmul (uint8_t, uint8_t)}
+@defbuiltinx{int16_t __builtin_avr_fmuls (int8_t, int8_t)}
+@defbuiltinx{int16_t __builtin_avr_fmulsu (int8_t, uint8_t)}
 
 These built-in functions map to the respective machine
 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
 as library call if no hardware multiplier is available.
-
 @enddefbuiltin
 
-@defbuiltin{void __builtin_avr_delay_cycles (unsigned long @var{ticks})}
+@defbuiltin{void __builtin_avr_delay_cycles (uint32_t @var{ticks})}
 Delay execution for @var{ticks} cycles. Note that this
 built-in does not take into account the effect of interrupts that
 might increase delay time. @var{ticks} must be a compile-time
 integer constant; delays with a variable number of cycles are not supported.
 @enddefbuiltin
 
-@defbuiltin{char __builtin_avr_flash_segment (const __memx void*)}
+@defbuiltin{int8_t __builtin_avr_flash_segment (const __memx void*)}
 This built-in takes a byte address to the 24-bit
 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
 the number of the flash segment (the 64 KiB chunk) where the address
@@ -16862,7 +16860,7 @@ __builtin_avr_insert_bits (0x01234567, bits, 0);
 @end smallexample
 @enddefbuiltin
 
-@defbuiltin{void __builtin_avr_nops (unsigned @var{count})}
+@defbuiltin{void __builtin_avr_nops (uint16_t @var{count})}
 Insert @var{count} @code{NOP} instructions.
 The number of instructions must be a compile-time integer constant.
 @enddefbuiltin

                 reply	other threads:[~2024-02-20 14:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240220143248.9C29D3858D20@sourceware.org \
    --to=gjl@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).