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]

Re: [RFC] use symbol_ref flags for rs6000


To answer Richard's comments about the earlier version of this patch:

  It's not correct that current_file_function_operand() always returns
  false when SYMBOL_REF_FLAG is set; that is checked as part of an ||.
  The current patch sets the flag in default_encode_section_info and
  can clear it in rs6000_output_mi_thunk, as it did before.

  The symbols that are now flagged with SYMBOL_FLAG_SMALL_V4 are treated
  very differently from the generic small data symbols.  Combining them
  somehow would be very messy.

This version has been bootstrapped and regtested
powerpc-unknown-linux-gnu and regtested with a cross build for
powerpc64-unknown-linux-gnu.  The cross build included the second patch
referenced in http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01379.html,
since without it all of the C++ and F77 executable tests fail.  I keep
running into build and testing problems, so the testing of different
languages took place on different days, with different versions of the
CVS sources.  I'll fire off some more builds tonight and hope that
there aren't new problems.

Is this one OK for mainline?

2003-04-23  Janis Johnson  <janis187 at us dot ibm dot com>

	* config/rs6000/linux64.h (ASM_OUTPUT_LABELREF): Remove.
	* config/rs6000/rs6000.c (rs6000_elf_strip_name_encoding): Remove.
	(current_file_function_operand, small_data_operand, emit_move,
	rs6000_output_mi_thunk, rs6000_elf_in_small_data_p,):
	Use SYMBOL_REF_FLAGS.
	(rs6000_elf_encode_section_info): Call default_encode_section_info for
	generic flags, use SYMBOL_REF_FLAGS; code cleanups.
	* sysv4.h (TARGET_STRIP_NAME_ENCODING, ASM_OUTPUT_LABELREF): Remove.
	(SYMBOL_FLAG_SMALL_V4, SYMBOL_REF_SMALL_V4_P): New.
	* xcoff.h (ASM_DECLARE_FUNCTION_NAME): Use SYMBOL_FLAG_LOCAL.

Index: gcc/config/rs6000/linux64.h
===================================================================
RCS file: /home/janis/gcc_rsync/gcc-cvs/gcc/gcc/config/rs6000/linux64.h,v
retrieving revision 1.36
diff -u -p -r1.36 linux64.h
--- gcc/config/rs6000/linux64.h	13 Apr 2003 17:51:07 -0000	1.36
+++ gcc/config/rs6000/linux64.h	23 Apr 2003 22:46:19 -0000
@@ -271,23 +271,6 @@
 /* Dwarf2 debugging.  */
 #undef  PREFERRED_DEBUGGING_TYPE
 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-
-/* This is how to output a reference to a user-level label named NAME.
-   `assemble_name' uses this.  */
-
-/* Override elfos.h definition.  */
-#undef  ASM_OUTPUT_LABELREF
-#define ASM_OUTPUT_LABELREF(FILE,NAME)		\
-do {						\
-  const char *_name = NAME;			\
-  if (*_name == '@')				\
-    _name++;					\
- 						\
-  if (*_name == '*')				\
-    fprintf (FILE, "%s", _name + 1);		\
-  else						\
-    asm_fprintf (FILE, "%U%s", _name);		\
-} while (0)
 
 #undef  ASM_DECLARE_FUNCTION_NAME
 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /home/janis/gcc_rsync/gcc-cvs/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.460
diff -u -p -r1.460 rs6000.c
--- gcc/config/rs6000/rs6000.c	21 Apr 2003 21:47:58 -0000	1.460
+++ gcc/config/rs6000/rs6000.c	23 Apr 2003 22:46:19 -0000
@@ -231,7 +231,6 @@ static void rs6000_elf_select_rtx_sectio
 						   unsigned HOST_WIDE_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));
 #endif
 #if TARGET_XCOFF
@@ -242,7 +241,6 @@ static void rs6000_xcoff_select_section 
 static void rs6000_xcoff_unique_section PARAMS ((tree, int));
 static void rs6000_xcoff_select_rtx_section PARAMS ((enum machine_mode, rtx,
 						     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, rtx, int))
      ATTRIBUTE_UNUSED;
@@ -2100,7 +2098,7 @@ current_file_function_operand (op, mode)
      enum machine_mode mode ATTRIBUTE_UNUSED;
 {
   return (GET_CODE (op) == SYMBOL_REF
-	  && (SYMBOL_REF_FLAG (op)
+	  && (SYMBOL_REF_LOCAL_P (op)
 	      || (op == XEXP (DECL_RTL (current_function_decl), 0)
 	          && ! DECL_WEAK (current_function_decl))));
 }
@@ -2206,11 +2204,7 @@ small_data_operand (op, mode)
       sym_ref = XEXP (sum, 0);
     }
 
-  if (*XSTR (sym_ref, 0) != '@')
-    return 0;
-
-  return 1;
-
+  return SYMBOL_REF_SMALL_V4_P (sym_ref);
 #else
   return 0;
 #endif
@@ -2940,7 +2934,7 @@ rs6000_emit_move (dest, source, mode)
 	      new_ref = gen_rtx_SYMBOL_REF (Pmode, name);
 	      CONSTANT_POOL_ADDRESS_P (new_ref)
 		= CONSTANT_POOL_ADDRESS_P (operands[1]);
-	      SYMBOL_REF_FLAG (new_ref) = SYMBOL_REF_FLAG (operands[1]);
+	      SYMBOL_REF_FLAGS (new_ref) = SYMBOL_REF_FLAGS (operands[1]);
 	      SYMBOL_REF_USED (new_ref) = SYMBOL_REF_USED (operands[1]);
 	      operands[1] = new_ref;
 	    }
@@ -11753,13 +11747,13 @@ rs6000_output_mi_thunk (file, thunk_fnde
     }
   funexp = XEXP (DECL_RTL (function), 0);
 
-  SYMBOL_REF_FLAG (funexp) = 0;
+  SYMBOL_REF_FLAGS (funexp) &= ~SYMBOL_FLAG_LOCAL;
   if (current_file_function_operand (funexp, VOIDmode)
       && (! lookup_attribute ("longcall",
 			      TYPE_ATTRIBUTES (TREE_TYPE (function)))
 	  || lookup_attribute ("shortcall",
 			       TYPE_ATTRIBUTES (TREE_TYPE (function)))))
-    SYMBOL_REF_FLAG (funexp) = 1;
+    SYMBOL_REF_FLAGS (funexp) |= SYMBOL_FLAG_LOCAL;
 
   funexp = gen_rtx_MEM (FUNCTION_MODE, funexp);
 
@@ -12933,13 +12927,16 @@ rs6000_elf_unique_section (decl, reloc)
 			    flag_pic || DEFAULT_ABI == ABI_AIX);
 }
 
-/* If we are referencing a function that is static or is known to be
-   in this file, make the SYMBOL_REF special.  We can use this to indicate
-   that we can branch to this function without emitting a no-op after the
-   call.  For real AIX calling sequences, we also replace the
-   function name with the real name (1 or 2 leading .'s), rather than
-   the function descriptor name.  This saves a lot of overriding code
-   to read the prefixes.  */
+/* For a SYMBOL_REF, set generic flags and then perform some
+   target-specific processing.
+
+   Set SYMBOL_FLAG_SMALL_V4 for an operand in small memory on V.4/eabi;
+   this is different from the generic SYMBOL_FLAG_SMALL.
+
+   When the AIX ABI is requested on a non-AIX system, replace the
+   function name with the real name (with a leading .) rather than the
+   function descriptor name.  This saves a lot of overriding code to
+   read the prefixes.  */
 
 static void
 rs6000_elf_encode_section_info (decl, rtl, first)
@@ -12950,22 +12947,18 @@ rs6000_elf_encode_section_info (decl, rt
   if (!first)
     return;
 
+  default_encode_section_info (decl, rtl, first);
+
   if (TREE_CODE (decl) == FUNCTION_DECL)
     {
-      rtx sym_ref = XEXP (rtl, 0);
-      if ((*targetm.binds_local_p) (decl))
-	SYMBOL_REF_FLAG (sym_ref) = 1;
-
       if (!TARGET_AIX && DEFAULT_ABI == ABI_AIX)
 	{
-	  size_t len1 = (DEFAULT_ABI == ABI_AIX) ? 1 : 2;
-	  size_t len2 = strlen (XSTR (sym_ref, 0));
-	  char *str = alloca (len1 + len2 + 1);
+          rtx sym_ref = XEXP (rtl, 0);
+	  size_t len = strlen (XSTR (sym_ref, 0));
+	  char *str = alloca (len + 2);
 	  str[0] = '.';
-	  str[1] = '.';
-	  memcpy (str + len1, XSTR (sym_ref, 0), len2 + 1);
-
-	  XSTR (sym_ref, 0) = ggc_alloc_string (str, len1 + len2);
+	  memcpy (str + 1, XSTR (sym_ref, 0), len + 1);
+	  XSTR (sym_ref, 0) = ggc_alloc_string (str, len + 1);
 	}
     }
   else if (rs6000_sdata != SDATA_NONE
@@ -12976,56 +12969,27 @@ rs6000_elf_encode_section_info (decl, rt
       int size = int_size_in_bytes (TREE_TYPE (decl));
       tree section_name = DECL_SECTION_NAME (decl);
       const char *name = (char *)0;
-      int len = 0;
-
-      if ((*targetm.binds_local_p) (decl))
-	SYMBOL_REF_FLAG (sym_ref) = 1;
 
       if (section_name)
 	{
 	  if (TREE_CODE (section_name) == STRING_CST)
-	    {
-	      name = TREE_STRING_POINTER (section_name);
-	      len = TREE_STRING_LENGTH (section_name);
-	    }
+	    name = TREE_STRING_POINTER (section_name);
 	  else
 	    abort ();
 	}
 
       if (name
-	  ? ((len == sizeof (".sdata") - 1
-	      && strcmp (name, ".sdata") == 0)
-	     || (len == sizeof (".sdata2") - 1
-		 && strcmp (name, ".sdata2") == 0)
-	     || (len == sizeof (".sbss") - 1
-		 && strcmp (name, ".sbss") == 0)
-	     || (len == sizeof (".sbss2") - 1
-		 && strcmp (name, ".sbss2") == 0)
-	     || (len == sizeof (".PPC.EMB.sdata0") - 1
-		 && strcmp (name, ".PPC.EMB.sdata0") == 0)
-	     || (len == sizeof (".PPC.EMB.sbss0") - 1
-		 && strcmp (name, ".PPC.EMB.sbss0") == 0))
+	  ? (strcmp (name, ".sdata") == 0
+	     || strcmp (name, ".sdata2") == 0
+	     || strcmp (name, ".sbss") == 0
+	     || strcmp (name, ".sbss2") == 0
+	     || strcmp (name, ".PPC.EMB.sdata0") == 0
+	     || strcmp (name, ".PPC.EMB.sbss0") == 0)
 	  : (size > 0 && size <= g_switch_value))
-	{
-	  size_t len = strlen (XSTR (sym_ref, 0));
-	  char *str = alloca (len + 2);
-
-	  str[0] = '@';
-	  memcpy (str + 1, XSTR (sym_ref, 0), len + 1);
-	  XSTR (sym_ref, 0) = ggc_alloc_string (str, len + 1);
-	}
+	SYMBOL_REF_FLAGS (sym_ref) |= SYMBOL_FLAG_SMALL_V4;
     }
 }
 
-static const char *
-rs6000_elf_strip_name_encoding (str)
-     const char *str;
-{
-  while (*str == '*' || *str == '@')
-    str++;
-  return str;
-}
-
 static bool
 rs6000_elf_in_small_data_p (decl)
      tree decl;
@@ -13643,7 +13607,7 @@ rs6000_xcoff_encode_section_info (decl, 
 {
   if (TREE_CODE (decl) == FUNCTION_DECL
       && (*targetm.binds_local_p) (decl))
-    SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
+    SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= SYMBOL_FLAG_LOCAL;
 }
 #endif /* TARGET_XCOFF */
 
Index: gcc/config/rs6000/sysv4.h
===================================================================
RCS file: /home/janis/gcc_rsync/gcc-cvs/gcc/gcc/config/rs6000/sysv4.h,v
retrieving revision 1.121
diff -u -p -r1.121 sysv4.h
--- gcc/config/rs6000/sysv4.h	17 Apr 2003 23:18:57 -0000	1.121
+++ gcc/config/rs6000/sysv4.h	23 Apr 2003 22:46:19 -0000
@@ -766,7 +766,6 @@ extern int fixuplabelno;
 #define DBX_DEBUGGING_INFO 1
 
 #define TARGET_ENCODE_SECTION_INFO  rs6000_elf_encode_section_info
-#define TARGET_STRIP_NAME_ENCODING  rs6000_elf_strip_name_encoding
 #define TARGET_IN_SMALL_DATA_P  rs6000_elf_in_small_data_p
 #define TARGET_SECTION_TYPE_FLAGS  rs6000_elf_section_type_flags
 
@@ -775,25 +774,8 @@ extern int fixuplabelno;
 #define	RS6000_OUTPUT_BASENAME(FILE, NAME)	\
     assemble_name (FILE, NAME)
 
-/* This is how to output a reference to a user-level label named NAME.
-   `assemble_name' uses this.  */
-
-/* Override elfos.h definition.  */
-#undef	ASM_OUTPUT_LABELREF
-#define	ASM_OUTPUT_LABELREF(FILE,NAME)		\
-do {						\
-  const char *_name = NAME;			\
-  if (*_name == '@')				\
-    _name++;					\
- 						\
-  if (*_name == '*')				\
-    fprintf (FILE, "%s", _name + 1);		\
-  else						\
-    asm_fprintf (FILE, "%U%s", _name);		\
-} while (0)
-
-/* But, to make this work, we have to output the stabs for the function
-   name *first*...  */
+/* We have to output the stabs for the function name *first*, before
+   outputting its label.  */
 
 #define	DBX_FUNCTION_FIRST
 
@@ -1392,3 +1374,9 @@ ncrtn.o%s"
 
 /* Generate entries in .fixup for relocatable addresses.  */
 #define RELOCATABLE_NEEDS_FIXUP
+
+/* Define target-specific symbol_ref flags, beginning with
+   SYMBOL_REF_FLAG_DEP.  */
+#define SYMBOL_FLAG_SMALL_V4  (SYMBOL_FLAG_MACH_DEP << 0)
+#define SYMBOL_REF_SMALL_V4_P(RTX) \
+  ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_SMALL_V4) != 0)
Index: gcc/config/rs6000/xcoff.h
===================================================================
RCS file: /home/janis/gcc_rsync/gcc-cvs/gcc/gcc/config/rs6000/xcoff.h,v
retrieving revision 1.43
diff -u -p -r1.43 xcoff.h
--- gcc/config/rs6000/xcoff.h	13 Apr 2003 17:51:08 -0000	1.43
+++ gcc/config/rs6000/xcoff.h	23 Apr 2003 22:46:19 -0000
@@ -256,7 +256,7 @@ toc_section ()						\
    csect, however.
 
    We also record that the function exists in the current compilation
-   unit, reachable by short branch, by setting SYMBOL_REF_FLAG.
+   unit, reachable by short branch, by setting SYMBOL_FLAG_LOCAL.
 
    The third and fourth parameters to the .function pseudo-op (16 and 044)
    are placeholders which no longer have any use.  */
@@ -264,7 +264,7 @@ toc_section ()						\
 #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL)		\
 { rtx sym_ref = XEXP (DECL_RTL (DECL), 0);			\
   if ((*targetm.binds_local_p) (DECL))				\
-    SYMBOL_REF_FLAG (sym_ref) = 1;				\
+    SYMBOL_REF_FLAGS (sym_ref) |= SYMBOL_FLAG_LOCAL;		\
   if (TREE_PUBLIC (DECL))					\
     {								\
       if (!RS6000_WEAK || !DECL_WEAK (decl))			\


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