summaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authoruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>2015-12-02 19:52:53 +0000
committeruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>2015-12-02 19:52:53 +0000
commit4dcc3863968e51319047b060a7c25e5954c9504c (patch)
tree15fd340dce2472a8f70811827a1383045c344076 /gcc/config
parent8fb8e6c320998bd532e99fddfb76aa320f4a8197 (diff)
downloadgcc-4dcc3863968e51319047b060a7c25e5954c9504c.tar.gz
* configure.ac: Check assembler support for R_PPC64_ENTRY relocation.
* configure: Regenerate. * config.in: Regenerate. * config/rs6000/rs6000.c (rs6000_global_entry_point_needed_p): New function. (rs6000_output_function_prologue): Use it instead of checking cfun->machine->r2_setup_needed. Use internal labels instead of GNU as local label extension. Handle ELFv2 large code model. (rs6000_output_mi_thunk): Do not set cfun->machine->r2_setup_needed. (rs6000_elf_declare_function_name): Handle ELFv2 large code model. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231202 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/rs6000/rs6000.c90
1 files changed, 80 insertions, 10 deletions
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d451d7686cc..22eb0e5b713 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -24888,6 +24888,31 @@ split_stack_arg_pointer_used_p (void)
return bitmap_bit_p (DF_LR_OUT (bb), 12);
}
+/* Return whether we need to emit an ELFv2 global entry point prologue. */
+
+static bool
+rs6000_global_entry_point_needed_p (void)
+{
+ /* Only needed for the ELFv2 ABI. */
+ if (DEFAULT_ABI != ABI_ELFv2)
+ return false;
+
+ /* With -msingle-pic-base, we assume the whole program shares the same
+ TOC, so no global entry point prologues are needed anywhere. */
+ if (TARGET_SINGLE_PIC_BASE)
+ return false;
+
+ /* Ensure we have a global entry point for thunks. ??? We could
+ avoid that if the target routine doesn't need a global entry point,
+ but we do not know whether this is the case at this point. */
+ if (cfun->is_thunk)
+ return true;
+
+ /* For regular functions, rs6000_emit_prologue sets this flag if the
+ routine ever uses the TOC pointer. */
+ return cfun->machine->r2_setup_needed;
+}
+
/* Emit function prologue as insns. */
void
@@ -25951,12 +25976,52 @@ rs6000_output_function_prologue (FILE *file,
/* ELFv2 ABI r2 setup code and local entry point. This must follow
immediately after the global entry point label. */
- if (DEFAULT_ABI == ABI_ELFv2 && cfun->machine->r2_setup_needed)
+ if (rs6000_global_entry_point_needed_p ())
{
const char *name = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
- fprintf (file, "0:\taddis 2,12,.TOC.-0b@ha\n");
- fprintf (file, "\taddi 2,2,.TOC.-0b@l\n");
+ (*targetm.asm_out.internal_label) (file, "LCF", rs6000_pic_labelno);
+
+ if (TARGET_CMODEL != CMODEL_LARGE)
+ {
+ /* In the small and medium code models, we assume the TOC is less
+ 2 GB away from the text section, so it can be computed via the
+ following two-instruction sequence. */
+ char buf[256];
+
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno);
+ fprintf (file, "0:\taddis 2,12,.TOC.-");
+ assemble_name (file, buf);
+ fprintf (file, "@ha\n");
+ fprintf (file, "\taddi 2,2,.TOC.-");
+ assemble_name (file, buf);
+ fprintf (file, "@l\n");
+ }
+ else
+ {
+ /* In the large code model, we allow arbitrary offsets between the
+ TOC and the text section, so we have to load the offset from
+ memory. The data field is emitted directly before the global
+ entry point in rs6000_elf_declare_function_name. */
+ char buf[256];
+
+#ifdef HAVE_AS_ENTRY_MARKERS
+ /* If supported by the linker, emit a marker relocation. If the
+ total code size of the final executable or shared library
+ happens to fit into 2 GB after all, the linker will replace
+ this code sequence with the sequence for the small or medium
+ code model. */
+ fprintf (file, "\t.reloc .,R_PPC64_ENTRY\n");
+#endif
+ fprintf (file, "\tld 2,");
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LCL", rs6000_pic_labelno);
+ assemble_name (file, buf);
+ fprintf (file, "-");
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno);
+ assemble_name (file, buf);
+ fprintf (file, "(12)\n");
+ fprintf (file, "\tadd 2,2,12\n");
+ }
fputs ("\t.localentry\t", file);
assemble_name (file, name);
@@ -27620,13 +27685,6 @@ rs6000_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
SIBLING_CALL_P (insn) = 1;
emit_barrier ();
- /* Ensure we have a global entry point for the thunk. ??? We could
- avoid that if the target routine doesn't need a global entry point,
- but we do not know whether this is the case at this point. */
- if (DEFAULT_ABI == ABI_ELFv2
- && !TARGET_SINGLE_PIC_BASE)
- cfun->machine->r2_setup_needed = true;
-
/* Run just enough of rest_of_compilation to get the insns emitted.
There's not really enough bulk here to make other passes such as
instruction scheduling worth while. Note that use_thunk calls
@@ -31493,6 +31551,18 @@ rs6000_elf_declare_function_name (FILE *file, const char *name, tree decl)
ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
ASM_DECLARE_RESULT (file, DECL_RESULT (decl));
+ if (TARGET_CMODEL == CMODEL_LARGE && rs6000_global_entry_point_needed_p ())
+ {
+ char buf[256];
+
+ (*targetm.asm_out.internal_label) (file, "LCL", rs6000_pic_labelno);
+
+ fprintf (file, "\t.quad .TOC.-");
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LCF", rs6000_pic_labelno);
+ assemble_name (file, buf);
+ putc ('\n', file);
+ }
+
if (DEFAULT_ABI == ABI_AIX)
{
const char *desc_name, *orig_name;