Patchwork Hookize ASM_OUTPUT_SOURCE_FILENAME

login
register
mail settings
Submitter Anatoly Sokolov
Date July 16, 2010, 8:59 p.m.
Message ID <1188184004.20100717005944@post.ru>
Download mbox | patch
Permalink /patch/59126/
State New
Headers show

Comments

Anatoly Sokolov - July 16, 2010, 8:59 p.m.
Hello.

  This patch turns ASM_OUTPUT_SOURCE_FILENAME macro into a hook.

  The patch has been bootstrapped on and regression tested on
x86_64-unknown-linux-gnu and mips64el-unknown-linux-gnu for c and c++.

  This patch is pre-approved and should be committed within a week if no
objections.

        * target.def (output_source_filename): New hook.
        * doc/tm.texi.in (TARGET_ASM_OUTPUT_SOURCE_FILENAME): Document.
        * doc/tm.texi: Regenerate.
        * toplev.c (output_file_directive) Remove function.
        * toplev.h (output_file_directive) Remove.
        * output.h (default_asm_output_source_filename,
        output_file_directive): Declare.
        * varasm.h (default_asm_output_source_filename,
        output_file_directive): New functions.

        * config/mips/mips.h (ASM_OUTPUT_SOURCE_FILENAME): Remove macro.
        * config/mips/mips-protos.h (mips_output_filename): Remove.
        * config/mips/mips.c (mips_output_filename): Make Static.
        (TARGET_ASM_OUTPUT_SOURCE_FILENAME): Define.



Anatoly.
Richard Henderson - July 16, 2010, 10:46 p.m.
On 07/16/2010 01:59 PM, Anatoly Sokolov wrote:
> 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

This text goes ....

> +
>  @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,
> + "",

... here.

> + void ,(FILE *file, const char *name),
> + default_asm_output_source_filename)

Otherwise ok.



r~
Joseph S. Myers - July 26, 2010, 9:33 p.m.
On Fri, 16 Jul 2010, Richard Henderson wrote:

> On 07/16/2010 01:59 PM, Anatoly Sokolov wrote:
> > 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
> 
> This text goes ....

> > +DEFHOOK
> > +(output_source_filename,
> > + "",
> 
> ... here.

This only applies for new hook documentation text written from scratch, 
not text based on existing target macro documentation.  For text based on 
old target macro documentation (under the GFDL), FSF approval is needed 
for licensing it under the GPL.  RMS can be quite efficient about 
approving relicensing for existing text, so I encourage producing such 
patches and seeking the relicensing, but they do need to go by RMS.  (The 
same applies to all the existing hooks with documentation not in 
target.def: I encourage producing concrete patches for RMS's attention 
showing the specific text that should be relicensed.)

Patch

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);                             \