]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jun 2012 19:55:33 +0000 (19:55 +0000)
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Jun 2012 19:55:33 +0000 (19:55 +0000)
* target.def (output_ident): New hook.
* targhooks.h (default_asm_output_ident_directive): Add prototype.
* varasm.c (assemble_asm): Only prefix a tab if the string does not
already start with one.
(default_asm_output_ident_directive): New function to emit
.ident as a top-level asm node while parsing, or directly to
asm_out_file after parsing.
* toplev.c (compile_file): Print a GCC .ident with
targetm.asm_out.output_ident.
* doc/tm.texi.in (ASM_OUTPUT_IDENT): Remove documentation for macro.
(TARGET_ASM_OUTPUT_IDENT): Add @hook for this.
* doc/tm.texi: Update.

* config/elfos.h (ASM_OUTPUT_IDENT, IDENT_ASM_OP): Remove.
(TARGET_ASM_OUTPUT_IDENT): Define.
* config/i386/djgpp.h (IDENT_ASM_OP): Remove.
* config/i386/gas.h (ASM_OUTPUT_IDENT): Remove.
* config/arm/aout.h (ASM_OUTPUT_IDENT): Remove.
* config/sparc/sparc.h (IDENT_ASM_OP): Remove.
(TARGET_ASM_OUTPUT_IDENT): Define.
* config/picochip/picochip.h (IDENT_ASM_OP): Remove.
(TARGET_ASM_OUTPUT_IDENT): Define.

* config/cris/cris-protos.h (cris_asm_output_ident): Add prototype.
* config/cris/cris.c (cris_asm_output_ident): New function.
* config/cris/cris.h (ASM_OUTPUT_IDENT, IDENT_ASM_OP): Remove.

* config/microblaze/microblaze-protos.h (microblaze_asm_output_ident):
Add prototype.
* config/microblaze/microblaze.c: Include cgraph.h for add_asm_node.
(microblaze_asm_output_ident): Rewrite to work similar to
default_asm_output_ident_directive for front-end .idents.
* config/microblaze/microblaze.h (ASM_OUTPUT_IDENT): Remove.
(TARGET_ASM_OUTPUT_IDENT): Define.

* config/mips/mips.h (ASM_OUTPUT_IDENT): Remove.
* config/mips/sde.h (IDENT_ASM_OP, ASM_OUTPUT_IDENT): Remove.

* config/rx/rx.c: Include cgraph.h for add_asm_node.
(rx_asm_output_ident): New function, similar to
default_asm_output_ident_directive, but handle AS100 syntax also, so
that #ident also works for rx in AS100 syntax.
(TARGET_ASM_OUTPUT_IDENT): Define.
* config/rx/rx.h (IDENT_ASM_OP): Remove.

* Makefile.in: Fix dependencies for c-family/c-lex.o.

c-family/
* c-lex.c: Do not include output.h.
(cb_ident): Try to put out .ident with targetm.asm_out.output_ident.
Remove uses of ASM_OUTPUT_IDENT.

ada/
* gcc-interface/trans.c: Include target.h.
(gigi): Try to put out .ident with targetm.asm_out.output_ident.
Remove uses of ASM_OUTPUT_IDENT.
* gcc-interface/Make-lang.in: Fix dependencies.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188791 138bc75d-0d04-0410-961f-82ee72b054a4

29 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/ada/ChangeLog
gcc/ada/gcc-interface/Make-lang.in
gcc/ada/gcc-interface/trans.c
gcc/c-family/ChangeLog
gcc/c-family/c-lex.c
gcc/config/arm/aout.h
gcc/config/cris/cris-protos.h
gcc/config/cris/cris.c
gcc/config/cris/cris.h
gcc/config/elfos.h
gcc/config/i386/djgpp.h
gcc/config/i386/gas.h
gcc/config/microblaze/microblaze-protos.h
gcc/config/microblaze/microblaze.c
gcc/config/microblaze/microblaze.h
gcc/config/mips/mips.h
gcc/config/mips/sde.h
gcc/config/picochip/picochip.h
gcc/config/rx/rx.c
gcc/config/rx/rx.h
gcc/config/sparc/sparc.h
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/target.def
gcc/targhooks.h
gcc/toplev.c
gcc/varasm.c

index 3e1d8bbd4a316e1bf8d5cf86fb50e37ae5b42568..35db0820bb465bf0e3a4287e52d4492ec2fad932 100644 (file)
@@ -1,3 +1,52 @@
+2012-06-19  Steven Bosscher  <steven@gcc.gnu.org>
+
+       * target.def (output_ident): New hook.
+       * targhooks.h (default_asm_output_ident_directive): Add prototype.
+       * varasm.c (assemble_asm): Only prefix a tab if the string does not
+       already start with one.
+       (default_asm_output_ident_directive): New function to emit
+       .ident as a top-level asm node while parsing, or directly to
+       asm_out_file after parsing.
+       * toplev.c (compile_file): Print a GCC .ident with
+       targetm.asm_out.output_ident.
+       * doc/tm.texi.in (ASM_OUTPUT_IDENT): Remove documentation for macro.
+       (TARGET_ASM_OUTPUT_IDENT): Add @hook for this.
+       * doc/tm.texi: Update.
+
+       * config/elfos.h (ASM_OUTPUT_IDENT, IDENT_ASM_OP): Remove.
+       (TARGET_ASM_OUTPUT_IDENT): Define.
+       * config/i386/djgpp.h (IDENT_ASM_OP): Remove.
+       * config/i386/gas.h (ASM_OUTPUT_IDENT): Remove.
+       * config/arm/aout.h (ASM_OUTPUT_IDENT): Remove.
+       * config/sparc/sparc.h (IDENT_ASM_OP): Remove.
+       (TARGET_ASM_OUTPUT_IDENT): Define.
+       * config/picochip/picochip.h (IDENT_ASM_OP): Remove.
+       (TARGET_ASM_OUTPUT_IDENT): Define.
+
+       * config/cris/cris-protos.h (cris_asm_output_ident): Add prototype.
+       * config/cris/cris.c (cris_asm_output_ident): New function.
+       * config/cris/cris.h (ASM_OUTPUT_IDENT, IDENT_ASM_OP): Remove.
+
+       * config/microblaze/microblaze-protos.h (microblaze_asm_output_ident):
+       Add prototype.
+       * config/microblaze/microblaze.c: Include cgraph.h for add_asm_node.
+       (microblaze_asm_output_ident): Rewrite to work similar to
+       default_asm_output_ident_directive for front-end .idents.
+       * config/microblaze/microblaze.h (ASM_OUTPUT_IDENT): Remove.
+       (TARGET_ASM_OUTPUT_IDENT): Define.
+
+       * config/mips/mips.h (ASM_OUTPUT_IDENT): Remove.
+       * config/mips/sde.h (IDENT_ASM_OP, ASM_OUTPUT_IDENT): Remove.
+
+       * config/rx/rx.c: Include cgraph.h for add_asm_node.
+       (rx_asm_output_ident): New function, similar to
+       default_asm_output_ident_directive, but handle AS100 syntax also, so
+       that #ident also works for rx in AS100 syntax.
+       (TARGET_ASM_OUTPUT_IDENT): Define.
+       * config/rx/rx.h (IDENT_ASM_OP): Remove.
+
+       * Makefile.in: Fix dependencies for c-family/c-lex.o.
+
 2012-06-19  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (FIST_ROUNDING): New int iterator.
index 156a6b1f66839f34b29f7a698d55f867ad539460..585acbdf1f3de0e4d091ed202e24ee81e17a6fc1 100644 (file)
@@ -2019,7 +2019,7 @@ c-family/c-gimplify.o : c-family/c-gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H)
 
 c-family/c-lex.o : c-family/c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
        $(TM_H) $(TREE_H) $(FIXED_VALUE_H) debug.h $(C_COMMON_H) $(SPLAY_TREE_H) \
-       $(C_PRAGMA_H) $(INPUT_H) intl.h $(FLAGS_H) output.h \
+       $(C_PRAGMA_H) $(INPUT_H) intl.h $(FLAGS_H) \
        $(CPPLIB_H) $(TARGET_H) $(TIMEVAR_H)
 
 c-family/c-omp.o : c-family/c-omp.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
index 8cca048644c9553ad86c7940859432ef9713f712..c56d5c9b54935d616714c361e8d173aff5f22c9b 100644 (file)
@@ -1,3 +1,10 @@
+2012-06-19  Steven Bosscher  <steven@gcc.gnu.org>
+
+       * gcc-interface/trans.c: Include target.h.
+       (gigi): Try to put out .ident with targetm.asm_out.output_ident.
+       Remove uses of ASM_OUTPUT_IDENT.
+       * gcc-interface/Make-lang.in: Fix dependencies.
+
 2012-06-15  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR ada/53592
index b84ebd26c2fe398cfaf433c46d997c07dd3d2f7e..c9ddd9bfc4d344c44f88d5ef50a1fd9a1a04dfb1 100644 (file)
@@ -1014,7 +1014,7 @@ ada/targtyps.o : ada/gcc-interface/targtyps.c $(CONFIG_H) $(SYSTEM_H) \
 
 ada/trans.o : ada/gcc-interface/trans.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) $(TREE_H) $(FLAGS_H) output.h tree-iterator.h $(GIMPLE_H) \
-   $(BITMAP_H) $(CGRAPH_H) ada/gcc-interface/ada.h ada/adadecode.h \
+   $(BITMAP_H) $(CGRAPH_H) $(TARGET_H) ada/gcc-interface/ada.h ada/adadecode.h \
    ada/types.h ada/atree.h ada/elists.h ada/namet.h ada/nlists.h ada/snames.h \
    ada/stringt.h ada/uintp.h ada/urealp.h ada/fe.h ada/sinfo.h ada/einfo.h \
    ada/gcc-interface/gadaint.h $(ADA_TREE_H) ada/gcc-interface/gigi.h \
index 65231bde84872d589dd0c6d16b129212b60fa579..27750a6e4a486c5837f5bd1a1857b0e9d5b1974e 100644 (file)
@@ -36,6 +36,7 @@
 #include "gimple.h"
 #include "bitmap.h"
 #include "cgraph.h"
+#include "target.h"
 
 #include "ada.h"
 #include "adadecode.h"
@@ -647,12 +648,9 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
   VEC_safe_push (tree, gc, gnu_program_error_label_stack, NULL_TREE);
 
   /* Process any Pragma Ident for the main unit.  */
-#ifdef ASM_OUTPUT_IDENT
   if (Present (Ident_String (Main_Unit)))
-    ASM_OUTPUT_IDENT
-      (asm_out_file,
-       TREE_STRING_POINTER (gnat_to_gnu (Ident_String (Main_Unit))));
-#endif
+    targetm.asm_out.output_ident
+      (TREE_STRING_POINTER (gnat_to_gnu (Ident_String (Main_Unit))));
 
   /* If we are using the GCC exception mechanism, let GCC know.  */
   if (Exception_Mechanism == Back_End_Exceptions)
index 529cc06f84bf0bfe67c080612fd427904b6365ae..15e8f386a1f7d1c216fce2347206566f67be6304 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-19  Steven Bosscher  <steven@gcc.gnu.org>
+
+       * c-lex.c: Do not include output.h.
+       (cb_ident): Try to put out .ident with targetm.asm_out.output_ident.
+       Remove uses of ASM_OUTPUT_IDENT.
+
 2012-06-15  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/51033
index d9bd823fde272803c0750427ae101c1a2d221000..de9fa698edc49ad6874d61bd9383264b31ca91f1 100644 (file)
@@ -26,7 +26,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "tree.h"
 #include "input.h"
-#include "output.h" /* for asm_out_file */
 #include "c-common.h"
 #include "flags.h"
 #include "timevar.h"
@@ -165,18 +164,16 @@ cb_ident (cpp_reader * ARG_UNUSED (pfile),
          unsigned int ARG_UNUSED (line),
          const cpp_string * ARG_UNUSED (str))
 {
-#ifdef ASM_OUTPUT_IDENT
   if (!flag_no_ident)
     {
       /* Convert escapes in the string.  */
       cpp_string cstr = { 0, 0 };
       if (cpp_interpret_string (pfile, str, 1, &cstr, CPP_STRING))
        {
-         ASM_OUTPUT_IDENT (asm_out_file, (const char *) cstr.text);
+         targetm.asm_out.output_ident ((const char *) cstr.text);
          free (CONST_CAST (unsigned char *, cstr.text));
        }
     }
-#endif
 }
 
 /* Called at the start of every non-empty line.  TOKEN is the first
index f8e7367fd664e23bc990f53abf3fead8d29cbfc7..c60adb9a3294fd0fb47419862d7d124b24c9102a 100644 (file)
   asm_output_aligned_bss (STREAM, DECL, NAME, SIZE, ALIGN)
 #endif
 
-/* Output a #ident directive.  */
-#ifndef ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(STREAM,STRING)  \
-  asm_fprintf (STREAM, "%@ - - - ident %s\n", STRING)
-#endif
-     
 #ifndef ASM_COMMENT_START
 #define ASM_COMMENT_START      "@"
 #endif
index b8d1c78db6d9c6970e9d64a290220f88309683dc..d08dac5dab0aa8d35ac37458b103dcf9cb532ae4 100644 (file)
@@ -52,6 +52,7 @@ extern void cris_order_for_addsi3 (rtx *, int);
 extern void cris_emit_trap_for_misalignment (rtx);
 #endif /* RTX_CODE */
 extern void cris_asm_output_label_ref (FILE *, char *);
+extern void cris_asm_output_ident (const char *);
 extern void cris_expand_prologue (void);
 extern void cris_expand_epilogue (void);
 extern void cris_expand_return (bool);
index 3c6fb080ed33d8904c982a744a7127d1e851176f..a5a342720bbcbb7ddf9f517d7ff9e6919bd10004 100644 (file)
@@ -2467,6 +2467,22 @@ cris_legitimate_pic_operand (rtx x)
   return cris_valid_pic_const (x, true);
 }
 
+/* Queue an .ident string in the queue of top-level asm statements.
+   If the front-end is done, we must be being called from toplev.c.
+   In that case, do nothing.  */
+void 
+cris_asm_output_ident (const char *string)
+{
+  const char *section_asm_op;
+  int size;
+  char *buf;
+
+  if (cgraph_state != CGRAPH_STATE_PARSING)
+    return;
+
+  default_asm_output_ident_directive (string);
+}
+
 /* The ASM_OUTPUT_CASE_END worker.  */
 
 void
@@ -2517,6 +2533,10 @@ cris_asm_output_case_end (FILE *stream, int num, rtx table)
 static void
 cris_option_override (void)
 {
+  /* We don't want an .ident for gcc.
+     It isn't really clear anymore why not.  */
+  flag_no_gcc_ident = true;
+
   if (cris_max_stackframe_str)
     {
       cris_max_stackframe = atoi (cris_max_stackframe_str);
index 4e335314f3eda6e7a6b7f4415301a353b3e88521..b0bc57f7c0fecc83b0ccc6be18240529e93bf774 100644 (file)
@@ -842,12 +842,11 @@ enum cris_pic_symbol_type
 /* Node: File Framework */
 
 /* We don't want an .ident for gcc.  To avoid that but still support
-   #ident, we override ASM_OUTPUT_IDENT and, since the gcc .ident is its
-   only use besides ASM_OUTPUT_IDENT, undef IDENT_ASM_OP from elfos.h.  */
-#undef IDENT_ASM_OP
-#undef ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
-  fprintf (FILE, "%s\"%s\"\n", "\t.ident\t", NAME);
+   #ident, we override TARGET_ASM_OUTPUT_IDENT and, since the gcc .ident
+   is its only use besides front-end .ident directives, we return if
+   the state if the cgraph is not CGRAPH_STATE_PARSING.  */
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT cris_asm_output_ident
 
 #define ASM_APP_ON "#APP\n"
 
index dc68c810f268559dfc7e08a9c3ce8cdaff3785d5..4c748835da3c24660dffc6e97bbb10a7e2efbe97 100644 (file)
@@ -83,10 +83,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 /* Output #ident as a .ident.  */
 
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
-  fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
-
-#define IDENT_ASM_OP "\t.ident\t"
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 #undef  SET_ASM_OP
 #define SET_ASM_OP     "\t.set\t"
index c770219657c91e96639579463f8ebb07ed58e039..b2efb34354530da7aeec56999bd6d0d694b1cc6a 100644 (file)
@@ -31,10 +31,6 @@ along with GCC; see the file COPYING3.  If not see
 #undef DATA_SECTION_ASM_OP
 #define DATA_SECTION_ASM_OP "\t.section .data"
 
-/* Define the name of the .ident op.  */
-#undef IDENT_ASM_OP
-#define IDENT_ASM_OP "\t.ident\t"
-
 /* Enable alias attribute support.  */
 #ifndef SET_ASM_OP
 #define SET_ASM_OP "\t.set\t"
index 4c7c9d1ac62d18f60798dfd3cfe54e8ce450e03b..bb5877ff4bbaa98270f646abde5f0a4e31da2197 100644 (file)
@@ -47,7 +47,8 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Output #ident as a .ident.  */
 
-#define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME);
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 /* In the past there was confusion as to what the argument to .align was
    in GAS.  For the last several years the rule has been this: for a.out
index 0a7d1c7f56dcb2450867afefb5c6e3be1c4db44d..8673e49fb0c22d60e95a8b105eae7dad6898426a 100644 (file)
@@ -48,7 +48,7 @@ extern int microblaze_regno_ok_for_base_p (int, int);
 extern HOST_WIDE_INT microblaze_initial_elimination_offset (int, int);
 extern void microblaze_declare_object (FILE *, const char *, const char *,
    const char *, int);
-extern void microblaze_asm_output_ident (FILE *, const char *);
+extern void microblaze_asm_output_ident (const char *);
 #endif  /* RTX_CODE */
 
 /* Declare functions in microblaze-c.c.  */
index 8d08bc282ffbc10b2a4a05324d344d3fbd3386eb..31248a0b5593730f3727e5719da986b82dcaa167 100644 (file)
@@ -47,6 +47,7 @@
 #include "df.h"
 #include "optabs.h"
 #include "diagnostic-core.h"
+#include "cgraph.h"
 
 #define MICROBLAZE_VERSION_COMPARE(VA,VB) strcasecmp (VA, VB)
 
@@ -2736,16 +2737,28 @@ microblaze_return_addr (int count, rtx frame ATTRIBUTE_UNUSED)
                       GEN_INT (8));
 }
 
-/* Put string into .sdata2 if below threashold.  */
+/* Queue an .ident string in the queue of top-level asm statements.
+   If the string size is below the threshold, put it into .sdata2.
+   If the front-end is done, we must be being called from toplev.c.
+   In that case, do nothing.  */
 void 
-microblaze_asm_output_ident (FILE *file ATTRIBUTE_UNUSED, const char *string)
+microblaze_asm_output_ident (const char *string)
 {
-  int size = strlen (string) + 1;
+  const char *section_asm_op;
+  int size;
+  char *buf;
+
+  if (cgraph_state != CGRAPH_STATE_PARSING)
+    return;
+
+  size = strlen (string) + 1;
   if (size <= microblaze_section_threshold)
-    switch_to_section (sdata2_section);
+    section_asm_op = SDATA2_SECTION_ASM_OP;
   else
-    switch_to_section (readonly_data_section);
-  assemble_string (string, size);
+    section_asm_op = READONLY_DATA_SECTION_ASM_OP;
+
+  buf = ACONCAT ((section_asm_op, "\n\t.ascii \"", string, "\\0\"\n", NULL));
+  add_asm_node (build_string (strlen (buf), buf));
 }
 
 static void
index d17d89483355bf4bfa8d5fde76c71badd801f29d..783d1e09cb18961a371946202d530b258f625f6c 100644 (file)
@@ -696,8 +696,8 @@ do {                                                                        \
 #define ASCII_DATA_ASM_OP              "\t.ascii\t"
 #define STRING_ASM_OP                  "\t.asciz\t"
 
-#define ASM_OUTPUT_IDENT(FILE, STRING)                                 \
-  microblaze_asm_output_ident (FILE, STRING)
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT microblaze_asm_output_ident
 
 /* Default to -G 8 */
 #ifndef MICROBLAZE_DEFAULT_GVALUE
index bcb7c0436d0e4664ccdf9d9155a6bdf365c459ad..97f38b2c49b8cc129988e594c741c0b9aec75b71 100644 (file)
@@ -2674,15 +2674,6 @@ do {                                                                     \
 #undef ASM_OUTPUT_ASCII
 #define ASM_OUTPUT_ASCII mips_output_ascii
 
-/* Output #ident as a in the read-only data section.  */
-#undef  ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(FILE, STRING)                                 \
-{                                                                      \
-  const char *p = STRING;                                              \
-  int size = strlen (p) + 1;                                           \
-  switch_to_section (readonly_data_section);                           \
-  assemble_string (p, size);                                           \
-}
 \f
 /* Default to -G 8 */
 #ifndef MIPS_DEFAULT_GVALUE
index cc420eb5c53b24efada77ef837a5dcca3ff1a240..0fada904e8a7b18c851d9e6141d5ed62ff88e78a 100644 (file)
@@ -97,17 +97,6 @@ along with GCC; see the file COPYING3.  If not see
 /* Use periods rather than dollar signs in special g++ assembler names.  */
 #define NO_DOLLAR_IN_LABEL
 
-/* Attach a special .ident directive to the end of the file to identify
-   the version of GCC which compiled this code.  */
-#undef IDENT_ASM_OP
-#define IDENT_ASM_OP "\t.ident\t"
-
-/* Output #ident string into the ELF .comment section, so it doesn't
-   form part of the load image, and so that it can be stripped.  */
-#undef ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(STREAM, STRING) \
-  fprintf (STREAM, "%s\"%s\"\n", IDENT_ASM_OP, STRING);
-
 /* Currently we don't support 128bit long doubles, so for now we force
    n32 to be 64bit.  */
 #undef LONG_DOUBLE_TYPE_SIZE
index 9eb7df94c014768aca39a9e1ff91e9ede0699e79..f13efc9c4a6d14d0996c68699be50b1a8be935b8 100644 (file)
@@ -488,7 +488,8 @@ do {                                                                         \
 #define ASM_APP_ON "// High-level ASM start\n"
 #define ASM_APP_OFF "// High-level ASM end\n"
 
-#define ASM_OUTPUT_IDENT(STREAM,STRING) fprintf(STREAM, ".ident %s\n", STRING)
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 /* Output of Data  */
 
index 016c34827ce5ca74ef2d7457e7a1eff25a2c2965..08b998e2a46c76fc4f76cff82ae03b71cfbda72d 100644 (file)
@@ -52,6 +52,7 @@
 #include "target-def.h"
 #include "langhooks.h"
 #include "opts.h"
+#include "cgraph.h"
 
 static unsigned int rx_gp_base_regnum_val = INVALID_REGNUM;
 static unsigned int rx_pid_base_regnum_val = INVALID_REGNUM;
index 80c5b498f05333513d306b41bc88bfc76bac1662..065079fbbbdc7ead3381cba6ff4d1b4c9b5b3f50 100644 (file)
@@ -602,10 +602,6 @@ typedef unsigned int CUMULATIVE_ARGS;
     }                                                  \
   while (0)
 
-#undef  IDENT_ASM_OP
-#define IDENT_ASM_OP  (TARGET_AS100_SYNTAX \
-                      ? "\t.END\t; Built by: ": "\t.ident\t")
-
 /* For PIC put jump tables into the text section so that the offsets that
    they contain are always computed between two same-section symbols.  */
 #define JUMP_TABLES_IN_TEXT_SECTION    (TARGET_PID || flag_pic)
index 234edcfd9c4a19974bda95aed83c761336a557ee..81bcce8b6637f97f138a5eca164f7780b61300a8 100644 (file)
@@ -1709,12 +1709,10 @@ do {                                                                    \
     ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN);                \
   } while (0)
 
-#define IDENT_ASM_OP "\t.ident\t"
-
 /* Output #ident as a .ident.  */
 
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
-  fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 /* Prettify the assembly.  */
 
index 0715531af5728d42fb16a696a485b4111702478c..8399b71ce10144c1162ba2cc335dd5b729f55f39 100644 (file)
@@ -7392,6 +7392,10 @@ Output COFF information or DWARF debugging information which indicates that file
  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_IDENT (const char *@var{name})
+Output a string based on @var{name}, suitable for the @samp{#ident}  directive, or the equivalent directive or pragma in non-C-family languages.  If this hook is not defined, nothing is output for the @samp{#ident}  directive.
+@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}
@@ -7400,12 +7404,6 @@ the assembler source.  So you can use it to canonicalize the format
 of the filename using this macro.
 @end defmac
 
-@defmac ASM_OUTPUT_IDENT (@var{stream}, @var{string})
-A C statement to output something to the assembler file to handle a
-@samp{#ident} directive containing the text @var{string}.  If this
-macro is not defined, nothing is output for a @samp{#ident} directive.
-@end defmac
-
 @deftypefn {Target Hook} void TARGET_ASM_NAMED_SECTION (const char *@var{name}, unsigned int @var{flags}, tree @var{decl})
 Output assembly directives to switch to section @var{name}.  The section
 should have attributes as specified by @var{flags}, which is a bit mask
index 00f288b6a169897607d7df1aa04dfc6dcc0a59ea..9c76449c755c0179a9d293c26ea41a77c34ea20c 100644 (file)
@@ -7302,6 +7302,8 @@ for the file format in use is appropriate.
 
 @hook TARGET_ASM_OUTPUT_SOURCE_FILENAME
 
+@hook TARGET_ASM_OUTPUT_IDENT
+
 @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}
@@ -7310,12 +7312,6 @@ the assembler source.  So you can use it to canonicalize the format
 of the filename using this macro.
 @end defmac
 
-@defmac ASM_OUTPUT_IDENT (@var{stream}, @var{string})
-A C statement to output something to the assembler file to handle a
-@samp{#ident} directive containing the text @var{string}.  If this
-macro is not defined, nothing is output for a @samp{#ident} directive.
-@end defmac
-
 @hook TARGET_ASM_NAMED_SECTION
 Output assembly directives to switch to section @var{name}.  The section
 should have attributes as specified by @var{flags}, which is a bit mask
index 3463600f99ac930126fb38d6be702a68317e080a..051579ffabeb63dbed4089e7201cd755505f08ee 100644 (file)
@@ -427,6 +427,15 @@ DEFHOOK
  void, (rtx x),
  default_asm_output_anchor)
 
+DEFHOOK
+(output_ident,
+ "Output a string based on @var{name}, suitable for the @samp{#ident} \
+ directive, or the equivalent directive or pragma in non-C-family languages. \
+ If this hook is not defined, nothing is output for the @samp{#ident} \
+ directive.",
+ void, (const char *name),
+ hook_void_constcharptr)
+
 /* Output a DTP-relative reference to a TLS symbol.  */
 DEFHOOK
 (output_dwarf_dtprel,
index 861811543f8f03792342807757eed73e2a7c6824..da80fdf82c2442d97634e07c302db104dd303997 100644 (file)
@@ -178,3 +178,6 @@ extern enum machine_mode default_get_reg_raw_mode(int);
 
 extern void *default_get_pch_validity (size_t *);
 extern const char *default_pch_valid_p (const void *, size_t);
+
+extern void default_asm_output_ident_directive (const char*);
+
index 2eb75f1b9d68e7418e1524972afaa86a5fb10764..9776ff5208a778bb2c12d5ebcb4233eae04ffcaa 100644 (file)
@@ -647,17 +647,17 @@ compile_file (void)
   /* Attach a special .ident directive to the end of the file to identify
      the version of GCC which compiled this code.  The format of the .ident
      string is patterned after the ones produced by native SVR4 compilers.  */
-#ifdef IDENT_ASM_OP
   if (!flag_no_ident)
     {
       const char *pkg_version = "(GNU) ";
+      char *ident_str;
 
       if (strcmp ("(GCC) ", pkgversion_string))
        pkg_version = pkgversion_string;
-      fprintf (asm_out_file, "%s\"GCC: %s%s\"\n",
-              IDENT_ASM_OP, pkg_version, version_string);
+
+      ident_str = ACONCAT (("GCC: ", pkg_version, version_string, NULL));
+      targetm.asm_out.output_ident (ident_str);
     }
-#endif
 
   /* Invoke registered plugin callbacks.  */
   invoke_plugin_callbacks (PLUGIN_FINISH_UNIT, NULL);
index 89bd7caa198d805e38e2c6959fc2d23f0ebb181b..439b29ea24c470123cf73f65d1d14c2b95b3722a 100644 (file)
@@ -1363,12 +1363,14 @@ make_decl_rtl_for_debug (tree decl)
 void
 assemble_asm (tree string)
 {
+  const char *p;
   app_enable ();
 
   if (TREE_CODE (string) == ADDR_EXPR)
     string = TREE_OPERAND (string, 0);
 
-  fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
+  p = TREE_STRING_POINTER (string);
+  fprintf (asm_out_file, "%s%s\n", p[0] == '\t' ? "" : "\t", p);
 }
 
 /* Write the address of the entity given by SYMBOL to SEC.  */
@@ -7411,4 +7413,27 @@ default_elf_fini_array_asm_out_destructor (rtx symbol, int priority)
   assemble_addr_to_section (symbol, sec);
 }
 
+/* Default TARGET_ASM_OUTPUT_IDENT hook.
+
+   This is a bit of a cheat.  The real default is a no-op, but this
+   hook is the default for all targets with a .ident directive.  */
+
+void
+default_asm_output_ident_directive (const char *ident_str)
+{
+  const char *ident_asm_op = "\t.ident\t";
+
+  /* If we are still in the front end, do not write out the string
+     to asm_out_file.  Instead, add a fake top-level asm statement.
+     This allows the front ends to use this hook without actually
+     writing to asm_out_file, to handle #ident or Pragma Ident.  */
+  if (cgraph_state == CGRAPH_STATE_PARSING)
+    {
+      char *buf = ACONCAT ((ident_asm_op, "\"", ident_str, "\"\n", NULL));
+      add_asm_node (build_string (strlen (buf), buf));
+    }
+  else
+    fprintf (asm_out_file, "%s\"%s\"\n", ident_asm_op, ident_str);
+}
+
 #include "gt-varasm.h"