From patchwork Wed Feb 12 10:03:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 106367 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 1D7773858282 for ; Wed, 12 Feb 2025 10:04:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D7773858282 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 1C4203858C52 for ; Wed, 12 Feb 2025 10:03:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C4203858C52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1C4203858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354592; cv=none; b=ZPo7w2uW+C8iuLvba/cT9MFZvIvc8iYEL0up+6tTDVtMuRYyoSQlVTIrhyWI34z3KuvEXGst3XrV+sxpAlRUm2YbUIlerBvmL5YPIrjSrj2l7NLRs0XBVXQkh2Rd9FWbI4RHWXarAOI3a3cXQtXqLKG4MjW41gUJXDWasnmnuco= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354592; c=relaxed/simple; bh=3GoIj9/kJI63prc06uMnumSuzDweii0AaRRia0a3ym0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=K9RAzw4SstVvhL22ioodvIaFIsNn+09rrJ1O1cXrut68VMUjcr+hKn1fLuwE0tuVhtHlEDFqUtnJRTOACXdBxjAyUbRAJ/xn3T35VBsLMdlrgBE1Hg7EkqoP6NTklYAUIkUz9tiTpM0rVyC25FKc1l0XyXd0uh8jxH4aUtW9FNI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C4203858C52 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8Bx63Hdcaxn5ARzAA--.3449S3; Wed, 12 Feb 2025 18:03:09 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by front1 (Coremail) with SMTP id qMiowMCx7MTacaxnpXsNAA--.49752S3; Wed, 12 Feb 2025 18:03:08 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i.swmail@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v2 1/4] LoongArch: Move the function loongarch_register_pragmas to loongarch-c.cc. Date: Wed, 12 Feb 2025 18:03:46 +0800 Message-Id: <20250212100349.11909-2-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250212100349.11909-1-chenglulu@loongson.cn> References: <20250212100349.11909-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMCx7MTacaxnpXsNAA--.49752S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW3WrW3GF1Utw15AF1fJF48Xwc_yoW7CF15pF 9rury5tw4rJrZ3Gw4DJa4rX3Z5Jr17KrW29Fyftr40kw4agry7X348tr9IqF1jy3y5Wr1a vF1Fya1UZa1UAwbCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE14v2 6r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jea0PUUUUU= X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP 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 gcc/ChangeLog: * config/loongarch/loongarch-target-attr.cc (loongarch_pragma_target_parse): Move to ... (loongarch_register_pragmas): Move to ... * config/loongarch/loongarch-c.cc (loongarch_pragma_target_parse): ... here. (loongarch_register_pragmas): ... here. * config/loongarch/loongarch-protos.h (loongarch_process_target_attr): Function Declaration. Change-Id: Iacb09467e4b4551d6bf0ae55cced5c4abb901ddf --- gcc/config/loongarch/loongarch-c.cc | 51 +++++++++++++++++++ gcc/config/loongarch/loongarch-protos.h | 1 + gcc/config/loongarch/loongarch-target-attr.cc | 48 ----------------- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/gcc/config/loongarch/loongarch-c.cc b/gcc/config/loongarch/loongarch-c.cc index c95c0f373be..5d8c02e094b 100644 --- a/gcc/config/loongarch/loongarch-c.cc +++ b/gcc/config/loongarch/loongarch-c.cc @@ -23,9 +23,11 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" +#include "target.h" #include "tm.h" #include "c-family/c-common.h" #include "cpplib.h" +#include "tm_p.h" #define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM) #define builtin_define(TXT) cpp_define (pfile, TXT) @@ -145,3 +147,52 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile) builtin_define_with_int_value ("_LOONGARCH_SPFPSET", 32); } + +/* Hook to validate the current #pragma GCC target and set the state, and + update the macros based on what was changed. If ARGS is NULL, then + POP_TARGET is used to reset the options. */ + +static bool +loongarch_pragma_target_parse (tree args, tree pop_target) +{ + /* If args is not NULL then process it and setup the target-specific + information that it specifies. */ + if (args) + { + if (!loongarch_process_target_attr (args, NULL)) + return false; + + loongarch_option_override_internal (&la_target, + &global_options, + &global_options_set); + } + + /* args is NULL, restore to the state described in pop_target. */ + else + { + pop_target = pop_target ? pop_target : target_option_default_node; + cl_target_option_restore (&global_options, &global_options_set, + TREE_TARGET_OPTION (pop_target)); + } + + target_option_current_node + = build_target_option_node (&global_options, &global_options_set); + + loongarch_reset_previous_fndecl (); + + /* If we're popping or reseting make sure to update the globals so that + the optab availability predicates get recomputed. */ + if (pop_target) + loongarch_save_restore_target_globals (pop_target); + + return true; +} + +/* Implement REGISTER_TARGET_PRAGMAS. */ + +void +loongarch_register_pragmas (void) +{ + /* Update pragma hook to allow parsing #pragma GCC target. */ + targetm.target_option.pragma_parse = loongarch_pragma_target_parse; +} diff --git a/gcc/config/loongarch/loongarch-protos.h b/gcc/config/loongarch/loongarch-protos.h index b99f949a004..e7b318143bf 100644 --- a/gcc/config/loongarch/loongarch-protos.h +++ b/gcc/config/loongarch/loongarch-protos.h @@ -219,4 +219,5 @@ extern void loongarch_option_override_internal (struct loongarch_target *, struc extern void loongarch_reset_previous_fndecl (void); extern void loongarch_save_restore_target_globals (tree new_tree); extern void loongarch_register_pragmas (void); +extern bool loongarch_process_target_attr (tree args, tree fndecl); #endif /* ! GCC_LOONGARCH_PROTOS_H */ diff --git a/gcc/config/loongarch/loongarch-target-attr.cc b/gcc/config/loongarch/loongarch-target-attr.cc index cee7031ca1e..cb537446dff 100644 --- a/gcc/config/loongarch/loongarch-target-attr.cc +++ b/gcc/config/loongarch/loongarch-target-attr.cc @@ -422,51 +422,3 @@ loongarch_option_valid_attribute_p (tree fndecl, tree, tree args, int) return ret; } -/* Hook to validate the current #pragma GCC target and set the state, and - update the macros based on what was changed. If ARGS is NULL, then - POP_TARGET is used to reset the options. */ - -static bool -loongarch_pragma_target_parse (tree args, tree pop_target) -{ - /* If args is not NULL then process it and setup the target-specific - information that it specifies. */ - if (args) - { - if (!loongarch_process_target_attr (args, NULL)) - return false; - - loongarch_option_override_internal (&la_target, - &global_options, - &global_options_set); - } - - /* args is NULL, restore to the state described in pop_target. */ - else - { - pop_target = pop_target ? pop_target : target_option_default_node; - cl_target_option_restore (&global_options, &global_options_set, - TREE_TARGET_OPTION (pop_target)); - } - - target_option_current_node - = build_target_option_node (&global_options, &global_options_set); - - loongarch_reset_previous_fndecl (); - - /* If we're popping or reseting make sure to update the globals so that - the optab availability predicates get recomputed. */ - if (pop_target) - loongarch_save_restore_target_globals (pop_target); - - return true; -} - -/* Implement REGISTER_TARGET_PRAGMAS. */ - -void -loongarch_register_pragmas (void) -{ - /* Update pragma hook to allow parsing #pragma GCC target. */ - targetm.target_option.pragma_parse = loongarch_pragma_target_parse; -} From patchwork Wed Feb 12 10:03:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 106368 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 3110C3858408 for ; Wed, 12 Feb 2025 10:05:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3110C3858408 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 37892385841E for ; Wed, 12 Feb 2025 10:03:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37892385841E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 37892385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354593; cv=none; b=XJqSRf4fNLEUZVLfiYwLlnEM5Zc7+2+Ae/nKXRsnXO9Ig3OmPnqTa7t2OBxT5DQLdiVM0tk8Oa73cFH8Trv3jd5uOgqibRjhizDJ8uBbILGPr6TT1oIYmcmdAPyqMuRQer/SmBkO6rEphBWmnWFrEXoNYsBKrEt3h0MqUufEk9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354593; c=relaxed/simple; bh=3lxYEZjPb/nPdL3OwlScbXQ30geFToNmM47Xs1LY6KM=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=ZTZ9QOGZFy9SDPzDwfs4qbIwFxphtWpwh6NFRs1PICxcxDuiQ03k/YZ/617IBSTk0Eqh3ZywhmqMan4p6jo/V9H5tRkC/puKNsTnyU8y6Kj8etOKBuk+FL9tpS+fx3z4sSoK6ibveGCawc93f/bdGVaXCieFN1F7zkeTR8G8CpM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37892385841E Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8DxbKzecaxn6QRzAA--.3553S3; Wed, 12 Feb 2025 18:03:10 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by front1 (Coremail) with SMTP id qMiowMCx7MTacaxnpXsNAA--.49752S4; Wed, 12 Feb 2025 18:03:09 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i.swmail@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v2 2/4] LoongArch: Split the function loongarch_cpu_cpp_builtins into two functions. Date: Wed, 12 Feb 2025 18:03:47 +0800 Message-Id: <20250212100349.11909-3-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250212100349.11909-1-chenglulu@loongson.cn> References: <20250212100349.11909-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMCx7MTacaxnpXsNAA--.49752S4 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW3JF48uw1DCFWDXr4DtF45twc_yoW3Zr15pr Wjyr1Yk3y8XFs3A39Yy3W5Wrn5Ar1UWw1IvFy3KrWxurWUJ34Iqw15KrZxXF1jyayrJw10 9w1kJa1UZF45AwcCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE14v2 6r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jea0PUUUUU= X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP 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 Split the implementation of the function loongarch_cpu_cpp_builtins into two parts: 1. Macro definitions that do not change (only considering 64-bit architecture) 2. Macro definitions that change with different compilation options. gcc/ChangeLog: * config/loongarch/loongarch-c.cc (builtin_undef): New macro. (loongarch_cpu_cpp_builtins): Split to loongarch_update_cpp_builtins and loongarch_define_unconditional_macros. (loongarch_def_or_undef): New functions. (loongarch_define_unconditional_macros): Likewise. (loongarch_update_cpp_builtins): Likewise. Change-Id: Ifae73ffa2a07a595ed2a7f6ab7b82d8f51328a2a --- gcc/config/loongarch/loongarch-c.cc | 122 ++++++++++++++++++---------- 1 file changed, 77 insertions(+), 45 deletions(-) diff --git a/gcc/config/loongarch/loongarch-c.cc b/gcc/config/loongarch/loongarch-c.cc index 5d8c02e094b..9a8de1ec381 100644 --- a/gcc/config/loongarch/loongarch-c.cc +++ b/gcc/config/loongarch/loongarch-c.cc @@ -31,26 +31,22 @@ along with GCC; see the file COPYING3. If not see #define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM) #define builtin_define(TXT) cpp_define (pfile, TXT) +#define builtin_undef(TXT) cpp_undef (pfile, TXT) #define builtin_assert(TXT) cpp_assert (pfile, TXT) -void -loongarch_cpu_cpp_builtins (cpp_reader *pfile) +static void +loongarch_def_or_undef (bool def_p, const char *macro, cpp_reader *pfile) { - builtin_assert ("machine=loongarch"); - builtin_assert ("cpu=loongarch"); - builtin_define ("__loongarch__"); - - builtin_define_with_value ("__loongarch_arch", - loongarch_arch_strings[la_target.cpu_arch], 1); - - builtin_define_with_value ("__loongarch_tune", - loongarch_tune_strings[la_target.cpu_tune], 1); - - builtin_define_with_value ("_LOONGARCH_ARCH", - loongarch_arch_strings[la_target.cpu_arch], 1); + if (def_p) + cpp_define (pfile, macro); + else + cpp_undef (pfile, macro); +} - builtin_define_with_value ("_LOONGARCH_TUNE", - loongarch_tune_strings[la_target.cpu_tune], 1); +static void +loongarch_define_unconditional_macros (cpp_reader *pfile) +{ + builtin_define ("__loongarch__"); /* Base architecture / ABI. */ if (TARGET_64BIT) @@ -66,6 +62,48 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile) builtin_define ("__loongarch_lp64"); } + /* Add support for FLOAT128_TYPE on the LoongArch architecture. */ + builtin_define ("__FLOAT128_TYPE__"); + + /* Map the old _Float128 'q' builtins into the new 'f128' builtins. */ + builtin_define ("__builtin_fabsq=__builtin_fabsf128"); + builtin_define ("__builtin_copysignq=__builtin_copysignf128"); + builtin_define ("__builtin_nanq=__builtin_nanf128"); + builtin_define ("__builtin_nansq=__builtin_nansf128"); + builtin_define ("__builtin_infq=__builtin_inff128"); + builtin_define ("__builtin_huge_valq=__builtin_huge_valf128"); + + /* Native Data Sizes. */ + builtin_define_with_int_value ("_LOONGARCH_SZINT", INT_TYPE_SIZE); + builtin_define_with_int_value ("_LOONGARCH_SZLONG", LONG_TYPE_SIZE); + builtin_define_with_int_value ("_LOONGARCH_SZPTR", POINTER_SIZE); + builtin_define_with_int_value ("_LOONGARCH_FPSET", 32); + builtin_define_with_int_value ("_LOONGARCH_SPFPSET", 32); +} + +static void +loongarch_update_cpp_builtins (cpp_reader *pfile) +{ + /* Since the macros in this function might be redefined, it's necessary to + undef them first.*/ + builtin_undef ("__loongarch_arch"); + builtin_define_with_value ("__loongarch_arch", + loongarch_arch_strings[la_target.cpu_arch], 1); + + builtin_undef ("__loongarch_tune"); + builtin_define_with_value ("__loongarch_tune", + loongarch_tune_strings[la_target.cpu_tune], 1); + + builtin_undef ("_LOONGARCH_ARCH"); + builtin_define_with_value ("_LOONGARCH_ARCH", + loongarch_arch_strings[la_target.cpu_arch], 1); + + builtin_undef ("_LOONGARCH_TUNE"); + builtin_define_with_value ("_LOONGARCH_TUNE", + loongarch_tune_strings[la_target.cpu_tune], 1); + + builtin_undef ("__loongarch_double_float"); + builtin_undef ("__loongarch_single_float"); /* These defines reflect the ABI in use, not whether the FPU is directly accessible. */ if (TARGET_DOUBLE_FLOAT_ABI) @@ -73,6 +111,8 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile) else if (TARGET_SINGLE_FLOAT_ABI) builtin_define ("__loongarch_single_float=1"); + builtin_undef ("__loongarch_soft_float"); + builtin_undef ("__loongarch_hard_float"); if (TARGET_DOUBLE_FLOAT_ABI || TARGET_SINGLE_FLOAT_ABI) builtin_define ("__loongarch_hard_float=1"); else @@ -80,6 +120,7 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile) /* ISA Extensions. */ + builtin_undef ("__loongarch_frlen"); if (TARGET_DOUBLE_FLOAT) builtin_define ("__loongarch_frlen=64"); else if (TARGET_SINGLE_FLOAT) @@ -87,24 +128,22 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile) else builtin_define ("__loongarch_frlen=0"); - if (TARGET_HARD_FLOAT && ISA_HAS_FRECIPE) - builtin_define ("__loongarch_frecipe"); + loongarch_def_or_undef (TARGET_HARD_FLOAT && ISA_HAS_FRECIPE, + "__loongarch_frecipe", pfile); + + loongarch_def_or_undef (ISA_HAS_LSX, "__loongarch_simd", pfile); + loongarch_def_or_undef (ISA_HAS_LSX, "__loongarch_sx", pfile); + loongarch_def_or_undef (ISA_HAS_LASX, "__loongarch_asx", pfile); + builtin_undef ("__loongarch_simd_width"); if (ISA_HAS_LSX) { - builtin_define ("__loongarch_simd"); - builtin_define ("__loongarch_sx"); - - if (!ISA_HAS_LASX) + if (ISA_HAS_LASX) + builtin_define ("__loongarch_simd_width=256"); + else builtin_define ("__loongarch_simd_width=128"); } - if (ISA_HAS_LASX) - { - builtin_define ("__loongarch_asx"); - builtin_define ("__loongarch_simd_width=256"); - } - /* ISA evolution features */ int max_v_major = 1, max_v_minor = 0; @@ -122,30 +161,23 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile) } /* Find the minimum ISA version required to run the target program. */ + builtin_undef ("__loongarch_version_major"); + builtin_undef ("__loongarch_version_minor"); if (!(max_v_major == 1 && max_v_minor <= 1 && ISA_HAS_LASX)) { builtin_define_with_int_value ("__loongarch_version_major", max_v_major); builtin_define_with_int_value ("__loongarch_version_minor", max_v_minor); } +} - /* Add support for FLOAT128_TYPE on the LoongArch architecture. */ - builtin_define ("__FLOAT128_TYPE__"); - - /* Map the old _Float128 'q' builtins into the new 'f128' builtins. */ - builtin_define ("__builtin_fabsq=__builtin_fabsf128"); - builtin_define ("__builtin_copysignq=__builtin_copysignf128"); - builtin_define ("__builtin_nanq=__builtin_nanf128"); - builtin_define ("__builtin_nansq=__builtin_nansf128"); - builtin_define ("__builtin_infq=__builtin_inff128"); - builtin_define ("__builtin_huge_valq=__builtin_huge_valf128"); - - /* Native Data Sizes. */ - builtin_define_with_int_value ("_LOONGARCH_SZINT", INT_TYPE_SIZE); - builtin_define_with_int_value ("_LOONGARCH_SZLONG", LONG_TYPE_SIZE); - builtin_define_with_int_value ("_LOONGARCH_SZPTR", POINTER_SIZE); - builtin_define_with_int_value ("_LOONGARCH_FPSET", 32); - builtin_define_with_int_value ("_LOONGARCH_SPFPSET", 32); +void +loongarch_cpu_cpp_builtins (cpp_reader *pfile) +{ + builtin_assert ("machine=loongarch"); + builtin_assert ("cpu=loongarch"); + loongarch_define_unconditional_macros (pfile); + loongarch_update_cpp_builtins (pfile); } /* Hook to validate the current #pragma GCC target and set the state, and From patchwork Wed Feb 12 10:03:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 106365 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 16950385780D for ; Wed, 12 Feb 2025 10:04:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16950385780D X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 37BEE3858408 for ; Wed, 12 Feb 2025 10:03:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37BEE3858408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 37BEE3858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354594; cv=none; b=O8+G17YCi4kzLmo03D8W9mdr+LruqenNCZXxbC1rEFbiEAiauUe0E9t/oNAyv+uU5ATZZDGxMLqCzpauHPq8NvrP4a2oQbGihonVaxISzhsWJ1jC86GabPsWOchlsQcRQ23Oz6tNze9HRUSMt00GYAvkNfT6aXJIStp1lNrXj9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354594; c=relaxed/simple; bh=P3wijspRxOv1V968ikIpMHkSHVcnbG+p9msQK0KjBGA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=AXMrlXOuXgkAGJFan8JM+157Kg9ewNz1LxENGgYOv1CbxULDYtHS/bKLAZLywOGcYO39lhlFpW42A5Qw7BVwdwYAdQkNYo847iiNKYmHeuh6Dk0kAi2UJd7Of1RRNqIRvesYD32+BTSS/NSSavtbtwdWE99pDPHzpm2v7WH8XIM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37BEE3858408 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8DxdWnecaxn7ARzAA--.3638S3; Wed, 12 Feb 2025 18:03:10 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by front1 (Coremail) with SMTP id qMiowMCx7MTacaxnpXsNAA--.49752S5; Wed, 12 Feb 2025 18:03:10 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i.swmail@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v2 3/4] LoongArch: After setting the compilation options, update the predefined macros. Date: Wed, 12 Feb 2025 18:03:48 +0800 Message-Id: <20250212100349.11909-4-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250212100349.11909-1-chenglulu@loongson.cn> References: <20250212100349.11909-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMCx7MTacaxnpXsNAA--.49752S5 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxKr4UCry7XFykXF1ktFyfXwc_yoWxZw4UpF Zrur1rtr48JrZ3JrnxJa4Yqrnaqrn7Wryava4ftry8Cw47Jry8Xr1kJr9xZF13G3WUG34S vr4S93W5uF1jv3gCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v2 6r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07josjUUUUUU= X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP 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 PR target/118828 gcc/ChangeLog: * config/loongarch/loongarch-c.cc (loongarch_pragma_target_parse): Update the predefined macros. gcc/testsuite/ChangeLog: * gcc.target/loongarch/pr118828.c: New test. * gcc.target/loongarch/pr118828-2.c: New test. * gcc.target/loongarch/pr118828-3.c: New test. * gcc.target/loongarch/pr118828-4.c: New test. Change-Id: I13f7b44b11bba2080db797157a0389cc1bd65ac6 --- gcc/config/loongarch/loongarch-c.cc | 14 +++++ .../gcc.target/loongarch/pr118828-2.c | 30 ++++++++++ .../gcc.target/loongarch/pr118828-3.c | 55 +++++++++++++++++++ .../gcc.target/loongarch/pr118828-4.c | 55 +++++++++++++++++++ gcc/testsuite/gcc.target/loongarch/pr118828.c | 34 ++++++++++++ 5 files changed, 188 insertions(+) create mode 100644 gcc/testsuite/gcc.target/loongarch/pr118828-2.c create mode 100644 gcc/testsuite/gcc.target/loongarch/pr118828-3.c create mode 100644 gcc/testsuite/gcc.target/loongarch/pr118828-4.c create mode 100644 gcc/testsuite/gcc.target/loongarch/pr118828.c diff --git a/gcc/config/loongarch/loongarch-c.cc b/gcc/config/loongarch/loongarch-c.cc index 9a8de1ec381..66ae77ad665 100644 --- a/gcc/config/loongarch/loongarch-c.cc +++ b/gcc/config/loongarch/loongarch-c.cc @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "c-family/c-common.h" #include "cpplib.h" +#include "c-family/c-pragma.h" #include "tm_p.h" #define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM) @@ -212,6 +213,19 @@ loongarch_pragma_target_parse (tree args, tree pop_target) loongarch_reset_previous_fndecl (); + /* For the definitions, ensure all newly defined macros are considered + as used for -Wunused-macros. There is no point warning about the + compiler predefined macros. */ + cpp_options *cpp_opts = cpp_get_options (parse_in); + unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros; + cpp_opts->warn_unused_macros = 0; + + cpp_force_token_locations (parse_in, BUILTINS_LOCATION); + loongarch_update_cpp_builtins (parse_in); + cpp_stop_forcing_token_locations (parse_in); + + cpp_opts->warn_unused_macros = saved_warn_unused_macros; + /* If we're popping or reseting make sure to update the globals so that the optab availability predicates get recomputed. */ if (pop_target) diff --git a/gcc/testsuite/gcc.target/loongarch/pr118828-2.c b/gcc/testsuite/gcc.target/loongarch/pr118828-2.c new file mode 100644 index 00000000000..3d32fcc15c9 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr118828-2.c @@ -0,0 +1,30 @@ +/* { dg-do preprocess } */ +/* { dg-options "-mno-lsx" } */ + +#ifdef __loongarch_sx +#error LSX should not be available here +#endif + +#ifdef __loongarch_simd_width +#error simd width shuold not be available here +#endif + +#pragma GCC push_options +#pragma GCC target("lsx") +#ifndef __loongarch_sx +#error LSX should be available here +#endif +#ifndef __loongarch_simd_width +#error simd width should be available here +#elif __loongarch_simd_width != 128 +#error simd width should be 128 +#endif +#pragma GCC pop_options + +#ifdef __loongarch_sx +#error LSX should become unavailable again +#endif + +#ifdef __loongarch_simd_width +#error simd width shuold become unavailable again +#endif diff --git a/gcc/testsuite/gcc.target/loongarch/pr118828-3.c b/gcc/testsuite/gcc.target/loongarch/pr118828-3.c new file mode 100644 index 00000000000..a682ae4a356 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr118828-3.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-march=loongarch64" } */ + +#include +#include +#include + +#ifndef __loongarch_arch +#error __loongarch_arch should not be available here +#endif + +void +test1 (void) +{ + if (strcmp (__loongarch_arch, "loongarch64") != 0) + { + printf ("__loongarch_arch should be loongarch64 here.\n"); + abort (); + } +} + + +#pragma GCC push_options +#pragma GCC target("arch=la64v1.1") + +void +test2 (void) +{ + if (strcmp (__loongarch_arch, "la64v1.1") != 0) + { + printf ("__loongarch_arch should be la464 here.\n"); + abort (); + } +} +#pragma GCC pop_options + +void +test3 (void) +{ + if (strcmp (__loongarch_arch, "loongarch64") != 0) + { + printf ("__loongarch_arch should be loongarch64 here.\n"); + abort (); + } +} + +int +main (int argc, char **argv) +{ + test1 (); + test2 (); + test3 (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/loongarch/pr118828-4.c b/gcc/testsuite/gcc.target/loongarch/pr118828-4.c new file mode 100644 index 00000000000..3b3a7c6078c --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr118828-4.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-mtune=la464" } */ + +#include +#include +#include + +#ifndef __loongarch_tune +#error __loongarch_tune should not be available here +#endif + +void +test1 (void) +{ + if (strcmp (__loongarch_tune, "la464") != 0) + { + printf ("__loongarch_tune should be la464 here.\n"); + abort (); + } +} + + +#pragma GCC push_options +#pragma GCC target("arch=la664") + +void +test2 (void) +{ + if (strcmp (__loongarch_tune, "la664") != 0) + { + printf ("__loongarch_tune should be la664 here.\n"); + abort (); + } +} +#pragma GCC pop_options + +void +test3 (void) +{ + if (strcmp (__loongarch_tune, "la464") != 0) + { + printf ("__loongarch_tune should be la464 here.\n"); + abort (); + } +} + +int +main (int argc, char **argv) +{ + test1 (); + test2 (); + test3 (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/loongarch/pr118828.c b/gcc/testsuite/gcc.target/loongarch/pr118828.c new file mode 100644 index 00000000000..abdda24c758 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr118828.c @@ -0,0 +1,34 @@ +/* { dg-do preprocess } */ +/* { dg-options "-mno-lasx" } */ + +#ifdef __loongarch_asx +#error LASX should not be available here +#endif + +#ifdef __loongarch_simd_width +#if __loongarch_simd_width == 256 +#error simd width shuold not be 256 +#endif +#endif + +#pragma GCC push_options +#pragma GCC target("lasx") +#ifndef __loongarch_asx +#error LASX should be available here +#endif +#ifndef __loongarch_simd_width +#error simd width should be available here +#elif __loongarch_simd_width != 256 +#error simd width should be 256 +#endif +#pragma GCC pop_options + +#ifdef __loongarch_asx +#error LASX should become unavailable again +#endif + +#ifdef __loongarch_simd_width +#if __loongarch_simd_width == 256 +#error simd width shuold not be 256 again +#endif +#endif From patchwork Wed Feb 12 10:03:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 106366 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 6113F3858406 for ; Wed, 12 Feb 2025 10:04:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6113F3858406 X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id B3BCB3858C31 for ; Wed, 12 Feb 2025 10:03:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3BCB3858C31 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B3BCB3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354598; cv=none; b=Os2IIO6ezvEt7wJUVRrXpP+wHihBKPeEgi3E677/Y66hBlPW6CHV7mXsGmSNirE1iMcC7UO0iD1dxX9jLuGxFhfcyz9tuhNH2aUlf70g/XFqMC+bKvYS0uUOlj4+h6B9To/9T9RasnXw/mfU+3M/qcOpQoOWWtfxpidbiftZZFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739354598; c=relaxed/simple; bh=0ZyHNbHZXTkyCbvBMkzW17VIPevCeK0wDzPi23kPcek=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=S9KYNiU+6yGl/QpvuGl22ddpFd6HWCuWI2Wx6KIZu9fxMCCh5fNNp+WcxYp81JB4k2It/9/D13ZZ45kCLBCBtYCy9UiFcb6UQBZn6BSjNVJKgJBPL3GsFAPlRa01IvunuNYXG0LuxA+AmHcUfu4cV8gKEe5r1Pof4vprQ2tqPwE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3BCB3858C31 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8AxaeDfcaxn7wRzAA--.5185S3; Wed, 12 Feb 2025 18:03:11 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by front1 (Coremail) with SMTP id qMiowMCx7MTacaxnpXsNAA--.49752S6; Wed, 12 Feb 2025 18:03:10 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i.swmail@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v2 4/4] LoongArch: When -mfpu=none, '__loongarch_frecipe' shouldn't be defined [PR118843]. Date: Wed, 12 Feb 2025 18:03:49 +0800 Message-Id: <20250212100349.11909-5-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250212100349.11909-1-chenglulu@loongson.cn> References: <20250212100349.11909-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMCx7MTacaxnpXsNAA--.49752S6 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxZr1rCr1DGF45Kry5WF1DCFX_yoW5WrWxpa srZF1Yvr48GFZrJrn5Ja43ZFs8JrnFgw1Svanxtry0kr47J342vw1ktF9xZFyjy398tFyI 9F4rC3W5Xa1jvwcCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v2 6r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07josjUUUUUU= X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP 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 PR target/118843 gcc/ChangeLog: * config/loongarch/loongarch-c.cc (loongarch_update_cpp_builtins): Fix macro definition issues. gcc/testsuite/ChangeLog: * gcc.target/loongarch/pr118843.c: New test. Change-Id: I777e46ccbc80bfa8948e7d416ac86853c8f4c16d --- gcc/config/loongarch/loongarch-c.cc | 27 ++++++++++--------- gcc/testsuite/gcc.target/loongarch/pr118843.c | 6 +++++ 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/pr118843.c diff --git a/gcc/config/loongarch/loongarch-c.cc b/gcc/config/loongarch/loongarch-c.cc index 66ae77ad665..effdcf0e255 100644 --- a/gcc/config/loongarch/loongarch-c.cc +++ b/gcc/config/loongarch/loongarch-c.cc @@ -129,9 +129,6 @@ loongarch_update_cpp_builtins (cpp_reader *pfile) else builtin_define ("__loongarch_frlen=0"); - loongarch_def_or_undef (TARGET_HARD_FLOAT && ISA_HAS_FRECIPE, - "__loongarch_frecipe", pfile); - loongarch_def_or_undef (ISA_HAS_LSX, "__loongarch_simd", pfile); loongarch_def_or_undef (ISA_HAS_LSX, "__loongarch_sx", pfile); loongarch_def_or_undef (ISA_HAS_LASX, "__loongarch_asx", pfile); @@ -149,17 +146,23 @@ loongarch_update_cpp_builtins (cpp_reader *pfile) int max_v_major = 1, max_v_minor = 0; for (int i = 0; i < N_EVO_FEATURES; i++) - if (la_target.isa.evolution & la_evo_feature_masks[i]) - { - builtin_define (la_evo_macro_name[i]); + { + builtin_undef (la_evo_macro_name[i]); - int major = la_evo_version_major[i], - minor = la_evo_version_minor[i]; + if (la_target.isa.evolution & la_evo_feature_masks[i] + && (la_evo_feature_masks[i] != OPTION_MASK_ISA_FRECIPE + || TARGET_HARD_FLOAT)) + { + builtin_define (la_evo_macro_name[i]); - max_v_major = major > max_v_major ? major : max_v_major; - max_v_minor = major == max_v_major - ? (minor > max_v_minor ? minor : max_v_minor) : max_v_minor; - } + int major = la_evo_version_major[i], + minor = la_evo_version_minor[i]; + + max_v_major = major > max_v_major ? major : max_v_major; + max_v_minor = major == max_v_major + ? (minor > max_v_minor ? minor : max_v_minor) : max_v_minor; + } + } /* Find the minimum ISA version required to run the target program. */ builtin_undef ("__loongarch_version_major"); diff --git a/gcc/testsuite/gcc.target/loongarch/pr118843.c b/gcc/testsuite/gcc.target/loongarch/pr118843.c new file mode 100644 index 00000000000..30372b8ffe6 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr118843.c @@ -0,0 +1,6 @@ +/* { dg-do preprocess } */ +/* { dg-options "-mfrecipe -mfpu=none" } */ + +#ifdef __loongarch_frecipe +#error __loongarch_frecipe should not be avaliable here +#endif