[RFC] use symbol_ref flags for rs6000
Janis Johnson
janis187@us.ibm.com
Wed Apr 30 16:55:00 GMT 2003
Here's the patch I checked in, which incorporates requests from Richard
and David.
Small data sections for V4 are still handled separately from small data
sections for other ABIs.
Tested with bootstrap and regtest for powerpc-unknown-linux-gnu and
cross build plus regtest for powerpc64-linux. Test builds included
Alan's add_sysrooted_prefix patch, without which cross compiler tests
that need newly-built shared libraries all fail.
2003-04-30 Janis Johnson <janis187@us.ibm.com>
* config/rs6000/linux64.h (ASM_OUTPUT_LABELREF): Remove.
* config/rs6000/rs6000.c (rs6000_elf_strip_name_encoding): Remove.
(rs6000_xcoff_encode_section_info): Remove.
(current_file_function_operand): Use SYMBOL_REF_FLAGS; fix latent bug.
(rs6000_output_mi_thunk): Remove dead code; use SYMBOL_REF_FLAGS.
(small_data_operand, rs6000_emit_move, 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 (TARGET_ENCODE_SECTION_INFO): Remove.
(ASM_DECLARE_FUNCTION_NAME): Remove setting of SYMBOL_REF_FLAG.
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 30 Apr 2003 02:52:48 -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.461
diff -u -p -r1.461 rs6000.c
--- gcc/config/rs6000/rs6000.c 25 Apr 2003 17:43:58 -0000 1.461
+++ gcc/config/rs6000/rs6000.c 30 Apr 2003 02:52:48 -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
@@ -244,8 +243,6 @@ 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, rtx, int))
- ATTRIBUTE_UNUSED;
#endif
#if TARGET_MACHO
static bool rs6000_binds_local_p PARAMS ((tree));
@@ -2092,17 +2089,24 @@ call_operand (op, mode)
}
/* Return 1 if the operand is a SYMBOL_REF for a function known to be in
- this file and the function is not weakly defined. */
+ this file. */
int
current_file_function_operand (op, mode)
rtx op;
enum machine_mode mode ATTRIBUTE_UNUSED;
{
- return (GET_CODE (op) == SYMBOL_REF
- && (SYMBOL_REF_FLAG (op)
- || (op == XEXP (DECL_RTL (current_function_decl), 0)
- && ! DECL_WEAK (current_function_decl))));
+ if (GET_CODE (op) == SYMBOL_REF
+ && (SYMBOL_REF_LOCAL_P (op)
+ || (op == XEXP (DECL_RTL (current_function_decl), 0))))
+ {
+#ifdef ENABLE_CHECKING
+ if (!SYMBOL_REF_FUNCTION_P (op))
+ abort ();
+#endif
+ return 1;
+ }
+ return 0;
}
/* Return 1 if this operand is a valid input for a move insn. */
@@ -2206,11 +2210,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
@@ -2939,8 +2939,9 @@ 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]);
+ SYMBOL_REF_DECL (new_ref) = SYMBOL_REF_DECL (operands[1]);
operands[1] = new_ref;
}
@@ -11749,15 +11750,7 @@ rs6000_output_mi_thunk (file, thunk_fnde
TREE_USED (function) = 1;
}
funexp = XEXP (DECL_RTL (function), 0);
-
- SYMBOL_REF_FLAG (funexp) = 0;
- 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);
#if TARGET_MACHO
@@ -12930,13 +12923,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)
@@ -12944,26 +12940,19 @@ rs6000_elf_encode_section_info (decl, rt
rtx rtl;
int first;
{
- if (!first)
- return;
+ default_encode_section_info (decl, rtl, first);
- if (TREE_CODE (decl) == FUNCTION_DECL)
+ if (first
+ && TREE_CODE (decl) == FUNCTION_DECL
+ && !TARGET_AIX
+ && DEFAULT_ABI == ABI_AIX)
{
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);
- str[0] = '.';
- str[1] = '.';
- memcpy (str + len1, XSTR (sym_ref, 0), len2 + 1);
-
- XSTR (sym_ref, 0) = ggc_alloc_string (str, len1 + len2);
- }
+ 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);
}
else if (rs6000_sdata != SDATA_NONE
&& DEFAULT_ABI == ABI_V4
@@ -12973,56 +12962,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;
@@ -13630,17 +13590,6 @@ rs6000_xcoff_section_type_flags (decl, n
? UNITS_PER_FP_WORD : MIN_UNITS_PER_WORD);
return flags | (exact_log2 (align) & SECTION_ENTSIZE);
-}
-
-static void
-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 (rtl, 0)) = 1;
}
#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 30 Apr 2003 02:52:48 -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 30 Apr 2003 02:52:48 -0000
@@ -163,7 +163,6 @@ toc_section () \
#define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section
#define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section
#define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section
-#define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info
#define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding
#define TARGET_SECTION_TYPE_FLAGS rs6000_xcoff_section_type_flags
@@ -255,16 +254,11 @@ toc_section () \
`text_section' call previously done. We do have to go back to that
csect, however.
- We also record that the function exists in the current compilation
- unit, reachable by short branch, by setting SYMBOL_REF_FLAG.
-
The third and fourth parameters to the .function pseudo-op (16 and 044)
are placeholders which no longer have any use. */
#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; \
if (TREE_PUBLIC (DECL)) \
{ \
if (!RS6000_WEAK || !DECL_WEAK (decl)) \
More information about the Gcc-patches
mailing list