OSDN Git Service

* Makefile.in (local-distclean): Remove leftover built files.
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index 2e1b689..cb4f6f7 100644 (file)
@@ -23,9 +23,6 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
 /* TODO: Implement .debug_str handling, and share entries somehow.
-        Eliminate duplicates by putting common info in a separate section
-          to be collected by the linker and referring to it with
-          DW_FORM_ref_addr.
         Emit .debug_line header even when there are no functions, since
           the file numbers are used by .debug_info.  Alternately, leave
           out locations for types and decls.
@@ -56,17 +53,9 @@ Boston, MA 02111-1307, USA.  */
 #include "toplev.h"
 #include "varray.h"
 #include "ggc.h"
+#include "md5.h"
 #include "tm_p.h"
 
-/* We cannot use <assert.h> in GCC source, since that would include
-   GCC's assert.h, which may not be compatible with the host compiler.  */
-#undef assert
-#ifdef NDEBUG
-# define assert(e)
-#else
-# define assert(e) do { if (! (e)) abort (); } while (0)
-#endif
-
 /* Decide whether we want to emit frame unwind information for the current
    translation unit.  */
 
@@ -75,7 +64,7 @@ dwarf2out_do_frame ()
 {
   return (write_symbols == DWARF2_DEBUG
 #ifdef DWARF2_FRAME_INFO
-          || DWARF2_FRAME_INFO
+         || DWARF2_FRAME_INFO
 #endif
 #ifdef DWARF2_UNWIND_INFO
          || flag_unwind_tables
@@ -105,6 +94,7 @@ typedef union dw_cfi_oprnd_struct
   unsigned long dw_cfi_reg_num;
   long int dw_cfi_offset;
   const char *dw_cfi_addr;
+  struct dw_loc_descr_struct *dw_cfi_loc;
 }
 dw_cfi_oprnd;
 
@@ -117,6 +107,19 @@ typedef struct dw_cfi_struct
 }
 dw_cfi_node;
 
+/* This is how we define the location of the CFA. We use to handle it
+   as REG + OFFSET all the time,  but now it can be more complex.
+   It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
+   Instead of passing around REG and OFFSET, we pass a copy
+   of this structure.  */
+typedef struct cfa_loc
+{
+  unsigned long reg;
+  long offset;
+  long base_offset;
+  int indirect;            /* 1 if CFA is accessed via a dereference.  */
+} dw_cfa_location;
+
 /* All call frame descriptions (FDE's) in the GCC generated DWARF
    refer to a single Common Information Entry (CIE), defined at
    the beginning of the .debug_frame section.  This used of a single
@@ -136,15 +139,6 @@ dw_fde_node;
 /* Maximum size (in bytes) of an artificially generated label.   */
 #define MAX_ARTIFICIAL_LABEL_BYTES     30
 
-/* Make sure we know the sizes of the various types dwarf can describe. These
-   are only defaults.  If the sizes are different for your target, you should
-   override these values by defining the appropriate symbols in your tm.h
-   file.  */
-
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
-
 /* The size of the target's pointer type.  */
 #ifndef PTR_SIZE
 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
@@ -175,11 +169,13 @@ dw_fde_node;
   ((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
 
 /* Offsets recorded in opcodes are a multiple of this alignment factor.  */
+#ifndef DWARF_CIE_DATA_ALIGNMENT
 #ifdef STACK_GROWS_DOWNWARD
 #define DWARF_CIE_DATA_ALIGNMENT (-((int) UNITS_PER_WORD))
 #else
 #define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
 #endif
+#endif /* not DWARF_CIE_DATA_ALIGNMENT */
 
 /* A pointer to the base of a table that contains frame description
    information for each routine.  */
@@ -207,7 +203,7 @@ static unsigned current_funcdef_number = 0;
 
 /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
    attribute that accelerates the lookup of the FDE associated
-   with the subprogram.  This variable holds the table index of the FDE 
+   with the subprogram.  This variable holds the table index of the FDE
    associated with the current function (body) definition.  */
 static unsigned current_funcdef_fde;
 
@@ -222,18 +218,25 @@ static unsigned long size_of_sleb128      PARAMS ((long));
 static void output_uleb128             PARAMS ((unsigned long));
 static void output_sleb128             PARAMS ((long));
 static void add_fde_cfi                        PARAMS ((const char *, dw_cfi_ref));
-static void lookup_cfa_1               PARAMS ((dw_cfi_ref, unsigned long *,
-                                                long *));
-static void lookup_cfa                 PARAMS ((unsigned long *, long *));
+static void lookup_cfa_1               PARAMS ((dw_cfi_ref, dw_cfa_location *));
+static void lookup_cfa                 PARAMS ((dw_cfa_location *));
 static void reg_save                   PARAMS ((const char *, unsigned,
                                                 unsigned, long));
 static void initial_return_save                PARAMS ((rtx));
+static long stack_adjust_offset                PARAMS ((rtx));
 static void output_cfi                 PARAMS ((dw_cfi_ref, dw_fde_ref));
 static void output_call_frame_info     PARAMS ((int));
-static unsigned int reg_number         PARAMS ((rtx));
 static void dwarf2out_stack_adjust     PARAMS ((rtx));
 static void dwarf2out_frame_debug_expr PARAMS ((rtx, const char *));
 
+/* Support for complex CFA locations.  */
+static void output_cfa_loc             PARAMS ((dw_cfi_ref));
+static void get_cfa_from_loc_descr     PARAMS ((dw_cfa_location *,
+                                               struct dw_loc_descr_struct *));
+static struct dw_loc_descr_struct *build_cfa_loc
+                                       PARAMS ((dw_cfa_location *));
+static void def_cfa_1                  PARAMS ((const char *, dw_cfa_location *));
+
 /* Definitions of defaults for assembler-dependent names of various
    pseudo-ops and section names.
    Theses may be overridden in the tm.h file (if necessary) for a particular
@@ -241,18 +244,18 @@ static void dwarf2out_frame_debug_expr    PARAMS ((rtx, const char *));
 
 #ifdef OBJECT_FORMAT_ELF
 #ifndef UNALIGNED_SHORT_ASM_OP
-#define UNALIGNED_SHORT_ASM_OP ".2byte"
+#define UNALIGNED_SHORT_ASM_OP "\t.2byte\t"
 #endif
 #ifndef UNALIGNED_INT_ASM_OP
-#define UNALIGNED_INT_ASM_OP   ".4byte"
+#define UNALIGNED_INT_ASM_OP   "\t.4byte\t"
 #endif
 #ifndef UNALIGNED_DOUBLE_INT_ASM_OP
-#define UNALIGNED_DOUBLE_INT_ASM_OP    ".8byte"
+#define UNALIGNED_DOUBLE_INT_ASM_OP    "\t.8byte\t"
 #endif
 #endif /* OBJECT_FORMAT_ELF */
 
 #ifndef ASM_BYTE_OP
-#define ASM_BYTE_OP            ".byte"
+#define ASM_BYTE_OP            "\t.byte\t"
 #endif
 
 /* Data and reference forms for relocatable data.  */
@@ -261,7 +264,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 
 /* Pseudo-op for defining a new section.  */
 #ifndef SECTION_ASM_OP
-#define SECTION_ASM_OP ".section"
+#define SECTION_ASM_OP "\t.section\t"
 #endif
 
 /* The default format used by the ASM_OUTPUT_SECTION macro (see below) to
@@ -272,7 +275,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 #ifdef PUSHSECTION_FORMAT
 #define SECTION_FORMAT PUSHSECTION_FORMAT
 #else
-#define SECTION_FORMAT         "\t%s\t%s\n"
+#define SECTION_FORMAT         "%s%s\n"
 #endif
 #endif
 
@@ -292,6 +295,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 #define FDE_AFTER_SIZE_LABEL   "LSFDE"
 #define FDE_END_LABEL          "LEFDE"
 #define FDE_LENGTH_LABEL       "LLFDE"
+#define DIE_LABEL_PREFIX       "DW"
 
 /* Definitions of defaults for various types of primitive assembly language
    output operations.  These may be overridden from within the tm.h file,
@@ -304,12 +308,12 @@ static void dwarf2out_frame_debug_expr    PARAMS ((rtx, const char *));
 
 #ifndef ASM_OUTPUT_DWARF_DATA1
 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) (VALUE))
+  fprintf ((FILE), "%s0x%x", ASM_BYTE_OP, (unsigned) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DELTA1
 #define ASM_OUTPUT_DWARF_DELTA1(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", ASM_BYTE_OP);                        \
+ do {  fprintf ((FILE), "%s", ASM_BYTE_OP);                    \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -332,7 +336,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 
 #ifndef ASM_OUTPUT_DWARF_DELTA2
 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP);             \
+ do {  fprintf ((FILE), "%s", UNALIGNED_SHORT_ASM_OP);                 \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -341,7 +345,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 
 #ifndef ASM_OUTPUT_DWARF_DELTA4
 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
+ do {  fprintf ((FILE), "%s", UNALIGNED_INT_ASM_OP);                   \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -350,7 +354,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 
 #ifndef ASM_OUTPUT_DWARF_DELTA
 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2)                     \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP);            \
+ do {  fprintf ((FILE), "%s", UNALIGNED_OFFSET_ASM_OP);                \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -359,7 +363,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 
 #ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2)                        \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP);              \
+ do {  fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                  \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, "-");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -368,7 +372,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 
 #ifndef ASM_OUTPUT_DWARF_ADDR
 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL)                              \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP);              \
+ do {  fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                  \
        assemble_name (FILE, LABEL);                                    \
   } while (0)
 #endif
@@ -376,59 +380,65 @@ static void dwarf2out_frame_debug_expr    PARAMS ((rtx, const char *));
 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX)                          \
   do {                                                                 \
-    fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP);                 \
+    fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                     \
     output_addr_const ((FILE), (RTX));                                 \
   } while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_OFFSET4
 #define ASM_OUTPUT_DWARF_OFFSET4(FILE,LABEL) \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
+ do {  fprintf ((FILE), "%s", UNALIGNED_INT_ASM_OP);                   \
        assemble_name (FILE, LABEL);                                    \
   } while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_OFFSET
 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL)                            \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP);            \
+ do {  fprintf ((FILE), "%s", UNALIGNED_OFFSET_ASM_OP);                \
        assemble_name (FILE, LABEL);                                    \
   } while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA2
 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) (VALUE))
+  fprintf ((FILE), "%s0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA4
 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, (unsigned) (VALUE))
+  fprintf ((FILE), "%s0x%x", UNALIGNED_INT_ASM_OP, (unsigned) (VALUE))
+#endif
+
+#ifndef ASM_OUTPUT_DWARF_DATA8
+#define ASM_OUTPUT_DWARF_DATA8(FILE,VALUE) \
+  fprintf ((FILE), "%s0x%lx", UNALIGNED_DOUBLE_INT_ASM_OP, \
+          (unsigned long) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA
 #define ASM_OUTPUT_DWARF_DATA(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_OFFSET_ASM_OP, \
+  fprintf ((FILE), "%s0x%lx", UNALIGNED_OFFSET_ASM_OP, \
           (unsigned long) (VALUE))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_ADDR_DATA
 #define ASM_OUTPUT_DWARF_ADDR_DATA(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_WORD_ASM_OP, \
+  fprintf ((FILE), "%s0x%lx", UNALIGNED_WORD_ASM_OP, \
           (unsigned long) (VALUE))
 #endif
 
-#ifndef ASM_OUTPUT_DWARF_DATA8
-#define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE)              \
+#ifndef ASM_OUTPUT_DWARF_CONST_DOUBLE
+#define ASM_OUTPUT_DWARF_CONST_DOUBLE(FILE,HIGH_VALUE,LOW_VALUE)       \
   do {                                                                 \
     if (WORDS_BIG_ENDIAN)                                              \
       {                                                                        \
-       fprintf ((FILE), "\t%s\t0x%lx\n", UNALIGNED_INT_ASM_OP, (HIGH_VALUE));\
-       fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_INT_ASM_OP, (LOW_VALUE));\
+       fprintf ((FILE), "%s0x%lx\n", UNALIGNED_INT_ASM_OP, (HIGH_VALUE));\
+       fprintf ((FILE), "%s0x%lx", UNALIGNED_INT_ASM_OP, (LOW_VALUE));\
       }                                                                        \
     else                                                               \
       {                                                                        \
-       fprintf ((FILE), "\t%s\t0x%lx\n", UNALIGNED_INT_ASM_OP, (LOW_VALUE)); \
-       fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_INT_ASM_OP, (HIGH_VALUE)); \
+       fprintf ((FILE), "%s0x%lx\n", UNALIGNED_INT_ASM_OP, (LOW_VALUE)); \
+       fprintf ((FILE), "%s0x%lx", UNALIGNED_INT_ASM_OP, (HIGH_VALUE)); \
       }                                                                        \
   } while (0)
 #endif
@@ -436,40 +446,69 @@ static void dwarf2out_frame_debug_expr    PARAMS ((rtx, const char *));
 #else /* UNALIGNED_INT_ASM_OP */
 
 /* We don't have unaligned support, let's hope the normal output works for
-   .debug_frame.  */
+   .debug_frame.  But we know it won't work for .debug_info.  */
 
+#ifdef DWARF2_DEBUGGING_INFO
+ #error DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP.
+#endif
+
+#ifndef ASM_OUTPUT_DWARF_ADDR
 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
   assemble_integer (gen_rtx_SYMBOL_REF (Pmode, LABEL), DWARF2_ADDR_SIZE, 1)
+#endif
+
+#ifndef ASM_OUTPUT_DWARF_ADDR_CONST
+#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) ASM_OUTPUT_DWARF_ADDR (FILE,RTX)
+#endif
 
+#ifndef ASM_OUTPUT_DWARF_OFFSET4
 #define ASM_OUTPUT_DWARF_OFFSET4(FILE,LABEL) \
   assemble_integer (gen_rtx_SYMBOL_REF (SImode, LABEL), 4, 1)
+#endif
 
+#ifndef ASM_OUTPUT_DWARF_OFFSET
 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
   assemble_integer (gen_rtx_SYMBOL_REF (SImode, LABEL), 4, 1)
+#endif
 
+#ifndef ASM_OUTPUT_DWARF_DELTA2
 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2)                    \
   assemble_integer (gen_rtx_MINUS (HImode,                             \
                                   gen_rtx_SYMBOL_REF (Pmode, LABEL1),  \
                                   gen_rtx_SYMBOL_REF (Pmode, LABEL2)), \
                    2, 1)
-  
+#endif
+
+#ifndef ASM_OUTPUT_DWARF_DELTA4
 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2)                    \
   assemble_integer (gen_rtx_MINUS (SImode,                             \
                                   gen_rtx_SYMBOL_REF (Pmode, LABEL1),  \
                                   gen_rtx_SYMBOL_REF (Pmode, LABEL2)), \
                    4, 1)
+#endif
 
+#ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2)                        \
   assemble_integer (gen_rtx_MINUS (Pmode,                              \
                                   gen_rtx_SYMBOL_REF (Pmode, LABEL1),  \
                                   gen_rtx_SYMBOL_REF (Pmode, LABEL2)), \
                    DWARF2_ADDR_SIZE, 1)
+#endif
 
+#ifndef ASM_OUTPUT_DWARF_DELTA
 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
   ASM_OUTPUT_DWARF_DELTA4 (FILE,LABEL1,LABEL2)
+#endif
+
+#ifndef ASM_OUTPUT_DWARF_DATA2
+#define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
+  assemble_integer (GEN_INT (VALUE), 2, 1)
+#endif
 
+#ifndef ASM_OUTPUT_DWARF_DATA4
 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
   assemble_integer (GEN_INT (VALUE), 4, 1)
+#endif
 
 #endif /* UNALIGNED_INT_ASM_OP */
 
@@ -477,7 +516,7 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
 #ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)            \
  do {                                                                  \
-  fprintf (FILE, "\t%s\t", SET_ASM_OP);                                        \
+  fprintf (FILE, "%s", SET_ASM_OP);                                    \
   assemble_name (FILE, SY);                                            \
   fputc (',', FILE);                                                   \
   assemble_name (FILE, HI);                                            \
@@ -490,10 +529,10 @@ static void dwarf2out_frame_debug_expr    PARAMS ((rtx, const char *));
 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
    newline is produced.  When flag_debug_asm is asserted, we add commentary
    at the end of the line, so we must avoid output of a newline here.  */
-#ifndef ASM_OUTPUT_DWARF_STRING
-#define ASM_OUTPUT_DWARF_STRING(FILE,P) \
+#ifndef ASM_OUTPUT_DWARF_NSTRING
+#define ASM_OUTPUT_DWARF_NSTRING(FILE,P,SLEN) \
   do {                                                                       \
-    register int slen = strlen(P);                                            \
+    register int slen = (SLEN);                                               \
     register const char *p = (P);                                            \
     register int i;                                                          \
     fprintf (FILE, "\t.ascii \"");                                           \
@@ -513,6 +552,8 @@ static void dwarf2out_frame_debug_expr      PARAMS ((rtx, const char *));
   }                                                                          \
   while (0)
 #endif
+#define ASM_OUTPUT_DWARF_STRING(FILE,P) \
+  ASM_OUTPUT_DWARF_NSTRING (FILE, P, strlen (P))
 
 /* The DWARF 2 CFA column which tracks the return address.  Normally this
    is the column for PC, or the first column after all of the hard
@@ -564,24 +605,6 @@ stripattributes (s)
   return stripped;
 }
 
-/* Return the register number described by a given RTL node.  */
-
-static unsigned int
-reg_number (rtl)
-     register rtx rtl;
-{
-  register unsigned regno = REGNO (rtl);
-
-  if (regno >= FIRST_PSEUDO_REGISTER)
-    {
-      warning ("internal regno botch: regno = %d\n", regno);
-      regno = 0;
-    }
-
-  regno = DBX_REGISTER_NUMBER (regno);
-  return regno;
-}
-
 /* Generate code to initialize the register size table.  */
 
 void
@@ -595,9 +618,12 @@ expand_builtin_init_dwarf_reg_sizes (address)
 
   for (i = 0; i < DWARF_FRAME_REGISTERS; ++i)
     {
-      int offset = i * GET_MODE_SIZE (mode);
+      int offset = DWARF_FRAME_REGNUM (i) * GET_MODE_SIZE (mode);
       int size = GET_MODE_SIZE (reg_raw_mode[i]);
 
+      if (offset < 0)
+       continue;
+
       emit_move_insn (change_address (mem, mode,
                                      plus_constant (addr, offset)),
                      GEN_INT (size));
@@ -648,6 +674,8 @@ dwarf_cfi_name (cfi_opc)
       return "DW_CFA_def_cfa_register";
     case DW_CFA_def_cfa_offset:
       return "DW_CFA_def_cfa_offset";
+    case DW_CFA_def_cfa_expression:
+      return "DW_CFA_def_cfa_expression";
 
     /* SGI/MIPS specific */
     case DW_CFA_MIPS_advance_loc8:
@@ -703,7 +731,7 @@ dwarf2out_cfi_label ()
 {
   static char label[20];
   static unsigned long label_num = 0;
-  
+
   ASM_GENERATE_INTERNAL_LABEL (label, "LCFI", label_num++);
   ASM_OUTPUT_LABEL (asm_out_file, label);
 
@@ -749,22 +777,24 @@ add_fde_cfi (label, cfi)
 /* Subroutine of lookup_cfa.  */
 
 static inline void
-lookup_cfa_1 (cfi, regp, offsetp)
+lookup_cfa_1 (cfi, loc)
      register dw_cfi_ref cfi;
-     register unsigned long *regp;
-     register long *offsetp;
+     register dw_cfa_location *loc;
 {
   switch (cfi->dw_cfi_opc)
     {
     case DW_CFA_def_cfa_offset:
-      *offsetp = cfi->dw_cfi_oprnd1.dw_cfi_offset;
+      loc->offset = cfi->dw_cfi_oprnd1.dw_cfi_offset;
       break;
     case DW_CFA_def_cfa_register:
-      *regp = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
+      loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
       break;
     case DW_CFA_def_cfa:
-      *regp = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
-      *offsetp = cfi->dw_cfi_oprnd2.dw_cfi_offset;
+      loc->reg = cfi->dw_cfi_oprnd1.dw_cfi_reg_num;
+      loc->offset = cfi->dw_cfi_oprnd2.dw_cfi_offset;
+      break;
+    case DW_CFA_def_cfa_expression:
+      get_cfa_from_loc_descr (loc, cfi->dw_cfi_oprnd1.dw_cfi_loc);
       break;
     default:
       break;
@@ -774,34 +804,33 @@ lookup_cfa_1 (cfi, regp, offsetp)
 /* Find the previous value for the CFA.  */
 
 static void
-lookup_cfa (regp, offsetp)
-     register unsigned long *regp;
-     register long *offsetp;
+lookup_cfa (loc)
+     register dw_cfa_location *loc;
 {
   register dw_cfi_ref cfi;
 
-  *regp = (unsigned long) -1;
-  *offsetp = 0;
+  loc->reg = (unsigned long) -1;
+  loc->offset = 0;
+  loc->indirect = 0;
+  loc->base_offset = 0;
 
   for (cfi = cie_cfi_head; cfi; cfi = cfi->dw_cfi_next)
-    lookup_cfa_1 (cfi, regp, offsetp);
+    lookup_cfa_1 (cfi, loc);
 
   if (fde_table_in_use)
     {
       register dw_fde_ref fde = &fde_table[fde_table_in_use - 1];
       for (cfi = fde->dw_fde_cfi; cfi; cfi = cfi->dw_cfi_next)
-       lookup_cfa_1 (cfi, regp, offsetp);
+       lookup_cfa_1 (cfi, loc);
     }
 }
 
 /* The current rule for calculating the DWARF2 canonical frame address.  */
-static unsigned long cfa_reg;
-static long cfa_offset;
+dw_cfa_location cfa;
 
 /* The register used for saving registers to the stack, and its offset
    from the CFA.  */
-static unsigned cfa_store_reg;
-static long cfa_store_offset;
+dw_cfa_location cfa_store;
 
 /* The running total of the size of arguments pushed onto the stack.  */
 static long args_size;
@@ -816,45 +845,73 @@ static long old_args_size;
 void
 dwarf2out_def_cfa (label, reg, offset)
      register const char *label;
-     register unsigned reg;
-     register long offset;
+     unsigned reg;
+     long offset;
+{
+  dw_cfa_location loc;
+  loc.indirect = 0;
+  loc.base_offset = 0;
+  loc.reg = reg;
+  loc.offset = offset;
+  def_cfa_1 (label, &loc);
+}
+
+/* This routine does the actual work. The CFA is now calculated from
+   the dw_cfa_location structure.  */
+static void
+def_cfa_1 (label, loc_p)
+     register const char *label;
+     dw_cfa_location *loc_p;
 {
   register dw_cfi_ref cfi;
-  unsigned long old_reg;
-  long old_offset;
+  dw_cfa_location old_cfa, loc;
 
-  cfa_reg = reg;
-  cfa_offset = offset;
-  if (cfa_store_reg == reg)
-    cfa_store_offset = offset;
+  cfa = *loc_p;
+  loc = *loc_p;
 
-  reg = DWARF_FRAME_REGNUM (reg);
-  lookup_cfa (&old_reg, &old_offset);
+  if (cfa_store.reg == loc.reg && loc.indirect == 0)
+    cfa_store.offset = loc.offset;
 
-  if (reg == old_reg && offset == old_offset)
-    return;
+  loc.reg = DWARF_FRAME_REGNUM (loc.reg);
+  lookup_cfa (&old_cfa);
+
+  if (loc.reg == old_cfa.reg && loc.offset == old_cfa.offset &&
+      loc.indirect == old_cfa.indirect)
+    {
+      if (loc.indirect == 0
+         || loc.base_offset == old_cfa.base_offset)
+       return;
+    }
 
   cfi = new_cfi ();
 
-  if (reg == old_reg)
+  if (loc.reg == old_cfa.reg && !loc.indirect)
     {
       cfi->dw_cfi_opc = DW_CFA_def_cfa_offset;
-      cfi->dw_cfi_oprnd1.dw_cfi_offset = offset;
+      cfi->dw_cfi_oprnd1.dw_cfi_offset = loc.offset;
     }
 
 #ifndef MIPS_DEBUGGING_INFO  /* SGI dbx thinks this means no offset.  */
-  else if (offset == old_offset && old_reg != (unsigned long) -1)
+  else if (loc.offset == old_cfa.offset && old_cfa.reg != (unsigned long) -1
+          && !loc.indirect)
     {
       cfi->dw_cfi_opc = DW_CFA_def_cfa_register;
-      cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
+      cfi->dw_cfi_oprnd1.dw_cfi_reg_num = loc.reg;
     }
 #endif
 
-  else
+  else if (loc.indirect == 0)
     {
       cfi->dw_cfi_opc = DW_CFA_def_cfa;
-      cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
-      cfi->dw_cfi_oprnd2.dw_cfi_offset = offset;
+      cfi->dw_cfi_oprnd1.dw_cfi_reg_num = loc.reg;
+      cfi->dw_cfi_oprnd2.dw_cfi_offset = loc.offset;
+    }
+  else
+    {
+      struct dw_loc_descr_struct *loc_list;
+      cfi->dw_cfi_opc = DW_CFA_def_cfa_expression;
+      loc_list = build_cfa_loc (&loc);
+      cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list;
     }
 
   add_fde_cfi (label, cfi);
@@ -887,6 +944,18 @@ reg_save (label, reg, sreg, offset)
       else
        cfi->dw_cfi_opc = DW_CFA_offset;
 
+#ifdef ENABLE_CHECKING
+      {
+       /* If we get an offset that is not a multiple of
+          DWARF_CIE_DATA_ALIGNMENT, there is either a bug in the
+          definition of DWARF_CIE_DATA_ALIGNMENT, or a bug in the machine
+          description.  */
+       long check_offset = offset / DWARF_CIE_DATA_ALIGNMENT;
+
+       if (check_offset * DWARF_CIE_DATA_ALIGNMENT != offset)
+         abort ();
+      }
+#endif
       offset /= DWARF_CIE_DATA_ALIGNMENT;
       if (offset < 0)
        {
@@ -910,7 +979,7 @@ reg_save (label, reg, sreg, offset)
 /* Add the CFI for saving a register window.  LABEL is passed to reg_save.
    This CFI tells the unwinder that it needs to restore the window registers
    from the previous frame's window save area.
-   
+
    ??? Perhaps we should note in the CIE where windows are saved (instead of
    assuming 0(cfa)) and what registers are in the window.  */
 
@@ -1029,7 +1098,51 @@ initial_return_save (rtl)
       abort ();
     }
 
-  reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa_offset);
+  reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset);
+}
+
+/* Given a SET, calculate the amount of stack adjustment it
+   contains. */
+
+static long
+stack_adjust_offset (pattern)
+  rtx pattern;
+{
+  rtx src = SET_SRC (pattern);
+  rtx dest = SET_DEST (pattern);
+  long offset = 0;
+  enum rtx_code code;
+
+  if (dest == stack_pointer_rtx)
+    {
+      /* (set (reg sp) (plus (reg sp) (const_int))) */
+      code = GET_CODE (src);
+      if (! (code == PLUS || code == MINUS)
+         || XEXP (src, 0) != stack_pointer_rtx
+         || GET_CODE (XEXP (src, 1)) != CONST_INT)
+       return 0;
+
+      offset = INTVAL (XEXP (src, 1));
+    }
+  else if (GET_CODE (dest) == MEM)
+    {
+      /* (set (mem (pre_dec (reg sp))) (foo)) */
+      src = XEXP (dest, 0);
+      code = GET_CODE (src);
+
+      if (! (code == PRE_DEC || code == PRE_INC)
+         || XEXP (src, 0) != stack_pointer_rtx)
+       return 0;
+
+      offset = GET_MODE_SIZE (GET_MODE (dest));
+    }
+  else
+    return 0;
+
+  if (code == PLUS || code == PRE_INC)
+    offset = -offset;
+
+  return offset;
 }
 
 /* Check INSN to see if it looks like a push or a stack adjustment, and
@@ -1052,7 +1165,8 @@ dwarf2out_stack_adjust (insn)
        insn = XVECEXP (insn, 0, 0);
       if (GET_CODE (insn) == SET)
        insn = SET_SRC (insn);
-      assert (GET_CODE (insn) == CALL);
+      if (GET_CODE (insn) != CALL)
+       abort ();
       dwarf2out_args_size ("", INTVAL (XEXP (insn, 1)));
       return;
     }
@@ -1060,7 +1174,7 @@ dwarf2out_stack_adjust (insn)
   /* If only calls can throw, and we have a frame pointer,
      save up adjustments until we see the CALL_INSN.  */
   else if (! asynchronous_exceptions
-          && cfa_reg != STACK_POINTER_REGNUM)
+          && cfa.reg != STACK_POINTER_REGNUM)
     return;
 
   if (GET_CODE (insn) == BARRIER)
@@ -1076,41 +1190,22 @@ dwarf2out_stack_adjust (insn)
     }
   else if (GET_CODE (PATTERN (insn)) == SET)
     {
-      rtx src, dest;
-      enum rtx_code code;
-
-      insn = PATTERN (insn);
-      src = SET_SRC (insn);
-      dest = SET_DEST (insn);
-
-      if (dest == stack_pointer_rtx)
-       {
-         /* (set (reg sp) (plus (reg sp) (const_int))) */
-         code = GET_CODE (src);
-         if (! (code == PLUS || code == MINUS)
-             || XEXP (src, 0) != stack_pointer_rtx
-             || GET_CODE (XEXP (src, 1)) != CONST_INT)
-           return;
+      offset = stack_adjust_offset (PATTERN (insn));
+    }
+  else if (GET_CODE (PATTERN (insn)) == PARALLEL
+          || GET_CODE (PATTERN (insn)) == SEQUENCE)
+    {
+      /* There may be stack adjustments inside compound insns.  Search
+         for them. */
+      int j;
 
-         offset = INTVAL (XEXP (src, 1));
-       }
-      else if (GET_CODE (dest) == MEM)
+      offset = 0;
+      for (j = XVECLEN (PATTERN (insn), 0) - 1; j >= 0; j--)
        {
-         /* (set (mem (pre_dec (reg sp))) (foo)) */
-         src = XEXP (dest, 0);
-         code = GET_CODE (src);
-
-         if (! (code == PRE_DEC || code == PRE_INC)
-             || XEXP (src, 0) != stack_pointer_rtx)
-           return;
-
-         offset = GET_MODE_SIZE (GET_MODE (dest));
+         rtx pattern = XVECEXP (PATTERN (insn), 0, j);
+         if (GET_CODE (pattern) == SET)
+           offset += stack_adjust_offset (pattern);
        }
-      else
-       return;
-
-      if (code == PLUS || code == PRE_INC)
-       offset = -offset;
     }
   else
     return;
@@ -1118,8 +1213,8 @@ dwarf2out_stack_adjust (insn)
   if (offset == 0)
     return;
 
-  if (cfa_reg == STACK_POINTER_REGNUM)
-    cfa_offset += offset;
+  if (cfa.reg == STACK_POINTER_REGNUM)
+    cfa.offset += offset;
 
 #ifndef STACK_GROWS_DOWNWARD
   offset = -offset;
@@ -1129,7 +1224,7 @@ dwarf2out_stack_adjust (insn)
     args_size = 0;
 
   label = dwarf2out_cfi_label ();
-  dwarf2out_def_cfa (label, cfa_reg, cfa_offset);
+  def_cfa_1 (label, &cfa);
   dwarf2out_args_size (label, args_size);
 }
 
@@ -1141,7 +1236,7 @@ static long cfa_temp_value;
 
 /* Record call frame debugging information for an expression, which either
    sets SP or FP (adjusting how we calculate the frame address) or saves a
-   register to the stack. */
+   register to the stack.  */
 
 static void
 dwarf2out_frame_debug_expr (expr, label)
@@ -1150,29 +1245,30 @@ dwarf2out_frame_debug_expr (expr, label)
 {
   rtx src, dest;
   long offset;
-    
-  /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of 
-     the PARALLEL independantly. The first element is always processed if 
-     it is a SET. This is for backward compatability.   Other elements 
-     are processed only if they are SETs and the RTX_FRAME_RELATED_P 
-     flag is set in them. */
-
-  if (GET_CODE (expr) == PARALLEL)
-    { 
+
+  /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
+     the PARALLEL independently. The first element is always processed if
+     it is a SET. This is for backward compatability.   Other elements
+     are processed only if they are SETs and the RTX_FRAME_RELATED_P
+     flag is set in them.  */
+
+  if (GET_CODE (expr) == PARALLEL
+      || GET_CODE (expr) == SEQUENCE)
+    {
       int par_index;
       int limit = XVECLEN (expr, 0);
 
       for (par_index = 0; par_index < limit; par_index++)
-        {
-          rtx x = XVECEXP (expr, 0, par_index);
-          
-          if (GET_CODE (x) == SET &&
+       {
+         rtx x = XVECEXP (expr, 0, par_index);
+
+         if (GET_CODE (x) == SET &&
              (RTX_FRAME_RELATED_P (x) || par_index == 0))
            dwarf2out_frame_debug_expr (x, label);
-        }
+       }
       return;
     }
-  
+
   if (GET_CODE (expr) != SET)
     abort ();
 
@@ -1185,23 +1281,26 @@ dwarf2out_frame_debug_expr (expr, label)
       /* Update the CFA rule wrt SP or FP.  Make sure src is
          relative to the current CFA register.  */
       switch (GET_CODE (src))
-        {
-          /* Setting FP from SP.  */
-        case REG:
-          if (cfa_reg != (unsigned) REGNO (src))
-            abort ();
+       {
+         /* Setting FP from SP.  */
+       case REG:
+         if (cfa.reg == (unsigned) REGNO (src))
+           /* OK.  */
+           ;
+         else
+           abort ();
 
          /* We used to require that dest be either SP or FP, but the
             ARM copies SP to a temporary register, and from there to
             FP.  So we just rely on the backends to only set
             RTX_FRAME_RELATED_P on appropriate insns.  */
-          cfa_reg = REGNO (dest);
-          break;
+         cfa.reg = REGNO (dest);
+         break;
 
-        case PLUS:
-        case MINUS:
-          if (dest == stack_pointer_rtx)
-            {
+       case PLUS:
+       case MINUS:
+         if (dest == stack_pointer_rtx)
+           {
              /* Adjusting SP.  */
              switch (GET_CODE (XEXP (src, 1)))
                {
@@ -1220,80 +1319,91 @@ dwarf2out_frame_debug_expr (expr, label)
              if (XEXP (src, 0) == hard_frame_pointer_rtx)
                {
                  /* Restoring SP from FP in the epilogue.  */
-                 if (cfa_reg != (unsigned) HARD_FRAME_POINTER_REGNUM)
+                 if (cfa.reg != (unsigned) HARD_FRAME_POINTER_REGNUM)
                    abort ();
-                 cfa_reg = STACK_POINTER_REGNUM;
+                 cfa.reg = STACK_POINTER_REGNUM;
                }
              else if (XEXP (src, 0) != stack_pointer_rtx)
                abort ();
 
              if (GET_CODE (src) == PLUS)
                offset = -offset;
-             if (cfa_reg == STACK_POINTER_REGNUM)
-               cfa_offset += offset;
-             if (cfa_store_reg == STACK_POINTER_REGNUM)
-               cfa_store_offset += offset;
-            }
-          else if (dest == hard_frame_pointer_rtx)
-            {
+             if (cfa.reg == STACK_POINTER_REGNUM)
+               cfa.offset += offset;
+             if (cfa_store.reg == STACK_POINTER_REGNUM)
+               cfa_store.offset += offset;
+           }
+         else if (dest == hard_frame_pointer_rtx)
+           {
              /* Either setting the FP from an offset of the SP,
                 or adjusting the FP */
              if (! frame_pointer_needed)
                abort ();
 
              if (GET_CODE (XEXP (src, 0)) == REG
-                 && (unsigned) REGNO (XEXP (src, 0)) == cfa_reg
+                 && (unsigned) REGNO (XEXP (src, 0)) == cfa.reg
                  && GET_CODE (XEXP (src, 1)) == CONST_INT)
                {
                  offset = INTVAL (XEXP (src, 1));
                  if (GET_CODE (src) == PLUS)
                    offset = -offset;
-                 cfa_offset += offset;
-                 cfa_reg = HARD_FRAME_POINTER_REGNUM;
+                 cfa.offset += offset;
+                 cfa.reg = HARD_FRAME_POINTER_REGNUM;
                }
-             else 
-               abort();
-            }
-          else
-            {
+             else
+               abort ();
+           }
+         else
+           {
              if (GET_CODE (src) != PLUS
                  || XEXP (src, 1) != stack_pointer_rtx)
                abort ();
              if (GET_CODE (XEXP (src, 0)) != REG
                  || (unsigned) REGNO (XEXP (src, 0)) != cfa_temp_reg)
                abort ();
-             if (cfa_reg != STACK_POINTER_REGNUM)
+             if (cfa.reg != STACK_POINTER_REGNUM)
                abort ();
-             cfa_store_reg = REGNO (dest);
-             cfa_store_offset = cfa_offset - cfa_temp_value;
-            }
-          break;
-
-        case CONST_INT:
-          cfa_temp_reg = REGNO (dest);
-          cfa_temp_value = INTVAL (src);
-          break;
-
-        case IOR:
-          if (GET_CODE (XEXP (src, 0)) != REG
+             cfa_store.reg = REGNO (dest);
+             cfa_store.offset = cfa.offset - cfa_temp_value;
+           }
+         break;
+
+       case CONST_INT:
+         cfa_temp_reg = REGNO (dest);
+         cfa_temp_value = INTVAL (src);
+         break;
+
+       case IOR:
+         if (GET_CODE (XEXP (src, 0)) != REG
              || (unsigned) REGNO (XEXP (src, 0)) != cfa_temp_reg
              || (unsigned) REGNO (dest) != cfa_temp_reg
              || GET_CODE (XEXP (src, 1)) != CONST_INT)
-            abort ();
-          cfa_temp_value |= INTVAL (XEXP (src, 1));
-          break;
-
-        default:
-          abort ();
-        }
-      dwarf2out_def_cfa (label, cfa_reg, cfa_offset);
+           abort ();
+         cfa_temp_value |= INTVAL (XEXP (src, 1));
+         break;
+
+       default:
+         abort ();
+       }
+      def_cfa_1 (label, &cfa);
+      break;
+
+      /* Skip over HIGH, assuming it will be followed by a LO_SUM, which
+        will fill in all of the bits.  */
+    case HIGH:
+      break;
+
+    case LO_SUM:
+      cfa_temp_reg = REGNO (dest);
+      cfa_temp_value = INTVAL (XEXP (src, 1));
       break;
 
     case MEM:
-      /* Saving a register to the stack.  Make sure dest is relative to the
-        CFA register.  */
       if (GET_CODE (src) != REG)
        abort ();
+
+      /* Saving a register to the stack.  Make sure dest is relative to the
+        CFA register.  */
       switch (GET_CODE (XEXP (dest, 0)))
        {
          /* With a push.  */
@@ -1304,13 +1414,13 @@ dwarf2out_frame_debug_expr (expr, label)
            offset = -offset;
 
          if (REGNO (XEXP (XEXP (dest, 0), 0)) != STACK_POINTER_REGNUM
-             || cfa_store_reg != STACK_POINTER_REGNUM)
+             || cfa_store.reg != STACK_POINTER_REGNUM)
            abort ();
-         cfa_store_offset += offset;
-         if (cfa_reg == STACK_POINTER_REGNUM)
-           cfa_offset = cfa_store_offset;
+         cfa_store.offset += offset;
+         if (cfa.reg == STACK_POINTER_REGNUM)
+           cfa.offset = cfa_store.offset;
 
-         offset = -cfa_store_offset;
+         offset = -cfa_store.offset;
          break;
 
          /* With an offset.  */
@@ -1320,22 +1430,57 @@ dwarf2out_frame_debug_expr (expr, label)
          if (GET_CODE (XEXP (dest, 0)) == MINUS)
            offset = -offset;
 
-         if (cfa_store_reg != (unsigned) REGNO (XEXP (XEXP (dest, 0), 0)))
+         if (cfa_store.reg != (unsigned) REGNO (XEXP (XEXP (dest, 0), 0)))
            abort ();
-         offset -= cfa_store_offset;
+         offset -= cfa_store.offset;
          break;
 
          /* Without an offset.  */
        case REG:
-         if (cfa_store_reg != REGNO (XEXP (dest, 0)))
-           abort();
-         offset = -cfa_store_offset;
+         if (cfa_store.reg != (unsigned) REGNO (XEXP (dest, 0)))
+           abort ();
+         offset = -cfa_store.offset;
          break;
 
        default:
          abort ();
        }
-      dwarf2out_def_cfa (label, cfa_reg, cfa_offset);
+
+      if (REGNO (src) != STACK_POINTER_REGNUM
+         && REGNO (src) != HARD_FRAME_POINTER_REGNUM
+         && (unsigned) REGNO (src) == cfa.reg)
+       {
+         /* We're storing the current CFA reg into the stack.  */
+
+         if (cfa.offset == 0)
+           {
+             /* If the source register is exactly the CFA, assume
+                we're saving SP like any other register; this happens
+                on the ARM.  */
+
+             def_cfa_1 (label, &cfa);
+             dwarf2out_reg_save (label, STACK_POINTER_REGNUM, offset);
+             break;
+           }
+         else
+           {
+             /* Otherwise, we'll need to look in the stack to
+                 calculate the CFA.  */
+
+             rtx x = XEXP (dest, 0);
+             if (GET_CODE (x) != REG)
+               x = XEXP (x, 0);
+             if (GET_CODE (x) != REG)
+               abort ();
+             cfa.reg = (unsigned) REGNO (x);
+             cfa.base_offset = offset;
+             cfa.indirect = 1;
+             def_cfa_1 (label, &cfa);
+             break;
+           }
+       }
+
+      def_cfa_1 (label, &cfa);
       dwarf2out_reg_save (label, REGNO (src), offset);
       break;
 
@@ -1344,7 +1489,6 @@ dwarf2out_frame_debug_expr (expr, label)
     }
 }
 
-
 /* Record call frame debugging information for INSN, which either
    sets SP or FP (adjusting how we calculate the frame address) or saves a
    register to the stack.  If INSN is NULL_RTX, initialize our state.  */
@@ -1359,12 +1503,11 @@ dwarf2out_frame_debug (insn)
   if (insn == NULL_RTX)
     {
       /* Set up state for generating call frame debug info.  */
-      lookup_cfa (&cfa_reg, &cfa_offset);
-      if (cfa_reg != (unsigned long) DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM))
+      lookup_cfa (&cfa);
+      if (cfa.reg != (unsigned long) DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM))
        abort ();
-      cfa_reg = STACK_POINTER_REGNUM;
-      cfa_store_reg = cfa_reg;
-      cfa_store_offset = cfa_offset;
+      cfa.reg = STACK_POINTER_REGNUM;
+      cfa_store = cfa;
       cfa_temp_reg = -1;
       cfa_temp_value = 0;
       return;
@@ -1377,11 +1520,11 @@ dwarf2out_frame_debug (insn)
     }
 
   label = dwarf2out_cfi_label ();
-    
+
   src = find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX);
   if (src)
     insn = XEXP (src, 0);
-  else 
+  else
     insn = PATTERN (insn);
 
   dwarf2out_frame_debug_expr (insn, label);
@@ -1436,7 +1579,7 @@ output_uleb128 (value)
 {
   unsigned long save_value = value;
 
-  fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP);
+  fprintf (asm_out_file, "%s", ASM_BYTE_OP);
   do
     {
       register unsigned byte = (value & 0x7f);
@@ -1465,7 +1608,7 @@ output_sleb128 (value)
   register unsigned byte;
   long save_value = value;
 
-  fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP);
+  fprintf (asm_out_file, "%s", ASM_BYTE_OP);
   do
     {
       byte = (value & 0x7f);
@@ -1539,8 +1682,8 @@ output_cfi (cfi, fde)
       switch (cfi->dw_cfi_opc)
        {
        case DW_CFA_set_loc:
-          ASM_OUTPUT_DWARF_ADDR (asm_out_file, cfi->dw_cfi_oprnd1.dw_cfi_addr);
-          fputc ('\n', asm_out_file);
+         ASM_OUTPUT_DWARF_ADDR (asm_out_file, cfi->dw_cfi_oprnd1.dw_cfi_addr);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_advance_loc1:
          ASM_OUTPUT_DWARF_DELTA1 (asm_out_file,
@@ -1550,17 +1693,17 @@ output_cfi (cfi, fde)
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
        case DW_CFA_advance_loc2:
-          ASM_OUTPUT_DWARF_DELTA2 (asm_out_file,
+         ASM_OUTPUT_DWARF_DELTA2 (asm_out_file,
                                   cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                   fde->dw_fde_current_label);
           fputc ('\n', asm_out_file);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
        case DW_CFA_advance_loc4:
-          ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
+         ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
                                   cfi->dw_cfi_oprnd1.dw_cfi_addr,
                                   fde->dw_fde_current_label);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
 #ifdef MIPS_DEBUGGING_INFO
@@ -1573,40 +1716,43 @@ output_cfi (cfi, fde)
        case DW_CFA_GNU_negative_offset_extended:
        case DW_CFA_def_cfa:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_restore_extended:
        case DW_CFA_undefined:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_same_value:
        case DW_CFA_def_cfa_register:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_register:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_def_cfa_offset:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
          break;
        case DW_CFA_GNU_window_save:
          break;
        case DW_CFA_GNU_args_size:
          output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset);
-          fputc ('\n', asm_out_file);
+         fputc ('\n', asm_out_file);
+         break;
+       case DW_CFA_def_cfa_expression:
+         output_cfa_loc (cfi);
          break;
        default:
          break;
        }
-     }
+    }
 }
 
 /* Output the call frame information used to used to record information
@@ -1662,7 +1808,7 @@ output_call_frame_info (for_eh)
   else
     ASM_OUTPUT_SECTION (asm_out_file, FRAME_SECTION);
 
-  /* Output the CIE. */
+  /* Output the CIE.  */
   ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
   ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
 #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
@@ -1775,10 +1921,10 @@ output_call_frame_info (for_eh)
       if (for_eh && fde->nothrow)
        continue;
 
-      ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i*2);
-      ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i*2);
+      ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2);
+      ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i * 2);
 #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
-      ASM_GENERATE_INTERNAL_LABEL (ld, FDE_LENGTH_LABEL, for_eh + i*2);
+      ASM_GENERATE_INTERNAL_LABEL (ld, FDE_LENGTH_LABEL, for_eh + i * 2);
       if (for_eh)
        ASM_OUTPUT_DWARF_OFFSET4 (asm_out_file, ld);
       else
@@ -1945,23 +2091,16 @@ dwarf2out_frame_finish ()
 #else
   if (write_symbols == DWARF2_DEBUG
       || flag_unwind_tables || (flag_exceptions && ! exceptions_via_longjmp))
-    output_call_frame_info (1);  
+    output_call_frame_info (1);
 #endif
-}  
-
-#endif /* .debug_frame support */
-
-/* And now, the support for symbolic debugging information.  */
-#ifdef DWARF2_DEBUGGING_INFO
-
-/* NOTE: In the comments in this file, many references are made to
-   "Debugging Information Entries".  This term is abbreviated as `DIE'
-   throughout the remainder of this file.  */
+}
+\f
+/* And now, the subset of the debugging information support code necessary
+   for emitting location expressions.  */
 
-/* An internal representation of the DWARF output is built, and then
-   walked to generate the DWARF debugging info.  The walk of the internal
-   representation is done after the entire program has been compiled.
-   The types below are used to describe the internal representation.  */
+typedef struct dw_val_struct *dw_val_ref;
+typedef struct die_struct *dw_die_ref;
+typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
 
 /* Each DIE may have a series of attribute/value pairs.  Values
    can take on several forms.  The forms that are used in this
@@ -1984,23 +2123,8 @@ typedef enum
 }
 dw_val_class;
 
-/* Various DIE's use offsets relative to the beginning of the
-   .debug_info section to refer to each other.  */
-
-typedef long int dw_offset;
-
-/* Define typedefs here to avoid circular dependencies.  */
-
-typedef struct die_struct *dw_die_ref;
-typedef struct dw_attr_struct *dw_attr_ref;
-typedef struct dw_val_struct *dw_val_ref;
-typedef struct dw_line_info_struct *dw_line_info_ref;
-typedef struct dw_separate_line_info_struct *dw_separate_line_info_ref;
-typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
-typedef struct pubname_struct *pubname_ref;
-typedef dw_die_ref *arange_ref;
-
 /* Describe a double word constant value.  */
+/* ??? Every instance of long_long in the code really means CONST_DOUBLE.  */
 
 typedef struct dw_long_long_struct
 {
@@ -2018,32 +2142,10 @@ typedef struct dw_fp_struct
 }
 dw_float_const;
 
-/* Each entry in the line_info_table maintains the file and
-   line number associated with the label generated for that
-   entry.  The label gives the PC value associated with
-   the line number entry.  */
+/* The dw_val_node describes an attribute's value, as it is
+   represented internally.  */
 
-typedef struct dw_line_info_struct
-{
-  unsigned long dw_file_num;
-  unsigned long dw_line_num;
-}
-dw_line_info_entry;
-
-/* Line information for functions in separate sections; each one gets its
-   own sequence.  */
-typedef struct dw_separate_line_info_struct
-{
-  unsigned long dw_file_num;
-  unsigned long dw_line_num;
-  unsigned long function;
-}
-dw_separate_line_info_entry;
-
-/* The dw_val_node describes an attribute's value, as it is
-   represented internally.  */
-
-typedef struct dw_val_struct
+typedef struct dw_val_struct
 {
   dw_val_class val_class;
   union
@@ -2054,7 +2156,10 @@ typedef struct dw_val_struct
       long unsigned val_unsigned;
       dw_long_long_const val_long_long;
       dw_float_const val_float;
-      dw_die_ref val_die_ref;
+      struct {
+       dw_die_ref die;
+       int external;
+      } val_die_ref;
       unsigned val_fde_index;
       char *val_str;
       char *val_lbl_id;
@@ -2073,1005 +2178,26 @@ typedef struct dw_loc_descr_struct
   enum dwarf_location_atom dw_loc_opc;
   dw_val_node dw_loc_oprnd1;
   dw_val_node dw_loc_oprnd2;
+  int dw_loc_addr;
 }
 dw_loc_descr_node;
 
-/* Each DIE attribute has a field specifying the attribute kind,
-   a link to the next attribute in the chain, and an attribute value.
-   Attributes are typically linked below the DIE they modify.  */
-
-typedef struct dw_attr_struct
-{
-  enum dwarf_attribute dw_attr;
-  dw_attr_ref dw_attr_next;
-  dw_val_node dw_attr_val;
-}
-dw_attr_node;
-
-/* The Debugging Information Entry (DIE) structure */
-
-typedef struct die_struct
-{
-  enum dwarf_tag die_tag;
-  dw_attr_ref die_attr;
-  dw_die_ref die_parent;
-  dw_die_ref die_child;
-  dw_die_ref die_sib;
-  dw_offset die_offset;
-  unsigned long die_abbrev;
-}
-die_node;
-
-/* The pubname structure */
+static const char *dwarf_stack_op_name PARAMS ((unsigned));
+static dw_loc_descr_ref new_loc_descr  PARAMS ((enum dwarf_location_atom,
+                                                unsigned long,
+                                                unsigned long));
+static void add_loc_descr              PARAMS ((dw_loc_descr_ref *,
+                                                dw_loc_descr_ref));
+static unsigned long size_of_loc_descr PARAMS ((dw_loc_descr_ref));
+static unsigned long size_of_locs      PARAMS ((dw_loc_descr_ref));
+static void output_loc_operands                PARAMS ((dw_loc_descr_ref));
+static void output_loc_sequence                PARAMS ((dw_loc_descr_ref));
 
-typedef struct pubname_struct
-{
-  dw_die_ref die;
-  char * name;
-}
-pubname_entry;
+/* Convert a DWARF stack opcode into its string name.  */
 
-/* The limbo die list structure.  */
-typedef struct limbo_die_struct
-{
-  dw_die_ref die;
-  struct limbo_die_struct *next;
-}
-limbo_die_node;
-
-/* How to start an assembler comment.  */
-#ifndef ASM_COMMENT_START
-#define ASM_COMMENT_START ";#"
-#endif
-
-/* Define a macro which returns non-zero for a TYPE_DECL which was
-   implicitly generated for a tagged type.
-
-   Note that unlike the gcc front end (which generates a NULL named
-   TYPE_DECL node for each complete tagged type, each array type, and
-   each function type node created) the g++ front end generates a
-   _named_ TYPE_DECL node for each tagged type node created.
-   These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
-   generate a DW_TAG_typedef DIE for them.  */
-
-#define TYPE_DECL_IS_STUB(decl)                                \
-  (DECL_NAME (decl) == NULL_TREE                       \
-   || (DECL_ARTIFICIAL (decl)                          \
-       && is_tagged_type (TREE_TYPE (decl))            \
-       && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
-          /* This is necessary for stub decls that     \
-             appear in nested inline functions.  */    \
-          || (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
-              && (decl_ultimate_origin (decl)          \
-                  == TYPE_STUB_DECL (TREE_TYPE (decl)))))))
-
-/* Information concerning the compilation unit's programming
-   language, and compiler version.  */
-
-extern int flag_traditional;
-
-/* Fixed size portion of the DWARF compilation unit header.  */
-#define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
-
-/* Fixed size portion of debugging line information prolog.  */
-#define DWARF_LINE_PROLOG_HEADER_SIZE 5
-
-/* Fixed size portion of public names info.  */
-#define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
-
-/* Fixed size portion of the address range info.  */
-#define DWARF_ARANGES_HEADER_SIZE                                      \
-  (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2)       \
-   - DWARF_OFFSET_SIZE)
-
-/* Size of padding portion in the address range info.  It must be
-   aligned to twice the pointer size.  */
-#define DWARF_ARANGES_PAD_SIZE \
-  (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
-   - (2 * DWARF_OFFSET_SIZE + 4))
-
-/* The default is to have gcc emit the line number tables.  */
-#ifndef DWARF2_ASM_LINE_DEBUG_INFO
-#define DWARF2_ASM_LINE_DEBUG_INFO 0
-#endif
-
-/* Define the architecture-dependent minimum instruction length (in bytes).
-   In this implementation of DWARF, this field is used for information
-   purposes only.  Since GCC generates assembly language, we have
-   no a priori knowledge of how many instruction bytes are generated
-   for each source line, and therefore can use only the  DW_LNE_set_address
-   and DW_LNS_fixed_advance_pc line information commands.  */
-
-#ifndef DWARF_LINE_MIN_INSTR_LENGTH
-#define DWARF_LINE_MIN_INSTR_LENGTH 4
-#endif
-
-/* Minimum line offset in a special line info. opcode.
-   This value was chosen to give a reasonable range of values.  */
-#define DWARF_LINE_BASE  -10
-
-/* First special line opcde - leave room for the standard opcodes.  */
-#define DWARF_LINE_OPCODE_BASE  10
-
-/* Range of line offsets in a special line info. opcode.  */
-#define DWARF_LINE_RANGE  (254-DWARF_LINE_OPCODE_BASE+1)
-
-/* Flag that indicates the initial value of the is_stmt_start flag.
-   In the present implementation, we do not mark any lines as
-   the beginning of a source statement, because that information
-   is not made available by the GCC front-end.  */
-#define        DWARF_LINE_DEFAULT_IS_STMT_START 1
-
-/* This location is used by calc_die_sizes() to keep track
-   the offset of each DIE within the .debug_info section.  */
-static unsigned long next_die_offset;
-
-/* Record the root of the DIE's built for the current compilation unit.  */
-static dw_die_ref comp_unit_die;
-
-/* A list of DIEs with a NULL parent waiting to be relocated.  */
-static limbo_die_node *limbo_die_list = 0;
-
-/* Pointer to an array of filenames referenced by this compilation unit.  */
-static char **file_table;
-
-/* Total number of entries in the table (i.e. array) pointed to by
-   `file_table'.  This is the *total* and includes both used and unused
-   slots.  */
-static unsigned file_table_allocated;
-
-/* Number of entries in the file_table which are actually in use.  */
-static unsigned file_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the filename
-   table.  */
-#define FILE_TABLE_INCREMENT 64
-
-/* Local pointer to the name of the main input file.  Initialized in
-   dwarf2out_init.  */
-static const char *primary_filename;
-
-/* A pointer to the base of a table of references to DIE's that describe
-   declarations.  The table is indexed by DECL_UID() which is a unique
-   number identifying each decl.  */
-static dw_die_ref *decl_die_table;
-
-/* Number of elements currently allocated for the decl_die_table.  */
-static unsigned decl_die_table_allocated;
-
-/* Number of elements in decl_die_table currently in use.  */
-static unsigned decl_die_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the
-   decl_die_table.  */
-#define DECL_DIE_TABLE_INCREMENT 256
-
-/* A pointer to the base of a table of references to declaration
-   scopes.  This table is a display which tracks the nesting
-   of declaration scopes at the current scope and containing
-   scopes.  This table is used to find the proper place to
-   define type declaration DIE's.  */
-static tree *decl_scope_table;
-
-/* Number of elements currently allocated for the decl_scope_table.  */
-static int decl_scope_table_allocated;
-
-/* Current level of nesting of declaration scopes.  */
-static int decl_scope_depth;
-
-/* Size (in elements) of increments by which we may expand the
-   decl_scope_table.  */
-#define DECL_SCOPE_TABLE_INCREMENT 64
-
-/* A pointer to the base of a list of references to DIE's that
-   are uniquely identified by their tag, presence/absence of
-   children DIE's, and list of attribute/value pairs.  */
-static dw_die_ref *abbrev_die_table;
-
-/* Number of elements currently allocated for abbrev_die_table.  */
-static unsigned abbrev_die_table_allocated;
-
-/* Number of elements in type_die_table currently in use.  */
-static unsigned abbrev_die_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the
-   abbrev_die_table.  */
-#define ABBREV_DIE_TABLE_INCREMENT 256
-
-/* A pointer to the base of a table that contains line information
-   for each source code line in .text in the compilation unit.  */
-static dw_line_info_ref line_info_table;
-
-/* Number of elements currently allocated for line_info_table.  */
-static unsigned line_info_table_allocated;
-
-/* Number of elements in separate_line_info_table currently in use.  */
-static unsigned separate_line_info_table_in_use;
-
-/* A pointer to the base of a table that contains line information
-   for each source code line outside of .text in the compilation unit.  */
-static dw_separate_line_info_ref separate_line_info_table;
-
-/* Number of elements currently allocated for separate_line_info_table.  */
-static unsigned separate_line_info_table_allocated;
-
-/* Number of elements in line_info_table currently in use.  */
-static unsigned line_info_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the
-   line_info_table.  */
-#define LINE_INFO_TABLE_INCREMENT 1024
-
-/* A pointer to the base of a table that contains a list of publicly
-   accessible names.  */
-static pubname_ref pubname_table;
-
-/* Number of elements currently allocated for pubname_table.  */
-static unsigned pubname_table_allocated;
-
-/* Number of elements in pubname_table currently in use.  */
-static unsigned pubname_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the
-   pubname_table.  */
-#define PUBNAME_TABLE_INCREMENT 64
-
-/* A pointer to the base of a table that contains a list of publicly
-   accessible names.  */
-static arange_ref arange_table;
-
-/* Number of elements currently allocated for arange_table.  */
-static unsigned arange_table_allocated;
-
-/* Number of elements in arange_table currently in use.  */
-static unsigned arange_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the
-   arange_table.  */
-#define ARANGE_TABLE_INCREMENT 64
-
-/* A pointer to the base of a list of incomplete types which might be
-   completed at some later time.  */
-
-static tree *incomplete_types_list;
-
-/* Number of elements currently allocated for the incomplete_types_list.  */
-static unsigned incomplete_types_allocated;
-
-/* Number of elements of incomplete_types_list currently in use.  */
-static unsigned incomplete_types;
-
-/* Size (in elements) of increments by which we may expand the incomplete
-   types list.  Actually, a single hunk of space of this size should
-   be enough for most typical programs.         */
-#define INCOMPLETE_TYPES_INCREMENT 64
-
-/* Record whether the function being analyzed contains inlined functions.  */
-static int current_function_has_inlines;
-#if 0 && defined (MIPS_DEBUGGING_INFO)
-static int comp_unit_has_inlines;
-#endif
-
-/* Array of RTXes referenced by the debugging information, which therefore
-   must be kept around forever.  We do this rather than perform GC on
-   the dwarf info because almost all of the dwarf info lives forever, and
-   it's easier to support non-GC frontends this way.  */
-static varray_type used_rtx_varray;
-
-/* Forward declarations for functions defined in this file.  */
-
-static int is_pseudo_reg               PARAMS ((rtx));
-static tree type_main_variant          PARAMS ((tree));
-static int is_tagged_type              PARAMS ((tree));
-static const char *dwarf_tag_name      PARAMS ((unsigned));
-static const char *dwarf_attr_name     PARAMS ((unsigned));
-static const char *dwarf_form_name     PARAMS ((unsigned));
-static const char *dwarf_stack_op_name PARAMS ((unsigned));
-#if 0
-static const char *dwarf_type_encoding_name PARAMS ((unsigned));
-#endif
-static tree decl_ultimate_origin       PARAMS ((tree));
-static tree block_ultimate_origin      PARAMS ((tree));
-static tree decl_class_context         PARAMS ((tree));
-static void add_dwarf_attr             PARAMS ((dw_die_ref, dw_attr_ref));
-static void add_AT_flag                        PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                unsigned));
-static void add_AT_int                 PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute, long));
-static void add_AT_unsigned            PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                unsigned long));
-static void add_AT_long_long           PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                unsigned long,
-                                                unsigned long));
-static void add_AT_float               PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                unsigned, long *));
-static void add_AT_string              PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                const char *));
-static void add_AT_die_ref             PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                dw_die_ref));
-static void add_AT_fde_ref             PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                unsigned));
-static void add_AT_loc                 PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                dw_loc_descr_ref));
-static void add_AT_addr                        PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                rtx));
-static void add_AT_lbl_id              PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                const char *));
-static void add_AT_lbl_offset          PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute,
-                                                const char *));
-static dw_attr_ref get_AT              PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute));
-static const char *get_AT_low_pc       PARAMS ((dw_die_ref));
-static const char *get_AT_hi_pc                PARAMS ((dw_die_ref));
-static const char *get_AT_string       PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute));
-static int get_AT_flag                 PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute));
-static unsigned get_AT_unsigned                PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute));
-static inline dw_die_ref get_AT_ref    PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute));
-static int is_c_family                 PARAMS ((void));
-static int is_fortran                  PARAMS ((void));
-static void remove_AT                  PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute));
-static void remove_children            PARAMS ((dw_die_ref));
-static void add_child_die              PARAMS ((dw_die_ref, dw_die_ref));
-static dw_die_ref new_die              PARAMS ((enum dwarf_tag, dw_die_ref));
-static dw_die_ref lookup_type_die      PARAMS ((tree));
-static void equate_type_number_to_die  PARAMS ((tree, dw_die_ref));
-static dw_die_ref lookup_decl_die      PARAMS ((tree));
-static void equate_decl_number_to_die  PARAMS ((tree, dw_die_ref));
-static dw_loc_descr_ref new_loc_descr  PARAMS ((enum dwarf_location_atom,
-                                                unsigned long,
-                                                unsigned long));
-static void add_loc_descr              PARAMS ((dw_loc_descr_ref *,
-                                                dw_loc_descr_ref));
-static void print_spaces               PARAMS ((FILE *));
-static void print_die                  PARAMS ((dw_die_ref, FILE *));
-static void print_dwarf_line_table     PARAMS ((FILE *));
-static void add_sibling_attributes     PARAMS ((dw_die_ref));
-static void build_abbrev_table         PARAMS ((dw_die_ref));
-static unsigned long size_of_string    PARAMS ((const char *));
-static unsigned long size_of_loc_descr PARAMS ((dw_loc_descr_ref));
-static unsigned long size_of_locs      PARAMS ((dw_loc_descr_ref));
-static int constant_size               PARAMS ((long unsigned));
-static unsigned long size_of_die       PARAMS ((dw_die_ref));
-static void calc_die_sizes             PARAMS ((dw_die_ref));
-static unsigned long size_of_line_prolog PARAMS ((void));
-static unsigned long size_of_pubnames  PARAMS ((void));
-static unsigned long size_of_aranges   PARAMS ((void));
-static enum dwarf_form value_format    PARAMS ((dw_attr_ref));
-static void output_value_format                PARAMS ((dw_attr_ref));
-static void output_abbrev_section      PARAMS ((void));
-static void output_loc_operands                PARAMS ((dw_loc_descr_ref));
-static void output_die                 PARAMS ((dw_die_ref));
-static void output_compilation_unit_header PARAMS ((void));
-static const char *dwarf2_name         PARAMS ((tree, int));
-static void add_pubname                        PARAMS ((tree, dw_die_ref));
-static void output_pubnames            PARAMS ((void));
-static void add_arange                 PARAMS ((tree, dw_die_ref));
-static void output_aranges             PARAMS ((void));
-static void output_line_info           PARAMS ((void));
-static dw_die_ref base_type_die                PARAMS ((tree));
-static tree root_type                  PARAMS ((tree));
-static int is_base_type                        PARAMS ((tree));
-static dw_die_ref modified_type_die    PARAMS ((tree, int, int, dw_die_ref));
-static int type_is_enum                        PARAMS ((tree));
-static dw_loc_descr_ref reg_loc_descriptor PARAMS ((rtx));
-static dw_loc_descr_ref based_loc_descr        PARAMS ((unsigned, long));
-static int is_based_loc                        PARAMS ((rtx));
-static dw_loc_descr_ref mem_loc_descriptor PARAMS ((rtx, enum machine_mode mode));
-static dw_loc_descr_ref concat_loc_descriptor PARAMS ((rtx, rtx));
-static dw_loc_descr_ref loc_descriptor PARAMS ((rtx));
-static HOST_WIDE_INT ceiling           PARAMS ((HOST_WIDE_INT, unsigned int));
-static tree field_type                 PARAMS ((tree));
-static unsigned int simple_type_align_in_bits PARAMS ((tree));
-static unsigned HOST_WIDE_INT simple_type_size_in_bits PARAMS ((tree));
-static HOST_WIDE_INT field_byte_offset PARAMS ((tree));
-static void add_AT_location_description        PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute, rtx));
-static void add_data_member_location_attribute PARAMS ((dw_die_ref, tree));
-static void add_const_value_attribute  PARAMS ((dw_die_ref, rtx));
-static void add_location_or_const_value_attribute PARAMS ((dw_die_ref, tree));
-static void add_name_attribute         PARAMS ((dw_die_ref, const char *));
-static void add_bound_info             PARAMS ((dw_die_ref,
-                                                enum dwarf_attribute, tree));
-static void add_subscript_info         PARAMS ((dw_die_ref, tree));
-static void add_byte_size_attribute    PARAMS ((dw_die_ref, tree));
-static void add_bit_offset_attribute   PARAMS ((dw_die_ref, tree));
-static void add_bit_size_attribute     PARAMS ((dw_die_ref, tree));
-static void add_prototyped_attribute   PARAMS ((dw_die_ref, tree));
-static void add_abstract_origin_attribute PARAMS ((dw_die_ref, tree));
-static void add_pure_or_virtual_attribute PARAMS ((dw_die_ref, tree));
-static void add_src_coords_attributes  PARAMS ((dw_die_ref, tree));
-static void add_name_and_src_coords_attributes PARAMS ((dw_die_ref, tree));
-static void push_decl_scope            PARAMS ((tree));
-static dw_die_ref scope_die_for                PARAMS ((tree, dw_die_ref));
-static void pop_decl_scope             PARAMS ((void));
-static void add_type_attribute         PARAMS ((dw_die_ref, tree, int, int,
-                                                dw_die_ref));
-static const char *type_tag            PARAMS ((tree));
-static tree member_declared_type       PARAMS ((tree));
-#if 0
-static const char *decl_start_label    PARAMS ((tree));
-#endif
-static void gen_array_type_die         PARAMS ((tree, dw_die_ref));
-static void gen_set_type_die           PARAMS ((tree, dw_die_ref));
-#if 0
-static void gen_entry_point_die                PARAMS ((tree, dw_die_ref));
-#endif
-static void gen_inlined_enumeration_type_die PARAMS ((tree, dw_die_ref));
-static void gen_inlined_structure_type_die PARAMS ((tree, dw_die_ref));
-static void gen_inlined_union_type_die PARAMS ((tree, dw_die_ref));
-static void gen_enumeration_type_die   PARAMS ((tree, dw_die_ref));
-static dw_die_ref gen_formal_parameter_die PARAMS ((tree, dw_die_ref));
-static void gen_unspecified_parameters_die PARAMS ((tree, dw_die_ref));
-static void gen_formal_types_die       PARAMS ((tree, dw_die_ref));
-static void gen_subprogram_die         PARAMS ((tree, dw_die_ref));
-static void gen_variable_die           PARAMS ((tree, dw_die_ref));
-static void gen_label_die              PARAMS ((tree, dw_die_ref));
-static void gen_lexical_block_die      PARAMS ((tree, dw_die_ref, int));
-static void gen_inlined_subroutine_die PARAMS ((tree, dw_die_ref, int));
-static void gen_field_die              PARAMS ((tree, dw_die_ref));
-static void gen_ptr_to_mbr_type_die    PARAMS ((tree, dw_die_ref));
-static dw_die_ref gen_compile_unit_die PARAMS ((const char *));
-static void gen_string_type_die                PARAMS ((tree, dw_die_ref));
-static void gen_inheritance_die                PARAMS ((tree, dw_die_ref));
-static void gen_member_die             PARAMS ((tree, dw_die_ref));
-static void gen_struct_or_union_type_die PARAMS ((tree, dw_die_ref));
-static void gen_subroutine_type_die    PARAMS ((tree, dw_die_ref));
-static void gen_typedef_die            PARAMS ((tree, dw_die_ref));
-static void gen_type_die               PARAMS ((tree, dw_die_ref));
-static void gen_tagged_type_instantiation_die PARAMS ((tree, dw_die_ref));
-static void gen_block_die              PARAMS ((tree, dw_die_ref, int));
-static void decls_for_scope            PARAMS ((tree, dw_die_ref, int));
-static int is_redundant_typedef                PARAMS ((tree));
-static void gen_decl_die               PARAMS ((tree, dw_die_ref));
-static unsigned lookup_filename                PARAMS ((const char *));
-static void add_incomplete_type                PARAMS ((tree));
-static void retry_incomplete_types     PARAMS ((void));
-static void gen_type_die_for_member    PARAMS ((tree, tree, dw_die_ref));
-static void gen_abstract_function      PARAMS ((tree));
-static rtx save_rtx                    PARAMS ((rtx));
-static void splice_child_die           PARAMS ((dw_die_ref, dw_die_ref));
-static void reverse_die_lists          PARAMS ((dw_die_ref));
-
-/* Section names used to hold DWARF debugging information.  */
-#ifndef DEBUG_INFO_SECTION
-#define DEBUG_INFO_SECTION     ".debug_info"
-#endif
-#ifndef ABBREV_SECTION
-#define ABBREV_SECTION         ".debug_abbrev"
-#endif
-#ifndef ARANGES_SECTION
-#define ARANGES_SECTION                ".debug_aranges"
-#endif
-#ifndef DW_MACINFO_SECTION
-#define DW_MACINFO_SECTION     ".debug_macinfo"
-#endif
-#ifndef DEBUG_LINE_SECTION
-#define DEBUG_LINE_SECTION     ".debug_line"
-#endif
-#ifndef LOC_SECTION
-#define LOC_SECTION            ".debug_loc"
-#endif
-#ifndef PUBNAMES_SECTION
-#define PUBNAMES_SECTION       ".debug_pubnames"
-#endif
-#ifndef STR_SECTION
-#define STR_SECTION            ".debug_str"
-#endif
-
-/* Standard ELF section names for compiled code and data.  */
-#ifndef TEXT_SECTION
-#define TEXT_SECTION           ".text"
-#endif
-#ifndef DATA_SECTION
-#define DATA_SECTION           ".data"
-#endif
-#ifndef BSS_SECTION
-#define BSS_SECTION            ".bss"
-#endif
-
-/* Labels we insert at beginning sections we can reference instead of
-   the section names themselves. */
-
-#ifndef TEXT_SECTION_LABEL
-#define TEXT_SECTION_LABEL      "Ltext"
-#endif
-#ifndef DEBUG_LINE_SECTION_LABEL
-#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
-#endif
-#ifndef DEBUG_INFO_SECTION_LABEL
-#define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
-#endif
-#ifndef ABBREV_SECTION_LABEL
-#define ABBREV_SECTION_LABEL     "Ldebug_abbrev"
-#endif
-
-
-/* Definitions of defaults for formats and names of various special
-   (artificial) labels which may be generated within this file (when the -g
-   options is used and DWARF_DEBUGGING_INFO is in effect.
-   If necessary, these may be overridden from within the tm.h file, but
-   typically, overriding these defaults is unnecessary.  */
-
-static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
-static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
-static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
-static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-#ifndef TEXT_END_LABEL
-#define TEXT_END_LABEL         "Letext"
-#endif
-#ifndef DATA_END_LABEL
-#define DATA_END_LABEL         "Ledata"
-#endif
-#ifndef BSS_END_LABEL
-#define BSS_END_LABEL           "Lebss"
-#endif
-#ifndef INSN_LABEL_FMT
-#define INSN_LABEL_FMT         "LI%u_"
-#endif
-#ifndef BLOCK_BEGIN_LABEL
-#define BLOCK_BEGIN_LABEL      "LBB"
-#endif
-#ifndef BLOCK_END_LABEL
-#define BLOCK_END_LABEL                "LBE"
-#endif
-#ifndef BODY_BEGIN_LABEL
-#define BODY_BEGIN_LABEL       "Lbb"
-#endif
-#ifndef BODY_END_LABEL
-#define BODY_END_LABEL         "Lbe"
-#endif
-#ifndef LINE_CODE_LABEL
-#define LINE_CODE_LABEL                "LM"
-#endif
-#ifndef SEPARATE_LINE_CODE_LABEL
-#define SEPARATE_LINE_CODE_LABEL       "LSM"
-#endif
-\f
-/* We allow a language front-end to designate a function that is to be
-   called to "demangle" any name before it it put into a DIE.  */
-
-static const char *(*demangle_name_func) PARAMS ((const char *));
-
-void
-dwarf2out_set_demangle_name_func (func)
-     const char *(*func) PARAMS ((const char *));
-{
-  demangle_name_func = func;
-}
-\f
-/* Return an rtx like ORIG which lives forever.  If we're doing GC,
-   that means adding it to used_rtx_varray.  If not, that means making
-   a copy on the permanent_obstack.  */
-
-static rtx
-save_rtx (orig)
-     register rtx orig;
-{
-  if (ggc_p)
-    VARRAY_PUSH_RTX (used_rtx_varray, orig);
-  else
-    {
-      push_obstacks_nochange ();
-      end_temporary_allocation ();
-      orig = copy_rtx (orig);
-      pop_obstacks ();
-    }
-
-  return orig;
-}
-
-/* Test if rtl node points to a pseudo register.  */
-
-static inline int
-is_pseudo_reg (rtl)
-     register rtx rtl;
-{
-  return ((GET_CODE (rtl) == REG && REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
-         || (GET_CODE (rtl) == SUBREG
-             && REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER));
-}
-
-/* Return a reference to a type, with its const and volatile qualifiers
-   removed.  */
-
-static inline tree
-type_main_variant (type)
-     register tree type;
-{
-  type = TYPE_MAIN_VARIANT (type);
-
-  /* There really should be only one main variant among any group of variants 
-     of a given type (and all of the MAIN_VARIANT values for all members of
-     the group should point to that one type) but sometimes the C front-end
-     messes this up for array types, so we work around that bug here.  */
-
-  if (TREE_CODE (type) == ARRAY_TYPE)
-    while (type != TYPE_MAIN_VARIANT (type))
-      type = TYPE_MAIN_VARIANT (type);
-
-  return type;
-}
-
-/* Return non-zero if the given type node represents a tagged type.  */
-
-static inline int
-is_tagged_type (type)
-     register tree type;
-{
-  register enum tree_code code = TREE_CODE (type);
-
-  return (code == RECORD_TYPE || code == UNION_TYPE
-         || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
-}
-
-/* Convert a DIE tag into its string name.  */
-
-static const char *
-dwarf_tag_name (tag)
-     register unsigned tag;
-{
-  switch (tag)
-    {
-    case DW_TAG_padding:
-      return "DW_TAG_padding";
-    case DW_TAG_array_type:
-      return "DW_TAG_array_type";
-    case DW_TAG_class_type:
-      return "DW_TAG_class_type";
-    case DW_TAG_entry_point:
-      return "DW_TAG_entry_point";
-    case DW_TAG_enumeration_type:
-      return "DW_TAG_enumeration_type";
-    case DW_TAG_formal_parameter:
-      return "DW_TAG_formal_parameter";
-    case DW_TAG_imported_declaration:
-      return "DW_TAG_imported_declaration";
-    case DW_TAG_label:
-      return "DW_TAG_label";
-    case DW_TAG_lexical_block:
-      return "DW_TAG_lexical_block";
-    case DW_TAG_member:
-      return "DW_TAG_member";
-    case DW_TAG_pointer_type:
-      return "DW_TAG_pointer_type";
-    case DW_TAG_reference_type:
-      return "DW_TAG_reference_type";
-    case DW_TAG_compile_unit:
-      return "DW_TAG_compile_unit";
-    case DW_TAG_string_type:
-      return "DW_TAG_string_type";
-    case DW_TAG_structure_type:
-      return "DW_TAG_structure_type";
-    case DW_TAG_subroutine_type:
-      return "DW_TAG_subroutine_type";
-    case DW_TAG_typedef:
-      return "DW_TAG_typedef";
-    case DW_TAG_union_type:
-      return "DW_TAG_union_type";
-    case DW_TAG_unspecified_parameters:
-      return "DW_TAG_unspecified_parameters";
-    case DW_TAG_variant:
-      return "DW_TAG_variant";
-    case DW_TAG_common_block:
-      return "DW_TAG_common_block";
-    case DW_TAG_common_inclusion:
-      return "DW_TAG_common_inclusion";
-    case DW_TAG_inheritance:
-      return "DW_TAG_inheritance";
-    case DW_TAG_inlined_subroutine:
-      return "DW_TAG_inlined_subroutine";
-    case DW_TAG_module:
-      return "DW_TAG_module";
-    case DW_TAG_ptr_to_member_type:
-      return "DW_TAG_ptr_to_member_type";
-    case DW_TAG_set_type:
-      return "DW_TAG_set_type";
-    case DW_TAG_subrange_type:
-      return "DW_TAG_subrange_type";
-    case DW_TAG_with_stmt:
-      return "DW_TAG_with_stmt";
-    case DW_TAG_access_declaration:
-      return "DW_TAG_access_declaration";
-    case DW_TAG_base_type:
-      return "DW_TAG_base_type";
-    case DW_TAG_catch_block:
-      return "DW_TAG_catch_block";
-    case DW_TAG_const_type:
-      return "DW_TAG_const_type";
-    case DW_TAG_constant:
-      return "DW_TAG_constant";
-    case DW_TAG_enumerator:
-      return "DW_TAG_enumerator";
-    case DW_TAG_file_type:
-      return "DW_TAG_file_type";
-    case DW_TAG_friend:
-      return "DW_TAG_friend";
-    case DW_TAG_namelist:
-      return "DW_TAG_namelist";
-    case DW_TAG_namelist_item:
-      return "DW_TAG_namelist_item";
-    case DW_TAG_packed_type:
-      return "DW_TAG_packed_type";
-    case DW_TAG_subprogram:
-      return "DW_TAG_subprogram";
-    case DW_TAG_template_type_param:
-      return "DW_TAG_template_type_param";
-    case DW_TAG_template_value_param:
-      return "DW_TAG_template_value_param";
-    case DW_TAG_thrown_type:
-      return "DW_TAG_thrown_type";
-    case DW_TAG_try_block:
-      return "DW_TAG_try_block";
-    case DW_TAG_variant_part:
-      return "DW_TAG_variant_part";
-    case DW_TAG_variable:
-      return "DW_TAG_variable";
-    case DW_TAG_volatile_type:
-      return "DW_TAG_volatile_type";
-    case DW_TAG_MIPS_loop:
-      return "DW_TAG_MIPS_loop";
-    case DW_TAG_format_label:
-      return "DW_TAG_format_label";
-    case DW_TAG_function_template:
-      return "DW_TAG_function_template";
-    case DW_TAG_class_template:
-      return "DW_TAG_class_template";
-    default:
-      return "DW_TAG_<unknown>";
-    }
-}
-
-/* Convert a DWARF attribute code into its string name.  */
-
-static const char *
-dwarf_attr_name (attr)
-     register unsigned attr;
-{
-  switch (attr)
-    {
-    case DW_AT_sibling:
-      return "DW_AT_sibling";
-    case DW_AT_location:
-      return "DW_AT_location";
-    case DW_AT_name:
-      return "DW_AT_name";
-    case DW_AT_ordering:
-      return "DW_AT_ordering";
-    case DW_AT_subscr_data:
-      return "DW_AT_subscr_data";
-    case DW_AT_byte_size:
-      return "DW_AT_byte_size";
-    case DW_AT_bit_offset:
-      return "DW_AT_bit_offset";
-    case DW_AT_bit_size:
-      return "DW_AT_bit_size";
-    case DW_AT_element_list:
-      return "DW_AT_element_list";
-    case DW_AT_stmt_list:
-      return "DW_AT_stmt_list";
-    case DW_AT_low_pc:
-      return "DW_AT_low_pc";
-    case DW_AT_high_pc:
-      return "DW_AT_high_pc";
-    case DW_AT_language:
-      return "DW_AT_language";
-    case DW_AT_member:
-      return "DW_AT_member";
-    case DW_AT_discr:
-      return "DW_AT_discr";
-    case DW_AT_discr_value:
-      return "DW_AT_discr_value";
-    case DW_AT_visibility:
-      return "DW_AT_visibility";
-    case DW_AT_import:
-      return "DW_AT_import";
-    case DW_AT_string_length:
-      return "DW_AT_string_length";
-    case DW_AT_common_reference:
-      return "DW_AT_common_reference";
-    case DW_AT_comp_dir:
-      return "DW_AT_comp_dir";
-    case DW_AT_const_value:
-      return "DW_AT_const_value";
-    case DW_AT_containing_type:
-      return "DW_AT_containing_type";
-    case DW_AT_default_value:
-      return "DW_AT_default_value";
-    case DW_AT_inline:
-      return "DW_AT_inline";
-    case DW_AT_is_optional:
-      return "DW_AT_is_optional";
-    case DW_AT_lower_bound:
-      return "DW_AT_lower_bound";
-    case DW_AT_producer:
-      return "DW_AT_producer";
-    case DW_AT_prototyped:
-      return "DW_AT_prototyped";
-    case DW_AT_return_addr:
-      return "DW_AT_return_addr";
-    case DW_AT_start_scope:
-      return "DW_AT_start_scope";
-    case DW_AT_stride_size:
-      return "DW_AT_stride_size";
-    case DW_AT_upper_bound:
-      return "DW_AT_upper_bound";
-    case DW_AT_abstract_origin:
-      return "DW_AT_abstract_origin";
-    case DW_AT_accessibility:
-      return "DW_AT_accessibility";
-    case DW_AT_address_class:
-      return "DW_AT_address_class";
-    case DW_AT_artificial:
-      return "DW_AT_artificial";
-    case DW_AT_base_types:
-      return "DW_AT_base_types";
-    case DW_AT_calling_convention:
-      return "DW_AT_calling_convention";
-    case DW_AT_count:
-      return "DW_AT_count";
-    case DW_AT_data_member_location:
-      return "DW_AT_data_member_location";
-    case DW_AT_decl_column:
-      return "DW_AT_decl_column";
-    case DW_AT_decl_file:
-      return "DW_AT_decl_file";
-    case DW_AT_decl_line:
-      return "DW_AT_decl_line";
-    case DW_AT_declaration:
-      return "DW_AT_declaration";
-    case DW_AT_discr_list:
-      return "DW_AT_discr_list";
-    case DW_AT_encoding:
-      return "DW_AT_encoding";
-    case DW_AT_external:
-      return "DW_AT_external";
-    case DW_AT_frame_base:
-      return "DW_AT_frame_base";
-    case DW_AT_friend:
-      return "DW_AT_friend";
-    case DW_AT_identifier_case:
-      return "DW_AT_identifier_case";
-    case DW_AT_macro_info:
-      return "DW_AT_macro_info";
-    case DW_AT_namelist_items:
-      return "DW_AT_namelist_items";
-    case DW_AT_priority:
-      return "DW_AT_priority";
-    case DW_AT_segment:
-      return "DW_AT_segment";
-    case DW_AT_specification:
-      return "DW_AT_specification";
-    case DW_AT_static_link:
-      return "DW_AT_static_link";
-    case DW_AT_type:
-      return "DW_AT_type";
-    case DW_AT_use_location:
-      return "DW_AT_use_location";
-    case DW_AT_variable_parameter:
-      return "DW_AT_variable_parameter";
-    case DW_AT_virtuality:
-      return "DW_AT_virtuality";
-    case DW_AT_vtable_elem_location:
-      return "DW_AT_vtable_elem_location";
-
-    case DW_AT_MIPS_fde:
-      return "DW_AT_MIPS_fde";
-    case DW_AT_MIPS_loop_begin:
-      return "DW_AT_MIPS_loop_begin";
-    case DW_AT_MIPS_tail_loop_begin:
-      return "DW_AT_MIPS_tail_loop_begin";
-    case DW_AT_MIPS_epilog_begin:
-      return "DW_AT_MIPS_epilog_begin";
-    case DW_AT_MIPS_loop_unroll_factor:
-      return "DW_AT_MIPS_loop_unroll_factor";
-    case DW_AT_MIPS_software_pipeline_depth:
-      return "DW_AT_MIPS_software_pipeline_depth";
-    case DW_AT_MIPS_linkage_name:
-      return "DW_AT_MIPS_linkage_name";
-    case DW_AT_MIPS_stride:
-      return "DW_AT_MIPS_stride";
-    case DW_AT_MIPS_abstract_name:
-      return "DW_AT_MIPS_abstract_name";
-    case DW_AT_MIPS_clone_origin:
-      return "DW_AT_MIPS_clone_origin";
-    case DW_AT_MIPS_has_inlines:
-      return "DW_AT_MIPS_has_inlines";
-
-    case DW_AT_sf_names:
-      return "DW_AT_sf_names";
-    case DW_AT_src_info:
-      return "DW_AT_src_info";
-    case DW_AT_mac_info:
-      return "DW_AT_mac_info";
-    case DW_AT_src_coords:
-      return "DW_AT_src_coords";
-    case DW_AT_body_begin:
-      return "DW_AT_body_begin";
-    case DW_AT_body_end:
-      return "DW_AT_body_end";
-    default:
-      return "DW_AT_<unknown>";
-    }
-}
-
-/* Convert a DWARF value form code into its string name.  */
-
-static const char *
-dwarf_form_name (form)
-     register unsigned form;
-{
-  switch (form)
-    {
-    case DW_FORM_addr:
-      return "DW_FORM_addr";
-    case DW_FORM_block2:
-      return "DW_FORM_block2";
-    case DW_FORM_block4:
-      return "DW_FORM_block4";
-    case DW_FORM_data2:
-      return "DW_FORM_data2";
-    case DW_FORM_data4:
-      return "DW_FORM_data4";
-    case DW_FORM_data8:
-      return "DW_FORM_data8";
-    case DW_FORM_string:
-      return "DW_FORM_string";
-    case DW_FORM_block:
-      return "DW_FORM_block";
-    case DW_FORM_block1:
-      return "DW_FORM_block1";
-    case DW_FORM_data1:
-      return "DW_FORM_data1";
-    case DW_FORM_flag:
-      return "DW_FORM_flag";
-    case DW_FORM_sdata:
-      return "DW_FORM_sdata";
-    case DW_FORM_strp:
-      return "DW_FORM_strp";
-    case DW_FORM_udata:
-      return "DW_FORM_udata";
-    case DW_FORM_ref_addr:
-      return "DW_FORM_ref_addr";
-    case DW_FORM_ref1:
-      return "DW_FORM_ref1";
-    case DW_FORM_ref2:
-      return "DW_FORM_ref2";
-    case DW_FORM_ref4:
-      return "DW_FORM_ref4";
-    case DW_FORM_ref8:
-      return "DW_FORM_ref8";
-    case DW_FORM_ref_udata:
-      return "DW_FORM_ref_udata";
-    case DW_FORM_indirect:
-      return "DW_FORM_indirect";
-    default:
-      return "DW_FORM_<unknown>";
-    }
-}
-
-/* Convert a DWARF stack opcode into its string name.  */
-
-static const char *
-dwarf_stack_op_name (op)
-     register unsigned op;
+static const char *
+dwarf_stack_op_name (op)
+     register unsigned op;
 {
   switch (op)
     {
@@ -3288,85 +2414,1633 @@ dwarf_stack_op_name (op)
     case DW_OP_reg31:
       return "DW_OP_reg31";
     case DW_OP_breg0:
-      return "DW_OP_breg0";
+      return "DW_OP_breg0";
+    case DW_OP_breg1:
+      return "DW_OP_breg1";
+    case DW_OP_breg2:
+      return "DW_OP_breg2";
+    case DW_OP_breg3:
+      return "DW_OP_breg3";
+    case DW_OP_breg4:
+      return "DW_OP_breg4";
+    case DW_OP_breg5:
+      return "DW_OP_breg5";
+    case DW_OP_breg6:
+      return "DW_OP_breg6";
+    case DW_OP_breg7:
+      return "DW_OP_breg7";
+    case DW_OP_breg8:
+      return "DW_OP_breg8";
+    case DW_OP_breg9:
+      return "DW_OP_breg9";
+    case DW_OP_breg10:
+      return "DW_OP_breg10";
+    case DW_OP_breg11:
+      return "DW_OP_breg11";
+    case DW_OP_breg12:
+      return "DW_OP_breg12";
+    case DW_OP_breg13:
+      return "DW_OP_breg13";
+    case DW_OP_breg14:
+      return "DW_OP_breg14";
+    case DW_OP_breg15:
+      return "DW_OP_breg15";
+    case DW_OP_breg16:
+      return "DW_OP_breg16";
+    case DW_OP_breg17:
+      return "DW_OP_breg17";
+    case DW_OP_breg18:
+      return "DW_OP_breg18";
+    case DW_OP_breg19:
+      return "DW_OP_breg19";
+    case DW_OP_breg20:
+      return "DW_OP_breg20";
+    case DW_OP_breg21:
+      return "DW_OP_breg21";
+    case DW_OP_breg22:
+      return "DW_OP_breg22";
+    case DW_OP_breg23:
+      return "DW_OP_breg23";
+    case DW_OP_breg24:
+      return "DW_OP_breg24";
+    case DW_OP_breg25:
+      return "DW_OP_breg25";
+    case DW_OP_breg26:
+      return "DW_OP_breg26";
+    case DW_OP_breg27:
+      return "DW_OP_breg27";
+    case DW_OP_breg28:
+      return "DW_OP_breg28";
+    case DW_OP_breg29:
+      return "DW_OP_breg29";
+    case DW_OP_breg30:
+      return "DW_OP_breg30";
+    case DW_OP_breg31:
+      return "DW_OP_breg31";
+    case DW_OP_regx:
+      return "DW_OP_regx";
+    case DW_OP_fbreg:
+      return "DW_OP_fbreg";
+    case DW_OP_bregx:
+      return "DW_OP_bregx";
+    case DW_OP_piece:
+      return "DW_OP_piece";
+    case DW_OP_deref_size:
+      return "DW_OP_deref_size";
+    case DW_OP_xderef_size:
+      return "DW_OP_xderef_size";
+    case DW_OP_nop:
+      return "DW_OP_nop";
+    default:
+      return "OP_<unknown>";
+    }
+}
+
+/* Return a pointer to a newly allocated location description.  Location
+   descriptions are simple expression terms that can be strung
+   together to form more complicated location (address) descriptions.  */
+
+static inline dw_loc_descr_ref
+new_loc_descr (op, oprnd1, oprnd2)
+     register enum dwarf_location_atom op;
+     register unsigned long oprnd1;
+     register unsigned long oprnd2;
+{
+  /* Use xcalloc here so we clear out all of the long_long constant in
+     the union.  */
+  register dw_loc_descr_ref descr
+    = (dw_loc_descr_ref) xcalloc (1, sizeof (dw_loc_descr_node));
+
+  descr->dw_loc_opc = op;
+  descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
+  descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
+  descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
+  descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
+
+  return descr;
+}
+
+/* Add a location description term to a location description expression.  */
+
+static inline void
+add_loc_descr (list_head, descr)
+     register dw_loc_descr_ref *list_head;
+     register dw_loc_descr_ref descr;
+{
+  register dw_loc_descr_ref *d;
+
+  /* Find the end of the chain.  */
+  for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
+    ;
+
+  *d = descr;
+}
+
+/* Return the size of a location descriptor.  */
+
+static unsigned long
+size_of_loc_descr (loc)
+     register dw_loc_descr_ref loc;
+{
+  register unsigned long size = 1;
+
+  switch (loc->dw_loc_opc)
+    {
+    case DW_OP_addr:
+      size += DWARF2_ADDR_SIZE;
+      break;
+    case DW_OP_const1u:
+    case DW_OP_const1s:
+      size += 1;
+      break;
+    case DW_OP_const2u:
+    case DW_OP_const2s:
+      size += 2;
+      break;
+    case DW_OP_const4u:
+    case DW_OP_const4s:
+      size += 4;
+      break;
+    case DW_OP_const8u:
+    case DW_OP_const8s:
+      size += 8;
+      break;
+    case DW_OP_constu:
+      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+      break;
+    case DW_OP_consts:
+      size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
+      break;
+    case DW_OP_pick:
+      size += 1;
+      break;
+    case DW_OP_plus_uconst:
+      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+      break;
+    case DW_OP_skip:
+    case DW_OP_bra:
+      size += 2;
+      break;
+    case DW_OP_breg0:
+    case DW_OP_breg1:
+    case DW_OP_breg2:
+    case DW_OP_breg3:
+    case DW_OP_breg4:
+    case DW_OP_breg5:
+    case DW_OP_breg6:
+    case DW_OP_breg7:
+    case DW_OP_breg8:
+    case DW_OP_breg9:
+    case DW_OP_breg10:
+    case DW_OP_breg11:
+    case DW_OP_breg12:
+    case DW_OP_breg13:
+    case DW_OP_breg14:
+    case DW_OP_breg15:
+    case DW_OP_breg16:
+    case DW_OP_breg17:
+    case DW_OP_breg18:
+    case DW_OP_breg19:
+    case DW_OP_breg20:
+    case DW_OP_breg21:
+    case DW_OP_breg22:
+    case DW_OP_breg23:
+    case DW_OP_breg24:
+    case DW_OP_breg25:
+    case DW_OP_breg26:
+    case DW_OP_breg27:
+    case DW_OP_breg28:
+    case DW_OP_breg29:
+    case DW_OP_breg30:
+    case DW_OP_breg31:
+      size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
+      break;
+    case DW_OP_regx:
+      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+      break;
+    case DW_OP_fbreg:
+      size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
+      break;
+    case DW_OP_bregx:
+      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+      size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
+      break;
+    case DW_OP_piece:
+      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
+      break;
+    case DW_OP_deref_size:
+    case DW_OP_xderef_size:
+      size += 1;
+      break;
+    default:
+      break;
+    }
+
+  return size;
+}
+
+/* Return the size of a series of location descriptors.  */
+
+static unsigned long
+size_of_locs (loc)
+     register dw_loc_descr_ref loc;
+{
+  register unsigned long size = 0;
+
+  for (; loc != NULL; loc = loc->dw_loc_next)
+    {
+      loc->dw_loc_addr = size;
+      size += size_of_loc_descr (loc);
+    }
+
+  return size;
+}
+
+/* Output location description stack opcode's operands (if any).  */
+
+static void
+output_loc_operands (loc)
+     register dw_loc_descr_ref loc;
+{
+  register dw_val_ref val1 = &loc->dw_loc_oprnd1;
+  register dw_val_ref val2 = &loc->dw_loc_oprnd2;
+
+  switch (loc->dw_loc_opc)
+    {
+#ifdef DWARF2_DEBUGGING_INFO
+    case DW_OP_addr:
+      ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, val1->v.val_addr);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_const2u:
+    case DW_OP_const2s:
+      ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_const4u:
+    case DW_OP_const4s:
+      ASM_OUTPUT_DWARF_DATA4 (asm_out_file, val1->v.val_int);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_const8u:
+    case DW_OP_const8s:
+      abort ();
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_skip:
+    case DW_OP_bra:
+      {
+       int offset;
+
+       if (val1->val_class == dw_val_class_loc)
+         offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
+       else
+         abort ();
+
+       ASM_OUTPUT_DWARF_DATA2 (asm_out_file, offset);
+       fputc ('\n', asm_out_file);
+      }
+      break;
+#else
+    case DW_OP_addr:
+    case DW_OP_const2u:
+    case DW_OP_const2s:
+    case DW_OP_const4u:
+    case DW_OP_const4s:
+    case DW_OP_const8u:
+    case DW_OP_const8s:
+    case DW_OP_skip:
+    case DW_OP_bra:
+      /* We currently don't make any attempt to make sure these are
+         aligned properly like we do for the main unwind info, so
+         don't support emitting things larger than a byte if we're
+         only doing unwinding.  */
+      abort ();
+#endif
+    case DW_OP_const1u:
+    case DW_OP_const1s:
+      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_constu:
+      output_uleb128 (val1->v.val_unsigned);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_consts:
+      output_sleb128 (val1->v.val_int);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_pick:
+      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_int);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_plus_uconst:
+      output_uleb128 (val1->v.val_unsigned);
+      fputc ('\n', asm_out_file);
+      break;
+    case DW_OP_breg0:
     case DW_OP_breg1:
-      return "DW_OP_breg1";
     case DW_OP_breg2:
-      return "DW_OP_breg2";
     case DW_OP_breg3:
-      return "DW_OP_breg3";
     case DW_OP_breg4:
-      return "DW_OP_breg4";
     case DW_OP_breg5:
-      return "DW_OP_breg5";
     case DW_OP_breg6:
-      return "DW_OP_breg6";
     case DW_OP_breg7:
-      return "DW_OP_breg7";
     case DW_OP_breg8:
-      return "DW_OP_breg8";
     case DW_OP_breg9:
-      return "DW_OP_breg9";
     case DW_OP_breg10:
-      return "DW_OP_breg10";
     case DW_OP_breg11:
-      return "DW_OP_breg11";
     case DW_OP_breg12:
-      return "DW_OP_breg12";
     case DW_OP_breg13:
-      return "DW_OP_breg13";
     case DW_OP_breg14:
-      return "DW_OP_breg14";
     case DW_OP_breg15:
-      return "DW_OP_breg15";
     case DW_OP_breg16:
-      return "DW_OP_breg16";
     case DW_OP_breg17:
-      return "DW_OP_breg17";
     case DW_OP_breg18:
-      return "DW_OP_breg18";
     case DW_OP_breg19:
-      return "DW_OP_breg19";
     case DW_OP_breg20:
-      return "DW_OP_breg20";
     case DW_OP_breg21:
-      return "DW_OP_breg21";
     case DW_OP_breg22:
-      return "DW_OP_breg22";
     case DW_OP_breg23:
-      return "DW_OP_breg23";
     case DW_OP_breg24:
-      return "DW_OP_breg24";
     case DW_OP_breg25:
-      return "DW_OP_breg25";
     case DW_OP_breg26:
-      return "DW_OP_breg26";
     case DW_OP_breg27:
-      return "DW_OP_breg27";
     case DW_OP_breg28:
-      return "DW_OP_breg28";
     case DW_OP_breg29:
-      return "DW_OP_breg29";
     case DW_OP_breg30:
-      return "DW_OP_breg30";
     case DW_OP_breg31:
-      return "DW_OP_breg31";
+      output_sleb128 (val1->v.val_int);
+      fputc ('\n', asm_out_file);
+      break;
     case DW_OP_regx:
-      return "DW_OP_regx";
+      output_uleb128 (val1->v.val_unsigned);
+      fputc ('\n', asm_out_file);
+      break;
     case DW_OP_fbreg:
-      return "DW_OP_fbreg";
+      output_sleb128 (val1->v.val_int);
+      fputc ('\n', asm_out_file);
+      break;
     case DW_OP_bregx:
-      return "DW_OP_bregx";
+      output_uleb128 (val1->v.val_unsigned);
+      fputc ('\n', asm_out_file);
+      output_sleb128 (val2->v.val_int);
+      fputc ('\n', asm_out_file);
+      break;
     case DW_OP_piece:
-      return "DW_OP_piece";
+      output_uleb128 (val1->v.val_unsigned);
+      fputc ('\n', asm_out_file);
+      break;
     case DW_OP_deref_size:
-      return "DW_OP_deref_size";
     case DW_OP_xderef_size:
-      return "DW_OP_xderef_size";
-    case DW_OP_nop:
-      return "DW_OP_nop";
+      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag);
+      fputc ('\n', asm_out_file);
+      break;
+    default:
+      /* Other codes have no operands.  */
+      break;
+    }
+}
+
+/* Output a sequence of location operations.  */
+
+static void
+output_loc_sequence (loc)
+     dw_loc_descr_ref loc;
+{
+  for (; loc != NULL; loc = loc->dw_loc_next)
+    {
+      /* Output the opcode.  */
+      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, loc->dw_loc_opc);
+      if (flag_debug_asm)
+       fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START,
+                dwarf_stack_op_name (loc->dw_loc_opc));
+
+      fputc ('\n', asm_out_file);
+
+      /* Output the operand(s) (if any).  */
+      output_loc_operands (loc);
+    }
+}
+
+/* This routine will generate the correct assembly data for a location
+   description based on a cfi entry with a complex address.  */
+
+static void
+output_cfa_loc (cfi)
+     dw_cfi_ref cfi;
+{
+  dw_loc_descr_ref loc;
+  unsigned long size;
+
+  /* Output the size of the block.  */
+  loc = cfi->dw_cfi_oprnd1.dw_cfi_loc;
+  size = size_of_locs (loc);
+  output_uleb128 (size);
+  fputc ('\n', asm_out_file);
+
+  /* Now output the operations themselves.  */
+  output_loc_sequence (loc);
+}
+
+/* This function builds a dwarf location descriptor seqeunce from
+   a dw_cfa_location.  */
+
+static struct dw_loc_descr_struct *
+build_cfa_loc (cfa)
+     dw_cfa_location *cfa;
+{
+  struct dw_loc_descr_struct *head, *tmp;
+
+  if (cfa->indirect == 0)
+    abort ();
+
+  if (cfa->base_offset)
+    {
+      if (cfa->reg <= 31)
+       head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->base_offset, 0);
+      else
+       head = new_loc_descr (DW_OP_bregx, cfa->reg, cfa->base_offset);
+    }
+  else if (cfa->reg <= 31)
+    head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
+  else
+    head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
+  head->dw_loc_oprnd1.val_class = dw_val_class_const;
+  tmp = new_loc_descr (DW_OP_deref, 0, 0);
+  add_loc_descr (&head, tmp);
+  if (cfa->offset != 0)
+    {
+      tmp = new_loc_descr (DW_OP_plus_uconst, cfa->offset, 0);
+      add_loc_descr (&head, tmp);
+    }
+  return head;
+}
+
+/* This function fills in aa dw_cfa_location structure from a
+   dwarf location descriptor sequence.  */
+
+static void
+get_cfa_from_loc_descr (cfa, loc)
+     dw_cfa_location *cfa;
+     struct dw_loc_descr_struct *loc;
+{
+  struct dw_loc_descr_struct *ptr;
+  cfa->offset = 0;
+  cfa->base_offset = 0;
+  cfa->indirect = 0;
+  cfa->reg = -1;
+
+  for (ptr = loc; ptr != NULL; ptr = ptr->dw_loc_next)
+    {
+      enum dwarf_location_atom op = ptr->dw_loc_opc;
+      switch (op)
+       {
+       case DW_OP_reg0:
+       case DW_OP_reg1:
+       case DW_OP_reg2:
+       case DW_OP_reg3:
+       case DW_OP_reg4:
+       case DW_OP_reg5:
+       case DW_OP_reg6:
+       case DW_OP_reg7:
+       case DW_OP_reg8:
+       case DW_OP_reg9:
+       case DW_OP_reg10:
+       case DW_OP_reg11:
+       case DW_OP_reg12:
+       case DW_OP_reg13:
+       case DW_OP_reg14:
+       case DW_OP_reg15:
+       case DW_OP_reg16:
+       case DW_OP_reg17:
+       case DW_OP_reg18:
+       case DW_OP_reg19:
+       case DW_OP_reg20:
+       case DW_OP_reg21:
+       case DW_OP_reg22:
+       case DW_OP_reg23:
+       case DW_OP_reg24:
+       case DW_OP_reg25:
+       case DW_OP_reg26:
+       case DW_OP_reg27:
+       case DW_OP_reg28:
+       case DW_OP_reg29:
+       case DW_OP_reg30:
+       case DW_OP_reg31:
+         cfa->reg = op - DW_OP_reg0;
+         break;
+       case DW_OP_regx:
+         cfa->reg = ptr->dw_loc_oprnd1.v.val_int;
+         break;
+       case DW_OP_breg0:
+       case DW_OP_breg1:
+       case DW_OP_breg2:
+       case DW_OP_breg3:
+       case DW_OP_breg4:
+       case DW_OP_breg5:
+       case DW_OP_breg6:
+       case DW_OP_breg7:
+       case DW_OP_breg8:
+       case DW_OP_breg9:
+       case DW_OP_breg10:
+       case DW_OP_breg11:
+       case DW_OP_breg12:
+       case DW_OP_breg13:
+       case DW_OP_breg14:
+       case DW_OP_breg15:
+       case DW_OP_breg16:
+       case DW_OP_breg17:
+       case DW_OP_breg18:
+       case DW_OP_breg19:
+       case DW_OP_breg20:
+       case DW_OP_breg21:
+       case DW_OP_breg22:
+       case DW_OP_breg23:
+       case DW_OP_breg24:
+       case DW_OP_breg25:
+       case DW_OP_breg26:
+       case DW_OP_breg27:
+       case DW_OP_breg28:
+       case DW_OP_breg29:
+       case DW_OP_breg30:
+       case DW_OP_breg31:
+         cfa->reg = op - DW_OP_breg0;
+         cfa->base_offset = ptr->dw_loc_oprnd1.v.val_int;
+         break;
+       case DW_OP_bregx:
+         cfa->reg = ptr->dw_loc_oprnd1.v.val_int;
+         cfa->base_offset = ptr->dw_loc_oprnd2.v.val_int;
+         break;
+       case DW_OP_deref:
+         cfa->indirect = 1;
+         break;
+       case DW_OP_plus_uconst:
+         cfa->offset = ptr->dw_loc_oprnd1.v.val_unsigned;
+         break;
+       default:
+         fatal ("DW_LOC_OP %s not implememnted yet.\n",
+                dwarf_stack_op_name (ptr->dw_loc_opc));
+       }
+    }
+}
+#endif /* .debug_frame support */
+\f
+/* And now, the support for symbolic debugging information.  */
+#ifdef DWARF2_DEBUGGING_INFO
+
+/* NOTE: In the comments in this file, many references are made to
+   "Debugging Information Entries".  This term is abbreviated as `DIE'
+   throughout the remainder of this file.  */
+
+/* An internal representation of the DWARF output is built, and then
+   walked to generate the DWARF debugging info.  The walk of the internal
+   representation is done after the entire program has been compiled.
+   The types below are used to describe the internal representation.  */
+
+/* Various DIE's use offsets relative to the beginning of the
+   .debug_info section to refer to each other.  */
+
+typedef long int dw_offset;
+
+/* Define typedefs here to avoid circular dependencies.  */
+
+typedef struct dw_attr_struct *dw_attr_ref;
+typedef struct dw_line_info_struct *dw_line_info_ref;
+typedef struct dw_separate_line_info_struct *dw_separate_line_info_ref;
+typedef struct pubname_struct *pubname_ref;
+typedef dw_die_ref *arange_ref;
+
+/* Each entry in the line_info_table maintains the file and
+   line number associated with the label generated for that
+   entry.  The label gives the PC value associated with
+   the line number entry.  */
+
+typedef struct dw_line_info_struct
+{
+  unsigned long dw_file_num;
+  unsigned long dw_line_num;
+}
+dw_line_info_entry;
+
+/* Line information for functions in separate sections; each one gets its
+   own sequence.  */
+typedef struct dw_separate_line_info_struct
+{
+  unsigned long dw_file_num;
+  unsigned long dw_line_num;
+  unsigned long function;
+}
+dw_separate_line_info_entry;
+
+/* Each DIE attribute has a field specifying the attribute kind,
+   a link to the next attribute in the chain, and an attribute value.
+   Attributes are typically linked below the DIE they modify.  */
+
+typedef struct dw_attr_struct
+{
+  enum dwarf_attribute dw_attr;
+  dw_attr_ref dw_attr_next;
+  dw_val_node dw_attr_val;
+}
+dw_attr_node;
+
+/* The Debugging Information Entry (DIE) structure */
+
+typedef struct die_struct
+{
+  enum dwarf_tag die_tag;
+  char *die_symbol;
+  dw_attr_ref die_attr;
+  dw_die_ref die_parent;
+  dw_die_ref die_child;
+  dw_die_ref die_sib;
+  dw_offset die_offset;
+  unsigned long die_abbrev;
+  int die_mark;
+}
+die_node;
+
+/* The pubname structure */
+
+typedef struct pubname_struct
+{
+  dw_die_ref die;
+  char *name;
+}
+pubname_entry;
+
+/* The limbo die list structure.  */
+typedef struct limbo_die_struct
+{
+  dw_die_ref die;
+  struct limbo_die_struct *next;
+}
+limbo_die_node;
+
+/* How to start an assembler comment.  */
+#ifndef ASM_COMMENT_START
+#define ASM_COMMENT_START ";#"
+#endif
+
+/* Define a macro which returns non-zero for a TYPE_DECL which was
+   implicitly generated for a tagged type.
+
+   Note that unlike the gcc front end (which generates a NULL named
+   TYPE_DECL node for each complete tagged type, each array type, and
+   each function type node created) the g++ front end generates a
+   _named_ TYPE_DECL node for each tagged type node created.
+   These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
+   generate a DW_TAG_typedef DIE for them.  */
+
+#define TYPE_DECL_IS_STUB(decl)                                \
+  (DECL_NAME (decl) == NULL_TREE                       \
+   || (DECL_ARTIFICIAL (decl)                          \
+       && is_tagged_type (TREE_TYPE (decl))            \
+       && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
+          /* This is necessary for stub decls that     \
+             appear in nested inline functions.  */    \
+          || (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
+              && (decl_ultimate_origin (decl)          \
+                  == TYPE_STUB_DECL (TREE_TYPE (decl)))))))
+
+/* Information concerning the compilation unit's programming
+   language, and compiler version.  */
+
+extern int flag_traditional;
+
+/* Fixed size portion of the DWARF compilation unit header.  */
+#define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
+
+/* Fixed size portion of debugging line information prolog.  */
+#define DWARF_LINE_PROLOG_HEADER_SIZE 5
+
+/* Fixed size portion of public names info.  */
+#define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
+
+/* Fixed size portion of the address range info.  */
+#define DWARF_ARANGES_HEADER_SIZE                                      \
+  (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2)       \
+   - DWARF_OFFSET_SIZE)
+
+/* Size of padding portion in the address range info.  It must be
+   aligned to twice the pointer size.  */
+#define DWARF_ARANGES_PAD_SIZE \
+  (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
+   - (2 * DWARF_OFFSET_SIZE + 4))
+
+/* Use assembler line directives if available.  */
+#ifndef DWARF2_ASM_LINE_DEBUG_INFO
+#ifdef HAVE_AS_DWARF2_DEBUG_LINE
+#define DWARF2_ASM_LINE_DEBUG_INFO 1
+#else
+#define DWARF2_ASM_LINE_DEBUG_INFO 0
+#endif
+#endif
+
+/* Define the architecture-dependent minimum instruction length (in bytes).
+   In this implementation of DWARF, this field is used for information
+   purposes only.  Since GCC generates assembly language, we have
+   no a priori knowledge of how many instruction bytes are generated
+   for each source line, and therefore can use only the  DW_LNE_set_address
+   and DW_LNS_fixed_advance_pc line information commands.  */
+
+#ifndef DWARF_LINE_MIN_INSTR_LENGTH
+#define DWARF_LINE_MIN_INSTR_LENGTH 4
+#endif
+
+/* Minimum line offset in a special line info. opcode.
+   This value was chosen to give a reasonable range of values.  */
+#define DWARF_LINE_BASE  -10
+
+/* First special line opcde - leave room for the standard opcodes.  */
+#define DWARF_LINE_OPCODE_BASE  10
+
+/* Range of line offsets in a special line info. opcode.  */
+#define DWARF_LINE_RANGE  (254-DWARF_LINE_OPCODE_BASE+1)
+
+/* Flag that indicates the initial value of the is_stmt_start flag.
+   In the present implementation, we do not mark any lines as
+   the beginning of a source statement, because that information
+   is not made available by the GCC front-end.  */
+#define        DWARF_LINE_DEFAULT_IS_STMT_START 1
+
+/* This location is used by calc_die_sizes() to keep track
+   the offset of each DIE within the .debug_info section.  */
+static unsigned long next_die_offset;
+
+/* Record the root of the DIE's built for the current compilation unit.  */
+static dw_die_ref comp_unit_die;
+
+/* A list of DIEs with a NULL parent waiting to be relocated.  */
+static limbo_die_node *limbo_die_list = 0;
+
+/* Structure used by lookup_filename to manage sets of filenames.  */
+struct file_table
+{
+  char **table;
+  unsigned allocated;
+  unsigned in_use;
+  unsigned last_lookup_index;
+};
+
+/* Size (in elements) of increments by which we may expand the filename
+   table.  */
+#define FILE_TABLE_INCREMENT 64
+
+/* Filenames referenced by declarations this compilation unit.  */
+static struct file_table decl_file_table;
+
+/* Filenames referenced by line numbers in this compilation unit.  */
+static struct file_table line_file_table;
+
+/* Local pointer to the name of the main input file.  Initialized in
+   dwarf2out_init.  */
+static const char *primary_filename;
+
+/* A pointer to the base of a table of references to DIE's that describe
+   declarations.  The table is indexed by DECL_UID() which is a unique
+   number identifying each decl.  */
+static dw_die_ref *decl_die_table;
+
+/* Number of elements currently allocated for the decl_die_table.  */
+static unsigned decl_die_table_allocated;
+
+/* Number of elements in decl_die_table currently in use.  */
+static unsigned decl_die_table_in_use;
+
+/* Size (in elements) of increments by which we may expand the
+   decl_die_table.  */
+#define DECL_DIE_TABLE_INCREMENT 256
+
+/* A pointer to the base of a table of references to declaration
+   scopes.  This table is a display which tracks the nesting
+   of declaration scopes at the current scope and containing
+   scopes.  This table is used to find the proper place to
+   define type declaration DIE's.  */
+static tree *decl_scope_table;
+
+/* Number of elements currently allocated for the decl_scope_table.  */
+static int decl_scope_table_allocated;
+
+/* Current level of nesting of declaration scopes.  */
+static int decl_scope_depth;
+
+/* Size (in elements) of increments by which we may expand the
+   decl_scope_table.  */
+#define DECL_SCOPE_TABLE_INCREMENT 64
+
+/* A pointer to the base of a list of references to DIE's that
+   are uniquely identified by their tag, presence/absence of
+   children DIE's, and list of attribute/value pairs.  */
+static dw_die_ref *abbrev_die_table;
+
+/* Number of elements currently allocated for abbrev_die_table.  */
+static unsigned abbrev_die_table_allocated;
+
+/* Number of elements in type_die_table currently in use.  */
+static unsigned abbrev_die_table_in_use;
+
+/* Size (in elements) of increments by which we may expand the
+   abbrev_die_table.  */
+#define ABBREV_DIE_TABLE_INCREMENT 256
+
+/* A pointer to the base of a table that contains line information
+   for each source code line in .text in the compilation unit.  */
+static dw_line_info_ref line_info_table;
+
+/* Number of elements currently allocated for line_info_table.  */
+static unsigned line_info_table_allocated;
+
+/* Number of elements in separate_line_info_table currently in use.  */
+static unsigned separate_line_info_table_in_use;
+
+/* A pointer to the base of a table that contains line information
+   for each source code line outside of .text in the compilation unit.  */
+static dw_separate_line_info_ref separate_line_info_table;
+
+/* Number of elements currently allocated for separate_line_info_table.  */
+static unsigned separate_line_info_table_allocated;
+
+/* Number of elements in line_info_table currently in use.  */
+static unsigned line_info_table_in_use;
+
+/* Size (in elements) of increments by which we may expand the
+   line_info_table.  */
+#define LINE_INFO_TABLE_INCREMENT 1024
+
+/* A pointer to the base of a table that contains a list of publicly
+   accessible names.  */
+static pubname_ref pubname_table;
+
+/* Number of elements currently allocated for pubname_table.  */
+static unsigned pubname_table_allocated;
+
+/* Number of elements in pubname_table currently in use.  */
+static unsigned pubname_table_in_use;
+
+/* Size (in elements) of increments by which we may expand the
+   pubname_table.  */
+#define PUBNAME_TABLE_INCREMENT 64
+
+/* A pointer to the base of a table that contains a list of publicly
+   accessible names.  */
+static arange_ref arange_table;
+
+/* Number of elements currently allocated for arange_table.  */
+static unsigned arange_table_allocated;
+
+/* Number of elements in arange_table currently in use.  */
+static unsigned arange_table_in_use;
+
+/* Size (in elements) of increments by which we may expand the
+   arange_table.  */
+#define ARANGE_TABLE_INCREMENT 64
+
+/* A pointer to the base of a list of incomplete types which might be
+   completed at some later time.  */
+
+static tree *incomplete_types_list;
+
+/* Number of elements currently allocated for the incomplete_types_list.  */
+static unsigned incomplete_types_allocated;
+
+/* Number of elements of incomplete_types_list currently in use.  */
+static unsigned incomplete_types;
+
+/* Size (in elements) of increments by which we may expand the incomplete
+   types list.  Actually, a single hunk of space of this size should
+   be enough for most typical programs.         */
+#define INCOMPLETE_TYPES_INCREMENT 64
+
+/* Record whether the function being analyzed contains inlined functions.  */
+static int current_function_has_inlines;
+#if 0 && defined (MIPS_DEBUGGING_INFO)
+static int comp_unit_has_inlines;
+#endif
+
+/* Array of RTXes referenced by the debugging information, which therefore
+   must be kept around forever.  We do this rather than perform GC on
+   the dwarf info because almost all of the dwarf info lives forever, and
+   it's easier to support non-GC frontends this way.  */
+static varray_type used_rtx_varray;
+
+/* Forward declarations for functions defined in this file.  */
+
+static int is_pseudo_reg               PARAMS ((rtx));
+static tree type_main_variant          PARAMS ((tree));
+static int is_tagged_type              PARAMS ((tree));
+static const char *dwarf_tag_name      PARAMS ((unsigned));
+static const char *dwarf_attr_name     PARAMS ((unsigned));
+static const char *dwarf_form_name     PARAMS ((unsigned));
+#if 0
+static const char *dwarf_type_encoding_name PARAMS ((unsigned));
+#endif
+static tree decl_ultimate_origin       PARAMS ((tree));
+static tree block_ultimate_origin      PARAMS ((tree));
+static tree decl_class_context         PARAMS ((tree));
+static void add_dwarf_attr             PARAMS ((dw_die_ref, dw_attr_ref));
+static void add_AT_flag                        PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                unsigned));
+static void add_AT_int                 PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute, long));
+static void add_AT_unsigned            PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                unsigned long));
+static void add_AT_long_long           PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                unsigned long,
+                                                unsigned long));
+static void add_AT_float               PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                unsigned, long *));
+static void add_AT_string              PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                const char *));
+static void add_AT_die_ref             PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                dw_die_ref));
+static void add_AT_fde_ref             PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                unsigned));
+static void add_AT_loc                 PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                dw_loc_descr_ref));
+static void add_AT_addr                        PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                rtx));
+static void add_AT_lbl_id              PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                const char *));
+static void add_AT_lbl_offset          PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute,
+                                                const char *));
+static dw_attr_ref get_AT              PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute));
+static const char *get_AT_low_pc       PARAMS ((dw_die_ref));
+static const char *get_AT_hi_pc                PARAMS ((dw_die_ref));
+static const char *get_AT_string       PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute));
+static int get_AT_flag                 PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute));
+static unsigned get_AT_unsigned                PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute));
+static inline dw_die_ref get_AT_ref    PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute));
+static int is_c_family                 PARAMS ((void));
+static int is_java                     PARAMS ((void));
+static int is_fortran                  PARAMS ((void));
+static void remove_AT                  PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute));
+static void remove_children            PARAMS ((dw_die_ref));
+static void add_child_die              PARAMS ((dw_die_ref, dw_die_ref));
+static dw_die_ref new_die              PARAMS ((enum dwarf_tag, dw_die_ref));
+static dw_die_ref lookup_type_die      PARAMS ((tree));
+static void equate_type_number_to_die  PARAMS ((tree, dw_die_ref));
+static dw_die_ref lookup_decl_die      PARAMS ((tree));
+static void equate_decl_number_to_die  PARAMS ((tree, dw_die_ref));
+static void print_spaces               PARAMS ((FILE *));
+static void print_die                  PARAMS ((dw_die_ref, FILE *));
+static void print_dwarf_line_table     PARAMS ((FILE *));
+static void reverse_die_lists          PARAMS ((dw_die_ref));
+static void reverse_all_dies           PARAMS ((dw_die_ref));
+static dw_die_ref push_new_compile_unit PARAMS ((dw_die_ref, dw_die_ref));
+static dw_die_ref pop_compile_unit     PARAMS ((dw_die_ref));
+static void loc_checksum        PARAMS ((dw_loc_descr_ref, struct md5_ctx *));
+static void attr_checksum            PARAMS ((dw_attr_ref, struct md5_ctx *));
+static void die_checksum              PARAMS ((dw_die_ref, struct md5_ctx *));
+static void compute_section_prefix     PARAMS ((dw_die_ref));
+static int is_type_die                 PARAMS ((dw_die_ref));
+static int is_comdat_die               PARAMS ((dw_die_ref));
+static int is_symbol_die               PARAMS ((dw_die_ref));
+static char *gen_internal_sym          PARAMS ((void));
+static void assign_symbol_names                PARAMS ((dw_die_ref));
+static void break_out_includes         PARAMS ((dw_die_ref));
+static void add_sibling_attributes     PARAMS ((dw_die_ref));
+static void build_abbrev_table         PARAMS ((dw_die_ref));
+static unsigned long size_of_string    PARAMS ((const char *));
+static int constant_size               PARAMS ((long unsigned));
+static unsigned long size_of_die       PARAMS ((dw_die_ref));
+static void calc_die_sizes             PARAMS ((dw_die_ref));
+static void mark_dies                  PARAMS ((dw_die_ref));
+static void unmark_dies                        PARAMS ((dw_die_ref));
+static unsigned long size_of_line_prolog PARAMS ((void));
+static unsigned long size_of_pubnames  PARAMS ((void));
+static unsigned long size_of_aranges   PARAMS ((void));
+static enum dwarf_form value_format    PARAMS ((dw_attr_ref));
+static void output_value_format                PARAMS ((dw_attr_ref));
+static void output_abbrev_section      PARAMS ((void));
+static void output_die_symbol          PARAMS ((dw_die_ref));
+static void output_symbolic_ref                PARAMS ((dw_die_ref));
+static void output_die                 PARAMS ((dw_die_ref));
+static void output_compilation_unit_header PARAMS ((void));
+static void output_comp_unit           PARAMS ((dw_die_ref));
+static const char *dwarf2_name         PARAMS ((tree, int));
+static void add_pubname                        PARAMS ((tree, dw_die_ref));
+static void output_pubnames            PARAMS ((void));
+static void add_arange                 PARAMS ((tree, dw_die_ref));
+static void output_aranges             PARAMS ((void));
+static void output_line_info           PARAMS ((void));
+static void output_file_names           PARAMS ((void));
+static dw_die_ref base_type_die                PARAMS ((tree));
+static tree root_type                  PARAMS ((tree));
+static int is_base_type                        PARAMS ((tree));
+static dw_die_ref modified_type_die    PARAMS ((tree, int, int, dw_die_ref));
+static int type_is_enum                        PARAMS ((tree));
+static unsigned int reg_number         PARAMS ((rtx));
+static dw_loc_descr_ref reg_loc_descriptor PARAMS ((rtx));
+static dw_loc_descr_ref int_loc_descriptor PARAMS ((HOST_WIDE_INT));
+static dw_loc_descr_ref based_loc_descr        PARAMS ((unsigned, long));
+static int is_based_loc                        PARAMS ((rtx));
+static dw_loc_descr_ref mem_loc_descriptor PARAMS ((rtx, enum machine_mode mode));
+static dw_loc_descr_ref concat_loc_descriptor PARAMS ((rtx, rtx));
+static dw_loc_descr_ref loc_descriptor PARAMS ((rtx));
+static dw_loc_descr_ref loc_descriptor_from_tree PARAMS ((tree, int));
+static HOST_WIDE_INT ceiling           PARAMS ((HOST_WIDE_INT, unsigned int));
+static tree field_type                 PARAMS ((tree));
+static unsigned int simple_type_align_in_bits PARAMS ((tree));
+static unsigned HOST_WIDE_INT simple_type_size_in_bits PARAMS ((tree));
+static HOST_WIDE_INT field_byte_offset PARAMS ((tree));
+static void add_AT_location_description        PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute, rtx));
+static void add_data_member_location_attribute PARAMS ((dw_die_ref, tree));
+static void add_const_value_attribute  PARAMS ((dw_die_ref, rtx));
+static rtx rtl_for_decl_location       PARAMS ((tree));
+static void add_location_or_const_value_attribute PARAMS ((dw_die_ref, tree));
+static void tree_add_const_value_attribute PARAMS ((dw_die_ref, tree));
+static void add_name_attribute         PARAMS ((dw_die_ref, const char *));
+static void add_bound_info             PARAMS ((dw_die_ref,
+                                                enum dwarf_attribute, tree));
+static void add_subscript_info         PARAMS ((dw_die_ref, tree));
+static void add_byte_size_attribute    PARAMS ((dw_die_ref, tree));
+static void add_bit_offset_attribute   PARAMS ((dw_die_ref, tree));
+static void add_bit_size_attribute     PARAMS ((dw_die_ref, tree));
+static void add_prototyped_attribute   PARAMS ((dw_die_ref, tree));
+static void add_abstract_origin_attribute PARAMS ((dw_die_ref, tree));
+static void add_pure_or_virtual_attribute PARAMS ((dw_die_ref, tree));
+static void add_src_coords_attributes  PARAMS ((dw_die_ref, tree));
+static void add_name_and_src_coords_attributes PARAMS ((dw_die_ref, tree));
+static void push_decl_scope            PARAMS ((tree));
+static dw_die_ref scope_die_for                PARAMS ((tree, dw_die_ref));
+static void pop_decl_scope             PARAMS ((void));
+static void add_type_attribute         PARAMS ((dw_die_ref, tree, int, int,
+                                                dw_die_ref));
+static const char *type_tag            PARAMS ((tree));
+static tree member_declared_type       PARAMS ((tree));
+#if 0
+static const char *decl_start_label    PARAMS ((tree));
+#endif
+static void gen_array_type_die         PARAMS ((tree, dw_die_ref));
+static void gen_set_type_die           PARAMS ((tree, dw_die_ref));
+#if 0
+static void gen_entry_point_die                PARAMS ((tree, dw_die_ref));
+#endif
+static void gen_inlined_enumeration_type_die PARAMS ((tree, dw_die_ref));
+static void gen_inlined_structure_type_die PARAMS ((tree, dw_die_ref));
+static void gen_inlined_union_type_die PARAMS ((tree, dw_die_ref));
+static void gen_enumeration_type_die   PARAMS ((tree, dw_die_ref));
+static dw_die_ref gen_formal_parameter_die PARAMS ((tree, dw_die_ref));
+static void gen_unspecified_parameters_die PARAMS ((tree, dw_die_ref));
+static void gen_formal_types_die       PARAMS ((tree, dw_die_ref));
+static void gen_subprogram_die         PARAMS ((tree, dw_die_ref));
+static void gen_variable_die           PARAMS ((tree, dw_die_ref));
+static void gen_label_die              PARAMS ((tree, dw_die_ref));
+static void gen_lexical_block_die      PARAMS ((tree, dw_die_ref, int));
+static void gen_inlined_subroutine_die PARAMS ((tree, dw_die_ref, int));
+static void gen_field_die              PARAMS ((tree, dw_die_ref));
+static void gen_ptr_to_mbr_type_die    PARAMS ((tree, dw_die_ref));
+static dw_die_ref gen_compile_unit_die PARAMS ((const char *));
+static void gen_string_type_die                PARAMS ((tree, dw_die_ref));
+static void gen_inheritance_die                PARAMS ((tree, dw_die_ref));
+static void gen_member_die             PARAMS ((tree, dw_die_ref));
+static void gen_struct_or_union_type_die PARAMS ((tree, dw_die_ref));
+static void gen_subroutine_type_die    PARAMS ((tree, dw_die_ref));
+static void gen_typedef_die            PARAMS ((tree, dw_die_ref));
+static void gen_type_die               PARAMS ((tree, dw_die_ref));
+static void gen_tagged_type_instantiation_die PARAMS ((tree, dw_die_ref));
+static void gen_block_die              PARAMS ((tree, dw_die_ref, int));
+static void decls_for_scope            PARAMS ((tree, dw_die_ref, int));
+static int is_redundant_typedef                PARAMS ((tree));
+static void gen_decl_die               PARAMS ((tree, dw_die_ref));
+static unsigned lookup_filename                PARAMS ((struct file_table *,
+                                                const char *));
+static void init_file_table            PARAMS ((struct file_table *));
+static void add_incomplete_type                PARAMS ((tree));
+static void retry_incomplete_types     PARAMS ((void));
+static void gen_type_die_for_member    PARAMS ((tree, tree, dw_die_ref));
+static void gen_abstract_function      PARAMS ((tree));
+static rtx save_rtx                    PARAMS ((rtx));
+static void splice_child_die           PARAMS ((dw_die_ref, dw_die_ref));
+
+/* Section names used to hold DWARF debugging information.  */
+#ifndef DEBUG_INFO_SECTION
+#define DEBUG_INFO_SECTION     ".debug_info"
+#endif
+#ifndef ABBREV_SECTION
+#define ABBREV_SECTION         ".debug_abbrev"
+#endif
+#ifndef ARANGES_SECTION
+#define ARANGES_SECTION                ".debug_aranges"
+#endif
+#ifndef DW_MACINFO_SECTION
+#define DW_MACINFO_SECTION     ".debug_macinfo"
+#endif
+#ifndef DEBUG_LINE_SECTION
+#define DEBUG_LINE_SECTION     ".debug_line"
+#endif
+#ifndef LOC_SECTION
+#define LOC_SECTION            ".debug_loc"
+#endif
+#ifndef PUBNAMES_SECTION
+#define PUBNAMES_SECTION       ".debug_pubnames"
+#endif
+#ifndef STR_SECTION
+#define STR_SECTION            ".debug_str"
+#endif
+
+/* Standard ELF section names for compiled code and data.  */
+#ifndef TEXT_SECTION
+#define TEXT_SECTION           ".text"
+#endif
+#ifndef DATA_SECTION
+#define DATA_SECTION           ".data"
+#endif
+#ifndef BSS_SECTION
+#define BSS_SECTION            ".bss"
+#endif
+
+/* Labels we insert at beginning sections we can reference instead of
+   the section names themselves.  */
+
+#ifndef TEXT_SECTION_LABEL
+#define TEXT_SECTION_LABEL      "Ltext"
+#endif
+#ifndef DEBUG_LINE_SECTION_LABEL
+#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
+#endif
+#ifndef DEBUG_INFO_SECTION_LABEL
+#define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
+#endif
+#ifndef ABBREV_SECTION_LABEL
+#define ABBREV_SECTION_LABEL     "Ldebug_abbrev"
+#endif
+
+/* Definitions of defaults for formats and names of various special
+   (artificial) labels which may be generated within this file (when the -g
+   options is used and DWARF_DEBUGGING_INFO is in effect.
+   If necessary, these may be overridden from within the tm.h file, but
+   typically, overriding these defaults is unnecessary.  */
+
+static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+#ifndef TEXT_END_LABEL
+#define TEXT_END_LABEL         "Letext"
+#endif
+#ifndef DATA_END_LABEL
+#define DATA_END_LABEL         "Ledata"
+#endif
+#ifndef BSS_END_LABEL
+#define BSS_END_LABEL           "Lebss"
+#endif
+#ifndef BLOCK_BEGIN_LABEL
+#define BLOCK_BEGIN_LABEL      "LBB"
+#endif
+#ifndef BLOCK_END_LABEL
+#define BLOCK_END_LABEL                "LBE"
+#endif
+#ifndef BODY_BEGIN_LABEL
+#define BODY_BEGIN_LABEL       "Lbb"
+#endif
+#ifndef BODY_END_LABEL
+#define BODY_END_LABEL         "Lbe"
+#endif
+#ifndef LINE_CODE_LABEL
+#define LINE_CODE_LABEL                "LM"
+#endif
+#ifndef SEPARATE_LINE_CODE_LABEL
+#define SEPARATE_LINE_CODE_LABEL       "LSM"
+#endif
+\f
+/* We allow a language front-end to designate a function that is to be
+   called to "demangle" any name before it it put into a DIE.  */
+
+static const char *(*demangle_name_func) PARAMS ((const char *));
+
+void
+dwarf2out_set_demangle_name_func (func)
+     const char *(*func) PARAMS ((const char *));
+{
+  demangle_name_func = func;
+}
+\f
+/* Return an rtx like ORIG which lives forever.  If we're doing GC,
+   that means adding it to used_rtx_varray.  If not, that means making
+   a copy on the permanent_obstack.  */
+
+static rtx
+save_rtx (orig)
+     register rtx orig;
+{
+  VARRAY_PUSH_RTX (used_rtx_varray, orig);
+
+  return orig;
+}
+
+/* Test if rtl node points to a pseudo register.  */
+
+static inline int
+is_pseudo_reg (rtl)
+     register rtx rtl;
+{
+  return ((GET_CODE (rtl) == REG && REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
+         || (GET_CODE (rtl) == SUBREG
+             && REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER));
+}
+
+/* Return a reference to a type, with its const and volatile qualifiers
+   removed.  */
+
+static inline tree
+type_main_variant (type)
+     register tree type;
+{
+  type = TYPE_MAIN_VARIANT (type);
+
+  /* There really should be only one main variant among any group of variants
+     of a given type (and all of the MAIN_VARIANT values for all members of
+     the group should point to that one type) but sometimes the C front-end
+     messes this up for array types, so we work around that bug here.  */
+
+  if (TREE_CODE (type) == ARRAY_TYPE)
+    while (type != TYPE_MAIN_VARIANT (type))
+      type = TYPE_MAIN_VARIANT (type);
+
+  return type;
+}
+
+/* Return non-zero if the given type node represents a tagged type.  */
+
+static inline int
+is_tagged_type (type)
+     register tree type;
+{
+  register enum tree_code code = TREE_CODE (type);
+
+  return (code == RECORD_TYPE || code == UNION_TYPE
+         || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
+}
+
+/* Convert a DIE tag into its string name.  */
+
+static const char *
+dwarf_tag_name (tag)
+     register unsigned tag;
+{
+  switch (tag)
+    {
+    case DW_TAG_padding:
+      return "DW_TAG_padding";
+    case DW_TAG_array_type:
+      return "DW_TAG_array_type";
+    case DW_TAG_class_type:
+      return "DW_TAG_class_type";
+    case DW_TAG_entry_point:
+      return "DW_TAG_entry_point";
+    case DW_TAG_enumeration_type:
+      return "DW_TAG_enumeration_type";
+    case DW_TAG_formal_parameter:
+      return "DW_TAG_formal_parameter";
+    case DW_TAG_imported_declaration:
+      return "DW_TAG_imported_declaration";
+    case DW_TAG_label:
+      return "DW_TAG_label";
+    case DW_TAG_lexical_block:
+      return "DW_TAG_lexical_block";
+    case DW_TAG_member:
+      return "DW_TAG_member";
+    case DW_TAG_pointer_type:
+      return "DW_TAG_pointer_type";
+    case DW_TAG_reference_type:
+      return "DW_TAG_reference_type";
+    case DW_TAG_compile_unit:
+      return "DW_TAG_compile_unit";
+    case DW_TAG_string_type:
+      return "DW_TAG_string_type";
+    case DW_TAG_structure_type:
+      return "DW_TAG_structure_type";
+    case DW_TAG_subroutine_type:
+      return "DW_TAG_subroutine_type";
+    case DW_TAG_typedef:
+      return "DW_TAG_typedef";
+    case DW_TAG_union_type:
+      return "DW_TAG_union_type";
+    case DW_TAG_unspecified_parameters:
+      return "DW_TAG_unspecified_parameters";
+    case DW_TAG_variant:
+      return "DW_TAG_variant";
+    case DW_TAG_common_block:
+      return "DW_TAG_common_block";
+    case DW_TAG_common_inclusion:
+      return "DW_TAG_common_inclusion";
+    case DW_TAG_inheritance:
+      return "DW_TAG_inheritance";
+    case DW_TAG_inlined_subroutine:
+      return "DW_TAG_inlined_subroutine";
+    case DW_TAG_module:
+      return "DW_TAG_module";
+    case DW_TAG_ptr_to_member_type:
+      return "DW_TAG_ptr_to_member_type";
+    case DW_TAG_set_type:
+      return "DW_TAG_set_type";
+    case DW_TAG_subrange_type:
+      return "DW_TAG_subrange_type";
+    case DW_TAG_with_stmt:
+      return "DW_TAG_with_stmt";
+    case DW_TAG_access_declaration:
+      return "DW_TAG_access_declaration";
+    case DW_TAG_base_type:
+      return "DW_TAG_base_type";
+    case DW_TAG_catch_block:
+      return "DW_TAG_catch_block";
+    case DW_TAG_const_type:
+      return "DW_TAG_const_type";
+    case DW_TAG_constant:
+      return "DW_TAG_constant";
+    case DW_TAG_enumerator:
+      return "DW_TAG_enumerator";
+    case DW_TAG_file_type:
+      return "DW_TAG_file_type";
+    case DW_TAG_friend:
+      return "DW_TAG_friend";
+    case DW_TAG_namelist:
+      return "DW_TAG_namelist";
+    case DW_TAG_namelist_item:
+      return "DW_TAG_namelist_item";
+    case DW_TAG_packed_type:
+      return "DW_TAG_packed_type";
+    case DW_TAG_subprogram:
+      return "DW_TAG_subprogram";
+    case DW_TAG_template_type_param:
+      return "DW_TAG_template_type_param";
+    case DW_TAG_template_value_param:
+      return "DW_TAG_template_value_param";
+    case DW_TAG_thrown_type:
+      return "DW_TAG_thrown_type";
+    case DW_TAG_try_block:
+      return "DW_TAG_try_block";
+    case DW_TAG_variant_part:
+      return "DW_TAG_variant_part";
+    case DW_TAG_variable:
+      return "DW_TAG_variable";
+    case DW_TAG_volatile_type:
+      return "DW_TAG_volatile_type";
+    case DW_TAG_MIPS_loop:
+      return "DW_TAG_MIPS_loop";
+    case DW_TAG_format_label:
+      return "DW_TAG_format_label";
+    case DW_TAG_function_template:
+      return "DW_TAG_function_template";
+    case DW_TAG_class_template:
+      return "DW_TAG_class_template";
+    case DW_TAG_GNU_BINCL:
+      return "DW_TAG_GNU_BINCL";
+    case DW_TAG_GNU_EINCL:
+      return "DW_TAG_GNU_EINCL";
     default:
-      return "OP_<unknown>";
+      return "DW_TAG_<unknown>";
+    }
+}
+
+/* Convert a DWARF attribute code into its string name.  */
+
+static const char *
+dwarf_attr_name (attr)
+     register unsigned attr;
+{
+  switch (attr)
+    {
+    case DW_AT_sibling:
+      return "DW_AT_sibling";
+    case DW_AT_location:
+      return "DW_AT_location";
+    case DW_AT_name:
+      return "DW_AT_name";
+    case DW_AT_ordering:
+      return "DW_AT_ordering";
+    case DW_AT_subscr_data:
+      return "DW_AT_subscr_data";
+    case DW_AT_byte_size:
+      return "DW_AT_byte_size";
+    case DW_AT_bit_offset:
+      return "DW_AT_bit_offset";
+    case DW_AT_bit_size:
+      return "DW_AT_bit_size";
+    case DW_AT_element_list:
+      return "DW_AT_element_list";
+    case DW_AT_stmt_list:
+      return "DW_AT_stmt_list";
+    case DW_AT_low_pc:
+      return "DW_AT_low_pc";
+    case DW_AT_high_pc:
+      return "DW_AT_high_pc";
+    case DW_AT_language:
+      return "DW_AT_language";
+    case DW_AT_member:
+      return "DW_AT_member";
+    case DW_AT_discr:
+      return "DW_AT_discr";
+    case DW_AT_discr_value:
+      return "DW_AT_discr_value";
+    case DW_AT_visibility:
+      return "DW_AT_visibility";
+    case DW_AT_import:
+      return "DW_AT_import";
+    case DW_AT_string_length:
+      return "DW_AT_string_length";
+    case DW_AT_common_reference:
+      return "DW_AT_common_reference";
+    case DW_AT_comp_dir:
+      return "DW_AT_comp_dir";
+    case DW_AT_const_value:
+      return "DW_AT_const_value";
+    case DW_AT_containing_type:
+      return "DW_AT_containing_type";
+    case DW_AT_default_value:
+      return "DW_AT_default_value";
+    case DW_AT_inline:
+      return "DW_AT_inline";
+    case DW_AT_is_optional:
+      return "DW_AT_is_optional";
+    case DW_AT_lower_bound:
+      return "DW_AT_lower_bound";
+    case DW_AT_producer:
+      return "DW_AT_producer";
+    case DW_AT_prototyped:
+      return "DW_AT_prototyped";
+    case DW_AT_return_addr:
+      return "DW_AT_return_addr";
+    case DW_AT_start_scope:
+      return "DW_AT_start_scope";
+    case DW_AT_stride_size:
+      return "DW_AT_stride_size";
+    case DW_AT_upper_bound:
+      return "DW_AT_upper_bound";
+    case DW_AT_abstract_origin:
+      return "DW_AT_abstract_origin";
+    case DW_AT_accessibility:
+      return "DW_AT_accessibility";
+    case DW_AT_address_class:
+      return "DW_AT_address_class";
+    case DW_AT_artificial:
+      return "DW_AT_artificial";
+    case DW_AT_base_types:
+      return "DW_AT_base_types";
+    case DW_AT_calling_convention:
+      return "DW_AT_calling_convention";
+    case DW_AT_count:
+      return "DW_AT_count";
+    case DW_AT_data_member_location:
+      return "DW_AT_data_member_location";
+    case DW_AT_decl_column:
+      return "DW_AT_decl_column";
+    case DW_AT_decl_file:
+      return "DW_AT_decl_file";
+    case DW_AT_decl_line:
+      return "DW_AT_decl_line";
+    case DW_AT_declaration:
+      return "DW_AT_declaration";
+    case DW_AT_discr_list:
+      return "DW_AT_discr_list";
+    case DW_AT_encoding:
+      return "DW_AT_encoding";
+    case DW_AT_external:
+      return "DW_AT_external";
+    case DW_AT_frame_base:
+      return "DW_AT_frame_base";
+    case DW_AT_friend:
+      return "DW_AT_friend";
+    case DW_AT_identifier_case:
+      return "DW_AT_identifier_case";
+    case DW_AT_macro_info:
+      return "DW_AT_macro_info";
+    case DW_AT_namelist_items:
+      return "DW_AT_namelist_items";
+    case DW_AT_priority:
+      return "DW_AT_priority";
+    case DW_AT_segment:
+      return "DW_AT_segment";
+    case DW_AT_specification:
+      return "DW_AT_specification";
+    case DW_AT_static_link:
+      return "DW_AT_static_link";
+    case DW_AT_type:
+      return "DW_AT_type";
+    case DW_AT_use_location:
+      return "DW_AT_use_location";
+    case DW_AT_variable_parameter:
+      return "DW_AT_variable_parameter";
+    case DW_AT_virtuality:
+      return "DW_AT_virtuality";
+    case DW_AT_vtable_elem_location:
+      return "DW_AT_vtable_elem_location";
+
+    case DW_AT_MIPS_fde:
+      return "DW_AT_MIPS_fde";
+    case DW_AT_MIPS_loop_begin:
+      return "DW_AT_MIPS_loop_begin";
+    case DW_AT_MIPS_tail_loop_begin:
+      return "DW_AT_MIPS_tail_loop_begin";
+    case DW_AT_MIPS_epilog_begin:
+      return "DW_AT_MIPS_epilog_begin";
+    case DW_AT_MIPS_loop_unroll_factor:
+      return "DW_AT_MIPS_loop_unroll_factor";
+    case DW_AT_MIPS_software_pipeline_depth:
+      return "DW_AT_MIPS_software_pipeline_depth";
+    case DW_AT_MIPS_linkage_name:
+      return "DW_AT_MIPS_linkage_name";
+    case DW_AT_MIPS_stride:
+      return "DW_AT_MIPS_stride";
+    case DW_AT_MIPS_abstract_name:
+      return "DW_AT_MIPS_abstract_name";
+    case DW_AT_MIPS_clone_origin:
+      return "DW_AT_MIPS_clone_origin";
+    case DW_AT_MIPS_has_inlines:
+      return "DW_AT_MIPS_has_inlines";
+
+    case DW_AT_sf_names:
+      return "DW_AT_sf_names";
+    case DW_AT_src_info:
+      return "DW_AT_src_info";
+    case DW_AT_mac_info:
+      return "DW_AT_mac_info";
+    case DW_AT_src_coords:
+      return "DW_AT_src_coords";
+    case DW_AT_body_begin:
+      return "DW_AT_body_begin";
+    case DW_AT_body_end:
+      return "DW_AT_body_end";
+    default:
+      return "DW_AT_<unknown>";
+    }
+}
+
+/* Convert a DWARF value form code into its string name.  */
+
+static const char *
+dwarf_form_name (form)
+     register unsigned form;
+{
+  switch (form)
+    {
+    case DW_FORM_addr:
+      return "DW_FORM_addr";
+    case DW_FORM_block2:
+      return "DW_FORM_block2";
+    case DW_FORM_block4:
+      return "DW_FORM_block4";
+    case DW_FORM_data2:
+      return "DW_FORM_data2";
+    case DW_FORM_data4:
+      return "DW_FORM_data4";
+    case DW_FORM_data8:
+      return "DW_FORM_data8";
+    case DW_FORM_string:
+      return "DW_FORM_string";
+    case DW_FORM_block:
+      return "DW_FORM_block";
+    case DW_FORM_block1:
+      return "DW_FORM_block1";
+    case DW_FORM_data1:
+      return "DW_FORM_data1";
+    case DW_FORM_flag:
+      return "DW_FORM_flag";
+    case DW_FORM_sdata:
+      return "DW_FORM_sdata";
+    case DW_FORM_strp:
+      return "DW_FORM_strp";
+    case DW_FORM_udata:
+      return "DW_FORM_udata";
+    case DW_FORM_ref_addr:
+      return "DW_FORM_ref_addr";
+    case DW_FORM_ref1:
+      return "DW_FORM_ref1";
+    case DW_FORM_ref2:
+      return "DW_FORM_ref2";
+    case DW_FORM_ref4:
+      return "DW_FORM_ref4";
+    case DW_FORM_ref8:
+      return "DW_FORM_ref8";
+    case DW_FORM_ref_udata:
+      return "DW_FORM_ref_udata";
+    case DW_FORM_indirect:
+      return "DW_FORM_indirect";
+    default:
+      return "DW_FORM_<unknown>";
     }
 }
 
@@ -3417,7 +4091,7 @@ decl_ultimate_origin (decl)
   if (DECL_ABSTRACT (decl) && DECL_ABSTRACT_ORIGIN (decl) == decl)
     return NULL_TREE;
 
-#ifdef ENABLE_CHECKING 
+#ifdef ENABLE_CHECKING
   if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
     /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
        most distant ancestor, this should never happen.  */
@@ -3488,7 +4162,7 @@ decl_class_context (decl)
 }
 \f
 /* Add an attribute/value pair to a DIE.  We build the lists up in reverse
-   addition order, and correct that in add_sibling_attributes.  */
+   addition order, and correct that in reverse_all_dies.  */
 
 static inline void
 add_dwarf_attr (die, attr)
@@ -3535,7 +4209,7 @@ AT_flag (a)
   if (a && AT_class (a) == dw_val_class_flag)
     return a->dw_attr_val.v.val_flag;
 
-  return 0;
+  abort ();
 }
 
 /* Add a signed integer attribute value to a DIE.  */
@@ -3563,7 +4237,7 @@ AT_int (a)
   if (a && AT_class (a) == dw_val_class_const)
     return a->dw_attr_val.v.val_int;
 
-  return 0;
+  abort ();
 }
 
 /* Add an unsigned integer attribute value to a DIE.  */
@@ -3591,7 +4265,7 @@ AT_unsigned (a)
   if (a && AT_class (a) == dw_val_class_unsigned_const)
     return a->dw_attr_val.v.val_unsigned;
 
-  return 0;
+  abort ();
 }
 
 /* Add an unsigned double integer attribute value to a DIE.  */
@@ -3657,7 +4331,7 @@ AT_string (a)
   if (a && AT_class (a) == dw_val_class_str)
     return a->dw_attr_val.v.val_str;
 
-  return NULL;
+  abort ();
 }
 
 /* Add a DIE reference attribute value to a DIE.  */
@@ -3673,19 +4347,43 @@ add_AT_die_ref (die, attr_kind, targ_die)
   attr->dw_attr_next = NULL;
   attr->dw_attr = attr_kind;
   attr->dw_attr_val.val_class = dw_val_class_die_ref;
-  attr->dw_attr_val.v.val_die_ref = targ_die;
+  attr->dw_attr_val.v.val_die_ref.die = targ_die;
+  attr->dw_attr_val.v.val_die_ref.external = 0;
   add_dwarf_attr (die, attr);
 }
 
-static inline dw_die_ref AT_ref PARAMS ((dw_attr_ref));
-static inline dw_die_ref
-AT_ref (a)
+static inline dw_die_ref AT_ref PARAMS ((dw_attr_ref));
+static inline dw_die_ref
+AT_ref (a)
+     register dw_attr_ref a;
+{
+  if (a && AT_class (a) == dw_val_class_die_ref)
+    return a->dw_attr_val.v.val_die_ref.die;
+
+  abort ();
+}
+
+static inline int AT_ref_external PARAMS ((dw_attr_ref));
+static inline int
+AT_ref_external (a)
+     register dw_attr_ref a;
+{
+  if (a && AT_class (a) == dw_val_class_die_ref)
+    return a->dw_attr_val.v.val_die_ref.external;
+
+  return 0;
+}
+
+static inline void set_AT_ref_external PARAMS ((dw_attr_ref, int));
+static inline void
+set_AT_ref_external (a, i)
      register dw_attr_ref a;
+     int i;
 {
   if (a && AT_class (a) == dw_val_class_die_ref)
-    return a->dw_attr_val.v.val_die_ref;
-
-  return NULL;
+    a->dw_attr_val.v.val_die_ref.external = i;
+  else
+    abort ();
 }
 
 /* Add an FDE reference attribute value to a DIE.  */
@@ -3730,7 +4428,7 @@ AT_loc (a)
   if (a && AT_class (a) == dw_val_class_loc)
     return a->dw_attr_val.v.val_loc;
 
-  return NULL;
+  abort ();
 }
 
 /* Add an address constant attribute value to a DIE.  */
@@ -3758,7 +4456,7 @@ AT_addr (a)
   if (a && AT_class (a) == dw_val_class_addr)
     return a->dw_attr_val.v.val_addr;
 
-  return NULL;
+  abort ();
 }
 
 /* Add a label identifier attribute value to a DIE.  */
@@ -3793,7 +4491,6 @@ add_AT_lbl_offset (die, attr_kind, label)
   attr->dw_attr_val.val_class = dw_val_class_lbl_offset;
   attr->dw_attr_val.v.val_lbl_id = xstrdup (label);
   add_dwarf_attr (die, attr);
-  
 }
 
 static inline const char *AT_lbl PARAMS ((dw_attr_ref));
@@ -3805,7 +4502,7 @@ AT_lbl (a)
            || AT_class (a) == dw_val_class_lbl_offset))
     return a->dw_attr_val.v.val_lbl_id;
 
-  return NULL;
+  abort ();
 }
 
 /* Get the attribute of type attr_kind.  */
@@ -3817,7 +4514,7 @@ get_AT (die, attr_kind)
 {
   register dw_attr_ref a;
   register dw_die_ref spec = NULL;
-  
+
   if (die != NULL)
     {
       for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
@@ -3847,7 +4544,7 @@ get_AT_low_pc (die)
      register dw_die_ref die;
 {
   register dw_attr_ref a = get_AT (die, DW_AT_low_pc);
-  return AT_lbl (a);
+  return a ? AT_lbl (a) : NULL;
 }
 
 /* Return the "high pc" attribute value, typically associated with
@@ -3860,7 +4557,7 @@ get_AT_hi_pc (die)
      register dw_die_ref die;
 {
   register dw_attr_ref a = get_AT (die, DW_AT_high_pc);
-  return AT_lbl (a);
+  return a ? AT_lbl (a) : NULL;
 }
 
 /* Return the value of the string attribute designated by ATTR_KIND, or
@@ -3872,7 +4569,7 @@ get_AT_string (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_string (a);
+  return a ? AT_string (a) : NULL;
 }
 
 /* Return the value of the flag attribute designated by ATTR_KIND, or -1
@@ -3884,7 +4581,7 @@ get_AT_flag (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_flag (a);
+  return a ? AT_flag (a) : 0;
 }
 
 /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
@@ -3896,7 +4593,7 @@ get_AT_unsigned (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_unsigned (a);
+  return a ? AT_unsigned (a) : 0;
 }
 
 static inline dw_die_ref
@@ -3905,7 +4602,7 @@ get_AT_ref (die, attr_kind)
      register enum dwarf_attribute attr_kind;
 {
   register dw_attr_ref a = get_AT (die, attr_kind);
-  return AT_ref (a);
+  return a ? AT_ref (a) : NULL;
 }
 
 static inline int
@@ -3915,7 +4612,7 @@ is_c_family ()
 
   return (lang == DW_LANG_C || lang == DW_LANG_C89
          || lang == DW_LANG_C_plus_plus);
-} 
+}
 
 static inline int
 is_fortran ()
@@ -3923,7 +4620,15 @@ is_fortran ()
   register unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
 
   return (lang == DW_LANG_Fortran77 || lang == DW_LANG_Fortran90);
-} 
+}
+
+static inline int
+is_java ()
+{
+  register unsigned lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+
+  return (lang == DW_LANG_Java);
+}
 
 /* Free up the memory used by A.  */
 
@@ -3940,12 +4645,16 @@ free_AT (a)
       free (a->dw_attr_val.v.val_str);
       break;
 
+    case dw_val_class_float:
+      free (a->dw_attr_val.v.val_float.array);
+      break;
+
     default:
       break;
     }
 
   free (a);
-}  
+}
 
 /* Remove the specified attribute if present.  */
 
@@ -3999,8 +4708,8 @@ remove_children (die)
       register dw_attr_ref a;
 
       child_die = child_die->die_sib;
-      
-      for (a = tmp_die->die_attr; a != NULL; )
+
+      for (a = tmp_die->die_attr; a != NULL;)
        {
          register dw_attr_ref tmp_a = a;
 
@@ -4013,7 +4722,7 @@ remove_children (die)
 }
 
 /* Add a child DIE below its parent.  We build the lists up in reverse
-   addition order, and correct that in add_sibling_attributes.  */
+   addition order, and correct that in reverse_all_dies.  */
 
 static inline void
 add_child_die (die, child_die)
@@ -4052,7 +4761,7 @@ splice_child_die (parent, child)
       && child->die_parent != get_AT_ref (parent, DW_AT_specification))
     abort ();
 
-  for (p = &(parent->die_child); *p; p = &((*p)->die_sib))
+  for (p = &(child->die_parent->die_child); *p; p = &((*p)->die_sib))
     if (*p == child)
       {
        *p = child->die_sib;
@@ -4079,6 +4788,7 @@ new_die (tag_value, parent_die)
   die->die_parent = NULL;
   die->die_sib = NULL;
   die->die_attr = NULL;
+  die->die_symbol = NULL;
 
   if (parent_die != NULL)
     add_child_die (parent_die, die);
@@ -4101,6 +4811,8 @@ static inline dw_die_ref
 lookup_type_die (type)
      register tree type;
 {
+  if (TREE_CODE (type) == VECTOR_TYPE)
+    type = TYPE_DEBUG_REPRESENTATION_TYPE (type);
   return (dw_die_ref) TYPE_SYMTAB_POINTER (type);
 }
 
@@ -4147,7 +4859,7 @@ equate_decl_number_to_die (decl, decl_die)
        = (dw_die_ref *) xrealloc (decl_die_table,
                                   sizeof (dw_die_ref) * num_allocated);
 
-      bzero ((char *) &decl_die_table[decl_die_table_allocated],
+      memset ((char *) &decl_die_table[decl_die_table_allocated], 0,
             (num_allocated - decl_die_table_allocated) * sizeof (dw_die_ref));
       decl_die_table_allocated = num_allocated;
     }
@@ -4157,45 +4869,6 @@ equate_decl_number_to_die (decl, decl_die)
 
   decl_die_table[decl_id] = decl_die;
 }
-
-/* Return a pointer to a newly allocated location description.  Location
-   descriptions are simple expression terms that can be strung
-   together to form more complicated location (address) descriptions.  */
-
-static inline dw_loc_descr_ref
-new_loc_descr (op, oprnd1, oprnd2)
-     register enum dwarf_location_atom op;
-     register unsigned long oprnd1;
-     register unsigned long oprnd2;
-{
-  register dw_loc_descr_ref descr
-    = (dw_loc_descr_ref) xmalloc (sizeof (dw_loc_descr_node));
-
-  descr->dw_loc_next = NULL;
-  descr->dw_loc_opc = op;
-  descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
-  descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
-  descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
-  descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
-
-  return descr;
-}
-
-/* Add a location description term to a location description expression.  */
-
-static inline void
-add_loc_descr (list_head, descr)
-     register dw_loc_descr_ref *list_head;
-     register dw_loc_descr_ref descr;
-{
-  register dw_loc_descr_ref *d;
-
-  /* Find the end of the chain.  */
-  for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
-    ;
-
-  *d = descr;
-}
 \f
 /* Keep track of the number of spaces used to indent the
    output of the debugging routines that print the structure of
@@ -4250,8 +4923,8 @@ print_die (die, outfile)
          break;
        case dw_val_class_long_long:
          fprintf (outfile, "constant (%lu,%lu)",
-                 a->dw_attr_val.v.val_long_long.hi,
-                 a->dw_attr_val.v.val_long_long.low);
+                  a->dw_attr_val.v.val_long_long.hi,
+                  a->dw_attr_val.v.val_long_long.low);
          break;
        case dw_val_class_float:
          fprintf (outfile, "floating-point constant");
@@ -4261,7 +4934,12 @@ print_die (die, outfile)
          break;
        case dw_val_class_die_ref:
          if (AT_ref (a) != NULL)
-           fprintf (outfile, "die -> %lu", AT_ref (a)->die_offset);
+           {
+             if (AT_ref (a)->die_symbol)
+               fprintf (outfile, "die -> label: %s", AT_ref (a)->die_symbol);
+             else
+               fprintf (outfile, "die -> %lu", AT_ref (a)->die_offset);
+           }
          else
            fprintf (outfile, "die -> <null>");
          break;
@@ -4290,294 +4968,555 @@ print_die (die, outfile)
 
       print_indent -= 4;
     }
+  if (print_indent == 0)
+    fprintf (outfile, "\n");
+}
+
+/* Print the contents of the source code line number correspondence table.
+   This routine is a debugging aid only.  */
+
+static void
+print_dwarf_line_table (outfile)
+     FILE *outfile;
+{
+  register unsigned i;
+  register dw_line_info_ref line_info;
+
+  fprintf (outfile, "\n\nDWARF source line information\n");
+  for (i = 1; i < line_info_table_in_use; ++i)
+    {
+      line_info = &line_info_table[i];
+      fprintf (outfile, "%5d: ", i);
+      fprintf (outfile, "%-20s", line_file_table.table[line_info->dw_file_num]);
+      fprintf (outfile, "%6ld", line_info->dw_line_num);
+      fprintf (outfile, "\n");
+    }
+
+  fprintf (outfile, "\n\n");
+}
+
+/* Print the information collected for a given DIE.  */
+
+void
+debug_dwarf_die (die)
+     dw_die_ref die;
+{
+  print_die (die, stderr);
+}
+
+/* Print all DWARF information collected for the compilation unit.
+   This routine is a debugging aid only.  */
+
+void
+debug_dwarf ()
+{
+  print_indent = 0;
+  print_die (comp_unit_die, stderr);
+  if (! DWARF2_ASM_LINE_DEBUG_INFO)
+    print_dwarf_line_table (stderr);
+}
+\f
+/* We build up the lists of children and attributes by pushing new ones
+   onto the beginning of the list.  Reverse the lists for DIE so that
+   they are in order of addition.  */
+
+static void
+reverse_die_lists (die)
+     register dw_die_ref die;
+{
+  register dw_die_ref c, cp, cn;
+  register dw_attr_ref a, ap, an;
+
+  for (a = die->die_attr, ap = 0; a; a = an)
+    {
+      an = a->dw_attr_next;
+      a->dw_attr_next = ap;
+      ap = a;
+    }
+  die->die_attr = ap;
+
+  for (c = die->die_child, cp = 0; c; c = cn)
+    {
+      cn = c->die_sib;
+      c->die_sib = cp;
+      cp = c;
+    }
+  die->die_child = cp;
+}
+
+/* reverse_die_lists only reverses the single die you pass it. Since
+   we used to reverse all dies in add_sibling_attributes, which runs
+   through all the dies, it would reverse all the dies.  Now, however,
+   since we don't call reverse_die_lists in add_sibling_attributes, we
+   need a routine to recursively reverse all the dies. This is that
+   routine.  */
+
+static void
+reverse_all_dies (die)
+     register dw_die_ref die;
+{
+  register dw_die_ref c;
+
+  reverse_die_lists (die);
+
+  for (c = die->die_child; c; c = c->die_sib)
+    reverse_all_dies (c);
+}
+
+/* Start a new compilation unit DIE for an include file.  OLD_UNIT is
+   the CU for the enclosing include file, if any.  BINCL_DIE is the
+   DW_TAG_GNU_BINCL DIE that marks the start of the DIEs for this
+   include file.  */
+
+static dw_die_ref
+push_new_compile_unit (old_unit, bincl_die)
+     dw_die_ref old_unit, bincl_die;
+{
+  const char *filename = get_AT_string (bincl_die, DW_AT_name);
+  dw_die_ref new_unit = gen_compile_unit_die (filename);
+  new_unit->die_sib = old_unit;
+  return new_unit;
+}
+
+/* Close an include-file CU and reopen the enclosing one.  */
+
+static dw_die_ref
+pop_compile_unit (old_unit)
+     dw_die_ref old_unit;
+{
+  dw_die_ref new_unit = old_unit->die_sib;
+  old_unit->die_sib = NULL;
+  return new_unit;
+}
+
+#define PROCESS(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
+#define PROCESS_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
+
+/* Calculate the checksum of a location expression.  */
+
+static inline void
+loc_checksum (loc, ctx)
+     dw_loc_descr_ref loc;
+     struct md5_ctx *ctx;
+{
+  PROCESS (loc->dw_loc_opc);
+  PROCESS (loc->dw_loc_oprnd1);
+  PROCESS (loc->dw_loc_oprnd2);
+}
+
+/* Calculate the checksum of an attribute.  */
+
+static void
+attr_checksum (at, ctx)
+     dw_attr_ref at;
+     struct md5_ctx *ctx;
+{
+  dw_loc_descr_ref loc;
+  rtx r;
+
+  PROCESS (at->dw_attr);
+
+  /* We don't care about differences in file numbering.  */
+  if (at->dw_attr == DW_AT_decl_file
+      /* Or that this was compiled with a different compiler snapshot; if
+        the output is the same, that's what matters.  */
+      || at->dw_attr == DW_AT_producer)
+    return;
+
+  switch (AT_class (at))
+    {
+    case dw_val_class_const:
+      PROCESS (at->dw_attr_val.v.val_int);
+      break;
+    case dw_val_class_unsigned_const:
+      PROCESS (at->dw_attr_val.v.val_unsigned);
+      break;
+    case dw_val_class_long_long:
+      PROCESS (at->dw_attr_val.v.val_long_long);
+      break;
+    case dw_val_class_float:
+      PROCESS (at->dw_attr_val.v.val_float);
+      break;
+    case dw_val_class_flag:
+      PROCESS (at->dw_attr_val.v.val_flag);
+      break;
+
+    case dw_val_class_str:
+      PROCESS_STRING (AT_string (at));
+      break;
+    case dw_val_class_addr:
+      r = AT_addr (at);
+      switch (GET_CODE (r))
+       {
+       case SYMBOL_REF:
+         PROCESS_STRING (XSTR (r, 0));
+         break;
+
+       default:
+         abort ();
+       }
+      break;
+
+    case dw_val_class_loc:
+      for (loc = AT_loc (at); loc; loc = loc->dw_loc_next)
+       loc_checksum (loc, ctx);
+      break;
+
+    case dw_val_class_die_ref:
+      if (AT_ref (at)->die_offset)
+       PROCESS (AT_ref (at)->die_offset);
+      /* FIXME else use target die name or something.  */
+
+    case dw_val_class_fde_ref:
+    case dw_val_class_lbl_id:
+    case dw_val_class_lbl_offset:
+
+    default:
+      break;
+    }
+}
+
+/* Calculate the checksum of a DIE.  */
+
+static void
+die_checksum (die, ctx)
+     dw_die_ref die;
+     struct md5_ctx *ctx;
+{
+  dw_die_ref c;
+  dw_attr_ref a;
+
+  PROCESS (die->die_tag);
+
+  for (a = die->die_attr; a; a = a->dw_attr_next)
+    attr_checksum (a, ctx);
+
+  for (c = die->die_child; c; c = c->die_sib)
+    die_checksum (c, ctx);
+}
+
+#undef PROCESS
+#undef PROCESS_STRING
+
+/* The prefix to attach to symbols on DIEs in the current comdat debug
+   info section.  */
+static char *comdat_symbol_id;
+
+/* The index of the current symbol within the current comdat CU.  */
+static unsigned int comdat_symbol_number;
+
+/* Calculate the MD5 checksum of the compilation unit DIE UNIT_DIE and its
+   children, and set comdat_symbol_id accordingly.  */
+
+static void
+compute_section_prefix (unit_die)
+     dw_die_ref unit_die;
+{
+  char *p, *name;
+  int i;
+  unsigned char checksum[16];
+  struct md5_ctx ctx;
+
+  md5_init_ctx (&ctx);
+  die_checksum (unit_die, &ctx);
+  md5_finish_ctx (&ctx, checksum);
+
+  p = file_name_nondirectory (get_AT_string (unit_die, DW_AT_name));
+  name = (char *) alloca (strlen (p) + 64);
+  sprintf (name, "%s.", p);
+
+  clean_symbol_name (name);
+
+  p = name + strlen (name);
+  for (i = 0; i < 4; ++i)
+    {
+      sprintf (p, "%.2x", checksum[i]);
+      p += 2;
+    }
+
+  comdat_symbol_id = unit_die->die_symbol = xstrdup (name);
+  comdat_symbol_number = 0;
+}
+
+/* Returns nonzero iff DIE represents a type, in the sense of TYPE_P.  */
+
+static int
+is_type_die (die)
+     dw_die_ref die;
+{
+  switch (die->die_tag)
+    {
+    case DW_TAG_array_type:
+    case DW_TAG_class_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_pointer_type:
+    case DW_TAG_reference_type:
+    case DW_TAG_string_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_subroutine_type:
+    case DW_TAG_union_type:
+    case DW_TAG_ptr_to_member_type:
+    case DW_TAG_set_type:
+    case DW_TAG_subrange_type:
+    case DW_TAG_base_type:
+    case DW_TAG_const_type:
+    case DW_TAG_file_type:
+    case DW_TAG_packed_type:
+    case DW_TAG_volatile_type:
+      return 1;
+    default:
+      return 0;
+    }
 }
 
-/* Print the contents of the source code line number correspondence table.
-   This routine is a debugging aid only.  */
+/* Returns 1 iff C is the sort of DIE that should go into a COMDAT CU.
+   Basically, we want to choose the bits that are likely to be shared between
+   compilations (types) and leave out the bits that are specific to individual
+   compilations (functions).  */
 
-static void
-print_dwarf_line_table (outfile)
-     FILE *outfile;
-{
-  register unsigned i;
-  register dw_line_info_ref line_info;
+static int
+is_comdat_die (c)
+     dw_die_ref c;
+{
+#if 1
+  /* I think we want to leave base types and __vtbl_ptr_type in the
+     main CU, as we do for stabs.  The advantage is a greater
+     likelihood of sharing between objects that don't include headers
+     in the same order (and therefore would put the base types in a
+     different comdat).  jason 8/28/00 */
+  if (c->die_tag == DW_TAG_base_type)
+    return 0;
 
-  fprintf (outfile, "\n\nDWARF source line information\n");
-  for (i = 1; i < line_info_table_in_use; ++i)
+  if (c->die_tag == DW_TAG_pointer_type
+      || c->die_tag == DW_TAG_reference_type
+      || c->die_tag == DW_TAG_const_type
+      || c->die_tag == DW_TAG_volatile_type)
     {
-      line_info = &line_info_table[i];
-      fprintf (outfile, "%5d: ", i);
-      fprintf (outfile, "%-20s", file_table[line_info->dw_file_num]);
-      fprintf (outfile, "%6ld", line_info->dw_line_num);
-      fprintf (outfile, "\n");
+      dw_die_ref t = get_AT_ref (c, DW_AT_type);
+      return t ? is_comdat_die (t) : 0;
     }
+#endif
 
-  fprintf (outfile, "\n\n");
-}
-
-/* Print the information collected for a given DIE.  */
-
-void
-debug_dwarf_die (die)
-     dw_die_ref die;
-{
-  print_die (die, stderr);
+  return is_type_die (c);
 }
 
-/* Print all DWARF information collected for the compilation unit.
-   This routine is a debugging aid only.  */
+/* Returns 1 iff C is the sort of DIE that might be referred to from another
+   compilation unit.  */
 
-void
-debug_dwarf ()
+static int
+is_symbol_die (c)
+     dw_die_ref c;
 {
-  print_indent = 0;
-  print_die (comp_unit_die, stderr);
-  if (! DWARF2_ASM_LINE_DEBUG_INFO)
-    print_dwarf_line_table (stderr);
+  if (is_type_die (c))
+    return 1;
+  if (get_AT (c, DW_AT_declaration)
+      && ! get_AT (c, DW_AT_specification))
+    return 1;
+  return 0;
 }
-\f
-/* We build up the lists of children and attributes by pushing new ones
-   onto the beginning of the list.  Reverse the lists for DIE so that
-   they are in order of addition.  */
 
-static void
-reverse_die_lists (die)
-     register dw_die_ref die;
+static char *
+gen_internal_sym ()
 {
-  register dw_die_ref c, cp, cn;
-  register dw_attr_ref a, ap, an;
-
-  for (a = die->die_attr, ap = 0; a; a = an)
-    {
-      an = a->dw_attr_next;
-      a->dw_attr_next = ap;
-      ap = a;
-    }
-  die->die_attr = ap;
-
-  for (c = die->die_child, cp = 0; c; c = cn)
-    {
-      cn = c->die_sib;
-      c->die_sib = cp;
-      cp = c;
-    }
-  die->die_child = cp;
+  char buf[256];
+  static int label_num;
+  ASM_GENERATE_INTERNAL_LABEL (buf, "LDIE", label_num++);
+  return xstrdup (buf);
 }
 
-/* Traverse the DIE, reverse its lists of attributes and children, and
-   add a sibling attribute if it may have the effect of speeding up
-   access to siblings.  To save some space, avoid generating sibling
-   attributes for DIE's without children.  */
+/* Assign symbols to all worthy DIEs under DIE.  */
 
 static void
-add_sibling_attributes (die)
+assign_symbol_names (die)
      register dw_die_ref die;
 {
   register dw_die_ref c;
 
-  reverse_die_lists (die);
-
-  if (die != comp_unit_die && die->die_sib && die->die_child != NULL)
-    /* Add the sibling link to the front of the attribute list.  */
-    add_AT_die_ref (die, DW_AT_sibling, die->die_sib);
+  if (is_symbol_die (die))
+    {
+      if (comdat_symbol_id)
+       {
+         char *p = alloca (strlen (comdat_symbol_id) + 64);
+         sprintf (p, "%s.%s.%x", DIE_LABEL_PREFIX,
+                  comdat_symbol_id, comdat_symbol_number++);
+         die->die_symbol = xstrdup (p);
+       }
+      else
+       die->die_symbol = gen_internal_sym ();
+    }
 
   for (c = die->die_child; c != NULL; c = c->die_sib)
-    add_sibling_attributes (c);
+    assign_symbol_names (c);
 }
 
-/* The format of each DIE (and its attribute value pairs)
-   is encoded in an abbreviation table.  This routine builds the
-   abbreviation table and assigns a unique abbreviation id for
-   each abbreviation entry.  The children of each die are visited
-   recursively.  */
+/* Traverse the DIE (which is always comp_unit_die), and set up
+   additional compilation units for each of the include files we see
+   bracketed by BINCL/EINCL.  */
 
 static void
-build_abbrev_table (die)
+break_out_includes (die)
      register dw_die_ref die;
 {
-  register unsigned long abbrev_id;
-  register unsigned long n_alloc;
-  register dw_die_ref c;
-  register dw_attr_ref d_attr, a_attr;
-  for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
+  dw_die_ref *ptr;
+  register dw_die_ref unit = NULL;
+  limbo_die_node *node;
+
+  for (ptr = &(die->die_child); *ptr; )
     {
-      register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
+      register dw_die_ref c = *ptr;
 
-      if (abbrev->die_tag == die->die_tag)
+      if (c->die_tag == DW_TAG_GNU_BINCL
+         || c->die_tag == DW_TAG_GNU_EINCL
+         || (unit && is_comdat_die (c)))
        {
-         if ((abbrev->die_child != NULL) == (die->die_child != NULL))
-           {
-             a_attr = abbrev->die_attr;
-             d_attr = die->die_attr;
-
-             while (a_attr != NULL && d_attr != NULL)
-               {
-                 if ((a_attr->dw_attr != d_attr->dw_attr)
-                     || (value_format (a_attr) != value_format (d_attr)))
-                   break;
-
-                 a_attr = a_attr->dw_attr_next;
-                 d_attr = d_attr->dw_attr_next;
-               }
+         /* This DIE is for a secondary CU; remove it from the main one.  */
+         *ptr = c->die_sib;
 
-             if (a_attr == NULL && d_attr == NULL)
-               break;
+         if (c->die_tag == DW_TAG_GNU_BINCL)
+           {
+             unit = push_new_compile_unit (unit, c);
+             free_die (c);
            }
+         else if (c->die_tag == DW_TAG_GNU_EINCL)
+           {
+             unit = pop_compile_unit (unit);
+             free_die (c);
+           }
+         else
+           add_child_die (unit, c);
        }
-    }
-
-  if (abbrev_id >= abbrev_die_table_in_use)
-    {
-      if (abbrev_die_table_in_use >= abbrev_die_table_allocated)
+      else
        {
-         n_alloc = abbrev_die_table_allocated + ABBREV_DIE_TABLE_INCREMENT;
-         abbrev_die_table 
-           = (dw_die_ref *) xrealloc (abbrev_die_table,
-                                      sizeof (dw_die_ref) * n_alloc);
-
-         bzero ((char *) &abbrev_die_table[abbrev_die_table_allocated],
-                (n_alloc - abbrev_die_table_allocated) * sizeof (dw_die_ref));
-         abbrev_die_table_allocated = n_alloc;
+         /* Leave this DIE in the main CU.  */
+         ptr = &(c->die_sib);
+         continue;
        }
-
-      ++abbrev_die_table_in_use;
-      abbrev_die_table[abbrev_id] = die;
     }
 
-  die->die_abbrev = abbrev_id;
-  for (c = die->die_child; c != NULL; c = c->die_sib)
-    build_abbrev_table (c);
+#if 0
+  /* We can only use this in debugging, since the frontend doesn't check
+     to make sure that we leave every include file we enter.  */
+  if (unit != NULL)
+    abort ();
+#endif
+
+  assign_symbol_names (die);
+  for (node = limbo_die_list; node; node = node->next)
+    {
+      compute_section_prefix (node->die);
+      assign_symbol_names (node->die);
+    }
 }
-\f
-/* Return the size of a string, including the null byte.
 
-   This used to treat backslashes as escapes, and hence they were not included
-   in the count.  However, that conflicts with what ASM_OUTPUT_ASCII does,
-   which treats a backslash as a backslash, escaping it if necessary, and hence
-   we must include them in the count.  */
+/* Traverse the DIE and add a sibling attribute if it may have the
+   effect of speeding up access to siblings.  To save some space,
+   avoid generating sibling attributes for DIE's without children.  */
 
-static unsigned long
-size_of_string (str)
-     register const char *str;
+static void
+add_sibling_attributes (die)
+     register dw_die_ref die;
 {
-  return strlen (str) + 1;
-}
+  register dw_die_ref c;
 
-/* Return the size of a location descriptor.  */
+  if (die->die_tag != DW_TAG_compile_unit
+      && die->die_sib && die->die_child != NULL)
+    /* Add the sibling link to the front of the attribute list.  */
+    add_AT_die_ref (die, DW_AT_sibling, die->die_sib);
 
-static unsigned long
-size_of_loc_descr (loc)
-     register dw_loc_descr_ref loc;
-{
-  register unsigned long size = 1;
+  for (c = die->die_child; c != NULL; c = c->die_sib)
+    add_sibling_attributes (c);
+}
 
-  switch (loc->dw_loc_opc)
-    {
-    case DW_OP_addr:
-      size += DWARF2_ADDR_SIZE;
-      break;
-    case DW_OP_const1u:
-    case DW_OP_const1s:
-      size += 1;
-      break;
-    case DW_OP_const2u:
-    case DW_OP_const2s:
-      size += 2;
-      break;
-    case DW_OP_const4u:
-    case DW_OP_const4s:
-      size += 4;
-      break;
-    case DW_OP_const8u:
-    case DW_OP_const8s:
-      size += 8;
-      break;
-    case DW_OP_constu:
-      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
-      break;
-    case DW_OP_consts:
-      size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
-      break;
-    case DW_OP_pick:
-      size += 1;
-      break;
-    case DW_OP_plus_uconst:
-      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
-      break;
-    case DW_OP_skip:
-    case DW_OP_bra:
-      size += 2;
-      break;
-    case DW_OP_breg0:
-    case DW_OP_breg1:
-    case DW_OP_breg2:
-    case DW_OP_breg3:
-    case DW_OP_breg4:
-    case DW_OP_breg5:
-    case DW_OP_breg6:
-    case DW_OP_breg7:
-    case DW_OP_breg8:
-    case DW_OP_breg9:
-    case DW_OP_breg10:
-    case DW_OP_breg11:
-    case DW_OP_breg12:
-    case DW_OP_breg13:
-    case DW_OP_breg14:
-    case DW_OP_breg15:
-    case DW_OP_breg16:
-    case DW_OP_breg17:
-    case DW_OP_breg18:
-    case DW_OP_breg19:
-    case DW_OP_breg20:
-    case DW_OP_breg21:
-    case DW_OP_breg22:
-    case DW_OP_breg23:
-    case DW_OP_breg24:
-    case DW_OP_breg25:
-    case DW_OP_breg26:
-    case DW_OP_breg27:
-    case DW_OP_breg28:
-    case DW_OP_breg29:
-    case DW_OP_breg30:
-    case DW_OP_breg31:
-      size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
-      break;
-    case DW_OP_regx:
-      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
-      break;
-    case DW_OP_fbreg:
-      size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
-      break;
-    case DW_OP_bregx:
-      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
-      size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
-      break;
-    case DW_OP_piece:
-      size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
-      break;
-    case DW_OP_deref_size:
-    case DW_OP_xderef_size:
-      size += 1;
-      break;
-    default:
-      break;
+/* The format of each DIE (and its attribute value pairs)
+   is encoded in an abbreviation table.  This routine builds the
+   abbreviation table and assigns a unique abbreviation id for
+   each abbreviation entry.  The children of each die are visited
+   recursively.  */
+
+static void
+build_abbrev_table (die)
+     register dw_die_ref die;
+{
+  register unsigned long abbrev_id;
+  register unsigned long n_alloc;
+  register dw_die_ref c;
+  register dw_attr_ref d_attr, a_attr;
+
+  /* Scan the DIE references, and mark as external any that refer to
+     DIEs from other CUs (i.e. those which are not marked).  */
+  for (d_attr = die->die_attr; d_attr; d_attr = d_attr->dw_attr_next)
+    {
+      if (AT_class (d_attr) == dw_val_class_die_ref
+         && AT_ref (d_attr)->die_mark == 0)
+       {
+         if (AT_ref (d_attr)->die_symbol == 0)
+           abort ();
+         set_AT_ref_external (d_attr, 1);
+       }
     }
 
-  return size;
+  for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
+    {
+      register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
+
+      if (abbrev->die_tag == die->die_tag)
+       {
+         if ((abbrev->die_child != NULL) == (die->die_child != NULL))
+           {
+             a_attr = abbrev->die_attr;
+             d_attr = die->die_attr;
+
+             while (a_attr != NULL && d_attr != NULL)
+               {
+                 if ((a_attr->dw_attr != d_attr->dw_attr)
+                     || (value_format (a_attr) != value_format (d_attr)))
+                   break;
+
+                 a_attr = a_attr->dw_attr_next;
+                 d_attr = d_attr->dw_attr_next;
+               }
+
+             if (a_attr == NULL && d_attr == NULL)
+               break;
+           }
+       }
+    }
+
+  if (abbrev_id >= abbrev_die_table_in_use)
+    {
+      if (abbrev_die_table_in_use >= abbrev_die_table_allocated)
+       {
+         n_alloc = abbrev_die_table_allocated + ABBREV_DIE_TABLE_INCREMENT;
+         abbrev_die_table
+           = (dw_die_ref *) xrealloc (abbrev_die_table,
+                                      sizeof (dw_die_ref) * n_alloc);
+
+         memset ((char *) &abbrev_die_table[abbrev_die_table_allocated], 0,
+                (n_alloc - abbrev_die_table_allocated) * sizeof (dw_die_ref));
+         abbrev_die_table_allocated = n_alloc;
+       }
+
+      ++abbrev_die_table_in_use;
+      abbrev_die_table[abbrev_id] = die;
+    }
+
+  die->die_abbrev = abbrev_id;
+  for (c = die->die_child; c != NULL; c = c->die_sib)
+    build_abbrev_table (c);
 }
+\f
+/* Return the size of a string, including the null byte.
 
-/* Return the size of a series of location descriptors.  */
+   This used to treat backslashes as escapes, and hence they were not included
+   in the count.  However, that conflicts with what ASM_OUTPUT_ASCII does,
+   which treats a backslash as a backslash, escaping it if necessary, and hence
+   we must include them in the count.  */
 
 static unsigned long
-size_of_locs (loc)
-     register dw_loc_descr_ref loc;
+size_of_string (str)
+     register const char *str;
 {
-  register unsigned long size = 0;
-
-  for (; loc != NULL; loc = loc->dw_loc_next)
-    size += size_of_loc_descr (loc);
-
-  return size;
+  return strlen (str) + 1;
 }
 
 /* Return the power-of-two number of bytes necessary to represent VALUE.  */
@@ -4627,7 +5566,7 @@ size_of_die (die)
          }
          break;
        case dw_val_class_const:
-         size += 4;
+         size += size_of_sleb128 (AT_int (a));
          break;
        case dw_val_class_unsigned_const:
          size += constant_size (AT_unsigned (a));
@@ -4686,6 +5625,33 @@ calc_die_sizes (die)
     next_die_offset += 1;
 }
 
+/* Set the marks for a die and its children.  We do this so
+   that we know whether or not a reference needs to use FORM_ref_addr; only
+   DIEs in the same CU will be marked.  We used to clear out the offset
+   and use that as the flag, but ran into ordering problems.  */
+
+static void
+mark_dies (die)
+     dw_die_ref die;
+{
+  register dw_die_ref c;
+  die->die_mark = 1;
+  for (c = die->die_child; c; c = c->die_sib)
+    mark_dies (c);
+}
+
+/* Clear the marks for a die and its children.  */
+
+static void
+unmark_dies (die)
+     dw_die_ref die;
+{
+  register dw_die_ref c;
+  die->die_mark = 0;
+  for (c = die->die_child; c; c = c->die_sib)
+    unmark_dies (c);
+}
+
 /* Return the size of the line information prolog generated for the
    compilation unit.  */
 
@@ -4705,10 +5671,10 @@ size_of_line_prolog ()
      null byte used to terminate the table.  */
   size += 1;
 
-  for (ft_index = 1; ft_index < file_table_in_use; ++ft_index)
+  for (ft_index = 1; ft_index < decl_file_table.in_use; ++ft_index)
     {
       /* File name entry.  */
-      size += size_of_string (file_table[ft_index]);
+      size += size_of_string (decl_file_table.table[ft_index]);
 
       /* Include directory index.  */
       size += size_of_uleb128 (0);
@@ -4784,7 +5750,7 @@ value_format (a)
          abort ();
        }
     case dw_val_class_const:
-      return DW_FORM_data4;
+      return DW_FORM_sdata;
     case dw_val_class_unsigned_const:
       switch (constant_size (AT_unsigned (a)))
        {
@@ -4806,7 +5772,10 @@ value_format (a)
     case dw_val_class_flag:
       return DW_FORM_flag;
     case dw_val_class_die_ref:
-      return DW_FORM_ref;
+      if (AT_ref_external (a))
+       return DW_FORM_ref_addr;
+      else
+       return DW_FORM_ref;
     case dw_val_class_fde_ref:
       return DW_FORM_data;
     case dw_val_class_lbl_id:
@@ -4830,182 +5799,96 @@ output_value_format (a)
 
   output_uleb128 (form);
   if (flag_debug_asm)
-    fprintf (asm_out_file, " (%s)", dwarf_form_name (form));
-
-  fputc ('\n', asm_out_file);
-}
-
-/* Output the .debug_abbrev section which defines the DIE abbreviation
-   table.  */
-
-static void
-output_abbrev_section ()
-{
-  unsigned long abbrev_id;
-
-  dw_attr_ref a_attr;
-  for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
-    {
-      register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
-
-      output_uleb128 (abbrev_id);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, " (abbrev code)");
-
-      fputc ('\n', asm_out_file);
-      output_uleb128 (abbrev->die_tag);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, " (TAG: %s)",
-                dwarf_tag_name (abbrev->die_tag));
-
-      fputc ('\n', asm_out_file);
-      fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP,
-              abbrev->die_child != NULL ? DW_children_yes : DW_children_no);
-
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s %s",
-                ASM_COMMENT_START,
-                (abbrev->die_child != NULL
-                 ? "DW_children_yes" : "DW_children_no"));
-
-      fputc ('\n', asm_out_file);
-
-      for (a_attr = abbrev->die_attr; a_attr != NULL;
-          a_attr = a_attr->dw_attr_next)
-       {
-         output_uleb128 (a_attr->dw_attr);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, " (%s)",
-                    dwarf_attr_name (a_attr->dw_attr));
-
-         fputc ('\n', asm_out_file);
-         output_value_format (a_attr);
-       }
-
-      fprintf (asm_out_file, "\t%s\t0,0\n", ASM_BYTE_OP);
-    }
-
-  /* Terminate the table.  */
-  fprintf (asm_out_file, "\t%s\t0\n", ASM_BYTE_OP);
-}
-
-/* Output location description stack opcode's operands (if any).  */
-
-static void
-output_loc_operands (loc)
-     register dw_loc_descr_ref loc;
-{
-  register dw_val_ref val1 = &loc->dw_loc_oprnd1;
-  register dw_val_ref val2 = &loc->dw_loc_oprnd2;
-
-  switch (loc->dw_loc_opc)
-    {
-    case DW_OP_addr:
-      ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, val1->v.val_addr);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_const1u:
-    case DW_OP_const1s:
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_const2u:
-    case DW_OP_const2s:
-      ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_const4u:
-    case DW_OP_const4s:
-      ASM_OUTPUT_DWARF_DATA4 (asm_out_file, val1->v.val_int);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_const8u:
-    case DW_OP_const8s:
-      abort ();
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_constu:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_consts:
-      output_sleb128 (val1->v.val_int);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_pick:
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_int);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_plus_uconst:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_skip:
-    case DW_OP_bra:
-      ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_breg0:
-    case DW_OP_breg1:
-    case DW_OP_breg2:
-    case DW_OP_breg3:
-    case DW_OP_breg4:
-    case DW_OP_breg5:
-    case DW_OP_breg6:
-    case DW_OP_breg7:
-    case DW_OP_breg8:
-    case DW_OP_breg9:
-    case DW_OP_breg10:
-    case DW_OP_breg11:
-    case DW_OP_breg12:
-    case DW_OP_breg13:
-    case DW_OP_breg14:
-    case DW_OP_breg15:
-    case DW_OP_breg16:
-    case DW_OP_breg17:
-    case DW_OP_breg18:
-    case DW_OP_breg19:
-    case DW_OP_breg20:
-    case DW_OP_breg21:
-    case DW_OP_breg22:
-    case DW_OP_breg23:
-    case DW_OP_breg24:
-    case DW_OP_breg25:
-    case DW_OP_breg26:
-    case DW_OP_breg27:
-    case DW_OP_breg28:
-    case DW_OP_breg29:
-    case DW_OP_breg30:
-    case DW_OP_breg31:
-      output_sleb128 (val1->v.val_int);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_regx:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_fbreg:
-      output_sleb128 (val1->v.val_int);
-      fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_bregx:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
-      output_sleb128 (val2->v.val_int);
+    fprintf (asm_out_file, " (%s)", dwarf_form_name (form));
+
+  fputc ('\n', asm_out_file);
+}
+
+/* Output the .debug_abbrev section which defines the DIE abbreviation
+   table.  */
+
+static void
+output_abbrev_section ()
+{
+  unsigned long abbrev_id;
+
+  dw_attr_ref a_attr;
+  for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
+    {
+      register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
+
+      output_uleb128 (abbrev_id);
+      if (flag_debug_asm)
+       fprintf (asm_out_file, " (abbrev code)");
+
       fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_piece:
-      output_uleb128 (val1->v.val_unsigned);
+      output_uleb128 (abbrev->die_tag);
+      if (flag_debug_asm)
+       fprintf (asm_out_file, " (TAG: %s)",
+                dwarf_tag_name (abbrev->die_tag));
+
       fputc ('\n', asm_out_file);
-      break;
-    case DW_OP_deref_size:
-    case DW_OP_xderef_size:
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag);
+      fprintf (asm_out_file, "%s0x%x", ASM_BYTE_OP,
+              abbrev->die_child != NULL ? DW_children_yes : DW_children_no);
+
+      if (flag_debug_asm)
+       fprintf (asm_out_file, "\t%s %s",
+                ASM_COMMENT_START,
+                (abbrev->die_child != NULL
+                 ? "DW_children_yes" : "DW_children_no"));
+
       fputc ('\n', asm_out_file);
-      break;
-    default:
-      break;
+
+      for (a_attr = abbrev->die_attr; a_attr != NULL;
+          a_attr = a_attr->dw_attr_next)
+       {
+         output_uleb128 (a_attr->dw_attr);
+         if (flag_debug_asm)
+           fprintf (asm_out_file, " (%s)",
+                    dwarf_attr_name (a_attr->dw_attr));
+
+         fputc ('\n', asm_out_file);
+         output_value_format (a_attr);
+       }
+
+      fprintf (asm_out_file, "%s0,0\n", ASM_BYTE_OP);
     }
+
+  /* Terminate the table.  */
+  fprintf (asm_out_file, "%s0\n", ASM_BYTE_OP);
+}
+
+/* Output a symbol we can use to refer to this DIE from another CU.  */
+
+static inline void
+output_die_symbol (die)
+     register dw_die_ref die;
+{
+  char *sym = die->die_symbol;
+
+  if (sym == 0)
+    return;
+
+  if (strncmp (sym, DIE_LABEL_PREFIX, sizeof (DIE_LABEL_PREFIX) - 1) == 0)
+    /* We make these global, not weak; if the target doesn't support
+       .linkonce, it doesn't support combining the sections, so debugging
+       will break.  */
+    ASM_GLOBALIZE_LABEL (asm_out_file, sym);
+  ASM_OUTPUT_LABEL (asm_out_file, sym);
+}
+
+/* Output a symbolic (i.e. FORM_ref_addr) reference to TARGET_DIE.  */
+
+static inline void
+output_symbolic_ref (target_die)
+     dw_die_ref target_die;
+{
+  char *sym = target_die->die_symbol;
+
+  if (sym == 0)
+    abort ();
+
+  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, sym);
 }
 
 /* Output the DIE and its attributes.  Called recursively to generate
@@ -5018,7 +5901,11 @@ output_die (die)
   register dw_attr_ref a;
   register dw_die_ref c;
   register unsigned long size;
-  register dw_loc_descr_ref loc;
+
+  /* If someone in another CU might refer to us, set up a symbol for
+     them to point to.  */
+  if (die->die_symbol)
+    output_die_symbol (die);
 
   output_uleb128 (die->die_abbrev);
   if (flag_debug_asm)
@@ -5056,23 +5943,15 @@ output_die (die)
                     ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
 
          fputc ('\n', asm_out_file);
-         for (loc = AT_loc (a); loc != NULL; loc = loc->dw_loc_next)
-           {
-             /* Output the opcode.  */
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, loc->dw_loc_opc);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START,
-                        dwarf_stack_op_name (loc->dw_loc_opc));
 
-             fputc ('\n', asm_out_file);
-
-             /* Output the operand(s) (if any).  */
-             output_loc_operands (loc);
-           }
+         output_loc_sequence (AT_loc (a));
          break;
 
        case dw_val_class_const:
-         ASM_OUTPUT_DWARF_DATA4 (asm_out_file, AT_int (a));
+         /* ??? It would be slightly more efficient to use a scheme like is
+            used for unsigned constants below, but gdb 4.x does not sign
+            extend.  Gdb 5.x does sign extend.  */
+         output_sleb128 (AT_int (a));
          break;
 
        case dw_val_class_unsigned_const:
@@ -5088,9 +5967,7 @@ output_die (die)
              ASM_OUTPUT_DWARF_DATA4 (asm_out_file, AT_unsigned (a));
              break;
            case 8:
-             ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
-                                     a->dw_attr_val.v.val_long_long.hi,
-                                     a->dw_attr_val.v.val_long_long.low);
+             ASM_OUTPUT_DWARF_DATA8 (asm_out_file, AT_unsigned (a));
              break;
            default:
              abort ();
@@ -5101,17 +5978,17 @@ output_die (die)
          ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 8);
          if (flag_debug_asm)
            fprintf (asm_out_file, "\t%s %s",
-                  ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
+                    ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
 
          fputc ('\n', asm_out_file);
-         ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
-                                 a->dw_attr_val.v.val_long_long.hi,
-                                 a->dw_attr_val.v.val_long_long.low);
+         ASM_OUTPUT_DWARF_CONST_DOUBLE (asm_out_file,
+                                        a->dw_attr_val.v.val_long_long.hi,
+                                        a->dw_attr_val.v.val_long_long.low);
 
          if (flag_debug_asm)
            fprintf (asm_out_file,
                     "\t%s long long constant", ASM_COMMENT_START);
-         
+
          fputc ('\n', asm_out_file);
          break;
 
@@ -5135,7 +6012,7 @@ output_die (die)
 
                fputc ('\n', asm_out_file);
              }
-         break;
+           break;
          }
 
        case dw_val_class_flag:
@@ -5143,7 +6020,10 @@ output_die (die)
          break;
 
        case dw_val_class_die_ref:
-         ASM_OUTPUT_DWARF_DATA (asm_out_file, AT_ref (a)->die_offset);
+         if (AT_ref_external (a))
+           output_symbolic_ref (AT_ref (a));
+         else
+           ASM_OUTPUT_DWARF_DATA (asm_out_file, AT_ref (a)->die_offset);
          break;
 
        case dw_val_class_fde_ref:
@@ -5193,7 +6073,7 @@ output_die (die)
 
   if (die->die_child != NULL)
     {
-      /* Add null byte to terminate sibling list. */
+      /* Add null byte to terminate sibling list.  */
       ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
       if (flag_debug_asm)
        fprintf (asm_out_file, "\t%s end of children of DIE 0x%lx",
@@ -5233,6 +6113,48 @@ output_compilation_unit_header ()
   fputc ('\n', asm_out_file);
 }
 
+/* Output the compilation unit DIE and its children.  */
+
+static void
+output_comp_unit (die)
+     dw_die_ref die;
+{
+  const char *secname;
+
+  if (die->die_child == 0)
+    return;
+
+  /* Mark all the DIEs in this CU so we know which get local refs.  */
+  mark_dies (die);
+
+  build_abbrev_table (die);
+
+  /* Initialize the beginning DIE offset - and calculate sizes/offsets.   */
+  next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
+  calc_die_sizes (die);
+
+  if (die->die_symbol)
+    {
+      char *tmp = (char *) alloca (strlen (die->die_symbol) + 24);
+      sprintf (tmp, ".gnu.linkonce.wi.%s", die->die_symbol);
+      secname = tmp;
+      die->die_symbol = NULL;
+    }
+  else
+    secname = (const char *) DEBUG_INFO_SECTION;
+
+  /* Output debugging information.  */
+  fputc ('\n', asm_out_file);
+  ASM_OUTPUT_SECTION (asm_out_file, secname);
+  output_compilation_unit_header ();
+  output_die (die);
+
+  /* Leave the marks on the main CU, so we can check them in
+     output_pubnames.  */
+  if (die->die_symbol)
+    unmark_dies (die);
+}
+
 /* The DWARF2 pubname for a nested thingy looks like "A::f".  The output
    of decl_printable_name for C++ looks like "A::f(int)".  Let's drop the
    argument list, and maybe the scope.  */
@@ -5308,6 +6230,10 @@ output_pubnames ()
     {
       register pubname_ref pub = &pubname_table[i];
 
+      /* We shouldn't see pubnames for DIEs outside of the main CU.  */
+      if (pub->die->die_mark == 0)
+       abort ();
+
       ASM_OUTPUT_DWARF_DATA (asm_out_file, pub->die->die_offset);
       if (flag_debug_asm)
        fprintf (asm_out_file, "\t%s DIE offset", ASM_COMMENT_START);
@@ -5399,10 +6325,10 @@ output_aranges ()
          for any pointer size.  */
       ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
       for (i = 2; i < DWARF_ARANGES_PAD_SIZE; i += 2)
-        fprintf (asm_out_file, ",0");
+       fprintf (asm_out_file, ",0");
       if (flag_debug_asm)
-        fprintf (asm_out_file, "\t%s Pad to %d byte boundary",
-                 ASM_COMMENT_START, 2 * DWARF2_ADDR_SIZE);
+       fprintf (asm_out_file, "\t%s Pad to %d byte boundary",
+                ASM_COMMENT_START, 2 * DWARF2_ADDR_SIZE);
     }
 
   fputc ('\n', asm_out_file);
@@ -5421,6 +6347,10 @@ output_aranges ()
     {
       dw_die_ref die = arange_table[i];
 
+      /* We shouldn't see aranges for DIEs outside of the main CU.  */
+      if (die->die_mark == 0)
+       abort ();
+
       if (die->die_tag == DW_TAG_subprogram)
        ASM_OUTPUT_DWARF_ADDR (asm_out_file, get_AT_low_pc (die));
       else
@@ -5466,6 +6396,314 @@ output_aranges ()
   fputc ('\n', asm_out_file);
 }
 
+
+/* Data structure containing information about input files.  */
+struct file_info
+{
+  char *path;          /* Complete file name.  */
+  char *fname;         /* File name part.  */
+  int length;          /* Length of entire string.  */
+  int file_idx;                /* Index in input file table.  */
+  int dir_idx;         /* Index in directory table.  */
+};
+
+/* Data structure containing information about directories with source
+   files.  */
+struct dir_info
+{
+  char *path;          /* Path including directory name.  */
+  int length;          /* Path length.  */
+  int prefix;          /* Index of directory entry which is a prefix.  */
+  int nbytes;          /* Total number of bytes in all file names excluding
+                          paths.  */
+  int count;           /* Number of files in this directory.  */
+  int dir_idx;         /* Index of directory used as base.  */
+  int used;            /* Used in the end?  */
+};
+
+/* Callback function for file_info comparison.  We sort by looking at
+   the directories in the path.  */
+static int
+file_info_cmp (p1, p2)
+     const void *p1;
+     const void *p2;
+{
+  const struct file_info *s1 = p1;
+  const struct file_info *s2 = p2;
+  unsigned char *cp1;
+  unsigned char *cp2;
+
+  /* Take care of file names without directories.  */
+  if (s1->path == s1->fname)
+    return -1;
+  else if (s2->path == s2->fname)
+    return 1;
+
+  cp1 = (unsigned char *) s1->path;
+  cp2 = (unsigned char *) s2->path;
+
+  while (1)
+    {
+      ++cp1;
+      ++cp2;
+      /* Reached the end of the first path?  */
+      if (cp1 == (unsigned char *) s1->fname)
+       /* It doesn't really matter in which order files from the
+          same directory are sorted in.  Therefore don't test for
+          the second path reaching the end.  */
+       return -1;
+      else if (cp2 == (unsigned char *) s2->fname)
+       return 1;
+
+      /* Character of current path component the same?  */
+      if (*cp1 != *cp2)
+       return *cp1 - *cp2;
+    }
+}
+
+/* Output the directory table and the file name table.  We try to minimize
+   the total amount of memory needed.  A heuristic is used to avoid large
+   slowdowns with many input files.  */
+static void
+output_file_names ()
+{
+  struct file_info *files;
+  struct dir_info *dirs;
+  int *saved;
+  int *savehere;
+  int *backmap;
+  int ndirs;
+  int idx_offset;
+  int i;
+  int idx;
+
+  /* Allocate the various arrays we need.  */
+  files = (struct file_info *) alloca (line_file_table.in_use
+                                      * sizeof (struct file_info));
+  dirs = (struct dir_info *) alloca (line_file_table.in_use
+                                    * sizeof (struct dir_info));
+
+  /* Sort the file names.  */
+   for (i = 1; i < (int) line_file_table.in_use; ++i)
+    {
+      char *f;
+
+      /* Skip all leading "./".  */
+      f = line_file_table.table[i];
+      while (f[0] == '.' && f[1] == '/')
+       f += 2;
+
+      /* Create a new array entry.  */
+      files[i].path = f;
+      files[i].length = strlen (f);
+      files[i].file_idx = i;
+
+      /* Search for the file name part.  */
+      f = strrchr (f, '/');
+      files[i].fname = f == NULL ? files[i].path : f + 1;
+    }
+  qsort (files + 1, line_file_table.in_use - 1, sizeof (files[0]),
+        file_info_cmp);
+
+  /* Find all the different directories used.  */
+  dirs[0].path = files[1].path;
+  dirs[0].length = files[1].fname - files[1].path;
+  dirs[0].prefix = -1;
+  dirs[0].nbytes = files[1].length - dirs[1].length + 1;
+  dirs[0].count = 1;
+  dirs[0].dir_idx = 0;
+  dirs[0].used = 0;
+  files[1].dir_idx = 0;
+  ndirs = 1;
+
+  for (i = 2; i < (int) line_file_table.in_use; ++i)
+    if (files[i].fname - files[i].path == dirs[ndirs - 1].length
+       && memcmp (dirs[ndirs - 1].path, files[i].path,
+                  dirs[ndirs - 1].length) == 0)
+      {
+       /* Same directory as last entry.  */
+       files[i].dir_idx = ndirs - 1;
+       dirs[ndirs - 1].nbytes += files[i].length - dirs[ndirs - 1].length + 1;
+       ++dirs[ndirs - 1].count;
+      }
+    else
+      {
+       int j;
+
+       /* This is a new directory.  */
+       dirs[ndirs].path = files[i].path;
+       dirs[ndirs].length = files[i].fname - files[i].path;
+       dirs[ndirs].nbytes = files[i].length - dirs[i].length + 1;
+       dirs[ndirs].count = 1;
+       dirs[ndirs].dir_idx = ndirs;
+       dirs[ndirs].used = 0;
+       files[i].dir_idx = ndirs;
+
+       /* Search for a prefix.  */
+       dirs[ndirs].prefix = -1;
+       for (j = 0; j < ndirs; ++j)
+         if (dirs[j].length < dirs[ndirs].length
+             && dirs[j].length != 0
+             && memcmp (dirs[j].path, dirs[ndirs].path, dirs[j].length) == 0)
+           dirs[ndirs].prefix = j;
+
+       ++ndirs;
+      }
+
+  /* Now to the actual work.  We have to find a subset of the
+     directories which allow expressing the file name using references
+     to the directory table with the least amount of characters.  We
+     do not do an exhaustive search where we would have to check out
+     every combination of every single possible prefix.  Instead we
+     use a heuristic which provides nearly optimal results in most
+     cases and never is much off.  */
+  saved = (int *) alloca (ndirs * sizeof (int));
+  savehere = (int *) alloca (ndirs * sizeof (int));
+
+  memset (saved, '\0', ndirs * sizeof (saved[0]));
+  for (i = 0; i < ndirs; ++i)
+    {
+      int j;
+      int total;
+
+      /* We can always safe some space for the current directory.  But
+        this does not mean it will be enough to justify adding the
+        directory.  */
+      savehere[i] = dirs[i].length;
+      total = (savehere[i] - saved[i]) * dirs[i].count;
+
+      for (j = i + 1; j < ndirs; ++j)
+       {
+         savehere[j] = 0;
+
+         if (saved[j] < dirs[i].length)
+           {
+             /* Determine whether the dirs[i] path is a prefix of the
+                dirs[j] path.  */
+             int k;
+
+              k = dirs[j].prefix;
+              while (k != -1 && k != i)
+                k = dirs[k].prefix;
+
+              if (k == i)
+                {
+                  /* Yes it is.  We can possibly safe some memory but
+                     writing the filenames in dirs[j] relative to
+                     dirs[i].  */
+                  savehere[j] = dirs[i].length;
+                  total += (savehere[j] - saved[j]) * dirs[j].count;
+                }
+           }
+       }
+
+      /* Check whether we can safe enough to justify adding the dirs[i]
+        directory.  */
+      if (total > dirs[i].length + 1)
+       {
+          /* It's worthwhile adding.  */
+          for (j = i; j < ndirs; ++j)
+           if (savehere[j] > 0)
+             {
+               /* Remember how much we saved for this directory so far.  */
+               saved[j] = savehere[j];
+
+               /* Remember the prefix directory.  */
+               dirs[j].dir_idx = i;
+             }
+       }
+    }
+
+  /* We have to emit them in the order they appear in the line_file_table
+     array since the index is used in the debug info generation.  To
+     do this efficiently we generate a back-mapping of the indices
+     first.  */
+  backmap = (int *) alloca (line_file_table.in_use * sizeof (int));
+  for (i = 1; i < (int) line_file_table.in_use; ++i)
+    {
+      backmap[files[i].file_idx] = i;
+      /* Mark this directory as used.  */
+      dirs[dirs[files[i].dir_idx].dir_idx].used = 1;
+    }
+
+  /* That was it.  We are ready to emit the information.  First the
+     directory name table.  Here we have to make sure that the first
+     actually emitted directory name has the index one.  Zero is
+     reserved for the current working directory.  Make sure we do not
+     confuse these indices with the one for the constructed table
+     (even though most of the time they are identical).  */
+  idx = 1;
+  idx_offset = dirs[0].path[0] == '/' ? 1 : 0;
+  for (i = 1 - idx_offset; i < ndirs; ++i)
+    if (dirs[i].used != 0)
+      {
+       dirs[i].used = idx++;
+
+       if (flag_debug_asm)
+         {
+           ASM_OUTPUT_DWARF_NSTRING (asm_out_file,
+                                     dirs[i].path, dirs[i].length - 1);
+           fprintf (asm_out_file, "%s Directory Entry: 0x%x\n",
+                    ASM_COMMENT_START, dirs[i].used);
+         }
+       else
+         {
+           ASM_OUTPUT_ASCII (asm_out_file, dirs[i].path, dirs[i].length - 1);
+           ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
+           fputc ('\n', asm_out_file);
+         }
+      }
+  /* Correct the index for the current working directory entry if it
+     exists.  */
+  if (idx_offset == 0)
+    dirs[0].used = 0;
+  /* Terminate the directory name array.  */
+  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
+  if (flag_debug_asm)
+    fprintf (asm_out_file, "\t%s End directory table", ASM_COMMENT_START);
+  fputc ('\n', asm_out_file);
+
+  /* Now write all the file names.  */
+  for (i = 1; i < (int) line_file_table.in_use; ++i)
+    {
+      int file_idx = backmap[i];
+      int dir_idx = dirs[files[file_idx].dir_idx].dir_idx;
+
+      if (flag_debug_asm)
+       {
+         ASM_OUTPUT_DWARF_STRING (asm_out_file,
+                                  files[file_idx].path
+                                  + dirs[dir_idx].length);
+         fprintf (asm_out_file, "%s File Entry: 0x%x\n",
+                  ASM_COMMENT_START, i);
+       }
+      else
+       ASM_OUTPUT_ASCII (asm_out_file,
+                         files[file_idx].path + dirs[dir_idx].length,
+                         (files[file_idx].length
+                          - dirs[dir_idx].length) + 1);
+
+      /* Include directory index.  */
+      output_uleb128 (dirs[dir_idx].used);
+      fputc ('\n', asm_out_file);
+
+      /* Modification time.  */
+      output_uleb128 (0);
+      fputc ('\n', asm_out_file);
+
+      /* File length in bytes.  */
+      output_uleb128 (0);
+      fputc ('\n', asm_out_file);
+    }
+
+  /* Terminate the file name table */
+  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
+  if (flag_debug_asm)
+    fprintf (asm_out_file, "\t%s End file name table", ASM_COMMENT_START);
+  fputc ('\n', asm_out_file);
+}
+
+
 /* Output the source line number correspondence information.  This
    information goes into the .debug_line section.  */
 
@@ -5476,7 +6714,6 @@ output_line_info ()
   char prev_line_label[MAX_ARTIFICIAL_LABEL_BYTES];
   register unsigned opc;
   register unsigned n_op_args;
-  register unsigned long ft_index;
   register unsigned long lt_index;
   register unsigned long current_line;
   register long line_offset;
@@ -5513,19 +6750,19 @@ output_line_info ()
             ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  fprintf (asm_out_file, "\t%s\t%d", ASM_BYTE_OP, DWARF_LINE_BASE);
+  fprintf (asm_out_file, "%s%d", ASM_BYTE_OP, DWARF_LINE_BASE);
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Line Base Value (Special Opcodes)",
             ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_RANGE);
+  fprintf (asm_out_file, "%s%u", ASM_BYTE_OP, DWARF_LINE_RANGE);
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Line Range Value (Special Opcodes)",
             ASM_COMMENT_START);
 
   fputc ('\n', asm_out_file);
-  fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_OPCODE_BASE);
+  fprintf (asm_out_file, "%s%u", ASM_BYTE_OP, DWARF_LINE_OPCODE_BASE);
   if (flag_debug_asm)
     fprintf (asm_out_file, "\t%s Special Opcode Base", ASM_COMMENT_START);
 
@@ -5552,48 +6789,8 @@ output_line_info ()
       fputc ('\n', asm_out_file);
     }
 
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "%s Include Directory Table\n", ASM_COMMENT_START);
-
-  /* Include directory table is empty, at present */
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-  fputc ('\n', asm_out_file);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "%s File Name Table\n", ASM_COMMENT_START);
-
-  for (ft_index = 1; ft_index < file_table_in_use; ++ft_index)
-    {
-      if (flag_debug_asm)
-       {
-         ASM_OUTPUT_DWARF_STRING (asm_out_file, file_table[ft_index]);
-         fprintf (asm_out_file, "%s File Entry: 0x%lx",
-                  ASM_COMMENT_START, ft_index);
-       }
-      else
-       {
-         ASM_OUTPUT_ASCII (asm_out_file,
-                           file_table[ft_index],
-                           (int) strlen (file_table[ft_index]) + 1);
-       }
-
-      fputc ('\n', asm_out_file);
-
-      /* Include directory index */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
-
-      /* Modification time */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
-
-      /* File length in bytes */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
-    }
-
-  /* Terminate the file name table */
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-  fputc ('\n', asm_out_file);
+  /* Write out the information about the files we use.  */
+  output_file_names ();
 
   /* We used to set the address register to the first location in the text
      section here, but that didn't accomplish anything since we already
@@ -5674,7 +6871,8 @@ output_line_info ()
          fputc ('\n', asm_out_file);
          output_uleb128 (current_file);
          if (flag_debug_asm)
-           fprintf (asm_out_file, " (\"%s\")", file_table[current_file]);
+           fprintf (asm_out_file, " (\"%s\")",
+                    line_file_table.table[current_file]);
 
          fputc ('\n', asm_out_file);
        }
@@ -5766,7 +6964,7 @@ output_line_info ()
   function = 0;
   current_file = 1;
   current_line = 1;
-  for (lt_index = 0; lt_index < separate_line_info_table_in_use; )
+  for (lt_index = 0; lt_index < separate_line_info_table_in_use;)
     {
       register dw_separate_line_info_ref line_info
        = &separate_line_info_table[lt_index];
@@ -5846,7 +7044,8 @@ output_line_info ()
          fputc ('\n', asm_out_file);
          output_uleb128 (current_file);
          if (flag_debug_asm)
-           fprintf (asm_out_file, " (\"%s\")", file_table[current_file]);
+           fprintf (asm_out_file, " (\"%s\")",
+                    line_file_table.table[current_file]);
 
          fputc ('\n', asm_out_file);
        }
@@ -5986,7 +7185,7 @@ base_type_die (type)
     case INTEGER_TYPE:
       /* Carefully distinguish the C character types, without messing
          up if the language is not C. Note that we check only for the names
-         that contain spaces; other names might occur by coincidence in other 
+         that contain spaces; other names might occur by coincidence in other
          languages.  */
       if (! (TYPE_PRECISION (type) == CHAR_TYPE_SIZE
             && (type == char_type_node
@@ -5999,7 +7198,7 @@ base_type_die (type)
            encoding = DW_ATE_signed;
          break;
        }
-      /* else fall through */
+      /* else fall through */
 
     case CHAR_TYPE:
       /* GNU Pascal/Ada CHAR type.  Not used in C.  */
@@ -6136,7 +7335,7 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
       if (mod_type_die)
        return mod_type_die;
 
-      /* Handle C typedef types. */
+      /* Handle C typedef types.  */
       if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
          && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
        {
@@ -6160,7 +7359,8 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
        }
 
       if (mod_type_die)
-       /* OK */;
+       /* OK.  */
+       ;
       else if (is_const_type)
        {
          mod_type_die = new_die (DW_TAG_const_type, comp_unit_die);
@@ -6186,7 +7386,7 @@ modified_type_die (type, is_const_type, is_volatile_type, context_die)
          add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE);
 #if 0
          add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
-#endif 
+#endif
          item_type = TREE_TYPE (type);
        }
       else if (is_base_type (type))
@@ -6234,6 +7434,24 @@ type_is_enum (type)
   return TREE_CODE (type) == ENUMERAL_TYPE;
 }
 
+/* Return the register number described by a given RTL node.  */
+
+static unsigned int
+reg_number (rtl)
+     register rtx rtl;
+{
+  register unsigned regno = REGNO (rtl);
+
+  if (regno >= FIRST_PSEUDO_REGISTER)
+    {
+      warning ("internal regno botch: regno = %d\n", regno);
+      regno = 0;
+    }
+
+  regno = DBX_REGISTER_NUMBER (regno);
+  return regno;
+}
+
 /* Return a location descriptor that designates a machine register.  */
 
 static dw_loc_descr_ref
@@ -6251,6 +7469,46 @@ reg_loc_descriptor (rtl)
   return loc_result;
 }
 
+/* Return a location descriptor that designates a constant.  */
+
+static dw_loc_descr_ref
+int_loc_descriptor (i)
+     HOST_WIDE_INT i;
+{
+  enum dwarf_location_atom op;
+
+  /* Pick the smallest representation of a constant, rather than just
+     defaulting to the LEB encoding.  */
+  if (i >= 0)
+    {
+      if (i <= 31)
+       op = DW_OP_lit0 + i;
+      else if (i <= 0xff)
+       op = DW_OP_const1u;
+      else if (i <= 0xffff)
+       op = DW_OP_const2u;
+      else if (HOST_BITS_PER_WIDE_INT == 32
+              || i <= 0xffffffff)
+       op = DW_OP_const4u;
+      else
+       op = DW_OP_constu;
+    }
+  else
+    {
+      if (i >= -0x80)
+       op = DW_OP_const1s;
+      else if (i >= -0x8000)
+       op = DW_OP_const2s;
+      else if (HOST_BITS_PER_WIDE_INT == 32
+              || i >= -0x80000000)
+       op = DW_OP_const4s;
+      else
+       op = DW_OP_consts;
+    }
+
+  return new_loc_descr (op, i, 0);
+}
+
 /* Return a location descriptor that designates a base+offset location.  */
 
 static dw_loc_descr_ref
@@ -6306,7 +7564,7 @@ mem_loc_descriptor (rtl, mode)
      enum machine_mode mode;
 {
   dw_loc_descr_ref mem_loc_result = NULL;
-  /* Note that for a dynamically sized array, the location we will generate a 
+  /* Note that for a dynamically sized array, the location we will generate a
      description of here will be the lowest numbered location which is
      actually within the array.  That's *not* necessarily the same as the
      zeroth element of the array.  */
@@ -6322,7 +7580,7 @@ mem_loc_descriptor (rtl, mode)
       /* POST_INC and POST_DEC can be handled just like a SUBREG.  So we
         just fall into the SUBREG code.  */
 
-      /* ... fall through ... */
+      /* Fall through.  */
 
     case SUBREG:
       /* The case of a subreg may arise when we have a local (register)
@@ -6332,12 +7590,12 @@ mem_loc_descriptor (rtl, mode)
          contains the given subreg.  */
       rtl = XEXP (rtl, 0);
 
-      /* ... fall through ... */
+      /* Fall through.  */
 
     case REG:
       /* Whenever a register number forms a part of the description of the
          method for calculating the (dynamic) address of a memory resident
-         object, DWARF rules require the register number be referred to as 
+         object, DWARF rules require the register number be referred to as
          a "base register".  This distinction is not based in any way upon
          what category of register the hardware believes the given register
          belongs to.  This is strictly DWARF terminology we're dealing with
@@ -6352,12 +7610,22 @@ mem_loc_descriptor (rtl, mode)
       break;
 
     case MEM:
-      mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
-      add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
+      {
+       dw_loc_descr_ref deref;
+
+       mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl));
+
+       if (GET_MODE_SIZE (mode) == DWARF2_ADDR_SIZE)
+         deref = new_loc_descr (DW_OP_deref, 0, 0);
+       else
+         deref = new_loc_descr (DW_OP_deref_size, GET_MODE_SIZE (mode), 0);
+
+       add_loc_descr (&mem_loc_result, deref);
+      }
       break;
 
-     case LABEL_REF:
-       /* Some ports can transform a symbol ref into a label ref, because
+    case LABEL_REF:
+      /* Some ports can transform a symbol ref into a label ref, because
         the symbol ref is too far away and has to be dumped into a constant
         pool.  */
     case CONST:
@@ -6373,10 +7641,10 @@ mem_loc_descriptor (rtl, mode)
         below.  */
       rtl = gen_rtx_PLUS (word_mode, XEXP (rtl, 0),
                          GEN_INT (GET_CODE (rtl) == PRE_INC
-                                  ? GET_MODE_UNIT_SIZE (mode) 
-                                  : - GET_MODE_UNIT_SIZE (mode)));
-                         
-      /* ... fall through ... */
+                                  ? GET_MODE_UNIT_SIZE (mode)
+                                  : -GET_MODE_UNIT_SIZE (mode)));
+
+      /* Fall through.  */
 
     case PLUS:
       if (is_based_loc (rtl))
@@ -6384,24 +7652,37 @@ mem_loc_descriptor (rtl, mode)
                                          INTVAL (XEXP (rtl, 1)));
       else
        {
-         add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 0),
-                                                             mode));
-         add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 1),
-                                                             mode));
-         add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_plus, 0, 0));
+         mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode);
+
+         if (GET_CODE (XEXP (rtl, 1)) == CONST_INT
+             && INTVAL (XEXP (rtl, 1)) >= 0)
+           {
+             add_loc_descr (&mem_loc_result,
+                            new_loc_descr (DW_OP_plus_uconst,
+                                           INTVAL (XEXP (rtl, 1)), 0));
+           }
+         else
+           {
+             add_loc_descr (&mem_loc_result,
+                            mem_loc_descriptor (XEXP (rtl, 1), mode));
+             add_loc_descr (&mem_loc_result,
+                            new_loc_descr (DW_OP_plus, 0, 0));
+           }
        }
       break;
 
     case MULT:
       /* If a pseudo-reg is optimized away, it is possible for it to
         be replaced with a MEM containing a multiply.  */
-      add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 0), mode));
-      add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 1), mode));
+      add_loc_descr (&mem_loc_result,
+                    mem_loc_descriptor (XEXP (rtl, 0), mode));
+      add_loc_descr (&mem_loc_result,
+                    mem_loc_descriptor (XEXP (rtl, 1), mode));
       add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_mul, 0, 0));
       break;
 
     case CONST_INT:
-      mem_loc_result = new_loc_descr (DW_OP_constu, INTVAL (rtl), 0);
+      mem_loc_result = int_loc_descriptor (INTVAL (rtl));
       break;
 
     default:
@@ -6456,7 +7737,7 @@ loc_descriptor (rtl)
          contains the given subreg.  */
       rtl = XEXP (rtl, 0);
 
-      /* ... fall through ... */
+      /* Fall through.  */
 
     case REG:
       loc_result = reg_loc_descriptor (rtl);
@@ -6477,6 +7758,262 @@ loc_descriptor (rtl)
   return loc_result;
 }
 
+/* Similar, but generate the descriptor from trees instead of rtl.
+   This comes up particularly with variable length arrays.  */
+
+static dw_loc_descr_ref
+loc_descriptor_from_tree (loc, addressp)
+     tree loc;
+     int addressp;
+{
+  dw_loc_descr_ref ret = NULL;
+  int indirect_size = 0;
+  int unsignedp = TREE_UNSIGNED (TREE_TYPE (loc));
+  enum dwarf_location_atom op;
+
+  /* ??? Most of the time we do not take proper care for sign/zero
+     extending the values properly.  Hopefully this won't be a real
+     problem...  */
+
+  switch (TREE_CODE (loc))
+    {
+    case ERROR_MARK:
+      break;
+
+    case VAR_DECL:
+    case PARM_DECL:
+      {
+       rtx rtl = rtl_for_decl_location (loc);
+       enum machine_mode mode = DECL_MODE (loc);
+
+       if (rtl == NULL_RTX)
+         break;
+       else if (CONSTANT_P (rtl))
+         {
+           ret = new_loc_descr (DW_OP_addr, 0, 0);
+           ret->dw_loc_oprnd1.val_class = dw_val_class_addr;
+           ret->dw_loc_oprnd1.v.val_addr = rtl;
+           indirect_size = GET_MODE_SIZE (mode);
+         }
+       else
+         {
+           if (GET_CODE (rtl) == MEM)
+             {
+               indirect_size = GET_MODE_SIZE (mode);
+               rtl = XEXP (rtl, 0);
+             }
+           ret = mem_loc_descriptor (rtl, mode);
+         }
+      }
+      break;
+
+    case INDIRECT_REF:
+      ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+      indirect_size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (loc)));
+      break;
+
+    case COMPONENT_REF:
+    case BIT_FIELD_REF:
+    case ARRAY_REF:
+      {
+       tree obj, offset;
+       HOST_WIDE_INT bitsize, bitpos, bytepos;
+       enum machine_mode mode;
+       int volatilep;
+       unsigned int alignment;
+
+       obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode,
+                                  &unsignedp, &volatilep, &alignment);
+       ret = loc_descriptor_from_tree (obj, 1);
+
+       if (offset != NULL_TREE)
+         {
+           /* Variable offset.  */
+           add_loc_descr (&ret, loc_descriptor_from_tree (offset, 0));
+           add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
+         }
+
+       if (addressp)
+         {
+           /* We cannot address anything not on a unit boundary.  */
+           if (bitpos % BITS_PER_UNIT != 0)
+             abort ();
+         }
+       else
+         {
+           if (bitpos % BITS_PER_UNIT != 0
+               || bitsize % BITS_PER_UNIT != 0)
+             {
+               /* ??? We could handle this by loading and shifting etc.
+                  Wait until someone needs it before expending the effort.  */
+               abort ();
+             }
+
+           indirect_size = bitsize / BITS_PER_UNIT;
+         }
+
+       bytepos = bitpos / BITS_PER_UNIT;
+       if (bytepos > 0)
+         add_loc_descr (&ret, new_loc_descr (DW_OP_plus_uconst, bytepos, 0));
+       else if (bytepos < 0)
+         {
+           add_loc_descr (&ret, int_loc_descriptor (bytepos));
+           add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
+         }
+       break;
+      }
+
+    case INTEGER_CST:
+      if (host_integerp (loc, 0))
+       ret = int_loc_descriptor (tree_low_cst (loc, 0));
+      break;
+      break;
+
+    case BIT_AND_EXPR:
+      op = DW_OP_and;
+      goto do_binop;
+    case BIT_XOR_EXPR:
+      op = DW_OP_xor;
+      goto do_binop;
+    case BIT_IOR_EXPR:
+      op = DW_OP_or;
+      goto do_binop;
+    case TRUNC_DIV_EXPR:
+      op = DW_OP_div;
+      goto do_binop;
+    case MINUS_EXPR:
+      op = DW_OP_minus;
+      goto do_binop;
+    case TRUNC_MOD_EXPR:
+      op = DW_OP_mod;
+      goto do_binop;
+    case MULT_EXPR:
+      op = DW_OP_mul;
+      goto do_binop;
+    case LSHIFT_EXPR:
+      op = DW_OP_shl;
+      goto do_binop;
+    case RSHIFT_EXPR:
+      op = (unsignedp ? DW_OP_shr : DW_OP_shra);
+      goto do_binop;
+    case PLUS_EXPR:
+      if (TREE_CODE (TREE_OPERAND (loc, 1)) == INTEGER_CST
+         && host_integerp (TREE_OPERAND (loc, 1), 0))
+       {
+         ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+         add_loc_descr (&ret,
+                        new_loc_descr (DW_OP_plus_uconst,
+                                       tree_low_cst (TREE_OPERAND (loc, 1),
+                                                     0),
+                                       0));
+         break;
+       }
+      op = DW_OP_plus;
+      goto do_binop;
+    case LE_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_le;
+      goto do_binop;
+    case GE_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_ge;
+      goto do_binop;
+    case LT_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_lt;
+      goto do_binop;
+    case GT_EXPR:
+      if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
+       break;
+      op = DW_OP_gt;
+      goto do_binop;
+    case EQ_EXPR:
+      op = DW_OP_eq;
+      goto do_binop;
+    case NE_EXPR:
+      op = DW_OP_ne;
+      goto do_binop;
+
+    do_binop:
+      ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+      add_loc_descr (&ret, loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0));
+      add_loc_descr (&ret, new_loc_descr (op, 0, 0));
+      break;
+
+    case BIT_NOT_EXPR:
+      op = DW_OP_not;
+      goto do_unop;
+    case ABS_EXPR:
+      op = DW_OP_abs;
+      goto do_unop;
+    case NEGATE_EXPR:
+      op = DW_OP_neg;
+      goto do_unop;
+
+    do_unop:
+      ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+      add_loc_descr (&ret, new_loc_descr (op, 0, 0));
+      break;
+
+    case MAX_EXPR:
+      loc = build (COND_EXPR, TREE_TYPE (loc),
+                  build (LT_EXPR, integer_type_node,
+                         TREE_OPERAND (loc, 0), TREE_OPERAND (loc, 1)),
+                  TREE_OPERAND (loc, 1), TREE_OPERAND (loc, 0));
+      /* FALLTHRU */
+
+    case COND_EXPR:
+      {
+       dw_loc_descr_ref bra_node, jump_node, tmp;
+
+       ret = loc_descriptor_from_tree (TREE_OPERAND (loc, 0), 0);
+       bra_node = new_loc_descr (DW_OP_bra, 0, 0);
+       add_loc_descr (&ret, bra_node);
+
+       tmp = loc_descriptor_from_tree (TREE_OPERAND (loc, 2), 0);
+       add_loc_descr (&ret, tmp);
+       jump_node = new_loc_descr (DW_OP_skip, 0, 0);
+       add_loc_descr (&ret, jump_node);
+
+       tmp = loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0);
+       add_loc_descr (&ret, tmp);
+       bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
+       bra_node->dw_loc_oprnd1.v.val_loc = tmp;
+
+       /* ??? Need a node to point the skip at.  Use a nop.  */
+       tmp = new_loc_descr (DW_OP_nop, 0, 0);
+       add_loc_descr (&ret, tmp);
+       jump_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
+       jump_node->dw_loc_oprnd1.v.val_loc = tmp;
+      }
+      break;
+
+    default:
+      abort ();
+    }
+
+  /* If we can't fill the request for an address, die.  */
+  if (addressp && indirect_size == 0)
+    abort ();
+
+  /* If we've got an address and don't want one, dereference.  */
+  if (!addressp && indirect_size > 0)
+    {
+      if (indirect_size > DWARF2_ADDR_SIZE)
+       abort ();
+      if (indirect_size == DWARF2_ADDR_SIZE)
+       op = DW_OP_deref;
+      else
+       op = DW_OP_deref_size;
+      add_loc_descr (&ret, new_loc_descr (op, indirect_size, 0));
+    }
+
+  return ret;
+}
+
 /* Given a value, round it up to the lowest multiple of `boundary'
    which is not less than the value itself.  */
 
@@ -6531,17 +8068,17 @@ static inline unsigned HOST_WIDE_INT
 simple_type_size_in_bits (type)
      register tree type;
 {
+  tree type_size_tree;
+
   if (TREE_CODE (type) == ERROR_MARK)
     return BITS_PER_WORD;
-  else
-    {
-      register tree type_size_tree = TYPE_SIZE (type);
+  type_size_tree = TYPE_SIZE (type);
 
-      if (! host_integerp (type_size_tree, 1))
-       return TYPE_ALIGN (type);
-
-      return tree_low_cst (type_size_tree, 1);
-    }
+  if (type_size_tree == NULL_TREE)
+    return 0;
+  if (! host_integerp (type_size_tree, 1))
+    return TYPE_ALIGN (type);
+  return tree_low_cst (type_size_tree, 1);
 }
 
 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
@@ -6576,16 +8113,12 @@ field_byte_offset (decl)
   type = field_type (decl);
   field_size_tree = DECL_SIZE (decl);
 
-  /* If there was an error, the size could be zero.  */
+  /* The size could be unspecified if there was an error, or for
+     a flexible array member.  */
   if (! field_size_tree)
-    {
-      if (errorcount)
-       return 0;
-
-      abort ();
-    }
+    field_size_tree = bitsize_zero_node;
 
-  /* We cannot yet cope with fields whose positions are variable, so 
+  /* We cannot yet cope with fields whose positions are variable, so
      for now, when we see such things, we simply return 0.  Someday, we may
      be able to handle such cases, but it will be damn difficult.  */
   if (! host_integerp (bit_position (decl), 0))
@@ -6593,7 +8126,7 @@ field_byte_offset (decl)
 
   bitpos_int = int_bit_position (decl);
 
-    /* If we don't know the size of the field, pretend it's a full word.  */
+  /* If we don't know the size of the field, pretend it's a full word.  */
   if (host_integerp (field_size_tree, 1))
     field_size_in_bits = tree_low_cst (field_size_tree, 1);
   else
@@ -6607,7 +8140,7 @@ field_byte_offset (decl)
      the starting bit offset (relative to the start of the containing
      structure type) of the hypothetical "containing object" for a bit-
      field.  Thus, when computing the byte offset value for the start of the
-     "containing object" of a bit-field, we must deduce this information on 
+     "containing object" of a bit-field, we must deduce this information on
      our own. This can be rather tricky to do in some cases.  For example,
      handling the following structure type definition when compiling for an
      i386/i486 target (which only aligns long long's to 32-bit boundaries)
@@ -6617,7 +8150,7 @@ field_byte_offset (decl)
 
      Fortunately, there is a simple rule-of-thumb which can be
      used in such cases.  When compiling for an i386/i486, GCC will allocate
-     8 bytes for the structure shown above.  It decides to do this based upon 
+     8 bytes for the structure shown above.  It decides to do this based upon
      one simple rule for bit-field allocation.  Quite simply, GCC allocates
      each "containing object" for each bit-field at the first (i.e. lowest
      addressed) legitimate alignment boundary (based upon the required
@@ -6635,10 +8168,10 @@ field_byte_offset (decl)
      (As it turns out, for the example above, the compiler finds that it is
      OK to allocate the "containing object" 64-bit field at bit-offset zero
      within the structure type.) Here we attempt to work backwards from the
-     limited set of facts we're given, and we try to deduce from those facts, 
+     limited set of facts we're given, and we try to deduce from those facts,
      where GCC must have believed that the containing object started (within
-     the structure type). The value we deduce is then used (by the callers of 
-     this routine) to generate DW_AT_location and DW_AT_bit_offset attributes 
+     the structure type). The value we deduce is then used (by the callers of
+     this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
      for fields (both bit-fields and, in the case of DW_AT_location, regular
      fields as well).  */
 
@@ -6681,13 +8214,13 @@ add_AT_location_description (die, attr_kind, rtl)
      of existence will have a DECL_RTL value which denotes a pseudo-reg.
      Currently, in some rare cases, variables can have DECL_RTL values which
      look like (MEM (REG pseudo-reg#)).  These cases are due to bugs
-     elsewhere in the compiler.  We treat such cases as if the variable(s) in 
+     elsewhere in the compiler.  We treat such cases as if the variable(s) in
      question had been optimized out of existence.  */
 
   if (is_pseudo_reg (rtl)
       || (GET_CODE (rtl) == MEM
          && is_pseudo_reg (XEXP (rtl, 0)))
-      /* This can happen for a PARM_DECL with a DECL_INCOMING_RTL which 
+      /* This can happen for a PARM_DECL with a DECL_INCOMING_RTL which
         references the internal argument pointer (a pseudo) in a function
         where all references to the internal argument pointer were
         eliminated via the optimizers.  */
@@ -6783,8 +8316,8 @@ add_const_value_attribute (die, rtl)
 
        if (GET_MODE_CLASS (mode) == MODE_FLOAT)
          {
-           register unsigned length = GET_MODE_SIZE (mode) / sizeof (long);
-           long array[4];
+           register unsigned length = GET_MODE_SIZE (mode) / 4;
+           long *array = (long *) xmalloc (sizeof (long) * length);
            REAL_VALUE_TYPE rv;
 
            REAL_VALUE_FROM_CONST_DOUBLE (rv, rtl);
@@ -6832,10 +8365,10 @@ add_const_value_attribute (die, rtl)
          variable (for the inlining) which acts as a stand-in for the
          corresponding formal parameter (of the inline function) will look
          like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).  This is not
-         exactly a compile-time constant expression, but it isn't the address 
-         of the (artificial) local variable either.  Rather, it represents the 
+         exactly a compile-time constant expression, but it isn't the address
+         of the (artificial) local variable either.  Rather, it represents the
          *value* which the artificial local variable always has during its
-         lifetime.  We currently have no way to represent such quasi-constant 
+         lifetime.  We currently have no way to represent such quasi-constant
          values in Dwarf, so for now we just punt and generate nothing.  */
       break;
 
@@ -6846,39 +8379,19 @@ add_const_value_attribute (die, rtl)
 
 }
 
-/* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
-   data attribute for a variable or a parameter.  We generate the
-   DW_AT_const_value attribute only in those cases where the given variable
-   or parameter does not have a true "location" either in memory or in a
-   register.  This can happen (for example) when a constant is passed as an
-   actual argument in a call to an inline function.  (It's possible that
-   these things can crop up in other ways also.)  Note that one type of
-   constant value which can be passed into an inlined function is a constant
-   pointer.  This can happen for example if an actual argument in an inlined
-   function call evaluates to a compile-time constant address.  */
-
-static void
-add_location_or_const_value_attribute (die, decl)
-     register dw_die_ref die;
-     register tree decl;
+static rtx
+rtl_for_decl_location (decl)
+     tree decl;
 {
   register rtx rtl;
-  register tree declared_type;
-  register tree passed_type;
-
-  if (TREE_CODE (decl) == ERROR_MARK)
-    return;
-
-  if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
-    abort ();
 
   /* Here we have to decide where we are going to say the parameter "lives"
      (as far as the debugger is concerned).  We only have a couple of
      choices.  GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
 
-     DECL_RTL normally indicates where the parameter lives during most of the 
+     DECL_RTL normally indicates where the parameter lives during most of the
      activation of the function.  If optimization is enabled however, this
-     could be either NULL or else a pseudo-reg.  Both of those cases indicate 
+     could be either NULL or else a pseudo-reg.  Both of those cases indicate
      that the parameter doesn't really live anywhere (as far as the code
      generation parts of GCC are concerned) during most of the function's
      activation.  That will happen (for example) if the parameter is never
@@ -6954,8 +8467,8 @@ add_location_or_const_value_attribute (die, decl)
     {
       if (rtl == NULL_RTX || is_pseudo_reg (rtl))
        {
-         declared_type = type_main_variant (TREE_TYPE (decl));
-         passed_type = type_main_variant (DECL_ARG_TYPE (decl));
+         tree declared_type = type_main_variant (TREE_TYPE (decl));
+         tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
 
          /* This decl represents a formal parameter which was optimized out.
             Note that DECL_INCOMING_RTL may be NULL in here, but we handle
@@ -6966,7 +8479,7 @@ add_location_or_const_value_attribute (die, decl)
                   && TREE_CODE (declared_type) == INTEGER_TYPE
                   && (GET_MODE_SIZE (TYPE_MODE (declared_type))
                       <= GET_MODE_SIZE (TYPE_MODE (passed_type))))
-               rtl = DECL_INCOMING_RTL (decl);
+           rtl = DECL_INCOMING_RTL (decl);
        }
 
       /* If the parm was passed in registers, but lives on the stack, then
@@ -7002,14 +8515,45 @@ add_location_or_const_value_attribute (die, decl)
        }
     }
 
-  if (rtl == NULL_RTX)
-    return;
-
-  rtl = eliminate_regs (rtl, 0, NULL_RTX);
+  if (rtl != NULL_RTX)
+    {
+      rtl = eliminate_regs (rtl, 0, NULL_RTX);
 #ifdef LEAF_REG_REMAP
-  if (current_function_uses_only_leaf_regs)
-    leaf_renumber_regs_insn (rtl);
+      if (current_function_uses_only_leaf_regs)
+       leaf_renumber_regs_insn (rtl);
 #endif
+    }
+
+  return rtl;
+}
+
+/* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
+   data attribute for a variable or a parameter.  We generate the
+   DW_AT_const_value attribute only in those cases where the given variable
+   or parameter does not have a true "location" either in memory or in a
+   register.  This can happen (for example) when a constant is passed as an
+   actual argument in a call to an inline function.  (It's possible that
+   these things can crop up in other ways also.)  Note that one type of
+   constant value which can be passed into an inlined function is a constant
+   pointer.  This can happen for example if an actual argument in an inlined
+   function call evaluates to a compile-time constant address.  */
+
+static void
+add_location_or_const_value_attribute (die, decl)
+     register dw_die_ref die;
+     register tree decl;
+{
+  register rtx rtl;
+
+  if (TREE_CODE (decl) == ERROR_MARK)
+    return;
+
+  if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != PARM_DECL)
+    abort ();
+
+  rtl = rtl_for_decl_location (decl);
+  if (rtl == NULL_RTX)
+    return;
 
   switch (GET_CODE (rtl))
     {
@@ -7041,6 +8585,40 @@ add_location_or_const_value_attribute (die, decl)
     }
 }
 
+/* If we don't have a copy of this variable in memory for some reason (such
+   as a C++ member constant that doesn't have an out-of-line definition),
+   we should tell the debugger about the constant value.  */
+
+static void
+tree_add_const_value_attribute (var_die, decl)
+     dw_die_ref var_die;
+     tree decl;
+{
+  tree init = DECL_INITIAL (decl);
+  tree type = TREE_TYPE (decl);
+
+  if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) && init
+      && initializer_constant_valid_p (init, type) == null_pointer_node)
+    /* OK */;
+  else
+    return;
+
+  switch (TREE_CODE (type))
+    {
+    case INTEGER_TYPE:
+      if (host_integerp (init, 0))
+       add_AT_unsigned (var_die, DW_AT_const_value,
+                        TREE_INT_CST_LOW (init));
+      else
+       add_AT_long_long (var_die, DW_AT_const_value,
+                         TREE_INT_CST_HIGH (init),
+                         TREE_INT_CST_LOW (init));
+      break;
+
+    default:;
+    }
+}
+
 /* Generate an DW_AT_name attribute given some string value to be included as
    the value of the attribute.  */
 
@@ -7082,7 +8660,7 @@ add_bound_info (subrange_die, bound_attr, bound)
     case INTEGER_CST:
       if (! host_integerp (bound, 0)
          || (bound_attr == DW_AT_lower_bound
-             && ((is_c_family () && integer_zerop (bound))
+             && (((is_c_family () || is_java ()) &&  integer_zerop (bound))
                  || (is_fortran () && integer_onep (bound)))))
        /* use the default */
        ;
@@ -7095,7 +8673,7 @@ add_bound_info (subrange_die, bound_attr, bound)
     case NON_LVALUE_EXPR:
       add_bound_info (subrange_die, bound_attr, TREE_OPERAND (bound, 0));
       break;
-      
+
     case SAVE_EXPR:
       /* If optimization is turned on, the SAVE_EXPRs that describe how to
          access the upper bound values may be bogus.  If they refer to a
@@ -7146,15 +8724,43 @@ add_bound_info (subrange_die, bound_attr, bound)
       /* Else leave out the attribute.  */
       break;
 
-    case MAX_EXPR:
     case VAR_DECL:
-    case COMPONENT_REF:
-      /* ??? These types of bounds can be created by the Ada front end,
-        and it isn't clear how to emit debug info for them.  */
-      break;
+    case PARM_DECL:
+      {
+       dw_die_ref decl_die = lookup_decl_die (bound);
+
+       /* ??? Can this happen, or should the variable have been bound
+          first?  Probably it can, since I imagine that we try to create
+          the types of parameters in the order in which they exist in
+          the list, and won't have created a forward reference to a
+          later parameter.  */
+       if (decl_die != NULL)
+         add_AT_die_ref (subrange_die, bound_attr, decl_die);
+       break;
+      }
 
     default:
-      abort ();
+      {
+       /* Otherwise try to create a stack operation procedure to
+          evaluate the value of the array bound.  */
+
+       dw_die_ref ctx, decl_die;
+       dw_loc_descr_ref loc;
+
+       loc = loc_descriptor_from_tree (bound, 0);
+       if (loc == NULL)
+         break;
+
+       ctx = lookup_decl_die (current_function_decl);
+
+       decl_die = new_die (DW_TAG_variable, ctx);
+       add_AT_flag (decl_die, DW_AT_artificial, 1);
+       add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
+       add_AT_loc (decl_die, DW_AT_location, loc);
+
+       add_AT_die_ref (subrange_die, bound_attr, decl_die);
+       break;
+      }
     }
 }
 
@@ -7172,13 +8778,13 @@ add_subscript_info (type_die, type)
   register tree lower, upper;
   register dw_die_ref subrange_die;
 
-  /* The GNU compilers represent multidimensional array types as sequences of 
+  /* The GNU compilers represent multidimensional array types as sequences of
      one dimensional array types whose element types are themselves array
      types.  Here we squish that down, so that each multidimensional array
-     type gets only one array_type DIE in the Dwarf debugging info. The draft 
+     type gets only one array_type DIE in the Dwarf debugging info. The draft
      Dwarf specification say that we are allowed to do this kind of
      compression in C (because there is no difference between an array or
-     arrays and a multidimensional array in C) but for other source languages 
+     arrays and a multidimensional array in C) but for other source languages
      (e.g. Ada) we probably shouldn't do this.  */
 
   /* ??? The SGI dwarf reader fails for multidimensional arrays with a
@@ -7194,7 +8800,7 @@ add_subscript_info (type_die, type)
       register tree domain = TYPE_DOMAIN (type);
 
       /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
-        and (in GNU C only) variable bounds.  Handle all three forms 
+        and (in GNU C only) variable bounds.  Handle all three forms
          here.  */
       subrange_die = new_die (DW_TAG_subrange_type, type_die);
       if (domain)
@@ -7213,7 +8819,7 @@ add_subscript_info (type_die, type)
                  && TYPE_NAME (domain) == NULL_TREE
                  && TREE_CODE (TREE_TYPE (domain)) == INTEGER_TYPE
                  && TYPE_NAME (TREE_TYPE (domain)) == NULL_TREE)
-               ;       
+               ;
              else
                add_type_attribute (subrange_die, TREE_TYPE (domain), 0, 0,
                                    type_die);
@@ -7234,8 +8840,7 @@ add_subscript_info (type_die, type)
        /* We have an array type with an unspecified length.  The DWARF-2
             spec does not say how to handle this; let's just leave out the
             bounds.  */
-       {;}
-      
+        {;}
 
 #ifndef MIPS_DEBUGGING_INFO
     }
@@ -7323,8 +8928,8 @@ add_bit_offset_attribute (die, decl)
   bitpos_int = int_bit_position (decl);
 
   /* Note that the bit offset is always the distance (in bits) from the
-     highest-order bit of the "containing object" to the highest-order bit of 
-     the bit-field itself.  Since the "high-order end" of any object or field 
+     highest-order bit of the "containing object" to the highest-order bit of
+     the bit-field itself.  Since the "high-order end" of any object or field
      is different on big-endian and little-endian machines, the computation
      below must take account of these differences.  */
   highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
@@ -7374,7 +8979,6 @@ add_prototyped_attribute (die, func_type)
     add_AT_flag (die, DW_AT_prototyped, 1);
 }
 
-
 /* Add an 'abstract_origin' attribute below a given DIE.  The DIE is found
    by looking in either the type declaration or object declaration
    equate table.  */
@@ -7409,7 +9013,7 @@ add_abstract_origin_attribute (die, origin)
 
   if (origin_die == NULL)
     abort ();
-  
+
   add_AT_die_ref (die, DW_AT_abstract_origin, origin_die);
 }
 
@@ -7444,7 +9048,8 @@ add_src_coords_attributes (die, decl)
      register dw_die_ref die;
      register tree decl;
 {
-  register unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl));
+  register unsigned file_index = lookup_filename (&decl_file_table,
+                                                 DECL_SOURCE_FILE (decl));
 
   add_AT_unsigned (die, DW_AT_decl_file, file_index);
   add_AT_unsigned (die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
@@ -7460,7 +9065,7 @@ add_name_and_src_coords_attributes (die, decl)
 {
   register tree decl_name;
 
-  decl_name = DECL_NAME (decl); 
+  decl_name = DECL_NAME (decl);
   if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL)
     {
       add_name_attribute (die, dwarf2_name (decl, 0));
@@ -7475,7 +9080,7 @@ add_name_and_src_coords_attributes (die, decl)
     }
 }
 
-/* Push a new declaration scope. */
+/* Push a new declaration scope.  */
 
 static void
 push_decl_scope (scope)
@@ -7511,8 +9116,8 @@ pop_decl_scope ()
 
 static dw_die_ref
 scope_die_for (t, context_die)
-    register tree t; 
-    register dw_die_ref context_die;
+     register tree t;
+     register dw_die_ref context_die;
 {
   register dw_die_ref scope_die = NULL;
   register tree containing_scope;
@@ -7648,7 +9253,7 @@ type_tag (type)
       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
        t = TYPE_NAME (type);
 
-      /* The g++ front end makes the TYPE_NAME of *each* tagged type point to 
+      /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
          a TYPE_DECL node, regardless of whether or not a `typedef' was
          involved.  */
       else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
@@ -7935,7 +9540,6 @@ gen_enumeration_type_die (type, context_die)
     add_AT_flag (type_die, DW_AT_declaration, 1);
 }
 
-
 /* Generate a DIE to represent either a real live formal parameter decl or to
    represent just the type of some formal parameter position in some function
    type.
@@ -8023,20 +9627,20 @@ gen_formal_types_die (function_or_method_type, context_die)
      non-static member function type, skip over the first thing on the
      TYPE_ARG_TYPES list because it only represents the type of the hidden
      `this pointer'.  The debugger should be able to figure out (without
-     being explicitly told) that this non-static member function type takes a 
-     `this pointer' and should be able to figure what the type of that hidden 
+     being explicitly told) that this non-static member function type takes a
+     `this pointer' and should be able to figure what the type of that hidden
      parameter is from the DW_AT_member attribute of the parent
      DW_TAG_subroutine_type DIE.  */
   if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
     first_parm_type = TREE_CHAIN (first_parm_type);
 #endif
 
-  /* Make our first pass over the list of formal parameter types and output a 
+  /* Make our first pass over the list of formal parameter types and output a
      DW_TAG_formal_parameter DIE for each one.  */
   for (link = first_parm_type; link; link = TREE_CHAIN (link))
     {
       register dw_die_ref parm_die;
-      
+
       formal_type = TREE_VALUE (link);
       if (formal_type == void_type_node)
        break;
@@ -8053,7 +9657,7 @@ gen_formal_types_die (function_or_method_type, context_die)
   if (formal_type != void_type_node)
     gen_unspecified_parameters_die (function_or_method_type, context_die);
 
-  /* Make our second (and final) pass over the list of formal parameter types 
+  /* Make our second (and final) pass over the list of formal parameter types
      and output DIEs to represent those types (as necessary).  */
   for (link = TYPE_ARG_TYPES (function_or_method_type);
        link;
@@ -8160,6 +9764,11 @@ gen_subprogram_die (decl, context_die)
       if (declaration && ! local_scope_p (context_die))
        abort ();
 
+      /* Fixup die_parent for the abstract instance of a nested
+        inline function.  */
+      if (old_die && old_die->die_parent == NULL)
+       add_child_die (context_die, old_die);
+
       subr_die = new_die (DW_TAG_subprogram, context_die);
       add_abstract_origin_attribute (subr_die, origin);
     }
@@ -8177,7 +9786,7 @@ gen_subprogram_die (decl, context_die)
   else if (old_die)
     {
       register unsigned file_index
-       = lookup_filename (DECL_SOURCE_FILE (decl));
+       = lookup_filename (&decl_file_table, DECL_SOURCE_FILE (decl));
 
       if (get_AT_flag (old_die, DW_AT_declaration) != 1)
        {
@@ -8203,7 +9812,7 @@ gen_subprogram_die (decl, context_die)
          && (DECL_ARTIFICIAL (decl)
              || (get_AT_unsigned (old_die, DW_AT_decl_file) == file_index
                  && (get_AT_unsigned (old_die, DW_AT_decl_line)
-                     == (unsigned)DECL_SOURCE_LINE (decl)))))
+                     == (unsigned) DECL_SOURCE_LINE (decl)))))
        {
          subr_die = old_die;
 
@@ -8218,7 +9827,7 @@ gen_subprogram_die (decl, context_die)
          if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
            add_AT_unsigned (subr_die, DW_AT_decl_file, file_index);
          if (get_AT_unsigned (old_die, DW_AT_decl_line)
-             != (unsigned)DECL_SOURCE_LINE (decl))
+             != (unsigned) DECL_SOURCE_LINE (decl))
            add_AT_unsigned
              (subr_die, DW_AT_decl_line, DECL_SOURCE_LINE (decl));
        }
@@ -8226,7 +9835,7 @@ gen_subprogram_die (decl, context_die)
   else
     {
       subr_die = new_die (DW_TAG_subprogram, context_die);
-                        
+
       if (TREE_PUBLIC (decl))
        add_AT_flag (subr_die, DW_AT_external, 1);
 
@@ -8316,17 +9925,17 @@ gen_subprogram_die (decl, context_die)
     }
 
   /* Now output descriptions of the arguments for this function. This gets
-     (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list 
+     (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
      for a FUNCTION_DECL doesn't indicate cases where there was a trailing
      `...' at the end of the formal parameter list.  In order to find out if
      there was a trailing ellipsis or not, we must instead look at the type
      associated with the FUNCTION_DECL.  This will be a node of type
      FUNCTION_TYPE. If the chain of type nodes hanging off of this
-     FUNCTION_TYPE node ends with a void_type_node then there should *not* be 
+     FUNCTION_TYPE node ends with a void_type_node then there should *not* be
      an ellipsis at the end.  */
 
   /* In the case where we are describing a mere function declaration, all we
-     need to do here (and all we *can* do here) is to describe the *types* of 
+     need to do here (and all we *can* do here) is to describe the *types* of
      its formal parameters.  */
   if (debug_info_level <= DINFO_LEVEL_TERSE)
     ;
@@ -8352,7 +9961,7 @@ gen_subprogram_die (decl, context_die)
          }
 
       /* Decide whether we need a unspecified_parameters DIE at the end.
-         There are 2 more cases to do this for: 1) the ansi ... declaration - 
+         There are 2 more cases to do this for: 1) the ansi ... declaration -
          this is detectable when the end of the arg list is not a
          void_type_node 2) an unprototyped function declaration (not a
          definition).  This just means that we have no info about the
@@ -8434,13 +10043,13 @@ gen_variable_die (decl, context_die)
       if (DECL_NAME (decl))
        {
          register unsigned file_index
-           = lookup_filename (DECL_SOURCE_FILE (decl));
+           = lookup_filename (&decl_file_table, DECL_SOURCE_FILE (decl));
 
          if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index)
            add_AT_unsigned (var_die, DW_AT_decl_file, file_index);
 
          if (get_AT_unsigned (old_die, DW_AT_decl_line)
-             != (unsigned)DECL_SOURCE_LINE (decl))
+             != (unsigned) DECL_SOURCE_LINE (decl))
 
            add_AT_unsigned (var_die, DW_AT_decl_line,
                             DECL_SOURCE_LINE (decl));
@@ -8468,7 +10077,7 @@ gen_variable_die (decl, context_die)
 
   if (declaration)
     add_AT_flag (var_die, DW_AT_declaration, 1);
-  
+
   if (class_scope_p (context_die) || DECL_ABSTRACT (decl))
     equate_decl_number_to_die (decl, var_die);
 
@@ -8477,6 +10086,8 @@ gen_variable_die (decl, context_die)
       add_location_or_const_value_attribute (var_die, decl);
       add_pubname (decl, var_die);
     }
+  else
+    tree_add_const_value_attribute (var_die, decl);
 }
 
 /* Generate a DIE to represent a label identifier.  */
@@ -8490,7 +10101,6 @@ gen_label_die (decl, context_die)
   register dw_die_ref lbl_die = new_die (DW_TAG_label, context_die);
   register rtx insn;
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
-  char label2[MAX_ARTIFICIAL_LABEL_BYTES];
 
   if (origin != NULL)
     add_abstract_origin_attribute (lbl_die, origin);
@@ -8510,17 +10120,15 @@ gen_label_die (decl, context_die)
          || ((GET_CODE (insn) == NOTE
               && NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL)))
        {
-         /* When optimization is enabled (via -O) some parts of the compiler 
-            (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which 
+         /* When optimization is enabled (via -O) some parts of the compiler
+            (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
             represent source-level labels which were explicitly declared by
             the user.  This really shouldn't be happening though, so catch
             it if it ever does happen.  */
          if (INSN_DELETED_P (insn))
            abort ();
 
-         sprintf (label2, INSN_LABEL_FMT, current_funcdef_number);
-         ASM_GENERATE_INTERNAL_LABEL (label, label2,
-                                      (unsigned) INSN_UID (insn));
+         ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
          add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
        }
     }
@@ -8706,6 +10314,8 @@ gen_compile_unit_die (filename)
     language = DW_LANG_Fortran77;
   else if (strcmp (language_string, "GNU Pascal") == 0)
     language = DW_LANG_Pascal83;
+  else if (strcmp (language_string, "GNU Java") == 0)
+    language = DW_LANG_Java;
   else if (flag_traditional)
     language = DW_LANG_C;
   else
@@ -8729,7 +10339,7 @@ gen_string_type_die (type, context_die)
   equate_type_number_to_die (type, type_die);
 
   /* Fudge the string length attribute for now.  */
-  
+
   /* TODO: add string length info.
    string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
                              bound_representation (upper_bound, 0, 'u'); */
@@ -8769,12 +10379,12 @@ gen_member_die (type, context_die)
      members. Note that as we output the DIEs necessary to represent the
      members of this record or union type, we will also be trying to output
      DIEs to represent the *types* of those members. However the `type'
-     function (above) will specifically avoid generating type DIEs for member 
-     types *within* the list of member DIEs for this (containing) type execpt 
+     function (above) will specifically avoid generating type DIEs for member
+     types *within* the list of member DIEs for this (containing) type execpt
      for those types (of members) which are explicitly marked as also being
      members of this (containing) type themselves.  The g++ front- end can
      force any given type to be treated as a member of some other
-     (containing) type by setting the TYPE_CONTEXT of the given (member) type 
+     (containing) type by setting the TYPE_CONTEXT of the given (member) type
      to point to the TREE node representing the appropriate (containing)
      type.  */
 
@@ -8849,9 +10459,10 @@ gen_struct_or_union_type_die (type, context_die)
                          ? DW_TAG_structure_type : DW_TAG_union_type,
                          scope_die);
       equate_type_number_to_die (type, type_die);
-      add_name_attribute (type_die, type_tag (type));
       if (old_die)
        add_AT_die_ref (type_die, DW_AT_specification, old_die);
+      else
+       add_name_attribute (type_die, type_tag (type));
     }
   else
     remove_AT (type_die, DW_AT_declaration);
@@ -8860,7 +10471,7 @@ gen_struct_or_union_type_die (type, context_die)
      then give a list of members.  */
   if (complete)
     {
-      /* Prevent infinite recursion in cases where the type of some member of 
+      /* Prevent infinite recursion in cases where the type of some member of
          this type is expressed in terms of this type itself.  */
       TREE_ASM_WRITTEN (type) = 1;
       add_byte_size_attribute (type_die, type);
@@ -8938,7 +10549,11 @@ gen_typedef_die (decl, context_die)
       if (DECL_ORIGINAL_TYPE (decl))
        {
          type = DECL_ORIGINAL_TYPE (decl);
-         equate_type_number_to_die (TREE_TYPE (decl), type_die);
+
+         if (type == TREE_TYPE (decl))
+           abort ();
+         else
+           equate_type_number_to_die (TREE_TYPE (decl), type_die);
        }
       else
        type = TREE_TYPE (decl);
@@ -8972,7 +10587,7 @@ gen_type_die (type, context_die)
 
   if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
       && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
-    { 
+    {
       TREE_ASM_WRITTEN (type) = 1;
       gen_decl_die (TYPE_NAME (type), context_die);
       return;
@@ -8998,7 +10613,7 @@ gen_type_die (type, context_die)
       break;
 
     case OFFSET_TYPE:
-      /* This code is used for C++ pointer-to-data-member types. 
+      /* This code is used for C++ pointer-to-data-member types.
         Output a description of the relevant class type.  */
       gen_type_die (TYPE_OFFSET_BASETYPE (type), context_die);
 
@@ -9042,6 +10657,10 @@ gen_type_die (type, context_die)
        gen_array_type_die (type, context_die);
       break;
 
+    case VECTOR_TYPE:
+      gen_type_die (TYPE_DEBUG_REPRESENTATION_TYPE (type), context_die);
+      break;
+
     case ENUMERAL_TYPE:
     case RECORD_TYPE:
     case UNION_TYPE:
@@ -9122,7 +10741,7 @@ gen_tagged_type_instantiation_die (type, context_die)
 
   /* Do not check TREE_ASM_WRITTEN (type) as it may not be set if this is
      an instance of an unresolved type.  */
-  
+
   switch (TREE_CODE (type))
     {
     case ERROR_MARK:
@@ -9183,7 +10802,7 @@ gen_block_die (stmt, context_die, depth)
   else
     {
       /* In the case where the current block represents an inlining of the
-         "body block" of an inline function, we must *NOT* output any DIE for 
+         "body block" of an inline function, we must *NOT* output any DIE for
          this block because we have already output a DIE to represent the
          whole inlined function scope and the "body block" of any function
          doesn't really represent a different scope according to ANSI C
@@ -9315,7 +10934,7 @@ gen_decl_die (decl, context_die)
   switch (TREE_CODE (decl))
     {
     case CONST_DECL:
-      /* The individual enumerators of an enum type get output when we output 
+      /* The individual enumerators of an enum type get output when we output
          the Dwarf representation of the relevant enum type itself.  */
       break;
 
@@ -9329,7 +10948,11 @@ gen_decl_die (decl, context_die)
       /* If we're emitting an out-of-line copy of an inline function,
         emit info for the abstract instance and set up to refer to it.  */
       if (DECL_INLINE (decl) && ! DECL_ABSTRACT (decl)
-         && ! class_scope_p (context_die))
+         && ! class_scope_p (context_die)
+         /* gen_abstract_function won't emit a die if this is just a
+            declaration.  We must avoid setting DECL_ABSTRACT_ORIGIN in
+            that case, because that works only if we have a die.  */
+         && DECL_INITIAL (decl) != NULL_TREE)
        {
          gen_abstract_function (decl);
          set_decl_origin_self (decl);
@@ -9361,12 +10984,12 @@ gen_decl_die (decl, context_die)
       if (debug_info_level <= DINFO_LEVEL_TERSE)
        break;
 
-      /* In the special case of a TYPE_DECL node representing the 
+      /* In the special case of a TYPE_DECL node representing the
          declaration of some type tag, if the given TYPE_DECL is marked as
          having been instantiated from some other (original) TYPE_DECL node
          (e.g. one which was generated within the original definition of an
          inline function) we have to generate a special (abbreviated)
-         DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type 
+         DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
          DIE here.  */
       if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE)
        {
@@ -9449,13 +11072,13 @@ dwarf2out_add_library_unit_info (filename, context_list)
   if (filename != NULL)
     {
       dw_die_ref unit_die = new_die (DW_TAG_module, comp_unit_die);
-      tree context_list_decl 
+      tree context_list_decl
        = build_decl (LABEL_DECL, get_identifier (context_list),
                      void_type_node);
 
       TREE_PUBLIC (context_list_decl) = TRUE;
       add_name_attribute (unit_die, context_list);
-      file_index = lookup_filename (filename);
+      file_index = lookup_filename (&decl_file_table, filename);
       add_AT_unsigned (unit_die, DW_AT_decl_file, file_index);
       add_pubname (context_list_decl, unit_die);
     }
@@ -9479,7 +11102,7 @@ dwarf2out_decl (decl)
   switch (TREE_CODE (decl))
     {
     case FUNCTION_DECL:
-      /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a 
+      /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
          builtin function.  Explicit programmer-supplied declarations of
          these same functions should NOT be ignored however.  */
       if (DECL_EXTERNAL (decl) && DECL_BUILT_IN (decl))
@@ -9488,12 +11111,12 @@ dwarf2out_decl (decl)
       /* What we would really like to do here is to filter out all mere
          file-scope declarations of file-scope functions which are never
          referenced later within this translation unit (and keep all of ones
-         that *are* referenced later on) but we aren't clairvoyant, so we have 
-         no idea which functions will be referenced in the future (i.e. later 
+         that *are* referenced later on) but we aren't clairvoyant, so we have
+         no idea which functions will be referenced in the future (i.e. later
          on within the current translation unit). So here we just ignore all
-         file-scope function declarations which are not also definitions.  If 
+         file-scope function declarations which are not also definitions.  If
          and when the debugger needs to know something about these functions,
-         it will have to hunt around and find the DWARF information associated 
+         it will have to hunt around and find the DWARF information associated
          with the definition of the function.  Note that we can't just check
          `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
          definitions and which ones represent mere declarations.  We have to
@@ -9502,13 +11125,13 @@ dwarf2out_decl (decl)
          definitions.  These can get inlined within the current translation
          unit (an thus, we need to generate DWARF info for their abstract
          instances so that the DWARF info for the concrete inlined instances
-         can have something to refer to) but the compiler never generates any 
+         can have something to refer to) but the compiler never generates any
          out-of-lines instances of such things (despite the fact that they
          *are* definitions).  The important point is that the C front-end
          marks these "extern inline" functions as DECL_EXTERNAL, but we need
          to generate DWARF for them anyway. Note that the C++ front-end also
          plays some similar games for inline function definitions appearing
-         within include files which also contain 
+         within include files which also contain
         `#pragma interface' pragmas.  */
       if (DECL_INITIAL (decl) == NULL_TREE)
        return;
@@ -9522,7 +11145,7 @@ dwarf2out_decl (decl)
       break;
 
     case VAR_DECL:
-      /* Ignore this VAR_DECL if it refers to a file-scope extern data object 
+      /* Ignore this VAR_DECL if it refers to a file-scope extern data object
          declaration and if the declaration was never even referenced from
          within this entire compilation unit.  We suppress these DIEs in
          order to save space in the .debug section (by eliminating entries
@@ -9584,7 +11207,7 @@ dwarf2out_begin_block (blocknum)
      register unsigned blocknum;
 {
   function_section (current_function_decl);
-  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
+  ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
 }
 
 /* Output a marker (i.e. a label) for the end of the generated code for a
@@ -9595,7 +11218,7 @@ dwarf2out_end_block (blocknum)
      register unsigned blocknum;
 {
   function_section (current_function_decl);
-  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
+  ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
 }
 
 /* Returns nonzero if it is appropriate not to emit any debugging
@@ -9617,24 +11240,6 @@ dwarf2out_ignore_block (block)
   return 1;
 }
 
-/* Output a marker (i.e. a label) at a point in the assembly code which
-   corresponds to a given source level label.  */
-
-void
-dwarf2out_label (insn)
-     register rtx insn;
-{
-  char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-  if (debug_info_level >= DINFO_LEVEL_NORMAL)
-    {
-      function_section (current_function_decl);
-      sprintf (label, INSN_LABEL_FMT, current_funcdef_number);
-      ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, label,
-                                (unsigned) INSN_UID (insn));
-    }
-}
-
 /* Lookup a filename (in the list of filenames that we know about here in
    dwarf2out.c) and return its "index".  The index of each (known) filename is
    just a unique number which is associated with only that one filename.
@@ -9647,41 +11252,54 @@ dwarf2out_label (insn)
    was looked up last.  This handles the majority of all searches.  */
 
 static unsigned
-lookup_filename (file_name)
+lookup_filename (t, file_name)
+     struct file_table *t;
      const char *file_name;
 {
-  static unsigned last_file_lookup_index = 0;
   register unsigned i;
 
-  /* Check to see if the file name that was searched on the previous call
-     matches this file name. If so, return the index.  */
-  if (last_file_lookup_index != 0)
-    if (strcmp (file_name, file_table[last_file_lookup_index]) == 0)
-      return last_file_lookup_index;
+  /* Check to see if the file name that was searched on the previous
+     call matches this file name.  If so, return the index.  */
+  if (t->last_lookup_index != 0)
+    if (strcmp (file_name, t->table[t->last_lookup_index]) == 0)
+      return t->last_lookup_index;
 
   /* Didn't match the previous lookup, search the table */
-  for (i = 1; i < file_table_in_use; ++i)
-    if (strcmp (file_name, file_table[i]) == 0)
+  for (i = 1; i < t->in_use; ++i)
+    if (strcmp (file_name, t->table[i]) == 0)
       {
-       last_file_lookup_index = i;
+       t->last_lookup_index = i;
        return i;
       }
 
-  /* Prepare to add a new table entry by making sure there is enough space in 
+  /* Prepare to add a new table entry by making sure there is enough space in
      the table to do so.  If not, expand the current table.  */
-  if (file_table_in_use == file_table_allocated)
+  if (i == t->allocated)
     {
-      file_table_allocated += FILE_TABLE_INCREMENT;
-      file_table
-       = (char **) xrealloc (file_table,
-                             file_table_allocated * sizeof (char *));
+      t->allocated = i + FILE_TABLE_INCREMENT;
+      t->table = (char **)
+       xrealloc (t->table, t->allocated * sizeof (char *));
     }
 
   /* Add the new entry to the end of the filename table.  */
-  file_table[file_table_in_use] = xstrdup (file_name);
-  last_file_lookup_index = file_table_in_use++;
+  t->table[i] = xstrdup (file_name);
+  t->in_use = i + 1;
+  t->last_lookup_index = i;
 
-  return last_file_lookup_index;
+  return i;
+}
+
+static void
+init_file_table (t)
+     struct file_table *t;
+{
+  /* Allocate the initial hunk of the file_table.  */
+  t->table = (char **) xcalloc (FILE_TABLE_INCREMENT, sizeof (char *));
+  t->allocated = FILE_TABLE_INCREMENT;
+
+  /* Skip the first entry - file numbers begin at 1.  */
+  t->in_use = 1;
+  t->last_lookup_index = 0;
 }
 
 /* Output a label to mark the beginning of a source code line entry
@@ -9699,19 +11317,26 @@ dwarf2out_line (filename, line)
 
       if (DWARF2_ASM_LINE_DEBUG_INFO)
        {
-         static const char *lastfile;
+         unsigned old_in_use = line_file_table.in_use;
+         unsigned file_num = lookup_filename (&line_file_table, filename);
 
          /* Emit the .file and .loc directives understood by GNU as.  */
-         if (lastfile == 0 || strcmp (filename, lastfile))
+#if 0
+         /* ??? As of 2000-11-25, gas has a bug in which it doesn't
+            actually use the file number argument.  It merely remembers
+            the last .file directive emitted.  */
+         if (file_num >= old_in_use)
+           fprintf (asm_out_file, "\t.file %d \"%s\"\n", file_num, filename);
+         fprintf (asm_out_file, "\t.loc %d %d 0\n", file_num, line);
+#else
+         static int last_file_num;
+         if (file_num != last_file_num)
            {
-             if (lastfile == 0)
-               ggc_add_string_root ((char **) &lastfile, 1);
-
+             last_file_num = file_num;
              fprintf (asm_out_file, "\t.file 0 \"%s\"\n", filename);
-             lastfile = filename;
            }
-
          fprintf (asm_out_file, "\t.loc 0 %d 0\n", line);
+#endif
 
          /* Indicate that line number info exists.  */
          ++line_info_table_in_use;
@@ -9744,7 +11369,7 @@ dwarf2out_line (filename, line)
          /* Add the new entry at the end of the line_info_table.  */
          line_info
            = &separate_line_info_table[separate_line_info_table_in_use++];
-         line_info->dw_file_num = lookup_filename (filename);
+         line_info->dw_file_num = lookup_filename (&line_file_table, filename);
          line_info->dw_line_num = line;
          line_info->function = current_funcdef_number;
        }
@@ -9771,7 +11396,7 @@ dwarf2out_line (filename, line)
 
          /* Add the new entry at the end of the line_info_table.  */
          line_info = &line_info_table[line_info_table_in_use++];
-         line_info->dw_file_num = lookup_filename (filename);
+         line_info->dw_file_num = lookup_filename (&line_file_table, filename);
          line_info->dw_line_num = line;
        }
     }
@@ -9784,6 +11409,12 @@ void
 dwarf2out_start_source_file (filename)
      register const char *filename ATTRIBUTE_UNUSED;
 {
+  if (flag_eliminate_dwarf2_dups)
+    {
+      /* Record the beginning of the file for break_out_includes.  */
+      dw_die_ref bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die);
+      add_AT_string (bincl_die, DW_AT_name, filename);
+    }
 }
 
 /* Record the end of a source file, for later output
@@ -9792,6 +11423,11 @@ dwarf2out_start_source_file (filename)
 void
 dwarf2out_end_source_file ()
 {
+  if (flag_eliminate_dwarf2_dups)
+    {
+      /* Record the end of the file for break_out_includes.  */
+      new_die (DW_TAG_GNU_EINCL, comp_unit_die);
+    }
 }
 
 /* Called from check_newline in c-parse.y.  The `buffer' parameter contains
@@ -9832,12 +11468,8 @@ dwarf2out_init (asm_out_file, main_input_filename)
   /* Remember the name of the primary input file.  */
   primary_filename = main_input_filename;
 
-  /* Allocate the initial hunk of the file_table.  */
-  file_table = (char **) xcalloc (FILE_TABLE_INCREMENT, sizeof (char *));
-  file_table_allocated = FILE_TABLE_INCREMENT;
-
-  /* Skip the first entry - file numbers begin at 1.  */
-  file_table_in_use = 1;
+  init_file_table (&decl_file_table);
+  init_file_table (&line_file_table);
 
   /* Allocate the initial hunk of the decl_die_table.  */
   decl_die_table
@@ -9867,18 +11499,15 @@ dwarf2out_init (asm_out_file, main_input_filename)
   /* Zero-th entry is allocated, but unused */
   line_info_table_in_use = 1;
 
-  /* Generate the initial DIE for the .debug section.  Note that the (string) 
+  /* Generate the initial DIE for the .debug section.  Note that the (string)
      value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
-     will (typically) be a relative pathname and that this pathname should be 
+     will (typically) be a relative pathname and that this pathname should be
      taken as being relative to the directory from which the compiler was
      invoked when the given (base) source file was compiled.  */
   comp_unit_die = gen_compile_unit_die (main_input_filename);
 
-  if (ggc_p)
-    {
-      VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
-      ggc_add_rtx_varray_root (&used_rtx_varray, 1);
-    }
+  VARRAY_RTX_INIT (used_rtx_varray, 32, "used_rtx_varray");
+  ggc_add_rtx_varray_root (&used_rtx_varray, 1);
 
   ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label, ABBREV_SECTION_LABEL, 0);
@@ -9886,9 +11515,9 @@ dwarf2out_init (asm_out_file, main_input_filename)
     ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
   else
     strcpy (text_section_label, stripattributes (TEXT_SECTION));
-  ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label, 
+  ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
                               DEBUG_INFO_SECTION_LABEL, 0);
-  ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, 
+  ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
                               DEBUG_LINE_SECTION_LABEL, 0);
 
   ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
@@ -9941,9 +11570,20 @@ dwarf2out_finish ()
      emit full debugging info for them.  */
   retry_incomplete_types ();
 
-  /* Traverse the DIE's, reverse their lists of attributes and children,
-     and add add sibling attributes to those DIE's that have children.  */
+  /* We need to reverse all the dies before break_out_includes, or
+     we'll see the end of an include file before the beginning.  */
+  reverse_all_dies (comp_unit_die);
+
+  /* Generate separate CUs for each of the include files we've seen.
+     They will go into limbo_die_list.  */
+  if (flag_eliminate_dwarf2_dups)
+    break_out_includes (comp_unit_die);
+
+  /* Traverse the DIE's and add add sibling attributes to those DIE's
+     that have children.  */
   add_sibling_attributes (comp_unit_die);
+  for (node = limbo_die_list; node; node = node->next)
+    add_sibling_attributes (node->die);
 
   /* Output a terminator label for the .text section.  */
   fputc ('\n', asm_out_file);
@@ -9989,22 +11629,17 @@ dwarf2out_finish ()
     add_AT_unsigned (die, DW_AT_macro_info, 0);
 #endif
 
+  /* Output all of the compilation units.  We put the main one last so that
+     the offsets are available to output_pubnames.  */
+  for (node = limbo_die_list; node; node = node->next)
+    output_comp_unit (node->die);
+  output_comp_unit (comp_unit_die);
+
   /* Output the abbreviation table.  */
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
-  build_abbrev_table (comp_unit_die);
   output_abbrev_section ();
 
-  /* Initialize the beginning DIE offset - and calculate sizes/offsets.   */
-  next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE;
-  calc_die_sizes (comp_unit_die);
-
-  /* Output debugging information.  */
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_SECTION (asm_out_file, DEBUG_INFO_SECTION);
-  output_compilation_unit_header ();
-  output_die (comp_unit_die);
-
   if (pubname_table_in_use)
     {
       /* Output public names table.  */