public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add TARGET_ASM_DECLARE_FUNCTION_NAME  target hook.
@ 2008-08-14 16:45 Anatoly Sokolov
  2008-08-14 18:48 ` Mark Mitchell
  0 siblings, 1 reply; 3+ messages in thread
From: Anatoly Sokolov @ 2008-08-14 16:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: aesok, iant

Hello.

  This patch introduce new TARGET_ASM_DECLARE_FUNCTION_NAME target hook
instead of ASM_DECLARE_FUNCTION_NAME macro.

  Patch was bootstrapped and regression tested on x86_64-unknown-linux-gnu.

  Ok, to commit?

2008-08-14  Anatoly Sokolov  <aesok@post.ru>

        * target.h (struct asm_out): Add declare_function_name field.
        * target-def.h (TARGET_ASM_DECLARE_FUNCTION_NAME): New.
        (TARGET_ASM_OUT): Use TARGET_ASM_DECLARE_FUNCTION_NAME.
        * varasm.c (default_asm_declare_function_name): New function.
        (assemble_start_function): Use declare_function_name target hook.
        (assemble_label): Add a file parameter.
        * output.h (default_asm_declare_function_name): Declare function.
        (assemble_label): Update declaration.
        * config/darwin.c (machopic_output_indirection) : Call to
        assemble_label changed.
        * doc/tm.texi (TARGET_ASM_DECLARE_FUNCTION_NAME): Document new hook.

Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi     (revision 139100)
+++ gcc/doc/tm.texi     (working copy)
@@ -7321,6 +7321,20 @@
 of this macro.
 @end defmac
 
+@deftypefn {Target Hook} void TARGET_ASM_DECLARE_FUNCTION_NAME (FILE * @var{file}, const char * @var{name}, tree @var{decl})
+A target hook to output to the stdio stream @var{file} any text necessary
+for declaring the name @var{name} of a function which is being
+defined.  This target hook is responsible for outputting the label
+definition (perhaps using @code{ASM_OUTPUT_LABEL}).  The argument
+@var{decl} is the @code{FUNCTION_DECL} tree node representing the function.
+
+In the default version of this target hook the function name is defined in
+the usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+
+You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the
+implementation of this target hook.
+@end deftypefn
+
 @defmac ASM_DECLARE_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl})
 A C statement (sans semicolon) to output to the stdio stream
 @var{stream} any text necessary for declaring the size of a function
Index: gcc/target.h
===================================================================
--- gcc/target.h        (revision 139100)
+++ gcc/target.h        (working copy)
@@ -139,6 +139,9 @@
     /* Output an internal label.  */
     void (* internal_label) (FILE *, const char *, unsigned long);
 
+    /* Output an function name.  */
+    void (* declare_function_name) (FILE *, const char *, tree);
+    
     /* Emit a ttype table reference to a typeinfo object.  */
     bool (* ttype) (rtx);
 
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c        (revision 139100)
+++ gcc/varasm.c        (working copy)
@@ -1754,12 +1754,8 @@
     targetm.asm_out.mark_decl_preserved (fnname);
 
   /* Do any machine/system dependent processing of the function name.  */
-#ifdef ASM_DECLARE_FUNCTION_NAME
-  ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
-#else
-  /* Standard thing is just output label for the function.  */
-  ASM_OUTPUT_LABEL (asm_out_file, fnname);
-#endif /* ASM_DECLARE_FUNCTION_NAME */
+  targetm.asm_out.declare_function_name (asm_out_file, fnname, 
+                                        current_function_decl);
 }
 
 /* Output assembler code associated with defining the size of the
@@ -2326,9 +2322,9 @@
 /* Assemble a label named NAME.  */
 
 void
-assemble_label (const char *name)
+assemble_label (FILE *file, const char *name)
 {
-  ASM_OUTPUT_LABEL (asm_out_file, name);
+  ASM_OUTPUT_LABEL (file, name);
 }
 
 /* Set the symbol_referenced flag for ID.  */
@@ -6300,7 +6296,7 @@
 
 /* Default function to output code that will globalize a declaration.  */
 void
-default_globalize_decl_name (FILE * stream, tree decl)
+default_globalize_decl_name (FILE *stream, tree decl)
 {
   const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
   targetm.asm_out.globalize_label (stream, name);
@@ -6337,6 +6333,19 @@
   ASM_OUTPUT_INTERNAL_LABEL (stream, buf);
 }
 
+/* The default implementation of TARGET_ASM_DECLARE_FUNCTION_NAME.  */
+
+void
+default_asm_declare_function_name (FILE * stream, const char *fnname,
+            tree decl ATTRIBUTE_UNUSED)
+{
+#ifdef ASM_DECLARE_FUNCTION_NAME
+  ASM_DECLARE_FUNCTION_NAME (stream, fnname, current_function_decl);
+#else
+  assemble_label (stream, fnname);
+#endif /* ASM_DECLARE_FUNCTION_NAME */
+}
+
 /* This is the default behavior at the beginning of a file.  It's
    controlled by two other target-hook toggles.  */
 void
Index: gcc/target-def.h
===================================================================
--- gcc/target-def.h    (revision 139100)
+++ gcc/target-def.h    (working copy)
@@ -84,6 +84,10 @@
 #define TARGET_ASM_INTERNAL_LABEL default_internal_label
 #endif
 
+#ifndef TARGET_ASM_DECLARE_FUNCTION_NAME
+#define TARGET_ASM_DECLARE_FUNCTION_NAME default_asm_declare_function_name
+#endif
+
 #ifndef TARGET_ARM_TTYPE
 #define TARGET_ASM_TTYPE hook_bool_rtx_false
 #endif
@@ -267,6 +271,7 @@
                        TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL,     \
                        TARGET_UNWIND_EMIT,                     \
                        TARGET_ASM_INTERNAL_LABEL,              \
+                       TARGET_ASM_DECLARE_FUNCTION_NAME,       \
                        TARGET_ASM_TTYPE,                       \
                        TARGET_ASM_ASSEMBLE_VISIBILITY,         \
                        TARGET_ASM_FUNCTION_PROLOGUE,           \
Index: gcc/output.h
===================================================================
--- gcc/output.h        (revision 139100)
+++ gcc/output.h        (working copy)
@@ -217,7 +217,7 @@
 extern void assemble_external_libcall (rtx);
 
 /* Assemble a label named NAME.  */
-extern void assemble_label (const char *);
+extern void assemble_label (FILE *, const char *);
 
 /* Output to FILE (an assembly file) a reference to NAME.  If NAME
    starts with a *, the rest of NAME is output verbatim.  Otherwise
@@ -613,6 +613,7 @@
 extern void default_emit_unwind_label (FILE *, tree, int, int);
 extern void default_emit_except_table_label (FILE *);
 extern void default_internal_label (FILE *, const char *, unsigned long);
+extern void default_asm_declare_function_name (FILE *, const char *, tree);
 extern void default_file_start (void);
 extern void file_end_indicate_exec_stack (void);
 extern bool default_valid_pointer_mode (enum machine_mode);
Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(revision 139100)
+++ gcc/config/darwin.c	(working copy)
@@ -992,7 +992,7 @@
     {
       switch_to_section (data_section);
       assemble_align (GET_MODE_ALIGNMENT (Pmode));
-      assemble_label (ptr_name);
+      assemble_label (asm_out_file, ptr_name);
       assemble_integer (gen_rtx_SYMBOL_REF (Pmode, sym_name),
                        GET_MODE_SIZE (Pmode),
                        GET_MODE_ALIGNMENT (Pmode), 1);

Anatoliy.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-14 19:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-14 16:45 [PATCH] Add TARGET_ASM_DECLARE_FUNCTION_NAME target hook Anatoly Sokolov
2008-08-14 18:48 ` Mark Mitchell
2008-08-14 20:05   ` Anatoly Sokolov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).