OSDN Git Service

* config.gcc (extra_options): New variable for listing option files.
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
index f63e80b..04b02bc 100644 (file)
@@ -1,6 +1,6 @@
 /* Top level of GCC compilers (cc1, cc1plus, etc.)
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -61,7 +61,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "intl.h"
 #include "ggc.h"
 #include "graph.h"
-#include "loop.h"
 #include "regs.h"
 #include "timevar.h"
 #include "diagnostic.h"
@@ -81,6 +80,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "coverage.h"
 #include "value-prof.h"
 #include "alloc-pool.h"
+#include "tree-mudflap.h"
 
 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
 #include "dwarf2out.h"
@@ -267,15 +267,9 @@ int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
 
 /* 0 means straightforward implementation of complex divide acceptable.
    1 means wide ranges of inputs must work for complex divide.
-   2 means C99-like requirements for complex divide (not yet implemented).  */
+   2 means C99-like requirements for complex multiply and divide.  */
 
-int flag_complex_divide_method = 0;
-
-/* Nonzero means performs web construction pass.  When flag_web ==
-   AUTODETECT_FLAG_VAR_TRACKING it will be set according to optimize
-   and default_debug_hooks in process_options ().  */
-
-int flag_web = AUTODETECT_FLAG_VAR_TRACKING;
+int flag_complex_method = 1;
 
 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
    not just because the tree inliner turned us off.  */
@@ -373,13 +367,14 @@ int flag_evaluation_order = 0;
 const char *user_label_prefix;
 
 static const param_info lang_independent_params[] = {
-#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
-  { OPTION, DEFAULT, HELP },
+#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
+  { OPTION, DEFAULT, MIN, MAX, HELP },
 #include "params.def"
 #undef DEFPARAM
-  { NULL, 0, NULL }
+  { NULL, 0, 0, 0, NULL }
 };
 
+#ifdef TARGET_SWITCHES
 /* Here is a table, controlled by the tm.h file, listing each -m switch
    and which bits in `target_switches' it should set or clear.
    If VALUE is positive, it is bits to set.
@@ -393,6 +388,7 @@ static const struct
   const char *const description;
 }
 target_switches[] = TARGET_SWITCHES;
+#endif
 
 /* This table is similar, but allows the switch to have a value.  */
 
@@ -418,7 +414,7 @@ int warn_return_type;
 FILE *asm_out_file;
 FILE *aux_info_file;
 FILE *dump_file = NULL;
-char *dump_file_name;
+const char *dump_file_name;
 
 /* The current working directory of a translation.  It's generally the
    directory from which compilation was initiated, but a preprocessed
@@ -455,7 +451,11 @@ const char *
 get_src_pwd (void)
 {
   if (! src_pwd)
-    src_pwd = getpwd ();
+    {
+      src_pwd = getpwd ();
+      if (!src_pwd)
+       src_pwd = ".";
+    }
 
    return src_pwd;
 }
@@ -535,7 +535,7 @@ read_integral_parameter (const char *p, const char *pname, const int  defval)
   if (*endp != 0)
     {
       if (pname != 0)
-       error ("invalid option argument `%s'", pname);
+       error ("invalid option argument %qs", pname);
       return defval;
     }
 
@@ -543,20 +543,23 @@ read_integral_parameter (const char *p, const char *pname, const int  defval)
 }
 
 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
-   If X is 0, return -1.
-
-   This should be used via the floor_log2 macro.  */
+   If X is 0, return -1.  */
 
 int
-floor_log2_wide (unsigned HOST_WIDE_INT x)
+floor_log2 (unsigned HOST_WIDE_INT x)
 {
-  int t=0;
+  int t = 0;
+
   if (x == 0)
     return -1;
-  if (sizeof (HOST_WIDE_INT) * 8 > 64)
+
+#ifdef CLZ_HWI
+  t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
+#else
+  if (HOST_BITS_PER_WIDE_INT > 64)
     if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
       t += 64;
-  if (sizeof (HOST_WIDE_INT) * 8 > 32)
+  if (HOST_BITS_PER_WIDE_INT > 32)
     if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 32))
       t += 32;
   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 16))
@@ -569,21 +572,24 @@ floor_log2_wide (unsigned HOST_WIDE_INT x)
     t += 2;
   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
     t += 1;
+#endif
+
   return t;
 }
 
 /* Return the logarithm of X, base 2, considering X unsigned,
-   if X is a power of 2.  Otherwise, returns -1.
-
-   This should be used via the `exact_log2' macro.  */
+   if X is a power of 2.  Otherwise, returns -1.  */
 
 int
-exact_log2_wide (unsigned HOST_WIDE_INT x)
+exact_log2 (unsigned HOST_WIDE_INT x)
 {
-  /* Test for 0 or a power of 2.  */
-  if (x == 0 || x != (x & -x))
+  if (x != (x & -x))
     return -1;
-  return floor_log2_wide (x);
+#ifdef CTZ_HWI
+  return x ? CTZ_HWI (x) : -1;
+#else
+  return floor_log2 (x);
+#endif
 }
 
 /* Handler for fatal signals, such as SIGSEGV.  These are transformed
@@ -819,13 +825,13 @@ check_global_declarations (tree *vec, int len)
     {
       decl = vec[i];
 
-      if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
-         && ! TREE_ASM_WRITTEN (decl))
-       /* Cancel the RTL for this decl so that, if debugging info
-          output for global variables is still to come,
-          this one will be omitted.  */
-       SET_DECL_RTL (decl, NULL_RTX);
-
+      /* Do not emit debug information about variables that are in
+        static storage, but not defined.  */
+      if (TREE_CODE (decl) == VAR_DECL
+         && TREE_STATIC (decl)
+         && !TREE_ASM_WRITTEN (decl))
+       DECL_IGNORED_P (decl) = 1;
       /* Warn about any function
         declared static but not defined.
         We don't warn about variables,
@@ -841,9 +847,10 @@ check_global_declarations (tree *vec, int len)
              || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
        {
          if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
-           pedwarn ("%J'%F' used but never defined", decl, decl);
+           pedwarn ("%J%qF used but never defined", decl, decl);
          else
-           warning ("%J'%F' declared `static' but never defined", decl, decl);
+           warning ("%J%qF declared %<static%> but never defined",
+                    decl, decl);
          /* This symbol is effectively an "extern" declaration now.  */
          TREE_PUBLIC (decl) = 1;
          assemble_external (decl);
@@ -868,7 +875,7 @@ check_global_declarations (tree *vec, int len)
          && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
          /* Otherwise, ask the language.  */
          && lang_hooks.decls.warn_unused_global (decl))
-       warning ("%J'%D' defined but not used", decl, decl);
+       warning ("%J%qD defined but not used", decl, decl);
 
       /* Avoid confusing the debug information machinery when there are
         errors.  */
@@ -891,7 +898,7 @@ warn_deprecated_use (tree node)
   if (DECL_P (node))
     {
       expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
-      warning ("`%s' is deprecated (declared at %s:%d)",
+      warning ("%qs is deprecated (declared at %s:%d)",
               IDENTIFIER_POINTER (DECL_NAME (node)),
               xloc.file, xloc.line);
     }
@@ -914,7 +921,7 @@ warn_deprecated_use (tree node)
          expanded_location xloc
            = expand_location (DECL_SOURCE_LOCATION (decl));
          if (what)
-           warning ("`%s' is deprecated (declared at %s:%d)", what,
+           warning ("%qs is deprecated (declared at %s:%d)", what,
                       xloc.file, xloc.line);
          else
            warning ("type is deprecated (declared at %s:%d)",
@@ -923,7 +930,7 @@ warn_deprecated_use (tree node)
       else
        {
          if (what)
-           warning ("`%s' is deprecated", what);
+           warning ("%qs is deprecated", what);
          else
            warning ("type is deprecated");
        }
@@ -1010,6 +1017,10 @@ compile_file (void)
      functions in this compilation unit were deferred.  */
   coverage_finish ();
 
+  /* Likewise for mudflap static object registrations.  */
+  if (flag_mudflap)
+    mudflap_finish_file ();
+
   /* Write out any pending weak symbol declarations.  */
 
   weak_finish ();
@@ -1029,6 +1040,14 @@ compile_file (void)
 
   dw2_output_indirect_constants ();
 
+  /* Flush any pending external directives.  cgraph did this for
+     assemble_external calls from the front end, but the RTL
+     expander can also generate them.  */
+  process_pending_assemble_externals ();
+
+  /* Flush any pending equate directives.  */
+  process_pending_assemble_output_defs ();
+
   /* Attach a special .ident directive to the end of the file to identify
      the version of GCC which compiled this code.  The format of the .ident
      string is patterned after the ones produced by native SVR4 compilers.  */
@@ -1049,6 +1068,7 @@ void
 display_target_options (void)
 {
   int undoc, i;
+  unsigned int cli;
   static bool displayed = false;
 
   /* Avoid double printing for --help --target-help.  */
@@ -1057,18 +1077,26 @@ display_target_options (void)
 
   displayed = true;
 
-  if (ARRAY_SIZE (target_switches) > 1
+  for (cli = 0; cli < cl_options_count; cli++)
+    if ((cl_options[cli].flags & (CL_TARGET | CL_UNDOCUMENTED)) == CL_TARGET)
+      break;
+
+  if (cli < cl_options_count
+#ifdef TARGET_SWITCHES
+      || ARRAY_SIZE (target_switches) > 1
+#endif
 #ifdef TARGET_OPTIONS
       || ARRAY_SIZE (target_options) > 1
 #endif
       )
     {
-      int doc = 0;
+      int doc = cli < cl_options_count;
 
       undoc = 0;
 
       printf (_("\nTarget specific options:\n"));
 
+#ifdef TARGET_SWITCHES
       for (i = ARRAY_SIZE (target_switches); i--;)
        {
          const char *option      = target_switches[i].name;
@@ -1086,6 +1114,7 @@ display_target_options (void)
          else if (*description != 0)
            doc += printf ("  -m%-23s %s\n", option, _(description));
        }
+#endif
 
 #ifdef TARGET_OPTIONS
       for (i = ARRAY_SIZE (target_options); i--;)
@@ -1106,6 +1135,7 @@ display_target_options (void)
            doc += printf ("  -m%-23s %s\n", option, _(description));
        }
 #endif
+      print_filtered_help (CL_TARGET);
       if (undoc)
        {
          if (doc)
@@ -1163,7 +1193,7 @@ decode_d_option (const char *arg)
 /* Indexed by enum debug_info_type.  */
 const char *const debug_type_names[] =
 {
-  "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
+  "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
 };
 
 /* Decode -m switches.  */
@@ -1172,9 +1202,12 @@ const char *const debug_type_names[] =
 void
 set_target_switch (const char *name)
 {
+#if defined (TARGET_SWITCHES) || defined (TARGET_OPTIONS)
   size_t j;
+#endif
   int valid_target_option = 0;
 
+#ifdef TARGET_SWITCHES
   for (j = 0; j < ARRAY_SIZE (target_switches); j++)
     if (!strcmp (target_switches[j].name, name))
       {
@@ -1191,6 +1224,7 @@ set_target_switch (const char *name)
          }
        valid_target_option = 1;
       }
+#endif
 
 #ifdef TARGET_OPTIONS
   if (!valid_target_option)
@@ -1216,8 +1250,8 @@ set_target_switch (const char *name)
       }
 #endif
 
-  if (!valid_target_option)
-    error ("invalid option `%s'", name);
+  if (name[0] != 0 && !valid_target_option)
+    error ("invalid option %qs", name);
 }
 
 /* Print version information to FILE.
@@ -1323,28 +1357,14 @@ print_switch_values (FILE *file, int pos, int max,
                             _("options enabled: "), "");
 
   for (j = 0; j < cl_options_count; j++)
-    {
-      if (!cl_options[j].flag_var
-         || !(cl_options[j].flags & CL_REPORT))
-       continue;
-
-      if (cl_options[j].has_set_value)
-       {
-         if (*cl_options[j].flag_var != cl_options[j].set_value)
-           continue;
-       }
-      else
-       {
-         if (!*cl_options[j].flag_var)
-           continue;
-       }
-      
+    if ((cl_options[j].flags & CL_REPORT)
+       && option_enabled (&cl_options[j]) > 0)
       pos = print_single_switch (file, pos, max, indent, sep, term,
                                 "", cl_options[j].opt_text);
-    }
 
   /* Print target specific options.  */
 
+#ifdef TARGET_SWITCHES
   for (j = 0; j < ARRAY_SIZE (target_switches); j++)
     if (target_switches[j].name[0] != '\0'
        && target_switches[j].value > 0
@@ -1354,6 +1374,7 @@ print_switch_values (FILE *file, int pos, int max,
        pos = print_single_switch (file, pos, max, indent, sep, term,
                                   "-m", target_switches[j].name);
       }
+#endif
 
 #ifdef TARGET_OPTIONS
   for (j = 0; j < ARRAY_SIZE (target_options); j++)
@@ -1394,14 +1415,9 @@ init_asm_output (const char *name)
       else
        asm_out_file = fopen (asm_file_name, "w+b");
       if (asm_out_file == 0)
-       fatal_error ("can't open %s for writing: %m", asm_file_name);
+       fatal_error ("can%'t open %s for writing: %m", asm_file_name);
     }
 
-#ifdef IO_BUFFER_SIZE
-  setvbuf (asm_out_file, xmalloc (IO_BUFFER_SIZE),
-          _IOFBF, IO_BUFFER_SIZE);
-#endif
-
   if (!flag_syntax_only)
     {
       targetm.asm_out.file_start ();
@@ -1485,12 +1501,13 @@ default_pch_valid_p (const void *data_p, size_t len)
   /* Check target_flags.  */
   if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
     {
+      int tf;
+
+      memcpy (&tf, data, sizeof (target_flags));
+#ifdef TARGET_SWITCHES
       for (i = 0; i < ARRAY_SIZE (target_switches); i++)
        {
          int bits;
-         int tf;
-
-         memcpy (&tf, data, sizeof (target_flags));
 
          bits = target_switches[i].value;
          if (bits < 0)
@@ -1501,6 +1518,14 @@ default_pch_valid_p (const void *data_p, size_t len)
              goto make_message;
            }
        }
+#endif
+      for (i = 0; i < cl_options_count; i++)
+       if (cl_options[i].flag_var == &target_flags
+           && (cl_options[i].var_value & (target_flags ^ tf)) != 0)
+         {
+           flag_that_differs = cl_options[i].opt_text + 2;
+           goto make_message;
+         }
       gcc_unreachable ();
     }
   data += sizeof (target_flags);
@@ -1530,7 +1555,7 @@ default_pch_valid_p (const void *data_p, size_t len)
  make_message:
   {
     char *r;
-    asprintf (&r, _("created and used with differing settings of `-m%s'"),
+    asprintf (&r, _("created and used with differing settings of '-m%s'"),
                  flag_that_differs);
     if (r == NULL)
       return _("out of memory");
@@ -1542,23 +1567,36 @@ default_pch_valid_p (const void *data_p, size_t len)
 static bool
 default_tree_printer (pretty_printer * pp, text_info *text)
 {
+  tree t;
+
   switch (*text->format_spec)
     {
     case 'D':
+      t = va_arg (*text->args_ptr, tree);
+      if (DECL_DEBUG_EXPR (t) && DECL_DEBUG_EXPR_IS_FROM (t))
+       t = DECL_DEBUG_EXPR (t);
+      break;
+
     case 'F':
     case 'T':
-      {
-        tree t = va_arg (*text->args_ptr, tree);
-        const char *n = DECL_NAME (t)
-          ? lang_hooks.decl_printable_name (t, 2)
-          : "<anonymous>";
-        pp_string (pp, n);
-      }
-      return true;
+      t = va_arg (*text->args_ptr, tree);
+      break;
 
     default:
       return false;
     }
+
+  if (DECL_P (t))
+    {
+      const char *n = DECL_NAME (t)
+        ? lang_hooks.decl_printable_name (t, 2)
+        : "<anonymous>";
+      pp_string (pp, n);
+    }
+  else
+    dump_generic_node (pp, t, 0, 0, 0);
+
+  return true;
 }
 
 /* Initialization of the front end environment, before command line
@@ -1684,24 +1722,7 @@ process_options (void)
   if (flag_unroll_all_loops)
     flag_unroll_loops = 1;
 
-  if (flag_unroll_loops)
-    {
-      flag_old_unroll_loops = 0;
-      flag_old_unroll_all_loops = 0;
-    }
-
-  if (flag_old_unroll_all_loops)
-    flag_old_unroll_loops = 1;
-
-  /* Old loop unrolling requires that strength_reduction be on also.  Silently
-     turn on strength reduction here if it isn't already on.  Also, the loop
-     unrolling code assumes that cse will be run after loop, so that must
-     be turned on also.  */
-  if (flag_old_unroll_loops)
-    {
-      flag_strength_reduce = 1;
-      flag_rerun_cse_after_loop = 1;
-    }
+  /* The loop unrolling code assumes that cse will be run after loop.  */
   if (flag_unroll_loops || flag_peel_loops)
     flag_rerun_cse_after_loop = 1;
 
@@ -1844,7 +1865,7 @@ process_options (void)
           debug_type_names[write_symbols]);
 
   /* Now we know which debug output will be used so we can set
-     flag_var_tracking, flag_rename_registers and flag_web if the user has
+     flag_var_tracking, flag_rename_registers if the user has
      not specified them.  */
   if (debug_info_level < DINFO_LEVEL_NORMAL
       || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
@@ -1865,10 +1886,6 @@ process_options (void)
     flag_rename_registers = default_debug_hooks->var_location
                            != do_nothing_debug_hooks.var_location;
 
-  if (flag_web == AUTODETECT_FLAG_VAR_TRACKING)
-    flag_web = optimize >= 2 && (default_debug_hooks->var_location
-                                != do_nothing_debug_hooks.var_location);
-
   if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
     flag_var_tracking = optimize >= 1;
 
@@ -1879,7 +1896,7 @@ process_options (void)
     {
       aux_info_file = fopen (aux_info_file_name, "w");
       if (aux_info_file == 0)
-       fatal_error ("can't open %s: %m", aux_info_file_name);
+       fatal_error ("can%'t open %s: %m", aux_info_file_name);
     }
 
   if (! targetm.have_named_sections)
@@ -1944,14 +1961,16 @@ process_options (void)
   /* The presence of IEEE signaling NaNs, implies all math can trap.  */
   if (flag_signaling_nans)
     flag_trapping_math = 1;
+
+  /* With -fcx-limited-range, we do cheap and quick complex arithmetic.  */
+  if (flag_cx_limited_range)
+    flag_complex_method = 0;
 }
 
 /* Initialize the compiler back end.  */
 static void
 backend_init (void)
 {
-  init_adjust_machine_modes ();
-
   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
                  || debug_info_level == DINFO_LEVEL_VERBOSE
 #ifdef VMS_DEBUGGING_INFO
@@ -1960,6 +1979,7 @@ backend_init (void)
 #endif
                    || flag_test_coverage);
 
+  init_rtlanal ();
   init_regs ();
   init_fake_stack_mems ();
   init_alias_once ();
@@ -2087,6 +2107,11 @@ do_compile (void)
   /* Don't do any more if an error has already occurred.  */
   if (!errorcount)
     {
+      /* This must be run always, because it is needed to compute the FP
+        predefined macros, such as __LDBL_MAX__, for targets using non
+        default FP formats.  */
+      init_adjust_machine_modes ();
+
       /* Set up the back-end if requested.  */
       if (!no_backend)
        backend_init ();