diff options
author | sje <sje@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-24 19:40:12 +0000 |
---|---|---|
committer | sje <sje@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-24 19:40:12 +0000 |
commit | 9afff52dab85b10e858e0b2b5adf9d6f47f475d6 (patch) | |
tree | 13559698c1afb4d85fe748d845c52d2e03712729 | |
parent | 32875ae1539a38675063d51563416a67017d3af3 (diff) | |
download | gcc-9afff52dab85b10e858e0b2b5adf9d6f47f475d6.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121128 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/config/ia64/ia64.c | 53 | ||||
-rw-r--r-- | gcc/doc/extend.texi | 13 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 8 | ||||
-rw-r--r-- | gcc/output.h | 1 | ||||
-rw-r--r-- | gcc/target-def.h | 5 | ||||
-rw-r--r-- | gcc/target.h | 3 | ||||
-rw-r--r-- | gcc/varasm.c | 15 |
7 files changed, 91 insertions, 7 deletions
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index dc4cb39e2c1..36c0d63e1ae 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -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" diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 0eec8d2bd01..8bbb3169402 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -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. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 33905757a50..b2292c3e06a 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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; diff --git a/gcc/output.h b/gcc/output.h index ca010d92f2b..8340d412c69 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -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); diff --git a/gcc/target-def.h b/gcc/target-def.h index 8f7abd8a296..bc535ebb6cd 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -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, \ diff --git a/gcc/target.h b/gcc/target.h index e86ba2167e2..d43ea565579 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -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 diff --git a/gcc/varasm.c b/gcc/varasm.c index 0cb8f86eadc..48055cf65fd 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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. */ |