Makefile.in (OBJS): Add dwarf2asm.o.
authorRichard Henderson <rth@redhat.com>
Sat, 3 Mar 2001 02:17:07 +0000 (18:17 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sat, 3 Mar 2001 02:17:07 +0000 (18:17 -0800)
* Makefile.in (OBJS): Add dwarf2asm.o.
* dwarf2asm.c, dwarf2asm.h: New files.
* dwarf2out.c (*): Use them.
(size_of_uleb128, size_of_sleb128): Remove.
(output_uleb128, output_sleb128): Remove.
(UNALIGNED_SHORT_ASM_OP, UNALIGNED_INT_ASM_OP): Remove.
(UNALIGNED_DOUBLE_INT_ASM_OP, ASM_BYTE_OP): Remove.
(UNALIGNED_OFFSET_ASM_OP, UNALIGNED_WORD_ASM_OP): Remove.
(FDE_LABEL, LINE_NUMBER_BEGIN_LABEL, LINE_NUMBER_END_LABEL): New.
(ASM_OUTPUT_DWARF_DATA1, ASM_OUTPUT_DWARF_DELTA1): Remove.
(ASM_OUTPUT_DWARF_DATA2, ASM_OUTPUT_DWARF_DELTA2): Remove.
(ASM_OUTPUT_DWARF_DATA4, ASM_OUTPUT_DWARF_DELTA4): Remove.
(ASM_OUTPUT_DWARF_DATA, ASM_OUTPUT_DWARF_DELTA): Remove.
(ASM_OUTPUT_DWARF_ADDR, ASM_OUTPUT_DWARF_ADDR_DATA): Remove.
(ASM_OUTPUT_DWARF_ADDR_DELTA, ASM_OUTPUT_DWARF_ADDR_CONST): Remove.
(ASM_OUTPUT_DWARF_OFFSET4, ASM_OUTPUT_DWARF_OFFSET): Remove.
(ASM_OUTPUT_DWARF_CONST_DOUBLE): Remove.
(ASM_OUTPUT_DWARF_NSTRING, ASM_OUTPUT_DWARF_STRING): Remove.
(dwarf2out_frame_debug): Remove unused variables.
(output_loc_operands): Don't abort on 8 byte constants if
host integers are wide enough.
(output_symbolic_ref): Remove.
(size_of_die): Don't assume 4 byte host integers.
(output_line_info): Use ASM_GENERATE_INTERNAL_LABEL for begin
and end labels.
(add_const_value_attribute) [CONST_INT]: Verify we're not doing
something stupid with HOST_WIDE_INT to long truncation.
[CONST_DOUBLE]: Likewise.

* config/arm/conix-elf.h (UNALIGNED_WORD_ASM_OP): Remove.
(ASM_OUTPUT_DWARF2_ADDR_CONST, ASM_OUTPUT_DWARF_ADDR_CONST): Remove.
* config/arm/unknown-elf.h: Likewise.
* config/rs6000/aix.h (UNALIGNED_SHORT_ASM_OP): New.
(UNALIGNED_INT_ASM_OP, UNALIGNED_DOUBLE_INT_ASM_OP): New.
(ASM_OUTPUT_DWARF_ADDR_VAR, ASM_OUTPUT_DWARF_DELTA_VAR): Remove.
(ASM_OUTPUT_DWARF_DELTA2, ASM_OUTPUT_DWARF_DELTA4): Remove.
(ASM_OUTPUT_DWARF_DELTA, ASM_OUTPUT_DWARF_ADDR_DELTA): Remove.
(ASM_OUTPUT_DWARF_ADDR, ASM_OUTPUT_DWARF_DATA4): Remove.
(ASM_OUTPUT_DWARF_DATA2, ASM_OUTPUT_DWARF_OFFSET4): Remove.
(ASM_OUTPUT_DWARF_OFFSET): Remove.
* config/rs6000/sysv4.h (ASM_OUTPUT_DWARF_ADDR): Remove.
* config/sparc/sp64-elf.h (UNALIGNED_DOUBLE_INT_ASM_OP): New.
(UNALIGNED_LONGLONG_ASM_OP, ASM_OUTPUT_DWARF_ADDR): Remove.
(ASM_OUTPUT_DWARF_ADDR_CONST, ASM_OUTPUT_DWARF_REF): Remove.

From-SVN: r40197

gcc/ChangeLog
gcc/Makefile.in
gcc/config/arm/conix-elf.h
gcc/config/arm/unknown-elf.h
gcc/config/rs6000/aix.h
gcc/config/rs6000/sysv4.h
gcc/config/sparc/sp64-elf.h
gcc/dwarf2asm.c [new file with mode: 0644]
gcc/dwarf2asm.h [new file with mode: 0644]
gcc/dwarf2out.c

index c71cd60..47f2d24 100644 (file)
@@ -1,3 +1,50 @@
+2001-03-02  Richard Henderson  <rth@redhat.com>
+
+       * Makefile.in (OBJS): Add dwarf2asm.o.
+       * dwarf2asm.c, dwarf2asm.h: New files.
+       * dwarf2out.c (*): Use them.
+       (size_of_uleb128, size_of_sleb128): Remove.
+       (output_uleb128, output_sleb128): Remove.
+       (UNALIGNED_SHORT_ASM_OP, UNALIGNED_INT_ASM_OP): Remove.
+       (UNALIGNED_DOUBLE_INT_ASM_OP, ASM_BYTE_OP): Remove.
+       (UNALIGNED_OFFSET_ASM_OP, UNALIGNED_WORD_ASM_OP): Remove.
+       (FDE_LABEL, LINE_NUMBER_BEGIN_LABEL, LINE_NUMBER_END_LABEL): New.
+       (ASM_OUTPUT_DWARF_DATA1, ASM_OUTPUT_DWARF_DELTA1): Remove.
+       (ASM_OUTPUT_DWARF_DATA2, ASM_OUTPUT_DWARF_DELTA2): Remove.
+       (ASM_OUTPUT_DWARF_DATA4, ASM_OUTPUT_DWARF_DELTA4): Remove.
+       (ASM_OUTPUT_DWARF_DATA, ASM_OUTPUT_DWARF_DELTA): Remove.
+       (ASM_OUTPUT_DWARF_ADDR, ASM_OUTPUT_DWARF_ADDR_DATA): Remove.
+       (ASM_OUTPUT_DWARF_ADDR_DELTA, ASM_OUTPUT_DWARF_ADDR_CONST): Remove.
+       (ASM_OUTPUT_DWARF_OFFSET4, ASM_OUTPUT_DWARF_OFFSET): Remove.
+       (ASM_OUTPUT_DWARF_CONST_DOUBLE): Remove.
+       (ASM_OUTPUT_DWARF_NSTRING, ASM_OUTPUT_DWARF_STRING): Remove.
+       (dwarf2out_frame_debug): Remove unused variables.
+       (output_loc_operands): Don't abort on 8 byte constants if
+       host integers are wide enough.
+       (output_symbolic_ref): Remove.
+       (size_of_die): Don't assume 4 byte host integers.
+       (output_line_info): Use ASM_GENERATE_INTERNAL_LABEL for begin
+       and end labels.
+       (add_const_value_attribute) [CONST_INT]: Verify we're not doing
+       something stupid with HOST_WIDE_INT to long truncation.
+       [CONST_DOUBLE]: Likewise.
+
+       * config/arm/conix-elf.h (UNALIGNED_WORD_ASM_OP): Remove.
+       (ASM_OUTPUT_DWARF2_ADDR_CONST, ASM_OUTPUT_DWARF_ADDR_CONST): Remove.
+       * config/arm/unknown-elf.h: Likewise.
+       * config/rs6000/aix.h (UNALIGNED_SHORT_ASM_OP): New.
+       (UNALIGNED_INT_ASM_OP, UNALIGNED_DOUBLE_INT_ASM_OP): New.
+       (ASM_OUTPUT_DWARF_ADDR_VAR, ASM_OUTPUT_DWARF_DELTA_VAR): Remove.
+       (ASM_OUTPUT_DWARF_DELTA2, ASM_OUTPUT_DWARF_DELTA4): Remove.
+       (ASM_OUTPUT_DWARF_DELTA, ASM_OUTPUT_DWARF_ADDR_DELTA): Remove.
+       (ASM_OUTPUT_DWARF_ADDR, ASM_OUTPUT_DWARF_DATA4): Remove.
+       (ASM_OUTPUT_DWARF_DATA2, ASM_OUTPUT_DWARF_OFFSET4): Remove.
+       (ASM_OUTPUT_DWARF_OFFSET): Remove.
+       * config/rs6000/sysv4.h (ASM_OUTPUT_DWARF_ADDR): Remove.
+       * config/sparc/sp64-elf.h (UNALIGNED_DOUBLE_INT_ASM_OP): New.
+       (UNALIGNED_LONGLONG_ASM_OP, ASM_OUTPUT_DWARF_ADDR): Remove.
+       (ASM_OUTPUT_DWARF_ADDR_CONST, ASM_OUTPUT_DWARF_REF): Remove.
+
 2001-03-02  John David Anglin  <dave@hiauly1.hia.nrc.ca>
 
        * cselib.c (hash_rtx): Cast enums to unsigned int.
index bc6067e..9f3bb52 100644 (file)
@@ -733,19 +733,22 @@ C_OBJS = c-parse.o c-lang.o $(C_AND_OBJC_OBJS)
 
 # Language-independent object files.
 
-OBJS = diagnostic.o version.o tree.o print-tree.o stor-layout.o fold-const.o \
- function.o stmt.o except.o expr.o calls.o expmed.o explow.o optabs.o real.o \
- builtins.o intl.o varasm.o rtl.o print-rtl.o rtlanal.o emit-rtl.o genrtl.o  \
- dbxout.o sdbout.o dwarfout.o dwarf2out.o xcoffout.o bitmap.o alias.o gcse.o \
- integrate.o jump.o cse.o loop.o doloop.o unroll.o flow.o combine.o varray.o \
- regclass.o regmove.o local-alloc.o global.o reload.o reload1.o caller-save.o\
- insn-peep.o reorg.o haifa-sched.o final.o recog.o reg-stack.o regrename.o   \
- insn-opinit.o insn-recog.o insn-extract.o insn-output.o insn-emit.o lcm.o   \
- profile.o insn-attrtab.o $(out_object_file) $(EXTRA_OBJS) convert.o        \
- mbchar.o splay-tree.o graph.o sbitmap.o resource.o hash.o predict.o        \
- lists.o ggc-common.o $(GGC) stringpool.o simplify-rtx.o ssa.o bb-reorder.o  \
- sibcall.o conflict.o timevar.o ifcvt.o dominance.o dependence.o dce.o \
- sched-vis.o sched-deps.o sched-rgn.o sched-ebb.o hashtab.o cselib.o params.o
+OBJS =                                                                 \
+ alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o                \
+ combine.o conflict.o convert.o cse.o cselib.o dbxout.o dce.o          \
+ dependence.o diagnostic.o doloop.o dominance.o dwarf2asm.o dwarf2out.o        \
+ dwarfout.o emit-rtl.o except.o explow.o expmed.o expr.o final.o flow.o        \
+ fold-const.o function.o gcse.o genrtl.o ggc-common.o global.o graph.o \
+ haifa-sched.o hash.o hashtab.o ifcvt.o insn-attrtab.o insn-emit.o     \
+ insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o   \
+ integrate.o intl.o jump.o lcm.o lists.o local-alloc.o loop.o mbchar.o \
+ optabs.o params.o predict.o print-rtl.o print-tree.o profile.o real.o \
+ recog.o reg-stack.o regclass.o regmove.o regrename.o reload.o         \
+ reload1.o reorg.o resource.o rtl.o rtlanal.o sbitmap.o sched-deps.o   \
+ sched-ebb.o sched-rgn.o sched-vis.o sdbout.o sibcall.o simplify-rtx.o \
+ splay-tree.o ssa.o stmt.o stor-layout.o stringpool.o timevar.o tree.o \
+ unroll.o varasm.o varray.o version.o xcoffout.o                       \
+ $(GGC) $(out_object_file) $(EXTRA_OBJS)
 
 BACKEND = toplev.o libbackend.a
 
@@ -1397,7 +1400,9 @@ dwarfout.o : dwarfout.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) dwarf.h \
 dwarf2out.o : dwarf2out.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) dwarf2.h \
    flags.h insn-config.h reload.h output.h \
    hard-reg-set.h $(REGS_H) $(EXPR_H) toplev.h dwarf2out.h varray.h \
-   $(GGC_H) except.h
+   $(GGC_H) except.h dwarf2asm.h
+dwarf2asm.o : dwarf2asm.c $(CONFIG_H) system.h flags.h $(RTL_H) output.h \
+   dwarf2asm.h
 xcoffout.o : xcoffout.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) xcoffout.h \
    flags.h toplev.h output.h dbxout.h $(GGC_H)
 emit-rtl.o : emit-rtl.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \
index 2d447a5..a626af8 100644 (file)
@@ -99,23 +99,6 @@ func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
     }                                                                  \
   while (0)
 
-/* Don't know how to order these.  UNALIGNED_WORD_ASM_OP is in
-   dwarf2.out.  */ 
-#define UNALIGNED_WORD_ASM_OP "\t.4byte\t"
-
-#define ASM_OUTPUT_DWARF2_ADDR_CONST(FILE,ADDR)                  \
-     fprintf ((FILE), "%s%s", UNALIGNED_WORD_ASM_OP, ADDR)
-
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX)                  \
-  do                                                           \
-    {                                                          \
-      fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);           \
-      output_addr_const ((FILE), (RTX));                       \
-      fputc ('\n', (FILE));                                    \
-    }                                                          \
-  while (0)
-
-
 /* The ARM development system defines __main.  */
 #define NAME__MAIN "__gccmain"
 #define SYMBOL__MAIN __gccmain
index 315baff..fab8155 100644 (file)
@@ -103,23 +103,6 @@ rdata_section ()                                           \
     }                                                                  \
   while (0)
 
-/* Don't know how to order these.  UNALIGNED_WORD_ASM_OP is in
-   dwarf2.out. */ 
-#define UNALIGNED_WORD_ASM_OP "\t.4byte\t"
-
-#define ASM_OUTPUT_DWARF2_ADDR_CONST(FILE,ADDR)                  \
- fprintf ((FILE), "%s%s", UNALIGNED_WORD_ASM_OP, ADDR)
-
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX)                  \
-  do                                                           \
-    {                                                          \
-      fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);           \
-      output_addr_const ((FILE), (RTX));                       \
-      fputc ('\n', (FILE));                                    \
-    }                                                          \
-  while (0)
-
-
 /* The ARM development system defines __main.  */
 #define NAME__MAIN "__gccmain"
 #define SYMBOL__MAIN __gccmain
index a28fe1b..cb5db35 100644 (file)
@@ -561,48 +561,9 @@ toc_section ()                                             \
    use '.long' or '.word', but that aligns to a 4-byte boundary which
    is not what is required.  So we define a million macros...  */
 
-#define ASM_OUTPUT_DWARF_ADDR_VAR(FILE, LABEL, LENGTH) \
- do {   fprintf ((FILE), "\t.vbyte\t%d,", LENGTH);     \
-        assemble_name (FILE, LABEL);                   \
-  } while (0)
-
-#define ASM_OUTPUT_DWARF_DELTA_VAR(FILE, LABEL1, LABEL2, LENGTH)       \
- do {   fprintf ((FILE), "\t.vbyte\t%d,", LENGTH);                     \
-        assemble_name (FILE, LABEL1);                                  \
-        fprintf (FILE, "-");                                           \
-        assemble_name (FILE, LABEL2);                                  \
-  } while (0)
-
-#define ASM_OUTPUT_DWARF_DELTA2(FILE, LABEL1, LABEL2)  \
- ASM_OUTPUT_DWARF_DELTA_VAR (FILE, LABEL1, LABEL2, 2)
-
-#define ASM_OUTPUT_DWARF_DELTA4(FILE, LABEL1, LABEL2)  \
- ASM_OUTPUT_DWARF_DELTA_VAR (FILE, LABEL1, LABEL2, 4)
-
-#define ASM_OUTPUT_DWARF_DELTA(FILE, LABEL1, LABEL2)                   \
- ASM_OUTPUT_DWARF_DELTA_VAR (FILE, LABEL1, LABEL2, DWARF_OFFSET_SIZE)
-
-#define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE, LABEL1, LABEL2)      \
- ASM_OUTPUT_DWARF_DELTA_VAR (FILE, LABEL1, LABEL2,             \
-                            POINTER_SIZE / BITS_PER_UNIT)
-
-#define ASM_OUTPUT_DWARF_ADDR(FILE, LABEL)                             \
- ASM_OUTPUT_DWARF_ADDR_VAR (FILE, LABEL, POINTER_SIZE / BITS_PER_UNIT)
-
-#define ASM_OUTPUT_DWARF_DATA4(FILE, VALUE)                    \
-  fprintf ((FILE), "\t.vbyte\t4,0x%x", (unsigned) (VALUE))
-
-#define ASM_OUTPUT_DWARF_DATA2(FILE, VALUE)                    \
-  fprintf ((FILE), "\t.vbyte\t2,0x%x", (unsigned) (VALUE))
-
-#define ASM_OUTPUT_DWARF_OFFSET4(FILE, LABEL)  \
-  ASM_OUTPUT_DWARF_ADDR_VAR (FILE, LABEL, 4)
-
-#define ASM_OUTPUT_DWARF_OFFSET(FILE, LABEL)                   \
-  ASM_OUTPUT_DWARF_ADDR_VAR (FILE, LABEL, DWARF_OFFSET_SIZE)
-
-/* dwarf2out keys off this, but we don't have to have a real definition.  */
-#define UNALIGNED_INT_ASM_OP bite_me
+#define UNALIGNED_SHORT_ASM_OP         "\t.vbyte\t2,"
+#define UNALIGNED_INT_ASM_OP           "\t.vbyte\t4,"
+#define UNALIGNED_DOUBLE_INT_ASM_OP    "\t.vbyte\t8,"
 
 /* Output before instructions.  */
 #define TEXT_SECTION_ASM_OP "\t.csect .text[PR]"
index 5f1f950..6cf6379 100644 (file)
@@ -871,36 +871,6 @@ do {                                                                       \
     }                                                                  \
 } while (0)
 
-/* This is how to output an assembler line defining an address 
-   constant for the dwarf call unwinding information.
-   For -mrelocatable, we mark all addresses that need to be fixed up
-   in the .fixup section.  */
-
-#define        ASM_OUTPUT_DWARF_ADDR(FILE,LABEL)                               \
-do {                                                                   \
-  if (TARGET_RELOCATABLE)                                              \
-    {                                                                  \
-      char buf[256];                                                   \
-                                                                       \
-      ASM_GENERATE_INTERNAL_LABEL (buf, "LCP", fixuplabelno);          \
-      fixuplabelno++;                                                  \
-      ASM_OUTPUT_LABEL (FILE, buf);                                    \
-      fprintf (FILE, "\t.%dbyte\t", POINTER_SIZE / BITS_PER_UNIT);     \
-      assemble_name (FILE, LABEL);                                     \
-      fprintf (FILE, "\n");                                            \
-      fprintf (FILE, "\t.section \".fixup\",\"aw\"\n");                        \
-      ASM_OUTPUT_ALIGN (FILE, 2);                                      \
-      fprintf (FILE, "\t.long\t");                                     \
-      assemble_name (FILE, buf);                                       \
-      fprintf (FILE, "\n\t.previous\n");                               \
-    }                                                                  \
-  else                                                                 \
-    {                                                                  \
-      fprintf (FILE, "\t.%dbyte\t", POINTER_SIZE / BITS_PER_UNIT);     \
-      assemble_name (FILE, LABEL);                                     \
-    }                                                                  \
-} while (0)
-
 /* This is the end of what might become sysv4.h.  */
 
 /* Allow stabs and dwarf, for now, make stabs the default debugging type,
index b314899..1a7623b 100644 (file)
@@ -124,33 +124,6 @@ crtbegin.o%s \
 #undef ASM_IDENTIFY_GCC
 #define ASM_IDENTIFY_GCC(FILE)
 
-/* Define the names of various pseudo-ops used by the Sparc/svr4 assembler.
-   ??? If ints are 64 bits then UNALIGNED_INT_ASM_OP (defined elsewhere) is
-   misnamed.  These should all refer to explicit sizes (half/word/xword?),
-   anything other than short/int/long/etc.  */
-
-#define UNALIGNED_LONGLONG_ASM_OP      "\t.uaxword\t"
-
-/* DWARF stuff.  */
-
-#define ASM_OUTPUT_DWARF_ADDR(FILE, LABEL) \
-do {                                                           \
-  fprintf ((FILE), "%s", UNALIGNED_LONGLONG_ASM_OP);           \
-  assemble_name ((FILE), (LABEL));                             \
-  fprintf ((FILE), "\n");                                      \
-} while (0)
-
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE, RTX) \
-do {                                                           \
-  fprintf ((FILE), "%s", UNALIGNED_LONGLONG_ASM_OP);           \
-  output_addr_const ((FILE), (RTX));                           \
-  fputc ('\n', (FILE));                                                \
-} while (0)
-
-/* ??? Not sure if this should be 4 or 8 bytes.  4 works for now.  */
-#define ASM_OUTPUT_DWARF_REF(FILE, LABEL) \
-do {                                                           \
-  fprintf ((FILE), "%s", UNALIGNED_INT_ASM_OP);                        \
-  assemble_name ((FILE), (LABEL));                             \
-  fprintf ((FILE), "\n");                                      \
-} while (0)
+/* Define the names of various pseudo-ops used by the Sparc/svr4 assembler.  */
+
+#define UNALIGNED_DOUBLE_INT_ASM_OP    "\t.uaxword\t"
diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
new file mode 100644 (file)
index 0000000..132d83c
--- /dev/null
@@ -0,0 +1,585 @@
+/* Dwarf2 assembler output helper routines.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+
+#include "config.h"
+#include "system.h"
+#include "flags.h"
+#include "rtl.h"
+#include "output.h"
+#include "dwarf2asm.h"
+#include "tm_p.h"
+
+
+/* How to start an assembler comment.  */
+#ifndef ASM_COMMENT_START
+#define ASM_COMMENT_START ";#"
+#endif
+
+/* Definitions of defaults for assembler-dependent names of various
+   pseudo-ops and section names.  These may be overridden in the tm.h
+   file (if necessary) for a particular assembler.  */
+
+#ifdef OBJECT_FORMAT_ELF
+#ifndef UNALIGNED_SHORT_ASM_OP
+#define UNALIGNED_SHORT_ASM_OP         "\t.2byte\t"
+#endif
+#ifndef UNALIGNED_INT_ASM_OP
+#define UNALIGNED_INT_ASM_OP           "\t.4byte\t"
+#endif
+#ifndef UNALIGNED_DOUBLE_INT_ASM_OP
+#define UNALIGNED_DOUBLE_INT_ASM_OP    "\t.8byte\t"
+#endif
+#endif /* OBJECT_FORMAT_ELF */
+
+#ifndef ASM_BYTE_OP
+#define ASM_BYTE_OP                    "\t.byte\t"
+#endif
+
+/* We don't have unaligned support, let's hope the normal output works for
+   .debug_frame.  But we know it won't work for .debug_info.  */
+#if !defined(UNALIGNED_INT_ASM_OP) && defined(DWARF2_DEBUGGING_INFO)
+ #error DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP.
+#endif
+
+\f
+#ifdef UNALIGNED_INT_ASM_OP
+static const char * unaligned_integer_asm_op  PARAMS ((int));
+
+static inline const char *
+unaligned_integer_asm_op (size)
+     int size;
+{
+  const char *op;
+  switch (size)
+    {
+    case 1:
+      op = ASM_BYTE_OP;
+      break;
+    case 2:
+      op = UNALIGNED_SHORT_ASM_OP;
+      break;
+    case 4:
+      op = UNALIGNED_INT_ASM_OP;
+      break;
+    case 8:
+#ifdef UNALIGNED_DOUBLE_INT_ASM_OP
+      op = UNALIGNED_DOUBLE_INT_ASM_OP;
+      break;
+#endif
+    default:
+      abort ();
+    }
+  return op;
+}
+#endif /* UNALIGNED_INT_ASM_OP */
+
+void
+dw2_asm_output_data VPARAMS ((int size, unsigned HOST_WIDE_INT value,
+                             const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  int size;
+  unsigned HOST_WIDE_INT value;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  size = va_arg (ap, int);
+  value = va_arg (ap, unsigned HOST_WIDE_INT);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef UNALIGNED_INT_ASM_OP
+  fputs (unaligned_integer_asm_op (size), asm_out_file);
+  fprintf (asm_out_file, HOST_WIDE_INT_PRINT_HEX, value);
+#else
+  assemble_integer (GEN_INT (value), size, 1);
+#endif
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+void
+dw2_asm_output_delta VPARAMS ((int size, const char *lab1, const char *lab2,
+                              const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  int size;
+  const char *lab1, *lab2;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  size = va_arg (ap, int);
+  lab1 = va_arg (ap, const char *);
+  lab2 = va_arg (ap, const char *);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef UNALIGNED_INT_ASM_OP
+  fputs (unaligned_integer_asm_op (size), asm_out_file);
+  assemble_name (asm_out_file, lab1);
+  fputc ('-', asm_out_file);
+  assemble_name (asm_out_file, lab2);
+#else
+  assemble_integer (gen_rtx_MINUS (smallest_mode_for_size (size, MODE_INT, 0),
+                                  gen_rtx_SYMBOL_REF (Pmode, lab1),
+                                  gen_rtx_SYMBOL_REF (Pmode, lab2)),
+                   size, 1);
+#endif
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+void
+dw2_asm_output_offset VPARAMS ((int size, const char *label,
+                              const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  int size;
+  const char *label;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  size = va_arg (ap, int);
+  label = va_arg (ap, const char *);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef UNALIGNED_INT_ASM_OP
+  fputs (unaligned_integer_asm_op (size), asm_out_file);
+  assemble_name (asm_out_file, label);
+#else
+  assemble_integer (gen_rtx_SYMBOL_REF (Pmode, label), size, 1);
+#endif
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+void
+dw2_asm_output_pcrel VPARAMS ((int size, const char *label,
+                              const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  int size;
+  const char *label;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  size = va_arg (ap, int);
+  label = va_arg (ap, const char *);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef UNALIGNED_INT_ASM_OP
+  fputs (unaligned_integer_asm_op (size), asm_out_file);
+
+  /* ??? This needs target conditionalization.  E.g. the solaris
+     assembler uses %r_disp32(label).  Others don't like "." and
+     we need to generate a temporary label here.  */
+  assemble_name (asm_out_file, label);
+  fputc ('-', asm_out_file);
+  fputc ('.', asm_out_file);
+#else
+  abort ();
+#endif
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+void
+dw2_asm_output_addr_rtx VPARAMS ((int size, rtx addr,
+                                 const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  int size;
+  rtx addr;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  size = va_arg (ap, int);
+  addr = va_arg (ap, rtx);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef UNALIGNED_INT_ASM_OP
+  fputs (unaligned_integer_asm_op (size), asm_out_file);
+  output_addr_const (asm_out_file, addr);
+#else
+  assemble_integer (addr, size, 1);
+#endif
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+void
+dw2_asm_output_nstring VPARAMS ((const char *str, size_t orig_len,
+                                const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  const char *str;
+  size_t orig_len;
+  const char *comment;
+#endif
+  va_list ap;
+  size_t i, len = orig_len;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  str = va_arg (ap, const char *);
+  len = va_arg (ap, size_t);
+  comment = va_arg (ap, const char *);
+#endif
+
+  if (len == (size_t) -1)
+    len = strlen (str);
+
+  if (flag_debug_asm && comment)
+    {
+      fputs ("\t.ascii \"", asm_out_file);
+      for (i = 0; i < len; i++)
+       {
+         int c = str[i];
+         if (c == '\"' || c == '\\')
+           fputc ('\\', asm_out_file);
+         if (ISPRINT(c))
+           fputc (c, asm_out_file);
+         else
+           fprintf (asm_out_file, "\\%o", c);
+       }
+      fprintf (asm_out_file, "\\0\"\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+      fputc ('\n', asm_out_file);
+    }
+  else
+    {
+      /* If an explicit length was given, we can't assume there
+        is a null termination in the string buffer.  */
+      if (orig_len == (size_t) -1)
+       len += 1;
+      ASM_OUTPUT_ASCII (asm_out_file, str, len);
+      if (orig_len != (size_t) -1)
+       fprintf (asm_out_file, "%s0\n", ASM_BYTE_OP);
+    }
+
+  va_end (ap);
+}
+\f
+
+/* Return the size of an unsigned LEB128 quantity.  */
+
+int
+size_of_uleb128 (value)
+     unsigned HOST_WIDE_INT value;
+{
+  int size = 0, byte;
+
+  do
+    {
+      byte = (value & 0x7f);
+      value >>= 7;
+      size += 1;
+    }
+  while (value != 0);
+
+  return size;
+}
+
+/* Return the size of a signed LEB128 quantity.  */
+
+int
+size_of_sleb128 (value)
+     HOST_WIDE_INT value;
+{
+  int size = 0, byte;
+
+  do
+    {
+      byte = (value & 0x7f);
+      value >>= 7;
+      size += 1;
+    }
+  while (!((value == 0 && (byte & 0x40) == 0)
+          || (value == -1 && (byte & 0x40) != 0)));
+
+  return size;
+}
+
+/* Output an unsigned LEB128 quantity.  */
+
+void
+dw2_asm_output_data_uleb128 VPARAMS ((unsigned HOST_WIDE_INT value,
+                                     const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  unsigned HOST_WIDE_INT value;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  value = va_arg (ap, unsigned HOST_WIDE_INT);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef HAVE_AS_LEB128
+  fputs ("\t.uleb128\t", asm_out_file);
+  fprintf (asm_out_file, HOST_WIDE_INT_PRINT_HEX, value);
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+#else
+  {
+    unsigned HOST_WIDE_INT work = value;
+
+    fputs (ASM_BYTE_OP, asm_out_file);
+    do
+      {
+       int byte = (work & 0x7f);
+       work >>= 7;
+       if (work != 0)
+         /* More bytes to follow.  */
+         byte |= 0x80;
+
+       fprintf (asm_out_file, "0x%x", byte);
+       if (work != 0)
+         fputc (',', asm_out_file);
+      }
+    while (work != 0);
+
+  if (flag_debug_asm)
+    {
+      fprintf (asm_out_file, "\t%s uleb128 ", ASM_COMMENT_START);
+      fprintf (asm_out_file, HOST_WIDE_INT_PRINT_HEX, value);
+      if (comment)
+       {
+         fputs ("; ", asm_out_file);
+         vfprintf (asm_out_file, comment, ap);
+       }
+    }
+  }
+#endif
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+/* Output an signed LEB128 quantity.  */
+
+void
+dw2_asm_output_data_sleb128 VPARAMS ((HOST_WIDE_INT value,
+                                     const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  HOST_WIDE_INT value;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  value = va_arg (ap, HOST_WIDE_INT);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef HAVE_AS_LEB128
+  fputs ("\t.sleb128\t", asm_out_file);
+  fprintf (asm_out_file, HOST_WIDE_INT_PRINT_HEX, value);
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+#else
+  {
+    HOST_WIDE_INT work = value;
+    int more, byte;
+
+    fputs (ASM_BYTE_OP, asm_out_file);
+    do
+      {
+       byte = (work & 0x7f);
+       /* arithmetic shift */
+       work >>= 7;
+       more = !((work == 0 && (byte & 0x40) == 0)
+                || (work == -1 && (byte & 0x40) != 0));
+       if (more)
+         byte |= 0x80;
+
+       fprintf (asm_out_file, "0x%x", byte);
+       if (more)
+         fputc (',', asm_out_file);
+      }
+    while (more);
+
+  if (flag_debug_asm)
+    {
+      fprintf (asm_out_file, "\t%s sleb128 ", ASM_COMMENT_START);
+      fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, value);
+      if (comment)
+       {
+         fputs ("; ", asm_out_file);
+         vfprintf (asm_out_file, comment, ap);
+       }
+    }
+  }
+#endif
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+void
+dw2_asm_output_delta_uleb128 VPARAMS ((const char *lab1 ATTRIBUTE_UNUSED,
+                                      const char *lab2 ATTRIBUTE_UNUSED,
+                                      const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  const char *lab1, *lab2;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  lab1 = va_arg (ap, const char *);
+  lab2 = va_arg (ap, const char *);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef HAVE_AS_LEB128
+  fputs ("\t.uleb128\t", asm_out_file);
+  assemble_name (asm_out_file, lab1);
+  fputc ('-', asm_out_file);
+  assemble_name (asm_out_file, lab2);
+#else
+  abort ();
+#endif
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
+
+void
+dw2_asm_output_delta_sleb128 VPARAMS ((const char *lab1 ATTRIBUTE_UNUSED,
+                                      const char *lab2 ATTRIBUTE_UNUSED,
+                                      const char *comment, ...))
+{
+#ifndef ANSI_PROTOTYPES
+  const char *lab1, *lab2;
+  const char *comment;
+#endif
+  va_list ap;
+
+  VA_START (ap, comment);
+
+#ifndef ANSI_PROTOTYPES
+  lab1 = va_arg (ap, const char *);
+  lab2 = va_arg (ap, const char *);
+  comment = va_arg (ap, const char *);
+#endif
+
+#ifdef HAVE_AS_LEB128
+  fputs ("\t.sleb128\t", asm_out_file);
+  assemble_name (asm_out_file, lab1);
+  fputc ('-', asm_out_file);
+  assemble_name (asm_out_file, lab2);
+#else
+  abort ();
+#endif
+
+  if (flag_debug_asm && comment)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      vfprintf (asm_out_file, comment, ap);
+    }
+  fputc ('\n', asm_out_file);
+
+  va_end (ap);
+}
diff --git a/gcc/dwarf2asm.h b/gcc/dwarf2asm.h
new file mode 100644 (file)
index 0000000..a1a2ae9
--- /dev/null
@@ -0,0 +1,68 @@
+/* Dwarf2 assembler output helper routines.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+
+/* ??? Format checking yields "null format string" warnings, which is
+   the way these routines are signaled that there is no associated
+   debug information.  So the attributes are commented out.  */
+
+extern void dw2_asm_output_data                PARAMS ((int, unsigned HOST_WIDE_INT,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_3 */;
+
+extern void dw2_asm_output_delta       PARAMS ((int, const char *,
+                                                const char *,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_4 */;
+
+extern void dw2_asm_output_offset      PARAMS ((int, const char *,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_3 */;
+
+extern void dw2_asm_output_pcrel       PARAMS ((int, const char *,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_3 */;
+
+extern void dw2_asm_output_addr_rtx    PARAMS ((int, rtx,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_3 */;
+
+extern void dw2_asm_output_nstring     PARAMS ((const char *, size_t,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_3 */;
+
+extern void dw2_asm_output_data_uleb128        PARAMS ((unsigned HOST_WIDE_INT,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_2 */;
+
+extern void dw2_asm_output_data_sleb128        PARAMS ((HOST_WIDE_INT,
+                                                const char *, ...))
+     /* ATTRIBUTE_PRINTF_2 */;
+
+extern void dw2_asm_output_delta_uleb128 PARAMS ((const char *, const char *,
+                                                 const char *, ...))
+     /* ATTRIBUTE_PRINTF_3 */;
+
+extern void dw2_asm_output_delta_sleb128 PARAMS ((const char *, const char *,
+                                                 const char *, ...))
+     /* ATTRIBUTE_PRINTF_3 */;
+
+extern int size_of_uleb128             PARAMS ((unsigned HOST_WIDE_INT));
+extern int size_of_sleb128             PARAMS ((HOST_WIDE_INT));
index a34aa58..48777fe 100644 (file)
@@ -49,6 +49,7 @@ Boston, MA 02111-1307, USA.  */
 #include "except.h"
 #include "dwarf2.h"
 #include "dwarf2out.h"
+#include "dwarf2asm.h"
 #include "toplev.h"
 #include "varray.h"
 #include "ggc.h"
@@ -230,10 +231,6 @@ static char *stripattributes               PARAMS ((const char *));
 static const char *dwarf_cfi_name      PARAMS ((unsigned));
 static dw_cfi_ref new_cfi              PARAMS ((void));
 static void add_cfi                    PARAMS ((dw_cfi_ref *, dw_cfi_ref));
-static unsigned long size_of_uleb128   PARAMS ((unsigned long));
-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, dw_cfa_location *));
 static void lookup_cfa                 PARAMS ((dw_cfa_location *));
@@ -254,25 +251,9 @@ 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
-   assembler.  */
-
-#ifdef OBJECT_FORMAT_ELF
-#ifndef UNALIGNED_SHORT_ASM_OP
-#define UNALIGNED_SHORT_ASM_OP "\t.2byte\t"
-#endif
-#ifndef UNALIGNED_INT_ASM_OP
-#define UNALIGNED_INT_ASM_OP   "\t.4byte\t"
-#endif
-#ifndef UNALIGNED_DOUBLE_INT_ASM_OP
-#define UNALIGNED_DOUBLE_INT_ASM_OP    "\t.8byte\t"
-#endif
-#endif /* OBJECT_FORMAT_ELF */
-
-#ifndef ASM_BYTE_OP
-#define ASM_BYTE_OP            "\t.byte\t"
+/* How to start an assembler comment.  */
+#ifndef ASM_COMMENT_START
+#define ASM_COMMENT_START ";#"
 #endif
 
 /* Data and reference forms for relocatable data.  */
@@ -309,9 +290,12 @@ static void def_cfa_1                      PARAMS ((const char *, dw_cfa_location *));
 #define CIE_AFTER_SIZE_LABEL   "LSCIE"
 #define CIE_END_LABEL          "LECIE"
 #define CIE_LENGTH_LABEL       "LLCIE"
-#define FDE_AFTER_SIZE_LABEL   "LSFDE"
+#define FDE_LABEL              "LSFDE"
+#define FDE_AFTER_SIZE_LABEL   "LASFDE"
 #define FDE_END_LABEL          "LEFDE"
 #define FDE_LENGTH_LABEL       "LLFDE"
+#define LINE_NUMBER_BEGIN_LABEL        "LTSTART"
+#define LINE_NUMBER_END_LABEL  "LTEND"
 #define DIE_LABEL_PREFIX       "DW"
 
 /* Definitions of defaults for various types of primitive assembly language
@@ -323,212 +307,6 @@ static void def_cfa_1                     PARAMS ((const char *, dw_cfa_location *));
   fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION)
 #endif
 
-#ifndef ASM_OUTPUT_DWARF_DATA1
-#define ASM_OUTPUT_DWARF_DATA1(FILE,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), "%s", ASM_BYTE_OP);                    \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
-#endif
-
-#ifdef UNALIGNED_INT_ASM_OP
-
-#ifndef UNALIGNED_OFFSET_ASM_OP
-#define UNALIGNED_OFFSET_ASM_OP \
-  (DWARF_OFFSET_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
-#endif
-
-#ifndef UNALIGNED_WORD_ASM_OP
-#define UNALIGNED_WORD_ASM_OP                                          \
-  ((DWARF2_ADDR_SIZE) == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP               \
-   : (DWARF2_ADDR_SIZE) == 2 ? UNALIGNED_SHORT_ASM_OP                  \
-   : UNALIGNED_INT_ASM_OP)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA2
-#define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "%s", UNALIGNED_SHORT_ASM_OP);                 \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA4
-#define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "%s", UNALIGNED_INT_ASM_OP);                   \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA
-#define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2)                     \
- do {  fprintf ((FILE), "%s", UNALIGNED_OFFSET_ASM_OP);                \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
-#define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2)                        \
- do {  fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                  \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR
-#define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL)                              \
- do {  fprintf ((FILE), "%s", UNALIGNED_WORD_ASM_OP);                  \
-       assemble_name (FILE, LABEL);                                    \
-  } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR_CONST
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX)                          \
-  do {                                                                 \
-    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), "%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), "%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), "%s0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) (VALUE))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA4
-#define ASM_OUTPUT_DWARF_DATA4(FILE,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), "%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), "%s0x%lx", UNALIGNED_WORD_ASM_OP, \
-          (unsigned long) (VALUE))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_CONST_DOUBLE
-#define ASM_OUTPUT_DWARF_CONST_DOUBLE(FILE,HIGH_VALUE,LOW_VALUE)       \
-  do {                                                                 \
-    if (WORDS_BIG_ENDIAN)                                              \
-      {                                                                        \
-       fprintf ((FILE), "%s0x%lx\n", UNALIGNED_INT_ASM_OP, (HIGH_VALUE));\
-       fprintf ((FILE), "%s0x%lx", UNALIGNED_INT_ASM_OP, (LOW_VALUE));\
-      }                                                                        \
-    else                                                               \
-      {                                                                        \
-       fprintf ((FILE), "%s0x%lx\n", UNALIGNED_INT_ASM_OP, (LOW_VALUE)); \
-       fprintf ((FILE), "%s0x%lx", UNALIGNED_INT_ASM_OP, (HIGH_VALUE)); \
-      }                                                                        \
-  } while (0)
-#endif
-
-#else /* UNALIGNED_INT_ASM_OP */
-
-/* We don't have unaligned support, let's hope the normal output works for
-   .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 */
-
 #ifdef SET_ASM_OP
 #ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)            \
@@ -543,35 +321,6 @@ static void def_cfa_1                      PARAMS ((const char *, dw_cfa_location *));
 #endif
 #endif /* SET_ASM_OP */
 
-/* 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_NSTRING
-#define ASM_OUTPUT_DWARF_NSTRING(FILE,P,SLEN) \
-  do {                                                                       \
-    register int slen = (SLEN);                                               \
-    register const char *p = (P);                                            \
-    register int i;                                                          \
-    fprintf (FILE, "\t.ascii \"");                                           \
-    for (i = 0; i < slen; i++)                                               \
-      {                                                                              \
-         register int c = p[i];                                              \
-         if (c == '\"' || c == '\\')                                         \
-           putc ('\\', FILE);                                                \
-         if (ISPRINT(c))                                                     \
-           putc (c, FILE);                                                   \
-         else                                                                \
-           {                                                                 \
-             fprintf (FILE, "\\%o", c);                                      \
-           }                                                                 \
-      }                                                                              \
-    fprintf (FILE, "\\0\"");                                                 \
-  }                                                                          \
-  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
    registers.  */
@@ -1732,9 +1481,6 @@ dwarf2out_frame_debug (insn)
 
   if (insn == NULL_RTX)
     {
-      rtx insn;
-      int n_alternate_entry_points;
-
       /* Set up state for generating call frame debug info.  */
       lookup_cfa (&cfa);
       if (cfa.reg != (unsigned long) DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM))
@@ -1763,105 +1509,6 @@ dwarf2out_frame_debug (insn)
   dwarf2out_frame_debug_expr (insn, label);
 }
 
-/* Return the size of an unsigned LEB128 quantity.  */
-
-static inline unsigned long
-size_of_uleb128 (value)
-     register unsigned long value;
-{
-  register unsigned long size = 0;
-  register unsigned byte;
-
-  do
-    {
-      byte = (value & 0x7f);
-      value >>= 7;
-      size += 1;
-    }
-  while (value != 0);
-
-  return size;
-}
-
-/* Return the size of a signed LEB128 quantity.  */
-
-static inline unsigned long
-size_of_sleb128 (value)
-     register long value;
-{
-  register unsigned long size = 0;
-  register unsigned byte;
-
-  do
-    {
-      byte = (value & 0x7f);
-      value >>= 7;
-      size += 1;
-    }
-  while (!(((value == 0) && ((byte & 0x40) == 0))
-          || ((value == -1) && ((byte & 0x40) != 0))));
-
-  return size;
-}
-
-/* Output an unsigned LEB128 quantity.  */
-
-static void
-output_uleb128 (value)
-     register unsigned long value;
-{
-  unsigned long save_value = value;
-
-  fprintf (asm_out_file, "%s", ASM_BYTE_OP);
-  do
-    {
-      register unsigned byte = (value & 0x7f);
-      value >>= 7;
-      if (value != 0)
-       /* More bytes to follow.  */
-       byte |= 0x80;
-
-      fprintf (asm_out_file, "0x%x", byte);
-      if (value != 0)
-       fprintf (asm_out_file, ",");
-    }
-  while (value != 0);
-
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s ULEB128 0x%lx", ASM_COMMENT_START, save_value);
-}
-
-/* Output an signed LEB128 quantity.  */
-
-static void
-output_sleb128 (value)
-     register long value;
-{
-  register int more;
-  register unsigned byte;
-  long save_value = value;
-
-  fprintf (asm_out_file, "%s", ASM_BYTE_OP);
-  do
-    {
-      byte = (value & 0x7f);
-      /* arithmetic shift */
-      value >>= 7;
-      more = !((((value == 0) && ((byte & 0x40) == 0))
-               || ((value == -1) && ((byte & 0x40) != 0))));
-      if (more)
-       byte |= 0x80;
-
-      fprintf (asm_out_file, "0x%x", byte);
-      if (more)
-       fprintf (asm_out_file, ",");
-    }
-
-  while (more);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s SLEB128 %ld", ASM_COMMENT_START, save_value);
-}
-
 /* Output a Call Frame Information opcode and its operand(s).  */
 
 static void
@@ -1871,114 +1518,79 @@ output_cfi (cfi, fde)
 {
   if (cfi->dw_cfi_opc == DW_CFA_advance_loc)
     {
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
-                             cfi->dw_cfi_opc
-                             | (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f));
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s DW_CFA_advance_loc 0x%lx",
-                ASM_COMMENT_START, cfi->dw_cfi_oprnd1.dw_cfi_offset);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, (cfi->dw_cfi_opc
+                              | (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f)),
+                          "DW_CFA_advance_loc 0x%lx",
+                          cfi->dw_cfi_oprnd1.dw_cfi_offset);
     }
-
   else if (cfi->dw_cfi_opc == DW_CFA_offset)
     {
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
-                             cfi->dw_cfi_opc
-                             | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f));
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s DW_CFA_offset, column 0x%lx",
-                ASM_COMMENT_START, cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-
-      fputc ('\n', asm_out_file);
-      output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, (cfi->dw_cfi_opc
+                              | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
+                          "DW_CFA_offset, column 0x%lx",
+                          cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
+      dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
     }
   else if (cfi->dw_cfi_opc == DW_CFA_restore)
     {
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
-                             cfi->dw_cfi_opc
-                             | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f));
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s DW_CFA_restore, column 0x%lx",
-                ASM_COMMENT_START, cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, (cfi->dw_cfi_opc
+                              | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
+                          "DW_CFA_restore, column 0x%lx",
+                          cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
     }
   else
     {
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, cfi->dw_cfi_opc);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START,
-                dwarf_cfi_name (cfi->dw_cfi_opc));
+      dw2_asm_output_data (1, cfi->dw_cfi_opc,
+                          "%s", dwarf_cfi_name (cfi->dw_cfi_opc));
 
-      fputc ('\n', asm_out_file);
       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);
+         dw2_asm_output_offset (DWARF2_ADDR_SIZE, 
+                                  cfi->dw_cfi_oprnd1.dw_cfi_addr, NULL);
          break;
        case DW_CFA_advance_loc1:
-         ASM_OUTPUT_DWARF_DELTA1 (asm_out_file,
-                                  cfi->dw_cfi_oprnd1.dw_cfi_addr,
-                                  fde->dw_fde_current_label);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_delta (1, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+                               fde->dw_fde_current_label, NULL);
          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,
-                                  cfi->dw_cfi_oprnd1.dw_cfi_addr,
-                                  fde->dw_fde_current_label);
-          fputc ('\n', asm_out_file);
+         dw2_asm_output_delta (2, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+                               fde->dw_fde_current_label, NULL);
          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,
-                                  cfi->dw_cfi_oprnd1.dw_cfi_addr,
-                                  fde->dw_fde_current_label);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_delta (4, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+                               fde->dw_fde_current_label, NULL);
          fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
-#ifdef MIPS_DEBUGGING_INFO
        case DW_CFA_MIPS_advance_loc8:
-         /* TODO: not currently implemented.  */
-         abort ();
+         dw2_asm_output_delta (8, cfi->dw_cfi_oprnd1.dw_cfi_addr,
+                               fde->dw_fde_current_label, NULL);
+         fde->dw_fde_current_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
          break;
-#endif
        case DW_CFA_offset_extended:
        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);
-         output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, NULL);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
          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);
-         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);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, NULL);
          break;
        case DW_CFA_register:
-         output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
-         fputc ('\n', asm_out_file);
-         output_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, NULL);
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num, NULL);
          break;
        case DW_CFA_def_cfa_offset:
-         output_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset);
-         fputc ('\n', asm_out_file);
+       case DW_CFA_GNU_args_size:
+         dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_offset, NULL);
          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);
-         break;
        case DW_CFA_def_cfa_expression:
          output_cfa_loc (cfi);
          break;
@@ -2018,8 +1630,6 @@ output_call_frame_info (for_eh)
     found:;
     }
 
-  fputc ('\n', asm_out_file);
-
   /* We're going to be generating comments, so turn on app.  */
   if (flag_debug_asm)
     app_enable ();
@@ -2046,91 +1656,43 @@ output_call_frame_info (for_eh)
   ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
 #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
   ASM_GENERATE_INTERNAL_LABEL (ld, CIE_LENGTH_LABEL, for_eh);
-  if (for_eh)
-    ASM_OUTPUT_DWARF_OFFSET4 (asm_out_file, ld);
-  else
-    ASM_OUTPUT_DWARF_OFFSET (asm_out_file, ld);
+  dw2_asm_output_offset (for_eh ? 4 : DWARF_OFFSET_SIZE, ld,
+                       "Length of Common Information Entry");
 #else
-  if (for_eh)
-    ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, l2, l1);
-  else
-    ASM_OUTPUT_DWARF_DELTA (asm_out_file, l2, l1);
+  dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
+                       "Length of Common Information Entry");
 #endif
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Length of Common Information Entry",
-            ASM_COMMENT_START);
-
-  fputc ('\n', asm_out_file);
   ASM_OUTPUT_LABEL (asm_out_file, l1);
 
-  if (for_eh)
-    /* Now that the CIE pointer is PC-relative for EH,
-       use 0 to identify the CIE.  */
-    ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-  else
-    ASM_OUTPUT_DWARF_DATA4 (asm_out_file, DW_CIE_ID);
-
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s CIE Identifier Tag", ASM_COMMENT_START);
-
-  fputc ('\n', asm_out_file);
-  if (! for_eh && DWARF_OFFSET_SIZE == 8)
-    {
-      ASM_OUTPUT_DWARF_DATA4 (asm_out_file, DW_CIE_ID);
-      fputc ('\n', asm_out_file);
-    }
+  /* Now that the CIE pointer is PC-relative for EH,
+     use 0 to identify the CIE.  */
+  dw2_asm_output_data ((for_eh ? 4 : DWARF_OFFSET_SIZE),
+                      (for_eh ? 0 : DW_CIE_ID),
+                      "CIE Identifier Tag");
 
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_CIE_VERSION);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s CIE Version", ASM_COMMENT_START);
+  dw2_asm_output_data (1, DW_CIE_VERSION, "CIE Version");
 
-  fputc ('\n', asm_out_file);
   if (eh_ptr)
     {
       /* The CIE contains a pointer to the exception region info for the
          frame.  Make the augmentation string three bytes (including the
          trailing null) so the pointer is 4-byte aligned.  The Solaris ld
          can't handle unaligned relocs.  */
-      if (flag_debug_asm)
-       {
-         ASM_OUTPUT_DWARF_STRING (asm_out_file, "eh");
-         fprintf (asm_out_file, "\t%s CIE Augmentation", ASM_COMMENT_START);
-       }
-      else
-       {
-         ASM_OUTPUT_ASCII (asm_out_file, "eh", 3);
-       }
-      fputc ('\n', asm_out_file);
-
-      ASM_OUTPUT_DWARF_ADDR (asm_out_file, "__EXCEPTION_TABLE__");
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s pointer to exception region info",
-                ASM_COMMENT_START);
+      dw2_asm_output_nstring ("eh", 3, "CIE Augmentation");
+      dw2_asm_output_offset (DWARF2_ADDR_SIZE, "__EXCEPTION_TABLE__",
+                            "pointer to exception region info");
     }
   else
     {
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s CIE Augmentation (none)",
-                ASM_COMMENT_START);
+      dw2_asm_output_data (1, 0, "CIE Augmentation (none)");
     }
 
-  fputc ('\n', asm_out_file);
-  output_uleb128 (1);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, " (CIE Code Alignment Factor)");
+  dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
 
-  fputc ('\n', asm_out_file);
-  output_sleb128 (DWARF_CIE_DATA_ALIGNMENT);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, " (CIE Data Alignment Factor)");
-
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_FRAME_RETURN_COLUMN);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s CIE RA Column", ASM_COMMENT_START);
+  dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT,
+                              "CIE Data Alignment Factor");
 
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data (1, DWARF_FRAME_RETURN_COLUMN, "CIE RA Column");
 
   for (cfi = cie_cfi_head; cfi != NULL; cfi = cfi->dw_cfi_next)
     output_cfi (cfi, NULL);
@@ -2154,23 +1716,16 @@ output_call_frame_info (for_eh)
       if (for_eh && fde->nothrow)
        continue;
 
+      ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, FDE_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);
-      if (for_eh)
-       ASM_OUTPUT_DWARF_OFFSET4 (asm_out_file, ld);
-      else
-       ASM_OUTPUT_DWARF_OFFSET (asm_out_file, ld);
+      dw2_asm_output_offset (for_eh ? 4 : DWARF_OFFSET_SIZE, ld, "FDE Length");
 #else
-      if (for_eh)
-       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, l2, l1);
-      else
-       ASM_OUTPUT_DWARF_DELTA (asm_out_file, l2, l1);
+      dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
+                           "FDE Length");
 #endif
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s FDE Length", ASM_COMMENT_START);
-      fputc ('\n', asm_out_file);
       ASM_OUTPUT_LABEL (asm_out_file, l1);
 
       /* ??? This always emits a 4 byte offset when for_eh is true, but it
@@ -2182,24 +1737,17 @@ output_call_frame_info (for_eh)
         If the for_eh case is changed, then the struct in frame.c has
         to be adjusted appropriately.  */
       if (for_eh)
-       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, l1, "__FRAME_BEGIN__");
+       dw2_asm_output_delta (4, l1, "__FRAME_BEGIN__", "FDE CIE offset");
       else
-       ASM_OUTPUT_DWARF_OFFSET (asm_out_file, stripattributes (FRAME_SECTION));
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s FDE CIE offset", ASM_COMMENT_START);
+       dw2_asm_output_offset (DWARF_OFFSET_SIZE,
+                              stripattributes (FRAME_SECTION),
+                              "FDE CIE offset");
 
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_DWARF_ADDR (asm_out_file, fde->dw_fde_begin);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s FDE initial location", ASM_COMMENT_START);
-
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file,
-                                  fde->dw_fde_end, fde->dw_fde_begin);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s FDE address range", ASM_COMMENT_START);
+      dw2_asm_output_offset (DWARF2_ADDR_SIZE, fde->dw_fde_begin,
+                            "FDE initial location");
 
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_delta (DWARF2_ADDR_SIZE, fde->dw_fde_end,
+                           fde->dw_fde_begin, "FDE address range");
 
       /* Loop through the Call Frame Instructions associated with
         this FDE.  */
@@ -2217,13 +1765,10 @@ output_call_frame_info (for_eh)
       fputc ('\n', asm_out_file);
 #endif
     }
+
 #ifndef EH_FRAME_SECTION
   if (for_eh)
-    {
-      /* Emit terminating zero for table.  */
-      ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-      fputc ('\n', asm_out_file);
-    }
+    dw2_asm_output_data (4, 0, "End of Table");
 #endif
 #ifdef MIPS_DEBUGGING_INFO
   /* Work around Irix 6 assembler bug whereby labels at the end of a section
@@ -2902,23 +2447,21 @@ output_loc_operands (loc)
     {
 #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);
+      dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, val1->v.val_addr, NULL);
       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);
+      dw2_asm_output_data (2, val1->v.val_int, NULL);
       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);
+      dw2_asm_output_data (4, val1->v.val_int, NULL);
       break;
     case DW_OP_const8u:
     case DW_OP_const8s:
-      abort ();
-      fputc ('\n', asm_out_file);
+      if (HOST_BITS_PER_LONG < 64)
+       abort ();
+      dw2_asm_output_data (8, val1->v.val_int, NULL);
       break;
     case DW_OP_skip:
     case DW_OP_bra:
@@ -2930,8 +2473,7 @@ output_loc_operands (loc)
        else
          abort ();
 
-       ASM_OUTPUT_DWARF_DATA2 (asm_out_file, offset);
-       fputc ('\n', asm_out_file);
+       dw2_asm_output_data (2, offset, NULL);
       }
       break;
 #else
@@ -2952,24 +2494,19 @@ output_loc_operands (loc)
 #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);
+      dw2_asm_output_data (1, val1->v.val_int, NULL);
       break;
     case DW_OP_constu:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
       break;
     case DW_OP_consts:
-      output_sleb128 (val1->v.val_int);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
       break;
     case DW_OP_pick:
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_int);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, val1->v.val_int, NULL);
       break;
     case DW_OP_plus_uconst:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
       break;
     case DW_OP_breg0:
     case DW_OP_breg1:
@@ -3003,31 +2540,24 @@ output_loc_operands (loc)
     case DW_OP_breg29:
     case DW_OP_breg30:
     case DW_OP_breg31:
-      output_sleb128 (val1->v.val_int);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
       break;
     case DW_OP_regx:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
       break;
     case DW_OP_fbreg:
-      output_sleb128 (val1->v.val_int);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
       break;
     case 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);
+      dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
+      dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
       break;
     case DW_OP_piece:
-      output_uleb128 (val1->v.val_unsigned);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
       break;
     case DW_OP_deref_size:
     case DW_OP_xderef_size:
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, val1->v.val_int, NULL);
       break;
     default:
       /* Other codes have no operands.  */
@@ -3044,12 +2574,8 @@ output_loc_sequence (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);
+      dw2_asm_output_data (1, loc->dw_loc_opc,
+                          "%s", dwarf_stack_op_name (loc->dw_loc_opc));
 
       /* Output the operand(s) (if any).  */
       output_loc_operands (loc);
@@ -3069,8 +2595,7 @@ output_cfa_loc (cfi)
   /* 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);
+  dw2_asm_output_data_uleb128 (size, NULL);
 
   /* Now output the operations themselves.  */
   output_loc_sequence (loc);
@@ -3665,7 +3190,6 @@ 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));
@@ -5799,7 +5323,7 @@ size_of_die (die)
          size += constant_size (AT_unsigned (a));
          break;
        case dw_val_class_long_long:
-         size += 1 + 8; /* block */
+         size += 1 + 2*HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR; /* block */
          break;
        case dw_val_class_float:
          size += 1 + a->dw_attr_val.v.val_float.length * 4; /* block */
@@ -6023,12 +5547,7 @@ output_value_format (a)
      dw_attr_ref a;
 {
   enum dwarf_form form = value_format (a);
-
-  output_uleb128 (form);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, " (%s)", dwarf_form_name (form));
-
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data_uleb128 (form, "(%s)", dwarf_form_name (form));
 }
 
 /* Output the .debug_abbrev section which defines the DIE abbreviation
@@ -6044,45 +5563,30 @@ output_abbrev_section ()
     {
       register dw_die_ref abbrev = abbrev_die_table[abbrev_id];
 
-      output_uleb128 (abbrev_id);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, " (abbrev code)");
+      dw2_asm_output_data_uleb128 (abbrev_id, "(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));
+      dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)",
+                                  dwarf_tag_name (abbrev->die_tag));
 
-      fputc ('\n', asm_out_file);
-      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);
+      if (abbrev->die_child != NULL)
+       dw2_asm_output_data (1, DW_children_yes, "DW_children_yes");
+      else
+       dw2_asm_output_data (1, DW_children_no, "DW_children_no");
 
       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);
+         dw2_asm_output_data_uleb128 (a_attr->dw_attr, "(%s)",
+                                      dwarf_attr_name (a_attr->dw_attr));
          output_value_format (a_attr);
        }
 
-      fprintf (asm_out_file, "%s0,0\n", ASM_BYTE_OP);
+      dw2_asm_output_data (1, 0, NULL);
+      dw2_asm_output_data (1, 0, NULL);
     }
 
   /* Terminate the table.  */
-  fprintf (asm_out_file, "%s0\n", ASM_BYTE_OP);
+  dw2_asm_output_data (1, 0, NULL);
 }
 
 /* Output a symbol we can use to refer to this DIE from another CU.  */
@@ -6104,20 +5608,6 @@ output_die_symbol (die)
   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
    the definitions of each child DIE.  */
 
@@ -6134,42 +5624,24 @@ output_die (die)
   if (die->die_symbol)
     output_die_symbol (die);
 
-  output_uleb128 (die->die_abbrev);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, " (DIE (0x%lx) %s)",
-            die->die_offset, dwarf_tag_name (die->die_tag));
-
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data_uleb128 (die->die_abbrev, "(DIE (0x%lx) %s)",
+                              die->die_offset, dwarf_tag_name (die->die_tag));
 
   for (a = die->die_attr; a != NULL; a = a->dw_attr_next)
     {
+      const char *name = dwarf_attr_name (a->dw_attr);
+
       switch (AT_class (a))
        {
        case dw_val_class_addr:
-         ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, AT_addr (a));
+         dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, AT_addr (a), "%s", name);
          break;
 
        case dw_val_class_loc:
          size = size_of_locs (AT_loc (a));
 
          /* Output the block length for this list of location operations.  */
-         switch (constant_size (size))
-           {
-           case 1:
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, size);
-             break;
-           case 2:
-             ASM_OUTPUT_DWARF_DATA2 (asm_out_file, size);
-             break;
-           default:
-             abort ();
-           }
-
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s %s",
-                    ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
-
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (constant_size (size), size, "%s", name);
 
          output_loc_sequence (AT_loc (a));
          break;
@@ -6178,123 +5650,94 @@ output_die (die)
          /* ??? 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));
+         dw2_asm_output_data_sleb128 (AT_int (a), "%s", name);
          break;
 
        case dw_val_class_unsigned_const:
-         switch (constant_size (AT_unsigned (a)))
-           {
-           case 1:
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, AT_unsigned (a));
-             break;
-           case 2:
-             ASM_OUTPUT_DWARF_DATA2 (asm_out_file, AT_unsigned (a));
-             break;
-           case 4:
-             ASM_OUTPUT_DWARF_DATA4 (asm_out_file, AT_unsigned (a));
-             break;
-           case 8:
-             ASM_OUTPUT_DWARF_DATA8 (asm_out_file, AT_unsigned (a));
-             break;
-           default:
-             abort ();
-           }
+         dw2_asm_output_data (constant_size (AT_unsigned (a)),
+                              AT_unsigned (a), "%s", name);
          break;
 
        case dw_val_class_long_long:
-         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));
-
-         fputc ('\n', asm_out_file);
-         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);
+         {
+           unsigned HOST_WIDE_INT first, second;
 
-         if (flag_debug_asm)
-           fprintf (asm_out_file,
-                    "\t%s long long constant", ASM_COMMENT_START);
+           dw2_asm_output_data (1, 2*HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR,
+                                "%s", name);
 
-         fputc ('\n', asm_out_file);
+           if (WORDS_BIG_ENDIAN)
+             {
+               first = a->dw_attr_val.v.val_long_long.hi;
+               second = a->dw_attr_val.v.val_long_long.low;
+             }
+           else
+             {
+               first = a->dw_attr_val.v.val_long_long.low;
+               second = a->dw_attr_val.v.val_long_long.hi;
+             }
+           dw2_asm_output_data (HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR,
+                                first, "long long constant");
+           dw2_asm_output_data (HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR,
+                                second, NULL);
+         }
          break;
 
        case dw_val_class_float:
          {
            register unsigned int i;
-           ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
-                                   a->dw_attr_val.v.val_float.length * 4);
-           if (flag_debug_asm)
-             fprintf (asm_out_file, "\t%s %s",
-                      ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
 
-           fputc ('\n', asm_out_file);
-           for (i = 0; i < a->dw_attr_val.v.val_float.length; ++i)
-             {
-               ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
-                                       a->dw_attr_val.v.val_float.array[i]);
-               if (flag_debug_asm)
-                 fprintf (asm_out_file, "\t%s fp constant word %u",
-                          ASM_COMMENT_START, i);
+           dw2_asm_output_data (1, a->dw_attr_val.v.val_float.length * 4,
+                                "%s", name);
 
-               fputc ('\n', asm_out_file);
-             }
+           for (i = 0; i < a->dw_attr_val.v.val_float.length; ++i)
+             dw2_asm_output_data (4, a->dw_attr_val.v.val_float.array[i],
+                                  "fp constant word %u", i);
            break;
          }
 
        case dw_val_class_flag:
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, AT_flag (a));
+         dw2_asm_output_data (1, AT_flag (a), "%s", name);
          break;
 
        case dw_val_class_die_ref:
          if (AT_ref_external (a))
-           output_symbolic_ref (AT_ref (a));
+           {
+             char *sym = AT_ref (a)->die_symbol;
+             if (sym == 0)
+               abort ();
+             dw2_asm_output_offset (DWARF2_ADDR_SIZE, sym, "%s", name);
+           }
          else if (AT_ref (a)->die_offset == 0)
            abort ();
          else
-           ASM_OUTPUT_DWARF_DATA (asm_out_file, AT_ref (a)->die_offset);
+           dw2_asm_output_data (DWARF_OFFSET_SIZE, AT_ref (a)->die_offset,
+                                "%s", name);
          break;
 
        case dw_val_class_fde_ref:
          {
            char l1[20];
-           ASM_GENERATE_INTERNAL_LABEL
-             (l1, FDE_AFTER_SIZE_LABEL, a->dw_attr_val.v.val_fde_index * 2);
-           ASM_OUTPUT_DWARF_OFFSET (asm_out_file, l1);
-           fprintf (asm_out_file, " - %d", DWARF_OFFSET_SIZE);
+           ASM_GENERATE_INTERNAL_LABEL (l1, FDE_LABEL,
+                                        a->dw_attr_val.v.val_fde_index * 2);
+           dw2_asm_output_offset (DWARF_OFFSET_SIZE, l1, "%s", name);
          }
          break;
 
        case dw_val_class_lbl_id:
-         ASM_OUTPUT_DWARF_ADDR (asm_out_file, AT_lbl (a));
+         dw2_asm_output_offset (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name);
          break;
 
        case dw_val_class_lbl_offset:
-         ASM_OUTPUT_DWARF_OFFSET (asm_out_file, AT_lbl (a));
+         dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a), "%s", name);
          break;
 
        case dw_val_class_str:
-         if (flag_debug_asm)
-           ASM_OUTPUT_DWARF_STRING (asm_out_file, AT_string (a));
-         else
-           ASM_OUTPUT_ASCII (asm_out_file, AT_string (a),
-                             (int) strlen (AT_string (a)) + 1);
+         dw2_asm_output_nstring (AT_string (a), -1, "%s", name);
          break;
 
        default:
          abort ();
        }
-
-      if (AT_class (a) != dw_val_class_loc
-         && AT_class (a) != dw_val_class_long_long
-         && AT_class (a) != dw_val_class_float)
-       {
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s %s",
-                    ASM_COMMENT_START, dwarf_attr_name (a->dw_attr));
-
-         fputc ('\n', asm_out_file);
-       }
     }
 
   for (c = die->die_child; c != NULL; c = c->die_sib)
@@ -6303,12 +5746,8 @@ output_die (die)
   if (die->die_child != NULL)
     {
       /* 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",
-                ASM_COMMENT_START, die->die_offset);
-
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, 0, "end of children of DIE 0x%lx",
+                          die->die_offset);
     }
 }
 
@@ -6318,28 +5757,15 @@ output_die (die)
 static void
 output_compilation_unit_header ()
 {
-  ASM_OUTPUT_DWARF_DATA (asm_out_file, next_die_offset - DWARF_OFFSET_SIZE);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Length of Compilation Unit Info.",
-            ASM_COMMENT_START);
+  dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset - DWARF_OFFSET_SIZE,
+                      "Length of Compilation Unit Info");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s DWARF version number", ASM_COMMENT_START);
+  dw2_asm_output_data (2, DWARF_VERSION, "DWARF version number");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, abbrev_section_label);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Offset Into Abbrev. Section",
-            ASM_COMMENT_START);
-
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF2_ADDR_SIZE);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Pointer Size (in bytes)", ASM_COMMENT_START);
+  dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
+                        "Offset Into Abbrev. Section");
 
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
 }
 
 /* Output the compilation unit DIE and its children.  */
@@ -6373,7 +5799,6 @@ output_comp_unit (die)
     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);
@@ -6431,30 +5856,17 @@ output_pubnames ()
   register unsigned i;
   register unsigned long pubnames_length = size_of_pubnames ();
 
-  ASM_OUTPUT_DWARF_DATA (asm_out_file, pubnames_length);
-
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Length of Public Names Info.",
-            ASM_COMMENT_START);
+  dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
+                      "Length of Public Names Info");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
-
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
+  dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, debug_info_section_label);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.",
-            ASM_COMMENT_START);
+  dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
+                        "Offset of Compilation Unit Info");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA (asm_out_file, next_die_offset);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Compilation Unit Length", ASM_COMMENT_START);
+  dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset,
+                      "Compilation Unit Length");
 
-  fputc ('\n', asm_out_file);
   for (i = 0; i < pubname_table_in_use; ++i)
     {
       register pubname_ref pub = &pubname_table[i];
@@ -6463,28 +5875,13 @@ output_pubnames ()
       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);
-
-      fputc ('\n', asm_out_file);
-
-      if (flag_debug_asm)
-       {
-         ASM_OUTPUT_DWARF_STRING (asm_out_file, pub->name);
-         fprintf (asm_out_file, "%s external name", ASM_COMMENT_START);
-       }
-      else
-       {
-         ASM_OUTPUT_ASCII (asm_out_file, pub->name,
-                           (int) strlen (pub->name) + 1);
-       }
+      dw2_asm_output_data (DWARF_OFFSET_SIZE, pub->die->die_offset,
+                          "DIE offset");
 
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_nstring (pub->name, -1, "external name");
     }
 
-  ASM_OUTPUT_DWARF_DATA (asm_out_file, 0);
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, NULL);
 }
 
 /* Add a new entry to .debug_aranges if appropriate.  */
@@ -6518,60 +5915,33 @@ output_aranges ()
   register unsigned i;
   register unsigned long aranges_length = size_of_aranges ();
 
-  ASM_OUTPUT_DWARF_DATA (asm_out_file, aranges_length);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Length of Address Ranges Info.",
-            ASM_COMMENT_START);
-
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
+  dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
+                      "Length of Address Ranges Info");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, debug_info_section_label);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.",
-            ASM_COMMENT_START);
+  dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF2_ADDR_SIZE);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Size of Address", ASM_COMMENT_START);
+  dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
+                        "Offset of Compilation Unit Info");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Size of Segment Descriptor",
-            ASM_COMMENT_START);
+  dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address");
 
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
 
   /* We need to align to twice the pointer size here.  */
   if (DWARF_ARANGES_PAD_SIZE)
     {
-      /* Pad using a 2 bytes word so that padding is correct
-         for any pointer size.  */
-      ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
+      /* Pad using a 2 byte words so that padding is correct for any
+         pointer size.  */
+      dw2_asm_output_data (2, 0, "Pad to %d byte boundary",
+                          2 * DWARF2_ADDR_SIZE);
       for (i = 2; i < (unsigned) DWARF_ARANGES_PAD_SIZE; i += 2)
-       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);
+       dw2_asm_output_data (2, 0, NULL);
     }
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_ADDR (asm_out_file, text_section_label);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Address", ASM_COMMENT_START);
+  dw2_asm_output_offset (DWARF2_ADDR_SIZE, text_section_label, "Address");
+  dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
+                       text_section_label, "Length");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file, text_end_label,
-                              text_section_label);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "%s Length", ASM_COMMENT_START);
-
-  fputc ('\n', asm_out_file);
   for (i = 0; i < arange_table_in_use; ++i)
     {
       dw_die_ref die = arange_table[i];
@@ -6581,7 +5951,12 @@ output_aranges ()
        abort ();
 
       if (die->die_tag == DW_TAG_subprogram)
-       ASM_OUTPUT_DWARF_ADDR (asm_out_file, get_AT_low_pc (die));
+       {
+         dw2_asm_output_offset (DWARF2_ADDR_SIZE, get_AT_low_pc (die),
+                                "Address");
+         dw2_asm_output_delta (DWARF2_ADDR_SIZE, get_AT_hi_pc (die),
+                               get_AT_low_pc (die), "Length");
+       }
       else
        {
          /* A static variable; extract the symbol from DW_AT_location.
@@ -6597,32 +5972,17 @@ output_aranges ()
          if (loc->dw_loc_opc != DW_OP_addr)
            abort ();
 
-         ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file,
-                                      loc->dw_loc_oprnd1.v.val_addr);
+         dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE,
+                                  loc->dw_loc_oprnd1.v.val_addr, "Address");
+         dw2_asm_output_data (DWARF2_ADDR_SIZE,
+                              get_AT_unsigned (die, DW_AT_byte_size),
+                              "Length");
        }
-
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s Address", ASM_COMMENT_START);
-
-      fputc ('\n', asm_out_file);
-      if (die->die_tag == DW_TAG_subprogram)
-       ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file, get_AT_hi_pc (die),
-                                    get_AT_low_pc (die));
-      else
-       ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file,
-                                   get_AT_unsigned (die, DW_AT_byte_size));
-
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "%s Length", ASM_COMMENT_START);
-
-      fputc ('\n', asm_out_file);
     }
 
   /* Output the terminator words.  */
-  ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file, 0);
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file, 0);
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
+  dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
 }
 
 
@@ -6930,30 +6290,15 @@ output_file_names ()
     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);
-         }
+       dw2_asm_output_nstring (dirs[i].path, dirs[i].length - 1,
+                               "Directory Entry: 0x%x", dirs[i].used);
       }
+  dw2_asm_output_data (1, 0, "End directory table");
+
   /* 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)
@@ -6961,38 +6306,19 @@ output_file_names ()
       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);
+      dw2_asm_output_nstring (files[file_idx].path + dirs[dir_idx].length, -1,
+                             "File Entry: 0x%x", i);
 
       /* Include directory index.  */
-      output_uleb128 (dirs[dir_idx].used);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_uleb128 (dirs[dir_idx].used, NULL);
 
       /* Modification time.  */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_uleb128 (0, NULL);
 
       /* File length in bytes.  */
-      output_uleb128 (0);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data_uleb128 (0, NULL);
     }
-
-  /* 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);
+  dw2_asm_output_data (1, 0, "End file name table");
 }
 
 
@@ -7002,6 +6328,7 @@ output_file_names ()
 static void
 output_line_info ()
 {
+  char l1[20], l2[20];
   char line_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char prev_line_label[MAX_ARTIFICIAL_LABEL_BYTES];
   register unsigned opc;
@@ -7013,52 +6340,33 @@ output_line_info ()
   register unsigned long current_file;
   register unsigned long function;
 
-  ASM_OUTPUT_DWARF_DELTA (asm_out_file, ".LTEND", ".LTSTART");
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Length of Source Line Info.",
-            ASM_COMMENT_START);
+  ASM_GENERATE_INTERNAL_LABEL (l1, LINE_NUMBER_BEGIN_LABEL, 0);
+  ASM_GENERATE_INTERNAL_LABEL (l2, LINE_NUMBER_END_LABEL, 0);
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_LABEL (asm_out_file, ".LTSTART");
-  ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s DWARF Version", ASM_COMMENT_START);
+  dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
+                       "Length of Source Line Info");
+  ASM_OUTPUT_LABEL (asm_out_file, l1);
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA (asm_out_file, size_of_line_prolog ());
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Prolog Length", ASM_COMMENT_START);
+  dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_LINE_MIN_INSTR_LENGTH);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Minimum Instruction Length",
-            ASM_COMMENT_START);
+  dw2_asm_output_data (DWARF_OFFSET_SIZE, size_of_line_prolog (),
+                      "Prolog Length");
 
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_LINE_DEFAULT_IS_STMT_START);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s Default is_stmt_start flag",
-            ASM_COMMENT_START);
+  dw2_asm_output_data (1, DWARF_LINE_MIN_INSTR_LENGTH,
+                      "Minimum Instruction Length");
 
-  fputc ('\n', asm_out_file);
-  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);
+  dw2_asm_output_data (1, DWARF_LINE_DEFAULT_IS_STMT_START,
+                      "Default is_stmt_start flag");
 
-  fputc ('\n', asm_out_file);
-  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);
+  dw2_asm_output_data (1, DWARF_LINE_BASE,
+                      "Line Base Value (Special Opcodes)");
 
-  fputc ('\n', asm_out_file);
-  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);
+  dw2_asm_output_data (1, DWARF_LINE_RANGE,
+                      "Line Range Value (Special Opcodes)");
+
+  dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE,
+                      "Special Opcode Base");
 
-  fputc ('\n', asm_out_file);
   for (opc = 1; opc < DWARF_LINE_OPCODE_BASE; ++opc)
     {
       switch (opc)
@@ -7074,11 +6382,9 @@ output_line_info ()
          n_op_args = 0;
          break;
        }
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, n_op_args);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s opcode: 0x%x has %d args",
-                ASM_COMMENT_START, opc, n_op_args);
-      fputc ('\n', asm_out_file);
+
+      dw2_asm_output_data (1, n_op_args, "opcode: 0x%x has %d args",
+                          opc, n_op_args);
     }
 
   /* Write out the information about the files we use.  */
@@ -7110,44 +6416,31 @@ output_line_info ()
        continue;
 #endif
 
-      /* Emit debug info for the address of the current line, choosing
-        the encoding that uses the least amount of space.  */
-      /* ??? Unfortunately, we have little choice here currently, and must
-        always use the most general form.  Gcc does not know the address
-        delta itself, so we can't use DW_LNS_advance_pc.  There are no known
-        dwarf2 aware assemblers at this time, so we can't use any special
-        pseudo ops that would allow the assembler to optimally encode this for
-        us.  Many ports do have length attributes which will give an upper
-        bound on the address range.  We could perhaps use length attributes
-        to determine when it is safe to use DW_LNS_fixed_advance_pc.  */
+      /* Emit debug info for the address of the current line.
+
+        Unfortunately, we have little choice here currently, and must always
+        use the most general form.  Gcc does not know the address delta
+        itself, so we can't use DW_LNS_advance_pc.  Many ports do have length
+        attributes which will give an upper bound on the address range.  We
+        could perhaps use length attributes to determine when it is safe to
+        use DW_LNS_fixed_advance_pc.  */
+
       ASM_GENERATE_INTERNAL_LABEL (line_label, LINE_CODE_LABEL, lt_index);
       if (0)
        {
          /* This can handle deltas up to 0xffff.  This takes 3 bytes.  */
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
-                    ASM_COMMENT_START);
-
-         fputc ('\n', asm_out_file);
-         ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, line_label, prev_line_label);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+                              "DW_LNS_fixed_advance_pc");
+         dw2_asm_output_delta (2, line_label, prev_line_label, NULL);
        }
       else
        {
          /* This can handle any delta.  This takes
              4+DWARF2_ADDR_SIZE bytes.  */
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNE_set_address",
-                    ASM_COMMENT_START);
-         fputc ('\n', asm_out_file);
-         output_uleb128 (1 + DWARF2_ADDR_SIZE);
-         fputc ('\n', asm_out_file);
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
-         fputc ('\n', asm_out_file);
-         ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+         dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+         dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+         dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL);
        }
       strcpy (prev_line_label, line_label);
 
@@ -7156,17 +6449,9 @@ output_line_info ()
       if (line_info->dw_file_num != current_file)
        {
          current_file = line_info->dw_file_num;
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_set_file);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNS_set_file", ASM_COMMENT_START);
-
-         fputc ('\n', asm_out_file);
-         output_uleb128 (current_file);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, " (\"%s\")",
-                    line_file_table.table[current_file]);
-
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (1, DW_LNS_set_file, "DW_LNS_set_file");
+         dw2_asm_output_data_uleb128 (current_file, "(\"%s\")",
+                                      line_file_table.table[current_file]);
        }
 
       /* Emit debug info for the current line number, choosing the encoding
@@ -7181,77 +6466,44 @@ output_line_info ()
              /* This can handle deltas from -10 to 234, using the current
                 definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE.  This
                 takes 1 byte.  */
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
-                                     DWARF_LINE_OPCODE_BASE + line_delta);
-             if (flag_debug_asm)
-               fprintf (asm_out_file,
-                        "\t%s line %ld", ASM_COMMENT_START, current_line);
-
-             fputc ('\n', asm_out_file);
+             dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE + line_delta,
+                                  "line %lu", current_line);
            }
          else
            {
              /* This can handle any delta.  This takes at least 4 bytes,
                 depending on the value being encoded.  */
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_advance_line);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s advance to line %ld",
-                        ASM_COMMENT_START, current_line);
-
-             fputc ('\n', asm_out_file);
-             output_sleb128 (line_offset);
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
-             fputc ('\n', asm_out_file);
+             dw2_asm_output_data (1, DW_LNS_advance_line,
+                                  "advance to line %lu", current_line);
+             dw2_asm_output_data_sleb128 (line_offset, NULL);
+             dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
            }
        }
       else
        {
          /* We still need to start a new row, so output a copy insn.  */
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
        }
     }
 
   /* Emit debug info for the address of the end of the function.  */
   if (0)
     {
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
-                ASM_COMMENT_START);
-
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, text_end_label, prev_line_label);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+                          "DW_LNS_fixed_advance_pc");
+      dw2_asm_output_delta (2, text_end_label, prev_line_label, NULL);
     }
   else
     {
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-      if (flag_debug_asm)
-       fprintf (asm_out_file, "\t%s DW_LNE_set_address", ASM_COMMENT_START);
-      fputc ('\n', asm_out_file);
-      output_uleb128 (1 + DWARF2_ADDR_SIZE);
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_DWARF_ADDR (asm_out_file, text_end_label);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+      dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+      dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+      dw2_asm_output_offset (DWARF2_ADDR_SIZE, text_end_label, NULL);
     }
 
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-  if (flag_debug_asm)
-    fprintf (asm_out_file, "\t%s DW_LNE_end_sequence", ASM_COMMENT_START);
-
-  fputc ('\n', asm_out_file);
-  output_uleb128 (1);
-  fputc ('\n', asm_out_file);
-  ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_end_sequence);
-  fputc ('\n', asm_out_file);
+  dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
+  dw2_asm_output_data_uleb128 (1, NULL);
+  dw2_asm_output_data (1, DW_LNE_end_sequence, NULL);
 
   function = 0;
   current_file = 1;
@@ -7279,47 +6531,26 @@ output_line_info ()
          function = line_info->function;
 
          /* Set the address register to the first line in the function */
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNE_set_address",
-                    ASM_COMMENT_START);
-
-         fputc ('\n', asm_out_file);
-         output_uleb128 (1 + DWARF2_ADDR_SIZE);
-         fputc ('\n', asm_out_file);
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
-         fputc ('\n', asm_out_file);
-         ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+         dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+         dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+         dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL);
        }
       else
        {
          /* ??? See the DW_LNS_advance_pc comment above.  */
          if (0)
            {
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
-                        ASM_COMMENT_START);
-
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, line_label,
-                                      prev_line_label);
-             fputc ('\n', asm_out_file);
+             dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+                                  "DW_LNS_fixed_advance_pc");
+             dw2_asm_output_delta (2, line_label, prev_line_label, NULL);
            }
          else
            {
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s DW_LNE_set_address",
-                        ASM_COMMENT_START);
-             fputc ('\n', asm_out_file);
-             output_uleb128 (1 + DWARF2_ADDR_SIZE);
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
-             fputc ('\n', asm_out_file);
+             dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+             dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+             dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+             dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL);
            }
        }
       strcpy (prev_line_label, line_label);
@@ -7329,17 +6560,9 @@ output_line_info ()
       if (line_info->dw_file_num != current_file)
        {
          current_file = line_info->dw_file_num;
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_set_file);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNS_set_file", ASM_COMMENT_START);
-
-         fputc ('\n', asm_out_file);
-         output_uleb128 (current_file);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, " (\"%s\")",
-                    line_file_table.table[current_file]);
-
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (1, DW_LNS_set_file, "DW_LNS_set_file");
+         dw2_asm_output_data_uleb128 (current_file, "(\"%s\")",
+                                      line_file_table.table[current_file]);
        }
 
       /* Emit debug info for the current line number, choosing the encoding
@@ -7350,39 +6573,18 @@ output_line_info ()
          line_delta = line_offset - DWARF_LINE_BASE;
          current_line = line_info->dw_line_num;
          if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1))
-           {
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file,
-                                     DWARF_LINE_OPCODE_BASE + line_delta);
-             if (flag_debug_asm)
-               fprintf (asm_out_file,
-                        "\t%s line %ld", ASM_COMMENT_START, current_line);
-
-             fputc ('\n', asm_out_file);
-           }
+           dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE + line_delta,
+                                "line %lu", current_line);
          else
            {
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_advance_line);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s advance to line %ld",
-                        ASM_COMMENT_START, current_line);
-
-             fputc ('\n', asm_out_file);
-             output_sleb128 (line_offset);
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
-             fputc ('\n', asm_out_file);
+             dw2_asm_output_data (1, DW_LNS_advance_line,
+                                  "advance to line %lu", current_line);
+             dw2_asm_output_data_sleb128 (line_offset, NULL);
+             dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
            }
        }
       else
-       {
-         /* We still need to start a new row, so output a copy insn.  */
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNS_copy", ASM_COMMENT_START);
-         fputc ('\n', asm_out_file);
-       }
+       dw2_asm_output_data (1, DW_LNS_copy, "DW_LNS_copy");
 
 #if 0
     cont:
@@ -7400,47 +6602,27 @@ output_line_info ()
          ASM_GENERATE_INTERNAL_LABEL (line_label, FUNC_END_LABEL, function);
          if (0)
            {
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc",
-                        ASM_COMMENT_START);
-
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, line_label,
-                                      prev_line_label);
-             fputc ('\n', asm_out_file);
+             dw2_asm_output_data (1, DW_LNS_fixed_advance_pc,
+                                  "DW_LNS_fixed_advance_pc");
+             dw2_asm_output_delta (2, line_label, prev_line_label, NULL);
            }
          else
            {
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-             if (flag_debug_asm)
-               fprintf (asm_out_file, "\t%s DW_LNE_set_address",
-                        ASM_COMMENT_START);
-             fputc ('\n', asm_out_file);
-             output_uleb128 (1 + DWARF2_ADDR_SIZE);
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address);
-             fputc ('\n', asm_out_file);
-             ASM_OUTPUT_DWARF_ADDR (asm_out_file, line_label);
-             fputc ('\n', asm_out_file);
+             dw2_asm_output_data (1, 0, "DW_LNE_set_address");
+             dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
+             dw2_asm_output_data (1, DW_LNE_set_address, NULL);
+             dw2_asm_output_offset (DWARF2_ADDR_SIZE, line_label, NULL);
            }
 
          /* Output the marker for the end of this sequence.  */
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0);
-         if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s DW_LNE_end_sequence",
-                    ASM_COMMENT_START);
-
-         fputc ('\n', asm_out_file);
-         output_uleb128 (1);
-         fputc ('\n', asm_out_file);
-         ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_end_sequence);
-         fputc ('\n', asm_out_file);
+         dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
+         dw2_asm_output_data_uleb128 (1, NULL);
+         dw2_asm_output_data (1, DW_LNE_end_sequence, NULL);
        }
     }
 
   /* Output the marker for the end of the line number info.  */
-  ASM_OUTPUT_LABEL (asm_out_file, ".LTEND");
+  ASM_OUTPUT_LABEL (asm_out_file, l2);
 }
 \f
 /* Given a pointer to a tree node for some base type, return a pointer to
@@ -8617,12 +7799,28 @@ add_const_value_attribute (die, rtl)
   switch (GET_CODE (rtl))
     {
     case CONST_INT:
-      /* Note that a CONST_INT rtx could represent either an integer or a
-         floating-point constant.  A CONST_INT is used whenever the constant
-         will fit into a single word.  In all such cases, the original mode
-         of the constant value is wiped out, and the CONST_INT rtx is
-         assigned VOIDmode.  */
-      add_AT_unsigned (die, DW_AT_const_value, (unsigned) INTVAL (rtl));
+      /* Note that a CONST_INT rtx could represent either an integer
+        or a floating-point constant.  A CONST_INT is used whenever
+        the constant will fit into a single word.  In all such
+        cases, the original mode of the constant value is wiped
+        out, and the CONST_INT rtx is assigned VOIDmode.  */
+      {
+       HOST_WIDE_INT val = INTVAL (rtl);
+       
+       /* ??? We really should be using HOST_WIDE_INT throughout.  */
+       if (val < 0)
+         {
+           if ((long) val != val)
+             abort ();
+           add_AT_int (die, DW_AT_const_value, (long) val);
+         }
+       else
+         {
+           if ((unsigned long) val != (unsigned HOST_WIDE_INT) val)
+             abort ();
+           add_AT_int (die, DW_AT_const_value, (unsigned long) val);
+         }
+      }
       break;
 
     case CONST_DOUBLE:
@@ -8662,8 +7860,13 @@ add_const_value_attribute (die, rtl)
            add_AT_float (die, DW_AT_const_value, length, array);
          }
        else
-         add_AT_long_long (die, DW_AT_const_value,
-                           CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl));
+         {
+           /* ??? We really should be using HOST_WIDE_INT throughout.  */
+           if (HOST_BITS_PER_LONG != HOST_BITS_PER_WIDE_INT)
+             abort ();
+           add_AT_long_long (die, DW_AT_const_value,
+                             CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl));
+         }
       }
       break;
 
@@ -11692,9 +10895,8 @@ dwarf2out_line (filename, line)
          ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, SEPARATE_LINE_CODE_LABEL,
                                     separate_line_info_table_in_use);
          if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s %s:%d", ASM_COMMENT_START,
+           fprintf (asm_out_file, "\t%s %s:%d\n", ASM_COMMENT_START,
                     filename, line);
-         fputc ('\n', asm_out_file);
 
          /* expand the line info table if necessary */
          if (separate_line_info_table_in_use
@@ -11722,9 +10924,8 @@ dwarf2out_line (filename, line)
          ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, LINE_CODE_LABEL,
                                     line_info_table_in_use);
          if (flag_debug_asm)
-           fprintf (asm_out_file, "\t%s %s:%d", ASM_COMMENT_START,
+           fprintf (asm_out_file, "\t%s %s:%d\n", ASM_COMMENT_START,
                     filename, line);
-         fputc ('\n', asm_out_file);
 
          /* Expand the line info table if necessary.  */
          if (line_info_table_in_use == line_info_table_allocated)
@@ -11929,18 +11130,15 @@ dwarf2out_finish ()
     add_sibling_attributes (node->die);
 
   /* Output a terminator label for the .text section.  */
-  fputc ('\n', asm_out_file);
   ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION);
   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, TEXT_END_LABEL, 0);
 
 #if 0
   /* Output a terminator label for the .data section.  */
-  fputc ('\n', asm_out_file);
   ASM_OUTPUT_SECTION (asm_out_file, DATA_SECTION);
   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, DATA_END_LABEL, 0);
 
   /* Output a terminator label for the .bss section.  */
-  fputc ('\n', asm_out_file);
   ASM_OUTPUT_SECTION (asm_out_file, BSS_SECTION);
   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BSS_END_LABEL, 0);
 #endif
@@ -11950,7 +11148,6 @@ dwarf2out_finish ()
     {
       if (! DWARF2_ASM_LINE_DEBUG_INFO)
        {
-         fputc ('\n', asm_out_file);
          ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
          output_line_info ();
        }
@@ -11979,14 +11176,12 @@ dwarf2out_finish ()
   output_comp_unit (comp_unit_die);
 
   /* Output the abbreviation table.  */
-  fputc ('\n', asm_out_file);
   ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION);
   output_abbrev_section ();
 
   if (pubname_table_in_use)
     {
       /* Output public names table.  */
-      fputc ('\n', asm_out_file);
       ASM_OUTPUT_SECTION (asm_out_file, PUBNAMES_SECTION);
       output_pubnames ();
     }
@@ -11996,7 +11191,6 @@ dwarf2out_finish ()
   if (fde_table_in_use)
     {
       /* Output the address range information.  */
-      fputc ('\n', asm_out_file);
       ASM_OUTPUT_SECTION (asm_out_file, ARANGES_SECTION);
       output_aranges ();
     }