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]

Pass RTL as additional argument to encode_section_info


This patch adds a third argument to encode_section_info, which carries
the RTL that is to be modified.  With the exception of the PE
dllexport/dllimport code, I have also updated all definitions of
encode_section_info to use this argument instead of TREE_CST_RTL or
DECL_RTL.  (The PE code needs to be refactored anyway -- it's
duplicated in three targets and has not been updated for
SYMBOL_REF_FLAGS -- and the search-and-replace change would only
clutter up this patch.  Anyhow, as it does not use TREE_CST_RTL, it
doesn't interfere with my grander plans.)

Bootstrapped i686-linux; and all of the code affected by the patch has
been compiled.

zw

        * target.h (encode_section_info): Add new argument carrying
        the RTL to be modified by the hook.

        * varasm.c (make_decl_rtl, output_constant_def): Update calls
        to encode_section_info.
        (default_encode_section_info): Take and use RTL argument,
        don't use TREE_CST_RTL or DECL_RTL.
        * output.h: Update prototype of default_encode_section_info.
        * config/darwin.h (ASM_DECLARE_OBJECT_NAME)
        (ASM_DECLARE_FUNCTION_NAME, ASM_OUTPUT_ALIGNED_DECL_LOCAL):
        Update calls to encode_section_info.

        * config/darwin.c, config/arm/arm.c, config/arm/pe.c
        * config/h8300/h8300.c, config/i386/winnt.c, config/m32r/m32r.c
        * config/m68hc11/m68hc11.c, config/m88k/m88k.c, config/mcore/mcore.c
        * config/mips/mips.c, config/mmix/mmix.c, config/pa/pa.c
        * config/romp/romp.c, config/rs6000/rs6000.c, config/s390/s390.c
        * config/v850/v850.c (TARGET_ENCODE_SECTION_INFO definitions):
        Take and use RTL argument, don't use TREE_CST_RTL or DECL_RTL,
        except for PE dllimport/dllexport.  Update calls to
        default_encode_section_info.

        * config/darwin-protos.h, config/arm/arm-protos.h, config/i386-protos.h:
        Update prototypes.

        * doc/tm.texi (TARGET_ENCODE_SECTION_INFO): Update.

===================================================================
Index: output.h
--- output.h	11 Apr 2003 21:15:35 -0000	1.120
+++ output.h	20 Apr 2003 18:08:42 -0000
@@ -519,7 +519,7 @@ extern void default_select_rtx_section P
 						unsigned HOST_WIDE_INT));
 extern void default_elf_select_rtx_section PARAMS ((enum machine_mode, rtx,
 						    unsigned HOST_WIDE_INT));
-extern void default_encode_section_info PARAMS ((tree, int));
+extern void default_encode_section_info PARAMS ((tree, rtx, int));
 extern const char *default_strip_name_encoding PARAMS ((const char *));
 extern bool default_binds_local_p PARAMS ((tree));
 extern bool default_binds_local_p_1 PARAMS ((tree, int));
===================================================================
Index: target.h
--- target.h	5 Mar 2003 22:37:51 -0000	1.53
+++ target.h	20 Apr 2003 18:08:43 -0000
@@ -312,7 +312,7 @@ struct gcc_target
 
   /* Do something target-specific to record properties of the DECL into
      the associated SYMBOL_REF.  */
-  void (* encode_section_info) PARAMS ((tree, int));
+  void (* encode_section_info) PARAMS ((tree, rtx, int));
 
   /* Undo the effects of encode_section_info on the symbol string.  */
   const char * (* strip_name_encoding) PARAMS ((const char *));
===================================================================
Index: varasm.c
--- varasm.c	17 Apr 2003 07:34:32 -0000	1.340
+++ varasm.c	20 Apr 2003 18:08:44 -0000
@@ -809,7 +809,7 @@ make_decl_rtl (decl, asmspec)
       /* Let the target reassign the RTL if it wants.
 	 This is necessary, for example, when one machine specific
 	 decl attribute overrides another.  */
-      (* targetm.encode_section_info) (decl, false);
+      (* targetm.encode_section_info) (decl, DECL_RTL (decl), false);
       return;
     }
 
@@ -932,7 +932,7 @@ make_decl_rtl (decl, asmspec)
      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.  */
-  (* targetm.encode_section_info) (decl, true);
+  (* targetm.encode_section_info) (decl, DECL_RTL (decl), true);
 }
 
 /* Make the rtl for variable VAR be volatile.
@@ -2674,10 +2674,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) (exp, rtl, true);
 
       desc->rtl = rtl;
       desc->label = XSTR (XEXP (desc->rtl, 0), 0);
@@ -5346,14 +5343,13 @@ default_elf_select_rtx_section (mode, x,
 /* Set the generally applicable flags on the SYMBOL_REF for EXP.  */
 
 void
-default_encode_section_info (decl, first)
+default_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first ATTRIBUTE_UNUSED;
 {
-  rtx rtl, symbol;
+  rtx symbol;
   int flags;
-
-  rtl = DECL_P (decl) ? DECL_RTL (decl) : TREE_CST_RTL (decl);
 
   /* Careful not to prod global register variables.  */
   if (GET_CODE (rtl) != MEM)
===================================================================
Index: config/darwin-protos.h
--- config/darwin-protos.h	28 Jan 2003 23:26:27 -0000	1.21
+++ config/darwin-protos.h	20 Apr 2003 18:08:45 -0000
@@ -58,7 +58,7 @@ extern void machopic_define_ident PARAMS
 extern void machopic_define_name PARAMS ((const char*));
 extern int machopic_name_defined_p PARAMS ((const char*));
 extern int machopic_ident_defined_p PARAMS ((tree));
-extern void darwin_encode_section_info PARAMS ((tree, int));
+extern void darwin_encode_section_info PARAMS ((tree, rtx, int));
 extern const char *darwin_strip_name_encoding PARAMS ((const char *));
 
 #endif /* TREE_CODE */
===================================================================
Index: config/darwin.c
--- config/darwin.c	19 Mar 2003 03:23:43 -0000	1.35
+++ config/darwin.c	20 Apr 2003 18:08:45 -0000
@@ -974,8 +974,9 @@ machopic_operand_p (op)
    use later.  */
 
 void
-darwin_encode_section_info (decl, first)
+darwin_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first ATTRIBUTE_UNUSED;
 {
   char code = '\0';
@@ -1002,7 +1003,7 @@ darwin_encode_section_info (decl, first)
   if (code == '\0')
     return;
 
-  sym_ref = XEXP (DECL_RTL (decl), 0);
+  sym_ref = XEXP (rtl, 0);
   orig_str = XSTR (sym_ref, 0);
   len = strlen (orig_str) + 1;
 
===================================================================
Index: config/darwin.h
--- config/darwin.h	11 Mar 2003 01:41:06 -0000	1.49
+++ config/darwin.h	20 Apr 2003 18:08:45 -0000
@@ -379,7 +379,7 @@ do { text_section ();							\
     if ((TREE_STATIC (DECL)                                             \
 	 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
         || DECL_INITIAL (DECL))                                         \
-      (* targetm.encode_section_info) (DECL, false);			\
+      (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);	\
     ASM_OUTPUT_LABEL (FILE, xname);                                     \
   } while (0)
 
@@ -395,7 +395,7 @@ do { text_section ();							\
     if ((TREE_STATIC (DECL)                                             \
 	 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
         || DECL_INITIAL (DECL))                                         \
-      (* targetm.encode_section_info) (DECL, false);			\
+      (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);	\
     ASM_OUTPUT_LABEL (FILE, xname);                                     \
     /* Avoid generating stubs for functions we've just defined by	\
        outputting any required stub name label now.  */			\
@@ -459,7 +459,7 @@ do { text_section ();							\
     if ((DECL) && ((TREE_STATIC (DECL)					\
 	 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))		\
         || DECL_INITIAL (DECL)))					\
-      (* targetm.encode_section_info) (DECL, false);			\
+      (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);	\
     if ((DECL) && ((TREE_STATIC (DECL)					\
 	 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))		\
         || DECL_INITIAL (DECL)))					\
===================================================================
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	20 Apr 2003 18:08:46 -0000
@@ -206,7 +206,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 	PARAMS ((tree, rtx, int));
 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	20 Apr 2003 18:08:49 -0000
@@ -142,7 +142,7 @@ static void      cirrus_reorg           
 static void	 arm_elf_asm_named_section	PARAMS ((Ccstar, unsigned int));
 #endif
 #ifndef ARM_PE
-static void	 arm_encode_section_info	PARAMS ((tree, int));
+static void	 arm_encode_section_info	PARAMS ((tree, rtx, int));
 #endif
 #ifdef AOF_ASSEMBLER
 static void	 aof_globalize_label		PARAMS ((FILE *, Ccstar));
@@ -12152,8 +12152,9 @@ arm_elf_asm_named_section (name, flags)
    simplification.  */
 
 static void
-arm_encode_section_info (decl, first)
+arm_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
   /* This doesn't work with AOF syntax, since the string table may be in
@@ -12161,11 +12162,7 @@ arm_encode_section_info (decl, first)
 #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;
-    }
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 #endif
 
   /* If we are referencing a function that is weak then encode a long call
===================================================================
Index: config/arm/pe.c
--- config/arm/pe.c	10 Feb 2003 16:33:09 -0000	1.19
+++ config/arm/pe.c	20 Apr 2003 18:08:49 -0000
@@ -207,18 +207,15 @@ arm_mark_dllimport (decl)
 }
 
 void
-arm_pe_encode_section_info (decl, first)
+arm_pe_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      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))
-    {
-      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 (rtl, 0)) = 1;
 
   /* Mark the decl so we can tell from the rtl whether the object is
      dllexport'd or dllimport'd.  */
===================================================================
Index: config/h8300/h8300.c
--- config/h8300/h8300.c	17 Apr 2003 07:16:15 -0000	1.226
+++ config/h8300/h8300.c	20 Apr 2003 18:08:50 -0000
@@ -66,7 +66,7 @@ static void h8300_insert_attributes PARA
 #ifndef OBJECT_FORMAT_ELF
 static void h8300_asm_named_section PARAMS ((const char *, unsigned int));
 #endif
-static void h8300_encode_section_info PARAMS ((tree, int));
+static void h8300_encode_section_info PARAMS ((tree, rtx, int));
 static int const_costs PARAMS ((rtx, enum rtx_code, enum rtx_code));
 static int h8300_and_costs PARAMS ((rtx));
 static int h8300_shift_costs PARAMS ((rtx));
@@ -4171,13 +4171,14 @@ h8300_handle_tiny_data_attribute (node, 
 /* Mark function vectors, and various small data objects.  */
 
 static void
-h8300_encode_section_info (decl, first)
+h8300_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
   int extra_flags = 0;
 
-  default_encode_section_info (decl, first);
+  default_encode_section_info (decl, rtl, first);
 
   if (TREE_CODE (decl) == FUNCTION_DECL
       && h8300_funcvec_function_p (decl))
@@ -4192,7 +4193,7 @@ h8300_encode_section_info (decl, first)
     }
 
   if (extra_flags)
-    SYMBOL_REF_FLAGS (XEXP (DECL_RTL (decl), 0)) |= extra_flags;
+    SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= extra_flags;
 }
 
 const char *
===================================================================
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	20 Apr 2003 18:08:50 -0000
@@ -236,7 +236,7 @@ extern void i386_pe_declare_function_typ
 extern void i386_pe_record_external_function PARAMS ((const char *));
 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 PARAMS ((tree, rtx, int));
 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/winnt.c
--- config/i386/winnt.c	12 Apr 2003 20:01:28 -0000	1.43
+++ config/i386/winnt.c	20 Apr 2003 18:08:50 -0000
@@ -420,14 +420,15 @@ gen_stdcall_suffix (decl)
 }
 
 void
-i386_pe_encode_section_info (decl, first)
+i386_pe_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
   if (!first)
     return;
 
-  default_encode_section_info (decl, first);
+  default_encode_section_info (decl, rtl, first);
 
   if (TREE_CODE (decl) == FUNCTION_DECL)
     {
===================================================================
Index: config/m32r/m32r.c
--- config/m32r/m32r.c	17 Apr 2003 08:49:53 -0000	1.62
+++ config/m32r/m32r.c	20 Apr 2003 18:08:51 -0000
@@ -84,7 +84,7 @@ static int    m32r_sched_reorder   PARAM
 static int    m32r_variable_issue  PARAMS ((FILE *, int, rtx, int));
 static int    m32r_issue_rate	   PARAMS ((void));
 
-static void m32r_encode_section_info PARAMS ((tree, int));
+static void m32r_encode_section_info PARAMS ((tree, rtx, int));
 static bool m32r_in_small_data_p PARAMS ((tree));
 static void init_idents PARAMS ((void));
 static bool m32r_rtx_costs PARAMS ((rtx, int, int, int *));
@@ -349,15 +349,16 @@ m32r_handle_model_attribute (node, name,
 */
 
 static void
-m32r_encode_section_info (decl, first)
+m32r_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
   int extra_flags = 0;
   tree model_attr;
   enum m32r_model model;
 
-  default_encode_section_info (decl, first);
+  default_encode_section_info (decl, rtl, first);
 
   if (!DECL_P (decl))
     return;
@@ -394,7 +395,7 @@ m32r_encode_section_info (decl, first)
   extra_flags |= model << SYMBOL_FLAG_MODEL_SHIFT;
 
   if (extra_flags)
-    SYMBOL_REF_FLAGS (XEXP (DECL_RTL (decl), 0)) |= extra_flags;
+    SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= extra_flags;
 }
 
 /* Only mark the object as being small data area addressable if
===================================================================
Index: config/m68hc11/m68hc11.c
--- config/m68hc11/m68hc11.c	12 Apr 2003 21:52:33 -0000	1.75
+++ config/m68hc11/m68hc11.c	20 Apr 2003 18:08:52 -0000
@@ -81,7 +81,7 @@ static void asm_print_register PARAMS ((
 static void m68hc11_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
 static void m68hc11_asm_out_constructor PARAMS ((rtx, int));
 static void m68hc11_asm_out_destructor PARAMS ((rtx, int));
-static void m68hc11_encode_section_info PARAMS((tree, int));
+static void m68hc11_encode_section_info PARAMS((tree, rtx, int));
 static int autoinc_mode PARAMS((rtx));
 static int m68hc11_make_autoinc_notes PARAMS((rtx *, void *));
 
@@ -1287,19 +1287,17 @@ m68hc11_handle_fntype_attribute (node, n
    in SYMBOL_REF_FLAG.  */
 
 static void
-m68hc11_encode_section_info (decl, first)
+m68hc11_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first ATTRIBUTE_UNUSED;
 {
   tree func_attr;
   int trap_handler;
   int is_far = 0;
-  rtx rtl;
   
   if (TREE_CODE (decl) != FUNCTION_DECL)
     return;
-
-  rtl = DECL_RTL (decl);
 
   func_attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));
 
===================================================================
Index: config/m88k/m88k.c
--- config/m88k/m88k.c	28 Jan 2003 18:08:51 -0000	1.71
+++ config/m88k/m88k.c	20 Apr 2003 18:08:53 -0000
@@ -75,7 +75,7 @@ static void m88k_svr3_asm_out_destructor
 #endif
 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 PARAMS ((tree, rtx, int));
 #ifdef AS_BUG_DOT_LABELS
 static void m88k_internal_label PARAMS ((FILE *, const char *, unsigned long));
 #endif
@@ -3335,8 +3335,9 @@ m88k_adjust_cost (insn, link, dep, cost)
 /* For the m88k, determine if the item should go in the global pool.  */
 
 static void
-m88k_encode_section_info (decl, first)
+m88k_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first ATTRIBUTE_UNUSED;
 {
   if (m88k_gp_threshold > 0)
@@ -3348,13 +3349,13 @@ m88k_encode_section_info (decl, first)
 	      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;
+		SYMBOL_REF_FLAG (XEXP (rtl, 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;
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
 }
 
===================================================================
Index: config/mcore/mcore.c
--- config/mcore/mcore.c	17 Apr 2003 08:57:13 -0000	1.44
+++ config/mcore/mcore.c	20 Apr 2003 18:08:54 -0000
@@ -139,7 +139,7 @@ static void	  mcore_asm_named_section   
 							unsigned int));
 #endif
 static void       mcore_unique_section	       PARAMS ((tree, int));
-static void mcore_encode_section_info		PARAMS ((tree, int));
+static void mcore_encode_section_info		PARAMS ((tree, rtx, int));
 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));
@@ -3464,8 +3464,9 @@ mcore_dllimport_p (decl)
    install some info in the .drective (PE) or .exports (ELF) sections.   */
 
 static void
-mcore_encode_section_info (decl, first)
+mcore_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl ATTRIBUTE_UNUSED;
      int first ATTRIBUTE_UNUSED;
 {
   /* Mark the decl so we can tell from the rtl whether the object is
===================================================================
Index: config/mips/mips.c
--- config/mips/mips.c	15 Apr 2003 20:57:11 -0000	1.255
+++ config/mips/mips.c	20 Apr 2003 18:08:58 -0000
@@ -154,7 +154,7 @@ static void mips_unique_section			PARAMS
 static void mips_select_rtx_section PARAMS ((enum machine_mode, rtx,
 					     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		PARAMS ((tree, rtx, int));
 static bool mips_rtx_costs			PARAMS ((rtx, int, int, int *));
 static int mips_address_cost			PARAMS ((rtx));
 
@@ -8521,8 +8521,9 @@ mips_select_section (decl, reloc, align)
    is why the DECL_INITIAL macros differ from mips_select_section.  */
 
 static void
-mips_encode_section_info (decl, first)
+mips_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
   if (TARGET_MIPS16)
@@ -8545,7 +8546,7 @@ mips_encode_section_info (decl, first)
 	{
 	  rtx symref;
 
-	  symref = XEXP (TREE_CST_RTL (decl), 0);
+	  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);
@@ -8558,20 +8559,20 @@ mips_encode_section_info (decl, first)
       && (!DECL_INITIAL (decl)
 	  || TREE_CONSTANT (DECL_INITIAL (decl))))
     {
-      SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 0;
+      SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 0;
     }
 
   else if (TARGET_EMBEDDED_PIC)
     {
       if (TREE_CODE (decl) == VAR_DECL)
-	SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
       else if (TREE_CODE (decl) == FUNCTION_DECL)
-	SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 0;
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 0;
       else if (TREE_CODE (decl) == STRING_CST
 	       && ! flag_writable_strings)
-	SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (decl), 0)) = 0;
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 0;
       else
-	SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (decl), 0)) = 1;
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
 
   else if (TREE_CODE (decl) == VAR_DECL
@@ -8581,7 +8582,7 @@ mips_encode_section_info (decl, first)
 	       || 0 == strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
 			       ".sbss")))
     {
-      SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
+      SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
 
   /* We can not perform GP optimizations on variables which are in
@@ -8597,7 +8598,7 @@ mips_encode_section_info (decl, first)
       int size = int_size_in_bytes (TREE_TYPE (decl));
 
       if (size > 0 && size <= mips_section_threshold)
-	SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
+	SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
     }
 
 }
===================================================================
Index: config/mmix/mmix.c
--- config/mmix/mmix.c	28 Jan 2003 18:08:53 -0000	1.49
+++ config/mmix/mmix.c	20 Apr 2003 18:08:59 -0000
@@ -124,7 +124,7 @@ static HOST_WIDEST_INT mmix_intval PARAM
 static void mmix_output_octa PARAMS ((FILE *, HOST_WIDEST_INT, int));
 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 PARAMS ((tree, rtx, int));
 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
@@ -1235,8 +1235,9 @@ mmix_data_section_asm_op ()
 }
 
 static void
-mmix_encode_section_info (decl, first)
+mmix_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
   /* Test for an external declaration, and do nothing if it is one.  */
@@ -1256,7 +1257,7 @@ mmix_encode_section_info (decl, first)
 	 means that when -mtoplevel-symbols is in use, we can just handle
 	 well-behaved ISO-compliant code.  */
 
-      const char *str = XSTR (XEXP (DECL_RTL (decl), 0), 0);
+      const char *str = XSTR (XEXP (rtl, 0), 0);
       int len = strlen (str);
       char *newstr;
 
@@ -1265,7 +1266,7 @@ mmix_encode_section_info (decl, first)
 
       strcpy (newstr + 1, str);
       *newstr = '@';
-      XSTR (XEXP (DECL_RTL (decl), 0), 0) = newstr;
+      XSTR (XEXP (rtl, 0), 0) = newstr;
     }
 
   /* Set SYMBOL_REF_FLAG for things that we want to access with GETA.  We
@@ -1278,11 +1279,7 @@ mmix_encode_section_info (decl, first)
 	  && !TREE_SIDE_EFFECTS (decl)
 	  && (!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 (rtl, 0)) = 1;
 }
 
 static const char *
===================================================================
Index: config/pa/pa.c
--- config/pa/pa.c	16 Apr 2003 17:06:50 -0000	1.206
+++ config/pa/pa.c	20 Apr 2003 18:09:01 -0000
@@ -119,7 +119,7 @@ static int pa_adjust_priority PARAMS ((r
 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 PARAMS ((tree, rtx, int));
 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 *))
@@ -7114,21 +7114,16 @@ hppa_encode_label (sym)
 }
 
 static void
-pa_encode_section_info (decl, first)
+pa_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int 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;
       if (TREE_CODE (decl) == FUNCTION_DECL)
-	hppa_encode_label (XEXP (DECL_RTL (decl), 0));
+	hppa_encode_label (XEXP (rtl, 0));
     }
 }
 
===================================================================
Index: config/romp/romp.c
--- config/romp/romp.c	28 Jan 2003 18:08:53 -0000	1.30
+++ config/romp/romp.c	20 Apr 2003 18:09:02 -0000
@@ -58,7 +58,7 @@ static void romp_output_function_prologu
 static void romp_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
 static void romp_select_rtx_section PARAMS ((enum machine_mode, rtx,
 					     unsigned HOST_WIDE_INT));
-static void romp_encode_section_info PARAMS ((tree, int));
+static void romp_encode_section_info PARAMS ((tree, rtx, int));
 static bool romp_rtx_costs PARAMS ((rtx, int, int, int *));
 static int romp_address_cost PARAMS ((rtx));
 
@@ -2098,12 +2098,13 @@ romp_select_rtx_section (mode, x, align)
    that we need to mark such SYMBOL_REFs.  We do so here.  */
 
 static void
-romp_encode_section_info (decl, first)
+romp_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first ATTRIBUTE_UNUSED;
 {
   if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
-    SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 
 static bool
===================================================================
Index: config/rs6000/rs6000.c
--- config/rs6000/rs6000.c	14 Apr 2003 22:54:35 -0000	1.458
+++ config/rs6000/rs6000.c	20 Apr 2003 18:09:06 -0000
@@ -229,7 +229,7 @@ static void rs6000_elf_select_section PA
 static void rs6000_elf_unique_section PARAMS ((tree, int));
 static void rs6000_elf_select_rtx_section PARAMS ((enum machine_mode, rtx,
 						   unsigned HOST_WIDE_INT));
-static void rs6000_elf_encode_section_info PARAMS ((tree, int))
+static void rs6000_elf_encode_section_info PARAMS ((tree, rtx, int))
      ATTRIBUTE_UNUSED;
 static const char *rs6000_elf_strip_name_encoding PARAMS ((const char *));
 static bool rs6000_elf_in_small_data_p PARAMS ((tree));
@@ -244,7 +244,7 @@ static void rs6000_xcoff_select_rtx_sect
 						     unsigned HOST_WIDE_INT));
 static const char * rs6000_xcoff_strip_name_encoding PARAMS ((const char *));
 static unsigned int rs6000_xcoff_section_type_flags PARAMS ((tree, const char *, int));
-static void rs6000_xcoff_encode_section_info PARAMS ((tree, int))
+static void rs6000_xcoff_encode_section_info PARAMS ((tree, rtx, int))
      ATTRIBUTE_UNUSED;
 #endif
 #if TARGET_MACHO
@@ -12935,8 +12935,9 @@ rs6000_elf_unique_section (decl, reloc)
    to read the prefixes.  */
 
 static void
-rs6000_elf_encode_section_info (decl, first)
+rs6000_elf_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
   if (!first)
@@ -12944,7 +12945,7 @@ rs6000_elf_encode_section_info (decl, fi
 
   if (TREE_CODE (decl) == FUNCTION_DECL)
     {
-      rtx sym_ref = XEXP (DECL_RTL (decl), 0);
+      rtx sym_ref = XEXP (rtl, 0);
       if ((*targetm.binds_local_p) (decl))
 	SYMBOL_REF_FLAG (sym_ref) = 1;
 
@@ -12964,7 +12965,7 @@ rs6000_elf_encode_section_info (decl, fi
 	   && DEFAULT_ABI == ABI_V4
 	   && TREE_CODE (decl) == VAR_DECL)
     {
-      rtx sym_ref = XEXP (DECL_RTL (decl), 0);
+      rtx sym_ref = XEXP (rtl, 0);
       int size = int_size_in_bytes (TREE_TYPE (decl));
       tree section_name = DECL_SECTION_NAME (decl);
       const char *name = (char *)0;
@@ -13628,13 +13629,14 @@ rs6000_xcoff_section_type_flags (decl, n
 }
 
 static void
-rs6000_xcoff_encode_section_info (decl, first)
+rs6000_xcoff_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first ATTRIBUTE_UNUSED;
 {
   if (TREE_CODE (decl) == FUNCTION_DECL
       && (*targetm.binds_local_p) (decl))
-    SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
+    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
 }
 #endif /* TARGET_XCOFF */
 
===================================================================
Index: config/s390/s390.c
--- config/s390/s390.c	17 Apr 2003 09:59:31 -0000	1.88
+++ config/s390/s390.c	20 Apr 2003 18:09:07 -0000
@@ -57,7 +57,7 @@ Boston, MA 02111-1307, USA.  */
 static bool s390_assemble_integer PARAMS ((rtx, unsigned int, int));
 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 PARAMS ((tree, rtx, int));
 static bool s390_cannot_force_const_mem PARAMS ((rtx));
 static rtx s390_delegitimize_address PARAMS ((rtx));
 static void s390_init_builtins PARAMS ((void));
@@ -6406,17 +6406,18 @@ s390_select_rtx_section (mode, x, align)
    into its SYMBOL_REF_FLAGS.  */
 
 static void
-s390_encode_section_info (decl, first)
+s390_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
-  default_encode_section_info (decl, first);
+  default_encode_section_info (decl, rtl, first);
 
   /* If a variable has a forced alignment to < 2 bytes, mark it with
      SYMBOL_FLAG_ALIGN1 to prevent it from being used as LARL operand.  */
   if (TREE_CODE (decl) == VAR_DECL 
       && DECL_USER_ALIGN (decl) && DECL_ALIGN (decl) < 16)
-    SYMBOL_REF_FLAGS (XEXP (DECL_RTL (decl), 0)) |= SYMBOL_FLAG_ALIGN1;
+    SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= SYMBOL_FLAG_ALIGN1;
 }
 
 /* Output thunk to FILE that implements a C++ virtual function call (with
===================================================================
Index: config/v850/v850.c
--- config/v850/v850.c	17 Apr 2003 11:16:28 -0000	1.74
+++ config/v850/v850.c	20 Apr 2003 18:09:08 -0000
@@ -61,8 +61,8 @@ static tree v850_handle_interrupt_attrib
 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));
-static void v850_encode_data_area    PARAMS ((tree));
-static void v850_encode_section_info PARAMS ((tree, int));
+static void v850_encode_data_area    PARAMS ((tree, rtx));
+static void v850_encode_section_info PARAMS ((tree, rtx, int));
 
 /* Information about the various small memory areas.  */
 struct small_memory_info small_memory[ (int)SMALL_MEMORY_max ] =
@@ -2324,11 +2324,11 @@ v850_interrupt_function_p (func)
 
 
 static void
-v850_encode_data_area (decl)
+v850_encode_data_area (decl, symbol)
      tree decl;
+     rtx symbol;
 {
   int flags;
-  rtx symbol;
 
   /* Map explict sections into the appropriate attribute */
   if (v850_get_data_area (decl) == DATA_AREA_NORMAL)
@@ -2368,7 +2368,6 @@ v850_encode_data_area (decl)
 	return;
     }
 
-  symbol = XEXP (DECL_RTL (decl), 0);
   flags = SYMBOL_REF_FLAGS (symbol);
   switch (v850_get_data_area (decl))
     {
@@ -2381,15 +2380,16 @@ v850_encode_data_area (decl)
 }
 
 static void
-v850_encode_section_info (decl, first)
+v850_encode_section_info (decl, rtl, first)
      tree decl;
+     rtx rtl;
      int first;
 {
-  default_encode_section_info (decl, first);
+  default_encode_section_info (decl, rtl, first);
 
   if (TREE_CODE (decl) == VAR_DECL
       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
-    v850_encode_data_area (decl);
+    v850_encode_data_area (decl, XEXP (rtl, 0));
 }
 
 /* Return true if the given RTX is a register which can be restored
===================================================================
Index: doc/tm.texi
--- doc/tm.texi	17 Apr 2003 23:18:58 -0000	1.213
+++ doc/tm.texi	20 Apr 2003 18:09:12 -0000
@@ -6047,30 +6047,43 @@ constants in @code{flag_pic} mode in @co
 else in @code{readonly_data_section}.
 @end deftypefn
 
- at deftypefn {Target Hook} void TARGET_ENCODE_SECTION_INFO (tree @var{decl}, int @var{new_decl_p})
+ at deftypefn {Target Hook} void TARGET_ENCODE_SECTION_INFO (tree @var{decl}, rtx @var{rtl}, int @var{new_decl_p})
 Define this hook if references to a symbol or a constant must be
 treated differently depending on something about the variable or
 function named by the symbol (such as what section it is in).
 
-The hook is executed under two circumstances.  One is immediately after
-the rtl for @var{decl} that represents a variable or a function has been
-created and stored in @code{DECL_RTL(@var{decl})}.  The value of the rtl
-will be a @code{mem} whose address is a @code{symbol_ref}.  The other is
-immediately after the rtl for @var{decl} that represents a constant has
-been created and stored in @code{TREE_CST_RTL (@var{decl})}.  The macro
-is called once for each distinct constant in a source file.
+The hook is executed immediately after rtl has been created for
+ at var{decl}, which may be a variable or function declaration or
+an entry in the constant pool.  In either case, @var{rtl} is the
+rtl in question.  Do @emph{not} use @code{DECL_RTL (@var{decl})}
+or @code{TREE_CST_RTL (@var{decl})} in this hook; that field may
+not have been initialized yet.
+
+In the case of a constant, it is safe to assume that the rtl is
+a @code{mem} whose address is a @code{symbol_ref}.  Most decls
+will also have this form, but that is not guaranteed.  Global
+register variables, for instance, will have a @code{reg} for their
+rtl.  (Normally the right thing to do with such unusual rtl is
+leave it alone.)
 
 The @var{new_decl_p} argument will be true if this is the first time
-that @code{ENCODE_SECTION_INFO} has been invoked on this decl.  It will
+that @code{TARGET_ENCODE_SECTION_INFO} has been invoked on this decl.  It will
 be false for subsequent invocations, which will happen for duplicate
 declarations.  Whether or not anything must be done for the duplicate
 declaration depends on whether the hook examines @code{DECL_ATTRIBUTES}.
+ at var{new_decl_p} is always true when the hook is called for a constant.
 
 @cindex @code{SYMBOL_REF_FLAG}, in @code{TARGET_ENCODE_SECTION_INFO}
-The usual thing for this hook to do is to record a flag in the
- at code{symbol_ref} (such as @code{SYMBOL_REF_FLAG}) or to store a
-modified name string in the @code{symbol_ref} (if one bit is not
-enough information).
+The usual thing for this hook to do is to record flags in the
+ at code{symbol_ref}, using @code{SYMBOL_REF_FLAG} or @code{SYMBOL_REF_FLAGS}.
+Historically, the name string was modified if it was necessary to
+encode more than one bit of information, but this practice is now
+discouraged; use @code{SYMBOL_REF_FLAGS}.
+
+The default definition of this hook, @code{default_encode_section_info}
+in @file{varasm.c}, sets a number of commonly-useful bits in
+ at code{SYMBOL_REF_FLAGS} dot   Check whether the default does what you need
+before overriding it.
 @end deftypefn
 
 @deftypefn {Target Hook} const char *TARGET_STRIP_NAME_ENCODING (const char *name)


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