This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: Remove TREE_CST_RTL


This patch eliminates the TREE_CST_RTL field, which should save a
substantial amount of memory -- at present, all the trees with such a
field are either 20 or 24 bytes (on a 32-bit system); now they will
all be 16 or 20 bytes instead.  Both the latter sizes have dedicated
GC pools.  TREE_CST_RTL was examined in very few places, so there
should be negligible cost to going through output_constant_def all
the time; in fact I expect better performance due to reduced memory
use.

It was necessary to make changes to lots of back ends.  I broke the
encode_section_info target hook in half; there is now one interface
for DECL nodes (which still have their DECL_RTL field) and another for
constants.  I changed all and only those back ends which used
TREE_CST_RTL; this means that I may have missed code that needs
updating, although it seems unlikely.

The patch has received NO TESTING WHATSOEVER.  I am posting it now so
that architecture maintainers can look at it and tell me if I've
broken something.  Meantime I will run simulator testing for all the
affected architectures.

zw

        * tree.h (CST_OR_CONSTRUCTOR_CHECK, TREE_CST_RTL): Kill.
        (tree_int_cst, tree_real_cst, tree_string, tree_complex,
        tree_vector): Kill 'rtl' field.
        (CONSTRUCTOR_ELTS): Is now operand 0.
        * tree.def (CONSTRUCTOR): Only one operand now.  Update comment.

        * hooks.c (hook_void_tree_rtx): New.
        * hooks.h: Prototype it.
        * target.h: New hook encode_section_info_for_cst.
        * target-def.h: Default TARGET_ENCODE_SECTION_INFO_FOR_CST
        to hook_void_tree_rtx.  Add it to TARGET_INITIALIZER.

        * varasm.c (decode_addr_const): Delete now-invalid comment.
        (output_constant_def): Don't use TREE_CST_RTL.  Update comments.
        Call targetm.encode_section_info_for_cst instead of
        targetm.encode_section_info.
        (find_rtl_for_constant): New.
        * rtl.h: Prototype it.

        * expr.c (expand_expr [COMPLEX_CST, STRING_CST]):
        Unconditionally call output_constant_def, save its result, and
        refer to that instead of TREE_CST_RTL.
        (expand_expr [CONSTRUCTOR]): Use find_rtl_for_constant.
        * ada/utils.c (convert): No need to clear TREE_CST_RTL.
        * config/mips/mips.c (mips16_constant_after_function_p):
        Use find_rtl_for_constant.

        * config/alpha/alpha.c, config/arm/arm.c, config/arm/pe.c,
        config/cris/cris.c, config/i386/i386.c, config/i386/winnt.c,
        config/m32r/m32r.c, config/m88k/m88k.c, config/mcore/mcore.c,
        config/mips/mips.c, config/mmix/mmix.c, config/ns32k/ns32k.c,
        config/pa/pa.c, config/s390/s390.c, config/sh/sh.c:
        Define an encode_section_info_for_cst hook; split out
        relevant code from encode_section_info hook; redefine
        TARGET_ENCODE_SECTION_INFO_FOR_CST.

        * config/arm/arm-protos.h, config/i386/i386-protos.h:
        Prototype functions as necessary.

        * config/i386/cygming.h, config/i386/i386.h, config/i386/win32.h:
        Redefine TARGET_ENCODE_SECTION_INFO_FOR_CST.

===================================================================
Index: expr.c
--- expr.c	1 Apr 2003 13:40:07 -0000	1.517
+++ expr.c	6 Apr 2003 01:00:07 -0000
@@ -6865,22 +6865,20 @@ expand_expr (exp, target, tmode, modifie
 
     case COMPLEX_CST:
     case STRING_CST:
-      if (! TREE_CST_RTL (exp))
-	output_constant_def (exp, 1);
+      temp = output_constant_def (exp, 1);
 
-      /* TREE_CST_RTL probably contains a constant address.
+      /* The RTL probably contains a constant address.
 	 On RISC machines where a constant address isn't valid,
 	 make some insns to get that address into a register.  */
-      if (GET_CODE (TREE_CST_RTL (exp)) == MEM
+      if (GET_CODE (temp) == MEM
 	  && modifier != EXPAND_CONST_ADDRESS
 	  && modifier != EXPAND_INITIALIZER
 	  && modifier != EXPAND_SUM
-	  && (! memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0))
+	  && (! memory_address_p (mode, XEXP (temp, 0))
 	      || (flag_force_addr
-		  && GET_CODE (XEXP (TREE_CST_RTL (exp), 0)) != REG)))
-	return replace_equiv_address (TREE_CST_RTL (exp),
-				      copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
-      return TREE_CST_RTL (exp);
+		  && GET_CODE (XEXP (temp, 0)) != REG)))
+	return replace_equiv_address (temp, copy_rtx (XEXP (temp, 0)));
+      return temp;
 
     case EXPR_WITH_FILE_LOCATION:
       {
@@ -7304,7 +7302,7 @@ expand_expr (exp, target, tmode, modifie
 	 and varasm.c assumes that's what we'll do.  */
       if (code == COMPONENT_REF
 	  && TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR
-	  && TREE_CST_RTL (TREE_OPERAND (exp, 0)) == 0)
+	  && find_rtl_for_constant (TREE_OPERAND (exp, 0)) == 0)
 	{
 	  tree elt;
 
===================================================================
Index: hooks.c
--- hooks.c	5 Mar 2003 22:37:47 -0000	1.13
+++ hooks.c	6 Apr 2003 01:00:07 -0000
@@ -49,6 +49,14 @@ hook_void_tree_int (a, b)
 {
 }
 
+/* Generic hook that takes (tree, rtx) and does nothing.  */
+void
+hook_void_tree_rtx (a, b)
+     tree a ATTRIBUTE_UNUSED;
+     rtx b ATTRIBUTE_UNUSED;
+{
+}
+
 /* Generic hook that takes (FILE *, const char *) and does nothing.  */
 void
 hook_void_FILEptr_constcharptr (a, b)
===================================================================
Index: hooks.h
--- hooks.h	5 Mar 2003 22:37:51 -0000	1.13
+++ hooks.h	6 Apr 2003 01:00:07 -0000
@@ -32,6 +32,7 @@ bool hook_bool_rtx_false PARAMS ((rtx));
 bool hook_bool_rtx_int_int_intp_false PARAMS ((rtx, int, int, int *));
 
 void hook_void_tree_int PARAMS ((tree, int));
+void hook_void_tree_rtx PARAMS ((tree, rtx));
 void hook_void_void PARAMS ((void));
 void hook_void_FILEptr_constcharptr PARAMS ((FILE *, const char *));
 void hook_void_tree PARAMS ((tree));
===================================================================
Index: rtl.h
--- rtl.h	5 Apr 2003 15:57:40 -0000	1.392
+++ rtl.h	6 Apr 2003 01:00:07 -0000
@@ -1893,6 +1893,7 @@ extern rtx gen_lowpart_SUBREG PARAMS ((e
 extern rtx find_next_ref		PARAMS ((rtx, rtx));
 
 extern rtx output_constant_def		PARAMS ((tree, int));
+extern rtx find_rtl_for_constant	PARAMS ((tree));
 
 /* Define a default value for STORE_FLAG_VALUE.  */
 
===================================================================
Index: target-def.h
--- target-def.h	5 Mar 2003 22:37:51 -0000	1.47
+++ target-def.h	6 Apr 2003 01:00:07 -0000
@@ -283,6 +283,10 @@ Foundation, 59 Temple Place - Suite 330,
 #define TARGET_ENCODE_SECTION_INFO hook_void_tree_int
 #endif
 
+#ifndef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST hook_void_tree_rtx
+#endif
+
 /* The whole shebang.  */
 #define TARGET_INITIALIZER			\
 {						\
@@ -307,6 +311,7 @@ Foundation, 59 Temple Place - Suite 330,
   TARGET_IN_SMALL_DATA_P,			\
   TARGET_BINDS_LOCAL_P,				\
   TARGET_ENCODE_SECTION_INFO,			\
+  TARGET_ENCODE_SECTION_INFO_FOR_CST,		\
   TARGET_STRIP_NAME_ENCODING,			\
   TARGET_VALID_POINTER_MODE,                    \
   TARGET_VECTOR_OPAQUE_P,			\
===================================================================
Index: target.h
--- target.h	5 Mar 2003 22:37:51 -0000	1.53
+++ target.h	6 Apr 2003 01:00:07 -0000
@@ -314,6 +314,10 @@ struct gcc_target
      the associated SYMBOL_REF.  */
   void (* encode_section_info) PARAMS ((tree, int));
 
+  /* Do something target-specific to record properties of the CONSTANT
+     into the associated SYMBOL_REF.  */
+  void (* encode_section_info_for_cst) PARAMS ((tree, rtx));
+
   /* Undo the effects of encode_section_info on the symbol string.  */
   const char * (* strip_name_encoding) PARAMS ((const char *));
 
===================================================================
Index: tree.def
--- tree.def	1 Feb 2003 18:59:48 -0000	1.56
+++ tree.def	6 Apr 2003 01:00:08 -0000
@@ -385,10 +385,8 @@ DEFTREECODE (VTABLE_REF, "vtable_ref", '
 /* Constructor: return an aggregate value made from specified components.
    In C, this is used only for structure and array initializers.
    Also used for SET_TYPE in Chill (and potentially Pascal).
-   The first "operand" is really a pointer to the RTL,
-   for constant constructors only.
-   The second operand is a list of component values
-   made out of a chain of TREE_LIST nodes.
+   The operand is a list of component values made out of a chain of
+   TREE_LIST nodes.
 
    For ARRAY_TYPE:
    The TREE_PURPOSE of each node is the corresponding index.
@@ -404,7 +402,7 @@ DEFTREECODE (VTABLE_REF, "vtable_ref", '
    The TREE_VALUE specifies a value (index) in the set that is true.
    If TREE_PURPOSE is non-NULL, it specifies the lower limit of a
    range of true values.  Elements not listed are false (not in the set).  */
-DEFTREECODE (CONSTRUCTOR, "constructor", 'e', 2)
+DEFTREECODE (CONSTRUCTOR, "constructor", 'e', 1)
 
 /* The expression types are mostly straightforward, with the fourth argument
    of DEFTREECODE saying how many operands there are.
===================================================================
Index: tree.h
--- tree.h	3 Apr 2003 18:23:00 -0000	1.388
+++ tree.h	6 Apr 2003 01:00:09 -0000
@@ -297,13 +297,6 @@ struct tree_common GTY(())
     __t; })
 
 /* These checks have to be special cased.  */
-#define CST_OR_CONSTRUCTOR_CHECK(t) __extension__			\
-({  const tree __t = (t);						\
-    enum tree_code const __c = TREE_CODE(__t);				\
-    if (__c != CONSTRUCTOR && TREE_CODE_CLASS(__c) != 'c')		\
-      tree_check_failed (__t, CONSTRUCTOR, __FILE__, __LINE__,		\
-			 __FUNCTION__);					\
-    __t; })
 #define EXPR_CHECK(t) __extension__					\
 ({  const tree __t = (t);						\
     char const __c = TREE_CODE_CLASS(TREE_CODE(__t));			\
@@ -338,7 +331,6 @@ extern void tree_vec_elt_check_failed PA
 
 #define TREE_CHECK(t, code)		(t)
 #define TREE_CLASS_CHECK(t, code)	(t)
-#define CST_OR_CONSTRUCTOR_CHECK(t)	(t)
 #define EXPR_CHECK(t)			(t)
 #define TREE_VEC_ELT_CHECK(t, i)	((t)->vec.a[i])
 
@@ -710,8 +702,6 @@ extern void tree_vec_elt_check_failed PA
 struct tree_int_cst GTY(())
 {
   struct tree_common common;
-  rtx rtl;	/* acts as link to register transfer language
-			   (rtl) info */
   /* A sub-struct is necessary here because the function `const_hash'
      wants to scan both words as a unit and taking the address of the
      sub-struct yields the properly inclusive bounded pointer.  */
@@ -721,12 +711,6 @@ struct tree_int_cst GTY(())
   } int_cst;
 };
 
-/* In REAL_CST, STRING_CST, COMPLEX_CST, VECTOR_CST nodes, and
-   CONSTRUCTOR nodes, and generally in all kinds of constants that
-   could be given labels (rather than being immediate).  */
-
-#define TREE_CST_RTL(NODE) (CST_OR_CONSTRUCTOR_CHECK (NODE)->real_cst.rtl)
-
 /* In a REAL_CST node.  struct real_value is an opaque entity, with
    manipulators defined in real.h.  We don't want tree.h depending on
    real.h and transitively on tm.h.  */
@@ -738,7 +722,6 @@ struct real_value;
 struct tree_real_cst GTY(())
 {
   struct tree_common common;
-  rtx rtl;	/* acts as link to register transfer language (rtl) info */
   struct real_value * real_cst_ptr;
 };
 
@@ -749,7 +732,6 @@ struct tree_real_cst GTY(())
 struct tree_string GTY(())
 {
   struct tree_common common;
-  rtx rtl;	/* acts as link to register transfer language (rtl) info */
   int length;
   const char *pointer;
 };
@@ -761,7 +743,6 @@ struct tree_string GTY(())
 struct tree_complex GTY(())
 {
   struct tree_common common;
-  rtx rtl;	/* acts as link to register transfer language (rtl) info */
   tree real;
   tree imag;
 };
@@ -772,7 +753,6 @@ struct tree_complex GTY(())
 struct tree_vector GTY(())
 {
   struct tree_common common;
-  rtx rtl;
   tree elements;
 };
 
@@ -845,7 +825,7 @@ struct tree_vec GTY(())
   (*(rtx *) &WITH_CLEANUP_EXPR_CHECK (NODE)->exp.operands[2])
 
 /* In a CONSTRUCTOR node.  */
-#define CONSTRUCTOR_ELTS(NODE) TREE_OPERAND (CONSTRUCTOR_CHECK (NODE), 1)
+#define CONSTRUCTOR_ELTS(NODE) TREE_OPERAND (CONSTRUCTOR_CHECK (NODE), 0)
 
 /* In ordinary expression nodes.  */
 #define TREE_OPERAND(NODE, I) (EXPR_CHECK (NODE)->exp.operands[I])
===================================================================
Index: varasm.c
--- varasm.c	1 Apr 2003 18:33:49 -0000	1.337
+++ varasm.c	6 Apr 2003 01:00:10 -0000
@@ -2090,8 +2090,6 @@ decode_addr_const (exp, value)
     case COMPLEX_CST:
     case CONSTRUCTOR:
     case INTEGER_CST:
-      /* This constant should have been output already, but we can't simply
-	 use TREE_CST_RTL since INTEGER_CST doesn't have one.  */
       x = output_constant_def (target, 1);
       break;
 
@@ -2598,6 +2596,23 @@ copy_constant (exp)
     }
 }
 
+/* If assembler code for the constant expression EXP has already been
+   output, return an rtx to refer to it.  Otherwise return 0.  */
+rtx
+find_rtl_for_constant (exp)
+     tree exp;
+{
+  int hash;
+  struct constant_descriptor_tree *desc;
+
+  hash = const_hash (exp);
+  for (desc = const_hash_table[hash]; desc; desc = desc->next)
+    if (compare_constant (exp, desc->value))
+      return desc->rtl;
+
+  return 0;
+}
+
 /* Return an rtx representing a reference to constant data in memory
    for the constant expression EXP.
 
@@ -2609,7 +2624,6 @@ copy_constant (exp)
    If DEFER is nonzero, the output of string constants can be deferred
    and output only if referenced in the function after all optimizations.
 
-   The TREE_CST_RTL of EXP is set up to point to that rtx.
    The const_hash_table records which constants already have label strings.  */
 
 rtx
@@ -2627,12 +2641,6 @@ output_constant_def (exp, defer)
   int labelno = -1;
   rtx rtl;
 
-  /* We can't just use the saved RTL if this is a deferred string constant
-     and we are not to defer anymore.  */
-  if (TREE_CODE (exp) != INTEGER_CST && TREE_CST_RTL (exp)
-      && (defer || !STRING_POOL_ADDRESS_P (XEXP (TREE_CST_RTL (exp), 0))))
-    return TREE_CST_RTL (exp);
-
   /* Make sure any other constants whose addresses appear in EXP
      are assigned label numbers.  */
 
@@ -2679,9 +2687,6 @@ output_constant_def (exp, defer)
   else
     rtl = desc->rtl;
 
-  if (TREE_CODE (exp) != INTEGER_CST)
-    TREE_CST_RTL (exp) = rtl;
-
   /* Optionally set flags or add text to the name to record information
      such as that it is a function name.  If the name is changed, the macro
      ASM_OUTPUT_LABELREF will have to know how to strip this information.  */
@@ -2689,10 +2694,7 @@ output_constant_def (exp, defer)
      encoded in it.  */
   if (! found)
     {
-      /* Take care not to invoke targetm.encode_section_info for
-	 constants which don't have a TREE_CST_RTL.  */
-      if (TREE_CODE (exp) != INTEGER_CST)
-	(*targetm.encode_section_info) (exp, true);
+      (*targetm.encode_section_info_for_cst) (exp, rtl);
 
       desc->rtl = rtl;
       desc->label = XSTR (XEXP (desc->rtl, 0), 0);
===================================================================
Index: ada/utils.c
--- ada/utils.c	16 Dec 2002 18:20:07 -0000	1.23
+++ ada/utils.c	6 Apr 2003 01:00:11 -0000
@@ -2877,17 +2877,13 @@ convert (type, expr)
     case CONSTRUCTOR:
       /* If we are converting a STRING_CST to another constrained array type,
 	 just make a new one in the proper type.  Likewise for a
-	 CONSTRUCTOR.  But if the mode of the type is different, we must
-	 ensure a new RTL is made for the constant.  */
+	 CONSTRUCTOR.  */
       if (code == ecode && AGGREGATE_TYPE_P (etype)
 	  && ! (TREE_CODE (TYPE_SIZE (etype)) == INTEGER_CST
 		&& TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST))
 	{
 	  expr = copy_node (expr);
 	  TREE_TYPE (expr) = type;
-
-	  if (TYPE_MODE (type) != TYPE_MODE (etype))
-	    TREE_CST_RTL (expr) = 0;
 
 	  return expr;
 	}
===================================================================
Index: config/alpha/alpha.c
--- config/alpha/alpha.c	24 Mar 2003 17:53:30 -0000	1.298
+++ config/alpha/alpha.c	6 Apr 2003 01:00:13 -0000
@@ -184,8 +184,12 @@ static bool decl_has_samegp
   PARAMS ((tree));
 static bool alpha_in_small_data_p
   PARAMS ((tree));
+static const char *apply_name_encoding
+  PARAMS ((const char *, int, int));
 static void alpha_encode_section_info
   PARAMS ((tree, int));
+static void alpha_encode_section_info_for_cst
+  PARAMS ((tree, rtx));
 static const char *alpha_strip_name_encoding
   PARAMS ((const char *));
 static int some_small_symbolic_operand_1
@@ -299,6 +303,8 @@ static void vms_asm_out_destructor PARAM
 #define TARGET_IN_SMALL_DATA_P alpha_in_small_data_p
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO alpha_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST alpha_encode_section_info_for_cst
 #undef TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING alpha_strip_name_encoding
 
@@ -1941,6 +1947,47 @@ alpha_in_small_data_p (exp)
   return false;
 }
 
+/* Subroutine of alpha_encode_section_info and
+   alpha_encode_section_info_for_cst.  Ensure that STR, which is the
+   name of a symbol, starts with the section-info code requested by
+   ENCODING and IS_LOCAL.  */
+
+static const char *
+apply_name_encoding (str, encoding, is_local)
+     const char *str;
+     int encoding;
+     int is_local;
+{
+  char *newstr;
+  size_t len;
+  char want_prefix = (is_local ? '@' : '%');
+  char other_prefix = (is_local ? '%' : '@');
+
+  if (!encoding)
+    /* Nothing to do.  */
+    return str;
+
+  if (str[0] == want_prefix)
+    {
+      if (str[1] == encoding)
+	/* Nothing to do.  */
+	return str;
+
+      symbol_str += 2;
+    }
+  else if (symbol_str[0] == other_prefix)
+    symbol_str += 2;
+
+  len = strlen (symbol_str) + 1;
+  newstr = alloca (len + 2);
+
+  newstr[0] = want_prefix;
+  newstr[1] = encoding;
+  memcpy (newstr + 2, symbol_str, len);
+  
+  return ggc_alloc_string (newstr, len + 2 - 1);
+}
+
 /* 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. 
@@ -1954,12 +2001,11 @@ alpha_encode_section_info (decl, first)
      tree decl;
      int first ATTRIBUTE_UNUSED;
 {
-  const char *symbol_str;
   bool is_local;
   char encoding = 0;
   rtx rtl, symbol;
 
-  rtl = DECL_P (decl) ? DECL_RTL (decl) : TREE_CST_RTL (decl);
+  rtl = DECL_RTL (decl);
 
   /* Careful not to prod global register variables.  */
   if (GET_CODE (rtl) != MEM)
@@ -2006,8 +2052,6 @@ alpha_encode_section_info (decl, first)
   if (! TARGET_EXPLICIT_RELOCS)
     return;
 
-  symbol_str = XSTR (symbol, 0);
-
   /* Care for TLS variables.  */
   if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
     {
@@ -2037,31 +2081,30 @@ alpha_encode_section_info (decl, first)
     }
 
   /* Finally, encode this into the symbol string.  */
-  if (encoding)
-    {
-      char *newstr;
-      size_t len;
-      char want_prefix = (is_local ? '@' : '%');
-      char other_prefix = (is_local ? '%' : '@');
+  XSTR (symbol, 0) = apply_name_encoding (XSTR (symbol, 0), encoding, is_local);
+}
 
-      if (symbol_str[0] == want_prefix)
-	{
-	  if (symbol_str[1] == encoding)
-	    return;
-	  symbol_str += 2;
-	}
-      else if (symbol_str[0] == other_prefix)
-	symbol_str += 2;
+/* Annotate the SYMBOL_REF entry for CST with @v or @s depending which
+   section it belongs in (all constants are local symbols, and none are
+   thread-local data).  */
 
-      len = strlen (symbol_str) + 1;
-      newstr = alloca (len + 2);
+static void
+alpha_encode_section_info_for_cst (cst, rtl)
+     tree cst;
+     rtx rtl;
+{
+  char encoding;
+  rtx symbol = XEXP (rtl, 0);
 
-      newstr[0] = want_prefix;
-      newstr[1] = encoding;
-      memcpy (newstr + 2, symbol_str, len);
-	  
-      XSTR (symbol, 0) = ggc_alloc_string (newstr, len + 2 - 1);
-    }
+  if (!TARGET_EXPLICIT_RELOCS)
+    return;
+
+  if (alpha_in_small_data_p (cst))
+    encoding = 'S';
+  else
+    encoding = 'L';
+
+  XSTR (symbol, 0) = apply_name_encoding (XSTR (symbol, 0), encoding, 1);
 }
 
 /* Undo the effects of the above.  */
===================================================================
Index: config/arm/arm-protos.h
--- config/arm/arm-protos.h	8 Mar 2003 16:23:20 -0000	1.51
+++ config/arm/arm-protos.h	6 Apr 2003 01:00:13 -0000
@@ -207,6 +207,7 @@ extern int  arm_dllimport_name_p 	PARAMS
 #ifdef TREE_CODE
 extern void arm_pe_unique_section 	PARAMS ((tree, int));
 extern void arm_pe_encode_section_info 	PARAMS ((tree, int));
+extern void arm_pe_encode_section_info_for_cst 	PARAMS ((tree, rtx));
 extern int  arm_dllexport_p 		PARAMS ((tree));
 extern int  arm_dllimport_p 		PARAMS ((tree));
 extern void arm_mark_dllexport 		PARAMS ((tree));
===================================================================
Index: config/arm/arm.c
--- config/arm/arm.c	13 Mar 2003 16:55:35 -0000	1.268
+++ config/arm/arm.c	6 Apr 2003 01:00:15 -0000
@@ -143,6 +143,7 @@ static void	 arm_elf_asm_named_section	P
 #endif
 #ifndef ARM_PE
 static void	 arm_encode_section_info	PARAMS ((tree, int));
+static void	 arm_encode_section_info_for_cst PARAMS ((tree, rtx));
 #endif
 #ifdef AOF_ASSEMBLER
 static void	 aof_globalize_label		PARAMS ((FILE *, Ccstar));
@@ -194,10 +195,13 @@ static void	 aof_globalize_label		PARAMS
 #define TARGET_SCHED_ADJUST_COST arm_adjust_cost
 
 #undef TARGET_ENCODE_SECTION_INFO
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
 #ifdef ARM_PE
 #define TARGET_ENCODE_SECTION_INFO  arm_pe_encode_section_info
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST  arm_pe_encode_section_info_for_cst
 #else
 #define TARGET_ENCODE_SECTION_INFO  arm_encode_section_info
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST  arm_pe_encode_section_info_for_cst
 #endif
 
 #undef TARGET_STRIP_NAME_ENCODING
@@ -12159,25 +12163,32 @@ arm_encode_section_info (decl, first)
   /* This doesn't work with AOF syntax, since the string table may be in
      a different AREA.  */
 #ifndef AOF_ASSEMBLER
-  if (optimize > 0 && TREE_CONSTANT (decl)
-      && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))
-    {
-      rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-                 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
-      SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
-    }
+  if (optimize > 0 && TREE_CONSTANT (decl))
+    SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
 #endif
 
   /* If we are referencing a function that is weak then encode a long call
      flag in the function name, otherwise if the function is static or
      or known to be defined in this file then encode a short call flag.  */
-  if (first && TREE_CODE_CLASS (TREE_CODE (decl)) == 'd')
+  if (first)
     {
       if (TREE_CODE (decl) == FUNCTION_DECL && DECL_WEAK (decl))
         arm_encode_call_attribute (decl, LONG_CALL_FLAG_CHAR);
       else if (! TREE_PUBLIC (decl))
         arm_encode_call_attribute (decl, SHORT_CALL_FLAG_CHAR);
     }
+}
+
+static void
+arm_encode_section_info_for_cst (cst, rtl)
+     tree cst ATTRIBUTE_UNUSED;
+     rtx rtl ATTRIBUTE_UNUSED;
+{
+#ifndef AOF_ASSEMBLER
+  if (optimize > 0
+      && (!flag_writable_strings || TREE_CODE (cst) != STRING_CST))
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
+#endif
 }
 #endif /* !ARM_PE */
 
===================================================================
Index: config/arm/pe.c
--- config/arm/pe.c	10 Feb 2003 16:33:09 -0000	1.19
+++ config/arm/pe.c	6 Apr 2003 01:00:15 -0000
@@ -212,11 +212,9 @@ arm_pe_encode_section_info (decl, first)
      int first ATTRIBUTE_UNUSED;
 {
   /* This bit is copied from arm_encode_section_info.  */
-  if (optimize > 0 && TREE_CONSTANT (decl)
-      && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))
+  if (optimize > 0 && TREE_CONSTANT (decl))
     {
-      rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-                 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
+      rtx rtl = DECL_RTL (decl);
       SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
 
@@ -246,6 +244,16 @@ arm_pe_encode_section_info (decl, first)
       /* We previously set TREE_PUBLIC and DECL_EXTERNAL.
 	 ??? We leave these alone for now.  */
     }
+}
+
+void
+arm_pe_encode_section_info_for_cst (cst, rtl)
+     tree cst;
+     rtx rtl;
+{
+  if (optimize > 0
+      && (!flag_writable_strings || TREE_CODE (cst) != STRING_CST))
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 void
===================================================================
Index: config/cris/cris.c
--- config/cris/cris.c	11 Mar 2003 15:43:25 -0000	1.37
+++ config/cris/cris.c	6 Apr 2003 01:00:16 -0000
@@ -101,6 +101,7 @@ static void cris_target_asm_function_epi
   PARAMS ((FILE *, HOST_WIDE_INT));
 
 static void cris_encode_section_info PARAMS ((tree, int));
+static void cris_encode_section_info_for_cst PARAMS ((tree, rtx));
 static void cris_operand_lossage PARAMS ((const char *, rtx));
 
 static void cris_asm_output_mi_thunk
@@ -160,6 +161,8 @@ int cris_cpu_version = CRIS_DEFAULT_CPU_
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO cris_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST cris_encode_section_info_for_cst
 
 #undef TARGET_ASM_OUTPUT_MI_THUNK
 #define TARGET_ASM_OUTPUT_MI_THUNK cris_asm_output_mi_thunk
@@ -3198,11 +3201,20 @@ cris_encode_section_info (exp, first)
 {
   if (flag_pic)
     {
-      rtx rtl = DECL_P (exp) ? DECL_RTL (exp) : TREE_CST_RTL (exp);
+      rtx rtl = DECL_RTL (exp);
 
       if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF)
 	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = (*targetm.binds_local_p) (exp);
     }
+}
+
+static void
+cris_encode_section_info_for_cst (exp, rtl)
+     tree exp ATTRIBUTE_UNUSED;
+     rtx rtl;
+{
+  if (flag_pic)
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 #if 0
===================================================================
Index: config/i386/cygming.h
--- config/i386/cygming.h	21 Mar 2003 03:57:09 -0000	1.2
+++ config/i386/cygming.h	6 Apr 2003 01:00:16 -0000
@@ -188,6 +188,8 @@ do {									\
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST  i386_pe_encode_section_info_for_cst
 #undef  TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
 
===================================================================
Index: config/i386/i386-protos.h
--- config/i386/i386-protos.h	5 Mar 2003 01:33:26 -0000	1.95
+++ config/i386/i386-protos.h	6 Apr 2003 01:00:16 -0000
@@ -237,6 +237,7 @@ extern void i386_pe_record_external_func
 extern void i386_pe_record_exported_symbol PARAMS ((const char *, int));
 extern void i386_pe_asm_file_end PARAMS ((FILE *));
 extern void i386_pe_encode_section_info PARAMS ((tree, int));
+extern void i386_pe_encode_section_info_for_cst PARAMS ((tree, rtx));
 extern const char *i386_pe_strip_name_encoding PARAMS ((const char *));
 extern const char *i386_pe_strip_name_encoding_full PARAMS ((const char *));
 extern void i386_pe_output_labelref PARAMS ((FILE *, const char *));
===================================================================
Index: config/i386/i386.c
--- config/i386/i386.c	3 Apr 2003 17:40:47 -0000	1.557
+++ config/i386/i386.c	6 Apr 2003 01:00:19 -0000
@@ -846,6 +846,8 @@ static bool ix86_cannot_force_const_mem 
 static rtx ix86_delegitimize_address PARAMS ((rtx));
 
 static void ix86_encode_section_info PARAMS ((tree, int)) ATTRIBUTE_UNUSED;
+static void ix86_encode_section_info_for_cst PARAMS ((tree, rtx))
+     ATTRIBUTE_UNUSED;
 static const char *ix86_strip_name_encoding PARAMS ((const char *))
      ATTRIBUTE_UNUSED;
 
@@ -6273,7 +6275,7 @@ ix86_encode_section_info (decl, first)
   bool local_p = (*targetm.binds_local_p) (decl);
   rtx rtl, symbol;
 
-  rtl = DECL_P (decl) ? DECL_RTL (decl) : TREE_CST_RTL (decl);
+  rtl = DECL_RTL (decl);
   if (GET_CODE (rtl) != MEM)
     return;
   symbol = XEXP (rtl, 0);
@@ -6329,6 +6331,19 @@ ix86_encode_section_info (decl, first)
 
       XSTR (symbol, 0) = ggc_alloc_string (newstr, len + 2 - 1);
     }
+}
+
+/* If PIC, mark the SYMBOL_REF for a constant-pool entry (which is by
+   definition a local symbol) so that we may access it directly in the
+   GOT.  */
+
+static void
+ix86_encode_section_info_for_cst (cst, rtl)
+     tree cst ATTRIBUTE_UNUSED;
+     rtx rtl;
+{
+  if (flag_pic)
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 /* Undo the above when printing symbol names.  */
===================================================================
Index: config/i386/i386.h
--- config/i386/i386.h	31 Mar 2003 18:33:23 -0000	1.331
+++ config/i386/i386.h	6 Apr 2003 01:00:20 -0000
@@ -2497,6 +2497,7 @@ enum ix86_builtins
 };
 
 #define TARGET_ENCODE_SECTION_INFO  ix86_encode_section_info
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST ix86_encode_section_info_for_cst
 #define TARGET_STRIP_NAME_ENCODING  ix86_strip_name_encoding
 
 #define ASM_OUTPUT_LABELREF(FILE,NAME)		\
===================================================================
Index: config/i386/win32.h
--- config/i386/win32.h	29 Aug 2002 21:40:11 -0000	1.30
+++ config/i386/win32.h	6 Apr 2003 01:00:20 -0000
@@ -116,6 +116,8 @@ Boston, MA 02111-1307, USA.  */
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST  i386_pe_encode_section_info_for_cst
 #undef  TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
 
===================================================================
Index: config/i386/winnt.c
--- config/i386/winnt.c	12 Mar 2003 08:59:29 -0000	1.41
+++ config/i386/winnt.c	6 Apr 2003 01:00:20 -0000
@@ -430,11 +430,9 @@ i386_pe_encode_section_info (decl, first
     return;
 
   /* This bit is copied from i386.h.  */
-  if (optimize > 0 && TREE_CONSTANT (decl)
-      && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))
+  if (optimize > 0 && TREE_CONSTANT (decl))
     {
-      rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-                 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
+      rtx rtl = DECL_RTL (decl);
       SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
 
@@ -481,6 +479,16 @@ i386_pe_encode_section_info (decl, first
       /* We previously set TREE_PUBLIC and DECL_EXTERNAL.
 	 We leave these alone for now.  */
     }
+}
+
+void
+i386_pe_encode_section_info_for_cst (cst, rtl)
+     tree cst;
+     rtx rtl;
+{
+  if (optimize > 0
+      && (!flag_writable_strings || TREE_CODE (cst) != STRING_CST))
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 /* Strip only the leading encoding, leaving the stdcall suffix and fastcall
===================================================================
Index: config/m32r/m32r.c
--- config/m32r/m32r.c	28 Jan 2003 18:08:51 -0000	1.61
+++ config/m32r/m32r.c	6 Apr 2003 01:00:21 -0000
@@ -394,18 +394,10 @@ m32r_encode_section_info (decl, first)
   if (!first)
     return;
 
-  switch (TREE_CODE (decl))
-    {
-    case VAR_DECL :
-    case FUNCTION_DECL :
-      model = lookup_attribute ("model", DECL_ATTRIBUTES (decl));
-      break;
-    case STRING_CST :
-    case CONSTRUCTOR :
-      /* ??? document all others that can appear here */
-    default :
-      return;
-    }
+  if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
+    return;
+
+  model = lookup_attribute ("model", DECL_ATTRIBUTES (decl));
 
   /* Only mark the object as being small data area addressable if
      it hasn't been explicitly marked with a code model.
@@ -419,8 +411,7 @@ m32r_encode_section_info (decl, first)
 
   if (! model)
     {
-      if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
-	  && DECL_SECTION_NAME (decl) != NULL_TREE)
+      if (DECL_SECTION_NAME (decl) != NULL_TREE)
 	{
 	  char *name = (char *) TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
 	  if (! strcmp (name, ".sdata") || ! strcmp (name, ".sbss"))
@@ -481,19 +472,15 @@ m32r_encode_section_info (decl, first)
 
   if (prefix != 0)
     {
-      rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-                 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
+      rtx rtl = DECL_RTL (decl);
       const char *str = XSTR (XEXP (rtl, 0), 0);
       int len = strlen (str);
-      char *newstr = ggc_alloc (len + 2);
+      char *newstr = alloca (len + 2);
 
       strcpy (newstr + 1, str);
       *newstr = prefix;
-      /* Note - we cannot leave the string in the ggc_alloc'ed space.
-         It must reside in the stringtable's domain.  */
-      newstr = (char *) ggc_alloc_string (newstr, len + 2);
 
-      XSTR (XEXP (rtl, 0), 0) = newstr;
+      XSTR (XEXP (rtl, 0), 0) = ggc_alloc_string (newstr, len + 2);
     }
 }
 
===================================================================
Index: config/m88k/m88k.c
--- config/m88k/m88k.c	28 Jan 2003 18:08:51 -0000	1.71
+++ config/m88k/m88k.c	6 Apr 2003 01:00:22 -0000
@@ -76,6 +76,7 @@ static void m88k_svr3_asm_out_destructor
 static void m88k_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT));
 static int m88k_adjust_cost PARAMS ((rtx, rtx, rtx, int));
 static void m88k_encode_section_info PARAMS ((tree, int));
+static void m88k_encode_section_info_for_cst PARAMS ((tree, rtx));
 #ifdef AS_BUG_DOT_LABELS
 static void m88k_internal_label PARAMS ((FILE *, const char *, unsigned long));
 #endif
@@ -108,6 +109,8 @@ static int m88k_address_cost PARAMS ((rt
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO  m88k_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST  m88k_encode_section_info_for_cst
 #ifdef AS_BUG_DOT_LABELS
 #undef TARGET_ASM_INTERNAL_LABEL
 #define  TARGET_ASM_INTERNAL_LABEL m88k_internal_label
@@ -3339,23 +3342,27 @@ m88k_encode_section_info (decl, first)
      tree decl;
      int first ATTRIBUTE_UNUSED;
 {
-  if (m88k_gp_threshold > 0)
+  if (m88k_gp_threshold > 0
+      && TREE_CODE (decl) == VAR_DECL
+      && (!TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl)))
     {
-      if (TREE_CODE (decl) == VAR_DECL)
-	{
-	  if (!TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl))
-	    {
-	      int size = int_size_in_bytes (TREE_TYPE (decl));
+      int size = int_size_in_bytes (TREE_TYPE (decl));
 
-	      if (size > 0 && size <= m88k_gp_threshold)
-		SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
-	    }
-	}
-      else if (TREE_CODE (decl) == STRING_CST
-	       && flag_writable_strings
-	       && TREE_STRING_LENGTH (decl) <= m88k_gp_threshold)
-	SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (decl), 0)) = 1;
+      if (size > 0 && size <= m88k_gp_threshold)
+	SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
     }
+}
+
+static void
+m88k_encode_section_info_for_cst (cst, rtl)
+     tree cst;
+     rtx rtl;
+{
+  if (m88k_gp_threshold > 0
+      && flag_writable_strings
+      && TREE_CODE (cst) == STRING_CST
+      && TREE_STRING_LENGTH (cst) <= m88k_gp_threshold)
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 #ifdef AS_BUG_DOT_LABELS /* The assembler requires a declaration of local.  */
===================================================================
Index: config/mcore/mcore.c
--- config/mcore/mcore.c	28 Jan 2003 18:08:51 -0000	1.43
+++ config/mcore/mcore.c	6 Apr 2003 01:00:22 -0000
@@ -140,6 +140,7 @@ static void	  mcore_asm_named_section   
 #endif
 static void       mcore_unique_section	       PARAMS ((tree, int));
 static void mcore_encode_section_info		PARAMS ((tree, int));
+static void mcore_encode_section_info_for_cst	PARAMS ((tree, rtx));
 static const char *mcore_strip_name_encoding	PARAMS ((const char *));
 static int        mcore_const_costs            	PARAMS ((rtx, RTX_CODE));
 static int        mcore_and_cost               	PARAMS ((rtx));
@@ -165,6 +166,8 @@ static bool       mcore_rtx_costs		PARAM
 #define TARGET_ASM_UNIQUE_SECTION mcore_unique_section
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO mcore_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST mcore_encode_section_info_for_cst
 #undef TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING mcore_strip_name_encoding
 
@@ -3469,14 +3472,8 @@ mcore_encode_section_info (decl, first)
      int first ATTRIBUTE_UNUSED;
 {
   /* This bit is copied from arm.h.  */
-  if (optimize > 0
-      && TREE_CONSTANT (decl)
-      && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))
-    {
-      rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-                 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
-      SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
-    }
+  if (optimize > 0 && TREE_CONSTANT (decl))
+    SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
 
   /* Mark the decl so we can tell from the rtl whether the object is
      dllexport'd or dllimport'd.  */
@@ -3505,6 +3502,16 @@ mcore_encode_section_info (decl, first)
       /* We previously set TREE_PUBLIC and DECL_EXTERNAL.
 	 ??? We leave these alone for now.  */
     }
+}
+
+static void
+mcore_encode_section_info_for_cst (cst, rtl)
+     tree cst;
+     rtx rtl;
+{
+  if (optimize > 0
+      && (!flag_writable_strings || TREE_CODE (cst) != STRING_CST))
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 /* Undo the effects of the above.  */
===================================================================
Index: config/mips/mips.c
--- config/mips/mips.c	1 Apr 2003 21:45:28 -0000	1.254
+++ config/mips/mips.c	6 Apr 2003 01:00:25 -0000
@@ -155,6 +155,7 @@ static void mips_select_rtx_section PARA
 					     unsigned HOST_WIDE_INT));
 static int mips_use_dfa_pipeline_interface      PARAMS ((void));
 static void mips_encode_section_info		PARAMS ((tree, int));
+static void mips_encode_section_info_for_cst	PARAMS ((tree, rtx));
 static bool mips_rtx_costs			PARAMS ((rtx, int, int, int *));
 static int mips_address_cost			PARAMS ((rtx));
 
@@ -670,6 +671,8 @@ const struct mips_cpu_info mips_cpu_info
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO mips_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST mips_encode_section_info_for_cst
 
 #undef TARGET_VALID_POINTER_MODE
 #define TARGET_VALID_POINTER_MODE mips_valid_pointer_mode
@@ -8525,33 +8528,6 @@ mips_encode_section_info (decl, first)
      tree decl;
      int first;
 {
-  if (TARGET_MIPS16)
-    {
-      if (first && TREE_CODE (decl) == STRING_CST
-	  && ! flag_writable_strings
-	  /* If this string is from a function, and the function will
-	     go in a gnu linkonce section, then we can't directly
-	     access the string.  This gets an assembler error
-	     "unsupported PC relative reference to different section".
-	     If we modify SELECT_SECTION to put it in function_section
-	     instead of text_section, it still fails because
-	     DECL_SECTION_NAME isn't set until assemble_start_function.
-	     If we fix that, it still fails because strings are shared
-	     among multiple functions, and we have cross section
-	     references again.  We force it to work by putting string
-	     addresses in the constant pool and indirecting.  */
-	  && (! current_function_decl
-	      || ! DECL_ONE_ONLY (current_function_decl)))
-	{
-	  rtx symref;
-
-	  symref = XEXP (TREE_CST_RTL (decl), 0);
-	  mips16_strings = alloc_EXPR_LIST (0, symref, mips16_strings);
-	  SYMBOL_REF_FLAG (symref) = 1;
-	  mips_string_length += TREE_STRING_LENGTH (decl);
-	}
-    }
-
   if (TARGET_EMBEDDED_DATA
       && (TREE_CODE (decl) == VAR_DECL
 	  && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl))
@@ -8567,11 +8543,8 @@ mips_encode_section_info (decl, first)
 	SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
       else if (TREE_CODE (decl) == FUNCTION_DECL)
 	SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 0;
-      else if (TREE_CODE (decl) == STRING_CST
-	       && ! flag_writable_strings)
-	SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (decl), 0)) = 0;
       else
-	SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (decl), 0)) = 1;
+	abort ();
     }
 
   else if (TREE_CODE (decl) == VAR_DECL
@@ -8601,6 +8574,50 @@ mips_encode_section_info (decl, first)
     }
 
 }
+
+static void
+mips_encode_section_info_for_cst (cst, rtl)
+     tree cst;
+     rtx rtl;
+{
+  if (TARGET_MIPS16)
+    {
+      if (TREE_CODE (cst) == STRING_CST
+	  && ! flag_writable_strings
+	  /* If this string is from a function, and the function will
+	     go in a gnu linkonce section, then we can't directly
+	     access the string.  This gets an assembler error
+	     "unsupported PC relative reference to different section".
+	     If we modify SELECT_SECTION to put it in function_section
+	     instead of text_section, it still fails because
+	     DECL_SECTION_NAME isn't set until assemble_start_function.
+	     If we fix that, it still fails because strings are shared
+	     among multiple functions, and we have cross section
+	     references again.  We force it to work by putting string
+	     addresses in the constant pool and indirecting.  */
+	  && (! current_function_decl
+	      || ! DECL_ONE_ONLY (current_function_decl)))
+	{
+	  rtx symref;
+
+	  symref = XEXP (rtl, 0);
+	  mips16_strings = alloc_EXPR_LIST (0, symref, mips16_strings);
+	  SYMBOL_REF_FLAG (symref) = 1;
+	  mips_string_length += TREE_STRING_LENGTH (decl);
+	}
+    }
+
+  if (TARGET_EMBEDDED_PIC && !TARGET_EMBEDDED_DATA)
+    {
+      if (TREE_CODE (cst) == STRING_CST
+	  && ! flag_writable_strings)
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 0;
+      else
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
+    }
+
+}
+
 
 /* Return register to use for a function return value with VALTYPE for
    function FUNC.  MODE is used instead of VALTYPE for LIBCALLs.  */
@@ -9156,9 +9173,12 @@ mips16_constant_after_function_p (x)
 		|| DECL_EXTERNAL (current_function_decl))))
     {
       struct string_constant *n;
+      rtx rtl = find_rtl_for_constant (x);
+      if (!rtl)
+	abort ();
 
       n = (struct string_constant *) xmalloc (sizeof *n);
-      n->label = XSTR (XEXP (TREE_CST_RTL (x), 0), 0);
+      n->label = XSTR (XEXP (rtl, 0), 0);
       n->next = string_constants;
       string_constants = n;
 
===================================================================
Index: config/mmix/mmix.c
--- config/mmix/mmix.c	28 Jan 2003 18:08:53 -0000	1.49
+++ config/mmix/mmix.c	6 Apr 2003 01:00:25 -0000
@@ -125,6 +125,7 @@ static void mmix_output_octa PARAMS ((FI
 static bool mmix_assemble_integer PARAMS ((rtx, unsigned int, int));
 static struct machine_function * mmix_init_machine_status PARAMS ((void));
 static void mmix_encode_section_info PARAMS ((tree, int));
+static void mmix_encode_section_info_for_cst PARAMS ((tree, rtx));
 static const char *mmix_strip_name_encoding PARAMS ((const char *));
 static void mmix_emit_sp_add PARAMS ((HOST_WIDE_INT offset));
 static void mmix_target_asm_function_prologue
@@ -165,6 +166,8 @@ static bool mmix_rtx_costs
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO  mmix_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_for_cst
+#define TARGET_ENCODE_SECTION_INFO_for_cst  mmix_encode_section_info_for_cst
 #undef TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING  mmix_strip_name_encoding
 
@@ -1244,7 +1247,7 @@ mmix_encode_section_info (decl, first)
        && (DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))
       || (TREE_CODE (decl) == FUNCTION_DECL && TREE_PUBLIC (decl)))
     ;
-  else if (first && DECL_P (decl))
+  else if (first)
     {
       /* For non-visible declarations, add a "@" prefix, which we skip
 	 when the label is output.  If the label does not have this
@@ -1279,10 +1282,16 @@ mmix_encode_section_info (decl, first)
 	  && (!DECL_INITIAL (decl)
 	      || TREE_CONSTANT (DECL_INITIAL (decl)))))
     {
-      rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-                 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
-      SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
+      SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
     }
+}
+
+static void
+mmix_encode_section_info_for_cst (cst, rtl)
+     tree cst ATTRIBUTE_UNUSED;
+     rtx rtl;
+{
+  SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 static const char *
===================================================================
Index: config/ns32k/ns32k.c
--- config/ns32k/ns32k.c	28 Jan 2003 18:08:53 -0000	1.35
+++ config/ns32k/ns32k.c	6 Apr 2003 01:00:26 -0000
@@ -72,6 +72,7 @@ const struct attribute_spec ns32k_attrib
 static void ns32k_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
 static void ns32k_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
 static void ns32k_encode_section_info PARAMS ((tree, int));
+static void ns32k_encode_section_info_for_cst PARAMS ((tree, rtx));
 static bool ns32k_rtx_costs PARAMS ((rtx, int, int, int *));
 static int ns32k_address_cost PARAMS ((rtx));
 
@@ -93,6 +94,8 @@ static int ns32k_address_cost PARAMS ((r
 #define TARGET_ASM_FUNCTION_EPILOGUE ns32k_output_function_epilogue
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO ns32k_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST ns32k_encode_section_info_for_cst
 
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS ns32k_rtx_costs
@@ -1611,11 +1614,14 @@ ns32k_encode_section_info (decl, first)
      int first ATTRIBUTE_UNUSED;
 {
   if (flag_pic)
-    {
-      rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-		 ? TREE_CST_RTL (decl) : DECL_RTL (decl));
-      SYMBOL_REF_FLAG (XEXP (rtl, 0))
-	= (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
-	   || ! TREE_PUBLIC (decl));
-    }
+    SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = ! TREE_PUBLIC (decl);
+}
+
+static void
+ns32k_encode_section_info_for_cst (cst, rtl)
+     tree cst ATTRIBUTE_UNUSED;
+     rtx rtl;
+{
+  if (flag_pic)
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
===================================================================
Index: config/pa/pa.c
--- config/pa/pa.c	23 Mar 2003 05:24:27 -0000	1.205
+++ config/pa/pa.c	6 Apr 2003 01:00:27 -0000
@@ -120,6 +120,7 @@ static int pa_issue_rate PARAMS ((void))
 static void pa_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT))
      ATTRIBUTE_UNUSED;
 static void pa_encode_section_info PARAMS ((tree, int));
+static void pa_encode_section_info_for_cst PARAMS ((tree, rtx));
 static const char *pa_strip_name_encoding PARAMS ((const char *));
 static bool pa_function_ok_for_sibcall PARAMS ((tree, tree));
 static void pa_globalize_label PARAMS ((FILE *, const char *))
@@ -205,6 +206,8 @@ static size_t n_deferred_plabels = 0;
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO pa_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST pa_encode_section_info_for_cst
 #undef TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING pa_strip_name_encoding
 
@@ -7120,16 +7123,19 @@ pa_encode_section_info (decl, first)
 {
   if (first && TEXT_SPACE_P (decl))
     {
-      rtx rtl;
-      if (TREE_CODE (decl) == FUNCTION_DECL
-	  || TREE_CODE (decl) == VAR_DECL)
-	rtl = DECL_RTL (decl);
-      else
-	rtl = TREE_CST_RTL (decl);
-      SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
+      SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
       if (TREE_CODE (decl) == FUNCTION_DECL)
 	hppa_encode_label (XEXP (DECL_RTL (decl), 0));
     }
+}
+
+static void
+pa_encode_section_info_for_cst (cst, rtl)
+     tree cst;
+     rtx rtl;
+{
+  if (TREE_CODE (cst) != STRING_CST || !flag_writable_strings)
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 /* This is sort of inverse to pa_encode_section_info.  */
===================================================================
Index: config/s390/s390.c
--- config/s390/s390.c	1 Apr 2003 17:32:33 -0000	1.86
+++ config/s390/s390.c	6 Apr 2003 01:00:29 -0000
@@ -54,6 +54,7 @@ static bool s390_assemble_integer PARAMS
 static void s390_select_rtx_section PARAMS ((enum machine_mode, rtx, 
 					     unsigned HOST_WIDE_INT));
 static void s390_encode_section_info PARAMS ((tree, int));
+static void s390_encode_section_info_for_cst PARAMS ((tree, rtx));
 static const char *s390_strip_name_encoding PARAMS ((const char *));
 static bool s390_cannot_force_const_mem PARAMS ((rtx));
 static rtx s390_delegitimize_address PARAMS ((rtx));
@@ -89,6 +90,8 @@ static int s390_address_cost PARAMS ((rt
 
 #undef	TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO s390_encode_section_info
+#undef	TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST s390_encode_section_info_for_cst
 #undef  TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING s390_strip_name_encoding
 
@@ -6427,7 +6430,7 @@ s390_encode_section_info (decl, first)
   bool local_p = (*targetm.binds_local_p) (decl);
   rtx rtl, symbol;
 
-  rtl = DECL_P (decl) ? DECL_RTL (decl) : TREE_CST_RTL (decl);
+  rtl DECL_RTL (decl);
   if (GET_CODE (rtl) != MEM)
     return;
   symbol = XEXP (rtl, 0);
@@ -6480,6 +6483,15 @@ s390_encode_section_info (decl, first)
 
       XSTR (symbol, 0) = ggc_alloc_string (newstr, len + 2 - 1);
     }
+}
+
+static void
+s390_encode_section_info_for_cst (cst, rtl)
+     tree cst ATTRIBUTE_UNUSED;
+     rtx rtl;
+{
+  if (flag_pic)
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 /* Undo the above when printing symbol names.  */
===================================================================
Index: config/sh/sh.c
--- config/sh/sh.c	4 Apr 2003 15:01:13 -0000	1.205
+++ config/sh/sh.c	6 Apr 2003 01:00:31 -0000
@@ -209,6 +209,7 @@ static bool sh_cannot_modify_jumps_p PAR
 static bool sh_ms_bitfield_layout_p PARAMS ((tree));
 
 static void sh_encode_section_info PARAMS ((tree, int));
+static void sh_encode_section_info_for_cst PARAMS ((tree, rtx));
 static const char *sh_strip_name_encoding PARAMS ((const char *));
 static void sh_init_builtins PARAMS ((void));
 static void sh_media_init_builtins PARAMS ((void));
@@ -271,6 +272,8 @@ static int sh_address_cost PARAMS ((rtx)
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO sh_encode_section_info
+#undef TARGET_ENCODE_SECTION_INFO_FOR_CST
+#define TARGET_ENCODE_SECTION_INFO_FOR_CST sh_encode_section_info_for_cst
 #undef TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING sh_strip_name_encoding
 
@@ -7669,10 +7672,8 @@ sh_encode_section_info (decl, first)
 {
   rtx rtl, symbol;
 
-  if (DECL_P (decl))
-    rtl = DECL_RTL (decl);
-  else
-    rtl = TREE_CST_RTL (decl);
+  rtl = DECL_RTL (decl);
+
   if (GET_CODE (rtl) != MEM)
     return;
   symbol = XEXP (rtl, 0);
@@ -7738,6 +7739,17 @@ sh_encode_section_info (decl, first)
 
   if (TARGET_SH5 && first && TREE_CODE (decl) != FUNCTION_DECL)
     XEXP (rtl, 0) = gen_datalabel_ref (symbol);
+}
+
+static void
+sh_encode_section_info_for_cst (cst, rtl)
+     tree cst ATTRIBUTE_UNUSED;
+     rtx rtl;
+{
+  if (flag_pic)
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
+  if (TARGET_SH5)
+    XEXP (rtl, 0) = gen_datalabel_ref (XEXP (rtl, 0));
 }
 
 /* Undo the effects of the above.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]