This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Hookize OUTPUT_QUOTED_STRING


Hello.

  This patch turns OUTPUT_QUOTED_STRING macro into a hook.

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

  Untested on alpha and coff targets.

  Ok to install?

        * target.def (output_quoted_string): New hook.
        * doc/tm.texi.in (TARGET_ASM_OUTPUT_QUOTED_STRING): Document.
        * doc/tm.texi: Regenerate.
        * toplev.c (output_quoted_string) Remove function.
        * toplev.h (output_quoted_string) Remove.
        * output.h (default_asm_output_quoted_string): Declare.
        * varasm.h (default_asm_output_quoted_string): New functions.
        (default_asm_output_source_filename): Use
        TARGET_ASM_OUTPUT_QUOTED_STRING target hook.
        * xcoffout.c (xcoffout_source_file): Ditto.
        * xcoffout.h (DBX_OUTPUT_MAIN_SOURCE_FILE_END): Ditto.
        * dbxout.c (dbxout_begin_simple_stabs,
        dbxout_begin_simple_stabs_desc): Dotto.
        * dwarf2out.c (maybe_emit_file): Ditto.
        * config/alpha/alpha.c (alpha_output_filename): Ditto.
        * config/rs6000/rs6000.c (rs6000_xcoff_file_start ): Ditto.
        * config/mips/mips.c (mips_output_filename): Ditto.


Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi     (revision 165655)
+++ gcc/doc/tm.texi     (working copy)
@@ -7349,6 +7349,12 @@
  This target hook need not be defined if the standard form of output for the file format in use is appropriate.
 @end deftypefn
 
+@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_QUOTED_STRING (FILE *@var{file}, const char *@var{string})
+A target hook to output the string @var{string} to the stdio stream
+@var{file}.  The GCC will only call it to output filenames to the assembler
+source.  So you can use it to canonicalize the format of the filename.
+@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 165655)
+++ gcc/doc/tm.texi.in  (working copy)
@@ -7334,6 +7334,12 @@
 
 @hook TARGET_ASM_OUTPUT_SOURCE_FILENAME
 
+@hook TARGET_ASM_OUTPUT_QUOTED_STRING
+A target hook to output the string @var{string} to the stdio stream
+@var{file}.  The GCC will only call it to output filenames to the assembler
+source.  So you can use it to canonicalize the format of the filename.
+@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 165655)
+++ gcc/target.def      (working copy)
@@ -431,7 +431,14 @@
  void ,(FILE *file, const char *name),
  default_asm_output_source_filename)
 
+/* Output a quoted string.  */
 DEFHOOK
+(output_quoted_string,
+ "",
+ void, (FILE *file, const char *string),
+ default_asm_output_quoted_string)
+
+DEFHOOK
 (output_addr_const_extra,
  "",
  bool, (FILE *file, rtx x),
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c        (revision 165655)
+++ gcc/toplev.c        (working copy)
@@ -568,32 +568,6 @@
     }
 }
 
-/* Output a quoted string.  */
-
-void
-output_quoted_string (FILE *asm_file, const char *string)
-{
-#ifdef OUTPUT_QUOTED_STRING
-  OUTPUT_QUOTED_STRING (asm_file, string);
-#else
-  char c;
-
-  putc ('\"', asm_file);
-  while ((c = *string++) != 0)
-    {
-      if (ISPRINT (c))
-       {
-         if (c == '\"' || c == '\\')
-           putc ('\\', asm_file);
-         putc (c, asm_file);
-       }
-      else
-       fprintf (asm_file, "\\%03o", (unsigned char) c);
-    }
-  putc ('\"', 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 165655)
+++ gcc/toplev.h        (working copy)
@@ -52,10 +52,6 @@
 extern void warn_deprecated_use (tree, tree);
 extern bool parse_optimize_options (tree, bool);
 
-#ifdef BUFSIZ
-extern void output_quoted_string       (FILE *, const char *);
-#endif
-
 extern void wrapup_global_declaration_1 (tree);
 extern bool wrapup_global_declaration_2 (tree);
 extern bool wrapup_global_declarations (tree *, int);
Index: gcc/dbxout.c
===================================================================
--- gcc/dbxout.c        (revision 165655)
+++ gcc/dbxout.c        (working copy)
@@ -592,7 +592,7 @@
 dbxout_begin_simple_stabs (const char *str, int stype)
 {
   fputs (ASM_STABS_OP, asm_out_file);
-  output_quoted_string (asm_out_file, str);
+  targetm.asm_out.output_quoted_string (asm_out_file, str);
   putc (',', asm_out_file);
   dbxout_int (stype);
   fputs (",0,0,", asm_out_file);
@@ -603,7 +603,7 @@
 dbxout_begin_simple_stabs_desc (const char *str, int stype, int sdesc)
 {
   fputs (ASM_STABS_OP, asm_out_file);
-  output_quoted_string (asm_out_file, str);
+  targetm.asm_out.output_quoted_string (asm_out_file, str);
   putc (',', asm_out_file);
   dbxout_int (stype);
   fputs (",0,", asm_out_file);
Index: gcc/xcoffout.c
===================================================================
--- gcc/xcoffout.c      (revision 165655)
+++ gcc/xcoffout.c      (working copy)
@@ -302,7 +302,7 @@
       if (xcoff_current_include_file)
        {
          fprintf (file, "\t.ei\t");
-         output_quoted_string (file,
+         targetm.asm_out.output_quoted_string (file,
              remap_debug_filename (xcoff_current_include_file));
          fprintf (file, "\n");
          xcoff_current_include_file = NULL;
@@ -311,7 +311,8 @@
       if (strcmp (main_input_filename, filename) || inline_p)
        {
          fprintf (file, "\t.bi\t");
-         output_quoted_string (file, remap_debug_filename (filename));
+         targetm.asm_out.output_quoted_string (file,
+                                               remap_debug_filename (filename));
          fprintf (file, "\n");
          xcoff_current_include_file = filename;
        }
Index: gcc/xcoffout.h
===================================================================
--- gcc/xcoffout.h      (revision 165655)
+++ gcc/xcoffout.h      (working copy)
@@ -149,7 +149,7 @@
   if (xcoff_current_include_file)                      \
     {                                                  \
       fputs ("\t.ei\t", (FILE));                       \
-      output_quoted_string ((FILE), xcoff_current_include_file);       \
+      targetm.asm_out.output_quoted_string ((FILE), xcoff_current_include_file); \
       putc ('\n', (FILE));                             \
       xcoff_current_include_file = NULL;               \
     }                                                  \
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c     (revision 165655)
+++ gcc/dwarf2out.c     (working copy)
@@ -21249,8 +21249,8 @@
       if (DWARF2_ASM_LINE_DEBUG_INFO)
        {
          fprintf (asm_out_file, "\t.file %u ", fd->emitted_number);
-         output_quoted_string (asm_out_file,
-                               remap_debug_filename (fd->filename));
+         targetm.asm_out.output_quoted_string (asm_out_file,
+                                       remap_debug_filename (fd->filename));
          fputc ('\n', asm_out_file);
        }
     }
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c        (revision 165655)
+++ gcc/varasm.c        (working copy)
@@ -7013,7 +7013,7 @@
   ASM_OUTPUT_SOURCE_FILENAME (file, name);
 #else
   fprintf (file, "\t.file\t");
-  output_quoted_string (file, name);
+  targetm.asm_out.output_quoted_string (file, name);
   putc ('\n', file);
 #endif
 }
@@ -7072,4 +7072,30 @@
   return dval;
 }
 
+/* Output a quoted string.  */
+
+void
+default_asm_output_quoted_string (FILE *asm_file, const char *string)
+{
+#ifdef OUTPUT_QUOTED_STRING
+  OUTPUT_QUOTED_STRING (asm_file, string);
+#else
+  char c;
+
+  putc ('\"', asm_file);
+  while ((c = *string++) != 0)
+    {
+      if (ISPRINT (c))
+        {
+          if (c == '\"' || c == '\\')
+            putc ('\\', asm_file);
+          putc (c, asm_file);
+        }
+      else
+        fprintf (asm_file, "\\%03o", (unsigned char) c);
+    }
+  putc ('\"', asm_file);
+#endif
+}
+
 #include "gt-varasm.h"
Index: gcc/output.h
===================================================================
--- gcc/output.h        (revision 165655)
+++ gcc/output.h        (working copy)
@@ -589,6 +589,7 @@
 extern void switch_to_section (section *);
 extern void output_section_asm_op (const void *);
 
+extern void default_asm_output_quoted_string (FILE *, const char *);
 extern void default_asm_output_source_filename (FILE *, const char *);
 extern void output_file_directive (FILE *, const char *);
 
Index: gcc/config/alpha/alpha.c
===================================================================
--- gcc/config/alpha/alpha.c    (revision 165655)
+++ gcc/config/alpha/alpha.c    (working copy)
@@ -8756,7 +8756,7 @@
       ++num_source_filenames;
       current_function_file = name;
       fprintf (stream, "\t.file\t%d ", num_source_filenames);
-      output_quoted_string (stream, name);
+      targetm.asm_out.output_quoted_string (stream, name);
       fprintf (stream, "\n");
       if (!TARGET_GAS && write_symbols == DBX_DEBUG)
        fprintf (stream, "\t#@stabs\n");
@@ -8778,7 +8778,7 @@
          fprintf (stream, "\t.file\t%d ", num_source_filenames);
        }
 
-      output_quoted_string (stream, name);
+      targetm.asm_out.output_quoted_string (stream, name);
       fprintf (stream, "\n");
     }
 }
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  (revision 165655)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -25689,7 +25689,7 @@
                           main_input_filename, ".ro_");
 
   fputs ("\t.file\t", asm_out_file);
-  output_quoted_string (asm_out_file, main_input_filename);
+  targetm.asm_out.output_quoted_string (asm_out_file, main_input_filename);
   fputc ('\n', asm_out_file);
   if (write_symbols != NO_DEBUG)
     switch_to_section (private_data_section);
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c      (revision 165655)
+++ gcc/config/mips/mips.c      (working copy)
@@ -7924,7 +7924,7 @@
       num_source_filenames += 1;
       current_function_file = name;
       fprintf (stream, "\t.file\t%d ", num_source_filenames);
-      output_quoted_string (stream, name);
+      targetm.asm_out.output_quoted_string (stream, name);
       putc ('\n', stream);
     }
   /* If we are emitting stabs, let dbxout.c handle this (except for
@@ -7937,7 +7937,7 @@
       num_source_filenames += 1;
       current_function_file = name;
       fprintf (stream, "\t.file\t%d ", num_source_filenames);
-      output_quoted_string (stream, name);
+      targetm.asm_out.output_quoted_string (stream, name);
       putc ('\n', stream);
     }
 }


Anatoly.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]