OSDN Git Service

* config/avr/avr.h (PREFERRED_RELOAD_CLASS): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / opts.c
index efee21e..52f8c6d 100644 (file)
@@ -362,12 +362,15 @@ static bool common_handle_option (struct gcc_options *opts,
                                  const struct cl_decoded_option *decoded,
                                  unsigned int lang_mask, int kind,
                                  const struct cl_option_handlers *handlers);
-static void handle_param (const char *);
+static void handle_param (struct gcc_options *opts,
+                         struct gcc_options *opts_set, const char *carg);
 static char *write_langs (unsigned int lang_mask);
 static void complain_wrong_lang (const struct cl_decoded_option *,
                                 unsigned int lang_mask);
 static void set_debug_level (enum debug_info_type type, int extended,
                             const char *arg);
+static void set_fast_math_flags (int set);
+static void set_unsafe_math_optimizations_flags (int set);
 
 /* Return a malloced slash-separated list of languages in MASK.  */
 static char *
@@ -652,11 +655,6 @@ read_cmdline_options (struct gcc_options *opts, struct gcc_options *opts_set,
 /* Language mask determined at initialization.  */
 static unsigned int initial_lang_mask;
 
-/* Initial values of parameters we reset.  */
-static int initial_min_crossjump_insns;
-static int initial_max_fields_for_field_sensitive;
-static int initial_loop_invariant_max_bbs_in_loop;
-
 /* Initialize global options-related settings at start-up.  */
 
 void
@@ -666,14 +664,6 @@ init_options_once (void)
   initial_lang_mask = lang_hooks.option_lang_mask ();
 
   lang_hooks.initialize_diagnostics (global_dc);
-
-  /* Save initial values of parameters we reset.  */
-  initial_min_crossjump_insns
-    = compiler_params[PARAM_MIN_CROSSJUMP_INSNS].value;
-  initial_max_fields_for_field_sensitive
-    = compiler_params[PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE].value;
-  initial_loop_invariant_max_bbs_in_loop
-    = compiler_params[PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP].value;
 }
 
 /* Initialize OPTS and OPTS_SET before using them in parsing options.  */
@@ -681,9 +671,15 @@ init_options_once (void)
 void
 init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
 {
+  size_t num_params = get_num_compiler_params ();
+
   *opts = global_options_init;
   memset (opts_set, 0, sizeof (*opts_set));
 
+  opts->x_param_values = XNEWVEC (int, num_params);
+  opts_set->x_param_values = XCNEWVEC (int, num_params);
+  init_param_values (opts->x_param_values);
+
   /* Use priority coloring if cover classes is not defined for the
      target.  */
   if (targetm.ira_cover_classes == NULL)
@@ -701,6 +697,9 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
 
   /* Some targets have ABI-specified unwind tables.  */
   opts->x_flag_unwind_tables = targetm.unwind_tables_default;
+
+  /* Some targets have other target-specific initialization.  */
+  targetm.target_option.init_struct (opts);
 }
 
 /* Decode command-line options to an array, like
@@ -853,12 +852,16 @@ default_options_optimization (struct gcc_options *opts,
   flag_ipa_sra = opt2;
 
   /* Track fields in field-sensitive alias analysis.  */
-  set_param_value ("max-fields-for-field-sensitive",
-                  (opt2) ? 100 : initial_max_fields_for_field_sensitive);
+  maybe_set_param_value
+    (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE,
+     opt2 ? 100 : default_param_value (PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE),
+     opts->x_param_values, opts_set->x_param_values);
 
   /* For -O1 only do loop invariant motion for very small loops.  */
-  set_param_value ("loop-invariant-max-bbs-in-loop",
-                  (opt2) ? initial_loop_invariant_max_bbs_in_loop : 1000);
+  maybe_set_param_value
+    (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP,
+     opt2 ? default_param_value (PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP) : 1000,
+     opts->x_param_values, opts_set->x_param_values);
 
   /* -O3 optimizations.  */
   opt3 = (optimize >= 3);
@@ -891,10 +894,13 @@ default_options_optimization (struct gcc_options *opts,
        optimize = 2;
 
       /* We want to crossjump as much as possible.  */
-      set_param_value ("min-crossjump-insns", 1);
+      maybe_set_param_value (PARAM_MIN_CROSSJUMP_INSNS, 1,
+                            opts->x_param_values, opts_set->x_param_values);
     }
   else
-    set_param_value ("min-crossjump-insns", initial_min_crossjump_insns);
+    maybe_set_param_value (PARAM_MIN_CROSSJUMP_INSNS,
+                          default_param_value (PARAM_MIN_CROSSJUMP_INSNS),
+                          opts->x_param_values, opts_set->x_param_values);
 
   /* -Ofast adds optimizations to -O3.  */
   if (ofast)
@@ -1001,7 +1007,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set)
      section-anchors.  */
   if (!flag_unit_at_a_time)
     {
-      if (flag_section_anchors == 1)
+      if (flag_section_anchors && opts_set->x_flag_section_anchors)
        error ("Section anchors must be disabled when unit-at-a-time "
               "is disabled.");
       flag_section_anchors = 0;
@@ -1018,14 +1024,16 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set)
   /* Unless the user has asked for section anchors, we disable toplevel
      reordering at -O0 to disable transformations that might be surprising
      to end users and to get -fno-toplevel-reorder tested.  */
-  if (!optimize && flag_toplevel_reorder == 2 && flag_section_anchors != 1)
+  if (!optimize
+      && flag_toplevel_reorder == 2
+      && !(flag_section_anchors && opts_set->x_flag_section_anchors))
     {
       flag_toplevel_reorder = 0;
       flag_section_anchors = 0;
     }
   if (!flag_toplevel_reorder)
     {
-      if (flag_section_anchors == 1)
+      if (flag_section_anchors && opts_set->x_flag_section_anchors)
        error ("section anchors must be disabled when toplevel reorder"
               " is disabled");
       flag_section_anchors = 0;
@@ -1114,10 +1122,10 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set)
 
   if (flag_conserve_stack)
     {
-      if (!PARAM_SET_P (PARAM_LARGE_STACK_FRAME))
-        PARAM_VALUE (PARAM_LARGE_STACK_FRAME) = 100;
-      if (!PARAM_SET_P (PARAM_STACK_FRAME_GROWTH))
-        PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 40;
+      maybe_set_param_value (PARAM_LARGE_STACK_FRAME, 100,
+                            opts->x_param_values, opts_set->x_param_values);
+      maybe_set_param_value (PARAM_STACK_FRAME_GROWTH, 40,
+                            opts->x_param_values, opts_set->x_param_values);
     }
   if (flag_wpa || flag_ltrans)
     {
@@ -1507,7 +1515,7 @@ common_handle_option (struct gcc_options *opts,
   switch (code)
     {
     case OPT__param:
-      handle_param (arg);
+      handle_param (opts, opts_set, arg);
       break;
 
     case OPT_v:
@@ -1827,8 +1835,10 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_finline_limit_:
-      set_param_value ("max-inline-insns-single", value / 2);
-      set_param_value ("max-inline-insns-auto", value / 2);
+      set_param_value ("max-inline-insns-single", value / 2,
+                      opts->x_param_values, opts_set->x_param_values);
+      set_param_value ("max-inline-insns-auto", value / 2,
+                      opts->x_param_values, opts_set->x_param_values);
       break;
 
     case OPT_finstrument_functions_exclude_function_list_:
@@ -2123,7 +2133,8 @@ common_handle_option (struct gcc_options *opts,
 
 /* Handle --param NAME=VALUE.  */
 static void
-handle_param (const char *carg)
+handle_param (struct gcc_options *opts, struct gcc_options *opts_set,
+             const char *carg)
 {
   char *equal, *arg;
   int value;
@@ -2140,7 +2151,8 @@ handle_param (const char *carg)
       else
        {
          *equal = '\0';
-         set_param_value (arg, value);
+         set_param_value (arg, value,
+                          opts->x_param_values, opts_set->x_param_values);
        }
     }
 
@@ -2165,7 +2177,7 @@ set_Wstrict_aliasing (int onoff)
 
 /* The following routines are useful in setting all the flags that
    -ffast-math and -fno-fast-math imply.  */
-void
+static void
 set_fast_math_flags (int set)
 {
   flag_unsafe_math_optimizations = set;
@@ -2182,7 +2194,7 @@ set_fast_math_flags (int set)
 
 /* When -funsafe-math-optimizations is set the following
    flags are set as well.  */
-void
+static void
 set_unsafe_math_optimizations_flags (int set)
 {
   flag_trapping_math = !set;