Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi     (revision 162265)
+++ gcc/doc/tm.texi     (working copy)
@@ -7287,6 +7287,15 @@
 for the file format in use is appropriate.
 @end defmac
 
+@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_SOURCE_FILENAME (FILE *@var{file}, const char *@var{name})
+Output COFF information or DWARF debugging information which indicates
+that filename @var{name} is the current source file to the stdio
+stream @var{file}.
+
+This target hook need not be defined if the standard form of output
+for the file format in use is appropriate.
+@end deftypefn
+
 @defmac OUTPUT_QUOTED_STRING (@var{stream}, @var{string})
 A C statement to output the string @var{string} to the stdio stream
 @var{stream}.  If you do not call the function @code{output_quoted_string}
Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in  (revision 162265)
+++ gcc/doc/tm.texi.in  (working copy)
@@ -7287,6 +7287,15 @@
 for the file format in use is appropriate.
 @end defmac
 
+@hook TARGET_ASM_OUTPUT_SOURCE_FILENAME
+Output COFF information or DWARF debugging information which indicates
+that filename @var{name} is the current source file to the stdio
+stream @var{file}.
+
+This target hook need not be defined if the standard form of output
+for the file format in use is appropriate.
+@end deftypefn
+
 @defmac OUTPUT_QUOTED_STRING (@var{stream}, @var{string})
 A C statement to output the string @var{string} to the stdio stream
 @var{stream}.  If you do not call the function @code{output_quoted_string}
Index: gcc/target.def
===================================================================
--- gcc/target.def      (revision 162265)
+++ gcc/target.def      (working copy)
@@ -404,6 +404,14 @@
  void, (FILE *f),
  NULL)
 
+/* Output information which indicates that filename is the current source
+   file.  */
+DEFHOOK
+(output_source_filename,
+ "",
+ void ,(FILE *file, const char *name),
+ default_asm_output_source_filename)
+
 /* ??? The TARGET_PRINT_OPERAND* hooks are part of the asm_out struct,
    even though that is not reflected in the macro name to override their
    initializers.  */
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c        (revision 162265)
+++ gcc/toplev.c        (working copy)
@@ -620,39 +620,6 @@
 #endif
 }
 
-/* Output a file name in the form wanted by System V.  */
-
-void
-output_file_directive (FILE *asm_file, const char *input_name)
-{
-  int len;
-  const char *na;
-
-  if (input_name == NULL)
-    input_name = "<stdin>";
-  else
-    input_name = remap_debug_filename (input_name);
-
-  len = strlen (input_name);
-  na = input_name + len;
-
-  /* NA gets INPUT_NAME sans directory names.  */
-  while (na > input_name)
-    {
-      if (IS_DIR_SEPARATOR (na[-1]))
-       break;
-      na--;
-    }
-
-#ifdef ASM_OUTPUT_SOURCE_FILENAME
-  ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
-#else
-  fprintf (asm_file, "\t.file\t");
-  output_quoted_string (asm_file, na);
-  putc ('\n', asm_file);
-#endif
-}
-
 /* A subroutine of wrapup_global_declarations.  We've come to the end of
    the compilation unit.  All deferred variables should be undeferred,
    and all incomplete decls should be finalized.  */
Index: gcc/toplev.h
===================================================================
--- gcc/toplev.h        (revision 162265)
+++ gcc/toplev.h        (working copy)
@@ -50,7 +50,6 @@
 
 #ifdef BUFSIZ
 extern void output_quoted_string       (FILE *, const char *);
-extern void output_file_directive      (FILE *, const char *);
 #endif
 
 extern void wrapup_global_declaration_1 (tree);
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c        (revision 162265)
+++ gcc/varasm.c        (working copy)
@@ -7247,6 +7247,43 @@
     maybe_assemble_visibility (decl);
 }
 
+/* The default hook for TARGET_ASM_OUTPUT_SOURCE_FILENAME.  */
+
+void
+default_asm_output_source_filename (FILE *file, const char *name)
+{
+  fprintf (file, "\t.file\t");
+  output_quoted_string (file, name);
+  putc ('\n', file);
+}
+
+/* Output a file name in the form wanted by System V.  */
+
+void
+output_file_directive (FILE *asm_file, const char *input_name)
+{
+  int len;
+  const char *na;
+
+  if (input_name == NULL)
+    input_name = "<stdin>";
+  else
+    input_name = remap_debug_filename (input_name);
+
+  len = strlen (input_name);
+  na = input_name + len;
+
+  /* NA gets INPUT_NAME sans directory names.  */
+  while (na > input_name)
+    {
+      if (IS_DIR_SEPARATOR (na[-1]))
+       break;
+      na--;
+    }
+
+  targetm.asm_out.output_source_filename (asm_file, na);
+}
+
 /* Create a DEBUG_EXPR_DECL / DEBUG_EXPR pair from RTL expression
    EXP.  */
 rtx
Index: gcc/output.h
===================================================================
--- gcc/output.h        (revision 162265)
+++ gcc/output.h        (working copy)
@@ -595,6 +595,9 @@
 extern void switch_to_section (section *);
 extern void output_section_asm_op (const void *);
 
+extern void default_asm_output_source_filename (FILE *, const char *);
+extern void output_file_directive (FILE *, const char *);
+
 extern unsigned int default_section_type_flags (tree, const char *, int);
 
 extern bool have_global_bss_p (void);
Index: gcc/config/mips/mips-protos.h
===================================================================
--- gcc/config/mips/mips-protos.h       (revision 162265)
+++ gcc/config/mips/mips-protos.h       (working copy)
@@ -261,7 +261,6 @@
 extern void mips_push_asm_switch (struct mips_asm_switch *);
 extern void mips_pop_asm_switch (struct mips_asm_switch *);
 extern void mips_output_external (FILE *, tree, const char *);
-extern void mips_output_filename (FILE *, const char *);
 extern void mips_output_ascii (FILE *, const char *, size_t);
 extern void mips_output_aligned_decl_common (FILE *, tree, const char *,
                                             unsigned HOST_WIDE_INT,
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c      (revision 162265)
+++ gcc/config/mips/mips.c      (working copy)
@@ -7881,7 +7882,7 @@
 
 /* Implement ASM_OUTPUT_SOURCE_FILENAME.  */
 
-void
+static void
 mips_output_filename (FILE *stream, const char *name)
 {
   /* If we are emitting DWARF-2, let dwarf2out handle the ".file"
@@ -16484,6 +16485,9 @@
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT mips_trampoline_init
 
+#undef TARGET_ASM_OUTPUT_SOURCE_FILENAME
+#define TARGET_ASM_OUTPUT_SOURCE_FILENAME mips_output_filename
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-mips.h"
Index: gcc/config/mips/mips.h
===================================================================
--- gcc/config/mips/mips.h      (revision 162265)
+++ gcc/config/mips/mips.h      (working copy)
@@ -2666,9 +2666,6 @@
   }                                                                    \
 while (0)
 
-/* How to tell the debugger about changes of source files.  */
-#define ASM_OUTPUT_SOURCE_FILENAME mips_output_filename
-
 /* mips-tfile does not understand .stabd directives.  */
 #define DBX_OUTPUT_SOURCE_LINE(STREAM, LINE, COUNTER) do {     \
   dbxout_begin_stabn_sline (LINE);                             \
