aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/rs6000/rs6000.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-11-29 15:11:06 +1030
committerAlan Modra <amodra@gcc.gnu.org>2018-11-29 15:11:06 +1030
commit75a0b80599ca4326da8a203e042cb9db6c27ab08 (patch)
tree5ea43ae34b9d1f277ee33c2b5c731d17058797ee /gcc/config/rs6000/rs6000.c
parent645eee7431fef4cc37c5307a6c6f81fcc6c553d4 (diff)
downloadgcc-75a0b80599ca4326da8a203e042cb9db6c27ab08.zip
gcc-75a0b80599ca4326da8a203e042cb9db6c27ab08.tar.gz
gcc-75a0b80599ca4326da8a203e042cb9db6c27ab08.tar.bz2
[RS6000] rs6000_call_template for external call insn assembly output
This is a first step in tidying rs6000 call patterns, in preparation to support inline plt calls. * config/rs6000/rs6000-protos.h (rs6000_call_template): Declare. (rs6000_sibcall_template): Declare. (macho_call_template): Rename from output_call. * config/rs6000/rs6000.c (rs6000_call_template_1): New function. (rs6000_call_template, rs6000_sibcall_template): Likewise. (macho_call_template): Rename from output_call. * config/rs6000/rs6000.md (tls_gd_aix, tls_gd_sysv), (tls_gd_call_aix, tls_gd_call_sysv, tls_ld_aix, tls_ld_sysv), (tls_ld_call_aix, tls_ld_call_sysv, call_nonlocal_sysv), (call_nonlocal_sysv_secure, call_value_nonlocal_sysv), (call_value_nonlocal_sysv_secure, call_nonlocal_aix), (call_value_nonlocal_aix): Use rs6000_call_template and update occurrences of output_call to macho_call_template. (sibcall_nonlocal_sysv, sibcall_value_nonlocal_sysv, sibcall_aix), (sibcall_value_aix): Use rs6000_sibcall_template. From-SVN: r266600
Diffstat (limited to 'gcc/config/rs6000/rs6000.c')
-rw-r--r--gcc/config/rs6000/rs6000.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 965488c..7c7117c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21367,6 +21367,50 @@ rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p)
return default_assemble_integer (x, size, aligned_p);
}
+/* Return a template string for assembly to emit when making an
+ external call. FUNOP is the call mem argument operand number,
+ ARG is either NULL or a @TLSGD or @TLSLD __tls_get_addr argument
+ specifier. */
+
+static const char *
+rs6000_call_template_1 (rtx *operands ATTRIBUTE_UNUSED, unsigned int funop,
+ bool sibcall, const char *arg)
+{
+ /* -Wformat-overflow workaround, without which gcc thinks that %u
+ might produce 10 digits. */
+ gcc_assert (funop <= MAX_RECOG_OPERANDS);
+
+ /* The magic 32768 offset here corresponds to the offset of
+ r30 in .got2, as given by LCTOC1. See sysv4.h:toc_section. */
+ char z[11];
+ sprintf (z, "%%z%u%s", funop,
+ (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT && flag_pic == 2
+ ? "+32768" : ""));
+
+ static char str[32]; /* 4 spare */
+ if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
+ sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg,
+ sibcall ? "" : "\n\tnop");
+ else if (DEFAULT_ABI == ABI_V4)
+ sprintf (str, "b%s %s%s%s", sibcall ? "" : "l", z, arg,
+ flag_pic ? "@plt" : "");
+ else
+ gcc_unreachable ();
+ return str;
+}
+
+const char *
+rs6000_call_template (rtx *operands, unsigned int funop, const char *arg)
+{
+ return rs6000_call_template_1 (operands, funop, false, arg);
+}
+
+const char *
+rs6000_sibcall_template (rtx *operands, unsigned int funop, const char *arg)
+{
+ return rs6000_call_template_1 (operands, funop, true, arg);
+}
+
#if defined (HAVE_GAS_HIDDEN) && !TARGET_MACHO
/* Emit an assembler directive to set symbol visibility for DECL to
VISIBILITY_TYPE. */
@@ -32805,8 +32849,8 @@ get_prev_label (tree function_name)
CALL_DEST is the routine we are calling. */
char *
-output_call (rtx_insn *insn, rtx *operands, int dest_operand_number,
- int cookie_operand_number)
+macho_call_template (rtx_insn *insn, rtx *operands, int dest_operand_number,
+ int cookie_operand_number)
{
static char buf[256];
if (darwin_emit_branch_islands