]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
configure.in: Check whether assembler supports section merging.
authorJakub Jelinek <jakub@redhat.com>
Tue, 11 Sep 2001 16:50:05 +0000 (18:50 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 11 Sep 2001 16:50:05 +0000 (18:50 +0200)
* configure.in: Check whether assembler supports section merging.
* config.in: Rebuilt.
* configure: Rebuilt.
* varasm.c (variable_section, output_constant_pool): Pass alignment
to SELECT_SECTION and SELECT_RTX_SECTION.
(mergeable_string_section): New.
(mergeable_constant_section): New.
(default_elf_asm_named_section): Output SECTION_MERGE and
SECTION_STRINGS flags plus SECTION_ENTSIZE entity size.
* output.h (mergeable_string_section): New.
(mergeable_constant_section): New.
(SECTION_MERGE, SECTION_STRINGS, SECTION_ENTSIZE): Define.
* toplev.c (flag_merge_constants): New.
(f_options): Add -fmerge-constants and -fmerge-all-constants
options.
(toplev_main): Default to -fno-merge-constants if not optimizing.
* flags.h (flag_merge_constants): Add extern.
* invoke.texi (-fmerge-constants, -fmerge-all-constants): Document.
* tm.texi (SELECT_SECTION, SELECT_RTX_SECTION): Document added third
argument.
* config/elfos.h (ASM_SECTION_START_OP, ASM_OUTPUT_SECTION_START):
Define if assembler has working .subsection -1 support.
(SELECT_RTX_SECTION, SELECT_SECTION): Add third macro argument.
Put constant into special SHF_MERGE sections if the linker should
attempt to merge duplicates.
* config/ia64/sysv4.h (SELECT_RTX_SECTION, SELECT_SECTION): Add third
macro argument.
Put constant into special SHF_MERGE sections if the linker should
attempt to merge duplicates.
* config/alpha/elf.h: Likewise.
(ASM_SECTION_START_OP, ASM_OUTPUT_SECTION_START): Define if assembler
has working .subsection -1 support.
* config/nextstep.h: Add third argument to SELECT_RTX_SECTION and
SELECT_SECTION.
* config/svr3.h: Likewise.
* config/darwin.h: Likewise.
* config/arm/aof.h: Likewise.
* config/arm/linux-elf.h: Likewise.
* config/avr/avr.h: Likewise.
* config/c4x/c4x.h: Likewise.
* config/d30v/d30v.h: Likewise.
* config/i386/dgux.h: Likewise.
* config/i386/osfrose.h: Likewise.
* config/i386/sco5.h: Likewise.
* config/i386/svr3gas.h: Likewise.
* config/ia64/aix.h: Likewise.
* config/m32r/m32r.h: Likewise.
* config/m68k/m68k.h: Likewise.
* config/m88k/dgux.h: Likewise.
* config/m88k/m88k.h: Likewise.
* config/mcore/mcore-pe.h: Likewise.
* config/mips/mips.h: Likewise.
* config/pa/pa.h: Likewise.
* config/pa/pa-linux.h: Likewise.
* config/romp/romp.h: Likewise.
* config/rs6000/sysv4.h: Likewise.
* config/rs6000/xcoff.h: Likewise.
* config/s390/linux.h: Likewise.
* config/sparc/sparc.h: Likewise.
* config/sparc/sysv4.h: Likewise.
* config/stormy16/stormy16.h: Likewise.
* config/v850/v850.h: Likewise.
* config/vax/vms.h: Likewise.
* config/arm/arm.c (arm_elf_asm_named_section): Output SECTION_MERGE
and SECTION_STRINGS flags plus SECTION_ENTSIZE entity size.
* config/sparc/sparc.c (sparc_elf_asm_named_section): Use
default_elf_asm_named_section for SHF_MERGE sections.

* com.c (ffe_init_options): Default to -fmerge-all-constants
if optimizing.

From-SVN: r45548

47 files changed:
gcc/ChangeLog
gcc/config.in
gcc/config/alpha/elf.h
gcc/config/arm/aof.h
gcc/config/arm/arm.c
gcc/config/arm/linux-elf.h
gcc/config/avr/avr.h
gcc/config/c4x/c4x.h
gcc/config/d30v/d30v.h
gcc/config/darwin.h
gcc/config/elfos.h
gcc/config/i386/dgux.h
gcc/config/i386/osfrose.h
gcc/config/i386/sco5.h
gcc/config/i386/svr3gas.h
gcc/config/ia64/aix.h
gcc/config/ia64/sysv4.h
gcc/config/m32r/m32r.h
gcc/config/m68k/m68k.h
gcc/config/m88k/dgux.h
gcc/config/m88k/m88k.h
gcc/config/mcore/mcore-pe.h
gcc/config/mips/mips.h
gcc/config/nextstep.h
gcc/config/pa/pa-linux.h
gcc/config/pa/pa.h
gcc/config/romp/romp.h
gcc/config/rs6000/sysv4.h
gcc/config/rs6000/xcoff.h
gcc/config/s390/linux.h
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.h
gcc/config/sparc/sysv4.h
gcc/config/stormy16/stormy16.h
gcc/config/svr3.h
gcc/config/v850/v850.h
gcc/config/vax/vms.h
gcc/configure
gcc/configure.in
gcc/doc/invoke.texi
gcc/doc/tm.texi
gcc/f/ChangeLog
gcc/f/com.c
gcc/flags.h
gcc/output.h
gcc/toplev.c
gcc/varasm.c

index b0463a406311a9e855a81ddaed91bb15f39506d2..4fa939c9d96953fb0fb225785658f9480d8a8ea3 100644 (file)
@@ -1,3 +1,73 @@
+2001-09-11  Jakub Jelinek  <jakub@redhat.com>
+
+       * configure.in: Check whether assembler supports section merging.
+       * config.in: Rebuilt.
+       * configure: Rebuilt.
+       * varasm.c (variable_section, output_constant_pool): Pass alignment
+       to SELECT_SECTION and SELECT_RTX_SECTION.
+       (mergeable_string_section): New.
+       (mergeable_constant_section): New.
+       (default_elf_asm_named_section): Output SECTION_MERGE and
+       SECTION_STRINGS flags plus SECTION_ENTSIZE entity size.
+       * output.h (mergeable_string_section): New.
+       (mergeable_constant_section): New.
+       (SECTION_MERGE, SECTION_STRINGS, SECTION_ENTSIZE): Define.
+       * toplev.c (flag_merge_constants): New.
+       (f_options): Add -fmerge-constants and -fmerge-all-constants
+       options.
+       (toplev_main): Default to -fno-merge-constants if not optimizing.
+       * flags.h (flag_merge_constants): Add extern.
+       * invoke.texi (-fmerge-constants, -fmerge-all-constants): Document.
+       * tm.texi (SELECT_SECTION, SELECT_RTX_SECTION): Document added third
+       argument.
+       * config/elfos.h (ASM_SECTION_START_OP, ASM_OUTPUT_SECTION_START):
+       Define if assembler has working .subsection -1 support.
+       (SELECT_RTX_SECTION, SELECT_SECTION): Add third macro argument.
+       Put constant into special SHF_MERGE sections if the linker should
+       attempt to merge duplicates.
+       * config/ia64/sysv4.h (SELECT_RTX_SECTION, SELECT_SECTION): Add third
+       macro argument.
+       Put constant into special SHF_MERGE sections if the linker should
+       attempt to merge duplicates.
+       * config/alpha/elf.h: Likewise.
+       (ASM_SECTION_START_OP, ASM_OUTPUT_SECTION_START): Define if assembler
+       has working .subsection -1 support.
+       * config/nextstep.h: Add third argument to SELECT_RTX_SECTION and
+       SELECT_SECTION.
+       * config/svr3.h: Likewise.
+       * config/darwin.h: Likewise.
+       * config/arm/aof.h: Likewise.
+       * config/arm/linux-elf.h: Likewise.
+       * config/avr/avr.h: Likewise.
+       * config/c4x/c4x.h: Likewise.
+       * config/d30v/d30v.h: Likewise.
+       * config/i386/dgux.h: Likewise.
+       * config/i386/osfrose.h: Likewise.
+       * config/i386/sco5.h: Likewise.
+       * config/i386/svr3gas.h: Likewise.
+       * config/ia64/aix.h: Likewise.
+       * config/m32r/m32r.h: Likewise.
+       * config/m68k/m68k.h: Likewise.
+       * config/m88k/dgux.h: Likewise.
+       * config/m88k/m88k.h: Likewise.
+       * config/mcore/mcore-pe.h: Likewise.
+       * config/mips/mips.h: Likewise.
+       * config/pa/pa.h: Likewise.
+       * config/pa/pa-linux.h: Likewise.
+       * config/romp/romp.h: Likewise.
+       * config/rs6000/sysv4.h: Likewise.
+       * config/rs6000/xcoff.h: Likewise.
+       * config/s390/linux.h: Likewise.
+       * config/sparc/sparc.h: Likewise.
+       * config/sparc/sysv4.h: Likewise.
+       * config/stormy16/stormy16.h: Likewise.
+       * config/v850/v850.h: Likewise.
+       * config/vax/vms.h: Likewise.
+       * config/arm/arm.c (arm_elf_asm_named_section): Output SECTION_MERGE
+       and SECTION_STRINGS flags plus SECTION_ENTSIZE entity size.
+       * config/sparc/sparc.c (sparc_elf_asm_named_section): Use
+       default_elf_asm_named_section for SHF_MERGE sections.
+
 Tue Sep 11 17:55:54 CEST 2001  Jan Hubicka  <jh@suse.cz>
 
        * bb-reorder.c (fixup_reorder_chain): Fallthru edge to exit block
index 88a751703c43e93debeba6e399ffcb0dd990a2e2..b9156619b5c64ba9f649e09ea0deb4fc8c265984 100644 (file)
 /* Define if your assembler mis-optimizes .eh_frame data. */
 #undef USE_AS_TRADITIONAL_FORMAT
 
+/* Define if your assembler supports marking sections with SHF_MERGE flag. */
+#undef HAVE_GAS_SHF_MERGE
+
 /* Define if your assembler supports .register. */
 #undef HAVE_AS_REGISTER_PSEUDO_OP
 
index 3bb51cca6b224dbf59789cdddb802f2d41db567a..7c2ad236b44bfde9cf2d3530c6f50facfe118641 100644 (file)
@@ -1,5 +1,6 @@
 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
    Contributed by Richard Henderson (rth@tamu.edu).
 
 This file is part of GNU CC.
@@ -222,6 +223,16 @@ do {                                                                       \
 #undef  FINI_SECTION_ASM_OP
 #define FINI_SECTION_ASM_OP    "\t.section\t.fini"
 
+#ifdef HAVE_GAS_SUBSECTION_ORDERING
+
+#define ASM_SECTION_START_OP   "\t.subsection\t-1"
+
+/* Output assembly directive to move to the beginning of current section.  */
+#define ASM_OUTPUT_SECTION_START(FILE) \
+  fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
+
+#endif
+
 /* A default list of other sections which we might be "in" at any given
    time.  For targets that use additional sections (e.g. .tdesc) you
    should override this definition in the target-specific file which
@@ -240,8 +251,6 @@ do {                                                                        \
   SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP)        \
   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP)
 
-extern void ctors_section              PARAMS ((void));
-extern void dtors_section              PARAMS ((void));
 extern void sbss_section               PARAMS ((void));
 extern void sdata_section              PARAMS ((void));
 
@@ -300,6 +309,8 @@ void FN ()                                  \
         {                                                      \
           if (flag_writable_strings)                           \
             SECNUM = 2;                                        \
+          else                                                 \
+            SECNUM = 0x101;                                    \
         }                                                      \
        else if (TREE_CODE (DECL) == VAR_DECL)                  \
         {                                                      \
@@ -311,6 +322,17 @@ void FN ()                                 \
                    || TREE_SIDE_EFFECTS (DECL)                 \
                    || ! TREE_CONSTANT (DECL_INITIAL (DECL)))   \
             SECNUM = 2;                                        \
+         else if (flag_merge_constants >= 2)                   \
+           {                                                   \
+             /* C and C++ don't allow different variables to   \
+                share the same location.  -fmerge-all-constants\
+                allows even that (at the expense of not        \
+                conforming).  */                               \
+             if (TREE_CODE (DECL_INITIAL (DECL)) == STRING_CST)\
+               SECNUM = 0x201;                                 \
+             else                                              \
+               SECNUM = 0x301;                                 \
+           }                                                   \
         }                                                      \
        else if (TREE_CODE (DECL) == CONSTRUCTOR)               \
         {                                                      \
@@ -322,7 +344,7 @@ void FN ()                                  \
         }                                                      \
                                                                \
        /* Select small data sections based on size.  */                \
-       if (SECNUM >= 2)                                                \
+       if ((SECNUM & 0xff) >= 2)                               \
         {                                                      \
           int size = int_size_in_bytes (TREE_TYPE (DECL));     \
           if (size >= 0 && size <= g_switch_value)             \
@@ -332,26 +354,42 @@ void FN ()                                        \
    while (0)
 
 #undef  SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC)            \
-  do                                           \
-    {                                          \
-      typedef void (*sec_fn) PARAMS ((void));  \
-      static sec_fn const sec_functions[6] =   \
-      {                                                \
-       text_section,                           \
-       const_section,                          \
-       data_section,                           \
-       sdata_section,                          \
-       bss_section,                            \
-       sbss_section                            \
-      };                                       \
-                                               \
-      int sec;                                 \
-                                               \
-      DO_SELECT_SECTION (sec, DECL, RELOC);    \
-                                               \
-      (*sec_functions[sec]) ();                        \
-    }                                          \
+#define SELECT_SECTION(DECL, RELOC, ALIGN)             \
+  do                                                   \
+    {                                                  \
+      typedef void (*sec_fn) PARAMS ((void));          \
+      static sec_fn const sec_functions[6] =           \
+      {                                                        \
+       text_section,                                   \
+       const_section,                                  \
+       data_section,                                   \
+       sdata_section,                                  \
+       bss_section,                                    \
+       sbss_section                                    \
+      };                                               \
+                                                       \
+      int sec;                                         \
+                                                       \
+      DO_SELECT_SECTION (sec, DECL, RELOC);            \
+                                                       \
+      switch (sec)                                     \
+       {                                               \
+       case 0x101:                                     \
+         mergeable_string_section (DECL, ALIGN, 0);    \
+         break;                                        \
+       case 0x201:                                     \
+         mergeable_string_section (DECL_INITIAL (DECL),\
+                                   ALIGN, 0);          \
+         break;                                        \
+       case 0x301:                                     \
+         mergeable_constant_section (DECL_MODE (DECL), \
+                                     ALIGN, 0);        \
+         break;                                        \
+       default:                                        \
+         (*sec_functions[sec]) ();                     \
+         break;                                        \
+       }                                               \
+    }                                                  \
   while (0)
 
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
@@ -380,7 +418,7 @@ void FN ()                                  \
       STRIP_NAME_ENCODING (name, name);                                        \
       nlen = strlen (name);                                            \
                                                                        \
-      prefix = prefixes[sec][DECL_ONE_ONLY(DECL)];                     \
+      prefix = prefixes[sec & 0xff][DECL_ONE_ONLY(DECL)];              \
       plen = strlen (prefix);                                          \
                                                                        \
       string = alloca (nlen + plen + 1);                               \
@@ -399,8 +437,8 @@ void FN ()                                  \
    go into the const section.  */
 
 #undef  SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE, RTX) \
-   const_section()
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \
+   mergeable_constant_section((MODE), (ALIGN), 0)
 
 /* Define the strings used for the special svr4 .type and .size directives.
    These strings generally do not vary from one system running svr4 to
index 2721b8bbdebe760323ea67feb035d59a1674976c..55b8eefda2d7f9104715e894af6bb9329035b06d 100644 (file)
@@ -55,7 +55,7 @@ Boston, MA 02111-1307, USA.  */
 char *aof_text_section ();
 #define TEXT_SECTION_ASM_OP aof_text_section ()
 
-#define SELECT_RTX_SECTION(MODE,RTX) text_section ();
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN) text_section ();
 
 char *aof_data_section ();
 #define DATA_SECTION_ASM_OP aof_data_section ()
index c3f4e2eadefa3515974e97254cf6db1d01196a28..725864c54a011e9aa8d3faa0702df070b7491185 100644 (file)
@@ -10860,6 +10860,10 @@ arm_elf_asm_named_section (name, flags)
     *f++ = 'x';
   if (flags & SECTION_SMALL)
     *f++ = 's';
+  if (flags & SECTION_MERGE)
+    *f++ = 'M';
+  if (flags & SECTION_STRINGS)
+    *f++ = 'S';
   *f = '\0';
 
   if (flags & SECTION_BSS)
@@ -10867,6 +10871,10 @@ arm_elf_asm_named_section (name, flags)
   else
     type = "progbits";
 
-  fprintf (asm_out_file, "\t.section\t%s,\"%s\",%%%s\n",
-          name, flagchars, type);
+  if (flags & SECTION_ENTSIZE)
+    fprintf (asm_out_file, "\t.section\t%s,\"%s\",%%%s,%d\n",
+            name, flagchars, type, flags & SECTION_ENTSIZE);
+  else
+    fprintf (asm_out_file, "\t.section\t%s,\"%s\",%%%s\n",
+            name, flagchars, type);
 }
index 06519604ff0c54fdfaba01550945028c27f83514..cb9014ce7411aac8bbb28545bbc10f847f86fd8e 100644 (file)
@@ -139,7 +139,7 @@ const_section ()                                                    \
    section for output of DECL.  DECL is either a `VAR_DECL' node
    or a constant of some sort.  RELOC indicates whether forming
    the initial value of DECL requires link-time relocations.  */
-#define SELECT_SECTION(DECL,RELOC)                                     \
+#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
@@ -204,7 +204,7 @@ const_section ()                                                    \
    of constant in RTL.  The argument MODE is redundant except
    in the case of a `const_int' rtx.  Currently, these always
    go into the const section.  */
-#define SELECT_RTX_SECTION(MODE,RTX) const_section ()
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN) const_section ()
 
 /* On svr4, we *do* have support for the .init and .fini sections, and we
    can put stuff in there to be executed before and after `main'.  We let
index 3fd1e5652eb7586069d8df80efe1c445957131d8..8ae9302f5e1d26901db1ac89ac8415034b0ee0ee 100644 (file)
@@ -1890,7 +1890,7 @@ progmem_section (void)                                                          \
    If these items should be placed in the text section, this macro
    should not be defined.  */
 
-/* `SELECT_SECTION (EXP, RELOC)'
+/* `SELECT_SECTION (EXP, RELOC, ALIGN)'
    A C statement or statements to switch to the appropriate section
    for output of EXP.  You can assume that EXP is either a `VAR_DECL'
    node or a constant of some sort.  RELOC indicates whether the
@@ -1901,7 +1901,7 @@ progmem_section (void)                                                          \
    Do not define this macro if you put all read-only variables and
    constants in the read-only data section (usually the text section).  */
 
-/* `SELECT_RTX_SECTION (MODE, RTX)'
+/* `SELECT_RTX_SECTION (MODE, RTX, ALIGN)'
    A C statement or statements to switch to the appropriate section
    for output of RTX in mode MODE.  You can assume that RTX is some
    kind of constant in RTL.  The argument MODE is redundant except in
index cdc39db30c33362d9f1b5e2954dbadce3b115ba9..e8052c6b68c1af4a6ca44ed3f25bd3262c4e1ef1 100644 (file)
@@ -2030,7 +2030,7 @@ const_section ()                                                  \
    or a constant of some sort.  RELOC indicates whether forming
    the initial value of DECL requires link-time relocations.  */
 
-#define SELECT_SECTION(DECL, RELOC)                                    \
+#define SELECT_SECTION(DECL, RELOC, ALIGN)                             \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
@@ -2075,7 +2075,7 @@ const_section ()                                                  \
    in the case of a `const_int' rtx.  Currently, these always
    go into the const section.  */
 
-#define SELECT_RTX_SECTION(MODE, RTX) const_section()
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN) const_section()
 
 
 /* Overall Framework of an Assembler File.  */
index 82598fd659b97285046e91253e5e8c4ea7f89590..abf2d4736f0101c1331ea8d99afaf9dc1253cc81 100644 (file)
@@ -3698,7 +3698,7 @@ extern const char *d30v_branch_cost_string;
    the read-only data section (usually the text section).
 
    Defined in svr4.h.  */
-/* #define SELECT_SECTION(EXP, RELOC) */
+/* #define SELECT_SECTION(EXP, RELOC, ALIGN) */
 
 /* A C statement or statements to switch to the appropriate section for output
    of RTX in mode MODE.  You can assume that RTX is some kind of constant in
@@ -3710,7 +3710,7 @@ extern const char *d30v_branch_cost_string;
    section.
 
    Defined in svr4.h.  */
-/* #define SELECT_RTX_SECTION(MODE, RTX) */
+/* #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) */
 
 /* Define this macro if jump tables (for `tablejump' insns) should be output in
    the text section, along with the assembler instructions.  Otherwise, the
index 9124307755c46012127ba2dbb0ae563d0f2827e3..5c49d1131932e3e1f027ae8d5c78bd62ae2f1365 100644 (file)
@@ -509,7 +509,7 @@ void alias_section (name, alias)                    \
 #define READONLY_DATA_SECTION const_section
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(exp,reloc)                              \
+#define SELECT_SECTION(exp,reloc,align)                                \
   do                                                           \
     {                                                          \
       if (TREE_CODE (exp) == STRING_CST)                       \
@@ -633,7 +633,7 @@ void alias_section (name, alias)                    \
   while (0)
 
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(mode, rtx)                                  \
+#define SELECT_RTX_SECTION(mode, rtx, align)                           \
   do                                                                   \
     {                                                                  \
       if (GET_MODE_SIZE (mode) == 8)                                   \
index d813678682e4fc0529fd9cc6428f0a59119456a9..d2ae669a83ff714e9de81937072fc0cececcf66d 100644 (file)
@@ -262,6 +262,16 @@ Boston, MA 02111-1307, USA.  */
 #define INIT_SECTION_ASM_OP    "\t.section\t.init"
 #define FINI_SECTION_ASM_OP    "\t.section\t.fini"
 
+#ifdef HAVE_GAS_SUBSECTION_ORDERING
+
+#define ASM_SECTION_START_OP   "\t.subsection\t-1"
+
+/* Output assembly directive to move to the beginning of current section.  */
+#define ASM_OUTPUT_SECTION_START(FILE) \
+  fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
+
+#endif
+
 /* A default list of other sections which we might be "in" at any given
    time.  For targets that use additional sections (e.g. .tdesc) you
    should override this definition in the target-specific file which
@@ -340,11 +350,14 @@ const_section ()                                          \
 /* A C statement or statements to switch to the appropriate
    section for output of RTX in mode MODE.  RTX is some kind
    of constant in RTL.  The argument MODE is redundant except
-   in the case of a `const_int' rtx.  Currently, these always
-   go into the const section.  */
+   in the case of a `const_int' rtx.
+   If assembler supports SHF_MERGE sections, put it into
+   a .rodata.cstN section where N is size of the constant,
+   otherwise into const section.  */
 
 #undef  SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE, RTX) const_section ()
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN)   \
+  mergeable_constant_section ((MODE), (ALIGN), 0)
 
 /* A C statement or statements to switch to the appropriate
    section for output of DECL.  DECL is either a `VAR_DECL' node
@@ -352,12 +365,12 @@ const_section ()                                          \
    the initial value of DECL requires link-time relocations.  */
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC)                            \
+#define SELECT_SECTION(DECL, RELOC, ALIGN)                     \
 {                                                              \
   if (TREE_CODE (DECL) == STRING_CST)                          \
     {                                                          \
       if (! flag_writable_strings)                             \
-       const_section ();                                       \
+       mergeable_string_section ((DECL), (ALIGN), 0);          \
       else                                                     \
        data_section ();                                        \
     }                                                          \
@@ -369,8 +382,17 @@ const_section ()                                           \
          || (DECL_INITIAL (DECL) != error_mark_node            \
              && !TREE_CONSTANT (DECL_INITIAL (DECL))))         \
        data_section ();                                        \
-      else                                                     \
+      else if (flag_merge_constants < 2)                       \
+       /* C and C++ don't allow different variables to share   \
+          the same location.  -fmerge-all-constants allows     \
+          even that (at the expense of not conforming).  */    \
        const_section ();                                       \
+      else if (TREE_CODE (DECL_INITIAL (DECL)) == STRING_CST)  \
+       mergeable_string_section (DECL_INITIAL (DECL), (ALIGN), \
+                                 0);                           \
+      else                                                     \
+       mergeable_constant_section (DECL_MODE (DECL), (ALIGN),  \
+                                   0);                         \
     }                                                          \
   else if (TREE_CODE (DECL) == CONSTRUCTOR)                    \
     {                                                          \
index 04a290012911b34a96f2967fa2924e931334349c..5d7a6aa0d4fe1c326a012921ea45ae8141aa4b5b 100644 (file)
@@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA.  */
 #include "i386/sysv4.h"
 
 #ifndef VERSION_INFO2
-#define VERSION_INFO2   "$Revision: 1.12 $"
+#define VERSION_INFO2   "$Revision: 1.13 $"
 #endif
 
 #ifndef VERSION_STRING
@@ -232,7 +232,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Must use data section for relocatable constants when pic.  */
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE,RTX)            \
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN)      \
 {                                               \
   if (flag_pic && symbolic_operand (RTX, VOIDmode)) \
     data_section ();                            \
index 7d74f7ac1bcef3dc85eb91e2e77682f7ece57c36..785aa4fe7a6990288e163e4ab334c321de16c538 100644 (file)
@@ -506,7 +506,7 @@ while (0)
    and select that section.  */
 
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE, RTX)                                  \
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN)                           \
 do                                                                     \
   {                                                                    \
     if (MODE == Pmode && HALF_PIC_P () && HALF_PIC_ADDRESS_P (RTX))    \
@@ -517,7 +517,7 @@ do                                                                  \
 while (0)
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC)                                    \
+#define SELECT_SECTION(DECL, RELOC, ALIGN)                             \
 {                                                                      \
   if (RELOC && HALF_PIC_P ())                                          \
     data_section ();                                                   \
index a818427082198ad67486399dfb2235669ac92751..56bc2879e6c753931f3b1d89fcc22827ee2fbd94 100644 (file)
@@ -371,7 +371,7 @@ do {                                                                        \
 
 /* Must use data section for relocatable constants when pic.  */
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE,RTX)                                   \
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN)                             \
 {                                                                      \
   if (TARGET_ELF) {                                                    \
     if (flag_pic && symbolic_operand (RTX, VOIDmode))                  \
@@ -565,7 +565,7 @@ init_section ()                                                             \
    : 0))
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC)                                     \
+#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
 {                                                                      \
   if (TARGET_ELF && flag_pic && RELOC)                                 \
      data_section ();                                                  \
index 8733ba7272458d036a19b5d6ed8a301bf2966830..08ada117284cc413b49abcc3e26945a32b81355e 100644 (file)
@@ -177,7 +177,7 @@ const_section ()                                                    \
    or a constant of some sort.  RELOC indicates whether forming
    the initial value of DECL requires link-time relocations.  */
 
-#define SELECT_SECTION(DECL,RELOC)                                     \
+#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
@@ -207,4 +207,4 @@ const_section ()                                                    \
    in the case of a `const_int' rtx.  Currently, these always
    go into the const section.  */
 
-#define SELECT_RTX_SECTION(MODE,RTX) const_section()
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN) const_section()
index cf1f4b0874a4040701760d114ba3b230a05f651b..0c632111b5ad521abe8fe8e9f0f5a481eea8868d 100644 (file)
@@ -150,7 +150,7 @@ do {                                                        \
    the initial value of DECL requires link-time relocations.  */
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC)                                     \
+#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
@@ -184,7 +184,7 @@ do {                                                        \
 
 extern unsigned int ia64_section_threshold;
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE, RTX)                                  \
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN)                           \
 {                                                                      \
   if (GET_MODE_SIZE (MODE) > 0                                         \
       && GET_MODE_SIZE (MODE) <= ia64_section_threshold)               \
index 0abb7e8cd7ed60bfd2de85cda23c4986c1b3de80..54b5167363e57137dc9081a62fadab6e93ebbb24 100644 (file)
@@ -138,12 +138,12 @@ do {                                                                      \
 /* We override svr4.h so that we can support the sdata section.  */
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC)                                     \
+#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
       if (! flag_writable_strings)                                     \
-       const_section ();                                               \
+       mergeable_string_section ((DECL), (ALIGN), 0);                  \
       else                                                             \
        data_section ();                                                \
     }                                                                  \
@@ -152,13 +152,20 @@ do {                                                                      \
       if (XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0]                       \
          == SDATA_NAME_FLAG_CHAR)                                      \
         sdata_section ();                                              \
-      /* ??? We need the extra ! RELOC check, because the default is to \
+      /* ??? We need the extra RELOC check, because the default is to  \
         only check RELOC if flag_pic is set, and we don't set flag_pic \
         (yet?).  */                                                    \
-      else if (DECL_READONLY_SECTION (DECL, RELOC) && ! (RELOC))       \
+      else if (!DECL_READONLY_SECTION (DECL, RELOC) || (RELOC))                \
+       data_section ();                                                \
+      else if (flag_merge_constants < 2)                               \
+       /* C and C++ don't allow different variables to share           \
+          the same location.  -fmerge-all-constants allows             \
+          even that (at the expense of not conforming).  */            \
        const_section ();                                               \
+      else if (TREE_CODE (DECL_INITIAL (DECL)) == STRING_CST)          \
+       mergeable_string_section (DECL_INITIAL (DECL), (ALIGN), 0);     \
       else                                                             \
-       data_section ();                                                \
+       mergeable_constant_section (DECL_MODE (DECL), (ALIGN), 0);      \
     }                                                                  \
   /* This could be a CONSTRUCTOR containing ADDR_EXPR of a VAR_DECL,   \
      in which case we can't put it in a shared library rodata.  */     \
@@ -172,7 +179,7 @@ do {                                                                        \
 
 extern unsigned int ia64_section_threshold;
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE, RTX)                                  \
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN)                           \
 {                                                                      \
   if (GET_MODE_SIZE (MODE) > 0                                         \
       && GET_MODE_SIZE (MODE) <= ia64_section_threshold)               \
@@ -180,7 +187,7 @@ extern unsigned int ia64_section_threshold;
   else if (flag_pic && symbolic_operand ((RTX), (MODE)))               \
     data_section ();                                                   \
   else                                                                 \
-    const_section ();                                                  \
+    mergeable_constant_section ((MODE), (ALIGN), 0);                   \
 }
 
 #undef EXTRA_SECTIONS
index 5ef9951cd6b8a18fea9c5e2af491f89f5c10990f..4cb379e34be432fa9fa5496878e759a121305eb2 100644 (file)
@@ -1534,7 +1534,8 @@ sbss_section ()                                                           \
    or a constant of some sort.  RELOC indicates whether the initial value
    of EXP requires link-time relocations.  */
 #undef  SELECT_SECTION
-#define SELECT_SECTION(EXP, RELOC) m32r_select_section ((EXP), (RELOC))
+#define SELECT_SECTION(EXP, RELOC, ALIGN) \
+  m32r_select_section ((EXP), (RELOC))
 
 /* A C statement or statements to switch to the appropriate section for
    output of RTX in mode MODE.  You can assume that RTX
index 14bcaa25c147289bf3a20865b58b5202be6a3a1b..9607a920c59e233e40f0363b1f5bcf37a4119eb0 100644 (file)
@@ -359,7 +359,7 @@ extern int target_flags;
 /* This is how to align an instruction for optimal branching. */
 #define LABEL_ALIGN_AFTER_BARRIER(LABEL) (m68k_align_jumps)
 
-#define SELECT_RTX_SECTION(MODE, X)                                    \
+#define SELECT_RTX_SECTION(MODE, X, ALIGN)                             \
 {                                                                      \
   if (!flag_pic)                                                       \
     readonly_data_section();                                           \
index ab8e3710e1e8dbff6c152a30323005755c9e3880..1d91168a5a406c412c39d5ae756c4b6ac692ee36 100644 (file)
@@ -294,7 +294,7 @@ func_ptr __DTOR_END__[1] = { (func_ptr) (-1) }
 
 /* Must use data section for relocatable constants when pic.  */
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE,RTX)            \
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN)      \
 {                                               \
   if (flag_pic && symbolic_operand (RTX))       \
     data_section ();                            \
index c30c81891f4d260bceed31df9522efbf4414e725..881acd88be0d815cd845b707f3f20c13ea935b99 100644 (file)
@@ -2480,7 +2480,7 @@ sdata_section ()                                                  \
 
    For strings, the section is selected before the segment info is encoded.  */
 #undef SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC)                                     \
+#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
index 2362b521a18f0a71b007c9ba2477986ab710fc37..e08b337c1948090444cdeef0fe04d55e28c287b7 100644 (file)
@@ -81,7 +81,7 @@ rdata_section ()                                              \
    or a constant of some sort.  RELOC indicates whether forming
    the initial value of DECL requires link-time relocations.  */
 #undef  SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC)                                    \
+#define SELECT_SECTION(DECL, RELOC, ALIGN)                             \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
@@ -111,7 +111,7 @@ rdata_section ()                                            \
    in the case of a `const_int' rtx.  Currently, these always
    go into the const section.  */
 #undef  SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE, RTX) rdata_section ()
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN) rdata_section ()
 
 #define MCORE_EXPORT_NAME(STREAM, NAME)                        \
   do                                                   \
index 81f675cd06a8fd604304bcff306853bf06b81298..fb54bcd605da77bd8ec831ef44bc9a9a0808abff 100644 (file)
@@ -4477,10 +4477,12 @@ rdata_section ()                                                        \
    and select that section.  */
 
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE,RTX)   mips_select_rtx_section (MODE, RTX)
+#define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \
+  mips_select_rtx_section (MODE, RTX)
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC)    mips_select_section (DECL, RELOC)
+#define SELECT_SECTION(DECL, RELOC, ALIGN) \
+  mips_select_section (DECL, RELOC)
 
 \f
 /* Store in OUTPUT a string (made with alloca) containing
index 7bb9681463424955cad0f394e04dd726143e1fff..956b9e27d42b56d87950d5401e88061cde3a35c9 100644 (file)
@@ -445,7 +445,7 @@ objc_section_init ()                                \
 #define READONLY_DATA_SECTION const_section
 
 #undef SELECT_SECTION
-#define SELECT_SECTION(exp,reloc)                              \
+#define SELECT_SECTION(exp,reloc,align)                                \
   do                                                           \
     {                                                          \
       if (TREE_CODE (exp) == STRING_CST)                       \
@@ -563,7 +563,7 @@ objc_section_init ()                                \
   while (0)
 
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(mode, rtx)                                  \
+#define SELECT_RTX_SECTION(mode, rtx, align)                           \
   do                                                                   \
     {                                                                  \
       if (GET_MODE_SIZE(mode) == 8)                                    \
index baa1cf5b4a5d5cfe541afca897b410a2f1dedec9..f290802bf3460711333e24c9ea39cbbcd9b49c2c 100644 (file)
@@ -55,7 +55,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Put plabels into the data section so we can relocate them.  */
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE,RTX)   \
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN)     \
   if (flag_pic && function_label_operand (RTX, MODE))  \
     data_section ();                                   \
   else                                                 \
index 4385914347dbe05cbe734edff6efadb6e271f5b3..fa892f1421b9e3440353ca1f7012825fd1ad3b1b 100644 (file)
@@ -1403,7 +1403,7 @@ do {                                                                      \
    library.  Since we can't know at compile time if a symbol will be
    satisfied by a shared library or main program we put any symbolic
    constant into the normal data section.  */
-#define SELECT_RTX_SECTION(MODE,RTX)   \
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN)     \
   if (symbolic_operand (RTX, MODE))    \
     data_section ();                   \
   else                                 \
@@ -1413,7 +1413,7 @@ do {                                                                      \
    in the read-only data section to a symbol defined in a shared
    library.  Therefore, expressions that might require a reloc can
    not be placed in the read-only data section.  */
-#define SELECT_SECTION(EXP,RELOC) \
+#define SELECT_SECTION(EXP,RELOC,ALIGN) \
   if (TREE_CODE (EXP) == VAR_DECL \
       && TREE_READONLY (EXP) \
       && !TREE_THIS_VOLATILE (EXP) \
index 4f920cc574d8552e413a33624a639fc7379b755a..2e517a19cb54bfdd08ec1c50901f547cc8d18419 100644 (file)
@@ -717,7 +717,7 @@ struct rt_cargs {int gregs, fregs; };
 
    On ROMP, all constants are in the data area.  */
 
-#define SELECT_RTX_SECTION(MODE, X)    data_section ()
+#define SELECT_RTX_SECTION(MODE, X, ALIGN)     data_section ()
 
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.  */
index b8158ccf15bba91d520042518e49207d4bbcd2eb..1b2051d82c4f3bce41e9de54416efa9639f5bc55 100644 (file)
@@ -566,7 +566,7 @@ fini_section ()                                                             \
 
 /* Override elfos.h definition.  */
 #undef SELECT_RTX_SECTION
-#define        SELECT_RTX_SECTION(MODE, X) rs6000_select_rtx_section (MODE, X)
+#define        SELECT_RTX_SECTION(MODE, X, ALIGN) rs6000_select_rtx_section (MODE, X)
 
 /* A C statement or statements to switch to the appropriate
    section for output of DECL.  DECL is either a `VAR_DECL' node
@@ -575,7 +575,7 @@ fini_section ()                                                             \
 
 /* Override elfos.h definition.  */
 #undef SELECT_SECTION
-#define        SELECT_SECTION(DECL, RELOC) rs6000_select_section (DECL, RELOC)
+#define        SELECT_SECTION(DECL, RELOC, ALIGN) 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).
index c120e643c9472dc5a8348c58fb5aba5002b9a744..fbb74360bad7f7eccee569d5df10328fd9054d13 100644 (file)
@@ -144,7 +144,7 @@ toc_section ()                                              \
    On the RS/6000, we have a special section for all variables except those
    that are static.  */
 
-#define SELECT_SECTION(EXP,RELOC)                      \
+#define SELECT_SECTION(EXP,RELOC,ALIGN)                        \
 {                                                      \
   if ((TREE_CODE (EXP) == STRING_CST                   \
        && ! flag_writable_strings)                     \
@@ -199,7 +199,7 @@ toc_section ()                                              \
    However, if this is being placed in the TOC it must be output as a
    toc entry.  */
 
-#define SELECT_RTX_SECTION(MODE, X)                    \
+#define SELECT_RTX_SECTION(MODE, X, ALIGN)             \
 { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X, MODE))       \
     toc_section ();                                    \
   else                                                 \
index 31b657ce78d1c34ad1f5ef2648a90e9d73fc087c..efe13777623aa1796534d06f537795a8d1994c17 100644 (file)
@@ -295,7 +295,7 @@ do {                                                                    \
  */
 
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE, X)
+#define SELECT_RTX_SECTION(MODE, X, ALIGN)
 
 \f
 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
index 9f51d989e5c9a6fbc81d2619df79a4af1e526517..91deb4903d28ad8b36f3054d4acd811ea4ab1337 100644 (file)
@@ -8765,6 +8765,14 @@ sparc_elf_asm_named_section (name, flags)
      const char *name;
      unsigned int flags;
 {
+  if (flags & SECTION_MERGE)
+    {
+      /* entsize cannot be expressed in this section attributes
+        encoding style.  */
+      default_elf_asm_named_section (name, flags);
+      return;
+    }
+
   fprintf (asm_out_file, "\t.section\t\"%s\"", name);
 
   if (!(flags & SECTION_DEBUG))
index 1b7ce2721c9d6c2605d00ccd1b28c1dfe83e8f9b..629286ed912694ad5bcdec5e48845f2489b7d52e 100644 (file)
@@ -912,7 +912,7 @@ if (TARGET_ARCH64                           \
 #endif
 
 /* This is defined differently for v9 in a cover file.  */
-#define SELECT_SECTION(T,RELOC)                                                \
+#define SELECT_SECTION(T,RELOC,ALIGN)                                  \
 {                                                                      \
   if (TREE_CODE (T) == VAR_DECL)                                       \
     {                                                                  \
@@ -945,7 +945,7 @@ if (TARGET_ARCH64                           \
 /* Use text section for a constant
    unless we need more alignment than that offers.  */
 /* This is defined differently for v9 in a cover file.  */
-#define SELECT_RTX_SECTION(MODE, X)            \
+#define SELECT_RTX_SECTION(MODE, X, ALIGN)     \
 {                                              \
   if (GET_MODE_BITSIZE (MODE) <= MAX_TEXT_ALIGN \
       && ! (flag_pic && (symbolic_operand ((X), (MODE)) || SUNOS4_SHARED_LIBRARIES)))  \
index 4cd0b396ca73aea9880688eb1040cbe69d9f4061..d9c0be7e2081d1ba43a206963487c59bee9b0a7c 100644 (file)
@@ -79,7 +79,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Must use data section for relocatable constants when pic.  */
 #undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE,RTX)           \
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN)     \
 {                                              \
   if (flag_pic && symbolic_operand ((RTX), (MODE))) \
     data_section ();                           \
index 8f2ee8094be02e1fb9d5600173420151fe8f3962..2258819306cfe59a8c2bfd2e98895b6b89700a31 100644 (file)
@@ -3470,7 +3470,7 @@ do {                                                      \
    the read-only data section (usually the text section).
 
    Defined in svr4.h.  */
-/* #define SELECT_SECTION(EXP, RELOC) */
+/* #define SELECT_SECTION(EXP, RELOC, ALIGN) */
 
 /* A C statement or statements to switch to the appropriate section for output
    of RTX in mode MODE.  You can assume that RTX is some kind of constant in
@@ -3482,7 +3482,7 @@ do {                                                      \
    section.
 
    Defined in svr4.h.  */
-/* #define SELECT_RTX_SECTION(MODE, RTX) */
+/* #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) */
 
 /* Define this macro if jump tables (for `tablejump' insns) should be output in
    the text section, along with the assembler instructions.  Otherwise, the
index 6f26fde8cd53c14be06210870e439bc81845f5ae..57f3ee333edcabcf0064cb0e699552ba6dfa63b5 100644 (file)
@@ -301,7 +301,7 @@ const_section ()                                                    \
    or a constant of some sort.  RELOC indicates whether forming
    the initial value of DECL requires link-time relocations.  */
 
-#define SELECT_SECTION(DECL,RELOC)                                     \
+#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
 {                                                                      \
   if (TREE_CODE (DECL) == STRING_CST)                                  \
     {                                                                  \
@@ -331,4 +331,4 @@ const_section ()                                                    \
    in the case of a `const_int' rtx.  Currently, these always
    go into the const section.  */
 
-#define SELECT_RTX_SECTION(MODE,RTX) const_section()
+#define SELECT_RTX_SECTION(MODE,RTX,ALIGN) const_section()
index 5baef15e847265d33113d382477af79325991639..b077f6d72d9e8047a02d7df6c775e16d6aa35fe6 100644 (file)
@@ -1164,7 +1164,7 @@ zbss_section ()                                                           \
    Do not define this macro if you put all read-only variables and
    constants in the read-only data section (usually the text section).  */
 #undef  SELECT_SECTION
-#define SELECT_SECTION(EXP, RELOC)                                     \
+#define SELECT_SECTION(EXP, RELOC, ALIGN)                              \
 do {                                                                   \
   if (TREE_CODE (EXP) == VAR_DECL)                                     \
     {                                                                  \
@@ -1227,7 +1227,7 @@ do {                                                                      \
 
    Do not define this macro if you put all constants in the read-only
    data section.  */
-/* #define SELECT_RTX_SECTION(MODE, RTX) */
+/* #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) */
 
 /* Output at beginning/end of assembler file.  */
 #undef ASM_FILE_START
index 52f4d2750e3ff6fc67ee0eeca72faed493f432e2..133d1c3ba1ab8db60195352f40fb2e3dff149af9 100644 (file)
@@ -218,7 +218,7 @@ const_section ()                                    \
    Since this macro is used in a number of places, we must also be able
    to decide where to place string constants.  */
 
-#define SELECT_SECTION(T,RELOC)                                                \
+#define SELECT_SECTION(T,RELOC,ALIGN)                                  \
 {                                                                      \
   if (TREE_CODE (T) == VAR_DECL)                                       \
     {                                                                  \
index 640e5c2e8f90d562f948bb101048aabef87cb4f3..169ba2cbb28ee50c7fbe2cb3867d7c84b470c70f 100755 (executable)
@@ -7164,6 +7164,29 @@ EOF
 fi
 echo "$ac_t""$gcc_cv_as_eh_frame" 1>&6
 
+echo $ac_n "checking assembler section merging support""... $ac_c" 1>&6
+echo "configure:6569: checking assembler section merging support" >&5
+gcc_cv_as_shf_merge=no
+if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
+  if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 12 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then
+    gcc_cv_as_subsections="working SHF_MERGE support"
+  fi
+elif test x$gcc_cv_as != x; then
+       # Check if we support SHF_MERGE sections
+       echo '.section .rodata.str, "aMS", @progbits, 1' > conftest.s
+       if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+               gcc_cv_as_shf_merge=yes
+       fi
+       rm -f conftest.s conftest.o
+fi
+if test x"$gcc_cv_as_shf_merge" = xyes; then
+       cat >> confdefs.h <<\EOF
+#define HAVE_GAS_SHF_MERGE 1
+EOF
+
+fi
+echo "$ac_t""$gcc_cv_as_shf_merge" 1>&6
+
 case "$target" in 
   sparc*-*-*)
     echo $ac_n "checking assembler .register pseudo-op support""... $ac_c" 1>&6
index f69250efd013b9c52262696b451e365209d69ed6..01a927e76a0f13bdcf9d7ae4dff764122a32b0d4 100644 (file)
@@ -1484,6 +1484,26 @@ EOF
 fi
 AC_MSG_RESULT($gcc_cv_as_eh_frame)
 
+AC_MSG_CHECKING(assembler section merging support)
+gcc_cv_as_shf_merge=no
+if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
+  if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 12 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then
+    gcc_cv_as_subsections="working SHF_MERGE support"
+  fi
+elif test x$gcc_cv_as != x; then
+       # Check if we support SHF_MERGE sections
+       echo '.section .rodata.str, "aMS", @progbits, 1' > conftest.s
+       if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+               gcc_cv_as_shf_merge=yes
+       fi
+       rm -f conftest.s conftest.o
+fi
+if test x"$gcc_cv_as_shf_merge" = xyes; then
+       AC_DEFINE(HAVE_GAS_SHF_MERGE, 1,
+[Define if your assembler supports marking sections with SHF_MERGE flag.])
+fi
+AC_MSG_RESULT($gcc_cv_as_shf_merge)
+
 case "$target" in 
   sparc*-*-*)
     AC_CACHE_CHECK([assembler .register pseudo-op support],
index 7991e8b42d60101c41e0f51af77f3748de8bb4cc..d2b2afc8a8065b81042ffe3fb467c053c75fc501 100644 (file)
@@ -262,8 +262,8 @@ in the following sections.
 -fforce-addr  -fforce-mem  -ffunction-sections @gol
 -fgcse  -fgcse-lm  -fgcse-sm @gol
 -finline-functions  -finline-limit=@var{n}  -fkeep-inline-functions @gol
--fkeep-static-consts  -fmove-all-movables @gol
--fno-default-inline  -fno-defer-pop @gol
+-fkeep-static-consts  -fmerge-constants  -fmerge-all-constants @gol
+-fmove-all-movables  -fno-default-inline  -fno-defer-pop @gol
 -fno-function-cse  -fno-guess-branch-probability @gol
 -fno-inline  -fno-math-errno  -fno-peephole  -fno-peephole2 @gol
 -funsafe-math-optimizations -fno-trapping-math @gol
@@ -3321,6 +3321,23 @@ GCC enables this option by default.  If you want to force the compiler to
 check if the variable was referenced, regardless of whether or not
 optimization is turned on, use the @option{-fno-keep-static-consts} option.
 
+@item -fmerge-constants
+Attempt to merge identical constants (string constants and floating point
+constants) accross compilation units.
+
+This option is default for optimized compilation if assembler and linker
+support it.  Use @option{-fno-merge-constants} to inhibit this behaviour.
+
+@item -fmerge-all-constants
+Attempt to merge identical constants and identical variables.
+
+This option implies @option{-fmerge-constants}.  In addition to
+@option{-fmerge-constants} this considers e.g. even constant initialized
+arrays or initialized constant variables with integral or floating point
+types.  Languages like C or C++ require each non-automatic variable to
+have distinct location, so using this option will result in non-conforming
+behaviour.
+
 @item -fno-function-cse
 @opindex fno-function-cse
 Do not put function addresses in registers; make each instruction that
index 80e8e75209d065b4522b2ed32c4d301ff9e12a8c..edc2f3c342d1b4df5d5450de84e86a73686ad816 100644 (file)
@@ -5650,25 +5650,26 @@ If these items should be placed in the text section, this macro should
 not be defined.
 
 @findex SELECT_SECTION
-@item SELECT_SECTION (@var{exp}, @var{reloc})
+@item SELECT_SECTION (@var{exp}, @var{reloc}, @var{align})
 A C statement or statements to switch to the appropriate section for
 output of @var{exp}.  You can assume that @var{exp} is either a
 @code{VAR_DECL} node or a constant of some sort.  @var{reloc}
 indicates whether the initial value of @var{exp} requires link-time
 relocations.  Select the section by calling @code{text_section} or one
-of the alternatives for other sections.
+of the alternatives for other sections.  @var{align} is the constant
+alignment in bits.
 
 Do not define this macro if you put all read-only variables and
 constants in the read-only data section (usually the text section).
 
 @findex SELECT_RTX_SECTION
-@item SELECT_RTX_SECTION (@var{mode}, @var{rtx})
+@item SELECT_RTX_SECTION (@var{mode}, @var{rtx}, @var{align})
 A C statement or statements to switch to the appropriate section for
 output of @var{rtx} in mode @var{mode}.  You can assume that @var{rtx}
 is some kind of constant in RTL@.  The argument @var{mode} is redundant
 except in the case of a @code{const_int} rtx.  Select the section by
 calling @code{text_section} or one of the alternatives for other
-sections.
+sections.  @var{align} is the constant alignment in bits.
 
 Do not define this macro if you put all constants in the read-only
 data section.
index f33425ac4cbf0be93b5a8b31d308cae2eb78ef1b..04046af693b20cba8e2c4a5016e2c385af24a709 100644 (file)
@@ -1,3 +1,8 @@
+2001-09-11  Jakub Jelinek  <jakub@redhat.com>
+
+       * com.c (ffe_init_options): Default to -fmerge-all-constants
+       if optimizing.
+
 2000-08-14  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * target.h (FFETARGET_32bit_longs): Don't define
index 5b4388f7997598297333bf74cc2d450474ab4d58..137b72fa9acc4e20712079783733d54c005d47ef 100644 (file)
@@ -14657,6 +14657,7 @@ ffe_init_options ()
   flag_move_all_movables = 1;
   flag_reduce_all_givs = 1;
   flag_argument_noalias = 2;
+  flag_merge_constants = 2;
   flag_errno_math = 0;
   flag_complex_divide_method = 1;
 }
index 89188c0283af10df23925e175c82817f51723d12..bd29cea1cde7e6d478bc0b4b6154b1ad23bbc9c2 100644 (file)
@@ -544,6 +544,11 @@ extern int flag_bounded_pointers;
    For CHILL: defaults to off.  */
 extern int flag_bounds_check;
 
+/* This will attempt to merge constant section constants, if 1 only
+   string constants and constants from constant pool, if 2 also constant
+   variables.  */
+extern int flag_merge_constants;
+
 /* If one, renumber instruction UIDs to reduce the number of
    unused UIDs if there are a lot of instructions.  If greater than
    one, unconditionally renumber instruction UIDs.  */
index 2edfb050794be3faeab49eea6220b4d203492bcd..f1722f146b6d9c97c9c015331b174dd911eed6ec 100644 (file)
@@ -207,6 +207,15 @@ extern void function_section               PARAMS ((tree));
 /* Tell assembler to switch to the section for the exception table.  */
 extern void exception_section          PARAMS ((void));
 
+/* Tell assembler to switch to the section for string merging.  */
+extern void mergeable_string_section   PARAMS ((tree, unsigned HOST_WIDE_INT,
+                                                unsigned int));
+
+/* Tell assembler to switch to the section for constant merging.  */
+extern void mergeable_constant_section PARAMS ((enum machine_mode,
+                                                unsigned HOST_WIDE_INT,
+                                                unsigned int));
+
 /* Declare DECL to be a weak symbol.  */
 extern void declare_weak               PARAMS ((tree));
 #endif /* TREE_CODE */
@@ -450,14 +459,18 @@ extern void default_function_pro_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
 extern void no_asm_to_stream PARAMS ((FILE *));
 
 /* Flags controling properties of a section.  */
-#define SECTION_CODE       1   /* contains code */
-#define SECTION_WRITE      2   /* data is writable */
-#define SECTION_DEBUG      4   /* contains debug data */
-#define SECTION_LINKONCE    8  /* is linkonce */
-#define SECTION_SMALL     16   /* contains "small data" */
-#define SECTION_BSS       32   /* contains zeros only */
-#define SECTION_FORGET    64   /* forget that we've entered the section */
-#define SECTION_MACH_DEP  128  /* subsequent bits reserved for target */
+#define SECTION_ENTSIZE         0x000ff        /* entity size in section */
+#define SECTION_CODE    0x00100        /* contains code */
+#define SECTION_WRITE   0x00200        /* data is writable */
+#define SECTION_DEBUG   0x00400        /* contains debug data */
+#define SECTION_LINKONCE 0x00800       /* is linkonce */
+#define SECTION_SMALL   0x01000        /* contains "small data" */
+#define SECTION_BSS     0x02000        /* contains zeros only */
+#define SECTION_FORGET  0x04000        /* forget that we've entered the section */
+#define SECTION_MERGE   0x08000        /* contains mergeable data */
+#define SECTION_STRINGS  0x10000       /* contains zero terminated strings without
+                                          embedded zeros */
+#define SECTION_MACH_DEP 0x20000       /* subsequent bits reserved for target */
 
 extern unsigned int get_named_section_flags PARAMS ((const char *));
 extern bool set_named_section_flags    PARAMS ((const char *, unsigned int));
index 087a13a2cd8f8a7f37f652a7445f47d97b71abd0..925f06b3cde721f4ee3c48b9f16f173cc97e4937 100644 (file)
@@ -898,6 +898,11 @@ int flag_bounded_pointers = 0;
    For CHILL: defaults to off.  */
 int flag_bounds_check = 0;
 
+/* This will attempt to merge constant section constants, if 1 only
+   string constants and constants from constant pool, if 2 also constant
+   variables.  */
+int flag_merge_constants = 1;
+
 /* If one, renumber instruction UIDs to reduce the number of
    unused UIDs if there are a lot of instructions.  If greater than
    one, unconditionally renumber instruction UIDs.  */
@@ -1139,6 +1144,10 @@ lang_independent_options f_options[] =
    N_("Align all labels") },
   {"align-functions", &align_functions, 0,
    N_("Align the start of functions") },
+  {"merge-constants", &flag_merge_constants, 1,
+   N_("Attempt to merge identical constants accross compilation units") },
+  {"merge-all-constants", &flag_merge_constants, 2,
+   N_("Attempt to merge identical constants and constant variables") },
   {"check-memory-usage", &flag_check_memory_usage, 1,
    N_("Generate code to check every memory access") },
   {"prefix-function-name", &flag_prefix_function_name, 1,
@@ -4680,6 +4689,11 @@ toplev_main (argc, argv)
        }
     }
 
+  if (!optimize)
+    {
+      flag_merge_constants = 0;
+    }
+
   if (optimize >= 1)
     {
       flag_defer_pop = 1;
index a95994ca237dd4a28fcddaaa2fcfc7335ccdebac..defa0c6a4d8d375aeb60ba0b7f9987c5ae3b9148 100644 (file)
@@ -560,7 +560,7 @@ variable_section (decl, reloc)
         for them.  */
 
 #ifdef SELECT_SECTION
-      SELECT_SECTION (decl, reloc);
+      SELECT_SECTION (decl, reloc, DECL_ALIGN (decl));
 #else
       if (DECL_READONLY_SECTION (decl, reloc))
        readonly_data_section ();
@@ -587,6 +587,111 @@ exception_section ()
     readonly_data_section ();
 #endif
 }
+
+/* Tell assembler to switch to the section for string merging.  */
+
+void
+mergeable_string_section (decl, align, flags)
+  tree decl ATTRIBUTE_UNUSED;
+  unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+  unsigned int flags ATTRIBUTE_UNUSED;
+{
+#ifdef HAVE_GAS_SHF_MERGE
+  if (flag_merge_constants
+      && TREE_CODE (decl) == STRING_CST
+      && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
+      && align <= 256
+      && TREE_STRING_LENGTH (decl) >= int_size_in_bytes (TREE_TYPE (decl)))
+    {
+      enum machine_mode mode;
+      unsigned int modesize;
+      const char *str;
+      int i, j, len, unit;
+      char name[30];
+
+      mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
+      modesize = GET_MODE_BITSIZE (mode);
+      if (modesize >= 8 && modesize <= 256
+         && (modesize & (modesize - 1)) == 0)
+       {
+         if (align < modesize)
+           align = modesize;
+
+         str = TREE_STRING_POINTER (decl);
+         len = TREE_STRING_LENGTH (decl);
+         unit = GET_MODE_SIZE (mode);
+
+         /* Check for embedded NUL characters.  */
+         for (i = 0; i < len; i += unit)
+           {
+             for (j = 0; j < unit; j++)
+               if (str [i + j] != '\0')
+                 break;
+             if (j == unit)
+               break;
+           }
+         if (i == len - unit)
+           {
+             sprintf (name, ".rodata.str%d.%d", modesize / 8,
+                      (int) (align / 8));
+             flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS;
+             if (!i && modesize < align)
+               {
+                 /* A "" string with requested alignment greater than
+                    character size might cause a problem:
+                    if some other string required even bigger
+                    alignment than "", then linker might think the
+                    "" is just part of padding after some other string
+                    and not put it into the hash table initially.
+                    But this means "" could have smaller alignment
+                    than requested.  */
+#ifdef ASM_OUTPUT_SECTION_START
+                 named_section_flags (name, flags);
+                 ASM_OUTPUT_SECTION_START (asm_out_file);
+#else
+                 readonly_data_section ();
+#endif
+                 return;
+               }
+
+             named_section_flags (name, flags);
+             return;
+           }
+       }
+    }
+#endif
+  readonly_data_section ();
+}  
+
+/* Tell assembler to switch to the section for constant merging.  */
+
+void
+mergeable_constant_section (mode, align, flags)
+  enum machine_mode mode ATTRIBUTE_UNUSED;
+  unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+  unsigned int flags ATTRIBUTE_UNUSED;
+{
+#ifdef HAVE_GAS_SHF_MERGE
+  unsigned int modesize = GET_MODE_BITSIZE (mode);
+
+  if (flag_merge_constants
+      && mode != VOIDmode
+      && mode != BLKmode
+      && modesize <= align
+      && align >= 8
+      && align <= 256
+      && (align & (align - 1)) == 0)
+    {
+      char name[24];
+
+      sprintf (name, ".rodata.cst%d", (int) (align / 8));
+      flags |= (align / 8) | SECTION_MERGE;
+      named_section_flags (name, flags);
+      return;
+    }            
+#endif
+  readonly_data_section ();
+}
 \f
 /* Given NAME, a putative register name, discard any customary prefixes.  */
 
@@ -3305,13 +3410,19 @@ output_constant_def_contents (exp, reloc, labelno)
 {
   int align;
 
+  /* Align the location counter as required by EXP's data type.  */
+  align = TYPE_ALIGN (TREE_TYPE (exp));
+#ifdef CONSTANT_ALIGNMENT
+  align = CONSTANT_ALIGNMENT (exp, align);
+#endif
+
   if (IN_NAMED_SECTION (exp))
     named_section (exp, NULL, reloc);
   else
     {
       /* First switch to text section, except for writable strings.  */
 #ifdef SELECT_SECTION
-      SELECT_SECTION (exp, reloc);
+      SELECT_SECTION (exp, reloc, align);
 #else
       if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
          || (flag_pic && reloc))
@@ -3321,12 +3432,6 @@ output_constant_def_contents (exp, reloc, labelno)
 #endif
     }
 
-  /* Align the location counter as required by EXP's data type.  */
-  align = TYPE_ALIGN (TREE_TYPE (exp));
-#ifdef CONSTANT_ALIGNMENT
-  align = CONSTANT_ALIGNMENT (exp, align);
-#endif
-
   if (align > BITS_PER_UNIT)
     ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
 
@@ -3877,7 +3982,7 @@ output_constant_pool (fnname, fndecl)
 
       /* First switch to correct section.  */
 #ifdef SELECT_RTX_SECTION
-      SELECT_RTX_SECTION (pool->mode, x);
+      SELECT_RTX_SECTION (pool->mode, x, pool->align);
 #else
       readonly_data_section ();
 #endif
@@ -5060,7 +5165,7 @@ default_elf_asm_named_section (name, flags)
      const char *name;
      unsigned int flags;
 {
-  char flagchars[8], *f = flagchars;
+  char flagchars[10], *f = flagchars;
   const char *type;
 
   if (!(flags & SECTION_DEBUG))
@@ -5071,6 +5176,10 @@ default_elf_asm_named_section (name, flags)
     *f++ = 'x';
   if (flags & SECTION_SMALL)
     *f++ = 's';
+  if (flags & SECTION_MERGE)
+    *f++ = 'M';
+  if (flags & SECTION_STRINGS)
+    *f++ = 'S';
   *f = '\0';
 
   if (flags & SECTION_BSS)
@@ -5078,8 +5187,12 @@ default_elf_asm_named_section (name, flags)
   else
     type = "progbits";
 
-  fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s\n",
-          name, flagchars, type);
+  if (flags & SECTION_ENTSIZE)
+    fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s,%d\n",
+            name, flagchars, type, flags & SECTION_ENTSIZE);
+  else
+    fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s\n",
+            name, flagchars, type);
 }
 
 void