flags.h: Add flag_data_sections.

* flags.h:  Add flag_data_sections.
        * toplev.c:  Add option -fdata-sections.  Add flag_data_sections.
        (compile_file):  Error if flag_data_sections not supported.
        * varasm.c (assemble_variable):  Handle flag_data_sections.
        * config/svr4.h:  Modify prefixes for UNIQUE_SECTION_NAME.
        * config/mips/elf.h:  Likewise.
        * config/mips/elf64.h:  Likewise.
        * invoke.texi:  Describe -fdata-sections.

From-SVN: r22619
This commit is contained in:
Catherine Moore 1998-09-28 06:24:06 +00:00 committed by Catherine Moore
parent 52464fd6e7
commit 7d0756fbf1
8 changed files with 172 additions and 12 deletions

View file

@ -1,3 +1,14 @@
Mon Sep 28 07:54:03 1998 Catherine Moore <clm@cygnus.com>
* flags.h: Add flag_data_sections.
* toplev.c: Add option -fdata-sections. Add flag_data_sections.
(compile_file): Error if flag_data_sections not supported.
* varasm.c (assemble_variable): Handle flag_data_sections.
* config/svr4.h: Modify prefixes for UNIQUE_SECTION_NAME.
* config/mips/elf.h: Likewise.
* config/mips/elf64.h: Likewise.
* invoke.texi: Describe -fdata-sections.
Mon Sep 28 04:15:44 1998 Craig Burley <burley@melange.gnu.org>
* invoke.texi (-ffloat-store): Clarify that this option

View file

@ -169,3 +169,64 @@ do { \
fputc ('\n', FILE); \
} while (0)
#define UNIQUE_SECTION(DECL,RELOC) \
do { \
int len, size, sec; \
char *name, *string, *prefix; \
static char *prefixes[4][2] = { \
{ ".text.", ".gnu.linkonce.t." }, \
{ ".rodata.", ".gnu.linkonce.r." }, \
{ ".data.", ".gnu.linkonce.d." }, \
{ ".sdata.", ".gnu.linkonce.s." } \
}; \
\
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
size = int_size_in_bytes (TREE_TYPE (decl)); \
\
/* Determine the base section we are interested in: \
0=text, 1=rodata, 2=data, 3=sdata. */ \
if (TREE_CODE (DECL) == FUNCTION_DECL) \
sec = 0; \
else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
&& TREE_CODE (decl) == STRING_CST \
&& !flag_writable_strings) \
{ \
/* For embedded position independent code, put constant strings \
in the text section, because the data section is limited to \
64K in size. For mips16 code, put strings in the text \
section so that a PC relative load instruction can be used to \
get their address. */ \
sec = 0; \
} \
else if (TARGET_EMBEDDED_DATA) \
{ \
/* For embedded applications, always put an object in read-only data \
if possible, in order to reduce RAM usage. */ \
\
if (DECL_READONLY_SECTION (DECL, RELOC)) \
sec = 1; \
else if (size > 0 && size <= mips_section_threshold) \
sec = 3; \
else \
sec = 2; \
} \
else \
{ \
/* For hosted applications, always put an object in small data if \
possible, as this gives the best performance. */ \
\
if (size > 0 && size <= mips_section_threshold) \
sec = 3; \
else if (DECL_READONLY_SECTION (DECL, RELOC)) \
sec = 1; \
else \
sec = 2; \
} \
\
prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
len = strlen (name) + strlen (prefix); \
string = alloca (len + 1); \
sprintf (string, "%s%s", prefix, name); \
\
DECL_SECTION_NAME (DECL) = build_string (len, string); \
} while (0)

View file

@ -195,3 +195,64 @@ do { \
fputc ('\n', FILE); \
} while (0)
#define UNIQUE_SECTION(DECL,RELOC) \
do { \
int len, size, sec; \
char *name, *string, *prefix; \
static char *prefixes[4][2] = { \
{ ".text.", ".gnu.linkonce.t." }, \
{ ".rodata.", ".gnu.linkonce.r." }, \
{ ".data.", ".gnu.linkonce.d." }, \
{ ".sdata.", ".gnu.linkonce.s." } \
}; \
\
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
size = int_size_in_bytes (TREE_TYPE (decl)); \
\
/* Determine the base section we are interested in: \
0=text, 1=rodata, 2=data, 3=sdata. */ \
if (TREE_CODE (DECL) == FUNCTION_DECL) \
sec = 0; \
else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
&& TREE_CODE (decl) == STRING_CST \
&& !flag_writable_strings) \
{ \
/* For embedded position independent code, put constant strings \
in the text section, because the data section is limited to \
64K in size. For mips16 code, put strings in the text \
section so that a PC relative load instruction can be used to \
get their address. */ \
sec = 0; \
} \
else if (TARGET_EMBEDDED_DATA) \
{ \
/* For embedded applications, always put an object in read-only data \
if possible, in order to reduce RAM usage. */ \
\
if (DECL_READONLY_SECTION (DECL, RELOC)) \
sec = 1; \
else if (size > 0 && size <= mips_section_threshold) \
sec = 3; \
else \
sec = 2; \
} \
else \
{ \
/* For hosted applications, always put an object in small data if \
possible, as this gives the best performance. */ \
\
if (size > 0 && size <= mips_section_threshold) \
sec = 3; \
else if (DECL_READONLY_SECTION (DECL, RELOC)) \
sec = 1; \
else \
sec = 2; \
} \
\
prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
len = strlen (name) + strlen (prefix); \
string = alloca (len + 1); \
sprintf (string, "%s%s", prefix, name); \
\
DECL_SECTION_NAME (DECL) = build_string (len, string); \
} while (0)

View file

@ -655,7 +655,15 @@ do { \
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
\
if (! DECL_ONE_ONLY (DECL)) \
prefix = "."; \
{ \
prefix = "."; \
if (TREE_CODE (DECL) == FUNCTION_DECL) \
prefix = ".text."; \
else if (DECL_READONLY_SECTION (DECL, RELOC)) \
prefix = ".rodata."; \
else \
prefix = ".data."; \
} \
else if (TREE_CODE (DECL) == FUNCTION_DECL) \
prefix = ".gnu.linkonce.t."; \
else if (DECL_READONLY_SECTION (DECL, RELOC)) \
@ -669,7 +677,6 @@ do { \
\
DECL_SECTION_NAME (DECL) = build_string (len, string); \
} while (0)
/* A C statement (sans semicolon) to output an element in the table of
global constructors. */
#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \

View file

@ -398,6 +398,10 @@ extern int flag_inhibit_size_directive;
extern int flag_function_sections;
/* ... and similar for data. */
extern int flag_data_sections;
/* -fverbose-asm causes extra commentary information to be produced in
the generated assembly code (to make it more readable). This option
is generally only of use to those who actually need to read the

View file

@ -151,9 +151,9 @@ in the following sections.
-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks
-fdelayed-branch -fexpensive-optimizations
-ffast-math -ffloat-store -fforce-addr -fforce-mem
-ffunction-sections -fgcse -finline-functions
-fkeep-inline-functions -fno-default-inline
-fno-defer-pop -fno-function-cse
-fdata-sections -ffunction-sections -fgcse
-finline-functions -fkeep-inline-functions
-fno-default-inline -fno-defer-pop -fno-function-cse
-fno-inline -fno-peephole -fomit-frame-pointer -fregmove
-frerun-cse-after-loop -frerun-loop-opt -fschedule-insns
-fschedule-insns2 -fstrength-reduce -fthread-jumps
@ -2340,18 +2340,20 @@ especially useful on machines with a relatively small number of
registers and where memory load instructions take more than one cycle.
@item -ffunction-sections
Place each function into its own section in the output file if the
target supports arbitrary sections. The function's name determines
the section's name in the output file.
@item -fdata-sections
Place each function or data item into its own section in the output
file if the target supports arbitrary sections. The name of the
function or the name of the data item determines the section's name
in the output file.
Use this option on systems where the linker can perform optimizations
Use these options on systems where the linker can perform optimizations
to improve locality of reference in the instruction space. HPPA
processors running HP-UX and Sparc processors running Solaris 2 have
linkers with such optimizations. Other systems using the ELF object format
as well as AIX may have these optimizations in the future.
Only use this option when there are significant benefits from doing
so. When you specify this option, the assembler and linker will
Only use these options when there are significant benefits from doing
so. When you specify these options, the assembler and linker will
create larger object and executable files and will also be slower.
You will not be able to use @code{gprof} on all systems if you
specify this option and you may have problems with debugging if

View file

@ -528,6 +528,10 @@ int flag_no_peephole = 0;
/* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
operations in the interest of optimization. For example it allows
/* ... and similar for data. */
int flag_data_sections = 0;
GCC to assume arguments to sqrt are nonnegative numbers, allowing
faster code for sqrt to be generated. */
@ -932,6 +936,8 @@ documented_lang_options[] =
enabled by default. */
{ "-ansi", "Compile just for ANSI C" },
{"data-sections", &flag_data_sections, 1,
"place data items into their own section" },
{ "-fallow-single-precision",
"Do not promote floats to double if using -traditional" },
@ -2809,6 +2815,12 @@ compile_file (name)
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
vec[len - i - 1] = decl;
if (flag_data_sections)
{
warning ("-fdata-sections not supported for this target.");
flag_data_sections = 0;
}
for (i = 0; i < len; i++)
{

View file

@ -1464,7 +1464,9 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
reloc = output_addressed_constants (DECL_INITIAL (decl));
#ifdef ASM_OUTPUT_SECTION_NAME
if (UNIQUE_SECTION_P (decl))
if ((flag_data_sections != 0
&& DECL_SECTION_NAME (decl) == NULL_TREE)
|| UNIQUE_SECTION_P (decl))
UNIQUE_SECTION (decl, reloc);
#endif