OSDN Git Service

2009-10-29 Steve Ellcey <sje@cup.hp.com>
authorsje <sje@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Oct 2009 16:44:02 +0000 (16:44 +0000)
committersje <sje@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Oct 2009 16:44:02 +0000 (16:44 +0000)
PR middle-end/37565
PR target/38018
* doc/tm.texi (OVERRIDE_OPTIONS): Update.
(TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New.
* optc-gen.awk (cl_target_option_restore): Include call to
targetm.override_options_after_change.
* target-def.h (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New.
* target.h (override_options_after_change): New.
* c-common.c (parse_optimize_options): Call
targetm.override_options_after_change.
* config/ia64/ia64.c (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New.
(ia64_override_options_after_change): New.
(ia64_override_options) Add call to above.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153714 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-common.c
gcc/config/ia64/ia64.c
gcc/doc/tm.texi
gcc/optc-gen.awk
gcc/target-def.h
gcc/target.h

index e6c56b1..8a2b539 100644 (file)
@@ -1,3 +1,19 @@
+2009-10-29  Steve Ellcey  <sje@cup.hp.com>
+
+       PR middle-end/37565
+       PR target/38018
+       * doc/tm.texi (OVERRIDE_OPTIONS): Update.
+       (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New.
+       * optc-gen.awk (cl_target_option_restore): Include call to 
+       targetm.override_options_after_change.
+       * target-def.h (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New.
+       * target.h (override_options_after_change): New.
+       * c-common.c (parse_optimize_options): Call
+       targetm.override_options_after_change.
+       * config/ia64/ia64.c (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New.
+       (ia64_override_options_after_change): New.
+       (ia64_override_options) Add call to above.
+
 2009-10-29  Michael Matz  <matz@suse.de>
 
        * tree-ssa-math-opts.c (execute_convert_to_rsqrt): Remove.
 2009-10-29  Michael Matz  <matz@suse.de>
 
        * tree-ssa-math-opts.c (execute_convert_to_rsqrt): Remove.
index 1f30d06..8b85f66 100644 (file)
@@ -7825,6 +7825,8 @@ parse_optimize_options (tree args, bool attr_p)
   /* Now parse the options.  */
   decode_options (opt_argc, opt_argv);
 
   /* Now parse the options.  */
   decode_options (opt_argc, opt_argv);
 
+  targetm.override_options_after_change();
+
   /* Don't allow changing -fstrict-aliasing.  */
   flag_strict_aliasing = saved_flag_strict_aliasing;
 
   /* Don't allow changing -fstrict-aliasing.  */
   flag_strict_aliasing = saved_flag_strict_aliasing;
 
index 23fc754..8460475 100644 (file)
@@ -303,6 +303,7 @@ static enum machine_mode ia64_promote_function_mode (const_tree,
                                                     const_tree,
                                                     int);
 static void ia64_trampoline_init (rtx, tree, rtx);
                                                     const_tree,
                                                     int);
 static void ia64_trampoline_init (rtx, tree, rtx);
+static void ia64_override_options_after_change (void);
 \f
 /* Table of valid machine attributes.  */
 static const struct attribute_spec ia64_attribute_table[] =
 \f
 /* Table of valid machine attributes.  */
 static const struct attribute_spec ia64_attribute_table[] =
@@ -536,6 +537,9 @@ static const struct attribute_spec ia64_attribute_table[] =
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT ia64_trampoline_init
 
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT ia64_trampoline_init
 
+#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
+#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE ia64_override_options_after_change
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 typedef enum
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 typedef enum
@@ -5504,6 +5508,25 @@ ia64_override_options (void)
     flag_ira_loop_pressure = 1;
 
 
     flag_ira_loop_pressure = 1;
 
 
+  ia64_section_threshold = g_switch_set ? g_switch_value : IA64_DEFAULT_GVALUE;
+
+  init_machine_status = ia64_init_machine_status;
+
+  if (align_functions <= 0)
+    align_functions = 64;
+  if (align_loops <= 0)
+    align_loops = 32;
+  if (TARGET_ABI_OPEN_VMS)
+    flag_no_common = 1;
+
+  ia64_override_options_after_change();
+}
+
+/* Implement targetm.override_options_after_change.  */
+
+static void
+ia64_override_options_after_change (void)
+{
   ia64_flag_schedule_insns2 = flag_schedule_insns_after_reload;
   flag_schedule_insns_after_reload = 0;
 
   ia64_flag_schedule_insns2 = flag_schedule_insns_after_reload;
   flag_schedule_insns_after_reload = 0;
 
@@ -5525,18 +5548,6 @@ ia64_override_options (void)
          a transformation.  */
       flag_auto_inc_dec = 0;
     }
          a transformation.  */
       flag_auto_inc_dec = 0;
     }
-
-  ia64_section_threshold = g_switch_set ? g_switch_value : IA64_DEFAULT_GVALUE;
-
-  init_machine_status = ia64_init_machine_status;
-
-  if (align_functions <= 0)
-    align_functions = 64;
-  if (align_loops <= 0)
-    align_loops = 32;
-
-  if (TARGET_ABI_OPEN_VMS)
-    flag_no_common = 1;
 }
 
 /* Initialize the record of emitted frame related registers.  */
 }
 
 /* Initialize the record of emitted frame related registers.  */
index 0f33d3d..984bbd7 100644 (file)
@@ -814,8 +814,22 @@ parsed.
 
 Don't use this macro to turn on various extra optimizations for
 @option{-O}.  That is what @code{OPTIMIZATION_OPTIONS} is for.
 
 Don't use this macro to turn on various extra optimizations for
 @option{-O}.  That is what @code{OPTIMIZATION_OPTIONS} is for.
+
+If you need to do something whenever the optimization level is
+changed via the optimize attribute or pragma, see
+@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}
 @end defmac
 
 @end defmac
 
+@deftypefn {Target Hook} void TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE (void)
+This target function is similar to the macro @code{OVERRIDE_OPTIONS}
+but is called when the optimize level is changed via an attribute or
+pragma or when it is reset at the end of the code affected by the
+attribute or pragma.  It is not called at the beginning of compilation
+when @code{OVERRIDE_OPTIONS} is called so if you want to perform these
+actions then, you should have @code{OVERRIDE_OPTIONS} call
+@code{TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE}.
+@end deftypefn
+
 @defmac C_COMMON_OVERRIDE_OPTIONS
 This is similar to @code{OVERRIDE_OPTIONS} but is only used in the C
 language frontends (C, Objective-C, C++, Objective-C++) and so can be
 @defmac C_COMMON_OVERRIDE_OPTIONS
 This is similar to @code{OVERRIDE_OPTIONS} but is only used in the C
 language frontends (C, Objective-C, C++, Objective-C++) and so can be
index 2117150..992e4d3 100644 (file)
@@ -327,6 +327,7 @@ for (i = 0; i < n_opt_char; i++) {
        print "  " var_opt_char[i] " = ptr->" var_opt_char[i] ";";
 }
 
        print "  " var_opt_char[i] " = ptr->" var_opt_char[i] ";";
 }
 
+print "  targetm.override_options_after_change ();";
 print "}";
 
 print "";
 print "}";
 
 print "";
index c5a7321..e76e862 100644 (file)
 
 #define TARGET_DEFAULT_TARGET_FLAGS 0
 
 
 #define TARGET_DEFAULT_TARGET_FLAGS 0
 
+#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook_void_void
+
 #define TARGET_HANDLE_OPTION hook_bool_size_t_constcharptr_int_true
 #define TARGET_HELP NULL
 
 #define TARGET_HANDLE_OPTION hook_bool_size_t_constcharptr_int_true
 #define TARGET_HELP NULL
 
   TARGET_SCHED,                                        \
   TARGET_VECTORIZE,                            \
   TARGET_DEFAULT_TARGET_FLAGS,                 \
   TARGET_SCHED,                                        \
   TARGET_VECTORIZE,                            \
   TARGET_DEFAULT_TARGET_FLAGS,                 \
+  TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE,                \
   TARGET_HANDLE_OPTION,                                \
   TARGET_HELP,                                 \
   TARGET_EH_RETURN_FILTER_MODE,                        \
   TARGET_HANDLE_OPTION,                                \
   TARGET_HELP,                                 \
   TARGET_EH_RETURN_FILTER_MODE,                        \
index 31a54f3..6d62d52 100644 (file)
@@ -500,6 +500,11 @@ struct gcc_target
   /* The initial value of target_flags.  */
   int default_target_flags;
 
   /* The initial value of target_flags.  */
   int default_target_flags;
 
+  /* Allow target specific overriding of option settings after options have
+     been changed by an attribute or pragma or when it is reset at the
+     end of the code affected by an attribute or pragma.  */
+  void (* override_options_after_change) (void);
+
   /* Handle target switch CODE (an OPT_* value).  ARG is the argument
      passed to the switch; it is NULL if no argument was.  VALUE is the
      value of ARG if CODE specifies a UInteger option, otherwise it is
   /* Handle target switch CODE (an OPT_* value).  ARG is the argument
      passed to the switch; it is NULL if no argument was.  VALUE is the
      value of ARG if CODE specifies a UInteger option, otherwise it is