rs6000.c (rs6000_select_section): Rewrite to not put stuff in .sdata unnecessarily.
* config/rs6000/rs6000.c (rs6000_select_section): Rewrite to not put stuff in .sdata unnecessarily. (rs6000_unique_section): New function. * config/rs6000/rs6000-protos.h: Add rs6000_unique_section. * config/rs6000/sysv4.h (UNIQUE_SECTION): Define. From-SVN: r35667
This commit is contained in:
parent
05273f087b
commit
630193739f
4 changed files with 114 additions and 36 deletions
|
@ -1,5 +1,11 @@
|
||||||
2000-08-13 Geoff Keating <geoffk@cygnus.com>
|
2000-08-13 Geoff Keating <geoffk@cygnus.com>
|
||||||
|
|
||||||
|
* config/rs6000/rs6000.c (rs6000_select_section): Rewrite to
|
||||||
|
not put stuff in .sdata unnecessarily.
|
||||||
|
(rs6000_unique_section): New function.
|
||||||
|
* config/rs6000/rs6000-protos.h: Add rs6000_unique_section.
|
||||||
|
* config/rs6000/sysv4.h (UNIQUE_SECTION): Define.
|
||||||
|
|
||||||
* c-typeck.c (build_array_ref): Don't complain about non-lvalue
|
* c-typeck.c (build_array_ref): Don't complain about non-lvalue
|
||||||
arrays in C99. Don't try to look at DECL_REGISTER of a
|
arrays in C99. Don't try to look at DECL_REGISTER of a
|
||||||
COMPONENT_REF. Don't complain twice about the same error.
|
COMPONENT_REF. Don't complain twice about the same error.
|
||||||
|
|
|
@ -126,6 +126,7 @@ extern int rs6000_valid_type_attribute_p PARAMS ((tree, tree, tree, tree));
|
||||||
extern void rs6000_set_default_type_attributes PARAMS ((tree));
|
extern void rs6000_set_default_type_attributes PARAMS ((tree));
|
||||||
extern void rs6000_encode_section_info PARAMS ((tree));
|
extern void rs6000_encode_section_info PARAMS ((tree));
|
||||||
extern void rs6000_select_section PARAMS ((tree, int));
|
extern void rs6000_select_section PARAMS ((tree, int));
|
||||||
|
extern void rs6000_unique_section PARAMS ((tree, int));
|
||||||
#ifdef ARGS_SIZE_RTX
|
#ifdef ARGS_SIZE_RTX
|
||||||
/* expr.h defines ARGS_SIZE_RTX and `enum direction' */
|
/* expr.h defines ARGS_SIZE_RTX and `enum direction' */
|
||||||
extern enum direction function_arg_padding PARAMS ((enum machine_mode, tree));
|
extern enum direction function_arg_padding PARAMS ((enum machine_mode, tree));
|
||||||
|
|
|
@ -7355,45 +7355,104 @@ rs6000_select_section (decl, reloc)
|
||||||
int reloc;
|
int reloc;
|
||||||
{
|
{
|
||||||
int size = int_size_in_bytes (TREE_TYPE (decl));
|
int size = int_size_in_bytes (TREE_TYPE (decl));
|
||||||
|
int needs_sdata;
|
||||||
|
int readonly;
|
||||||
|
static void (* const sec_funcs[4]) PARAMS ((void)) = {
|
||||||
|
&const_section,
|
||||||
|
&sdata2_section,
|
||||||
|
&data_section,
|
||||||
|
&sdata_section
|
||||||
|
};
|
||||||
|
|
||||||
|
needs_sdata = (size > 0
|
||||||
|
&& size <= g_switch_value
|
||||||
|
&& rs6000_sdata != SDATA_NONE
|
||||||
|
&& (rs6000_sdata != SDATA_DATA || TREE_PUBLIC (decl)));
|
||||||
|
|
||||||
if (TREE_CODE (decl) == STRING_CST)
|
if (TREE_CODE (decl) == STRING_CST)
|
||||||
{
|
readonly = ! flag_writable_strings;
|
||||||
if (! flag_writable_strings)
|
|
||||||
const_section ();
|
|
||||||
else
|
|
||||||
data_section ();
|
|
||||||
}
|
|
||||||
else if (TREE_CODE (decl) == VAR_DECL)
|
else if (TREE_CODE (decl) == VAR_DECL)
|
||||||
|
readonly = (! (flag_pic && reloc)
|
||||||
|
&& TREE_READONLY (decl)
|
||||||
|
&& ! TREE_SIDE_EFFECTS (decl)
|
||||||
|
&& DECL_INITIAL (decl)
|
||||||
|
&& DECL_INITIAL (decl) != error_mark_node
|
||||||
|
&& TREE_CONSTANT (DECL_INITIAL (decl)));
|
||||||
|
else
|
||||||
|
readonly = 1;
|
||||||
|
if (needs_sdata && rs6000_sdata != SDATA_EABI)
|
||||||
|
readonly = 0;
|
||||||
|
|
||||||
|
(*sec_funcs[(readonly ? 0 : 2) + (needs_sdata ? 1 : 0)])();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A C statement to build up a unique section name, expressed as a
|
||||||
|
STRING_CST node, and assign it to DECL_SECTION_NAME (decl).
|
||||||
|
RELOC indicates whether the initial value of EXP requires
|
||||||
|
link-time relocations. If you do not define this macro, GCC will use
|
||||||
|
the symbol name prefixed by `.' as the section name. Note - this
|
||||||
|
macro can now be called for unitialised data items as well as
|
||||||
|
initialised data and functions. */
|
||||||
|
|
||||||
|
void
|
||||||
|
rs6000_unique_section (decl, reloc)
|
||||||
|
tree decl;
|
||||||
|
int reloc;
|
||||||
|
{
|
||||||
|
int size = int_size_in_bytes (TREE_TYPE (decl));
|
||||||
|
int needs_sdata;
|
||||||
|
int readonly;
|
||||||
|
int len;
|
||||||
|
int sec;
|
||||||
|
const char *name;
|
||||||
|
char *string;
|
||||||
|
const char *prefix;
|
||||||
|
|
||||||
|
static const char *const prefixes[7][2] =
|
||||||
{
|
{
|
||||||
if ((flag_pic && reloc)
|
{ ".text.", ".gnu.linkonce.t." },
|
||||||
|| ! TREE_READONLY (decl)
|
{ ".rodata.", ".gnu.linkonce.r." },
|
||||||
|| TREE_SIDE_EFFECTS (decl)
|
{ ".sdata2.", ".gnu.linkonce.s2." },
|
||||||
|| ! DECL_INITIAL (decl)
|
{ ".data.", ".gnu.linkonce.d." },
|
||||||
|| (DECL_INITIAL (decl) != error_mark_node
|
{ ".sdata.", ".gnu.linkonce.s." },
|
||||||
&& ! TREE_CONSTANT (DECL_INITIAL (decl))))
|
{ ".bss.", ".gnu.linkonce.b." },
|
||||||
{
|
{ ".sbss.", ".gnu.linkonce.sb." }
|
||||||
if (rs6000_sdata != SDATA_NONE && (size > 0)
|
};
|
||||||
&& (size <= g_switch_value))
|
|
||||||
sdata_section ();
|
needs_sdata = (TREE_CODE (decl) != FUNCTION_DECL
|
||||||
|
&& size > 0
|
||||||
|
&& size <= g_switch_value
|
||||||
|
&& rs6000_sdata != SDATA_NONE
|
||||||
|
&& (rs6000_sdata != SDATA_DATA || TREE_PUBLIC (decl)));
|
||||||
|
|
||||||
|
if (TREE_CODE (decl) == STRING_CST)
|
||||||
|
readonly = ! flag_writable_strings;
|
||||||
|
else if (TREE_CODE (decl) == VAR_DECL)
|
||||||
|
readonly = (! (flag_pic && reloc)
|
||||||
|
&& TREE_READONLY (decl)
|
||||||
|
&& ! TREE_SIDE_EFFECTS (decl)
|
||||||
|
&& DECL_INITIAL (decl)
|
||||||
|
&& DECL_INITIAL (decl) != error_mark_node
|
||||||
|
&& TREE_CONSTANT (DECL_INITIAL (decl)));
|
||||||
else
|
else
|
||||||
data_section ();
|
readonly = 1;
|
||||||
}
|
if (needs_sdata && rs6000_sdata != SDATA_EABI)
|
||||||
else
|
readonly = 0;
|
||||||
{
|
|
||||||
if (rs6000_sdata != SDATA_NONE && (size > 0)
|
sec = ((TREE_CODE (decl) == FUNCTION_DECL ? 0 : 1)
|
||||||
&& (size <= g_switch_value))
|
+ (readonly ? 0 : 2)
|
||||||
{
|
+ (needs_sdata ? 1 : 0)
|
||||||
if (rs6000_sdata == SDATA_EABI)
|
+ (DECL_INITIAL (decl) == 0
|
||||||
sdata2_section ();
|
|| DECL_INITIAL (decl) == error_mark_node) ? 4 : 0);
|
||||||
else
|
|
||||||
sdata_section (); /* System V doesn't have .sdata2/.sbss2 */
|
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
|
||||||
}
|
prefix = prefixes[sec][DECL_ONE_ONLY (decl)];
|
||||||
else
|
len = strlen (name) + strlen (prefix);
|
||||||
const_section ();
|
string = alloca (len + 1);
|
||||||
}
|
|
||||||
}
|
sprintf (string, "%s%s", prefix, name);
|
||||||
else
|
|
||||||
const_section ();
|
DECL_SECTION_NAME (decl) = build_string (len, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -549,7 +549,19 @@ fini_section () \
|
||||||
|
|
||||||
/* Override elfos.h definition. */
|
/* Override elfos.h definition. */
|
||||||
#undef SELECT_SECTION
|
#undef SELECT_SECTION
|
||||||
#define SELECT_SECTION(DECL,RELOC) rs6000_select_section (DECL, RELOC)
|
#define SELECT_SECTION(DECL, RELOC) rs6000_select_section (DECL, RELOC)
|
||||||
|
|
||||||
|
/* A C statement to build up a unique section name, expressed as a
|
||||||
|
STRING_CST node, and assign it to DECL_SECTION_NAME (decl).
|
||||||
|
RELOC indicates whether the initial value of EXP requires
|
||||||
|
link-time relocations. If you do not define this macro, GCC will use
|
||||||
|
the symbol name prefixed by `.' as the section name. Note - this
|
||||||
|
macro can now be called for unitialised data items as well as
|
||||||
|
initialised data and functions. */
|
||||||
|
|
||||||
|
/* Override elfos.h definition. */
|
||||||
|
#undef UNIQUE_SECTION
|
||||||
|
#define UNIQUE_SECTION(DECL, RELOC) rs6000_unique_section (DECL, RELOC)
|
||||||
|
|
||||||
/* Return non-zero if this entry is to be written into the constant pool
|
/* Return non-zero if this entry is to be written into the constant pool
|
||||||
in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
|
in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
|
||||||
|
|
Loading…
Add table
Reference in a new issue