diff mbox

[18/21,arm] Use cl_target_options for configuring the active target.

Message ID d12de2c1-59ba-59f0-88c7-d814364673ce@arm.com
State New
Headers show

Commit Message

Richard Earnshaw (lists) Dec. 15, 2016, 4:07 p.m. UTC
It now becomes apparent that it would be better to use the the
cl_target_options as the basis for calling arm_configure_build_target;
it already contains exactly the same fields that we need.  I chose not
to rewrite the earlier patches as that would make the progression of
changes seem less logical than it currently is, with several early
changes having no immediate justification.

	* arm-protos.h (arm_configure_build_target): Change second argument
	to cl_target_options.
	* arm.c (arm_configure_build_target): Likewise.
	(arm_option_restore): Update accordingly.
	(arm_option_override): Create the target_option_default_node before
	calling arm_configure_build_target.  Use it in call of latter.
	Resynchronize after all other overrides have been calculated.
	(arm_valid_target_attribute_tree): Use the target options for
	reconfiguration.  Resynchronize after performing override checks.
	* arm-c.c (arm_pragma_target_parse): Use target optiosn from cur_tree
	to reconfigure the build target.
---
 gcc/config/arm/arm-c.c      |  3 ++-
 gcc/config/arm/arm-protos.h |  2 +-
 gcc/config/arm/arm.c        | 36 ++++++++++++++++++++++++------------
 3 files changed, 27 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c
index 9dd9a8d..b57af69 100644
--- a/gcc/config/arm/arm-c.c
+++ b/gcc/config/arm/arm-c.c
@@ -243,7 +243,8 @@  arm_pragma_target_parse (tree args, tree pop_target)
       /* handle_pragma_pop_options and handle_pragma_reset_options will set
        target_option_current_node, but not handle_pragma_target.  */
       target_option_current_node = cur_tree;
-      arm_configure_build_target (&arm_active_target, &global_options,
+      arm_configure_build_target (&arm_active_target,
+				  TREE_TARGET_OPTION (cur_tree),
 				  &global_options_set, false);
     }
 
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index da3484f..d418ca9 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -225,7 +225,7 @@  extern bool arm_change_mode_p (tree);
 extern tree arm_valid_target_attribute_tree (tree, struct gcc_options *,
 					     struct gcc_options *);
 extern void arm_configure_build_target (struct arm_build_target *,
-					struct gcc_options *,
+					struct cl_target_option *,
 					struct gcc_options *, bool);
 extern void arm_pr_long_calls (struct cpp_reader *);
 extern void arm_pr_no_long_calls (struct cpp_reader *);
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 676c78b..df520e5 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -2936,16 +2936,17 @@  arm_override_options_after_change_1 (struct gcc_options *opts)
 static void
 arm_override_options_after_change (void)
 {
-  arm_configure_build_target (&arm_active_target, &global_options,
+  arm_configure_build_target (&arm_active_target,
+			      TREE_TARGET_OPTION (target_option_default_node),
 			      &global_options_set, false);
 
   arm_override_options_after_change_1 (&global_options);
 }
 
 static void
-arm_option_restore (struct gcc_options *opts, struct cl_target_option *ptr)
+arm_option_restore (struct gcc_options *, struct cl_target_option *ptr)
 {
-  arm_configure_build_target (&arm_active_target, opts, &global_options_set,
+  arm_configure_build_target (&arm_active_target, ptr, &global_options_set,
 			      false);
 }
 
@@ -3070,7 +3071,7 @@  static sbitmap isa_quirkbits;
    architecture have been specified, but the two are not identical.  */
 void
 arm_configure_build_target (struct arm_build_target *target,
-			    struct gcc_options *opts,
+			    struct cl_target_option *opts,
 			    struct gcc_options *opts_set,
 			    bool warn_compatible)
 {
@@ -3306,7 +3307,13 @@  arm_option_override (void)
       gcc_assert (ok);
     }
 
-  arm_configure_build_target (&arm_active_target, &global_options,
+  /* Create the default target_options structure.  We need this early
+     to configure the overall build target.  */
+  target_option_default_node = target_option_current_node
+    = build_target_option_node (&global_options);
+
+  arm_configure_build_target (&arm_active_target,
+			      TREE_TARGET_OPTION (target_option_default_node),
 			      &global_options_set, true);
 
 #ifdef SUBTARGET_OVERRIDE_OPTIONS
@@ -3657,14 +3664,12 @@  arm_option_override (void)
   arm_option_check_internal (&global_options);
   arm_option_params_internal ();
 
+  /* Resynchronize the saved target options.  */
+  cl_target_option_save (TREE_TARGET_OPTION (target_option_default_node),
+			 &global_options);
   /* Register global variables with the garbage collector.  */
   arm_add_gc_roots ();
 
-  /* Save the initial options in case the user does function specific
-     options or #pragma target.  */
-  target_option_default_node = target_option_current_node
-    = build_target_option_node (&global_options);
-
   /* Init initial mode for testing.  */
   thumb_flipper = TARGET_THUMB;
 }
@@ -30326,15 +30331,22 @@  tree
 arm_valid_target_attribute_tree (tree args, struct gcc_options *opts,
 				 struct gcc_options *opts_set)
 {
+  tree t;
+
   if (!arm_valid_target_attribute_rec (args, opts))
     return NULL_TREE;
 
-  arm_configure_build_target (&arm_active_target, opts, opts_set, false);
+  t = build_target_option_node (opts);
+  arm_configure_build_target (&arm_active_target, TREE_TARGET_OPTION (t),
+			      opts_set, false);
   arm_option_check_internal (opts);
   /* Do any overrides, such as global options arch=xxx.  */
   arm_option_override_internal (opts, opts_set);
 
-  return build_target_option_node (opts);
+  /* Resynchronize the saved target options.  */
+  cl_target_option_save (TREE_TARGET_OPTION (t), opts);
+
+  return t;
 }
 
 static void