Commit 25fdb4dc by Richard Henderson Committed by Richard Henderson

c-common.c (handle_visibility_attribute): Accept "default".

	* c-common.c (handle_visibility_attribute): Accept "default".
	* tree.h (enum symbol_visibility): New.
	(decl_visibility): Declare.
	* target.h (gcc_target.visibility): Take visibility arg as integer.
	* varasm.c (default_assemble_visibility): Likewise.
	(decl_visibility): New.
	(maybe_assemble_visibility): Use it.
	* output.h (default_assemble_visibility): Update prototype.
	* config/rs6000/rs6000.c (rs6000_assemble_visibility): Take
	visibility arg as integer.

From-SVN: r59559
parent 02077425
2002-11-26 Richard Henderson <rth@redhat.com>
* c-common.c (handle_visibility_attribute): Accept "default".
* tree.h (enum symbol_visibility): New.
(decl_visibility): Declare.
* target.h (gcc_target.visibility): Take visibility arg as integer.
* varasm.c (default_assemble_visibility): Likewise.
(decl_visibility): New.
(maybe_assemble_visibility): Use it.
* output.h (default_assemble_visibility): Update prototype.
* config/rs6000/rs6000.c (rs6000_assemble_visibility): Take
visibility arg as integer.
2002-11-26 Kazu Hirata <kazu@cs.umass.edu> 2002-11-26 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c: Adjust spacing. * config/h8300/h8300.c: Adjust spacing.
......
...@@ -5891,9 +5891,10 @@ handle_visibility_attribute (node, name, args, flags, no_add_attrs) ...@@ -5891,9 +5891,10 @@ handle_visibility_attribute (node, name, args, flags, no_add_attrs)
} }
if (strcmp (TREE_STRING_POINTER (id), "hidden") if (strcmp (TREE_STRING_POINTER (id), "hidden")
&& strcmp (TREE_STRING_POINTER (id), "protected") && strcmp (TREE_STRING_POINTER (id), "protected")
&& strcmp (TREE_STRING_POINTER (id), "internal")) && strcmp (TREE_STRING_POINTER (id), "internal")
&& strcmp (TREE_STRING_POINTER (id), "default"))
{ {
error ("visibility arg must be one of \"hidden\", \"protected\" or \"internal\""); error ("visibility arg must be one of \"default\", \"hidden\", \"protected\" or \"internal\"");
*no_add_attrs = true; *no_add_attrs = true;
return NULL_TREE; return NULL_TREE;
} }
......
...@@ -186,7 +186,7 @@ static int constant_pool_expr_1 PARAMS ((rtx, int *, int *)); ...@@ -186,7 +186,7 @@ static int constant_pool_expr_1 PARAMS ((rtx, int *, int *));
static struct machine_function * rs6000_init_machine_status PARAMS ((void)); static struct machine_function * rs6000_init_machine_status PARAMS ((void));
static bool rs6000_assemble_integer PARAMS ((rtx, unsigned int, int)); static bool rs6000_assemble_integer PARAMS ((rtx, unsigned int, int));
#ifdef HAVE_GAS_HIDDEN #ifdef HAVE_GAS_HIDDEN
static void rs6000_assemble_visibility PARAMS ((tree, const char *)); static void rs6000_assemble_visibility PARAMS ((tree, int));
#endif #endif
static int rs6000_ra_ever_killed PARAMS ((void)); static int rs6000_ra_ever_killed PARAMS ((void));
static tree rs6000_handle_longcall_attribute PARAMS ((tree *, tree, tree, int, bool *)); static tree rs6000_handle_longcall_attribute PARAMS ((tree *, tree, tree, int, bool *));
...@@ -8157,23 +8157,29 @@ rs6000_assemble_integer (x, size, aligned_p) ...@@ -8157,23 +8157,29 @@ rs6000_assemble_integer (x, size, aligned_p)
VISIBILITY_TYPE. */ VISIBILITY_TYPE. */
static void static void
rs6000_assemble_visibility (decl, visibility_type) rs6000_assemble_visibility (decl, vis)
tree decl; tree decl;
const char *visibility_type; int vis;
{ {
default_assemble_visibility (decl, visibility_type);
/* Functions need to have their entry point symbol visibility set as /* Functions need to have their entry point symbol visibility set as
well as their descriptor symbol visibility. */ well as their descriptor symbol visibility. */
if (DEFAULT_ABI == ABI_AIX && TREE_CODE (decl) == FUNCTION_DECL) if (DEFAULT_ABI == ABI_AIX && TREE_CODE (decl) == FUNCTION_DECL)
{ {
const char *name; static const char * const visibility_types[] = {
NULL, "internal", "hidden", "protected"
};
const char *name, *type;
name = ((* targetm.strip_name_encoding) name = ((* targetm.strip_name_encoding)
(IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)))); (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
type = visibility_types[vis];
fprintf (asm_out_file, "\t.%s\t.%s\n", visibility_type, name); fprintf (asm_out_file, "\t.%s\t%s\n", type, name);
fprintf (asm_out_file, "\t.%s\t.%s\n", type, name);
} }
else
default_assemble_visibility (decl, vis);
} }
#endif #endif
......
...@@ -253,7 +253,7 @@ extern void assemble_constant_align PARAMS ((tree)); ...@@ -253,7 +253,7 @@ extern void assemble_constant_align PARAMS ((tree));
extern void assemble_alias PARAMS ((tree, tree)); extern void assemble_alias PARAMS ((tree, tree));
extern void default_assemble_visibility PARAMS ((tree, const char *)); extern void default_assemble_visibility PARAMS ((tree, int));
/* Output a string of literal assembler code /* Output a string of literal assembler code
for an `asm' keyword used between functions. */ for an `asm' keyword used between functions. */
......
...@@ -74,7 +74,7 @@ struct gcc_target ...@@ -74,7 +74,7 @@ struct gcc_target
/* Emit an assembler directive to set visibility for the symbol /* Emit an assembler directive to set visibility for the symbol
associated with the tree decl. */ associated with the tree decl. */
void (* visibility) PARAMS ((tree, const char *)); void (* visibility) PARAMS ((tree, int));
/* Output the assembler code for entry to a function. */ /* Output the assembler code for entry to a function. */
void (* function_prologue) PARAMS ((FILE *, HOST_WIDE_INT)); void (* function_prologue) PARAMS ((FILE *, HOST_WIDE_INT));
......
...@@ -2133,6 +2133,16 @@ enum tls_model { ...@@ -2133,6 +2133,16 @@ enum tls_model {
}; };
extern enum tls_model flag_tls_default; extern enum tls_model flag_tls_default;
/* Enumerate visibility settings. */
enum symbol_visibility
{
VISIBILITY_DEFAULT,
VISIBILITY_INTERNAL,
VISIBILITY_HIDDEN,
VISIBILITY_PROTECTED
};
/* A pointer-to-function member type looks like: /* A pointer-to-function member type looks like:
...@@ -3043,6 +3053,7 @@ extern void make_decl_one_only PARAMS ((tree)); ...@@ -3043,6 +3053,7 @@ extern void make_decl_one_only PARAMS ((tree));
extern int supports_one_only PARAMS ((void)); extern int supports_one_only PARAMS ((void));
extern void variable_section PARAMS ((tree, int)); extern void variable_section PARAMS ((tree, int));
enum tls_model decl_tls_model PARAMS ((tree)); enum tls_model decl_tls_model PARAMS ((tree));
enum symbol_visibility decl_visibility PARAMS ((tree));
/* In fold-const.c */ /* In fold-const.c */
extern int div_and_round_double PARAMS ((enum tree_code, int, extern int div_and_round_double PARAMS ((enum tree_code, int,
......
...@@ -4643,20 +4643,25 @@ assemble_alias (decl, target) ...@@ -4643,20 +4643,25 @@ assemble_alias (decl, target)
} }
/* Emit an assembler directive to set symbol for DECL visibility to /* Emit an assembler directive to set symbol for DECL visibility to
VISIBILITY_TYPE. */ the visibility type VIS, which must not be VISIBILITY_DEFAULT. */
void void
default_assemble_visibility (decl, visibility_type) default_assemble_visibility (decl, vis)
tree decl; tree decl;
const char *visibility_type ATTRIBUTE_UNUSED; int vis;
{ {
const char *name; static const char * const visibility_types[] = {
NULL, "internal", "hidden", "protected"
};
const char *name, *type;
name = (* targetm.strip_name_encoding) name = (* targetm.strip_name_encoding)
(IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
type = visibility_types[vis];
#ifdef HAVE_GAS_HIDDEN #ifdef HAVE_GAS_HIDDEN
fprintf (asm_out_file, "\t.%s\t%s\n", visibility_type, name); fprintf (asm_out_file, "\t.%s\t%s\n", type, name);
#else #else
warning ("visibility attribute not supported in this configuration; ignored"); warning ("visibility attribute not supported in this configuration; ignored");
#endif #endif
...@@ -4668,13 +4673,10 @@ static void ...@@ -4668,13 +4673,10 @@ static void
maybe_assemble_visibility (decl) maybe_assemble_visibility (decl)
tree decl; tree decl;
{ {
tree visibility = lookup_attribute ("visibility", DECL_ATTRIBUTES (decl)); enum symbol_visibility vis = decl_visibility (decl);
if (visibility)
{ if (vis != VISIBILITY_DEFAULT)
const char *type (* targetm.asm_out.visibility) (decl, vis);
= TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (visibility)));
(* targetm.asm_out.visibility) (decl, type);
}
} }
/* Returns 1 if the target configuration supports defining public symbols /* Returns 1 if the target configuration supports defining public symbols
...@@ -4775,6 +4777,31 @@ decl_tls_model (decl) ...@@ -4775,6 +4777,31 @@ decl_tls_model (decl)
return kind; return kind;
} }
enum symbol_visibility
decl_visibility (decl)
tree decl;
{
tree attr = lookup_attribute ("visibility", DECL_ATTRIBUTES (decl));
if (attr)
{
const char *which = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)));
if (strcmp (which, "default") == 0)
return VISIBILITY_DEFAULT;
if (strcmp (which, "internal") == 0)
return VISIBILITY_INTERNAL;
if (strcmp (which, "hidden") == 0)
return VISIBILITY_HIDDEN;
if (strcmp (which, "protected") == 0)
return VISIBILITY_PROTECTED;
abort ();
}
return VISIBILITY_DEFAULT;
}
/* Select a set of attributes for section NAME based on the properties /* Select a set of attributes for section NAME based on the properties
of DECL and whether or not RELOC indicates that DECL's initializer of DECL and whether or not RELOC indicates that DECL's initializer
might contain runtime relocations. might contain runtime relocations.
......
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