]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Move the function loongarch_register_pragmas to loongarch-c.cc.
authorLulu Cheng <chenglulu@loongson.cn>
Wed, 12 Feb 2025 01:57:02 +0000 (09:57 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Fri, 14 Feb 2025 07:48:32 +0000 (15:48 +0800)
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.

gcc/config/loongarch/loongarch-c.cc
gcc/config/loongarch/loongarch-protos.h
gcc/config/loongarch/loongarch-target-attr.cc

index c95c0f373be6b479a6d97c71854302784a2b27b3..5d8c02e094bcb439ac2a9904c0d3bcd35330490a 100644 (file)
@@ -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;
+}
index b99f949a004ef25d4befe7f9fe2964e872004f38..e7b318143bfebc59e95e2e9fbb5fc48edad88356 100644 (file)
@@ -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 */
index cee7031ca1e76addfa31c8b163eade4fc6620323..cb537446dffe13169f81123a5b30636bcd3611b7 100644 (file)
@@ -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;
-}