]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
target.h (globalize_decl_name): New.
authorSteve Ellcey <sje@gcc.gnu.org>
Wed, 24 Jan 2007 19:40:12 +0000 (19:40 +0000)
committerSteve Ellcey <sje@gcc.gnu.org>
Wed, 24 Jan 2007 19:40:12 +0000 (19:40 +0000)
* target.h (globalize_decl_name): New.
* target-def.h (TARGET_ASM_GLOBALIZE_DECL_NAME): New.
* output.h (default_globalize_decl_name): New.
* varasm.c (asm_output_bss): Use globalize_decl_name instead of
globalize_label.
        (globalize_decl): Ditto.
(default_globalize_decl_name): New.
* config/ia64/ia64.c (ia64_globalize_decl_name): New.
(ia64_handle_version_id_attribute): New.
(TARGET_ASM_GLOBALIZE_DECL_NAME): New.
(ia64_asm_output_external): Use globalize_decl_name instead
of globalize_label.
* doc/extend.texi (version_id): New pragma.
* doc/tm.texi (ARGET_ASM_GLOBALIZE_DECL_NAME): New target hook.

From-SVN: r121128

gcc/config/ia64/ia64.c
gcc/doc/extend.texi
gcc/doc/tm.texi
gcc/output.h
gcc/target-def.h
gcc/target.h
gcc/varasm.c

index dc4cb39e2c143c542415f18512938419a0d8c9db..36c0d63e1ae44334550043297d298d4f4b3eff29 100644 (file)
@@ -242,6 +242,7 @@ static void bundling (FILE *, int, rtx, rtx);
 static void ia64_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
                                  HOST_WIDE_INT, tree);
 static void ia64_file_start (void);
+static void ia64_globalize_decl_name (FILE *, tree);
 
 static section *ia64_select_rtx_section (enum machine_mode, rtx,
                                         unsigned HOST_WIDE_INT);
@@ -265,6 +266,7 @@ static void ia64_vms_init_libfuncs (void)
      ATTRIBUTE_UNUSED;
 
 static tree ia64_handle_model_attribute (tree *, tree, tree, int, bool *);
+static tree ia64_handle_version_id_attribute (tree *, tree, tree, int, bool *);
 static void ia64_encode_section_info (tree, rtx, int);
 static rtx ia64_struct_value_rtx (tree, int);
 static tree ia64_gimplify_va_arg (tree, tree, tree *, tree *);
@@ -282,6 +284,8 @@ static const struct attribute_spec ia64_attribute_table[] =
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
   { "syscall_linkage", 0, 0, false, true,  true,  NULL },
   { "model",          1, 1, true, false, false, ia64_handle_model_attribute },
+  { "version_id",      1, 1, true, false, false,
+    ia64_handle_version_id_attribute },
   { NULL,             0, 0, false, false, false, NULL }
 };
 
@@ -391,6 +395,9 @@ static const struct attribute_spec ia64_attribute_table[] =
 #undef TARGET_ASM_FILE_START
 #define TARGET_ASM_FILE_START ia64_file_start
 
+#undef TARGET_ASM_GLOBALIZE_DECL_NAME
+#define TARGET_ASM_GLOBALIZE_DECL_NAME ia64_globalize_decl_name
+
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS ia64_rtx_costs
 #undef TARGET_ADDRESS_COST
@@ -2226,6 +2233,24 @@ emit_safe_across_calls (void)
     fputc ('\n', asm_out_file);
 }
 
+/* Globalize a declaration.  */
+
+static void
+ia64_globalize_decl_name (FILE * stream, tree decl)
+{
+  const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
+  tree version_attr = lookup_attribute ("version_id", DECL_ATTRIBUTES (decl));
+  if (version_attr)
+    {
+      tree v = TREE_VALUE (TREE_VALUE (version_attr));
+      const char *p = TREE_STRING_POINTER (v);
+      fprintf (stream, "\t.alias %s#, \"%s{%s}\"\n", name, name, p);
+    }
+  targetm.asm_out.globalize_label (stream, name);
+  if (TREE_CODE (decl) == FUNCTION_DECL)
+    ASM_OUTPUT_TYPE_DIRECTIVE (stream, name, "function");
+}
+
 /* Helper function for ia64_compute_frame_size: find an appropriate general
    register to spill some special register to.  SPECIAL_SPILL_MASK contains
    bits in GR0 to GR31 that have already been allocated by this routine.
@@ -9189,10 +9214,7 @@ ia64_asm_output_external (FILE *file, tree decl, const char *name)
         need something for external functions.  */
       if ((TARGET_HPUX_LD || !TARGET_GNU_AS)
          && TREE_CODE (decl) == FUNCTION_DECL)
-       {
-         ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
-         (*targetm.asm_out.globalize_label) (file, name);
-       }
+         (*targetm.asm_out.globalize_decl_name) (file, decl);
       else if (need_visibility && !TARGET_GNU_AS)
        (*targetm.asm_out.globalize_label) (file, name);
     }
@@ -9778,4 +9800,27 @@ ia64_optimization_options (int level ATTRIBUTE_UNUSED,
 
 }
 
+/* HP-UX version_id attribute.
+   For object foo, if the version_id is set to 1234 put out an alias
+   of '.alias foo "foo{1234}"  We can't use "foo{1234}" in anything
+   other than an alias statement because it is an illegal symbol name.  */
+
+static tree
+ia64_handle_version_id_attribute (tree *node ATTRIBUTE_UNUSED,
+                                 tree name ATTRIBUTE_UNUSED,
+                                 tree args,
+                                 int flags ATTRIBUTE_UNUSED,
+                                 bool *no_add_attrs)
+{
+  tree arg = TREE_VALUE (args);
+
+  if (TREE_CODE (arg) != STRING_CST)
+    {
+      error("version attribute is not a string");
+      *no_add_attrs = true;
+      return NULL_TREE;
+    }
+  return NULL_TREE;
+}
+
 #include "gt-ia64.h"
index 0eec8d2bd012f67fd02e98c585110d93dc1a0b89..8bbb3169402387c25e60616cc7977db6139d2c26 100644 (file)
@@ -2366,6 +2366,19 @@ for the function even if it appears that the function is not referenced.
 This is useful, for example, when the function is referenced only in
 inline assembly.
 
+@item version_id
+@cindex @code{version_id} attribute on IA64 HP-UX
+This attribute, attached to a global variable or function, renames a
+symbol to contain a version string, thus allowing for function level
+versioning.  HP-UX system header files may use version level functioning
+for some system calls.
+
+@smallexample
+extern int foo () __attribute__((version_id ("20040821")));
+@end smallexample
+
+Calls to @var{foo} will be mapped to calls to @var{foo@{20040821@}}.
+
 @item visibility ("@var{visibility_type}")
 @cindex @code{visibility} attribute
 This attribute affects the linkage of the declaration to which it is attached.
index 33905757a50c0965c4342a2fb6c20339a0016f70..b2292c3e06a20b9526ba4f6632857442a33b507a 100644 (file)
@@ -7198,6 +7198,14 @@ The default implementation relies on a proper definition of
 @code{GLOBAL_ASM_OP}.
 @end deftypefn
 
+@deftypefn {Target Hook} void TARGET_ASM_GLOBALIZE_DECL_NAME (FILE *@var{stream}, tree @var{decl})
+This target hook is a function to output to the stdio stream
+@var{stream} some commands that will make the name associated with @var{decl}
+global; that is, available for reference from other files.
+
+The default implementation uses the TARGET_ASM_GLOBALIZE_LABEL target hook.
+@end deftypefn
+
 @defmac ASM_WEAKEN_LABEL (@var{stream}, @var{name})
 A C statement (sans semicolon) to output to the stdio stream
 @var{stream} some commands that will make the label @var{name} weak;
index ca010d92f2bf3de81d7b8420ca940563aff3cde2..8340d412c6988c175444e2cf60bf802e386c9422 100644 (file)
@@ -612,6 +612,7 @@ extern bool default_use_anchors_for_symbol_p (rtx);
 extern bool default_binds_local_p (tree);
 extern bool default_binds_local_p_1 (tree, int);
 extern void default_globalize_label (FILE *, const char *);
+extern void default_globalize_decl_name (FILE *, tree);
 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);
index 8f7abd8a2963fbd3e3e21b06f9def90088f8182f..bc535ebb6cd9f5292d7068c8478cd61b29f901dc 100644 (file)
@@ -64,6 +64,10 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #define TARGET_ASM_GLOBALIZE_LABEL default_globalize_label
 #endif
 
+#ifndef TARGET_ASM_GLOBALIZE_DECL_NAME
+#define TARGET_ASM_GLOBALIZE_DECL_NAME default_globalize_decl_name
+#endif
+
 #ifndef TARGET_ASM_EMIT_UNWIND_LABEL
 #define TARGET_ASM_EMIT_UNWIND_LABEL default_emit_unwind_label
 #endif
@@ -253,6 +257,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
                        TARGET_ASM_UNALIGNED_INT_OP,            \
                        TARGET_ASM_INTEGER,                     \
                        TARGET_ASM_GLOBALIZE_LABEL,             \
+                       TARGET_ASM_GLOBALIZE_DECL_NAME,         \
                         TARGET_ASM_EMIT_UNWIND_LABEL,           \
                        TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL,     \
                        TARGET_UNWIND_EMIT,                     \
index e86ba2167e2e37bb965a8ef91303217fbda143ee..d43ea565579671acb971538a331dd1bfc1214d3f 100644 (file)
@@ -113,6 +113,9 @@ struct gcc_target
     /* Output code that will globalize a label.  */
     void (* globalize_label) (FILE *, const char *);
 
+    /* Output code that will globalise a declaration.  */
+    void (* globalize_decl_name) (FILE *, tree);
+
     /* Output code that will emit a label for unwind info, if this
        target requires such labels.  Second argument is the decl the
        unwind info is associated with, third is a boolean: true if
index 0cb8f86eadc6afa8f7d660f5d936be766a77300b..48055cf65fd645fea77efe76e126cb94d4b386be 100644 (file)
@@ -489,7 +489,8 @@ asm_output_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
                unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
                unsigned HOST_WIDE_INT rounded)
 {
-  targetm.asm_out.globalize_label (file, name);
+  gcc_assert (strcmp (XSTR (XEXP (DECL_RTL (decl), 0), 0), name) == 0);
+  targetm.asm_out.globalize_decl_name (file, decl);
   switch_to_section (bss_section);
 #ifdef ASM_DECLARE_OBJECT_NAME
   last_assemble_variable_decl = decl;
@@ -4739,11 +4740,11 @@ weak_finish (void)
 static void
 globalize_decl (tree decl)
 {
-  const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
 
 #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
   if (DECL_WEAK (decl))
     {
+      const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
       tree *p, t;
 
 #ifdef ASM_WEAKEN_DECL
@@ -4777,7 +4778,7 @@ globalize_decl (tree decl)
     }
 #endif
 
-  targetm.asm_out.globalize_label (asm_out_file, name);
+  targetm.asm_out.globalize_decl_name (asm_out_file, decl);
 }
 
 /* We have to be able to tell cgraph about the needed-ness of the target
@@ -5913,6 +5914,14 @@ default_globalize_label (FILE * stream, const char *name)
 }
 #endif /* GLOBAL_ASM_OP */
 
+/* Default function to output code that will globalize a declaration.  */
+void
+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);
+}
+
 /* Default function to output a label for unwind information.  The
    default is to do nothing.  A target that needs nonlocal labels for
    unwind information must provide its own function to do this.  */