From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1733) id 9C29D3858D20; Tue, 20 Feb 2024 14:32:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C29D3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708439568; bh=26Y1Z0ZPQr/JgYJ80Vpw4GzavETgvlFX68Ww5miesfo=; h=From:To:Subject:Date:From; b=k2Vp+fNzuDO55jDrovR5lr2p3pSmTIw6SVz/tXq0O76WoL0p3BVPSo8RP4mxBw+9S czu+tjL9WLXei7CCpDBnh0033BQh7LHjoiMw2yUk8FHzXYbiySE3+qW1yhYCcVL6R3 CnfxYrMV+Ohm3/avhbHWB813Gy8SAb5XTwbfGZLs= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Georg-Johann Lay To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9083] AVR: Use types of exact size and signedness in built-ins. X-Act-Checkin: gcc X-Git-Author: Georg-Johann Lay X-Git-Refname: refs/heads/master X-Git-Oldrev: 39ff13375dd2a79fe6af76d82636e8503513a099 X-Git-Newrev: 4238100cdd5f5eba10e71adbf60054d29a9a4480 Message-Id: <20240220143248.9C29D3858D20@sourceware.org> Date: Tue, 20 Feb 2024 14:32:48 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4238100cdd5f5eba10e71adbf60054d29a9a4480 commit r14-9083-g4238100cdd5f5eba10e71adbf60054d29a9a4480 Author: Georg-Johann Lay 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