From patchwork Tue Feb 20 14:34:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 86032 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09D9D3858CDA for ; Tue, 20 Feb 2024 14:34:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [85.215.255.22]) by sourceware.org (Postfix) with ESMTPS id 275C63858D20 for ; Tue, 20 Feb 2024 14:34:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 275C63858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gjlay.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gjlay.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 275C63858D20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=85.215.255.22 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708439659; cv=pass; b=leO3kln89XmlfWklnX+nTK9PgwBoDK5aQoimZYJXwmhrvMWzJIHSvDqpk8oDwwo8gMnvprSIvWr1xy4LIeR0mbY9xOKj8lyTzZF1iL420RfzSYee9HDSsTm9Spqy5+DBUxuywAnBJjms+2MydXIYBLcdywKHLiiRjAsPoZltKvg= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708439659; c=relaxed/simple; bh=CG1V9D5Ts3ZbLROTlxpUc2n1D9q1D5sjmQ38pMsx2v0=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version:From: To:Subject; b=uR21UnuyTxDwWX2ZV9unBvGHKG+NBpHHR1hQm36rPfn1kNWNbjBdxlILJUfEDtn4BHTVxTXugHZ5ocja9LznoLg1mNhow283tj8/yKD2WBTyqRDJujp/HJpEQq0PgKaAmaTULt+BDwffrgj/a7gQkSDLxiNr0EEPJFDclX4g6i0= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1708439651; cv=none; d=strato.com; s=strato-dkim-0002; b=Rlk0fhosN2PH+2xorINIbyw5R2hEiIybXv8+Kk6ij3V1EXJ+5tj2xLgcwEPeAySowW VSKV4vU4Ndc5iMDqakrAcITfIZcXnms5aHnflZTiLZx/YxsZj/tzNyfm+Zizc4/F89FU EvP8wKXl18a2StNuwcVblAQit1A3ehD+BqGVgKUKJWfcR09CB/a+23b2eeYZCPl1oeu7 oUtqYlU3LIwDyO6lCZmLRaQtVGj7mYZDHKzxWuStQlekimA08Qr8ualW7DsLZJcrqXxY c2tEVLhqHeX8CA4jwtSK7YqRnLhIDFqDXAa7PKA+P7HYtlptw+Khqu2svquPj9QwfdmQ rjCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1708439651; s=strato-dkim-0002; d=strato.com; h=Subject:To:From:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=IhY0o52caXHr7D47+1+dkAdHFG/F3XCfs6eYvY7rUiQ=; b=lxZZEFyi0kYsK+PL2tLJ2z2/YegPk/+FcyQ6If3ZoeOd3BzNwECSNcK8vcCLziWNnj CSU3OfpizAFpIY88Whudbn4/vbeSVcxv8SwK+CVPl1WAafxJu8TFJ62Bymr+gy2PLQnA grTevPd7b2Y6YKi62cKsrpasPjb0z38/cHdtezD/H3tS/P2xcyY7G3w12/Q7zmNdZsJ2 dkud0K17NHvk02/VPt3w96ZR5WFveK/hCtbpidpo10emuVW6hWbYtIzsdKbPrCvTbLN/ 4kkBByrNEKaFkhDJmqdLY80vqVzswtcgllTe6rX09jN3x2u4gV7p3LQFAI2LNH/YOmHq n+Xw== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1708439651; s=strato-dkim-0002; d=gjlay.de; h=Subject:To:From:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=IhY0o52caXHr7D47+1+dkAdHFG/F3XCfs6eYvY7rUiQ=; b=Gzaa0FdkryU9YqpdfVPUo6HZmTaaENbEY7FSEJp/vWYhnXgCDgJzrmRhJVWQ+YUbBK qQDmS5O4qk9UXWSdqHeCSMum1rx4t9YiYbQUvz4g0A9OimByNxZi4NlK6+6cQeDCVALN xaI/qj8omLQhR4qRq3YhbdnXU9u8m/mPzMHgmv+m9nf0pemOyoEpoF3h9kuwJYEtY9Rd pJDFtSGJXcJUkfkDqUp/2NqMaVIqehmi2nqU96RQvxAJm86+A764SyZDBC6RQmOPxHdr ZCpsM5L1qA1aPXHPFtzgass8Qly+9xmz0VniqKmtlNzQVRGzpdRyAWnv1BdnzNnoq/hz sHmw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1708439651; s=strato-dkim-0003; d=gjlay.de; h=Subject:To:From:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=IhY0o52caXHr7D47+1+dkAdHFG/F3XCfs6eYvY7rUiQ=; b=8BUl54/qDBmNoQOgP5RvhlE2ztvS+NAwM6pCVWfedoLum4G7Ejy9nNBm0ZkZ6VfwS/ U3+atFTGyIgjADezxBBA== X-RZG-AUTH: ":LXoWVUeid/7A29J/hMvvT3koxZnKT7Qq0xotTetVnKkSgcSjpmy9KwoMJ/K0VA==" Received: from [192.168.2.102] by smtp.strato.de (RZmta 49.11.2 DYNA|AUTH) with ESMTPSA id Lb68c601KEYAf9Q (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Tue, 20 Feb 2024 15:34:10 +0100 (CET) Message-ID: Date: Tue, 20 Feb 2024 15:34:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Georg-Johann Lay To: gcc-patches@gcc.gnu.org Subject: [patch,avr,applied] Use int types of exact width and signedness in built-ins prototypes X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org 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 --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 4a55f14bff7..d3756a2f036 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 b4bf7beb590..316bdebe498 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 b2383b55666..2135dfde9c8 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