aboutsummaryrefslogtreecommitdiff
path: root/gcc/target.def
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2023-12-05 09:35:57 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2023-12-05 09:35:57 +0000
commit2e0aefa77157396acb48833407637303edba450a (patch)
treeb8d825f5977a514e5273566b075e346f4b48ba7d /gcc/target.def
parenta1adce82c17577aeaaf6b9736ca8a1455d1164cb (diff)
downloadgcc-2e0aefa77157396acb48833407637303edba450a.zip
gcc-2e0aefa77157396acb48833407637303edba450a.tar.gz
gcc-2e0aefa77157396acb48833407637303edba450a.tar.bz2
Add a target hook for sibcall epilogues
Epilogues for sibling calls are generated using the sibcall_epilogue pattern. One disadvantage of this approach is that the target doesn't know which call the epilogue is for, even though the code that generates the pattern has the call to hand. Although call instructions are currently rtxes, and so could be passed as an operand to the pattern, the main point of introducing rtx_insn was to move towards separating the rtx and insn types (a good thing IMO). There also isn't an existing practice of passing genuine instructions (as opposed to labels) to instruction patterns. This patch therefore adds a hook that can be defined as an alternative to sibcall_epilogue. The advantage is that it can be passed the call; the disadvantage is that it can't use .md conveniences like generating instructions from textual patterns (although most epilogues are too complex to benefit much from that anyway). gcc/ * doc/tm.texi.in: Add TARGET_EMIT_EPILOGUE_FOR_SIBCALL. * doc/tm.texi: Regenerate. * target.def (emit_epilogue_for_sibcall): New hook. * calls.cc (can_implement_as_sibling_call_p): Use it. * function.cc (thread_prologue_and_epilogue_insns): Likewise. (reposition_prologue_and_epilogue_notes): Likewise. * config/aarch64/aarch64-protos.h (aarch64_expand_epilogue): Take an rtx_call_insn * rather than a bool. * config/aarch64/aarch64.cc (aarch64_expand_epilogue): Likewise. (TARGET_EMIT_EPILOGUE_FOR_SIBCALL): Define. * config/aarch64/aarch64.md (epilogue): Update call. (sibcall_epilogue): Delete.
Diffstat (limited to 'gcc/target.def')
-rw-r--r--gcc/target.def9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/target.def b/gcc/target.def
index 0471502..427fe52 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4174,6 +4174,15 @@ between instruction sets.",
bool, (),
hook_bool_void_false)
+DEFHOOK
+(emit_epilogue_for_sibcall,
+ "If defined, this hook emits an epilogue sequence for sibling (tail)\n\
+call instruction @var{call}. Another way of providing epilogues\n\
+for sibling calls is to define the @code{sibcall_epilogue} instruction\n\
+pattern; the main advantage of this hook over the pattern is that it\n\
+has access to the call instruction.",
+ void, (rtx_call_insn *call), NULL)
+
/* Do machine-dependent code transformations. Called just before
delayed-branch scheduling. */
DEFHOOK