From patchwork Tue Feb 11 12:49:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 106329 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 A40A03858CDA for ; Tue, 11 Feb 2025 12:51:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A40A03858CDA 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 2D5EC3858C51 for ; Tue, 11 Feb 2025 12:48:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D5EC3858C51 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 2D5EC3858C51 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=1739278132; cv=none; b=xzeNKJYlZd5aanQdEh5eYpxkKogCxSPwdHIh90aq4lVzjl/G9rgoiCxCBXYKHJJqj3aiBUmsITXBBayVvNkL2VaDYFGv45tGxKzwmHmJaQfMnuosvxxJkWHyzHnigswx83evuVyfWRxTShoL3/JWjpH6IoDAHGNMZlwmc6Tyaq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739278132; c=relaxed/simple; bh=+VNLT4Ve9hWJOyxxJT4T7VN52t5IhdR4yJrzEbKVkoI=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=uwbx2VW7MrmHjeS4jLo99lOHkKHQmxxRMQutkWfluS19JAUYTzEPZmqde8Jh+ajJCP9dA8ctzxuU+Y2cLVrXIHZv9P0Ksv2wBGTB68nqlLeOJPN1Ds9x4ySU+DU/AMMv2CdfqoZqTJXPunlZRPWKv2ZkCn1ukbe4+m1rog67U18= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D5EC3858C51 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8AxquAuR6tn4ChyAA--.24942S3; Tue, 11 Feb 2025 20:48:46 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by front1 (Coremail) with SMTP id qMiowMDxH+UjR6tnQAMMAA--.47337S3; Tue, 11 Feb 2025 20:48:45 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH 1/3] LoongArch: Move the function loongarch_register_pragmas to loongarch-c.cc. Date: Tue, 11 Feb 2025 20:49:15 +0800 Message-Id: <20250211124917.28685-2-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250211124917.28685-1-chenglulu@loongson.cn> References: <20250211124917.28685-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMDxH+UjR6tnQAMMAA--.47337S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW3WrW3GF1Utw15AF1fJF48Xwc_yoW7Aw4Dpr 9rury5tw4rJrZ3Gw4Dta4rX3Z8Jr17GrW29Fyftr40kw47Kry7ZryrKr9IqF1jy3y5Wry2 vF10ya1UZa1UAwcCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE14v2 6r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jY38nUUUUU= 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: I12751a6ce2f1b2f587699db3c80188066f193d2d --- 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 94d3e33cb9a..9659d5ae26e 100644 --- a/gcc/config/loongarch/loongarch-protos.h +++ b/gcc/config/loongarch/loongarch-protos.h @@ -222,4 +222,5 @@ extern void loongarch_save_restore_target_globals (tree new_tree); extern void loongarch_register_pragmas (void); extern rtx loongarch_gen_stepped_int_parallel (unsigned int nelts, int base, int step); +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; -}