This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFC] use symbol_ref flags for rs6000
- From: Janis Johnson <janis187 at us dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 15 Apr 2003 16:10:46 -0700
- Subject: [RFC] use symbol_ref flags for rs6000
I'm still testing, but am I on the right track here? I'll get these
changes out of the way before resubmitting the powerpc TLS support.
rs6000_elf_encode_section_info() does a lot that isn't covered in
default_encode_section_info() and sets SYMBOL_FLAG_LOCAL under different
conditions. I thought about having the rs6000_elf version call the
default version first and then munge things around, but it's too
different.
What's the preferred way to define target-specific symbol_ref flags,
particularly after the first one? There don't seem to be any yet.
2003-04-xx 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.
(rs6000_xcoff_strip_name_encoding): Remove.
(current_file_function_operand, small_data_operand, rs6000_emit_move):
Use SYMBOL_REF_FLAGS.
(rs6000_elf_encode_section_info, (rs6000_xcoff_encode_section_info):
Set SYMBOL_REF_FLAGS.
* config/rs6000/sysv4.h (ASM_OUTPUT_LABELREF): Remove.
(SYMBOL_FLAG_SMALL_OP, SYMBOL_REF_SMALL_OP_P): New.
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 15 Apr 2003 22:28:58 -0000
@@ -272,23 +272,6 @@
#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) \
do \
Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /home/janis/gcc_rsync/gcc-cvs/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.458
diff -u -p -r1.458 rs6000.c
--- gcc/config/rs6000/rs6000.c 14 Apr 2003 22:54:35 -0000 1.458
+++ gcc/config/rs6000/rs6000.c 15 Apr 2003 22:28:58 -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, 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, int))
ATTRIBUTE_UNUSED;
@@ -2093,7 +2091,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))));
}
@@ -2199,11 +2197,7 @@ small_data_operand (op, mode)
sym_ref = XEXP (sum, 0);
}
- if (*XSTR (sym_ref, 0) != '@')
- return 0;
-
- return 1;
-
+ return SYMBOL_REF_SMALL_OP_P (sym_ref);
#else
return 0;
#endif
@@ -2933,7 +2927,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;
}
@@ -11746,13 +11740,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);
@@ -12946,7 +12940,7 @@ rs6000_elf_encode_section_info (decl, fi
{
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 (!TARGET_AIX && DEFAULT_ABI == ABI_AIX)
{
@@ -12971,7 +12965,7 @@ rs6000_elf_encode_section_info (decl, fi
int len = 0;
if ((*targetm.binds_local_p) (decl))
- SYMBOL_REF_FLAG (sym_ref) = 1;
+ SYMBOL_REF_FLAGS (sym_ref) |= SYMBOL_FLAG_LOCAL;
if (section_name)
{
@@ -12998,26 +12992,10 @@ rs6000_elf_encode_section_info (decl, fi
|| (len == sizeof (".PPC.EMB.sbss0") - 1
&& 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_OP;
}
}
-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;
@@ -13634,7 +13612,7 @@ rs6000_xcoff_encode_section_info (decl,
{
if (TREE_CODE (decl) == FUNCTION_DECL
&& (*targetm.binds_local_p) (decl))
- SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
+ SYMBOL_REF_FLAGS (XEXP (DECL_RTL (decl), 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.120
diff -u -p -r1.120 sysv4.h
--- gcc/config/rs6000/sysv4.h 13 Apr 2003 17:51:08 -0000 1.120
+++ gcc/config/rs6000/sysv4.h 15 Apr 2003 22:28:58 -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_OP SYMBOL_FLAG_MACH_DEP
+#define SYMBOL_REF_SMALL_OP_P(RTX) \
+ ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_SMALL_OP) != 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 15 Apr 2003 22:28:58 -0000
@@ -164,7 +164,6 @@ toc_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
/* FP save and restore routines. */