OSDN Git Service

(find_reloads_address_1, case POST_INC): Don't use
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
index b080e19..1828ecb 100644 (file)
@@ -1,5 +1,5 @@
 /* Top level of GNU C compiler
-   Copyright (C) 1987, 88, 89, 92-5, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1987, 88, 89, 92-6, 1997 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -97,7 +97,7 @@ vms_fopen (fname, type)
    PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way. 
 
    This is one long line cause VAXC can't handle a \-newline.  */
-#if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
+#if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO))
 #ifndef PREFERRED_DEBUGGING_TYPE
 You Lose!  You must define PREFERRED_DEBUGGING_TYPE!
 #endif /* no PREFERRED_DEBUGGING_TYPE */
@@ -112,6 +112,9 @@ You Lose!  You must define PREFERRED_DEBUGGING_TYPE!
 #ifdef DWARF_DEBUGGING_INFO
 #define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
 #endif
+#ifdef DWARF2_DEBUGGING_INFO
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+#endif
 #ifdef XCOFF_DEBUGGING_INFO
 #define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
 #endif
@@ -659,6 +662,10 @@ char *lang_options[] =
   "-fno-asm",
   "-fbuiltin",
   "-fno-builtin",
+  "-fhosted",
+  "-fno-hosted",
+  "-ffreestanding",
+  "-fno-freestanding",
   "-fcond-mismatch",
   "-fno-cond-mismatch",
   "-fdollars-in-identifiers",
@@ -689,6 +696,8 @@ char *lang_options[] =
   "-Wno-import",
   "-Wimplicit",
   "-Wno-implicit",
+  "-Wmain",
+  "-Wno-main",
   "-Wmissing-braces",
   "-Wno-missing-braces",
   "-Wmissing-declarations",
@@ -1861,9 +1870,27 @@ floor_log2_wide (x)
   return log;
 }
 
+static int float_handler_set;
 int float_handled;
 jmp_buf float_handler;
 
+/* Signals actually come here.  */
+
+static void
+float_signal (signo)
+     /* If this is missing, some compilers complain.  */
+     int signo;
+{
+  if (float_handled == 0)
+    abort ();
+#if defined (USG) || defined (hpux)
+  signal (SIGFPE, float_signal);  /* re-enable the signal catcher */
+#endif
+  float_handled = 0;
+  signal (SIGFPE, float_signal);
+  longjmp (float_handler, 1);
+}
+
 /* Specify where to longjmp to when a floating arithmetic error happens.
    If HANDLER is 0, it means don't handle the errors any more.  */
 
@@ -1874,6 +1901,12 @@ set_float_handler (handler)
   float_handled = (handler != 0);
   if (handler)
     bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
+
+  if (float_handled && ! float_handler_set)
+    {
+      signal (SIGFPE, float_signal);
+      float_handler_set = 1;
+    }
 }
 
 /* Specify, in HANDLER, where to longjmp to when a floating arithmetic
@@ -1908,23 +1941,6 @@ pop_float_handler (handled, handler)
     bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler));
 }
 
-/* Signals actually come here.  */
-
-static void
-float_signal (signo)
-     /* If this is missing, some compilers complain.  */
-     int signo;
-{
-  if (float_handled == 0)
-    abort ();
-#if defined (USG) || defined (hpux)
-  signal (SIGFPE, float_signal);  /* re-enable the signal catcher */
-#endif
-  float_handled = 0;
-  signal (SIGFPE, float_signal);
-  longjmp (float_handler, 1);
-}
-
 /* Handler for SIGPIPE.  */
 
 static void
@@ -2315,6 +2331,10 @@ compile_file (name)
   if (write_symbols == DWARF_DEBUG)
     TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename));
 #endif
+#ifdef DWARF2_DEBUGGING_INFO
+  if (write_symbols == DWARF2_DEBUG)
+    TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename));
+#endif
 
   /* Initialize yet another pass.  */
 
@@ -2523,6 +2543,16 @@ compile_file (name)
            && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
          TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1));
 #endif
+#ifdef DWARF2_DEBUGGING_INFO
+       /* Output DWARF2 information for file-scope tentative data object
+          declarations, file-scope (extern) function declarations (which
+          had no corresponding body) and file-scope tagged type declarations
+          and definitions which have not yet been forced out.  */
+
+       if (write_symbols == DWARF2_DEBUG
+           && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl)))
+         TIMEVAR (symout_time, dwarf2out_decl (decl));
+#endif
       }
   }
 
@@ -2547,6 +2577,14 @@ compile_file (name)
             });
 #endif
 
+#ifdef DWARF2_DEBUGGING_INFO
+  if (write_symbols == DWARF2_DEBUG)
+    TIMEVAR (symout_time,
+            {
+              dwarf2out_finish ();
+            });
+#endif
+
   /* Output some stuff at end of file if nec.  */
 
   if (!output_bytecode)
@@ -2751,15 +2789,6 @@ rest_of_type_compilation (type, toplev)
   if (write_symbols == SDB_DEBUG)
     TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
 #endif
-#ifdef DWARF_DEBUGGING_INFO
-  /* If this is a file-scope type or a class-scope type
-     for which the containing class has already been completed, write it
-     out now to avoid ordering headaches with member functions.  */
-  if (write_symbols == DWARF_DEBUG
-      && (TYPE_CONTEXT (type) == NULL_TREE
-         || TREE_ASM_WRITTEN (TYPE_CONTEXT (type))))
-    TIMEVAR (symout_time, dwarfout_file_scope_decl (TYPE_STUB_DECL (type), 0));
-#endif
 }
 
 /* This is called from finish_function (within yyparse)
@@ -2867,6 +2896,17 @@ rest_of_compilation (decl)
                  set_decl_abstract_flags (decl, 0);
                }
 #endif
+#ifdef DWARF2_DEBUGGING_INFO
+             /* Generate the DWARF2 info for the "abstract" instance
+                of a function which we may later generate inlined and/or
+                out-of-line instances of.  */
+             if (write_symbols == DWARF2_DEBUG)
+               {
+                 set_decl_abstract_flags (decl, 1);
+                 TIMEVAR (symout_time, dwarf2out_decl (decl));
+                 set_decl_abstract_flags (decl, 0);
+               }
+#endif
              TIMEVAR (integration_time, save_for_inline_nocopy (decl));
              RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlineable;
              goto exit_rest_of_compilation;
@@ -2889,6 +2929,18 @@ rest_of_compilation (decl)
              set_decl_abstract_flags (decl, 0);
            }
 #endif
+#ifdef DWARF2_DEBUGGING_INFO
+         /* Generate the DWARF2 info for the "abstract" instance of
+            a function which we will generate an out-of-line instance
+            of almost immediately (and which we may also later generate
+            various inlined instances of).  */
+         if (write_symbols == DWARF2_DEBUG)
+           {
+             set_decl_abstract_flags (decl, 1);
+             TIMEVAR (symout_time, dwarf2out_decl (decl));
+             set_decl_abstract_flags (decl, 0);
+           }
+#endif
          saved_block_tree = DECL_INITIAL (decl);
          saved_arguments = DECL_ARGUMENTS (decl);
          TIMEVAR (integration_time, save_for_inline_copying (decl));
@@ -2915,12 +2967,9 @@ rest_of_compilation (decl)
       goto exit_rest_of_compilation;
     }
 
-  /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
-     Note that that may have been done above, in save_for_inline_copying.
-     The call to resume_temporary_allocation near the end of this function
-     goes back to the usual state of affairs.  */
-
-  rtl_in_current_obstack ();
+  /* Add an unwinder for exception handling, if needed.
+     This must be done before we finalize PIC code.  */
+  emit_unwinder ();
 
 #ifdef FINALIZE_PIC
   /* If we are doing position-independent code generation, now
@@ -2931,8 +2980,14 @@ rest_of_compilation (decl)
     FINALIZE_PIC;
 #endif
 
-  /* Add an unwinder for exception handling, if needed.  */
-  emit_unwinder ();
+  /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
+     Note that that may have been done above, in save_for_inline_copying.
+     The call to resume_temporary_allocation near the end of this function
+     goes back to the usual state of affairs.  This must be done after
+     we've built up any unwinders for exception handling, and done
+     the FINALIZE_PIC work, if necessary.  */
+
+  rtl_in_current_obstack ();
 
   insns = get_insns ();
 
@@ -3061,10 +3116,12 @@ rest_of_compilation (decl)
     }
 
   if (optimize > 0 && flag_thread_jumps)
-    /* This pass of jump threading straightens out code
-       that was kinked by loop optimization.  */
-    TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
-
+    {
+      /* This pass of jump threading straightens out code
+         that was kinked by loop optimization.  */
+      TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0));
+      TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0));
+    }
   /* Dump rtl code after cse, if we are doing that.  */
 
   if (cse2_dump)
@@ -3380,6 +3437,11 @@ rest_of_compilation (decl)
     TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0));
 #endif
 
+#ifdef DWARF2_DEBUGGING_INFO
+  if (write_symbols == DWARF2_DEBUG)
+    TIMEVAR (symout_time, dwarf2out_decl (decl));
+#endif
+
  exit_rest_of_compilation:
 
   /* In case the function was not output,
@@ -3822,8 +3884,6 @@ main (argc, argv, envp)
            }
          else if (str[0] == 'g')
            {
-             char *p = str + 1;
-             char *q;
              unsigned len;
              unsigned level;
              /* A lot of code assumes write_symbols == NO_DEBUG if the
@@ -3854,6 +3914,9 @@ main (argc, argv, envp)
                { "gdwarf", DWARF_DEBUG, 0 },
                { "gdwarf+", DWARF_DEBUG, 1 },
 #endif
+#ifdef DWARF2_DEBUGGING_INFO
+               { "gdwarf-2", DWARF2_DEBUG, 0 },
+#endif
 #ifdef XCOFF_DEBUGGING_INFO
                { "gxcoff", XCOFF_DEBUG, 0 },
                { "gxcoff+", XCOFF_DEBUG, 1 },
@@ -3865,40 +3928,46 @@ main (argc, argv, envp)
              };
              /* Indexed by enum debug_info_type.  */
              static char *debug_type_names[] = {
-               "none", "stabs", "coff", "dwarf", "xcoff"
+               "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff"
              };
 
-             while (*p && (*p < '0' || *p > '9'))
-               p++;
-             len = p - str;
-             q = p;
-             while (*q && (*q >= '0' && *q <= '9'))
-               q++;
-             if (*p)
-               level = atoi (p);
-             else
-               level = 2;      /* default debugging info level */
-             if (*q || level > 3)
-               {
-                 warning ("invalid debug level specification in option: `-%s'",
-                          str);
-                 /* ??? This error message is incorrect in the case of
-                    -g4 -g.  */
-                 warning ("no debugging information will be generated");
-                 level = 0;
-               }
-
              /* Look up STR in the table.  */
              for (da = debug_args; da->arg; da++)
                {
-                 if (! strncmp (str, da->arg, len))
+                 if (! strncmp (str, da->arg, strlen (da->arg)))
                    {
                      enum debug_info_type type = da->debug_type;
-                     /* ??? A few targets use STR and LEN in the
+                     char *p, *q;
+
+                     p = str + strlen (da->arg);
+                     if (*p && (*p < '0' || *p > '9'))
+                       continue;
+                     q = p;
+                     while (*q && (*q >= '0' && *q <= '9'))
+                       q++;
+                     if (*p)
+                       level = atoi (p);
+                     else
+                       level = 2;      /* default debugging info level */
+                     if (*q || level > 3)
+                       {
+                         warning ("invalid debug level specification in option: `-%s'",
+                                  str);
+                         /* ??? This error message is incorrect in the case of
+                            -g4 -g.  */
+                         warning ("no debugging information will be generated");
+                         level = 0;
+                       }
+
+                     /* ??? A few targets use STR in the
                         definition of PREFERRED_DEBUGGING_TYPE!  */
                      if (type == NO_DEBUG)
                        type = PREFERRED_DEBUGGING_TYPE;
 
+                     if (type == NO_DEBUG)
+                       warning ("`-%s' not supported by this configuration of GCC",
+                                str);
+
                      /* Does it conflict with an already selected type?  */
                      if (type_explicitly_set_p
                          /* -g/-ggdb don't conflict with anything */
@@ -4237,3 +4306,98 @@ print_switch_values (file, pos, max, indent, sep, term)
 
   fprintf (file, "%s", term);
 }
+
+/* Record the beginning of a new source file, named FILENAME.  */
+
+void
+debug_start_source_file (filename)
+     register char *filename;
+{
+#ifdef DBX_DEBUGGING_INFO
+  if (write_symbols == DBX_DEBUG)
+    dbxout_start_new_source_file (filename);
+#endif
+#ifdef DWARF_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF_DEBUG)
+    dwarfout_start_new_source_file (filename);
+#endif /* DWARF_DEBUGGING_INFO */
+#ifdef DWARF2_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF2_DEBUG)
+    dwarf2out_start_source_file (filename);
+#endif /* DWARF2_DEBUGGING_INFO */  
+#ifdef SDB_DEBUGGING_INFO
+  if (write_symbols == SDB_DEBUG)
+    sdbout_start_new_source_file (filename);
+#endif
+}
+
+/* Record the resumption of a source file.  LINENO is the line number in
+   the source file we are returning to.  */
+
+void
+debug_end_source_file (lineno)
+     register unsigned lineno;
+{
+#ifdef DBX_DEBUGGING_INFO
+  if (write_symbols == DBX_DEBUG)
+    dbxout_resume_previous_source_file ();
+#endif
+#ifdef DWARF_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF_DEBUG)
+    dwarfout_resume_previous_source_file (lineno);
+#endif /* DWARF_DEBUGGING_INFO */
+#ifdef DWARF2_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF2_DEBUG)
+    dwarf2out_end_source_file ();
+#endif /* DWARF2_DEBUGGING_INFO */
+#ifdef SDB_DEBUGGING_INFO
+  if (write_symbols == SDB_DEBUG)
+    sdbout_resume_previous_source_file ();
+#endif
+}
+
+/* Called from check_newline in c-parse.y.  The `buffer' parameter contains
+   the tail part of the directive line, i.e. the part which is past the
+   initial whitespace, #, whitespace, directive-name, whitespace part.  */
+
+void
+debug_define (lineno, buffer)
+     register unsigned lineno;
+     register char *buffer;
+{
+#ifdef DWARF_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF_DEBUG)
+    dwarfout_define (lineno, buffer);
+#endif /* DWARF_DEBUGGING_INFO */
+#ifdef DWARF2_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF2_DEBUG)
+    dwarf2out_define (lineno, buffer);
+#endif /* DWARF2_DEBUGGING_INFO */
+}
+
+/* Called from check_newline in c-parse.y.  The `buffer' parameter contains
+   the tail part of the directive line, i.e. the part which is past the
+   initial whitespace, #, whitespace, directive-name, whitespace part.  */
+
+void
+debug_undef (lineno, buffer)
+     register unsigned lineno;
+     register char *buffer;
+{
+#ifdef DWARF_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF_DEBUG)
+    dwarfout_undef (lineno, buffer);
+#endif /* DWARF_DEBUGGING_INFO */
+#ifdef DWARF2_DEBUGGING_INFO
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && write_symbols == DWARF2_DEBUG)
+    dwarf2out_undef (lineno, buffer);
+#endif /* DWARF2_DEBUGGING_INFO */
+}