OSDN Git Service

PR middle-end/20493
[pf3gnuchains/gcc-fork.git] / gcc / opts.c
index d570b8f..3befb1d 100644 (file)
@@ -1,5 +1,5 @@
 /* Command line option handling.
-   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Neil Booth.
 
 This file is part of GCC.
@@ -112,7 +112,6 @@ static void handle_options (unsigned int, const char **, unsigned int);
 static void wrap_help (const char *help, const char *item, unsigned int);
 static void print_help (void);
 static void print_param_help (void);
-static void print_filtered_help (unsigned int flag);
 static unsigned int print_switch (const char *text, unsigned int indent);
 static void set_debug_level (enum debug_info_type type, int extended,
                             const char *arg);
@@ -176,13 +175,13 @@ find_opt (const char *input, int lang_mask)
     {
       const struct cl_option *opt = &cl_options[mn];
 
-      /* Is this switch a prefix of the input?  */
-      if (!strncmp (input, opt->opt_text + 1, opt->opt_len))
+      /* Is the input either an exact match or a prefix that takes a
+        joined argument?  */
+      if (!strncmp (input, opt->opt_text + 1, opt->opt_len)
+         && (input[opt->opt_len] == '\0' || (opt->flags & CL_JOINED)))
        {
-         /* If language is OK, and the match is exact or the switch
-            takes a joined argument, return it.  */
-         if ((opt->flags & lang_mask)
-             && (input[opt->opt_len] == '\0' || (opt->flags & CL_JOINED)))
+         /* If language is OK, return it.  */
+         if (opt->flags & lang_mask)
            return mn;
 
          /* If we haven't remembered a prior match, remember this
@@ -277,10 +276,12 @@ handle_option (const char **argv, unsigned int lang_mask)
 
   opt = argv[0];
 
-  /* Drop the "no-" from negative switches.  */
-  if ((opt[1] == 'W' || opt[1] == 'f')
+  opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
+  if (opt_index == cl_options_count
+      && (opt[1] == 'W' || opt[1] == 'f' || opt[1] == 'm')
       && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
     {
+      /* Drop the "no-" from negative switches.  */
       size_t len = strlen (opt) - 3;
 
       dup = xmalloc (len + 1);
@@ -289,11 +290,20 @@ handle_option (const char **argv, unsigned int lang_mask)
       memcpy (dup + 2, opt + 5, len - 2 + 1);
       opt = dup;
       value = 0;
+      opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
     }
 
-  opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
   if (opt_index == cl_options_count)
-    goto done;
+    {
+#if defined (TARGET_OPTIONS) || defined (TARGET_SWITCHES)
+      if (opt[1] == 'm')
+       {
+         set_target_switch (argv[0] + 2);
+         result = 1;
+       }
+#endif
+      goto done;
+    }
 
   option = &cl_options[opt_index];
 
@@ -335,7 +345,7 @@ handle_option (const char **argv, unsigned int lang_mask)
 
   /* Now we've swallowed any potential argument, complain if this
      is a switch for a different front end.  */
-  if (!(option->flags & (lang_mask | CL_COMMON)))
+  if (!(option->flags & (lang_mask | CL_COMMON | CL_TARGET)))
     {
       complain_wrong_lang (argv[0], option, lang_mask);
       goto done;
@@ -361,17 +371,26 @@ handle_option (const char **argv, unsigned int lang_mask)
     }
 
   if (option->flag_var)
-    {
-      if (option->has_set_value)
-       {
-         if (value)
-           *option->flag_var = option->set_value;
-         else
-           *option->flag_var = !option->set_value;
-       }
-      else
+    switch (option->var_cond)
+      {
+      case CLVC_BOOLEAN:
        *option->flag_var = value;
-    }
+       break;
+
+      case CLVC_EQUAL:
+       *option->flag_var = value ? option->var_value : !option->var_value;
+       break;
+
+      case CLVC_BIT_CLEAR:
+      case CLVC_BIT_SET:
+       if ((value != 0) == (option->var_cond == CLVC_BIT_SET))
+         *option->flag_var |= option->var_value;
+       else
+         *option->flag_var &= ~option->var_value;
+       if (option->flag_var == &target_flags)
+         target_flags_explicit |= option->var_value;
+       break;
+      }
   
   if (option->flags & lang_mask)
     if (lang_hooks.handle_option (opt_index, arg, value) == 0)
@@ -381,12 +400,25 @@ handle_option (const char **argv, unsigned int lang_mask)
     if (common_handle_option (opt_index, arg, value) == 0)
       result = 0;
 
+  if (result && (option->flags & CL_TARGET))
+    if (!targetm.handle_option (opt_index, arg, value))
+      result = 0;
+
  done:
   if (dup)
     free (dup);
   return result;
 }
 
+/* Handle FILENAME from the command line.  */
+static void
+add_input_filename (const char *filename)
+{
+  num_in_fnames++;
+  in_fnames = xrealloc (in_fnames, num_in_fnames * sizeof (in_fnames[0]));
+  in_fnames[num_in_fnames - 1] = filename;
+}
+
 /* Decode and handle the vector of command line options.  LANG_MASK
    contains has a single bit set representing the current
    language.  */
@@ -419,15 +451,6 @@ handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
     }
 }
 
-/* Handle FILENAME from the command line.  */
-void
-add_input_filename (const char *filename)
-{
-  num_in_fnames++;
-  in_fnames = xrealloc (in_fnames, num_in_fnames * sizeof (in_fnames[0]));
-  in_fnames[num_in_fnames - 1] = filename;
-}
-
 /* Parse command line options and set default flag values.  Do minimal
    options processing.  */
 void
@@ -481,7 +504,6 @@ decode_options (unsigned int argc, const char **argv)
   if (optimize >= 1)
     {
       flag_defer_pop = 1;
-      flag_thread_jumps = 1;
 #ifdef DELAY_SLOTS
       flag_delayed_branch = 1;
 #endif
@@ -497,12 +519,13 @@ decode_options (unsigned int argc, const char **argv)
       flag_tree_dce = 1;
       flag_tree_dom = 1;
       flag_tree_dse = 1;
-      flag_tree_pre = 1;
       flag_tree_ter = 1;
       flag_tree_live_range_split = 1;
       flag_tree_sra = 1;
       flag_tree_copyrename = 1;
       flag_tree_fre = 1;
+      flag_tree_sink = 1;
+      flag_tree_salias = 1;
 
       if (!optimize_size)
        {
@@ -516,6 +539,7 @@ decode_options (unsigned int argc, const char **argv)
 
   if (optimize >= 2)
     {
+      flag_thread_jumps = 1;
       flag_crossjumping = 1;
       flag_optimize_sibling_calls = 1;
       flag_cse_follow_jumps = 1;
@@ -538,6 +562,12 @@ decode_options (unsigned int argc, const char **argv)
       flag_reorder_blocks = 1;
       flag_reorder_functions = 1;
       flag_unit_at_a_time = 1;
+
+      if (!optimize_size)
+       {
+          /* PRE tends to generate bigger code.  */
+          flag_tree_pre = 1;
+       }
     }
 
   if (optimize >= 3)
@@ -570,8 +600,10 @@ decode_options (unsigned int argc, const char **argv)
       /* Inlining of very small functions usually reduces total size.  */
       set_param_value ("max-inline-insns-single", 5);
       set_param_value ("max-inline-insns-auto", 5);
-      set_param_value ("max-inline-insns-rtl", 10);
       flag_inline_functions = 1;
+
+      /* We want to crossjump as much as possible.  */
+      set_param_value ("min-crossjump-insns", 1);
     }
 
   /* Initialize whether `char' is signed.  */
@@ -582,7 +614,7 @@ decode_options (unsigned int argc, const char **argv)
 
   /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
      modify it.  */
-  target_flags = 0;
+  target_flags = targetm.default_target_flags;
   set_target_switch ("");
 
   /* Unwind tables are always present when a target has ABI-specified unwind
@@ -803,7 +835,6 @@ common_handle_option (size_t scode, const char *arg, int value)
     case OPT_finline_limit_eq:
       set_param_value ("max-inline-insns-single", value / 2);
       set_param_value ("max-inline-insns-auto", value / 2);
-      set_param_value ("max-inline-insns-rtl", value);
       break;
 
     case OPT_fmessage_length_:
@@ -842,7 +873,7 @@ common_handle_option (size_t scode, const char *arg, int value)
       if (!flag_value_profile_transformations_set)
         flag_value_profile_transformations = value;
 #ifdef HAVE_prefetch
-      if (!flag_speculative_prefetching_set)
+      if (0 && !flag_speculative_prefetching_set)
        flag_speculative_prefetching = value;
 #endif
       break;
@@ -854,8 +885,10 @@ common_handle_option (size_t scode, const char *arg, int value)
         flag_profile_values = value;
       if (!flag_value_profile_transformations_set)
         flag_value_profile_transformations = value;
+      if (!flag_unroll_loops_set)
+       flag_unroll_loops = value;
 #ifdef HAVE_prefetch
-      if (!flag_speculative_prefetching_set)
+      if (0 && !flag_speculative_prefetching_set)
        flag_speculative_prefetching = value;
 #endif
       break;
@@ -937,6 +970,10 @@ common_handle_option (size_t scode, const char *arg, int value)
       stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg));
       break;
 
+    case OPT_ftree_vectorizer_verbose_:
+      vect_set_verbosity_level (arg);
+      break;
+
     case OPT_ftls_model_:
       if (!strcmp (arg, "global-dynamic"))
        flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
@@ -988,10 +1025,6 @@ common_handle_option (size_t scode, const char *arg, int value)
       set_debug_level (XCOFF_DEBUG, code == OPT_gxcoff_, arg);
       break;
 
-    case OPT_m:
-      set_target_switch (arg);
-      break;
-
     case OPT_o:
       asm_file_name = arg;
       break;
@@ -1027,7 +1060,7 @@ handle_param (const char *carg)
     {
       value = integral_argument (equal + 1);
       if (value == -1)
-       error ("invalid --param value `%s'", equal + 1);
+       error ("invalid --param value %qs", equal + 1);
       else
        {
          *equal = '\0';
@@ -1085,6 +1118,7 @@ set_fast_math_flags (int set)
     {
       flag_signaling_nans = 0;
       flag_rounding_math = 0;
+      flag_cx_limited_range = 1;
     }
 }
 
@@ -1208,7 +1242,7 @@ print_param_help (void)
 }
 
 /* Print help for a specific front-end, etc.  */
-static void
+void
 print_filtered_help (unsigned int flag)
 {
   unsigned int i, len, filter, indent = 0;
@@ -1216,7 +1250,7 @@ print_filtered_help (unsigned int flag)
   const char *help, *opt, *tab;
   static char *printed;
 
-  if (flag == CL_COMMON)
+  if (flag == CL_COMMON || flag == CL_TARGET)
     {
       filter = flag;
       if (!printed)
@@ -1363,3 +1397,27 @@ wrap_help (const char *help, const char *item, unsigned int item_width)
     }
   while (remaining);
 }
+
+/* Return 1 if OPTION is enabled, 0 if it is disabled, or -1 if it isn't
+   a simple on-off switch.  */
+
+int
+option_enabled (const struct cl_option *option)
+{
+  if (option->flag_var)
+    switch (option->var_cond)
+      {
+      case CLVC_BOOLEAN:
+       return *option->flag_var != 0;
+
+      case CLVC_EQUAL:
+       return *option->flag_var == option->var_value;
+
+      case CLVC_BIT_CLEAR:
+       return (*option->flag_var & option->var_value) == 0;
+
+      case CLVC_BIT_SET:
+       return (*option->flag_var & option->var_value) != 0;
+      }
+  return -1;
+}