This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
rs6000_flag_pic
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 12 Mar 2003 23:23:57 +1030
- Subject: rs6000_flag_pic
This patch gets rid of rs6000_flag_pic. The motivation being that the
generic parts of gcc test flag_pic in many places to determine whether
code is being compiled for a shared library. decl_tls_model is one
such place, thus adding tls support for powerpc either requires yet
another hook just for the rs6000 back-end, or something like this
patch. As a bonus, this patch also gets rid of some target hook code,
and results in slightly better generated code on PowerPC64 since
elf_select_section and elf_unique_section no longer assume code is
always for shared libs.
It seems to me that the rs6000 back-end clears flag_pic just for the
benefit of the back-end code. If that's not the case and the intent
is that some generic parts of the compiler should always see !flag_pic
for ABI_AIX, then I guess I need to rethink this patch. (*)
A simplistic patch, if I'm correct, would replace occurrences of
flag_pic in rs6000/* with "flag_pic && DEFAULT_ABI != ABI_AIX", or
some variation on this theme. It turns out that practically all uses
of flag_pic already have a DEFAULT_ABI test or TARGET_MACHO test, so
the number of places that need changing is small. Five of the places
that don't have such a test, I believe can stay as they are. Two of
these are highlighted here by formatting changes, there's one in
rs6000_emit_load_toc_table, and two lurking in sysv4.h.
I've made one other change in this patch, again with tls support in
view, and that's the extra test in rs6000_elf_encode_section_info.
This allows powerpc64-linux to use this function rather than
rs6000_xcoff_encode_section_info.
Bootstrapped and regression tested powerpc-linux, regression tested
powerpc64-linux. OK for mainline?
* config/rs6000/rs6000.c (rs6000_flag_pic): Delete.
(rs6000_elf_select_section, rs6000_elf_unique_section): Delete.
(rs6000_xcoff_encode_section_info): #ifdef TARGET_XCOFF.
(rs6000_binds_local_p, TARGET_BINDS_LOCAL_P): #if TARGET_MACHO.
(rs6000_override_options): Don't clear flag_pic for ABI_AIX.
(rs6000_legitimize_address): Formatting.
(rs6000_emit_move): Likewise.
(rs6000_return_addr): Test ABI_AIX as well as flag_pic.
(rs6000_emit_prologue <save_LR_around_toc_setup>): Likewise.
(rs6000_elf_encode_section_info): Test !TARGET_AIX as well as ABI_AIX.
(rs6000_elf_section_type_flags): Don't assume shared lib linking when
ABI_AIX.
* config/rs6000/rs6000.h (LEGITIMATE_LO_SUM_ADDRESS_P): Test ABI_AIX
as well as flag_pic.
* config/rs6000/sysv4.h (SUBTARGET_OVERRIDE_OPTIONS): Likewise.
(MINIMAL_TOC_SECTION_ASM_OP): Likewise.
(TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): Don't define.
* config/rs6000/linux64.h (TARGET_ENCODE_SECTION_INFO): Don't define.
*) Perhaps clear flag_pic when TARGET_XCOFF.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
diff -urp -xCVS -x'*~' gcc-rs6000.orig/gcc/config/rs6000/rs6000.c gcc-rs6000/gcc/config/rs6000/rs6000.c
--- gcc-rs6000.orig/gcc/config/rs6000/rs6000.c 2003-03-11 10:58:06.000000000 +1030
+++ gcc-rs6000/gcc/config/rs6000/rs6000.c 2003-03-12 21:31:52.000000000 +1030
@@ -97,9 +97,6 @@ const char *rs6000_isel_string;
/* Set to nonzero once AIX common-mode calls have been defined. */
static GTY(()) int common_mode_defined;
-/* Private copy of original value of flag_pic for ABI_AIX. */
-static int rs6000_flag_pic;
-
/* Save information from a "cmpxx" operation until the branch or scc is
emitted. */
rtx rs6000_compare_op0, rs6000_compare_op1;
@@ -205,9 +202,6 @@ static unsigned int rs6000_elf_section_t
int));
static void rs6000_elf_asm_out_constructor PARAMS ((rtx, int));
static void rs6000_elf_asm_out_destructor PARAMS ((rtx, int));
-static void rs6000_elf_select_section PARAMS ((tree, int,
- unsigned HOST_WIDE_INT));
-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))
@@ -225,10 +219,12 @@ 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));
-#endif
static void rs6000_xcoff_encode_section_info PARAMS ((tree, int))
ATTRIBUTE_UNUSED;
+#endif
+#if TARGET_MACHO
static bool rs6000_binds_local_p PARAMS ((tree));
+#endif
static int rs6000_use_dfa_pipeline_interface PARAMS ((void));
static int rs6000_variable_issue PARAMS ((FILE *, int, rtx, int));
static bool rs6000_rtx_costs PARAMS ((rtx, int, int, int *));
@@ -403,8 +399,10 @@ static const char alt_reg_names[][8] =
#undef TARGET_EXPAND_BUILTIN
#define TARGET_EXPAND_BUILTIN rs6000_expand_builtin
+#if TARGET_MACHO
#undef TARGET_BINDS_LOCAL_P
#define TARGET_BINDS_LOCAL_P rs6000_binds_local_p
+#endif
#undef TARGET_ASM_OUTPUT_MI_THUNK
#define TARGET_ASM_OUTPUT_MI_THUNK rs6000_output_mi_thunk
@@ -637,12 +635,6 @@ rs6000_override_options (default_cpu)
}
}
- if (flag_pic != 0 && DEFAULT_ABI == ABI_AIX)
- {
- rs6000_flag_pic = flag_pic;
- flag_pic = 0;
- }
-
/* For Darwin, always silently make -fpic and -fPIC identical. */
if (flag_pic == 1 && DEFAULT_ABI == ABI_DARWIN)
flag_pic = 2;
@@ -2214,7 +2206,10 @@ rs6000_legitimize_address (x, oldx, mode
return force_reg (Pmode, x);
}
- else if (TARGET_ELF && TARGET_32BIT && TARGET_NO_TOC && ! flag_pic
+ else if (TARGET_ELF
+ && TARGET_32BIT
+ && TARGET_NO_TOC
+ && ! flag_pic
&& GET_CODE (x) != CONST_INT
&& GET_CODE (x) != CONST_DOUBLE
&& CONSTANT_P (x)
@@ -2752,7 +2747,8 @@ rs6000_emit_move (dest, source, mode)
}
if ((TARGET_ELF || DEFAULT_ABI == ABI_DARWIN)
- && TARGET_NO_TOC && ! flag_pic
+ && TARGET_NO_TOC
+ && ! flag_pic
&& mode == Pmode
&& CONSTANT_P (operands[1])
&& GET_CODE (operands[1]) != HIGH
@@ -9615,7 +9611,7 @@ rs6000_return_addr (count, frame)
/* Currently we don't optimize very well between prolog and body
code and for PIC code the code can be actually quite bad, so
don't try to be too clever here. */
- if (count != 0 || flag_pic != 0)
+ if (count != 0 || (DEFAULT_ABI != ABI_AIX && flag_pic))
{
cfun->machine->ra_needs_full_frame = 1;
@@ -10727,7 +10723,9 @@ rs6000_emit_prologue ()
it. We use R11 for this purpose because emit_load_toc_table
can use register 0. This allows us to use a plain 'blr' to return
from the procedure more often. */
- int save_LR_around_toc_setup = (TARGET_ELF && flag_pic != 0
+ int save_LR_around_toc_setup = (TARGET_ELF
+ && DEFAULT_ABI != ABI_AIX
+ && flag_pic
&& ! info->lr_save_p
&& EXIT_BLOCK_PTR->pred != NULL);
if (save_LR_around_toc_setup)
@@ -12669,39 +12667,6 @@ rs6000_elf_select_rtx_section (mode, x,
else
default_elf_select_rtx_section (mode, x, align);
}
-
-/* A C statement or statements to switch to the appropriate
- section for output of DECL. DECL is either a `VAR_DECL' node
- or a constant of some sort. RELOC indicates whether forming
- the initial value of DECL requires link-time relocations. */
-
-static void
-rs6000_elf_select_section (decl, reloc, align)
- tree decl;
- int reloc;
- unsigned HOST_WIDE_INT align;
-{
- default_elf_select_section_1 (decl, reloc, align,
- flag_pic || DEFAULT_ABI == ABI_AIX);
-}
-
-/* A C statement to build up a unique section name, expressed as a
- STRING_CST node, and assign it to DECL_SECTION_NAME (decl).
- RELOC indicates whether the initial value of EXP requires
- link-time relocations. If you do not define this macro, GCC will use
- the symbol name prefixed by `.' as the section name. Note - this
- macro can now be called for uninitialized data items as well as
- initialized data and functions. */
-
-static void
-rs6000_elf_unique_section (decl, reloc)
- tree decl;
- int reloc;
-{
- default_unique_section_1 (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
@@ -12725,7 +12690,7 @@ rs6000_elf_encode_section_info (decl, fi
if ((*targetm.binds_local_p) (decl))
SYMBOL_REF_FLAG (sym_ref) = 1;
- if (DEFAULT_ABI == ABI_AIX)
+ if (!TARGET_AIX && DEFAULT_ABI == ABI_AIX)
{
size_t len1 = (DEFAULT_ABI == ABI_AIX) ? 1 : 2;
size_t len2 = strlen (XSTR (sym_ref, 0));
@@ -13189,8 +13154,7 @@ rs6000_elf_section_type_flags (decl, nam
int reloc;
{
unsigned int flags
- = default_section_type_flags_1 (decl, name, reloc,
- flag_pic || DEFAULT_ABI == ABI_AIX);
+ = default_section_type_flags_1 (decl, name, reloc, flag_pic);
if (TARGET_RELOCATABLE)
flags |= SECTION_WRITE;
@@ -13399,10 +13363,6 @@ rs6000_xcoff_section_type_flags (decl, n
return flags | (exact_log2 (align) & SECTION_ENTSIZE);
}
-#endif /* TARGET_XCOFF */
-
-/* Note that this is also used for PPC64 Linux. */
-
static void
rs6000_xcoff_encode_section_info (decl, first)
tree decl;
@@ -13412,18 +13372,19 @@ rs6000_xcoff_encode_section_info (decl,
&& (*targetm.binds_local_p) (decl))
SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
}
+#endif /* TARGET_XCOFF */
-/* Cross-module name binding. For AIX and PPC64 Linux, which always are
- PIC, use private copy of flag_pic. Darwin does not support overriding
+#if TARGET_MACHO
+/* Cross-module name binding. Darwin does not support overriding
functions at dynamic-link time. */
static bool
rs6000_binds_local_p (decl)
tree decl;
{
- return default_binds_local_p_1 (decl,
- DEFAULT_ABI == ABI_DARWIN ? 0 : flag_pic || rs6000_flag_pic);
+ return default_binds_local_p_1 (decl, 0);
}
+#endif
/* Compute a (partial) cost for rtx X. Return true if the complete
cost has been computed, and false if subexpressions should be
diff -urp -xCVS -x'*~' gcc-rs6000.orig/gcc/config/rs6000/rs6000.h gcc-rs6000/gcc/config/rs6000/rs6000.h
--- gcc-rs6000.orig/gcc/config/rs6000/rs6000.h 2003-03-11 10:58:06.000000000 +1030
+++ gcc-rs6000/gcc/config/rs6000/rs6000.h 2003-03-11 14:27:23.000000000 +1030
@@ -2091,7 +2091,8 @@ typedef struct rs6000_args
#define LEGITIMATE_LO_SUM_ADDRESS_P(MODE, X, STRICT) \
(TARGET_ELF \
- && ! flag_pic && ! TARGET_TOC \
+ && (DEFAULT_ABI == ABI_AIX || ! flag_pic) \
+ && ! TARGET_TOC \
&& GET_MODE_NUNITS (MODE) == 1 \
&& (GET_MODE_BITSIZE (MODE) <= 32 \
|| (TARGET_HARD_FLOAT && TARGET_FPRS && (MODE) == DFmode)) \
diff -urp -xCVS -x'*~' gcc-rs6000.orig/gcc/config/rs6000/sysv4.h gcc-rs6000/gcc/config/rs6000/sysv4.h
--- gcc-rs6000.orig/gcc/config/rs6000/sysv4.h 2003-02-23 16:45:33.000000000 +1030
+++ gcc-rs6000/gcc/config/rs6000/sysv4.h 2003-03-11 14:27:21.000000000 +1030
@@ -247,8 +247,9 @@ do { \
rs6000_sdata_name); \
} \
\
- else if (flag_pic && \
- (rs6000_sdata == SDATA_EABI || rs6000_sdata == SDATA_SYSV)) \
+ else if (flag_pic && DEFAULT_ABI != ABI_AIX \
+ && (rs6000_sdata == SDATA_EABI \
+ || rs6000_sdata == SDATA_SYSV)) \
{ \
rs6000_sdata = SDATA_DATA; \
error ("-f%s and -msdata=%s are incompatible", \
@@ -292,7 +293,7 @@ do { \
} \
\
/* Treat -fPIC the same as -mrelocatable. */ \
- if (flag_pic > 1) \
+ if (flag_pic > 1 && DEFAULT_ABI != ABI_AIX) \
target_flags |= MASK_RELOCATABLE | MASK_MINIMAL_TOC | MASK_NO_FP_IN_TOC; \
\
else if (TARGET_RELOCATABLE) \
@@ -421,7 +422,8 @@ do { \
/* Put PC relative got entries in .got2. */
#define MINIMAL_TOC_SECTION_ASM_OP \
- ((TARGET_RELOCATABLE || flag_pic) ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
+ (TARGET_RELOCATABLE || (flag_pic && DEFAULT_ABI != ABI_AIX) \
+ ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
#define SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\""
#define SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\""
@@ -549,9 +551,6 @@ fini_section () \
/* Override default elf definitions. */
#undef TARGET_ASM_SELECT_RTX_SECTION
#define TARGET_ASM_SELECT_RTX_SECTION rs6000_elf_select_rtx_section
-#undef TARGET_ASM_SELECT_SECTION
-#define TARGET_ASM_SELECT_SECTION rs6000_elf_select_section
-#define TARGET_ASM_UNIQUE_SECTION rs6000_elf_unique_section
/* Return nonzero if this entry is to be written into the constant pool
in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
diff -urp -xCVS -x'*~' gcc-rs6000.orig/gcc/config/rs6000/linux64.h gcc-rs6000/gcc/config/rs6000/linux64.h
--- gcc-rs6000.orig/gcc/config/rs6000/linux64.h 2003-01-06 13:59:04.000000000 +1030
+++ gcc-rs6000/gcc/config/rs6000/linux64.h 2003-03-12 21:19:50.000000000 +1030
@@ -221,9 +221,6 @@ Boston, MA 02111-1307, USA. */
#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-#undef TARGET_ENCODE_SECTION_INFO
-#define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info
-
/* This is how to output a reference to a user-level label named NAME.
`assemble_name' uses this. */