Commit 812b587e by Steve Ellcey

target.h (globalize_decl_name): New.

	* 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
parent fe32582a
...@@ -242,6 +242,7 @@ static void bundling (FILE *, int, rtx, rtx); ...@@ -242,6 +242,7 @@ static void bundling (FILE *, int, rtx, rtx);
static void ia64_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, static void ia64_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
HOST_WIDE_INT, tree); HOST_WIDE_INT, tree);
static void ia64_file_start (void); static void ia64_file_start (void);
static void ia64_globalize_decl_name (FILE *, tree);
static section *ia64_select_rtx_section (enum machine_mode, rtx, static section *ia64_select_rtx_section (enum machine_mode, rtx,
unsigned HOST_WIDE_INT); unsigned HOST_WIDE_INT);
...@@ -265,6 +266,7 @@ static void ia64_vms_init_libfuncs (void) ...@@ -265,6 +266,7 @@ static void ia64_vms_init_libfuncs (void)
ATTRIBUTE_UNUSED; ATTRIBUTE_UNUSED;
static tree ia64_handle_model_attribute (tree *, tree, tree, int, bool *); 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 void ia64_encode_section_info (tree, rtx, int);
static rtx ia64_struct_value_rtx (tree, int); static rtx ia64_struct_value_rtx (tree, int);
static tree ia64_gimplify_va_arg (tree, tree, tree *, tree *); static tree ia64_gimplify_va_arg (tree, tree, tree *, tree *);
...@@ -282,6 +284,8 @@ static const struct attribute_spec ia64_attribute_table[] = ...@@ -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 } */ /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
{ "syscall_linkage", 0, 0, false, true, true, NULL }, { "syscall_linkage", 0, 0, false, true, true, NULL },
{ "model", 1, 1, true, false, false, ia64_handle_model_attribute }, { "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 } { NULL, 0, 0, false, false, false, NULL }
}; };
...@@ -391,6 +395,9 @@ static const struct attribute_spec ia64_attribute_table[] = ...@@ -391,6 +395,9 @@ static const struct attribute_spec ia64_attribute_table[] =
#undef TARGET_ASM_FILE_START #undef TARGET_ASM_FILE_START
#define TARGET_ASM_FILE_START ia64_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 #undef TARGET_RTX_COSTS
#define TARGET_RTX_COSTS ia64_rtx_costs #define TARGET_RTX_COSTS ia64_rtx_costs
#undef TARGET_ADDRESS_COST #undef TARGET_ADDRESS_COST
...@@ -2226,6 +2233,24 @@ emit_safe_across_calls (void) ...@@ -2226,6 +2233,24 @@ emit_safe_across_calls (void)
fputc ('\n', asm_out_file); 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 /* Helper function for ia64_compute_frame_size: find an appropriate general
register to spill some special register to. SPECIAL_SPILL_MASK contains register to spill some special register to. SPECIAL_SPILL_MASK contains
bits in GR0 to GR31 that have already been allocated by this routine. 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) ...@@ -9189,10 +9214,7 @@ ia64_asm_output_external (FILE *file, tree decl, const char *name)
need something for external functions. */ need something for external functions. */
if ((TARGET_HPUX_LD || !TARGET_GNU_AS) if ((TARGET_HPUX_LD || !TARGET_GNU_AS)
&& TREE_CODE (decl) == FUNCTION_DECL) && TREE_CODE (decl) == FUNCTION_DECL)
{ (*targetm.asm_out.globalize_decl_name) (file, decl);
ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
(*targetm.asm_out.globalize_label) (file, name);
}
else if (need_visibility && !TARGET_GNU_AS) else if (need_visibility && !TARGET_GNU_AS)
(*targetm.asm_out.globalize_label) (file, name); (*targetm.asm_out.globalize_label) (file, name);
} }
...@@ -9778,4 +9800,27 @@ ia64_optimization_options (int level ATTRIBUTE_UNUSED, ...@@ -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" #include "gt-ia64.h"
...@@ -2366,6 +2366,19 @@ for the function even if it appears that the function is not referenced. ...@@ -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 This is useful, for example, when the function is referenced only in
inline assembly. 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}") @item visibility ("@var{visibility_type}")
@cindex @code{visibility} attribute @cindex @code{visibility} attribute
This attribute affects the linkage of the declaration to which it is attached. This attribute affects the linkage of the declaration to which it is attached.
......
...@@ -7198,6 +7198,14 @@ The default implementation relies on a proper definition of ...@@ -7198,6 +7198,14 @@ The default implementation relies on a proper definition of
@code{GLOBAL_ASM_OP}. @code{GLOBAL_ASM_OP}.
@end deftypefn @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}) @defmac ASM_WEAKEN_LABEL (@var{stream}, @var{name})
A C statement (sans semicolon) to output to the stdio stream A C statement (sans semicolon) to output to the stdio stream
@var{stream} some commands that will make the label @var{name} weak; @var{stream} some commands that will make the label @var{name} weak;
......
...@@ -612,6 +612,7 @@ extern bool default_use_anchors_for_symbol_p (rtx); ...@@ -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 (tree);
extern bool default_binds_local_p_1 (tree, int); extern bool default_binds_local_p_1 (tree, int);
extern void default_globalize_label (FILE *, const char *); 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_unwind_label (FILE *, tree, int, int);
extern void default_emit_except_table_label (FILE *); extern void default_emit_except_table_label (FILE *);
extern void default_internal_label (FILE *, const char *, unsigned long); extern void default_internal_label (FILE *, const char *, unsigned long);
......
...@@ -64,6 +64,10 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -64,6 +64,10 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define TARGET_ASM_GLOBALIZE_LABEL default_globalize_label #define TARGET_ASM_GLOBALIZE_LABEL default_globalize_label
#endif #endif
#ifndef TARGET_ASM_GLOBALIZE_DECL_NAME
#define TARGET_ASM_GLOBALIZE_DECL_NAME default_globalize_decl_name
#endif
#ifndef TARGET_ASM_EMIT_UNWIND_LABEL #ifndef TARGET_ASM_EMIT_UNWIND_LABEL
#define TARGET_ASM_EMIT_UNWIND_LABEL default_emit_unwind_label #define TARGET_ASM_EMIT_UNWIND_LABEL default_emit_unwind_label
#endif #endif
...@@ -253,6 +257,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -253,6 +257,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
TARGET_ASM_UNALIGNED_INT_OP, \ TARGET_ASM_UNALIGNED_INT_OP, \
TARGET_ASM_INTEGER, \ TARGET_ASM_INTEGER, \
TARGET_ASM_GLOBALIZE_LABEL, \ TARGET_ASM_GLOBALIZE_LABEL, \
TARGET_ASM_GLOBALIZE_DECL_NAME, \
TARGET_ASM_EMIT_UNWIND_LABEL, \ TARGET_ASM_EMIT_UNWIND_LABEL, \
TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL, \ TARGET_ASM_EMIT_EXCEPT_TABLE_LABEL, \
TARGET_UNWIND_EMIT, \ TARGET_UNWIND_EMIT, \
......
...@@ -113,6 +113,9 @@ struct gcc_target ...@@ -113,6 +113,9 @@ struct gcc_target
/* Output code that will globalize a label. */ /* Output code that will globalize a label. */
void (* globalize_label) (FILE *, const char *); 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 /* Output code that will emit a label for unwind info, if this
target requires such labels. Second argument is the decl the target requires such labels. Second argument is the decl the
unwind info is associated with, third is a boolean: true if unwind info is associated with, third is a boolean: true if
......
...@@ -489,7 +489,8 @@ asm_output_bss (FILE *file, tree decl ATTRIBUTE_UNUSED, ...@@ -489,7 +489,8 @@ asm_output_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT rounded) 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); switch_to_section (bss_section);
#ifdef ASM_DECLARE_OBJECT_NAME #ifdef ASM_DECLARE_OBJECT_NAME
last_assemble_variable_decl = decl; last_assemble_variable_decl = decl;
...@@ -4739,11 +4740,11 @@ weak_finish (void) ...@@ -4739,11 +4740,11 @@ weak_finish (void)
static void static void
globalize_decl (tree decl) globalize_decl (tree decl)
{ {
const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL) #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
if (DECL_WEAK (decl)) if (DECL_WEAK (decl))
{ {
const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
tree *p, t; tree *p, t;
#ifdef ASM_WEAKEN_DECL #ifdef ASM_WEAKEN_DECL
...@@ -4777,7 +4778,7 @@ globalize_decl (tree decl) ...@@ -4777,7 +4778,7 @@ globalize_decl (tree decl)
} }
#endif #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 /* 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) ...@@ -5913,6 +5914,14 @@ default_globalize_label (FILE * stream, const char *name)
} }
#endif /* GLOBAL_ASM_OP */ #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 function to output a label for unwind information. The
default is to do nothing. A target that needs nonlocal labels for default is to do nothing. A target that needs nonlocal labels for
unwind information must provide its own function to do this. */ unwind information must provide its own function to do this. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment