OSDN Git Service

2005-02-01 James A. Morrison <phython@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / opts.c
index 5a4873c..4439d1f 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.
@@ -76,6 +76,12 @@ enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
    write_symbols is set to DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG.  */
 bool use_gnu_debug_info_extensions;
 
+/* The default visibility for all symbols (unless overridden) */
+enum symbol_visibility default_visibility = VISIBILITY_DEFAULT;
+
+/* Global visibility options.  */
+struct visibility_flags visibility_options;
+
 /* Columns of --help display.  */
 static unsigned int columns = 80;
 
@@ -87,6 +93,7 @@ static const char undocumented_msg[] = N_("This switch lacks documentation");
 static bool profile_arc_flag_set, flag_profile_values_set;
 static bool flag_unroll_loops_set, flag_tracer_set;
 static bool flag_value_profile_transformations_set;
+bool flag_speculative_prefetching_set;
 static bool flag_peel_loops_set, flag_branch_probabilities_set;
 
 /* Input file names.  */
@@ -169,13 +176,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
@@ -380,6 +387,15 @@ handle_option (const char **argv, unsigned int lang_mask)
   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.  */
@@ -412,15 +428,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
@@ -474,7 +481,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
@@ -490,7 +496,6 @@ 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;
@@ -509,6 +514,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;
@@ -531,6 +537,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)
@@ -563,8 +575,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.  */
@@ -578,10 +592,10 @@ decode_options (unsigned int argc, const char **argv)
   target_flags = 0;
   set_target_switch ("");
 
-  /* Unwind tables are always present in an ABI-conformant IA-64
-     object file, so the default should be ON.  */
-#ifdef IA64_UNWIND_INFO
-  flag_unwind_tables = IA64_UNWIND_INFO;
+  /* Unwind tables are always present when a target has ABI-specified unwind
+     tables, so the default should be ON.  */
+#ifdef TARGET_UNWIND_INFO
+  flag_unwind_tables = TARGET_UNWIND_INFO;
 #endif
 
 #ifdef OPTIMIZATION_OPTIONS
@@ -635,6 +649,19 @@ decode_options (unsigned int argc, const char **argv)
       flag_reorder_blocks_and_partition = 0;
       flag_reorder_blocks = 1;
     }
+
+  /* The optimization to partition hot and cold basic blocks into
+     separate sections of the .o and executable files does not currently
+     work correctly with DWARF debugging turned on.  Until this is fixed
+     we will disable the optimization when DWARF debugging is set.  */
+  
+  if (flag_reorder_blocks_and_partition && write_symbols == DWARF2_DEBUG)
+    {
+      warning
+       ("-freorder-blocks-and-partition does not work with -g (currently)");
+      flag_reorder_blocks_and_partition = 0;
+      flag_reorder_blocks = 1;
+    }
 }
 
 /* Handle target- and language-independent options.  Return zero to
@@ -783,13 +810,22 @@ 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_:
       pp_set_line_maximum_length (global_dc->printer, value);
       break;
 
+    case OPT_fpack_struct_:
+      if (value <= 0 || (value & (value - 1)) || value > 16)
+       error("structure alignment must be a small power of two, not %d", value);
+      else
+       {
+         initial_max_fld_align = value;
+         maximum_field_alignment = value * BITS_PER_UNIT;
+       }
+      break;
+
     case OPT_fpeel_loops:
       flag_peel_loops_set = true;
       break;
@@ -811,6 +847,10 @@ common_handle_option (size_t scode, const char *arg, int value)
         flag_tracer = value;
       if (!flag_value_profile_transformations_set)
         flag_value_profile_transformations = value;
+#ifdef HAVE_prefetch
+      if (0 && !flag_speculative_prefetching_set)
+       flag_speculative_prefetching = value;
+#endif
       break;
 
     case OPT_fprofile_generate:
@@ -820,14 +860,39 @@ 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 (0 && !flag_speculative_prefetching_set)
+       flag_speculative_prefetching = value;
+#endif
       break;
 
     case OPT_fprofile_values:
       flag_profile_values_set = true;
       break;
 
+    case OPT_fvisibility_:
+      {
+        if (!strcmp(arg, "default"))
+          default_visibility = VISIBILITY_DEFAULT;
+        else if (!strcmp(arg, "internal"))
+          default_visibility = VISIBILITY_INTERNAL;
+        else if (!strcmp(arg, "hidden"))
+          default_visibility = VISIBILITY_HIDDEN;
+        else if (!strcmp(arg, "protected"))
+          default_visibility = VISIBILITY_PROTECTED;
+        else
+          error ("unrecognised visibility value \"%s\"", arg);
+      }
+      break;
+
     case OPT_fvpt:
-      flag_value_profile_transformations_set = value;
+      flag_value_profile_transformations_set = true;
+      break;
+
+    case OPT_fspeculative_prefetching:
+      flag_speculative_prefetching_set = true;
       break;
 
     case OPT_frandom_seed:
@@ -897,22 +962,6 @@ common_handle_option (size_t scode, const char *arg, int value)
       flag_tracer_set = true;
       break;
 
-    case OPT_ftree_points_to_:
-      if (!strcmp (arg, "andersen"))
-#ifdef HAVE_BANSHEE
-        flag_tree_points_to = PTA_ANDERSEN;
-#else
-        warning ("Andersen's PTA not available - libbanshee not compiled.");
-#endif
-      else if (!strcmp (arg, "none"))
-       flag_tree_points_to = PTA_NONE;
-      else
-       {
-         warning ("`%s`: unknown points-to analysis algorithm", arg);
-         return 0;
-       }
-      break;
-
     case OPT_funroll_loops:
       flag_unroll_loops_set = true;
       break;
@@ -986,7 +1035,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';