Define TARGET_POST_EPILOGUE_PROC if you have additional processing
after epilogue is inserted into a basic block.
gcc/ChangeLog:
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Document TARGET_POST_EPILOGUE_PROC.
* function.cc (thread_prologue_and_epilogue_insns): Allow
targets to have additional processingafter epilogue is
inserted into a basic block.
* hooks.cc (hook_void_rtx_insn): Define default handler.
* hooks.h (hook_void_rtx_insn): Declare.
* target.def: New hook.
Signed-off-by: Fei Gao <[email protected]>
---
gcc/doc/tm.texi | 5 +++++
gcc/doc/tm.texi.in | 2 ++
gcc/function.cc | 2 ++
gcc/hooks.cc | 7 +++++++
gcc/hooks.h | 1 +
gcc/target.def | 8 ++++++++
6 files changed, 25 insertions(+)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cd50078227d..666a08c0406 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5299,6 +5299,11 @@ This hook should add additional registers that are
computed by the prologue
to the hard regset for shrink-wrapping optimization purposes.
@end deftypefn
+@deftypefn {Target Hook} void TARGET_POST_EPILOGUE_PROC (rtx_insn *@var{})
+Define this hook if you have additional processing after epilogue is
+inserted into a basic block.
+@end deftypefn
+
@deftypefn {Target Hook} bool TARGET_WARN_FUNC_RETURN (tree)
True if a function's return statements should be checked for matching
the function's return type. This includes checking for falling off the end
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 058bd56487a..218e5d9dc20 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3754,6 +3754,8 @@ the function prologue. Normally, the profiling code
comes after.
@hook TARGET_SET_UP_BY_PROLOGUE
+@hook TARGET_POST_EPILOGUE_PROC
+
@hook TARGET_WARN_FUNC_RETURN
@node Shrink-wrapping separate components
diff --git a/gcc/function.cc b/gcc/function.cc
index 4edd4da1247..6f3027972ee 100644
--- a/gcc/function.cc
+++ b/gcc/function.cc
@@ -6258,6 +6258,8 @@ thread_prologue_and_epilogue_insns (void)
}
}
+ targetm.post_epilogue_proc (epilogue_seq);
+
/* Threading the prologue and epilogue changes the artificial refs in the
entry and exit blocks, and may invalidate DF info for tail calls. */
if (optimize
diff --git a/gcc/hooks.cc b/gcc/hooks.cc
index 28769074222..40844dd3593 100644
--- a/gcc/hooks.cc
+++ b/gcc/hooks.cc
@@ -501,6 +501,13 @@ hook_bool_rtx_insn_int_false (rtx_insn *, int)
return false;
}
+/* Generic hook that takes a rtx_insn * and returns void. */
+
+void
+hook_void_rtx_insn (rtx_insn *)
+{
+}
+
/* Generic hook that takes a rtx_insn * and an int and returns void. */
void
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 924748420e6..4b2f47c61c1 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -60,6 +60,7 @@ extern bool hook_bool_const_tree_hwi_hwi_const_tree_true
(const_tree,
extern bool hook_bool_rtx_insn_true (rtx_insn *);
extern bool hook_bool_rtx_false (rtx);
extern bool hook_bool_rtx_insn_int_false (rtx_insn *, int);
+extern void hook_void_rtx_insn (rtx_insn *);
extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *);
extern bool hook_bool_reg_class_t_false (reg_class_t regclass);
extern bool hook_bool_mode_mode_reg_class_t_true (machine_mode, machine_mode,
diff --git a/gcc/target.def b/gcc/target.def
index c27df8095be..cd23f569e0b 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -6840,6 +6840,14 @@ to the hard regset for shrink-wrapping optimization
purposes.",
void, (struct hard_reg_set_container *),
NULL)
+/* Post epilogue processing. */
+DEFHOOK
+(post_epilogue_proc,
+ "Define this hook if you have additional processing after epilogue is\n\
+inserted into a basic block.",
+ void, (rtx_insn *),
+ hook_void_rtx_insn)
+
/* For targets that have attributes that can affect whether a
function's return statements need checking. For instance a 'naked'
function attribute. */
--
2.17.1