OSDN Git Service

* hooks.c (hook_tree_bool_false): New.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 May 2002 07:43:41 +0000 (07:43 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 May 2002 07:43:41 +0000 (07:43 +0000)
* hooks.h: Declare it.
* target-def.h (TARGET_ASM_SELECT_SECTION): New.
(TARGET_ASM_UNIQUE_SECTION, TARGET_IN_SMALL_DATA_P): New.
* target.h (select_section, unique_section): New.
(in_small_data_p): New.
* varasm.c (resolve_unique_section): Use hooks instead of macros.
(variable_section, output_constant_def_contents): Likewise.
(default_select_section, default_unique_section): New.
(categorize_decl_for_section, default_elf_select_section): New.
* output.h: Declare them.

* config/darwin.h (ALIAS_SECTION, try_section_alias): Remove.
(TARGET_ASM_SELECT_SECTION): New.
(SELECT_SECTION): Move ...
* config/darwin.c (machopic_select_section): ... here.
* config/darwin-protos.h: Update.

* config/nextstep.h (TARGET_ASM_SELECT_SECTION): New.
(SELECT_SECTION): Move ...
* config/nextstep.c (nextstep_select_section): ... here.
* config/nextstep-protos.h: Update.

* config/elfos.h (UNIQUE_SECTION, SELECT_SECTION): Remove.
(TARGET_ASM_SELECT_SECTION): New.
* config/svr3.h (SELECT_SECTION): Remove.

* config/alpha/alpha.c (unicosmk_unique_section): Make static.
(TARGET_ASM_UNIQUE_SECTION) [UNICOS]: New.
(TARGET_IN_SMALL_DATA_P, alpha_in_small_data_p): New.
(alpha_encode_section_info): Use it.
* config/alpha/alpha-protos.h: Update.
* config/alpha/elf.h (DO_SELECT_SECTION): Remove.
(SELECT_SECTION, UNIQUE_SECTION): Remove.
(TARGET_ASM_SELECT_SECTION): New.
* config/alpha/unicosmk.h (UNIQUE_SECTION): Remove.

* config/arm/pe.h (UNIQUE_SECTION): Remove.
(TARGET_ASM_UNIQUE_SECTION): New.

* config/avr/avr.c (TARGET_ASM_UNIQUE_SECTION): New.
(avr_unique_section): Rename from unique_section; make static.
* config/avr/avr-protos.h: Update.
* config/avr/avr.h (UNIQUE_SECTION): Remove.

* config/c4x/c4x.h (SELECT_SECTION): Remove.

* config/i386/cygwin.h (UNIQUE_SECTION): Remove.
(TARGET_ASM_UNIQUE_SECTION): New.
* config/i386/i386-interix.h: Likewise.
* config/i386/win32.h: Likewise.
* config/i386/djgpp.h (UNIQUE_SECTION): Remove.
* config/i386/i386.c (ix86_asm_file_end): Use target hook not macro.
* config/i386/sco5.h (SELECT_SECTION): Remove.
(TARGET_ASM_SELECT_SECTION): New.
* config/i386/svr3gas.h (SELECT_SECTION): Remove.

* config/i860/paragon.h: Undef TARGET_ASM_SELECT_SECTION
instead of SELECT_SECTION.
* config/m68k/dpx2.h: Likewise.
* config/rs6000/lynx.h: Likewise.

* config/ia64/aix.h (SELECT_SECTION, UNIQUE_SECTION): Remove.
(TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New.
* config/ia64/ia64.c (TARGET_IN_SMALL_DATA_P): New.
(ia64_in_small_data_p): New.
(ia64_encode_section_info): Use it.  Reorganize overlarge conditional.
(ia64_aix_select_section, ia64_aix_unique_section): New.
* config/ia64/sysv4.h (DO_SELECT_SECTION): Remove.
(SELECT_SECTION, UNIQUE_SECTION): Remove.

* config/m32r/m32r.h (SELECT_SECTION): Remove.
(TARGET_ASM_SELECT_SECTION): New.
* config/m32r/m32r.c (m32r_select_section): Take align argument.
* config/m32r/m32r-protos.h: Update.

* config/m88k/m88k.h (TARGET_ASM_SELECT_SECTION): New.
(SELECT_SECTION): Move ...
* config/m88k/m88k.c (m88k_select_section): ... here.

* config/mcore/mcore-pe.h (SELECT_SECTION): Remove.
* config/mcore/mcore.h (UNIQUE_SECTION): Remove.
* config/mcore/mcore.c (TARGET_ASM_UNIQUE_SECTION): New.
(mcore_unique_section): Make static.
* config/mcore/mcore-protos.h: Update.

* config/mips/elf.h (UNIQUE_SECTION): Remove.
(TARGET_ASM_UNIQUE_SECTION): New.
* config/mips/elf64.h: Likewise.
* config/mips/iris6gld.h: Likewise.
* config/mips/linux.h: Likewise.
* config/mips/mips-protos.h: Update.
* config/mips/mips.c (mips_select_section): Add align argument.
* config/mips/mips.h (SELECT_SECTION): Remove.
(TARGET_ASM_SELECT_SECTION): New.

* config/mmix/mmix.h (SELECT_SECTION, UNIQUE_SECTION): Remove.
* config/mmix/mmix.c (mmix_select_section): Remove.
(mmix_unique_section): Remove.
* config/mmix/mmix-protos.h: Update.

* config/pa/pa.h (TARGET_ASM_SELECT_SECTION): New.
(SELECT_SECTION): Move ...
* config/pa/pa.c (pa_select_section): ... here.
* config/pa/pa64-hpux.h (UNIQUE_SECTION): Remove.

* config/rs6000/rs6000.c (rs6000_elf_select_section): Rename
from rs6000_select_section and make static.
(rs6000_elf_unique_section): Similarly.
(rs6000_xcoff_select_section): From xcoff.h.
(rs6000_xcoff_unique_section): Likewise.
* config/rs6000/rs6000-protos.h: Update.
* config/rs6000/sysv4.h (SELECT_SECTION, UNIQUE_SECTION): Remove.
(TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New.
* config/rs6000/xcoff.h: Likewise.

* config/sparc/aout.h (TARGET_ASM_SELECT_SECTION): New.
(SELECT_SECTION): Move ...
* config/sparc/sparc.c (sparc_aout_select_section): ... here.

* config/v850/v850.h (SELECT_SECTION): Move ...
* config/v850/v850.c (v850_select_section): ... here.
(TARGET_ASM_SELECT_SECTION): New.

* config/vax/vms.h (SELECT_SECTION): Move ...
* config/vax/vax.c (vms_select_section): ... here.
(TARGET_ASM_SELECT_SECTION): New.

* doc/tm.texi: Update SELECT_SECTION and UNIQUE_SECTION docs
for the target hooks.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53550 138bc75d-0d04-0410-961f-82ee72b054a4

76 files changed:
gcc/ChangeLog
gcc/config/alpha/alpha-interix.h
gcc/config/alpha/alpha-protos.h
gcc/config/alpha/alpha.c
gcc/config/alpha/elf.h
gcc/config/alpha/unicosmk.h
gcc/config/arm/pe.c
gcc/config/arm/pe.h
gcc/config/avr/avr-protos.h
gcc/config/avr/avr.c
gcc/config/avr/avr.h
gcc/config/c4x/c4x.h
gcc/config/d30v/d30v.h
gcc/config/darwin-protos.h
gcc/config/darwin.c
gcc/config/darwin.h
gcc/config/elfos.h
gcc/config/i386/cygwin.h
gcc/config/i386/djgpp.h
gcc/config/i386/i386-interix.h
gcc/config/i386/i386.c
gcc/config/i386/sco5.h
gcc/config/i386/svr3gas.h
gcc/config/i386/win32.h
gcc/config/i386/winnt.c
gcc/config/i860/paragon.h
gcc/config/ia64/aix.h
gcc/config/ia64/ia64.c
gcc/config/ia64/sysv4.h
gcc/config/m32r/m32r-protos.h
gcc/config/m32r/m32r.c
gcc/config/m32r/m32r.h
gcc/config/m68k/dpx2.h
gcc/config/m88k/m88k.c
gcc/config/m88k/m88k.h
gcc/config/mcore/mcore-pe.h
gcc/config/mcore/mcore-protos.h
gcc/config/mcore/mcore.c
gcc/config/mcore/mcore.h
gcc/config/mips/elf.h
gcc/config/mips/elf64.h
gcc/config/mips/iris6gld.h
gcc/config/mips/linux.h
gcc/config/mips/mips-protos.h
gcc/config/mips/mips.c
gcc/config/mips/mips.h
gcc/config/mmix/mmix-protos.h
gcc/config/mmix/mmix.c
gcc/config/mmix/mmix.h
gcc/config/netware.h
gcc/config/nextstep-protos.h
gcc/config/nextstep.c
gcc/config/nextstep.h
gcc/config/pa/pa.c
gcc/config/pa/pa.h
gcc/config/pa/pa64-hpux.h
gcc/config/rs6000/lynx.h
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/sysv4.h
gcc/config/rs6000/xcoff.h
gcc/config/sparc/aout.h
gcc/config/sparc/sparc.c
gcc/config/stormy16/stormy16.h
gcc/config/svr3.h
gcc/config/v850/v850.c
gcc/config/v850/v850.h
gcc/config/vax/vax.c
gcc/config/vax/vms.h
gcc/doc/tm.texi
gcc/hooks.c
gcc/hooks.h
gcc/output.h
gcc/target-def.h
gcc/target.h
gcc/varasm.c

index 76fde3d..e995d62 100644 (file)
@@ -1,3 +1,136 @@
+2002-05-17  Richard Henderson  <rth@redhat.com>
+
+       * hooks.c (hook_tree_bool_false): New.
+       * hooks.h: Declare it.
+       * target-def.h (TARGET_ASM_SELECT_SECTION): New.
+       (TARGET_ASM_UNIQUE_SECTION, TARGET_IN_SMALL_DATA_P): New.
+       * target.h (select_section, unique_section): New.
+       (in_small_data_p): New.
+       * varasm.c (resolve_unique_section): Use hooks instead of macros.
+       (variable_section, output_constant_def_contents): Likewise.
+       (default_select_section, default_unique_section): New.
+       (categorize_decl_for_section, default_elf_select_section): New.
+       * output.h: Declare them.
+
+       * config/darwin.h (ALIAS_SECTION, try_section_alias): Remove.
+       (TARGET_ASM_SELECT_SECTION): New.
+       (SELECT_SECTION): Move ...
+       * config/darwin.c (machopic_select_section): ... here.
+       * config/darwin-protos.h: Update.
+
+       * config/nextstep.h (TARGET_ASM_SELECT_SECTION): New.
+       (SELECT_SECTION): Move ...
+       * config/nextstep.c (nextstep_select_section): ... here.
+       * config/nextstep-protos.h: Update.
+
+       * config/elfos.h (UNIQUE_SECTION, SELECT_SECTION): Remove.
+       (TARGET_ASM_SELECT_SECTION): New.
+       * config/svr3.h (SELECT_SECTION): Remove.
+
+       * config/alpha/alpha.c (unicosmk_unique_section): Make static.
+       (TARGET_ASM_UNIQUE_SECTION) [UNICOS]: New.
+       (TARGET_IN_SMALL_DATA_P, alpha_in_small_data_p): New.
+       (alpha_encode_section_info): Use it.
+       * config/alpha/alpha-protos.h: Update.
+       * config/alpha/elf.h (DO_SELECT_SECTION): Remove.
+       (SELECT_SECTION, UNIQUE_SECTION): Remove.
+       (TARGET_ASM_SELECT_SECTION): New.
+       * config/alpha/unicosmk.h (UNIQUE_SECTION): Remove.
+
+       * config/arm/pe.h (UNIQUE_SECTION): Remove.
+       (TARGET_ASM_UNIQUE_SECTION): New.
+
+       * config/avr/avr.c (TARGET_ASM_UNIQUE_SECTION): New.
+       (avr_unique_section): Rename from unique_section; make static.
+       * config/avr/avr-protos.h: Update.
+       * config/avr/avr.h (UNIQUE_SECTION): Remove.
+
+       * config/c4x/c4x.h (SELECT_SECTION): Remove.
+
+       * config/i386/cygwin.h (UNIQUE_SECTION): Remove.
+       (TARGET_ASM_UNIQUE_SECTION): New.
+       * config/i386/i386-interix.h: Likewise.
+       * config/i386/win32.h: Likewise.
+       * config/i386/djgpp.h (UNIQUE_SECTION): Remove.
+       * config/i386/i386.c (ix86_asm_file_end): Use target hook not macro.
+       * config/i386/sco5.h (SELECT_SECTION): Remove.
+       (TARGET_ASM_SELECT_SECTION): New.
+       * config/i386/svr3gas.h (SELECT_SECTION): Remove.
+
+       * config/i860/paragon.h: Undef TARGET_ASM_SELECT_SECTION
+       instead of SELECT_SECTION.
+       * config/m68k/dpx2.h: Likewise.
+       * config/rs6000/lynx.h: Likewise.
+
+       * config/ia64/aix.h (SELECT_SECTION, UNIQUE_SECTION): Remove.
+       (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New.
+       * config/ia64/ia64.c (TARGET_IN_SMALL_DATA_P): New.
+       (ia64_in_small_data_p): New.
+       (ia64_encode_section_info): Use it.  Reorganize overlarge conditional.
+       (ia64_aix_select_section, ia64_aix_unique_section): New.
+       * config/ia64/sysv4.h (DO_SELECT_SECTION): Remove.
+       (SELECT_SECTION, UNIQUE_SECTION): Remove.
+
+       * config/m32r/m32r.h (SELECT_SECTION): Remove.
+       (TARGET_ASM_SELECT_SECTION): New.
+       * config/m32r/m32r.c (m32r_select_section): Take align argument.
+       * config/m32r/m32r-protos.h: Update.
+
+       * config/m88k/m88k.h (TARGET_ASM_SELECT_SECTION): New.
+       (SELECT_SECTION): Move ...
+       * config/m88k/m88k.c (m88k_select_section): ... here.
+
+       * config/mcore/mcore-pe.h (SELECT_SECTION): Remove.
+       * config/mcore/mcore.h (UNIQUE_SECTION): Remove.
+       * config/mcore/mcore.c (TARGET_ASM_UNIQUE_SECTION): New.
+       (mcore_unique_section): Make static.
+       * config/mcore/mcore-protos.h: Update.
+
+       * config/mips/elf.h (UNIQUE_SECTION): Remove.
+       (TARGET_ASM_UNIQUE_SECTION): New.
+       * config/mips/elf64.h: Likewise.
+       * config/mips/iris6gld.h: Likewise.
+       * config/mips/linux.h: Likewise.
+       * config/mips/mips-protos.h: Update.
+       * config/mips/mips.c (mips_select_section): Add align argument.
+       * config/mips/mips.h (SELECT_SECTION): Remove.
+       (TARGET_ASM_SELECT_SECTION): New.
+
+       * config/mmix/mmix.h (SELECT_SECTION, UNIQUE_SECTION): Remove.
+       * config/mmix/mmix.c (mmix_select_section): Remove.
+       (mmix_unique_section): Remove.
+       * config/mmix/mmix-protos.h: Update.
+
+       * config/pa/pa.h (TARGET_ASM_SELECT_SECTION): New.
+       (SELECT_SECTION): Move ...
+       * config/pa/pa.c (pa_select_section): ... here.
+       * config/pa/pa64-hpux.h (UNIQUE_SECTION): Remove.
+
+       * config/rs6000/rs6000.c (rs6000_elf_select_section): Rename
+       from rs6000_select_section and make static.
+       (rs6000_elf_unique_section): Similarly.
+       (rs6000_xcoff_select_section): From xcoff.h.
+       (rs6000_xcoff_unique_section): Likewise.
+       * config/rs6000/rs6000-protos.h: Update.
+       * config/rs6000/sysv4.h (SELECT_SECTION, UNIQUE_SECTION): Remove.
+       (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New.
+       * config/rs6000/xcoff.h: Likewise.
+
+       * config/sparc/aout.h (TARGET_ASM_SELECT_SECTION): New.
+       (SELECT_SECTION): Move ...
+       * config/sparc/sparc.c (sparc_aout_select_section): ... here.
+
+       * config/v850/v850.h (SELECT_SECTION): Move ...
+       * config/v850/v850.c (v850_select_section): ... here.
+       (TARGET_ASM_SELECT_SECTION): New.
+
+       * config/vax/vms.h (SELECT_SECTION): Move ...
+       * config/vax/vax.c (vms_select_section): ... here.
+       (TARGET_ASM_SELECT_SECTION): New.
+
+       * doc/tm.texi: Update SELECT_SECTION and UNIQUE_SECTION docs
+       for the target hooks.
+
 2002-05-17  Nick Clifton  <nickc@cambridge.redhat.com>
 
        * config/arm/arm.c (emit_multi_reg_push): Do not set
index e7874b0..a1c8cfc 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler, for DEC Alpha
    running Windows/NT.
-   Copyright (C) 1995, 1996, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1999, 2000, 2002 Free Software Foundation, Inc.
 
    Donn Terry, Softway Systems, Inc.
    From code
@@ -67,13 +67,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* The following are needed for C++, but also needed for profiling */
 
-/* Support const sections and the ctors and dtors sections for g++.
-   Note that there appears to be two different ways to support const
-   sections at the moment.  You can either #define the symbol
-   READONLY_DATA_SECTION (giving it some code which switches to the
-   readonly data section) or else you can #define the symbols
-   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
-   SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
+/* Support const sections and the ctors and dtors sections for g++.  */
 
 #define USE_CONST_SECTION      1
 
index 0ccdaaa..f7745a1 100644 (file)
@@ -1,5 +1,5 @@
 /* Prototypes for alpha.c functions used in the md file & elsewhere.
-   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -176,9 +176,6 @@ extern rtx unicosmk_add_call_info_word PARAMS ((rtx));
 #ifdef RTX_CODE
 extern void unicosmk_defer_case_vector PARAMS ((rtx, rtx));
 #endif
-#ifdef TREE_CODE
-extern void unicosmk_unique_section PARAMS ((tree, int));
-#endif
 extern void unicosmk_add_extern PARAMS ((const char *));
 extern void unicosmk_output_align PARAMS ((FILE *, int));
 extern char * unicosmk_text_section PARAMS ((void));
index 281e526..2fb51a2 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines used for code generation on the DEC Alpha.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001 Free Software Foundation, Inc. 
+   2000, 2001, 2002 Free Software Foundation, Inc. 
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 This file is part of GNU CC.
@@ -115,6 +115,8 @@ int alpha_this_gpdisp_sequence_number;
 /* Declarations of static functions.  */
 static bool decl_in_text_section
   PARAMS ((tree));
+static bool alpha_in_small_data_p
+  PARAMS ((tree));
 static int some_small_symbolic_operand_1
   PARAMS ((rtx *, void *));
 static int split_small_symbolic_operand_1
@@ -199,15 +201,21 @@ static void vms_asm_out_destructor PARAMS ((rtx, int));
 # define TARGET_SECTION_TYPE_FLAGS vms_section_type_flags
 #endif
 
+#undef TARGET_IN_SMALL_DATA_P
+#define TARGET_IN_SMALL_DATA_P alpha_in_small_data_p
+
 #if TARGET_ABI_UNICOSMK
 static void unicosmk_asm_named_section PARAMS ((const char *, unsigned int));
 static void unicosmk_insert_attributes PARAMS ((tree, tree *));
 static unsigned int unicosmk_section_type_flags PARAMS ((tree, const char *, 
                                                         int));
+static void unicosmk_unique_section PARAMS ((tree, int));
 # undef TARGET_INSERT_ATTRIBUTES
 # define TARGET_INSERT_ATTRIBUTES unicosmk_insert_attributes
 # undef TARGET_SECTION_TYPE_FLAGS
 # define TARGET_SECTION_TYPE_FLAGS unicosmk_section_type_flags
+# undef TARGET_ASM_UNIQUE_SECTION
+# define TARGET_ASM_UNIQUE_SECTION unicosmk_unique_section
 #endif
 
 #undef TARGET_ASM_ALIGNED_HI_OP
@@ -1552,6 +1560,32 @@ decl_in_text_section (decl)
                    && DECL_ONE_ONLY (decl))));
 }
 
+/* Return true if EXP should be placed in the small data section.  */
+
+static bool
+alpha_in_small_data_p (exp)
+     tree exp;
+{
+  if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp))
+    {
+      const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp));
+      if (strcmp (section, ".sdata") == 0
+         || strcmp (section, ".sbss") == 0)
+       return true;
+    }
+  else
+    {
+      HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
+
+      /* If this is an incomplete type with size 0, then we can't put it
+        in sdata because it might be too big when completed.  */
+      if (size > 0 && size <= g_switch_value)
+       return true;
+    }
+
+  return false;
+}
+
 /* If we are referencing a function that is static, make the SYMBOL_REF
    special.  We use this to see indicate we can branch to this function
    without setting PV or restoring GP. 
@@ -1626,32 +1660,7 @@ alpha_encode_section_info (decl, first)
     is_local = true;
 
   /* Determine if DECL will wind up in .sdata/.sbss.  */
-
-  is_small = false;
-  if (DECL_SECTION_NAME (decl))
-    {
-      const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
-      if (strcmp (section, ".sdata") == 0
-         || strcmp (section, ".sbss") == 0)
-       is_small = true;
-    }
-  else
-    {
-      HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl));
-
-      /* If the variable has already been defined in the output file, then it
-        is too late to put it in sdata if it wasn't put there in the first
-        place.  The test is here rather than above, because if it is already
-        in sdata, then it can stay there.  */
-
-      if (TREE_ASM_WRITTEN (decl))
-       ;
-
-      /* If this is an incomplete type with size 0, then we can't put it in
-        sdata because it might be too big when completed.  */
-      else if (size > 0 && size <= g_switch_value)
-       is_small = true;
-    }
+  is_small = alpha_in_small_data_p (decl);
 
   /* Finally, encode this into the symbol string.  */
   if (is_local)
@@ -8546,7 +8555,7 @@ unicosmk_section_type_flags (decl, name, reloc)
 /* Generate a section name for decl and associate it with the
    declaration.  */
 
-void
+static void
 unicosmk_unique_section (decl, reloc)
       tree decl;
       int reloc ATTRIBUTE_UNUSED;
@@ -8626,7 +8635,7 @@ unicosmk_insert_attributes (decl, attr_ptr)
 {
   if (DECL_P (decl)
       && (TREE_PUBLIC (decl) || TREE_CODE (decl) == FUNCTION_DECL))
-    UNIQUE_SECTION (decl, 0);
+    unicosmk_unique_section (decl, 0);
 }
 
 /* Output an alignment directive. We have to use the macro 'gcc@code@align'
index 22b63f0..5519998 100644 (file)
@@ -191,13 +191,7 @@ do {                                                                       \
 #undef  ASCII_DATA_ASM_OP
 #define ASCII_DATA_ASM_OP      "\t.ascii\t"
 
-/* Support const sections and the ctors and dtors sections for g++.
-   Note that there appears to be two different ways to support const
-   sections at the moment.  You can either #define the symbol
-   READONLY_DATA_SECTION (giving it some code which switches to the
-   readonly data section) or else you can #define the symbols
-   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
-   SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
+/* Support const sections and the ctors and dtors sections for g++.  */
 
 #undef USE_CONST_SECTION
 #define USE_CONST_SECTION      1
@@ -284,161 +278,10 @@ void FN ()                                       \
 
 /* Switch into a generic section.  */
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
-
-/* A C statement or statements to switch to the appropriate
-   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.
-
-   Set SECNUM to:
-       0       .text
-       1       .rodata
-       2       .data
-       3       .sdata
-       4       .bss
-       5       .sbss
-*/
-
-#define DO_SELECT_SECTION(SECNUM, DECL, RELOC)                 \
-  do                                                           \
-     {                                                         \
-       HOST_WIDE_INT size;                                     \
-       SECNUM = 1;                                             \
-       if (TREE_CODE (DECL) == FUNCTION_DECL)                  \
-        {                                                      \
-          SECNUM = 0;                                          \
-          break;                                               \
-        }                                                      \
-       else if (TREE_CODE (DECL) == STRING_CST)                        \
-        {                                                      \
-          if (flag_writable_strings)                           \
-            SECNUM = 2;                                        \
-          else                                                 \
-            SECNUM = 0x101;                                    \
-          break;                                               \
-        }                                                      \
-       else if (TREE_CODE (DECL) == VAR_DECL)                  \
-        {                                                      \
-          if (DECL_INITIAL (DECL) == NULL                      \
-              || DECL_INITIAL (DECL) == error_mark_node)       \
-            SECNUM = 4;                                        \
-          else if ((flag_pic && RELOC)                         \
-                   || ! TREE_READONLY (DECL)                   \
-                   || 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)               \
-        {                                                      \
-          if ((flag_pic && RELOC)                              \
-              || TREE_SIDE_EFFECTS (DECL)                      \
-              || ! TREE_CONSTANT (DECL))                       \
-            SECNUM = 2;                                        \
-        }                                                      \
-                                                               \
-       /* Select small data sections based on size.  */                \
-       size = int_size_in_bytes (TREE_TYPE (DECL));            \
-       if (size >= 0 && size <= g_switch_value)                        \
-        {                                                      \
-          if ((SECNUM & 0xff) >= 2)                            \
-            SECNUM += 1;                                       \
-          /* Move readonly data to .sdata only if -msmall-data.  */ \
-          /* ??? Consider .sdata.{lit4,lit8} as                \
-             SHF_MERGE|SHF_ALPHA_GPREL.  */                    \
-          else if (TARGET_SMALL_DATA)                          \
-            SECNUM = 3;                                        \
-        }                                                      \
-     }                                                         \
-   while (0)
-
-#undef  SELECT_SECTION
-#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 TARGET_ASM_SELECT_SECTION  default_elf_select_section
 
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
 
-#undef  UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL, RELOC)                                    \
-  do                                                                   \
-    {                                                                  \
-      static const char * const prefixes[6][2] =                       \
-      {                                                                        \
-       { ".text.",   ".gnu.linkonce.t." },                             \
-       { ".rodata.", ".gnu.linkonce.r." },                             \
-       { ".data.",   ".gnu.linkonce.d." },                             \
-       { ".sdata.",  ".gnu.linkonce.s." },                             \
-       { ".bss.",    ".gnu.linkonce.b." },                             \
-       { ".sbss.",   ".gnu.linkonce.sb." }                             \
-      };                                                               \
-                                                                       \
-      int nlen, plen, sec;                                             \
-      const char *name, *prefix;                                       \
-      char *string;                                                    \
-                                                                       \
-      DO_SELECT_SECTION (sec, DECL, RELOC);                            \
-                                                                       \
-      name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));          \
-      STRIP_NAME_ENCODING (name, name);                                        \
-      nlen = strlen (name);                                            \
-                                                                       \
-      prefix = prefixes[sec & 0xff][DECL_ONE_ONLY(DECL)];              \
-      plen = strlen (prefix);                                          \
-                                                                       \
-      string = alloca (nlen + plen + 1);                               \
-                                                                       \
-      memcpy (string, prefix, plen);                                   \
-      memcpy (string + plen, name, nlen + 1);                          \
-                                                                       \
-      DECL_SECTION_NAME (DECL) = build_string (nlen + plen, string);   \
-    }                                                                  \
-  while (0)
-
 /* 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
index 4be7be5..6cf19ac 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler, for DEC Alpha on Cray
    T3E running Unicos/Mk.
-   Copyright (C) 2001
+   Copyright (C) 2001, 2002
    Free Software Foundation, Inc.
    Contributed by Roman Lechtchinsky (rl@cs.tu-berlin.de)
 
@@ -380,16 +380,6 @@ ssib_section ()                    \
   in_section = in_ssib;                \
 }
 
-/* A C expression which evaluates to true if declshould be placed into a
-   unique section for some target-specific reason. On Unicos/Mk, functions
-   and public variables are always placed in unique sections.  */ 
-
-/*
-#define UNIQUE_SECTION_P(DECL) (TREE_PUBLIC (DECL)             \
-                               || TREE_CODE (DECL) == FUNCTION_DECL)
-*/
-#define UNIQUE_SECTION(DECL, RELOC) unicosmk_unique_section (DECL, RELOC)
-
 /* This outputs text to go at the start of an assembler file.  */
 
 #undef ASM_FILE_START
index 4069eac..7fb0ed9 100644 (file)
@@ -1,5 +1,5 @@
 /* Routines for GCC for ARM/pe.
-   Copyright (C) 1995, 1996, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Doug Evans (dje@cygnus.com).
 
 This file is part of GNU CC.
@@ -248,8 +248,6 @@ arm_pe_encode_section_info (decl, first)
     }
 }
 
-/* Cover function for UNIQUE_SECTION.  */
-
 void
 arm_pe_unique_section (decl, reloc)
      tree decl;
index 6c4375d..72fa77d 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for ARM with PE obj format.
-   Copyright (C) 1995, 1996, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1999, 2000, 2002 Free Software Foundation, Inc.
    Contributed by Doug Evans (dje@cygnus.com).
    
 This file is part of GNU CC.
@@ -111,7 +111,7 @@ Boston, MA 02111-1307, USA.  */
    symbols must be explicitly imported from shared libraries (DLLs).  */
 #define MULTIPLE_SYMBOL_SPACES
 
-#define UNIQUE_SECTION(DECL, RELOC) arm_pe_unique_section (DECL, RELOC)
+#define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section
 
 #define SUPPORTS_ONE_ONLY 1
 
index fe69e63..1a239d2 100644 (file)
@@ -1,6 +1,6 @@
 /* Prototypes for exported functions defined in avr.c
    
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Denis Chertykov (denisc@overta.ru)
 
    This file is part of GNU CC.
@@ -43,7 +43,6 @@ extern void   gas_output_ascii          PARAMS ((FILE *file, const char *str,
 #ifdef TREE_CODE
 extern void   asm_output_external          PARAMS ((FILE *file, tree decl,
                                                   char *name));
-extern void   unique_section               PARAMS ((tree decl, int reloc));
 extern void   encode_section_info          PARAMS ((tree decl, int));
 extern int    avr_progmem_p                PARAMS ((tree decl));
 
index fe1674d..955f1b1 100644 (file)
@@ -63,6 +63,7 @@ const struct attribute_spec avr_attribute_table[];
 static bool   avr_assemble_integer PARAMS ((rtx, unsigned int, int));
 static void   avr_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
 static void   avr_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
+static void   avr_unique_section PARAMS ((tree, int));
 
 /* Allocate registers from r25 to r8 for parameters for function calls */
 #define FIRST_CUM_REG 26
@@ -196,6 +197,8 @@ int avr_case_values_threshold = 30000;
 #define TARGET_ASM_FUNCTION_EPILOGUE avr_output_function_epilogue
 #undef TARGET_ATTRIBUTE_TABLE
 #define TARGET_ATTRIBUTE_TABLE avr_attribute_table
+#undef TARGET_ASM_UNIQUE_SECTION
+#define TARGET_ASM_UNIQUE_SECTION avr_unique_section
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
@@ -4498,8 +4501,8 @@ avr_assemble_integer (x, size, aligned_p)
 
 /* Sets section name for declaration DECL */
   
-void
-unique_section (decl, reloc)
+static void
+avr_unique_section (decl, reloc)
      tree decl;
      int reloc ATTRIBUTE_UNUSED;
 {
index 66ca80c..dcba856 100644 (file)
@@ -1791,17 +1791,6 @@ progmem_section (void)                                                         \
    If these items should be placed in the text section, this macro
    should not be defined.  */
 
-/* `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
-   initial value of EXP requires link-time relocations.  Select the
-   section by calling `text_section' or one of the alternatives for
-   other sections.
-
-   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, 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
@@ -1842,14 +1831,6 @@ progmem_section (void)                                                         \
    characters that encode section info.  Define this macro if
    `ENCODE_SECTION_INFO' alters the symbol's name string.  */
 
-#define UNIQUE_SECTION(DECL, RELOC) unique_section (DECL, RELOC)
-/* `UNIQUE_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, GNU CC
-   will use the symbol name prefixed by `.' as the section name.  */
-
 #define ASM_FILE_START(STREAM) asm_file_start (STREAM)
 /* A C expression which outputs to the stdio stream STREAM some
    appropriate text to go at the start of an assembler file.
index ba63e3c..04dbe52 100644 (file)
@@ -1738,35 +1738,6 @@ const_section ()                                                 \
 /* Switch into a generic section.  */
 #define TARGET_ASM_NAMED_SECTION c4x_asm_named_section
 
-/* A C statement or statements to switch to the appropriate
-   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, ALIGN)                             \
-{                                                                      \
-  if (TREE_CODE (DECL) == STRING_CST)                                  \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       const_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (DECL) == VAR_DECL)                               \
-    {                                                                  \
-      if ((0 && RELOC) /* Should be (flag_pic && RELOC).  */           \
-         || ! TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)         \
-         || ! DECL_INITIAL (DECL)                                      \
-         || (DECL_INITIAL (DECL) != error_mark_node                    \
-             && ! TREE_CONSTANT (DECL_INITIAL (DECL))))                \
-       data_section ();                                                \
-      else                                                             \
-       const_section ();                                               \
-    }                                                                  \
-  else                                                                 \
-    const_section ();                                                  \
-}
-
 /* The TI assembler wants to have hex numbers this way.  */
 
 #undef HOST_WIDE_INT_PRINT_HEX
index 41eceb5..f13d90c 100644 (file)
@@ -2758,18 +2758,6 @@ extern const char *d30v_branch_cost_string;
 /* #define READONLY_DATA_SECTION */
 
 /* 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 initial value of EXP requires
-   link-time relocations.  Select the section by calling `text_section' or one
-   of the alternatives for other sections.
-
-   Do not define this macro if you put all read-only variables and constants in
-   the read-only data section (usually the text section).
-
-   Defined in svr4.h.  */
-/* #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
    RTL.  The argument MODE is redundant except in the case of a `const_int'
    rtx.  Select the section by calling `text_section' or one of the
@@ -2792,16 +2780,6 @@ extern const char *d30v_branch_cost_string;
    that encode section info.  Define this macro if `ENCODE_SECTION_INFO' alters
    the symbol's name string.  */
 /* #define STRIP_NAME_ENCODING(VAR, SYM_NAME) */
-
-/* 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, GNU CC
-   will use the symbol name prefixed by `.' as the section name.
-
-   Defined in svr4.h.  */
-/* #define UNIQUE_SECTION(DECL, RELOC) */
-
 \f
 /* Position Independent Code.  */
 
index 5a93ca6..9a9c953 100644 (file)
@@ -1,5 +1,5 @@
 /* Prototypes.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -68,6 +68,8 @@ extern void machopic_output_possible_stub_label PARAMS ((FILE *, const char*));
 
 extern void darwin_exception_section PARAMS ((void));
 extern void darwin_eh_frame_section PARAMS ((void));
+extern void machopic_select_section PARAMS ((tree, int,
+                                            unsigned HOST_WIDE_INT));
 
 #ifdef GCC_C_PRAGMA_H
 extern void darwin_pragma_ignore PARAMS ((cpp_reader *));
index f5e9db0..8a3a2da 100644 (file)
@@ -1,5 +1,5 @@
 /* Functions for generic Darwin as target machine for GNU C compiler.
-   Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001
+   Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Contributed by Apple Computer Inc.
 
@@ -1110,6 +1110,134 @@ update_stubs (name)
 }
 
 void
+machopic_select_section (exp, reloc, align)
+     tree exp;
+     int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if (TREE_CODE (exp) == STRING_CST)
+    {
+      if (flag_writable_strings)
+       data_section ();
+      else if (TREE_STRING_LENGTH (exp) !=
+              strlen (TREE_STRING_POINTER (exp)) + 1)
+       readonly_data_section ();
+      else
+       cstring_section ();
+    }
+  else if (TREE_CODE (exp) == INTEGER_CST
+          || TREE_CODE (exp) == REAL_CST)
+    {
+      tree size = TYPE_SIZE (TREE_TYPE (exp));
+
+      if (TREE_CODE (size) == INTEGER_CST &&
+         TREE_INT_CST_LOW (size) == 4 &&
+         TREE_INT_CST_HIGH (size) == 0)
+       literal4_section ();
+      else if (TREE_CODE (size) == INTEGER_CST &&
+              TREE_INT_CST_LOW (size) == 8 &&
+              TREE_INT_CST_HIGH (size) == 0)
+       literal8_section ();
+      else
+       readonly_data_section ();
+    }
+  else if (TREE_CODE (exp) == CONSTRUCTOR
+          && TREE_TYPE (exp)
+          && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
+          && TYPE_NAME (TREE_TYPE (exp)))
+    {
+      tree name = TYPE_NAME (TREE_TYPE (exp));
+      if (TREE_CODE (name) == TYPE_DECL)
+       name = DECL_NAME (name);
+      if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString"))
+       objc_constant_string_object_section ();
+      else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString"))
+       objc_string_object_section ();
+      else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))
+       {
+         if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)
+           const_data_section ();
+         else
+           readonly_data_section ();
+       }
+      else
+       data_section ();
+    }
+  else if (TREE_CODE (exp) == VAR_DECL &&
+          DECL_NAME (exp) &&
+          TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE &&
+          IDENTIFIER_POINTER (DECL_NAME (exp)) &&
+          !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6))
+    {
+      const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));
+
+      if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))
+       objc_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))
+       objc_inst_meth_section ();
+      else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23))
+       objc_cat_inst_meth_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))
+       objc_class_vars_section ();
+      else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))
+       objc_instance_vars_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))
+       objc_class_names_section ();
+      else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))
+       objc_meth_var_names_section ();
+      else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))
+       objc_meth_var_types_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))
+       objc_cls_refs_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_", 12))
+       objc_class_section ();
+      else if (!strncmp (name, "_OBJC_METACLASS_", 16))
+       objc_meta_class_section ();
+      else if (!strncmp (name, "_OBJC_CATEGORY_", 15))
+       objc_category_section ();
+      else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))
+       objc_selector_refs_section ();
+      else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20))
+       objc_selector_fixup_section ();
+      else if (!strncmp (name, "_OBJC_SYMBOLS", 13))
+       objc_symbols_section ();
+      else if (!strncmp (name, "_OBJC_MODULES", 13))
+       objc_module_info_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32))
+       objc_cat_inst_meth_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))
+       objc_protocol_section ();
+      else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))
+              && !TREE_SIDE_EFFECTS (exp))
+       {
+         if (flag_pic && reloc)
+           const_data_section ();
+         else
+           readonly_data_section ();
+       }
+      else
+       data_section ();
+    }
+  else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))
+    {
+      if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)
+       const_data_section ();
+      else
+       readonly_data_section ();
+    }
+  else
+    data_section ();
+}
+
+void
 machopic_asm_out_constructor (symbol, priority)
      rtx symbol;
      int priority ATTRIBUTE_UNUSED;
index c5a078b..19c7a09 100644 (file)
@@ -316,11 +316,6 @@ FUNCTION ()                                                                \
     }                                                                  \
 }                                                                      \
 
-#define ALIAS_SECTION(enum_value, alias_name)                          \
-do { if (!strcmp (alias_name, name))                                   \
-       section_alias[enum_value] = (alias ? get_identifier (alias) : 0);  \
-   } while (0)
-
 /* Darwin uses many types of special sections.  */
 
 #undef EXTRA_SECTIONS
@@ -486,157 +481,13 @@ objc_section_init ()                             \
       objc_module_info_section ();             \
       objc_symbols_section ();                 \
     }                                          \
-}                                              \
-static tree section_alias[(int) num_sections]; \
-static void try_section_alias PARAMS ((void)); \
-static void try_section_alias ()               \
-{                                              \
-    if (section_alias[in_section] && asm_out_file) \
-      fprintf (asm_out_file, "%s\n",           \
-              IDENTIFIER_POINTER (section_alias[in_section])); \
-}                                                      \
-
-#if 0
-static void alias_section PARAMS ((const char *, const char *)); \
-static void alias_section (name, alias)                        \
-     const char *name, *alias;                         \
-{                                                      \
-    ALIAS_SECTION (in_data, "data");                   \
-    ALIAS_SECTION (in_text, "text");                   \
-    ALIAS_SECTION (in_const, "const");                 \
-    ALIAS_SECTION (in_const_data, "const_data");       \
-    ALIAS_SECTION (in_cstring, "cstring");             \
-    ALIAS_SECTION (in_literal4, "literal4");           \
-    ALIAS_SECTION (in_literal8, "literal8");           \
 }
-#endif
 
 #undef READONLY_DATA_SECTION
 #define READONLY_DATA_SECTION const_section
 
-#undef SELECT_SECTION
-#define SELECT_SECTION(exp,reloc,align)                                \
-  do                                                           \
-    {                                                          \
-      if (TREE_CODE (exp) == STRING_CST)                       \
-       {                                                       \
-         if (flag_writable_strings)                            \
-           data_section ();                                    \
-         else if (TREE_STRING_LENGTH (exp) !=                  \
-                  strlen (TREE_STRING_POINTER (exp)) + 1)      \
-           readonly_data_section ();                           \
-         else                                                  \
-           cstring_section ();                                 \
-       }                                                       \
-      else if (TREE_CODE (exp) == INTEGER_CST                  \
-              || TREE_CODE (exp) == REAL_CST)                  \
-        {                                                      \
-         tree size = TYPE_SIZE (TREE_TYPE (exp));              \
-                                                               \
-         if (TREE_CODE (size) == INTEGER_CST &&                \
-             TREE_INT_CST_LOW (size) == 4 &&                   \
-             TREE_INT_CST_HIGH (size) == 0)                    \
-           literal4_section ();                                \
-         else if (TREE_CODE (size) == INTEGER_CST &&           \
-             TREE_INT_CST_LOW (size) == 8 &&                   \
-             TREE_INT_CST_HIGH (size) == 0)                    \
-           literal8_section ();                                \
-         else                                                  \
-           readonly_data_section ();                           \
-       }                                                       \
-      else if (TREE_CODE (exp) == CONSTRUCTOR                          \
-              && TREE_TYPE (exp)                                       \
-              && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE            \
-              && TYPE_NAME (TREE_TYPE (exp)))                          \
-       {                                                               \
-         tree name = TYPE_NAME (TREE_TYPE (exp));                      \
-         if (TREE_CODE (name) == TYPE_DECL)                            \
-           name = DECL_NAME (name);                                    \
-         if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString"))  \
-           objc_constant_string_object_section ();                     \
-         else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \
-           objc_string_object_section ();                              \
-         else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))          \
-           {                                                           \
-             if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)         \
-               const_data_section ();                                  \
-             else                                                      \
-               readonly_data_section ();                               \
-            }                                                          \
-         else                                                          \
-           data_section ();                                            \
-      }                                                                        \
-      else if (TREE_CODE (exp) == VAR_DECL &&                          \
-              DECL_NAME (exp) &&                                       \
-              TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE &&        \
-              IDENTIFIER_POINTER (DECL_NAME (exp)) &&                  \
-              !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
-       {                                                               \
-         const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));      \
-                                                                       \
-         if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))              \
-           objc_cls_meth_section ();                                   \
-         else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))      \
-           objc_inst_meth_section ();                                  \
-         else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
-           objc_cat_inst_meth_section ();                              \
-         else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))       \
-           objc_class_vars_section ();                                 \
-         else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))    \
-           objc_instance_vars_section ();                              \
-         else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))       \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))            \
-           objc_class_names_section ();                                \
-         else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))         \
-           objc_meth_var_names_section ();                             \
-         else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))         \
-           objc_meth_var_types_section ();                             \
-         else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))       \
-           objc_cls_refs_section ();                                   \
-         else if (!strncmp (name, "_OBJC_CLASS_", 12))                 \
-           objc_class_section ();                                      \
-         else if (!strncmp (name, "_OBJC_METACLASS_", 16))             \
-           objc_meta_class_section ();                                 \
-         else if (!strncmp (name, "_OBJC_CATEGORY_", 15))              \
-           objc_category_section ();                                   \
-         else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))    \
-           objc_selector_refs_section ();                              \
-         else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20))         \
-           objc_selector_fixup_section ();                             \
-         else if (!strncmp (name, "_OBJC_SYMBOLS", 13))                \
-           objc_symbols_section ();                                    \
-         else if (!strncmp (name, "_OBJC_MODULES", 13))                \
-           objc_module_info_section ();                                \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
-           objc_cat_inst_meth_section ();                              \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))         \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))              \
-           objc_protocol_section ();                                   \
-         else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))         \
-               && !TREE_SIDE_EFFECTS (exp))                            \
-             { if (flag_pic && reloc ) const_data_section ();             \
-               else readonly_data_section (); }                        \
-         else                                                          \
-           data_section ();                                            \
-       }                                                               \
-      else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))             \
-       {                                                               \
-         if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc)             \
-           const_data_section ();                                      \
-         else                                                          \
-           readonly_data_section ();                                   \
-        }                                                              \
-      else                                                             \
-        data_section ();                                               \
-      try_section_alias ();                                            \
-    }                                                                  \
-  while (0)
+#undef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION machopic_select_section
 
 /* This can be called with address expressions as "rtx".
    They must go in "const". */
index 6b93253..ea11b65 100644 (file)
@@ -1,6 +1,6 @@
 /* elfos.h  --  operating system specific defines to be used when
    targeting GCC for some generic ELF system
-   Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001
+   Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Based on svr4.h contributed by Ron Guilmette (rfg@netcom.com).
 
@@ -216,16 +216,9 @@ Boston, MA 02111-1307, USA.  */
 #undef  ASCII_DATA_ASM_OP
 #define ASCII_DATA_ASM_OP      "\t.ascii\t"
 
-/* Support const sections and the ctors and dtors sections for g++.
-   Note that there appears to be two different ways to support const
-   sections at the moment.  You can either #define the symbol
-   READONLY_DATA_SECTION (giving it some code which switches to the
-   readonly data section) or else you can #define the symbols
-   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
-   SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
+/* Support const sections and the ctors and dtors sections for g++.  */
 
 #define USE_CONST_SECTION      1
-
 #define CONST_SECTION_ASM_OP   "\t.section\t.rodata"
 
 /* On svr4, we *do* have support for the .init and .fini sections, and we
@@ -279,45 +272,6 @@ const_section ()                                           \
 }
 
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-
-#define UNIQUE_SECTION(DECL, RELOC)                            \
-  do                                                           \
-    {                                                          \
-      int len;                                                 \
-      int sec;                                                 \
-      const char *name;                                                \
-      char *string;                                            \
-      const char *prefix;                                      \
-      static const char *const prefixes[4][2] =                        \
-      {                                                                \
-       { ".text.",   ".gnu.linkonce.t." },                     \
-       { ".rodata.", ".gnu.linkonce.r." },                     \
-       { ".data.",   ".gnu.linkonce.d." },                     \
-       { ".bss.",    ".gnu.linkonce.b." }                      \
-      };                                                       \
-                                                               \
-      if (TREE_CODE (DECL) == FUNCTION_DECL)                   \
-       sec = 0;                                                \
-      else if (DECL_INITIAL (DECL) == 0                                \
-              || DECL_INITIAL (DECL) == error_mark_node)       \
-        sec =  3;                                              \
-      else if (DECL_READONLY_SECTION (DECL, RELOC))            \
-       sec = 1;                                                \
-      else                                                     \
-       sec = 2;                                                \
-                                                               \
-      name   = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));        \
-      /* Strip off any encoding in name.  */                   \
-      STRIP_NAME_ENCODING (name, name);                                \
-      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)
      
 /* Switch into a generic section.  */
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
@@ -334,79 +288,8 @@ 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
-   or a constant of some sort.  RELOC indicates whether forming
-   the initial value of DECL requires link-time relocations.  
-   To optimize loading of shared programs, define following subsections
-   of data section by attaching:
-
-   .rel
-     Section with this string in name contains data that do have
-     relocations, so they get grouped together and dynamic linker
-     will visit fewer pages in memory.
-   .ro
-     Marks data read only otherwise.  This is useful with prelinking
-     as most of relocations won't be dynamically linked and thus
-     stay read only.
-   .local
-     Marks data containing relocations only to local objects.  These
-     relocation will get fully resolved by prelinking.
- */
-
-#undef SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC, ALIGN)                     \
-{                                                              \
-  if (TREE_CODE (DECL) == STRING_CST)                          \
-    {                                                          \
-      if (! flag_writable_strings)                             \
-       mergeable_string_section ((DECL), (ALIGN), 0);          \
-      else                                                     \
-       data_section ();                                        \
-    }                                                          \
-  else if (TREE_CODE (DECL) == VAR_DECL)                       \
-    {                                                          \
-      if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)    \
-         || !DECL_INITIAL (DECL)                               \
-         || (DECL_INITIAL (DECL) != error_mark_node            \
-             && !TREE_CONSTANT (DECL_INITIAL (DECL))))         \
-       {                                                       \
-         if (flag_pic && ((RELOC) & 2))                        \
-           named_section (NULL_TREE, ".data.rel", RELOC);      \
-         else if (flag_pic && (RELOC))                         \
-           named_section (NULL_TREE, ".data.rel.local", RELOC);\
-         else                                                  \
-           data_section ();                                    \
-       }                                                       \
-      else if (flag_pic && ((RELOC) & 2))                      \
-       named_section (NULL_TREE, ".data.rel.ro", RELOC);       \
-      else if (flag_pic && (RELOC))                            \
-       named_section (NULL_TREE, ".data.rel.ro.local", RELOC); \
-      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)                    \
-    {                                                          \
-      if ((flag_pic && RELOC)                                  \
-         || TREE_SIDE_EFFECTS (DECL)                           \
-         || ! TREE_CONSTANT (DECL))                            \
-       data_section ();                                        \
-      else                                                     \
-       const_section ();                                       \
-    }                                                          \
-  else                                                         \
-    const_section ();                                          \
-}
+#undef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION default_elf_select_section
 
 /* 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 09d4e69..739977b 100644 (file)
@@ -348,7 +348,7 @@ do {                                                        \
 #define MULTIPLE_SYMBOL_SPACES
 
 extern void i386_pe_unique_section PARAMS ((TREE, int));
-#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
+#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
 
 #define SUPPORTS_ONE_ONLY 1
 
index 6e53e51..c44b55f 100644 (file)
@@ -204,37 +204,3 @@ while (0)
 /* Support for C++ templates.  */
 #undef MAKE_DECL_ONE_ONLY
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-
-#undef UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL,RELOC)                             \
-do {                                                           \
-  int len;                                                     \
-  const char *name, *prefix;                                   \
-  char *string;                                                        \
-                                                               \
-  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));      \
-  /* Strip off any encoding in fnname.  */                      \
-  STRIP_NAME_ENCODING (name, name);                             \
-                                                               \
-  if (! DECL_ONE_ONLY (DECL))                                  \
-    {                                                          \
-      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))                        \
-    prefix = ".gnu.linkonce.r.";                               \
-  else                                                         \
-    prefix = ".gnu.linkonce.d.";                               \
-                                                               \
-  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)
index 1043c5f..680e026 100644 (file)
@@ -234,13 +234,6 @@ Boston, MA 02111-1307, USA.  */
 
 #define EH_FRAME_IN_DATA_SECTION
 
-/* Note that there appears to be two different ways to support const
-   sections at the moment.  You can either #define the symbol
-   READONLY_DATA_SECTION (giving it some code which switches to the
-   readonly data section) or else you can #define the symbols
-   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
-   SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
-
 #define USE_CONST_SECTION      1
 
 #define CONST_SECTION_ASM_OP   "\t.section\t.rdata,\"r\""
@@ -402,8 +395,8 @@ do {                                                                        \
    symbols must be explicitly imported from shared libraries (DLLs).  */
 #define MULTIPLE_SYMBOL_SPACES
 
-extern void i386_pe_unique_section ();
-#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
+extern void i386_pe_unique_section PARAMS ((tree, int));
+#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
 
 #define SUPPORTS_ONE_ONLY 1
 #endif /* 0 */
index 8d939f2..c5250f6 100644 (file)
@@ -3822,7 +3822,7 @@ ix86_asm_file_end (file)
                              get_identifier ("i686.get_pc_thunk"),
                              error_mark_node);
       DECL_ONE_ONLY (decl) = 1;
-      UNIQUE_SECTION (decl, 0);
+      (*targetm.asm_out.unique_section) (decl, 0);
       named_section (decl, NULL);
     }
   else
index 1682eda..0fc1427 100644 (file)
@@ -540,28 +540,9 @@ init_section ()                                                            \
              == void_type_node))) ? (SIZE)                             \
    : 0))
 
-#undef SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
-{                                                                      \
-  if (TARGET_ELF && flag_pic && RELOC)                                 \
-     data_section ();                                                  \
-  else if (TREE_CODE (DECL) == STRING_CST)                             \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       const_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (DECL) == VAR_DECL)                               \
-    {                                                                  \
-      if (! DECL_READONLY_SECTION (DECL, RELOC))                       \
-       data_section ();                                                \
-      else                                                             \
-       const_section ();                                               \
-    }                                                                  \
-  else                                                                 \
-    const_section ();                                                  \
-}
+/* ??? Ignore coff.  */
+#undef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION  default_elf_select_section
 
 #undef SWITCH_TAKES_ARG
 #define SWITCH_TAKES_ARG(CHAR)                                                 \
index 00dd408..489a0dc 100644 (file)
@@ -83,16 +83,7 @@ Boston, MA 02111-1307, USA.  */
    this file should be rewritten to include config/svr3.h
    and override what isn't right.  */
 
-/* Support const sections and the ctors and dtors sections for g++.
-   Note that there appears to be two different ways to support const
-   sections at the moment.  You can either #define the symbol
-   READONLY_DATA_SECTION (giving it some code which switches to the
-   readonly data section) or else you can #define the symbols
-   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
-   SELECT_RTX_SECTION.  We do both here just to be on the safe side.
-   However, use of the const section is turned off by default
-   unless the specific tm.h file turns it on by defining
-   USE_CONST_SECTION as 1.  */
+/* Support const sections and the ctors and dtors sections for g++.  */
 
 #define USE_CONST_SECTION      0
 
@@ -173,35 +164,6 @@ const_section ()                                                   \
 #define TARGET_ASM_CONSTRUCTOR  ix86_svr3_asm_out_constructor
 
 /* A C statement or statements to switch to the appropriate
-   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,ALIGN)                               \
-{                                                                      \
-  if (TREE_CODE (DECL) == STRING_CST)                                  \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       const_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (DECL) == VAR_DECL)                               \
-    {                                                                  \
-      if ((0 && RELOC) /* should be (flag_pic && RELOC) */             \
-         || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
-         || !DECL_INITIAL (DECL)                                       \
-         || (DECL_INITIAL (DECL) != error_mark_node                    \
-             && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
-       data_section ();                                                \
-      else                                                             \
-       const_section ();                                               \
-    }                                                                  \
-  else                                                                 \
-    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
index 561118b..2119a19 100644 (file)
@@ -2,7 +2,7 @@
    hosting on Windows NT 3.x, using a Unix style C library and tools,
    as distinct from winnt.h, which is used to build GCC for use with a
    windows style library and tool set and uses the Microsoft tools.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002
    Free Software Foundation, Inc.
 
 This file is part of GNU CC.
@@ -184,8 +184,8 @@ do {                                                                        \
    symbols must be explicitly imported from shared libraries (DLLs).  */
 #define MULTIPLE_SYMBOL_SPACES
 
-extern void i386_pe_unique_section ();
-#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
+extern void i386_pe_unique_section PARAMS ((tree, int));
+#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
 
 #define SUPPORTS_ONE_ONLY 1
 
index b8bb39e..08f144f 100644 (file)
@@ -1,6 +1,7 @@
 /* Subroutines for insn-output.c for Windows NT.
    Contributed by Douglas Rupp (drupp@cs.washington.edu)
-   Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002
+   Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -423,8 +424,6 @@ i386_pe_encode_section_info (decl, first)
     }
 }
 
-/* Cover function for UNIQUE_SECTION.  */
-
 void
 i386_pe_unique_section (decl, reloc)
      tree decl;
index 6ed94ad..f55b885 100644 (file)
@@ -1,5 +1,5 @@
 /* Target definitions for GNU compiler for Intel 80860 running OSF/1AD
-   Copyright (C) 1991, 1996, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1996, 1999, 2000, 2002 Free Software Foundation, Inc.
    Based upon original work of Ron Guilmette (rfg@monkeys.com).
    Contributed by Andy Pfiffer (andyp@ssd.intel.com).
    Partially inspired by
@@ -181,7 +181,7 @@ Boston, MA 02111-1307, USA.  */
 #undef DTORS_SECTION_ASM_OP
 #undef DO_GLOBAL_CTORS_BODY
 #undef ASM_OUTPUT_DESTRUCTOR
-#undef SELECT_SECTION
+#undef TARGET_ASM_SELECT_SECTION
 #undef SELECT_RTX_SECTION
 #undef READONLY_DATA_SECTION
 
index fee0732..0e66a5d 100644 (file)
@@ -132,47 +132,10 @@ do {                                                      \
 #define STANDARD_STARTFILE_PREFIX "/usr/lib/ia64l64/"
 #endif
 
-/* Override SELECT_SECTION and SELECT_RTX_SECTION from config/ia64/sysv4.h;  
-   these definitions ignore flag_pic as if it were always set; 
-   it is illegal to have relocations in shared segments on AIX.  */
-
-/* A C statement or statements to switch to the appropriate
-   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.  */
-
-#undef SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
-{                                                                      \
-  if (TREE_CODE (DECL) == STRING_CST)                                  \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       const_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (DECL) == VAR_DECL)                               \
-    {                                                                  \
-      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 \
-        only check RELOC if flag_pic is set, and we don't set flag_pic \
-        (yet?).  */                                                    \
-      else if (DECL_READONLY_SECTION (DECL, RELOC) && ! (RELOC))       \
-       const_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  /* 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.  */     \
-  else if (RELOC)                                                       \
-    data_section ();                                                   \
-  else                                                                 \
-    const_section ();                                                  \
-}
-
-/* Similarly for constant pool data.  */
+#undef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION  ia64_aix_select_section
+#undef TARGET_ASM_UNIQUE_SECTION
+#define TARGET_ASM_UNIQUE_SECTION  ia64_aix_unique_section
 
 extern unsigned int ia64_section_threshold;
 #undef SELECT_RTX_SECTION
@@ -187,49 +150,6 @@ extern unsigned int ia64_section_threshold;
     const_section ();                                                  \
 }
 
-#undef UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL, RELOC)                            \
-  do                                                           \
-    {                                                          \
-      int len;                                                 \
-      int sec;                                                 \
-      const char *name;                                                \
-      char *string;                                            \
-      const char *prefix;                                      \
-      static const char *const prefixes[/*4*/3][2] =           \
-      {                                                                \
-       { ".text.",   ".gnu.linkonce.t." },                     \
-       { ".rodata.", ".gnu.linkonce.r." },                     \
-       { ".data.",   ".gnu.linkonce.d." }                      \
-       /* Do not generate unique sections for uninitialised    \
-          data since we do not have support for this in the    \
-          linker scripts yet...                                \
-        ,{ ".bss.",    ".gnu.linkonce.b." }  */                        \
-      };                                                       \
-                                                               \
-      if (TREE_CODE (DECL) == FUNCTION_DECL)                   \
-       sec = 0;                                                \
-  /*  else if (DECL_INITIAL (DECL) == 0                                \
-              || DECL_INITIAL (DECL) == error_mark_node)       \
-        sec =  3; */                                           \
-      else if (DECL_READONLY_SECTION (DECL, RELOC) && ! (RELOC))\
-       sec = 1;                                                \
-      else                                                     \
-       sec = 2;                                                \
-                                                               \
-      name   = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));        \
-      /* Strip off any encoding in name.  */                   \
-      STRIP_NAME_ENCODING (name, name);                                \
-      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)
-
 /* Override ia64/sysv4.h setting with that used by AIX5.  */
 #undef WCHAR_TYPE
 #ifdef __64BIT__
index 562c977..f6f6c55 100644 (file)
@@ -125,6 +125,7 @@ static void ia64_free_machine_status PARAMS ((struct function *));
 static void emit_insn_group_barriers PARAMS ((FILE *, rtx));
 static void emit_all_insn_group_barriers PARAMS ((FILE *, rtx));
 static void emit_predicate_relation_info PARAMS ((void));
+static bool ia64_in_small_data_p PARAMS ((tree));
 static void process_epilogue PARAMS ((void));
 static int process_set PARAMS ((FILE *, rtx));
 
@@ -152,6 +153,11 @@ static int ia64_sched_reorder PARAMS ((FILE *, int, rtx *, int *, int));
 static int ia64_sched_reorder2 PARAMS ((FILE *, int, rtx *, int *, int));
 static int ia64_variable_issue PARAMS ((FILE *, int, rtx, int));
 
+static void ia64_aix_select_section PARAMS ((tree, int,
+                                            unsigned HOST_WIDE_INT))
+     ATTRIBUTE_UNUSED;
+static void ia64_aix_unique_section PARAMS ((tree, int))
+     ATTRIBUTE_UNUSED;
 \f
 /* Table of valid machine attributes.  */
 static const struct attribute_spec ia64_attribute_table[] =
@@ -195,6 +201,9 @@ static const struct attribute_spec ia64_attribute_table[] =
 #undef TARGET_ASM_FUNCTION_EPILOGUE
 #define TARGET_ASM_FUNCTION_EPILOGUE ia64_output_function_epilogue
 
+#undef TARGET_IN_SMALL_DATA_P
+#define TARGET_IN_SMALL_DATA_P  ia64_in_small_data_p
+
 #undef TARGET_SCHED_ADJUST_COST
 #define TARGET_SCHED_ADJUST_COST ia64_adjust_cost
 #undef TARGET_SCHED_ISSUE_RATE
@@ -6858,9 +6867,32 @@ ia64_eh_uses (regno)
    code faster because there is one less load.  This also includes incomplete
    types which can't go in sdata/sbss.  */
 
-/* ??? See select_section.  We must put short own readonly variables in
-   sdata/sbss instead of the more natural rodata, because we can't perform
-   the DECL_READONLY_SECTION test here.  */
+static bool
+ia64_in_small_data_p (exp)
+     tree exp;
+{
+  if (TARGET_NO_SDATA)
+    return false;
+
+  if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp))
+    {
+      const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp));
+      if (strcmp (section, ".sdata") == 0
+         || strcmp (section, ".sbss") == 0)
+       return true;
+    }
+  else
+    {
+      HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
+
+      /* If this is an incomplete type with size 0, then we can't put it
+        in sdata because it might be too big when completed.  */
+      if (size > 0 && size <= ia64_section_threshold)
+       return true;
+    }
+
+  return false;
+}
 
 void
 ia64_encode_section_info (decl, first)
@@ -6868,6 +6900,8 @@ ia64_encode_section_info (decl, first)
      int first ATTRIBUTE_UNUSED;
 {
   const char *symbol_str;
+  bool is_local, is_small;
+  rtx symbol;
 
   if (TREE_CODE (decl) == FUNCTION_DECL)
     {
@@ -6880,76 +6914,64 @@ ia64_encode_section_info (decl, first)
       || GET_CODE (DECL_RTL (decl)) != MEM
       || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
     return;
-    
-  symbol_str = XSTR (XEXP (DECL_RTL (decl), 0), 0);
-
-  /* We assume that -fpic is used only to create a shared library (dso).
-     With -fpic, no global data can ever be sdata.
-     Without -fpic, global common uninitialized data can never be sdata, since
-     it can unify with a real definition in a dso.  */
-  /* ??? Actually, we can put globals in sdata, as long as we don't use gprel
-     to access them.  The linker may then be able to do linker relaxation to
-     optimize references to them.  Currently sdata implies use of gprel.  */
-  /* We need the DECL_EXTERNAL check for C++.  static class data members get
-     both TREE_STATIC and DECL_EXTERNAL set, to indicate that they are
-     statically allocated, but the space is allocated somewhere else.  Such
-     decls can not be own data.  */
-  if (! TARGET_NO_SDATA
-      && ((TREE_STATIC (decl) && ! DECL_EXTERNAL (decl)
-          && ! (DECL_ONE_ONLY (decl) || DECL_WEAK (decl))
-          && ! (TREE_PUBLIC (decl)
-                && (flag_pic
-                    || (DECL_COMMON (decl)
-                        && (DECL_INITIAL (decl) == 0
-                            || DECL_INITIAL (decl) == error_mark_node)))))
-         || MODULE_LOCAL_P (decl))
-      /* Either the variable must be declared without a section attribute,
-        or the section must be sdata or sbss.  */
-      && (DECL_SECTION_NAME (decl) == 0
-         || ! strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
-                      ".sdata")
-         || ! strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
-                      ".sbss")))
-    {
-      HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl));
-
-      /* If the variable has already been defined in the output file, then it
-        is too late to put it in sdata if it wasn't put there in the first
-        place.  The test is here rather than above, because if it is already
-        in sdata, then it can stay there.  */
-
-      if (TREE_ASM_WRITTEN (decl))
-       ;
-
-      /* If this is an incomplete type with size 0, then we can't put it in
-        sdata because it might be too big when completed.
-        Objects bigger than threshold should have SDATA_NAME_FLAG_CHAR
-        added if they are in .sdata or .sbss explicitely.  */
-      else if (((size > 0
-                && size <= (HOST_WIDE_INT) ia64_section_threshold)
-               || DECL_SECTION_NAME (decl))
-              && symbol_str[0] != SDATA_NAME_FLAG_CHAR)
-       {
-         size_t len = strlen (symbol_str);
-         char *newstr = alloca (len + 1);
-         const char *string;
 
-         *newstr = SDATA_NAME_FLAG_CHAR;
-         memcpy (newstr + 1, symbol_str, len + 1);
-         
-         string = ggc_alloc_string (newstr, len + 1);
-         XSTR (XEXP (DECL_RTL (decl), 0), 0) = string;
-       }
-    }
-  /* This decl is marked as being in small data/bss but it shouldn't
-     be; one likely explanation for this is that the decl has been
-     moved into a different section from the one it was in when
-     ENCODE_SECTION_INFO was first called.  Remove the '@'.  */
-  else if (symbol_str[0] == SDATA_NAME_FLAG_CHAR)
+  symbol = XEXP (DECL_RTL (decl), 0);
+  symbol_str = XSTR (symbol, 0);
+
+  /* A variable is considered "local" if it is defined by this module.  */
+
+  if (MODULE_LOCAL_P (decl))
+    is_local = true;
+  /* Otherwise, variables defined outside this object may not be local.  */
+  else if (DECL_EXTERNAL (decl))
+    is_local = false;
+  /* Linkonce and weak data are never local.  */
+  else if (DECL_ONE_ONLY (decl) || DECL_WEAK (decl))
+    is_local = false;
+  /* Static variables are always local.  */
+  else if (! TREE_PUBLIC (decl))
+    is_local = true;
+  /* If PIC, then assume that any global name can be overridden by
+     symbols resolved from other modules.  */
+  else if (flag_pic)
+    is_local = false;
+  /* Uninitialized COMMON variable may be unified with symbols
+     resolved from other modules.  */
+  else if (DECL_COMMON (decl)
+          && (DECL_INITIAL (decl) == NULL
+              || DECL_INITIAL (decl) == error_mark_node))
+    is_local = false;
+  /* Otherwise we're left with initialized (or non-common) global data
+     which is of necessity defined locally.  */
+  else
+    is_local = true;
+
+  /* Determine if DECL will wind up in .sdata/.sbss.  */
+  is_small = ia64_in_small_data_p (decl);
+
+  /* Finally, encode this into the symbol string.  */
+  if (is_local && is_small)
     {
-      XSTR (XEXP (DECL_RTL (decl), 0), 0)
-       = ggc_strdup (symbol_str + 1);
+      char *newstr;
+      size_t len;
+
+      if (symbol_str[0] == SDATA_NAME_FLAG_CHAR)
+       return;
+
+      len = strlen (symbol_str) + 1;
+      newstr = alloca (len + 1);
+      newstr[0] = SDATA_NAME_FLAG_CHAR;
+      memcpy (newstr + 1, symbol_str, len);
+
+      XSTR (symbol, 0) = ggc_alloc_string (newstr, len);
     }
+
+  /* This decl is marked as being in small data/bss but it shouldn't be;
+     one likely explanation for this is that the decl has been moved into
+     a different section from the one it was in when ENCODE_SECTION_INFO
+     was first called.  Remove the '@'.  */
+  else if (symbol_str[0] == SDATA_NAME_FLAG_CHAR)
+    XSTR (symbol, 0) = ggc_strdup (symbol_str + 1);
 }
 \f
 /* Output assembly directives for prologue regions.  */
@@ -7820,3 +7842,29 @@ ia64_hpux_function_arg_padding (mode, type)
        : GET_MODE_BITSIZE (mode) < PARM_BOUNDARY)
       ? downward : upward);
 }
+\f
+/* It is illegal to have relocations in shared segments on AIX.
+   Pretend flag_pic is always set.  */
+
+static void
+ia64_aix_select_section (exp, reloc, align)
+     tree exp;
+     int reloc;
+     unsigned HOST_WIDE_INT align;
+{
+  int save_pic = flag_pic;
+  flag_pic = 1;
+  default_elf_select_section (exp, reloc, align);
+  flag_pic = save_pic;
+}
+
+static void
+ia64_aix_unique_section (decl, reloc)
+     tree decl;
+     int reloc;
+{
+  int save_pic = flag_pic;
+  flag_pic = 1;
+  default_unique_section (decl, reloc);
+  flag_pic = save_pic;
+}
index f4550b6..1f07b8c 100644 (file)
@@ -140,135 +140,6 @@ do {                                                                      \
   emit_safe_across_calls (STREAM);                                     \
 } while (0)
 
-/* A C statement or statements to switch to the appropriate
-   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.
-
-   Set SECNUM to:
-       0       .text
-       1       .rodata
-       2       .data
-       3       .sdata
-       4       .bss
-       5       .sbss
-*/
-#define DO_SELECT_SECTION(SECNUM, DECL, RELOC)                         \
-  do                                                                   \
-    {                                                                  \
-      if (TREE_CODE (DECL) == STRING_CST)                              \
-       {                                                               \
-         if (! flag_writable_strings)                                  \
-           SECNUM = 0x101;                                             \
-         else                                                          \
-           SECNUM = 2;                                                 \
-       }                                                               \
-      else if (TREE_CODE (DECL) == VAR_DECL)                           \
-       {                                                               \
-         if (XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0]                    \
-             == SDATA_NAME_FLAG_CHAR)                                  \
-           SECNUM = 3;                                                 \
-         /* ??? 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))     \
-           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).  */        \
-           SECNUM = 1;                                                 \
-         else if (TREE_CODE (DECL_INITIAL (DECL)) == STRING_CST)       \
-           SECNUM = 0x201;                                             \
-         else                                                          \
-           SECNUM = 0x301;                                             \
-       }                                                               \
-      /* 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.  */  \
-      else if (flag_pic && (RELOC))                                    \
-       SECNUM = 3;                                                     \
-      else                                                             \
-       SECNUM = 2;                                                     \
-    }                                                                  \
-  while (0)
-
-/* We override svr4.h so that we can support the sdata section.  */
-
-#undef SELECT_SECTION
-#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)
-
-#undef  UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL, RELOC)                                    \
-  do                                                                   \
-    {                                                                  \
-      static const char * const prefixes[6][2] =                       \
-      {                                                                        \
-       { ".text.",   ".gnu.linkonce.t." },                             \
-       { ".rodata.", ".gnu.linkonce.r." },                             \
-       { ".data.",   ".gnu.linkonce.d." },                             \
-       { ".sdata.",  ".gnu.linkonce.s." },                             \
-       { ".bss.",    ".gnu.linkonce.b." },                             \
-       { ".sbss.",   ".gnu.linkonce.sb." }                             \
-      };                                                               \
-                                                                       \
-      int nlen, plen, sec;                                             \
-      const char *name, *prefix;                                       \
-      char *string;                                                    \
-                                                                       \
-      DO_SELECT_SECTION (sec, DECL, RELOC);                            \
-                                                                       \
-      name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));          \
-      STRIP_NAME_ENCODING (name, name);                                        \
-      nlen = strlen (name);                                            \
-                                                                       \
-      prefix = prefixes[sec & 0xff][DECL_ONE_ONLY(DECL)];              \
-      plen = strlen (prefix);                                          \
-                                                                       \
-      string = alloca (nlen + plen + 1);                               \
-                                                                       \
-      memcpy (string, prefix, plen);                                   \
-      memcpy (string + plen, name, nlen + 1);                          \
-                                                                       \
-      DECL_SECTION_NAME (DECL) = build_string (nlen + plen, string);   \
-    }                                                                  \
-  while (0)
-
 /* Similarly for constant pool data.  */
 
 extern unsigned int ia64_section_threshold;
index 86adde0..cb8714d 100644 (file)
@@ -1,5 +1,5 @@
 /* Prototypes for m32r.c functions used in the md file & elsewhere.
-   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -33,10 +33,8 @@ extern void   m32r_finalize_pic                      PARAMS ((void));
 extern void   m32r_asm_file_start              PARAMS ((FILE *));
 extern int    direct_return                    PARAMS ((void));
 #ifdef TREE_CODE
-extern void   m32r_select_section              PARAMS ((tree, int));
 extern void   m32r_encode_section_info         PARAMS ((tree, int));
 extern enum m32r_function_type m32r_compute_function_type PARAMS ((tree));
-extern void   m32r_select_section              PARAMS ((tree, int));
 
 #ifdef HAVE_MACHINE_MODES
 extern void   m32r_setup_incoming_varargs      PARAMS ((CUMULATIVE_ARGS *, Mmode, tree, int *, int));
index 32dff3a..4851127 100644 (file)
@@ -74,6 +74,8 @@ static int    m32r_sched_reorder   PARAMS ((FILE *, int, rtx *, int *, int));
 static int    m32r_variable_issue  PARAMS ((FILE *, int, rtx, int));
 static int    m32r_issue_rate     PARAMS ((void));
 
+static void m32r_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT));
+
 \f
 /* Initialize the GCC target structure.  */
 #undef TARGET_ATTRIBUTE_TABLE
@@ -320,10 +322,11 @@ m32r_handle_model_attribute (node, name, args, flags, no_add_attrs)
    or a constant of some sort.  RELOC indicates whether forming
    the initial value of DECL requires link-time relocations.  */
 
-void
-m32r_select_section (decl, reloc)
+static void
+m32r_select_section (decl, reloc, align)
      tree decl;
      int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
 {
   if (TREE_CODE (decl) == STRING_CST)
     {
index 8d9aeeb..f0b783a 100644 (file)
@@ -1567,13 +1567,8 @@ sbss_section ()                                                          \
     }                                                                  \
 }                                                                      \
 
-/* 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 initial value
-   of EXP requires link-time relocations.  */
-#undef  SELECT_SECTION
-#define SELECT_SECTION(EXP, RELOC, ALIGN) \
-  m32r_select_section ((EXP), (RELOC))
+#undef  TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION  m32r_select_section
 
 /* A C statement or statements to switch to the appropriate section for
    output of RTX in mode MODE.  You can assume that RTX
index 06dfd50..fa6557b 100644 (file)
@@ -1,6 +1,7 @@
 /* Definitions of target machine for GNU compiler.  
    Bull DPX/2 200 and 300 systems (m68k, SysVr3).
-   Copyright (C) 1987, 1993, 1994, 1995, 1996, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1993, 1994, 1995, 1996, 1999, 2000, 2002
+   Free Software Foundation, Inc.
    Contributed by Frederic Pierresteguy (F.Pierresteguy@frcl.bull.fr).
 
 This file is part of GNU CC.
@@ -42,7 +43,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Remove handling for a separate constant data section.  We put
    constant data in text_section, which is the default.  */
-#undef SELECT_SECTION
+#undef TARGET_ASM_SELECT_SECTION
 #undef SELECT_RTX_SECTION
 #undef EXTRA_SECTIONS
 #undef EXTRA_SECTION_FUNCTIONS
index 80f3ff4..6fdcf4b 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines for insn-output.c for Motorola 88000.
    Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001 Free Software Foundation, Inc. 
+   2001, 2002 Free Software Foundation, Inc. 
    Contributed by Michael Tiemann (tiemann@mcc.com)
    Currently maintained by (gcc@dg-rtp.dg.com)
 
@@ -71,7 +71,7 @@ static void m88k_output_function_begin_epilogue PARAMS ((FILE *));
 static void m88k_svr3_asm_out_constructor PARAMS ((rtx, int));
 static void m88k_svr3_asm_out_destructor PARAMS ((rtx, int));
 #endif
-
+static void m88k_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT));
 static int m88k_adjust_cost PARAMS ((rtx, rtx, rtx, int));
 \f
 /* Initialize the GCC target structure.  */
@@ -3320,6 +3320,38 @@ m88k_svr3_asm_out_destructor (symbol, priority)
 }
 #endif /* INIT_SECTION_ASM_OP && ! OBJECT_FORMAT_ELF */
 
+static void
+m88k_select_section (decl, reloc, align)
+     tree decl;
+     int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if (TREE_CODE (decl) == STRING_CST)
+    {
+      if (! flag_writable_strings)
+       const_section ();
+      else if (TREE_STRING_LENGTH (decl) <= m88k_gp_threshold)
+       sdata_section ();
+      else
+       data_section ();
+    }
+  else if (TREE_CODE (decl) == VAR_DECL)
+    {
+      if (SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)))
+       sdata_section ();
+      else if ((flag_pic && reloc)
+              || !TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl)
+              || !DECL_INITIAL (decl)
+              || (DECL_INITIAL (decl) != error_mark_node
+                  && !TREE_CONSTANT (DECL_INITIAL (decl))))
+       data_section ();
+      else
+       const_section ();
+    }
+  else
+    const_section ();
+}
+
 /* Adjust the cost of INSN based on the relationship between INSN that
    is dependent on DEP_INSN through the dependence LINK.  The default
    is to make no adjustment to COST.
index 2373b9d..17b6b7b 100644 (file)
@@ -2354,40 +2354,7 @@ sdata_section ()                                                 \
   INIT_SECTION_FUNCTION                                                        \
   FINI_SECTION_FUNCTION
 
-/* A C statement or statements to switch to the appropriate
-   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.
-
-   For strings, the section is selected before the segment info is encoded.  */
-#undef SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
-{                                                                      \
-  if (TREE_CODE (DECL) == STRING_CST)                                  \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       const_section ();                                               \
-      else if ( TREE_STRING_LENGTH (DECL) <= m88k_gp_threshold)                \
-       sdata_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (DECL) == VAR_DECL)                               \
-    {                                                                  \
-      if (SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)))                 \
-       sdata_section ();                                               \
-      else if ((flag_pic && RELOC)                                     \
-              || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)     \
-              || !DECL_INITIAL (DECL)                                  \
-              || (DECL_INITIAL (DECL) != error_mark_node               \
-                  && !TREE_CONSTANT (DECL_INITIAL (DECL))))            \
-       data_section ();                                                \
-      else                                                             \
-       const_section ();                                               \
-    }                                                                  \
-  else                                                                 \
-    const_section ();                                                  \
-}
+#define TARGET_ASM_SELECT_SECTION  m88k_select_section
 
 /* Jump tables consist of branch instructions and should be output in
    the text section.  When we use a table of addresses, we explicitly
index efd9087..5fd3b8d 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for MCore using COFF/PE.
-   Copyright (C) 1994, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1999, 2000, 2002 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com).
 
 This file is part of GNU CC.
@@ -81,35 +81,6 @@ rdata_section ()                                             \
 #define READONLY_DATA_SECTION() rdata_section ()
 
 /* A C statement or statements to switch to the appropriate
-   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.  */
-#undef  SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC, ALIGN)                             \
-{                                                                      \
-  if (TREE_CODE (DECL) == STRING_CST)                                  \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       rdata_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (DECL) == VAR_DECL)                               \
-    {                                                                  \
-      if ((0 && RELOC) /* should be (flag_pic && RELOC) */             \
-         || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
-         || !DECL_INITIAL (DECL)                                       \
-         || (DECL_INITIAL (DECL) != error_mark_node                    \
-             && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
-       data_section ();                                                \
-      else                                                             \
-       rdata_section ();                                               \
-    }                                                                  \
-  else                                                                 \
-    rdata_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
index d6f6e2e..5cda48c 100644 (file)
@@ -1,5 +1,5 @@
 /* Prototypes for exported functions defined in mcore.c
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
    Contributed by Nick Clifton (nickc@redhat.com)
 
 This file is part of GNU CC.
@@ -35,7 +35,6 @@ extern int          mcore_dllimport_name_p            PARAMS ((const char *));
 extern int          mcore_naked_function_p             PARAMS ((void));
 
 #ifdef TREE_CODE
-extern void         mcore_unique_section               PARAMS ((tree, int));
 extern void         mcore_encode_section_info          PARAMS ((tree, int));
 
 #ifdef HAVE_MACHINE_MODES
index 2acd158..f9f5ae2 100644 (file)
@@ -1,5 +1,5 @@
 /* Output routines for Motorola MCore processor
-   Copyright (C) 1993, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -137,6 +137,7 @@ static tree       mcore_handle_naked_attribute PARAMS ((tree *, tree, tree, int,
 static void      mcore_asm_named_section      PARAMS ((const char *,
                                                        unsigned int));
 #endif
+static void       mcore_unique_section        PARAMS ((tree, int));
 \f
 /* Initialize the GCC target structure.  */
 #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
@@ -153,6 +154,8 @@ static void   mcore_asm_named_section      PARAMS ((const char *,
 
 #undef TARGET_ATTRIBUTE_TABLE
 #define TARGET_ATTRIBUTE_TABLE mcore_attribute_table
+#undef TARGET_ASM_UNIQUE_SECTION
+#define TARGET_ASM_UNIQUE_SECTION mcore_unique_section
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
@@ -3511,9 +3514,10 @@ mcore_handle_naked_attribute (node, name, args, flags, no_add_attrs)
   return NULL_TREE;
 }
 
-/* Cover function for UNIQUE_SECTION.  */
+/* ??? It looks like this is PE specific?  Oh well, this is what the
+   old code did as well.  */
 
-void
+static void
 mcore_unique_section (decl, reloc)
      tree decl;
      int reloc ATTRIBUTE_UNUSED;
index 6ef9613..32ceac6 100644 (file)
@@ -1143,9 +1143,6 @@ switch_to_section (section, decl)                         \
 #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \
   (VAR) = MCORE_STRIP_NAME_ENCODING (SYM_NAME)
 
-#undef  UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL, RELOC) mcore_unique_section (DECL, RELOC)
-
 #define MULTIPLE_SYMBOL_SPACES 1
 
 #define SUPPORTS_ONE_ONLY 1
index 5add2f1..d326737 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler.  MIPS R3000 version with
    GOFAST floating point library.
-   Copyright (C) 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -219,9 +219,8 @@ do {                                                                         \
  } while (0)
 
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#undef UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL,RELOC) \
-  mips_unique_section ((DECL), (RELOC))
+
+#define TARGET_ASM_UNIQUE_SECTION  mips_unique_section
 
 /* A list of other sections which the compiler might be "in" at any
    given time.  */
index 1015573..a162fc4 100644 (file)
@@ -1,6 +1,7 @@
 /* Definitions of target machine for GNU compiler.  MIPS R4000 version with
    GOFAST floating point library.
-   Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002
+   Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -208,9 +209,8 @@ do {                                                                         \
  } while (0)
 
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#undef UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL,RELOC) \
-  mips_unique_section ((DECL), (RELOC))
+
+#define TARGET_ASM_UNIQUE_SECTION mips_unique_section
 
 /* A list of other sections which the compiler might be "in" at any
    given time.  */
index addc0f7..75556a0 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler.  Iris version 6 with
    GNU ld.
-   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
    Written by Mark Mitchell <mark@codesourcery.com>.
 
 This file is part of GNU CC.
@@ -49,42 +49,4 @@ Boston, MA 02111-1307, USA.  */
 
 /* The GNU linker supports one-only sections.  */
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION(DECL, RELOC)                            \
-  do                                                           \
-    {                                                          \
-      int len;                                                 \
-      int sec;                                                 \
-      const char *name;                                                \
-      char *string;                                            \
-      const char *prefix;                                      \
-      static const char *const prefixes[/*4*/3][2] =           \
-      {                                                                \
-       { ".text.",   ".gnu.linkonce.t." },                     \
-       { ".rodata.", ".gnu.linkonce.r." },                     \
-       { ".data.",   ".gnu.linkonce.d." }                      \
-       /* Do not generate unique sections for uninitialised    \
-          data since we do not have support for this in the    \
-          linker scripts yet...                                \
-        , { ".bss.",    ".gnu.linkonce.b." }  */               \
-      };                                                       \
-                                                               \
-      if (TREE_CODE (DECL) == FUNCTION_DECL)                   \
-       sec = 0;                                                \
-   /* else if (DECL_INITIAL (DECL) == 0                                \
-              || DECL_INITIAL (DECL) == error_mark_node)       \
-        sec =  3; */                                           \
-      else if (DECL_READONLY_SECTION (DECL, RELOC))            \
-       sec = 1;                                                \
-      else                                                     \
-       sec = 2;                                                \
-                                                               \
-      name   = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));        \
-      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)
+#define TARGET_ASM_UNIQUE_SECTION  mips_unique_section
index 7e2b9ea..755a8c0 100644 (file)
@@ -88,9 +88,7 @@ do {                                                          \
     mips_declare_object (FILE, NAME, "", ":\n", 0);            \
   } while (0)
 
-#undef UNIQUE_SECTION
-#define UNIQUE_SECTION(DECL,RELOC) \
-  mips_unique_section ((DECL), (RELOC))
+#define TARGET_ASM_UNIQUE_SECTION  mips_unique_section
 
 /* A list of other sections which the compiler might be "in" at any
    given time.  */
index 29854f0..2158a02 100644 (file)
@@ -1,6 +1,6 @@
 /* Prototypes of target machine for GNU compiler.  MIPS version.
    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2001 Free Software Foundation, Inc.
+   1999, 2001, 2002 Free Software Foundation, Inc.
    Contributed by A. Lichnewsky (lich@inria.inria.fr).
    Changed by Michael Meissner (meissner@osf.org).
    64 bit r4000 support by Ian Lance Taylor (ian@cygnus.com) and
@@ -79,8 +79,6 @@ extern int            mips_output_external PARAMS ((FILE *, tree,
 extern tree            mips_build_va_list PARAMS ((void));
 extern void            mips_va_start PARAMS ((int, tree, rtx));
 extern struct rtx_def  *mips_va_arg PARAMS ((tree, tree));
-extern void            mips_select_section PARAMS ((tree, int));
-extern void            mips_unique_section PARAMS ((tree, int));
 
 extern void            expand_block_move PARAMS ((rtx *));
 extern void            final_prescan_insn PARAMS ((rtx, rtx *, int));
index 72f3325..b93e531 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines for insn-output.c for MIPS
    Copyright (C) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by A. Lichnewsky, lich@inria.inria.fr.
    Changes by Michael Meissner, meissner@osf.org.
    64 bit r4000 support by Ian Lance Taylor, ian@cygnus.com, and
@@ -146,6 +146,11 @@ static int mips_issue_rate                 PARAMS ((void));
 static void mips_init_machine_status           PARAMS ((struct function *));
 static void mips_free_machine_status           PARAMS ((struct function *));
 static void mips_mark_machine_status           PARAMS ((struct function *));
+static void mips_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT))
+       ATTRIBUTE_UNUSED;
+static void mips_unique_section                        PARAMS ((tree, int))
+       ATTRIBUTE_UNUSED;
+
 
 struct machine_function {
   /* Pseudo-reg holding the address of the current function when
@@ -7943,10 +7948,11 @@ mips_select_rtx_section (mode, x)
    If you need to make a change here, you probably should check
    ENCODE_SECTION_INFO to see if it needs a similar change.  */
 
-void
-mips_select_section (decl, reloc)
+static void
+mips_select_section (decl, reloc, align)
      tree decl;
      int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
 {
   int size = int_size_in_bytes (TREE_TYPE (decl));
 
@@ -10145,9 +10151,10 @@ mips_adjust_cost (insn, link, dep, cost)
   return cost;
 }
 
-/* Cover function for UNIQUE_SECTION.  */
+/* ??? This could be replaced with the default elf version if
+   TARGET_IS_SMALL_DATA_P is set properly.  */
 
-void
+static void
 mips_unique_section (decl, reloc)
      tree decl;
      int reloc;
index a6467c0..dba54e6 100644 (file)
@@ -4738,10 +4738,8 @@ rdata_section ()                                                 \
 #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \
   mips_select_rtx_section (MODE, RTX)
 
-#undef SELECT_SECTION
-#define SELECT_SECTION(DECL, RELOC, ALIGN) \
-  mips_select_section (DECL, RELOC)
-
+#undef  TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION  mips_select_section
 \f
 /* Store in OUTPUT a string (made with alloca) containing
    an assembler-name for a local static variable named NAME.
index eb9c24c..cc81308 100644 (file)
@@ -74,9 +74,7 @@ extern int mmix_constant_alignment PARAMS ((tree, int));
 extern int mmix_local_alignment PARAMS ((tree, int));
 extern void mmix_setup_incoming_varargs
   PARAMS ((CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int));
-extern void mmix_select_section PARAMS ((tree, int, int));
 extern void mmix_encode_section_info PARAMS ((tree, int));
-extern void mmix_unique_section PARAMS ((tree, int));
 extern void mmix_asm_output_pool_prologue
   PARAMS ((FILE *, const char *, tree, int));
 extern void mmix_asm_output_aligned_common
index af06624..40bd94f 100644 (file)
@@ -1713,46 +1713,6 @@ mmix_data_section_asm_op ()
   return "\t.data ! mmixal:= 8H LOC 9B";
 }
 
-/* SELECT_SECTION.
-   The meat is from elfos.h, which we will eventually consider using.  */
-
-void
-mmix_select_section (decl, reloc, align)
-     tree decl;
-     int reloc;
-     int align ATTRIBUTE_UNUSED;
-{
-  if (TREE_CODE (decl) == STRING_CST)
-    {
-      if (! flag_writable_strings)
-       const_section ();
-      else
-       data_section ();
-    }
-  else if (TREE_CODE (decl) == VAR_DECL)
-    {
-      if ((flag_pic && reloc)
-         || !TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl)
-         || !DECL_INITIAL (decl)
-         || (DECL_INITIAL (decl) != error_mark_node
-             && !TREE_CONSTANT (DECL_INITIAL (decl))))
-       data_section ();
-      else
-       const_section ();
-    }
-  else if (TREE_CODE (decl) == CONSTRUCTOR)
-    {
-      if ((flag_pic && reloc)
-         || !TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl)
-         || ! TREE_CONSTANT (decl))
-       data_section ();
-      else
-       const_section ();
-    }
-  else
-    const_section ();
-}
-
 /* ENCODE_SECTION_INFO.  */
 
 void
@@ -1818,49 +1778,6 @@ mmix_strip_name_encoding (name)
   return name;
 }
 
-/* UNIQUE_SECTION.
-   The meat is from elfos.h, which we should consider using.  */
-
-void
-mmix_unique_section (decl, reloc)
-     tree decl;
-     int reloc;
-{
-  int len;
-  int sec;
-  const char *name;
-  char *string;
-  const char *prefix;
-  static const char *const prefixes[4][2] =
-  {
-    { ".text.",   ".gnu.linkonce.t." },
-    { ".rodata.", ".gnu.linkonce.r." },
-    { ".data.",   ".gnu.linkonce.d." },
-    { ".bss.",    ".gnu.linkonce.b." }
-  };
-
-  if (TREE_CODE (decl) == FUNCTION_DECL)
-    sec = 0;
-  else if (DECL_INITIAL (decl) == 0
-          || DECL_INITIAL (decl) == error_mark_node)
-    sec =  3;
-  else if (DECL_READONLY_SECTION (decl, reloc))
-    sec = 1;
-  else
-    sec = 2;
-
-  name   = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-  /* Strip off any encoding in name.  */
-  STRIP_NAME_ENCODING (name, name);
-  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);
-}
-
 /* ASM_FILE_START.  */
 
 void
index 3abfe29..c603ebb 100644 (file)
@@ -929,18 +929,12 @@ const_section ()                                          \
 #undef  SELECT_RTX_SECTION
 #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) const_section ()
 
-#define SELECT_SECTION(DECL, RELOC, ALIGN) \
- mmix_select_section (DECL, RELOC, ALIGN)
-
 #define ENCODE_SECTION_INFO(DECL, FIRST) \
  mmix_encode_section_info (DECL, FIRST)
 
 #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \
  (VAR) = mmix_strip_name_encoding (SYM_NAME)
 
-#define UNIQUE_SECTION(DECL, RELOC) \
-  mmix_unique_section (decl, reloc)
-
 /* Node: PIC */
 /* (empty) */
 
index 129fa39..dbb2477 100644 (file)
@@ -1,6 +1,6 @@
 /* netware.h -- operating system specific defines to be used when 
    targeting GCC for some generic NetWare 4 system.
-   Copyright (C) 1993, 1994, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 2000, 2001, 2002 Free Software Foundation, Inc.
 
    Written by David V. Henkel-Wallace (gumby@cygnus.com)
 
@@ -56,13 +56,7 @@ Boston, MA 02111-1307, USA.  */
 #undef PREFERRED_DEBUGGING_TYPE
 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
 
-/* Support const sections and the ctors and dtors sections for g++.
-   Note that there appears to be two different ways to support const
-   sections at the moment.  You can either #define the symbol
-   READONLY_DATA_SECTION (giving it some code which switches to the
-   readonly data section) or else you can #define the symbols
-   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
-   SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
+/* Support const sections and the ctors and dtors sections for g++.  */
 
 #undef HAS_INIT_SECTION
 #undef INIT_SECTION_ASM_OP
index 1f86e1d..e5b520d 100644 (file)
@@ -1,6 +1,6 @@
 /* Operating system specific defines to be used when targeting GCC
    for NeXTSTEP.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -26,3 +26,5 @@ extern void constructor_section PARAMS ((void));
 extern void destructor_section PARAMS ((void));
 extern void nextstep_exception_section PARAMS ((void));
 extern void nextstep_eh_frame_section PARAMS ((void));
+extern void nextstep_select_section PARAMS ((tree, int,
+                                            unsigned HOST_WIDE_INT));
index 228c566..a701776 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions for generic NeXT as target machine for GNU C compiler.
    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997, 1998,
-   2000 Free Software Foundation, Inc.
+   2000, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -115,3 +115,123 @@ nextstep_asm_out_destructor (symbol, priority)
   fprintf (asm_out_file, ".reference .destructors_used\n");
 }
 
+void
+nextstep_select_section (exp, reloc, align)
+     tree exp;
+     int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if (TREE_CODE (exp) == STRING_CST)
+    {
+      if (flag_writable_strings)
+       data_section ();
+      else if (TREE_STRING_LENGTH (exp)
+              != strlen (TREE_STRING_POINTER (exp)) + 1)
+       readonly_data_section ();
+      else
+       cstring_section ();
+    }
+  else if (TREE_CODE (exp) == INTEGER_CST
+          || TREE_CODE (exp) == REAL_CST)
+    {
+      tree size = TYPE_SIZE (TREE_TYPE (exp));
+      HOST_WIDE_INT size_int;
+
+      if (TREE_CODE (size) == INTEGER_CST)
+       size_int = tree_low_cst (size, 1);
+      else
+       size_int = 0;
+
+      if (size_int == 4)
+       literal4_section ();
+      else if (size_int == 8)
+       literal8_section ();
+      else
+       readonly_data_section ();
+    }
+  else if (TREE_CODE (exp) == CONSTRUCTOR
+          && TREE_TYPE (exp)
+          && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
+          && TYPE_NAME (TREE_TYPE (exp))
+          && TREE_CODE (TYPE_NAME (TREE_TYPE (exp))) == IDENTIFIER_NODE
+          && IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))))
+    {
+      if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))),
+                  "NXConstantString"))
+       objc_string_object_section ();
+      else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))
+              && !TREE_SIDE_EFFECTS (exp))
+       readonly_data_section ();
+      else
+       data_section ();
+    }
+  else if (TREE_CODE (exp) == VAR_DECL
+          && DECL_NAME (exp)
+          && TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE
+          && IDENTIFIER_POINTER (DECL_NAME (exp))
+          && !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6))
+    {
+      const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));
+
+      if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))
+       objc_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))
+       objc_inst_meth_section ();
+      else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23))
+       objc_cat_inst_meth_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))
+       objc_class_vars_section ();
+      else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))
+       objc_instance_vars_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))
+       objc_class_names_section ();
+      else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))
+       objc_meth_var_names_section ();
+      else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))
+       objc_meth_var_types_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))
+       objc_cls_refs_section ();
+      else if (!strncmp (name, "_OBJC_CLASS_", 12))
+       objc_class_section ();
+      else if (!strncmp (name, "_OBJC_METACLASS_", 16))
+       objc_meta_class_section ();
+      else if (!strncmp (name, "_OBJC_CATEGORY_", 15))
+       objc_category_section ();
+      else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))
+       objc_selector_refs_section ();
+      else if (!strncmp (name, "_OBJC_SYMBOLS", 13))
+       objc_symbols_section ();
+      else if (!strncmp (name, "_OBJC_MODULES", 13))
+       objc_module_info_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32))
+       objc_cat_inst_meth_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))
+       objc_cat_cls_meth_section ();
+      else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))
+       objc_protocol_section ();
+      else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))
+              && !TREE_SIDE_EFFECTS (exp))
+       readonly_data_section ();
+      else
+       data_section ();
+    }
+  else if (TREE_CODE (exp) == VAR_DECL)
+    {
+      if ((flag_pic && reloc)
+         || !TREE_READONLY (exp) || TREE_SIDE_EFFECTS (exp)
+         || !DECL_INITIAL (exp)
+         || (DECL_INITIAL (exp) != error_mark_node
+             && !TREE_CONSTANT (DECL_INITIAL (exp))))
+       data_section ();
+      else
+       readonly_data_section ();
+    }
+  else
+    readonly_data_section ();
+}
index 850f0e6..b96e365 100644 (file)
@@ -1,7 +1,7 @@
 /* Operating system specific defines to be used when targeting GCC
    for NeXTSTEP.
    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997,
-   1999 Free Software Foundation, Inc.
+   1999, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -442,123 +442,8 @@ objc_section_init ()                              \
 #undef READONLY_DATA_SECTION
 #define READONLY_DATA_SECTION const_section
 
-#undef SELECT_SECTION
-#define SELECT_SECTION(exp,reloc,align)                                \
-  do                                                           \
-    {                                                          \
-      if (TREE_CODE (exp) == STRING_CST)                       \
-       {                                                       \
-         if (flag_writable_strings)                            \
-           data_section ();                                    \
-         else if (TREE_STRING_LENGTH (exp) !=                  \
-                  strlen (TREE_STRING_POINTER (exp)) + 1)      \
-           readonly_data_section ();                           \
-         else                                                  \
-           cstring_section ();                                 \
-       }                                                       \
-      else if (TREE_CODE (exp) == INTEGER_CST                  \
-              || TREE_CODE (exp) == REAL_CST)                  \
-        {                                                      \
-         tree size = TYPE_SIZE (TREE_TYPE (exp));              \
-                                                               \
-         if (TREE_CODE (size) == INTEGER_CST &&                \
-             TREE_INT_CST_LOW (size) == 4 &&                   \
-             TREE_INT_CST_HIGH (size) == 0)                    \
-           literal4_section ();                                \
-         else if (TREE_CODE (size) == INTEGER_CST &&           \
-             TREE_INT_CST_LOW (size) == 8 &&                   \
-             TREE_INT_CST_HIGH (size) == 0)                    \
-           literal8_section ();                                \
-         else                                                  \
-           readonly_data_section ();                           \
-       }                                                       \
-      else if (TREE_CODE (exp) == CONSTRUCTOR                          \
-              && TREE_TYPE (exp)                                       \
-              && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE            \
-              && TYPE_NAME (TREE_TYPE (exp))                           \
-              && TREE_CODE (TYPE_NAME (TREE_TYPE (exp))) == IDENTIFIER_NODE \
-              && IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))))     \
-       {                                                               \
-         if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))), \
-                       "NXConstantString"))                            \
-         objc_string_object_section ();                                \
-       else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))           \
-               && !TREE_SIDE_EFFECTS (exp))                            \
-         readonly_data_section ();                                     \
-       else                                                            \
-         data_section ();                                              \
-      }                                                                        \
-      else if (TREE_CODE (exp) == VAR_DECL &&                          \
-              DECL_NAME (exp) &&                                       \
-              TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE &&        \
-              IDENTIFIER_POINTER (DECL_NAME (exp)) &&                  \
-              !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
-       {                                                               \
-         const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));      \
-                                                                       \
-         if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))              \
-           objc_cls_meth_section ();                                   \
-         else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))      \
-           objc_inst_meth_section ();                                  \
-         else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
-           objc_cat_inst_meth_section ();                              \
-         else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))       \
-           objc_class_vars_section ();                                 \
-         else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))    \
-           objc_instance_vars_section ();                              \
-         else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))       \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))            \
-           objc_class_names_section ();                                \
-         else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))         \
-           objc_meth_var_names_section ();                             \
-         else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))         \
-           objc_meth_var_types_section ();                             \
-         else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))       \
-           objc_cls_refs_section ();                                   \
-         else if (!strncmp (name, "_OBJC_CLASS_", 12))                 \
-           objc_class_section ();                                      \
-         else if (!strncmp (name, "_OBJC_METACLASS_", 16))             \
-           objc_meta_class_section ();                                 \
-         else if (!strncmp (name, "_OBJC_CATEGORY_", 15))              \
-           objc_category_section ();                                   \
-         else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))    \
-           objc_selector_refs_section ();                              \
-         else if (!strncmp (name, "_OBJC_SYMBOLS", 13))                \
-           objc_symbols_section ();                                    \
-         else if (!strncmp (name, "_OBJC_MODULES", 13))                \
-           objc_module_info_section ();                                \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \
-           objc_cat_inst_meth_section ();                              \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))         \
-           objc_cat_cls_meth_section ();                               \
-         else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))              \
-           objc_protocol_section ();                                   \
-         else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))         \
-               && !TREE_SIDE_EFFECTS (exp))                            \
-           readonly_data_section ();                                   \
-         else                                                          \
-           data_section ();                                            \
-       }                                                               \
-      else if (TREE_CODE (exp) == VAR_DECL)                            \
-       {                                                               \
-         if ((flag_pic && reloc)                                       \
-             || !TREE_READONLY (exp) || TREE_SIDE_EFFECTS (exp)        \
-             || !DECL_INITIAL (exp)                                    \
-             || (DECL_INITIAL (exp) != error_mark_node                 \
-                 && !TREE_CONSTANT (DECL_INITIAL (exp))))              \
-           data_section ();                                            \
-         else                                                          \
-           readonly_data_section ();                                   \
-       }                                                               \
-      else                                                             \
-       readonly_data_section ();                                       \
-    }                                                                  \
-  while (0)
+#undef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION nextstep_select_section
 
 #undef SELECT_RTX_SECTION
 #define SELECT_RTX_SECTION(mode, rtx, align)                           \
index 8e93194..babf1a8 100644 (file)
@@ -114,6 +114,8 @@ static void pa_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
 static int pa_adjust_cost PARAMS ((rtx, rtx, rtx, int));
 static int pa_adjust_priority PARAMS ((rtx, int));
 static int pa_issue_rate PARAMS ((void));
+static void pa_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT))
+     ATTRIBUTE_UNUSED;
 
 /* Save the operands last given to a compare for use when we
    generate a scc or bcc insn.  */
@@ -7566,3 +7568,30 @@ pa_add_gc_roots ()
   ggc_add_root (&deferred_plabels, 1, sizeof (&deferred_plabels),
                &mark_deferred_plabels);
 }
+
+/* On hpux10, the linker will give an error if we have a reference
+   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.  */
+
+static void
+pa_select_section (exp, reloc, align)
+     tree exp;
+     int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if (TREE_CODE (exp) == VAR_DECL
+      && TREE_READONLY (exp)
+      && !TREE_THIS_VOLATILE (exp)
+      && DECL_INITIAL (exp)
+      && (DECL_INITIAL (exp) == error_mark_node
+          || TREE_CONSTANT (DECL_INITIAL (exp)))
+      && !reloc)
+    readonly_data_section ();
+  else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c'
+          && !(TREE_CODE (exp) == STRING_CST && flag_writable_strings)
+          && !reloc)
+    readonly_data_section ();
+  else
+    data_section ();
+}
index b4f0768..af19b64 100644 (file)
@@ -1503,25 +1503,7 @@ do {                                                                     \
   else                                 \
     readonly_data_section ();
 
-/* On hpux10, the linker will give an error if we have a reference
-   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,ALIGN) \
-  if (TREE_CODE (EXP) == VAR_DECL \
-      && TREE_READONLY (EXP) \
-      && !TREE_THIS_VOLATILE (EXP) \
-      && DECL_INITIAL (EXP) \
-      && (DECL_INITIAL (EXP) == error_mark_node \
-          || TREE_CONSTANT (DECL_INITIAL (EXP))) \
-      && !RELOC) \
-    readonly_data_section (); \
-  else if (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'c' \
-          && !(TREE_CODE (EXP) == STRING_CST && flag_writable_strings) \
-          && !RELOC) \
-    readonly_data_section (); \
-  else \
-    data_section ();
+#define TARGET_ASM_SELECT_SECTION  pa_select_section
    
 /* Define this macro if references to a symbol must be treated
    differently depending on something about the variable or
index c4a6b27..4469e37 100644 (file)
@@ -171,36 +171,6 @@ const_section ()                                                   \
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
 
 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION(DECL,RELOC)                             \
-do {                                                           \
-  int len;                                                     \
-  char *string;                                                        \
-  const char *prefix,                                          \
-    *const name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));\
-                                                               \
-  if (! DECL_ONE_ONLY (DECL))                                  \
-    {                                                          \
-      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))                        \
-    prefix = ".gnu.linkonce.r.";                               \
-  else                                                         \
-    prefix = ".gnu.linkonce.d.";                               \
-                                                               \
-  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)
 
 /* 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 5a859ca..5416abb 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions for Rs6000 running LynxOS.
-   Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2000, 2002 Free Software Foundation, Inc.
    Contributed by David Henkel-Wallace, Cygnus Support (gumby@cygnus.com)
 
 This file is part of GNU CC.
@@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA.  */
 #undef READONLY_DATA_SECTION
 #undef EXTRA_SECTION_FUNCTIONS
 #undef SELECT_RTX_SECTION
-#undef SELECT_SECTION
+#undef TARGET_ASM_SELECT_SECTION
 #undef USER_LABEL_PREFIX
 #undef ASM_OUTPUT_LABELREF
 #undef ASM_OUTPUT_INTERNAL_LABEL
index 9543663..06114d3 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for IBM RS/6000.
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 This file is part of GNU CC.
@@ -148,8 +148,6 @@ extern void setup_incoming_varargs PARAMS ((CUMULATIVE_ARGS *,
 extern struct rtx_def *rs6000_va_arg PARAMS ((tree, tree));
 extern void output_mi_thunk PARAMS ((FILE *, tree, int, tree));
 extern void rs6000_encode_section_info PARAMS ((tree, int));
-extern void rs6000_select_section PARAMS ((tree, int));
-extern void rs6000_unique_section PARAMS ((tree, int));
 #ifdef ARGS_SIZE_RTX
 /* expr.h defines ARGS_SIZE_RTX and `enum direction' */
 extern enum direction function_arg_padding PARAMS ((enum machine_mode, tree));
index 44e70db..e803e2e 100644 (file)
@@ -163,9 +163,15 @@ static unsigned int rs6000_elf_section_type_flags PARAMS ((tree, const char *,
                                                           int));
 static void rs6000_elf_asm_out_constructor PARAMS ((rtx, int));
 static void rs6000_elf_asm_out_destructor PARAMS ((rtx, int));
+static void rs6000_elf_select_section PARAMS ((tree, int,
+                                                unsigned HOST_WIDE_INT));
+static void rs6000_elf_unique_section PARAMS ((tree, int));
 #endif
 #ifdef OBJECT_FORMAT_COFF
 static void xcoff_asm_named_section PARAMS ((const char *, unsigned int));
+static void rs6000_xcoff_select_section PARAMS ((tree, int,
+                                                unsigned HOST_WIDE_INT));
+static void rs6000_xcoff_unique_section PARAMS ((tree, int));
 #endif
 static int rs6000_adjust_cost PARAMS ((rtx, rtx, rtx, int));
 static int rs6000_adjust_priority PARAMS ((rtx, int));
@@ -10954,10 +10960,11 @@ rs6000_select_rtx_section (mode, x)
    or a constant of some sort.  RELOC indicates whether forming
    the initial value of DECL requires link-time relocations.  */
 
-void
-rs6000_select_section (decl, reloc)
+static void
+rs6000_elf_select_section (decl, reloc, align)
      tree decl;
      int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
 {
   int size = int_size_in_bytes (TREE_TYPE (decl));
   int needs_sdata;
@@ -11003,8 +11010,8 @@ rs6000_select_section (decl, reloc)
    macro can now be called for uninitialized data items as well as
    initialised data and functions.  */
 
-void
-rs6000_unique_section (decl, reloc)
+static void
+rs6000_elf_unique_section (decl, reloc)
      tree decl;
      int reloc;
 {
@@ -11628,4 +11635,52 @@ xcoff_asm_named_section (name, flags)
 {
   fprintf (asm_out_file, "\t.csect %s\n", name);
 }
+
+static void
+rs6000_xcoff_select_section (exp, reloc, align)
+     tree exp;
+     int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if ((TREE_CODE (exp) == STRING_CST
+       && ! flag_writable_strings)
+      || (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd'
+         && TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp)
+         && DECL_INITIAL (exp)
+         && (DECL_INITIAL (exp) == error_mark_node
+             || TREE_CONSTANT (DECL_INITIAL (exp)))
+         && ! (reloc)))
+    {
+      if (TREE_PUBLIC (exp))
+        read_only_data_section ();
+      else
+        read_only_private_data_section ();
+    }
+  else
+    {
+      if (TREE_PUBLIC (exp))
+        data_section ();
+      else
+        private_data_section ();
+    }
+}
+
+static void
+rs6000_xcoff_unique_section (decl, reloc)
+     tree decl;
+     int reloc;
+{
+  const char *name;
+  char *string;
+  size_t len;
+
+  if (TREE_CODE (decl) == FUNCTION_DECL)
+    {
+      name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+      len = strlen (name) + 5;
+      string = alloca (len + 1);
+      sprintf (string, ".%s[PR]", name);
+      DECL_SECTION_NAME (decl) = build_string (len, string);
+    }
+}
 #endif
index cf0c668..2eff24c 100644 (file)
@@ -1,5 +1,5 @@
 /* Target definitions for GNU compiler for PowerPC running System V.4
-   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
@@ -567,8 +567,8 @@ fini_section ()                                                             \
    the initial value of DECL requires link-time relocations.  */
 
 /* Override elfos.h definition.  */
-#undef SELECT_SECTION
-#define        SELECT_SECTION(DECL, RELOC, ALIGN) rs6000_select_section (DECL, RELOC)
+#undef TARGET_ASM_SELECT_SECTION
+#define        TARGET_ASM_SELECT_SECTION  rs6000_elf_select_section
 
 /* A C statement to build up a unique section name, expressed as a
    STRING_CST node, and assign it to DECL_SECTION_NAME (decl).
@@ -578,9 +578,8 @@ fini_section ()                                                             \
    macro can now be called for uninitialized 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)
+/* Override default elf definition.  */
+#define TARGET_ASM_UNIQUE_SECTION  rs6000_elf_unique_section
 
 /* 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
index 9fcedf8..cae5a37 100644 (file)
@@ -140,30 +140,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,ALIGN)                        \
-{                                                      \
-  if ((TREE_CODE (EXP) == STRING_CST                   \
-       && ! flag_writable_strings)                     \
-      || (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'd'     \
-         && TREE_READONLY (EXP) && ! TREE_THIS_VOLATILE (EXP) \
-         && DECL_INITIAL (EXP)                         \
-         && (DECL_INITIAL (EXP) == error_mark_node     \
-             || TREE_CONSTANT (DECL_INITIAL (EXP)))    \
-         && ! (RELOC)))                                \
-    {                                                  \
-      if (TREE_PUBLIC (EXP))                           \
-        read_only_data_section ();                     \
-      else                                             \
-        read_only_private_data_section ();             \
-    }                                                  \
-  else                                                 \
-    {                                                  \
-      if (TREE_PUBLIC (EXP))                           \
-        data_section ();                               \
-      else                                             \
-        private_data_section ();                       \
-    }                                                  \
-}
+#define TARGET_ASM_SELECT_SECTION  rs6000_xcoff_select_section
 
 /* 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
@@ -468,20 +445,7 @@ toc_section ()                                             \
 #define DATA_SECTION_ASM_OP "\t.csect .data[RW],3"
 
 /* Define unique section name -- functions only.  */
-#define UNIQUE_SECTION(DECL,RELOC)                     \
-  do {                                                 \
-    int len;                                           \
-    const char *name;                                  \
-    char *string;                                      \
-                                                       \
-    if (TREE_CODE (DECL) == FUNCTION_DECL) {           \
-      name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
-      len = strlen (name) + 5;                         \
-      string = alloca (len + 1);                       \
-      sprintf (string, ".%s[PR]", name);               \
-      DECL_SECTION_NAME (DECL) = build_string (len, string); \
-    }                                                  \
-  } while (0)
+#define TARGET_ASM_UNIQUE_SECTION  rs6000_xcoff_unique_section
 
 /* Switch into a generic section.  */
 #define TARGET_ASM_NAMED_SECTION  xcoff_asm_named_section
index 3a2273f..292f164 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler, for SPARC using a.out.
-   Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1996, 2002 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com).
 
 This file is part of GNU CC.
@@ -37,36 +37,7 @@ Boston, MA 02111-1307, USA.  */
  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)                          \
   || !strcmp (STR, "target") || !strcmp (STR, "assert"))
 
-/* This is defined differently for v9 in a cover file.  */
-#define SELECT_SECTION(T,RELOC,ALIGN)                                  \
-{                                                                      \
-  if (TREE_CODE (T) == VAR_DECL)                                       \
-    {                                                                  \
-      if (TREE_READONLY (T) && ! TREE_SIDE_EFFECTS (T)                 \
-         && DECL_INITIAL (T)                                           \
-         && (DECL_INITIAL (T) == error_mark_node                       \
-             || TREE_CONSTANT (DECL_INITIAL (T)))                      \
-         && DECL_ALIGN (T) <= MAX_TEXT_ALIGN                           \
-         && ! (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES)))      \
-       text_section ();                                                \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (T) == CONSTRUCTOR)                               \
-    {                                                                  \
-      if (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES))            \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE_CLASS (TREE_CODE (T)) == 'c')                     \
-    {                                                                  \
-      if ((TREE_CODE (T) == STRING_CST && flag_writable_strings)       \
-         || TYPE_ALIGN (TREE_TYPE (T)) > MAX_TEXT_ALIGN                \
-         || (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES)))        \
-       data_section ();                                                \
-      else                                                             \
-       text_section ();                                                \
-    }                                                                  \
-}
+#define TARGET_ASM_SELECT_SECTION  sparc_aout_select_section
 
 /* Output the label for a function definition.  */
 
index ad1b3c0..2f8e36c 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines for insn-output.c for Sun SPARC.
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
    64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
    at Cygnus Support.
@@ -157,6 +157,9 @@ static void sparc_nonflat_function_prologue PARAMS ((FILE *, HOST_WIDE_INT,
 #ifdef OBJECT_FORMAT_ELF
 static void sparc_elf_asm_named_section PARAMS ((const char *, unsigned int));
 #endif
+static void sparc_aout_select_section PARAMS ((tree, int,
+                                              unsigned HOST_WIDE_INT))
+     ATTRIBUTE_UNUSED;
 
 static int sparc_adjust_cost PARAMS ((rtx, rtx, rtx, int));
 static int sparc_issue_rate PARAMS ((void));
@@ -8040,6 +8043,19 @@ sparc_elf_asm_named_section (name, flags)
 }
 #endif /* OBJECT_FORMAT_ELF */
 
+/* ??? Similar to the standard section selection, but force reloc-y-ness
+   if SUNOS4_SHARED_LIBRARIES.  Unclear why this helps (as opposed to
+   pretending PIC always on), but that's what the old code did.  */
+
+static void
+sparc_aout_select_section (t, reloc, align)
+     tree t;
+     int reloc;
+     unsigned HOST_WIDE_INT align;
+{
+  default_select_section (t, reloc | SUNOS4_SHARED_LIBRARIES, align)
+}
+
 int
 sparc_extra_constraint_check (op, c, strict)
      rtx op;
index 099fac0..4c49ad8 100644 (file)
@@ -2546,18 +2546,6 @@ do {                                                     \
 /* #define READONLY_DATA_SECTION */
 
 /* 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 initial value of EXP requires
-   link-time relocations.  Select the section by calling `text_section' or one
-   of the alternatives for other sections.
-
-   Do not define this macro if you put all read-only variables and constants in
-   the read-only data section (usually the text section).
-
-   Defined in svr4.h.  */
-/* #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
    RTL.  The argument MODE is redundant except in the case of a `const_int'
    rtx.  Select the section by calling `text_section' or one of the
@@ -2594,16 +2582,6 @@ do {                                                     \
    that encode section info.  Define this macro if `ENCODE_SECTION_INFO' alters
    the symbol's name string.  */
 /* #define STRIP_NAME_ENCODING(VAR, SYM_NAME) */
-
-/* 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, GNU CC
-   will use the symbol name prefixed by `.' as the section name.
-
-   Defined in svr4.h.  */
-/* #define UNIQUE_SECTION(DECL, RELOC) */
-
 \f
 /* Position Independent Code.  */
 
index 4de6f52..5e3ddc9 100644 (file)
@@ -1,6 +1,6 @@
 /* Operating system specific defines to be used when targeting GCC for
    generic System V Release 3 system.
-   Copyright (C) 1991, 1996, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1996, 2000, 2002 Free Software Foundation, Inc.
    Contributed by Ron Guilmette (rfg@monkeys.com).
 
 This file is part of GNU CC.
@@ -188,16 +188,7 @@ Boston, MA 02111-1307, USA.
 #undef LOCAL_LABEL_PREFIX
 #define LOCAL_LABEL_PREFIX "."
 
-/* Support const sections and the ctors and dtors sections for g++.
-   Note that there appears to be two different ways to support const
-   sections at the moment.  You can either #define the symbol
-   READONLY_DATA_SECTION (giving it some code which switches to the
-   readonly data section) or else you can #define the symbols
-   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
-   SELECT_RTX_SECTION.  We do both here just to be on the safe side.
-   However, use of the const section is turned off by default
-   unless the specific tm.h file turns it on by defining
-   USE_CONST_SECTION as 1.  */
+/* Support const sections and the ctors and dtors sections for g++.  */
 
 /* Define a few machine-specific details of the implementation of
    constructors.
@@ -292,36 +283,6 @@ const_section ()                                                   \
 }
 
 /* A C statement or statements to switch to the appropriate
-   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.  */
-
-#undef  SELECT_SECTION
-#define SELECT_SECTION(DECL,RELOC,ALIGN)                               \
-{                                                                      \
-  if (TREE_CODE (DECL) == STRING_CST)                                  \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       const_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  else if (TREE_CODE (DECL) == VAR_DECL)                               \
-    {                                                                  \
-      if ((0 && RELOC) /* should be (flag_pic && RELOC) */             \
-         || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
-         || !DECL_INITIAL (DECL)                                       \
-         || (DECL_INITIAL (DECL) != error_mark_node                    \
-             && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
-       data_section ();                                                \
-      else                                                             \
-       const_section ();                                               \
-    }                                                                  \
-  else                                                                 \
-    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
index a20e4ff..c47e47b 100644 (file)
@@ -58,6 +58,7 @@ const struct attribute_spec v850_attribute_table[];
 static tree v850_handle_interrupt_attribute PARAMS ((tree *, tree, tree, int, bool *));
 static tree v850_handle_data_area_attribute PARAMS ((tree *, tree, tree, int, bool *));
 static void v850_insert_attributes   PARAMS ((tree, tree *));
+static void v850_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT));
 
 /* True if the current function has anonymous arguments.  */
 int current_function_anonymous_args;
@@ -96,6 +97,9 @@ static int v850_interrupt_p = FALSE;
 #undef TARGET_INSERT_ATTRIBUTES
 #define TARGET_INSERT_ATTRIBUTES v850_insert_attributes
 
+#undef  TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION  v850_select_section
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 /* Sometimes certain combinations of command options do not make
@@ -2845,3 +2849,60 @@ v850_return_addr (count)
 
   return get_hard_reg_initial_val (Pmode, LINK_POINTER_REGNUM);
 }
+\f
+static void
+v850_select_section (exp, reloc, align)
+     tree exp;
+     int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if (TREE_CODE (exp) == VAR_DECL)
+    {
+      int is_const;
+      if (!TREE_READONLY (exp)
+         || TREE_SIDE_EFFECTS (exp)
+         || !DECL_INITIAL (exp)
+         || (DECL_INITIAL (exp) != error_mark_node
+             && !TREE_CONSTANT (DECL_INITIAL (exp))))
+        is_const = FALSE;
+      else
+        is_const = TRUE;
+
+      switch (v850_get_data_area (exp))
+        {
+        case DATA_AREA_ZDA:
+         if (is_const)
+           rozdata_section ();
+         else
+           zdata_section ();
+         break;
+
+        case DATA_AREA_TDA:
+         tdata_section ();
+         break;
+
+        case DATA_AREA_SDA:
+         if (is_const)
+           rosdata_section ();
+         else
+           sdata_section ();
+         break;
+
+        default:
+          if (is_const)
+           const_section ();
+         else
+           data_section ();
+         break;
+        }
+    }
+  else if (TREE_CODE (exp) == STRING_CST)
+    {
+      if (! flag_writable_strings)
+       const_section ();
+      else
+       data_section ();
+    }
+  else
+    const_section ();
+}
index b7f6367..4f637ff 100644 (file)
@@ -1120,71 +1120,6 @@ zbss_section ()                                                          \
 #define TCOMMON_ASM_OP                "\t.tcomm\t"
 
 /* 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
-   initial value of EXP requires link-time relocations.  Select the
-   section by calling `text_section' or one of the alternatives for
-   other sections.
-
-   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, ALIGN)                              \
-do {                                                                   \
-  if (TREE_CODE (EXP) == VAR_DECL)                                     \
-    {                                                                  \
-      int is_const;                                                    \
-      if (!TREE_READONLY (EXP)                                         \
-         || TREE_SIDE_EFFECTS (EXP)                                    \
-         || !DECL_INITIAL (EXP)                                        \
-         || (DECL_INITIAL (EXP) != error_mark_node                     \
-             && !TREE_CONSTANT (DECL_INITIAL (EXP))))                  \
-        is_const = FALSE;                                              \
-      else                                                             \
-        is_const = TRUE;                                               \
-                                                                       \
-      switch (v850_get_data_area (EXP))                                        \
-        {                                                              \
-        case DATA_AREA_ZDA:                                            \
-         if (is_const)                                                 \
-           rozdata_section ();                                         \
-         else                                                          \
-           zdata_section ();                                           \
-         break;                                                        \
-                                                                       \
-        case DATA_AREA_TDA:                                            \
-         tdata_section ();                                             \
-         break;                                                        \
-                                                                       \
-        case DATA_AREA_SDA:                                            \
-         if (is_const)                                                 \
-           rosdata_section ();                                         \
-         else                                                          \
-           sdata_section ();                                           \
-         break;                                                        \
-                                                                       \
-        default:                                                       \
-          if (is_const)                                                        \
-           const_section ();                                           \
-         else                                                          \
-           data_section ();                                            \
-         break;                                                        \
-        }                                                              \
-    }                                                                  \
-  else if (TREE_CODE (EXP) == STRING_CST)                              \
-    {                                                                  \
-      if (! flag_writable_strings)                                     \
-       const_section ();                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-                                                                       \
-  else                                                                 \
-    const_section ();                                                  \
-                                                                       \
-} while (0)
-
-/* 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
    the case of a `const_int' rtx.  Select the section by calling
index 9665609..fc1d9fa 100644 (file)
@@ -42,6 +42,7 @@ static void vax_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
 #if VMS_TARGET
 static void vms_asm_out_constructor PARAMS ((rtx, int));
 static void vms_asm_out_destructor PARAMS ((rtx, int));
+static void vms_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT));
 #endif
 \f
 /* Initialize the GCC target structure.  */
@@ -51,6 +52,11 @@ static void vms_asm_out_destructor PARAMS ((rtx, int));
 #undef TARGET_ASM_FUNCTION_PROLOGUE
 #define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue
 
+#if VMS_TARGET
+#undef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION vms_select_section
+#endif
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 /* Generate the assembly code for function entry.  FILE is a stdio
@@ -871,6 +877,36 @@ vms_asm_out_destructor (symbol, priority)
   assemble_name (asm_out_file, XSTR (symbol, 0));
   fputc ('\n', asm_out_file);
 }
+
+static void
+vax_select_section (exp, reloc, align)
+     tree exp;
+     int reloc ATTRIBUTE_UNUSED;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  if (TREE_CODE (exp) == VAR_DECL)
+    {
+      if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp)
+         && DECL_INITIAL (exp)
+         && (DECL_INITIAL (exp) == error_mark_node
+             || TREE_CONSTANT (DECL_INITIAL (exp))))
+       {
+         if (TREE_PUBLIC (exp))
+           const_section ();
+         else
+           text_section ();
+       }
+      else
+       data_section ();
+    }
+  if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c')
+    {
+      if (TREE_CODE (exp) == STRING_CST && flag_writable_strings)
+       data_section ();
+      else
+       text_section ();
+    }
+}
 #endif /* VMS_TARGET */
 \f
 /* Additional support code for VMS host.  */
index 69eced9..1703e9b 100644 (file)
@@ -1,5 +1,6 @@
 /* Output variables, constants and external declarations, for GNU compiler.
-   Copyright (C) 1988, 1994, 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1988, 1994, 1995, 1996, 1997, 1999, 2001, 2002
+   Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -210,40 +211,6 @@ const_section ()                                   \
   }                                                    \
 }
 
-/* This macro contains the logic to decide which section a variable
-   should be stored in.  Static constant variables go in the text_section,
-   non-const variables go in the data_section, and non-static const
-   variables go in the 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,ALIGN)                                  \
-{                                                                      \
-  if (TREE_CODE (T) == VAR_DECL)                                       \
-    {                                                                  \
-      if (TREE_READONLY (T) && ! TREE_THIS_VOLATILE (T)                        \
-         && DECL_INITIAL (T)                                           \
-         && (DECL_INITIAL (T) == error_mark_node                       \
-             || TREE_CONSTANT (DECL_INITIAL (T))))                     \
-       {                                                               \
-         if (TREE_PUBLIC (T))                                          \
-           const_section ();                                           \
-         else                                                          \
-           text_section ();                                            \
-       }                                                               \
-      else                                                             \
-       data_section ();                                                \
-    }                                                                  \
-  if (TREE_CODE_CLASS (TREE_CODE (T)) == 'c')                          \
-    {                                                                  \
-      if ((TREE_CODE (T) == STRING_CST && flag_writable_strings))      \
-       data_section ();                                                \
-      else                                                             \
-       text_section ();                                                \
-    }                                                                  \
-}
-
 /* This is used by a hook in varasm.c to write the assembler directives
    that are needed to tell the startup code which constructors need to
    be run.  */
index bbb2c50..f3b379f 100644 (file)
@@ -5752,21 +5752,6 @@ switches to the section to be used for read-only items.
 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}, @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.  Bit 1 is set when variable contains local relocations
-only, while bit 2 is set for global relocations.
-Select the section by calling @code{text_section} or one
-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}, @var{align})
 A C statement or statements to switch to the appropriate section for
@@ -5820,18 +5805,34 @@ enough information).
 Decode @var{sym_name} and store the real name part in @var{var}, sans
 the characters that encode section info.  Define this macro if
 @code{ENCODE_SECTION_INFO} alters the symbol's name string.
-
-@findex UNIQUE_SECTION
-@item UNIQUE_SECTION (@var{decl}, @var{reloc})
-A C statement to build up a unique section name, expressed as a
-@code{STRING_CST} node, and assign it to @samp{DECL_SECTION_NAME (@var{decl})}.
-@var{reloc} indicates whether the initial value of @var{exp} requires
-link-time relocations.  If you do not define this macro, GCC will use
-the symbol name prefixed by @samp{.} as the section name.  Note - this
-macro can now be called for uninitialized data items as well as
-initialized data and functions.
 @end table
 
+@deftypefn {Target Hook} void TARGET_ASM_SELECT_SECTION (tree @var{exp}, int @var{reloc}, unsigned HOST_WIDE_INT @var{align})
+Switches 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.  Bit 0 is set when variable contains
+local relocations only, while bit 1 is set for global relocations.
+Select the section by calling @code{data_section} or one of the
+alternatives for other sections.  @var{align} is the constant alignment
+in bits.
+
+The default version of this function takes care of putting read-only
+variables in @code{readonly_data_section}.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_ASM_UNIQUE_SECTION (tree @var{decl}, int @var{reloc})
+Build up a unique section name, expressed as a @code{STRING_CST} node,
+and assign it to @samp{DECL_SECTION_NAME (@var{decl})}.
+As with @code{TARGET_ASM_SELECT_SECTION}, @var{reloc} indicates whether
+the initial value of @var{exp} requires link-time relocations.
+
+The default version of this function appends the symbol name to the
+ELF section name that would normally be used for the symbol.  For
+example, the function @code{foo} would be placed in @code{.text.foo}.
+Whatever the actual target object format, this is often good enough.
+@end deftypefn
+
 @node PIC
 @section Position Independent Code
 @cindex position independent code
index 387f4db..c5371e9 100644 (file)
@@ -32,3 +32,11 @@ hook_void_bool_false ()
 {
   return false;
 }
+
+/* Generic hook that takes (tree) and returns false.  */
+bool
+hook_tree_bool_false (a)
+     tree a ATTRIBUTE_UNUSED;
+{
+  return false;
+}
index 7a8daa5..0358ae9 100644 (file)
@@ -20,3 +20,4 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  what you give them.   Help stamp out software-hoarding!  */
 
 bool hook_void_bool_false PARAMS ((void));
+bool hook_tree_bool_false PARAMS ((tree));
index a33f15b..2c8dbd6 100644 (file)
@@ -543,6 +543,12 @@ extern void default_named_section_asm_out_constructor PARAMS ((struct rtx_def *,
 extern void default_ctor_section_asm_out_constructor PARAMS ((struct rtx_def *,
                                                              int));
 
+extern void default_select_section PARAMS ((tree, int,
+                                           unsigned HOST_WIDE_INT));
+extern void default_elf_select_section PARAMS ((tree, int,
+                                               unsigned HOST_WIDE_INT));
+extern void default_unique_section PARAMS ((tree, int));
+
 /* Emit data for vtable gc for GNU binutils.  */
 extern void assemble_vtable_entry PARAMS ((struct rtx_def *, HOST_WIDE_INT));
 extern void assemble_vtable_inherit PARAMS ((struct rtx_def *,
index 76d238e..5390efa 100644 (file)
@@ -59,6 +59,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream
 #define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE no_asm_to_stream
 
+#ifndef TARGET_ASM_SELECT_SECTION
+#define TARGET_ASM_SELECT_SECTION default_select_section
+#endif
+
+#ifndef TARGET_ASM_UNIQUE_SECTION
+#define TARGET_ASM_UNIQUE_SECTION default_unique_section
+#endif
+
 #if !defined(TARGET_ASM_CONSTRUCTOR) && !defined(USE_COLLECT2)
 # ifdef CTORS_SECTION_ASM_OP
 #  define TARGET_ASM_CONSTRUCTOR default_ctor_section_asm_out_constructor
@@ -131,6 +139,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
                        TARGET_ASM_NAMED_SECTION,               \
                        TARGET_ASM_EXCEPTION_SECTION,           \
                        TARGET_ASM_EH_FRAME_SECTION,            \
+                       TARGET_ASM_SELECT_SECTION,              \
+                       TARGET_ASM_UNIQUE_SECTION,              \
                        TARGET_ASM_CONSTRUCTOR,                 \
                        TARGET_ASM_DESTRUCTOR}
 
@@ -192,6 +202,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 /* In hook.c.  */
 #define TARGET_CANNOT_MODIFY_JUMPS_P hook_void_bool_false
+#define TARGET_IN_SMALL_DATA_P hook_tree_bool_false
 
 /* The whole shebang.  */
 #define TARGET_INITIALIZER                     \
@@ -211,7 +222,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   TARGET_SECTION_TYPE_FLAGS,                   \
   TARGET_HAVE_NAMED_SECTIONS,                  \
   TARGET_HAVE_CTORS_DTORS,                     \
-  TARGET_CANNOT_MODIFY_JUMPS_P                 \
+  TARGET_CANNOT_MODIFY_JUMPS_P,                        \
+  TARGET_IN_SMALL_DATA_P                       \
 }
 
 #include "hooks.h"
index 1f29412..8b500bd 100644 (file)
@@ -91,6 +91,17 @@ struct gcc_target
     /* Switch to the section that holds the exception frames.  */
     void (* eh_frame_section) PARAMS ((void));
 
+    /* Select and switch to a section for EXP.  It may be a DECL or a
+       constant for which TREE_CST_RTL is valid.  RELOC is non-zero if
+       runtime relocations must be applied; bit 1 will be set if the
+       runtime relocations require non-local name resolution.  ALIGN is
+       the required alignment of the data.  */
+    void (* select_section) PARAMS ((tree, int, unsigned HOST_WIDE_INT));
+
+    /* Select a unique section name for DECL.  RELOC is the same as
+       for SELECT_SECTION.  */
+    void (* unique_section) PARAMS ((tree, int));
+
     /* Output a constructor for a symbol with a given priority.  */
     void (* constructor) PARAMS ((rtx, int));
 
@@ -224,6 +235,9 @@ struct gcc_target
   /* True if new jumps cannot be created, to replace existing ones or
      not, at the current point in the compilation.  */
   bool (* cannot_modify_jumps_p) PARAMS ((void));
+
+  /* True if EXP should be placed in a "small data" section.  */
+  bool (* in_small_data_p) PARAMS ((tree));
 };
 
 extern struct gcc_target targetm;
index 4a88412..e13efe0 100644 (file)
@@ -465,10 +465,10 @@ resolve_unique_section (decl, reloc, flag_function_or_data_sections)
      int flag_function_or_data_sections;
 {
   if (DECL_SECTION_NAME (decl) == NULL_TREE
+      && targetm.have_named_sections
       && (flag_function_or_data_sections
-         || (targetm.have_named_sections
-             && DECL_ONE_ONLY (decl))))
-    UNIQUE_SECTION (decl, reloc);
+         || DECL_ONE_ONLY (decl)))
+    (*targetm.asm_out.unique_section) (decl, reloc);
 }
 
 #ifdef BSS_SECTION_ASM_OP
@@ -567,9 +567,8 @@ function_section (decl)
     text_section ();
 }
 
-/* Switch to section for variable DECL.
-
-   RELOC is the `reloc' argument to SELECT_SECTION.  */
+/* Switch to section for variable DECL.  RELOC is the same as the
+   argument to SELECT_SECTION.  */
 
 void
 variable_section (decl, reloc)
@@ -579,29 +578,7 @@ variable_section (decl, reloc)
   if (IN_NAMED_SECTION (decl))
     named_section (decl, NULL, reloc);
   else
-    {
-      /* C++ can have const variables that get initialized from constructors,
-        and thus can not be in a readonly section.  We prevent this by
-        verifying that the initial value is constant for objects put in a
-        readonly section.
-
-        error_mark_node is used by the C front end to indicate that the
-        initializer has not been seen yet.  In this case, we assume that
-        the initializer must be constant.
-
-        C++ uses error_mark_node for variables that have complicated
-        initializers, but these variables go in BSS so we won't be called
-        for them.  */
-
-#ifdef SELECT_SECTION
-      SELECT_SECTION (decl, reloc, DECL_ALIGN (decl));
-#else
-      if (DECL_READONLY_SECTION (decl, reloc))
-       readonly_data_section ();
-      else
-       data_section ();
-#endif
-    }
+    (*targetm.asm_out.select_section) (decl, reloc, DECL_ALIGN (decl));
 }
 
 /* Tell assembler to switch to the section for the exception handling
@@ -3211,18 +3188,7 @@ output_constant_def_contents (exp, reloc, labelno)
   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, align);
-#else
-      if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
-         || (flag_pic && reloc))
-       data_section ();
-      else
-       readonly_data_section ();
-#endif
-    }
+    (*targetm.asm_out.select_section) (exp, reloc, align);
 
   if (align > BITS_PER_UNIT)
     {
@@ -5254,3 +5220,267 @@ assemble_vtable_inherit (child, parent)
   output_addr_const (asm_out_file, parent);
   fputc ('\n', asm_out_file);
 }
+\f
+/* The lame default section selector.  */
+
+void
+default_select_section (decl, reloc, align)
+     tree decl;
+     int reloc;
+     unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
+{
+  bool readonly = false;
+
+  if (DECL_P (decl))
+    {
+      if (DECL_READONLY_SECTION (decl, reloc))
+       readonly = true;
+    }
+  else if (TREE_CODE (decl) == CONSTRUCTOR)
+    {
+      if (! ((flag_pic && reloc)
+            || !TREE_READONLY (decl)
+            || TREE_SIDE_EFFECTS (decl)
+            || !TREE_CONSTANT (decl)))
+       readonly = true;
+    }
+  else if (TREE_CODE (decl) == STRING_CST)
+    readonly = !flag_writable_strings;
+  else if (! (flag_pic && reloc))
+    readonly = true;
+
+  if (readonly)
+    readonly_data_section ();
+  else
+    data_section ();
+}
+
+/* A helper function for default_elf_select_section and
+   default_elf_unique_section.  Categorizes the DECL.  */
+
+enum section_category
+{
+  SECCAT_TEXT,
+
+  SECCAT_RODATA,
+  SECCAT_RODATA_MERGE_STR,
+  SECCAT_RODATA_MERGE_STR_INIT,
+  SECCAT_RODATA_MERGE_CONST,
+
+  SECCAT_DATA,
+
+  /* To optimize loading of shared programs, define following subsections
+     of data section:
+       _REL    Contains data that has relocations, so they get grouped
+               together and dynamic linker will visit fewer pages in memory.
+       _RO     Contains data that is otherwise read-only.  This is useful
+               with prelinking as most relocations won't be dynamically
+               linked and thus stay read only.
+       _LOCAL  Marks data containing relocations only to local objects.
+               These relocations will get fully resolved by prelinking.  */
+  SECCAT_DATA_REL,
+  SECCAT_DATA_REL_LOCAL,
+  SECCAT_DATA_REL_RO,
+  SECCAT_DATA_REL_RO_LOCAL,
+
+  SECCAT_SDATA,
+  SECCAT_TDATA,
+
+  SECCAT_BSS,
+  SECCAT_SBSS,
+  SECCAT_TBSS
+};
+
+static enum section_category categorize_decl_for_section PARAMS ((tree, int));
+
+static enum section_category
+categorize_decl_for_section (decl, reloc)
+     tree decl;
+     int reloc;
+{
+  enum section_category ret;
+
+  if (TREE_CODE (decl) == FUNCTION_DECL)
+    return SECCAT_TEXT;
+  else if (TREE_CODE (decl) == STRING_CST)
+    {
+      if (flag_writable_strings)
+       return SECCAT_DATA;
+      else
+       return SECCAT_RODATA_MERGE_STR;
+    }
+  else if (TREE_CODE (decl) == VAR_DECL)
+    {
+      if (DECL_INITIAL (decl) == NULL
+         || DECL_INITIAL (decl) == error_mark_node)
+       ret = SECCAT_BSS;
+      else if (! TREE_READONLY (decl)
+              || TREE_SIDE_EFFECTS (decl)
+              || ! TREE_CONSTANT (DECL_INITIAL (decl)))
+       {
+         if (flag_pic && (reloc & 2))
+           ret = SECCAT_DATA_REL;
+         else if (flag_pic && reloc)
+           ret = SECCAT_DATA_REL_LOCAL;
+         else
+           ret = SECCAT_DATA;
+       }
+      else if (flag_pic && (reloc & 2))
+       ret = SECCAT_DATA_REL_RO;
+      else if (flag_pic && reloc)
+       ret = SECCAT_DATA_REL_RO_LOCAL;
+      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).  */
+       ret = SECCAT_RODATA;
+      else if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
+       ret = SECCAT_RODATA_MERGE_STR_INIT;
+      else
+       ret = SECCAT_RODATA_MERGE_CONST;
+    }
+  else if (TREE_CODE (decl) == CONSTRUCTOR)
+    {
+      if ((flag_pic && reloc)
+         || TREE_SIDE_EFFECTS (decl)
+         || ! TREE_CONSTANT (decl))
+       ret = SECCAT_DATA;
+      else
+       ret = SECCAT_RODATA;
+    }
+  else
+    ret = SECCAT_RODATA;
+
+  /* If the target uses small data sections, select it.  */
+  if ((*targetm.in_small_data_p) (decl))
+    {
+      if (ret == SECCAT_BSS)
+       ret = SECCAT_SBSS;
+      else
+       ret = SECCAT_SDATA;
+    }
+
+  return ret;
+}
+
+/* Select a section based on the above categorization.  */
+
+void
+default_elf_select_section (decl, reloc, align)
+     tree decl;
+     int reloc;
+     unsigned HOST_WIDE_INT align;
+{
+  switch (categorize_decl_for_section (decl, reloc))
+    {
+    case SECCAT_TEXT:
+      /* We're not supposed to be called on FUNCTION_DECLs.  */
+      abort ();
+    case SECCAT_RODATA:
+      readonly_data_section ();
+      break;
+    case SECCAT_RODATA_MERGE_STR:
+      mergeable_string_section (decl, align, 0);
+      break;
+    case SECCAT_RODATA_MERGE_STR_INIT:
+      mergeable_string_section (DECL_INITIAL (decl), align, 0);
+      break;
+    case SECCAT_RODATA_MERGE_CONST:
+      mergeable_constant_section (DECL_MODE (decl), align, 0);
+      break;
+    case SECCAT_DATA:
+      data_section ();
+      break;
+    case SECCAT_DATA_REL:
+      named_section (NULL_TREE, ".data.rel", reloc);
+      break;
+    case SECCAT_DATA_REL_LOCAL:
+      named_section (NULL_TREE, ".data.rel.local", reloc);
+      break;
+    case SECCAT_DATA_REL_RO:
+      named_section (NULL_TREE, ".data.rel.ro", reloc);
+      break;
+    case SECCAT_DATA_REL_RO_LOCAL:
+      named_section (NULL_TREE, ".data.rel.ro.local", reloc);
+      break;
+    case SECCAT_SDATA:
+      named_section (NULL_TREE, ".sdata", reloc);
+      break;
+    case SECCAT_TDATA:
+      named_section (NULL_TREE, ".tdata", reloc);
+      break;
+    case SECCAT_BSS:
+#ifdef BSS_SECTION_ASM_OP
+      bss_section ();
+#else
+      named_section (NULL_TREE, ".bss", reloc);
+#endif
+      break;
+    case SECCAT_SBSS:
+      named_section (NULL_TREE, ".sbss", reloc);
+      break;
+    case SECCAT_TBSS:
+      named_section (NULL_TREE, ".tbss", reloc);
+      break;
+    default:
+      abort ();
+    }
+}
+
+/* Construct a unique section name based on the decl name and the 
+   categorization performed above.  */
+
+void
+default_unique_section (decl, reloc)
+     tree decl;
+     int reloc;
+{
+  bool one_only = DECL_ONE_ONLY (decl);
+  const char *prefix, *name;
+  size_t nlen, plen;
+  char *string;
+
+  switch (categorize_decl_for_section (decl, reloc))
+    {
+    case SECCAT_TEXT:
+      prefix = one_only ? ".gnu.linkonce.t." : ".text.";
+      break;
+    case SECCAT_RODATA:
+    case SECCAT_RODATA_MERGE_STR:
+    case SECCAT_RODATA_MERGE_STR_INIT:
+    case SECCAT_RODATA_MERGE_CONST:
+      prefix = one_only ? ".gnu.linkonce.r." : ".rodata.";
+      break;
+    case SECCAT_DATA:
+    case SECCAT_DATA_REL:
+    case SECCAT_DATA_REL_LOCAL:
+    case SECCAT_DATA_REL_RO:
+    case SECCAT_DATA_REL_RO_LOCAL:
+      prefix = one_only ? ".gnu.linkonce.d." : ".data.";
+      break;
+    case SECCAT_SDATA:
+      prefix = one_only ? ".gnu.linkonce.s." : ".sdata.";
+      break;
+    case SECCAT_BSS:
+      prefix = one_only ? ".gnu.linkonce.b." : ".bss.";
+      break;
+    case SECCAT_SBSS:
+      prefix = one_only ? ".gnu.linkonce.sb." : ".sbss.";
+      break;
+    case SECCAT_TDATA:
+    case SECCAT_TBSS:
+    default:
+      abort ();
+    }
+  plen = strlen (prefix);
+
+  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+  STRIP_NAME_ENCODING (name, name);
+  nlen = strlen (name);
+
+  string = alloca (nlen + plen + 1);
+  memcpy (string, prefix, plen);
+  memcpy (string + plen, name, nlen + 1);
+
+  DECL_SECTION_NAME (decl) = build_string (nlen + plen, string);
+}