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 ASM_DECLARE_CONSTANT_NAME


Hello.

  This patch turns ASM_DECLARE_CONSTANT_NAME macro into a hook.

  The patch has been bootstrapped on and regression tested on
x86_64-unknown-linux-gnu and x86_64-apple-darwin10.3.0.

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


        * target.h (struct asm_out):Add declare_constant_name field.
        * target-def.h (TARGET_ASM_DECLARE_CONSTANT_NAME): Define.
        (TARGET_INITIALIZER): Use TARGET_ASM_DECLARE_CONSTANT_NAME.
        * output.h (default_asm_declare_constant_name): Declare.
        (assemble_label): Update prototype.
        * varasm.c (assemble_constant_contents): Use 
        targetm.asm_out.declare_constant_name target hook.
        (assemble_label): Add 'file' argument.
        (default_asm_declare_constant_name): New function.
        * system.h (ASM_DECLARE_CONSTANT_NAME): Poison.
        * doc/tm.texi (ASM_DECLARE_CONSTANT_NAME): Remove.
        (TARGET_ASM_DECLARE_CONSTANT_NAME): Document it.

        * config/darwin-protos.h (darwin_asm_declare_constant_name): Declare.
        * config/darwin.c (darwin_asm_declare_constant_name): New function.
        (machopic_output_indirection): Update assemble_label argument list.
        * ASM_DECLARE_CONSTANT_NAME): Remove.
        (TARGET_ASM_DECLARE_CONSTANT_NAME): Define.


Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi     (revision 160399)
+++ gcc/doc/tm.texi     (working copy)
@@ -7792,21 +7792,19 @@
 @code{ASM_OUTPUT_SIZE_DIRECTIVE} in the definition of this macro.
 @end defmac
 
-@defmac ASM_DECLARE_CONSTANT_NAME (@var{stream}, @var{name}, @var{exp}, @var{size})
-A C statement (sans semicolon) to output to the stdio stream
-@var{stream} any text necessary for declaring the name @var{name} of a
-constant which is being defined.  This macro is responsible for
-outputting the label definition (perhaps using
-@code{ASM_OUTPUT_LABEL}).  The argument @var{exp} is the
-value of the constant, and @var{size} is the size of the constant
-in bytes.  @var{name} will be an internal label.
+@deftypefn {Target Hook} void TARGET_ASM_DECLARE_CONSTANT_NAME (FILE * @var{file}, const char * @var{name}, const_tree @var{expr}, HOST_WIDE_INT @var{size})
+A target hook to output to the stdio stream @var{file} any text necessary
+for declaring the name @var{name} of a constant which is being defined.  This
+target hook is responsible for outputting the label definition (perhaps using
+@code{assemble_label}).  The argument @var{exp} is the value of the constant,
+and @var{size} is the size of the constant in bytes.  The @var{name}
+will be an internal label.
 
-If this macro is not defined, then the @var{name} is defined in the
-usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+The default version of this target hook, define the @var{name} in the
+usual manner as a label (by means of @code{assemble_label}).
 
-You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
-of this macro.
-@end defmac
+You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in this target hook.
+@end deftypefn
 
 @defmac ASM_DECLARE_REGISTER_GLOBAL (@var{stream}, @var{decl}, @var{regno}, @var{name})
 A C statement (sans semicolon) to output to the stdio stream
Index: gcc/target.h
===================================================================
--- gcc/target.h        (revision 160399)
+++ gcc/target.h        (working copy)
@@ -171,6 +171,10 @@
     /* Output an internal label.  */
     void (* internal_label) (FILE *, const char *, unsigned long);
 
+    /* Output label for the constant.  */
+    void (* declare_constant_name) (FILE *, const char *, const_tree, 
+                                   HOST_WIDE_INT);
+
     /* Emit a ttype table reference to a typeinfo object.  */
     bool (* ttype) (rtx);
 
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c        (revision 160399)
+++ gcc/varasm.c        (working copy)
@@ -2462,9 +2462,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.  */
@@ -3476,12 +3476,7 @@
   size = get_constant_size (exp);
 
   /* Do any machine/system dependent processing of the constant.  */
-#ifdef ASM_DECLARE_CONSTANT_NAME
-  ASM_DECLARE_CONSTANT_NAME (asm_out_file, label, exp, size);
-#else
-  /* Standard thing is just output label for the constant.  */
-  ASM_OUTPUT_LABEL (asm_out_file, label);
-#endif /* ASM_DECLARE_CONSTANT_NAME */
+  targetm.asm_out.declare_constant_name (asm_out_file, label, exp, size);
 
   /* Output the value of EXP.  */
   output_constant (exp, size, align);
@@ -6895,6 +6890,17 @@
   ASM_OUTPUT_INTERNAL_LABEL (stream, buf);
 }
 
+
+/* The default implementation of ASM_DECLARE_CONSTANT_NAME.  */
+
+void
+default_asm_declare_constant_name (FILE *file, const char *name,
+                                  const_tree exp ATTRIBUTE_UNUSED,
+                                  HOST_WIDE_INT size ATTRIBUTE_UNUSED)
+{
+  assemble_label (file, 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 160399)
+++ gcc/target-def.h    (working copy)
@@ -84,6 +84,10 @@
 #define TARGET_ASM_INTERNAL_LABEL default_internal_label
 #endif
 
+#ifndef TARGET_ASM_DECLARE_CONSTANT_NAME
+#define TARGET_ASM_DECLARE_CONSTANT_NAME default_asm_declare_constant_name
+#endif
+
 #ifndef TARGET_ASM_TTYPE
 #define TARGET_ASM_TTYPE hook_bool_rtx_false
 #endif
@@ -297,6 +301,7 @@
                        TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL,     \
                        TARGET_UNWIND_EMIT,                     \
                        TARGET_ASM_INTERNAL_LABEL,              \
+                       TARGET_ASM_DECLARE_CONSTANT_NAME,       \
                        TARGET_ASM_TTYPE,                       \
                        TARGET_ASM_ASSEMBLE_VISIBILITY,         \
                        TARGET_ASM_FUNCTION_PROLOGUE,           \
Index: gcc/output.h
===================================================================
--- gcc/output.h        (revision 160399)
+++ gcc/output.h        (working copy)
@@ -230,7 +230,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
@@ -630,6 +630,8 @@
 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_constant_name (FILE *, const char *,
+                                              const_tree, HOST_WIDE_INT);
 extern void default_file_start (void);
 extern void file_end_indicate_exec_stack (void);
 
Index: gcc/system.h
===================================================================
--- gcc/system.h        (revision 160399)
+++ gcc/system.h        (working copy)
@@ -762,7 +762,7 @@
        SMALL_ARG_MAX ASM_OUTPUT_SHARED_BSS ASM_OUTPUT_SHARED_COMMON       \
        ASM_OUTPUT_SHARED_LOCAL ASM_MAKE_LABEL_LINKONCE                    \
        STACK_CHECK_PROBE_INTERVAL STACK_CHECK_PROBE_LOAD                  \
-       ORDER_REGS_FOR_LOCAL_ALLOC
+       ORDER_REGS_FOR_LOCAL_ALLOC ASM_DECLARE_CONSTANT_NAME
 
 /* Hooks that are no longer used.  */
  #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE  \
Index: gcc/config/darwin-protos.h
===================================================================
--- gcc/config/darwin-protos.h  (revision 160399)
+++ gcc/config/darwin-protos.h  (working copy)
@@ -87,6 +87,8 @@
                                           const char *);
 extern void darwin_asm_output_dwarf_offset (FILE *, int, const char *,
                                            section *);
+extern void darwin_asm_declare_constant_name (FILE *, const char *,
+                                             const_tree, HOST_WIDE_INT);
 extern bool darwin_binds_local_p (const_tree);
 extern void darwin_cpp_builtins (struct cpp_reader *);
 extern void darwin_asm_output_anchor (rtx symbol);
Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(revision 160399)
+++ gcc/config/darwin.c	(working copy)
@@ -966,7 +966,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);
@@ -1617,6 +1617,20 @@
   fputs ("-.", file);
 }
 
+/* The implementation of ASM_DECLARE_CONSTANT_NAME.  */
+
+void
+darwin_asm_declare_constant_name (FILE *file, const char *name,
+                                 const_tree exp ATTRIBUTE_UNUSED,
+                                 HOST_WIDE_INT size)
+{
+  assemble_label (file, name);
+
+  /* Darwin doesn't support zero-size objects, so give them a byte.  */
+  if ((size) == 0)
+    assemble_zeros (1);
+}
+
 /* Emit an assembler directive to set visibility for a symbol.  The
    only supported visibilities are VISIBILITY_DEFAULT and
    VISIBILITY_HIDDEN; the latter corresponds to Darwin's "private
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 160399)
+++ gcc/config/darwin.h	(working copy)
@@ -652,14 +652,8 @@
     ASM_OUTPUT_LABEL (FILE, xname);                                    \
   } while (0)
 
-#define ASM_DECLARE_CONSTANT_NAME(FILE, NAME, EXP, SIZE)       \
-  do {                                                         \
-    ASM_OUTPUT_LABEL (FILE, NAME);                             \
-    /* Darwin doesn't support zero-size objects, so give them a        \
-       byte.  */                                               \
-    if ((SIZE) == 0)                                           \
-      assemble_zeros (1);                                      \
-  } while (0)
+#undef TARGET_ASM_DECLARE_CONSTANT_NAME
+#define TARGET_ASM_DECLARE_CONSTANT_NAME darwin_asm_declare_constant_name
 
 /* Wrap new method names in quotes so the assembler doesn't gag.
    Make Objective-C internal symbols local and in doing this, we need 


Anatoly.


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