OSDN Git Service

* config/picochip/picochip.c (picochip_init_builtins): Call
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
index 3050f07..d61adde 100644 (file)
@@ -1,7 +1,7 @@
 /* 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, 2005, 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+   2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -116,18 +116,6 @@ static bool no_backend;
 struct cl_decoded_option *save_decoded_options;
 unsigned int save_decoded_options_count;
 
-/* Name of top-level original source file (what was input to cpp).
-   This comes from the #-command at the beginning of the actual input.
-   If there isn't any there, then this is the cc1 input file name.  */
-
-const char *main_input_filename;
-
-/* Pointer to base name in main_input_filename, with directories and a
-   single final extension removed, and the length of this base
-   name.  */
-const char *main_input_basename;
-int main_input_baselength;
-
 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
    to optimize in process_options ().  */
 #define AUTODETECT_VALUE 2
@@ -182,9 +170,6 @@ int flag_permissive = 0;
    the support provided depends on the backend.  */
 rtx stack_limit_rtx;
 
-/* Type of stack check.  */
-enum stack_check_type flag_stack_check = NO_STACK_CHECK;
-
 /* True if the user has tagged the function with the 'section'
    attribute.  */
 
@@ -374,32 +359,6 @@ crash_signal (int signo)
   internal_error ("%s", strsignal (signo));
 }
 
-/* Output a quoted string.  */
-
-void
-output_quoted_string (FILE *asm_file, const char *string)
-{
-#ifdef OUTPUT_QUOTED_STRING
-  OUTPUT_QUOTED_STRING (asm_file, string);
-#else
-  char c;
-
-  putc ('\"', asm_file);
-  while ((c = *string++) != 0)
-    {
-      if (ISPRINT (c))
-       {
-         if (c == '\"' || c == '\\')
-           putc ('\\', asm_file);
-         putc (c, asm_file);
-       }
-      else
-       fprintf (asm_file, "\\%03o", (unsigned char) c);
-    }
-  putc ('\"', asm_file);
-#endif
-}
-
 /* A subroutine of wrapup_global_declarations.  We've come to the end of
    the compilation unit.  All deferred variables should be undeferred,
    and all incomplete decls should be finalized.  */
@@ -597,147 +556,40 @@ emit_debug_global_declarations (tree *vec, int len)
   timevar_pop (TV_SYMOUT);
 }
 
-/* Warn about a use of an identifier which was marked deprecated.  */
-void
-warn_deprecated_use (tree node, tree attr)
-{
-  const char *msg;
-
-  if (node == 0 || !warn_deprecated_decl)
-    return;
-
-  if (!attr)
-    {
-      if (DECL_P (node))
-       attr = DECL_ATTRIBUTES (node);
-      else if (TYPE_P (node))
-       {
-         tree decl = TYPE_STUB_DECL (node);
-         if (decl)
-           attr = lookup_attribute ("deprecated",
-                                    TYPE_ATTRIBUTES (TREE_TYPE (decl)));
-       }
-    }
-
-  if (attr)
-    attr = lookup_attribute ("deprecated", attr);
-
-  if (attr)
-    msg = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)));
-  else
-    msg = NULL;
-
-  if (DECL_P (node))
-    {
-      expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
-      if (msg)
-       warning (OPT_Wdeprecated_declarations,
-                "%qD is deprecated (declared at %s:%d): %s",
-                node, xloc.file, xloc.line, msg);
-      else
-       warning (OPT_Wdeprecated_declarations,
-                "%qD is deprecated (declared at %s:%d)",
-                node, xloc.file, xloc.line);
-    }
-  else if (TYPE_P (node))
-    {
-      tree what = NULL_TREE;
-      tree decl = TYPE_STUB_DECL (node);
-
-      if (TYPE_NAME (node))
-       {
-         if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
-           what = TYPE_NAME (node);
-         else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
-                  && DECL_NAME (TYPE_NAME (node)))
-           what = DECL_NAME (TYPE_NAME (node));
-       }
-
-      if (decl)
-       {
-         expanded_location xloc
-           = expand_location (DECL_SOURCE_LOCATION (decl));
-         if (what)
-           {
-             if (msg)
-               warning (OPT_Wdeprecated_declarations,
-                        "%qE is deprecated (declared at %s:%d): %s",
-                        what, xloc.file, xloc.line, msg);
-             else
-               warning (OPT_Wdeprecated_declarations,
-                        "%qE is deprecated (declared at %s:%d)", what,
-                        xloc.file, xloc.line);
-           }
-         else
-           {
-             if (msg)
-               warning (OPT_Wdeprecated_declarations,
-                        "type is deprecated (declared at %s:%d): %s",
-                        xloc.file, xloc.line, msg);
-             else
-               warning (OPT_Wdeprecated_declarations,
-                        "type is deprecated (declared at %s:%d)",
-                        xloc.file, xloc.line);
-           }
-       }
-      else
-       {
-         if (what)
-           {
-             if (msg)
-               warning (OPT_Wdeprecated_declarations, "%qE is deprecated: %s",
-                        what, msg);
-             else
-               warning (OPT_Wdeprecated_declarations, "%qE is deprecated", what);
-           }
-         else
-           {
-             if (msg)
-               warning (OPT_Wdeprecated_declarations, "type is deprecated: %s",
-                        msg);
-             else
-               warning (OPT_Wdeprecated_declarations, "type is deprecated");
-           }
-       }
-    }
-}
-
 /* Compile an entire translation unit.  Write a file of assembly
    output and various debugging dumps.  */
 
 static void
 compile_file (void)
 {
-  /* Initialize yet another pass.  */
-
-  ggc_protect_identifiers = true;
-
-  init_cgraph ();
-  init_final (main_input_filename);
-  coverage_init (aux_base_name);
-  statistics_init ();
-  invoke_plugin_callbacks (PLUGIN_START_UNIT, NULL);
-
-  timevar_push (TV_PARSE);
+  timevar_start (TV_PHASE_PARSING);
+  timevar_push (TV_PARSE_GLOBAL);
 
   /* Call the parser, which parses the entire file (calling
      rest_of_compilation for each function).  */
   lang_hooks.parse_file ();
 
+  timevar_pop (TV_PARSE_GLOBAL);
+  timevar_stop (TV_PHASE_PARSING);
+
   /* Compilation is now finished except for writing
      what's left of the symbol table output.  */
-  timevar_pop (TV_PARSE);
 
   if (flag_syntax_only || flag_wpa)
     return;
 
+  timevar_start (TV_PHASE_GENERATE);
+
   ggc_protect_identifiers = false;
 
   /* This must also call cgraph_finalize_compilation_unit.  */
   lang_hooks.decls.final_write_globals ();
 
   if (seen_error ())
-    return;
+    {
+      timevar_stop (TV_PHASE_GENERATE);
+      return;
+    }
 
   varpool_assemble_pending_decls ();
   finish_aliases_2 ();
@@ -817,6 +669,8 @@ compile_file (void)
      into the assembly file here, and hence we can not output anything to the
      assembly file after this point.  */
   targetm.asm_out.file_end ();
+
+  timevar_stop (TV_PHASE_GENERATE);
 }
 
 /* Indexed by enum debug_info_type.  */
@@ -1037,7 +891,7 @@ print_switch_values (print_switch_fn_type print_fn)
                             SWITCH_TYPE_DESCRIPTIVE, _("options enabled: "));
 
   for (j = 0; j < cl_options_count; j++)
-    if ((cl_options[j].flags & CL_REPORT)
+    if (cl_options[j].cl_report
        && option_enabled (j, &global_options) > 0)
       pos = print_single_switch (print_fn, pos,
                                 SWITCH_TYPE_ENABLED, cl_options[j].opt_text);
@@ -1108,115 +962,6 @@ init_asm_output (const char *name)
     }
 }
 
-/* Return true if the state of option OPTION should be stored in PCH files
-   and checked by default_pch_valid_p.  Store the option's current state
-   in STATE if so.  */
-
-static inline bool
-option_affects_pch_p (int option, struct cl_option_state *state)
-{
-  if ((cl_options[option].flags & CL_TARGET) == 0)
-    return false;
-  if (option_flag_var (option, &global_options) == &target_flags)
-    if (targetm.check_pch_target_flags)
-      return false;
-  return get_option_state (&global_options, option, state);
-}
-
-/* Default version of get_pch_validity.
-   By default, every flag difference is fatal; that will be mostly right for
-   most targets, but completely right for very few.  */
-
-void *
-default_get_pch_validity (size_t *sz)
-{
-  struct cl_option_state state;
-  size_t i;
-  char *result, *r;
-
-  *sz = 2;
-  if (targetm.check_pch_target_flags)
-    *sz += sizeof (target_flags);
-  for (i = 0; i < cl_options_count; i++)
-    if (option_affects_pch_p (i, &state))
-      *sz += state.size;
-
-  result = r = XNEWVEC (char, *sz);
-  r[0] = flag_pic;
-  r[1] = flag_pie;
-  r += 2;
-  if (targetm.check_pch_target_flags)
-    {
-      memcpy (r, &target_flags, sizeof (target_flags));
-      r += sizeof (target_flags);
-    }
-
-  for (i = 0; i < cl_options_count; i++)
-    if (option_affects_pch_p (i, &state))
-      {
-       memcpy (r, state.data, state.size);
-       r += state.size;
-      }
-
-  return result;
-}
-
-/* Return a message which says that a PCH file was created with a different
-   setting of OPTION.  */
-
-static const char *
-pch_option_mismatch (const char *option)
-{
-  char *r;
-
-  asprintf (&r, _("created and used with differing settings of '%s'"), option);
-  if (r == NULL)
-    return _("out of memory");
-  return r;
-}
-
-/* Default version of pch_valid_p.  */
-
-const char *
-default_pch_valid_p (const void *data_p, size_t len)
-{
-  struct cl_option_state state;
-  const char *data = (const char *)data_p;
-  size_t i;
-
-  /* -fpic and -fpie also usually make a PCH invalid.  */
-  if (data[0] != flag_pic)
-    return _("created and used with different settings of -fpic");
-  if (data[1] != flag_pie)
-    return _("created and used with different settings of -fpie");
-  data += 2;
-
-  /* Check target_flags.  */
-  if (targetm.check_pch_target_flags)
-    {
-      int tf;
-      const char *r;
-
-      memcpy (&tf, data, sizeof (target_flags));
-      data += sizeof (target_flags);
-      len -= sizeof (target_flags);
-      r = targetm.check_pch_target_flags (tf);
-      if (r != NULL)
-       return r;
-    }
-
-  for (i = 0; i < cl_options_count; i++)
-    if (option_affects_pch_p (i, &state))
-      {
-       if (memcmp (data, state.data, state.size) != 0)
-         return pch_option_mismatch (cl_options[i].opt_text);
-       data += state.size;
-       len -= state.size;
-      }
-
-  return NULL;
-}
-
 /* Default tree printer.   Handles declarations only.  */
 bool
 default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
@@ -1569,12 +1314,16 @@ process_options (void)
 
 #ifndef HAVE_cloog
   if (flag_graphite
+      || flag_graphite_identity
       || flag_loop_block
+      || flag_loop_flatten
       || flag_loop_interchange
       || flag_loop_strip_mine
-      || flag_graphite_identity
       || flag_loop_parallelize_all)
-    sorry ("Graphite loop optimizations cannot be used");
+    sorry ("Graphite loop optimizations cannot be used (-fgraphite, "
+          "-fgraphite-identity, -floop-block, -floop-flatten, "
+          "-floop-interchange, -floop-strip-mine, -floop-parallelize-all, "
+          "and -ftree-loop-linear)");
 #endif
 
   /* Unrolling all loops implies that standard loop unrolling must also
@@ -1851,6 +1600,15 @@ process_options (void)
       flag_omit_frame_pointer = 0;
     }
 
+  /* Enable -Werror=coverage-mismatch when -Werror and -Wno-error
+     have not been set.  */
+  if (!global_options_set.x_warnings_are_errors
+      && warn_coverage_mismatch
+      && (global_dc->classify_diagnostic[OPT_Wcoverage_mismatch] ==
+          DK_UNSPECIFIED))
+    diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_mismatch,
+                                    DK_ERROR, UNKNOWN_LOCATION);
+
   /* Save the current optimization options.  */
   optimization_default_node = build_optimization_node ();
   optimization_current_node = optimization_default_node;
@@ -1994,11 +1752,14 @@ lang_dependent_init (const char *name)
     return 0;
   input_location = save_loc;
 
-  init_asm_output (name);
+  if (!flag_wpa)
+    {
+      init_asm_output (name);
 
-  /* If stack usage information is desired, open the output file.  */
-  if (flag_stack_usage)
-    stack_usage_file = open_auxiliary_file ("su");
+      /* If stack usage information is desired, open the output file.  */
+      if (flag_stack_usage)
+       stack_usage_file = open_auxiliary_file ("su");
+    }
 
   /* This creates various _DECL nodes, so needs to be called after the
      front end is initialized.  */
@@ -2007,20 +1768,23 @@ lang_dependent_init (const char *name)
   /* Do the target-specific parts of the initialization.  */
   lang_dependent_init_target ();
 
-  /* If dbx symbol table desired, initialize writing it and output the
-     predefined types.  */
-  timevar_push (TV_SYMOUT);
+  if (!flag_wpa)
+    {
+      /* If dbx symbol table desired, initialize writing it and output the
+        predefined types.  */
+      timevar_push (TV_SYMOUT);
 
 #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
-  if (dwarf2out_do_frame ())
-    dwarf2out_frame_init ();
+      if (dwarf2out_do_frame ())
+       dwarf2out_frame_init ();
 #endif
 
-  /* Now we have the correct original filename, we can initialize
-     debug output.  */
-  (*debug_hooks->init) (name);
+      /* Now we have the correct original filename, we can initialize
+        debug output.  */
+      (*debug_hooks->init) (name);
 
-  timevar_pop (TV_SYMOUT);
+      timevar_pop (TV_SYMOUT);
+    }
 
   return 1;
 }
@@ -2031,11 +1795,33 @@ lang_dependent_init (const char *name)
 void
 target_reinit (void)
 {
+  struct rtl_data saved_x_rtl;
+  rtx *saved_regno_reg_rtx;
+
+  /* Save *crtl and regno_reg_rtx around the reinitialization
+     to allow target_reinit being called even after prepare_function_start.  */
+  saved_regno_reg_rtx = regno_reg_rtx;
+  if (saved_regno_reg_rtx)
+    {  
+      saved_x_rtl = *crtl;
+      memset (crtl, '\0', sizeof (*crtl));
+      regno_reg_rtx = NULL;
+    }
+
   /* Reinitialize RTL backend.  */
   backend_init_target ();
 
   /* Reinitialize lang-dependent parts.  */
   lang_dependent_init_target ();
+
+  /* And restore it at the end, as free_after_compilation from
+     expand_dummy_function_end clears it.  */
+  if (saved_regno_reg_rtx)
+    {
+      *crtl = saved_x_rtl;
+      regno_reg_rtx = saved_regno_reg_rtx;
+      saved_regno_reg_rtx = NULL;
+    }
 }
 
 void
@@ -2077,8 +1863,6 @@ finalize (bool no_backend)
        fatal_error ("error writing to %s: %m", asm_file_name);
       if (fclose (asm_out_file) != 0)
        fatal_error ("error closing %s: %m", asm_file_name);
-      if (flag_wpa)
-       unlink_if_ordinary (asm_file_name);
     }
 
   if (stack_usage_file)
@@ -2115,6 +1899,8 @@ do_compile (void)
   /* Don't do any more if an error has already occurred.  */
   if (!seen_error ())
     {
+      timevar_start (TV_PHASE_SETUP);
+
       /* 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.  */
@@ -2126,9 +1912,31 @@ do_compile (void)
 
       /* Language-dependent initialization.  Returns true on success.  */
       if (lang_dependent_init (main_input_filename))
-       compile_file ();
+        {
+          /* Initialize yet another pass.  */
+
+          ggc_protect_identifiers = true;
+
+          init_cgraph ();
+          init_final (main_input_filename);
+          coverage_init (aux_base_name);
+          statistics_init ();
+          invoke_plugin_callbacks (PLUGIN_START_UNIT, NULL);
+
+          timevar_stop (TV_PHASE_SETUP);
+
+          compile_file ();
+        }
+      else
+        {
+          timevar_stop (TV_PHASE_SETUP);
+        }
+
+      timevar_start (TV_PHASE_FINALIZE);
 
       finalize (no_backend);
+
+      timevar_stop (TV_PHASE_FINALIZE);
     }
 
   /* Stop timing and print the times.  */