On 07/31/2016 07:42 PM, Segher Boessenkool wrote:
This patch adds a new command-line flag "-fshrink-wrap-separate", a status
flag "shrink_wrapped_separate", hooks for abstracting the target components,
and documentation for all those.
2016-06-07 Segher Boessenkool <seg...@kernel.crashing.org>
* common.opt (-fshrink-wrap-separate): New flag.
* doc/invoke.texi: Document it.
* doc/tm.texi.in (Shrink-wrapping separate components): New subsection.
* doc/tm.texi: Regenerate.
* emit-rtl.h (struct rtl_data): New field shrink_wrapped_separate.
* target.def (shrink_wrap): New hook vector.
(get_separate_components, components_for_bb, disqualify_components,
emit_prologue_components, emit_epilogue_components,
set_handled_components): New hooks.
---
gcc/common.opt | 4 ++++
gcc/doc/invoke.texi | 11 ++++++++++-
gcc/doc/tm.texi | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
gcc/doc/tm.texi.in | 29 +++++++++++++++++++++++++++
gcc/emit-rtl.h | 4 ++++
gcc/target.def | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 158 insertions(+), 1 deletion(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index 8a292ed..97d305f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 9edb006..5a5c5cab 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4852,6 +4853,59 @@ This hook should add additional registers that are
computed by the prologue to t
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 of a
non-void function. Return false if no such check should be made.
@end deftypefn
+@node Shrink-wrapping separate components
+@subsection Shrink-wrapping separate components
+@cindex shrink-wrapping separate components
+
+The prologue does a lot of separate things: save callee-saved registers,
+do whatever needs to be done to be able to call things (save the return
+address, align the stack, whatever; different for each target), set up a
+stack frame, do whatever needs to be done for the static chain (if anything),
+set up registers for PIC, etc.
The prologue may perform a variety of target dependent tasks such as
saving callee saved registers, saving the return address, aligning the
stack, create a local stack frame, initialize the PIC register, etc.
On some targets some of these tasks may be independent of others and
thus may be shrink-wrapped separately. These independent tasks are
referred to as components and are handled generically by the target
independent parts of GCC.
Each component has a slot in a sbitmap that is generated and maintained
for each basic block.
+@deftypefn {Target Hook} sbitmap TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS
(void)
+This hook should return an @code{sbitmap} with the bits set for those
+components that can be separately shrink-wrapped in the current function.
+Return @code{NULL} if the current function should not get any separate
+shrink-wrapping.
+Don't define this hook if it would always return @code{NULL}.
+If it is defined, the other hooks in this group have to be defined as well.
+@end deftypefn
+
+@deftypefn {Target Hook} sbitmap TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB
(basic_block)
+This hook should return an @code{sbitmap} with the bits set for those
+components where either the prologue component has to be executed before
+the @code{basic_block}, or the epilogue component after it, or both.
+@end deftypefn
Who is responsible for allocating and releasing the sbitmaps?
I don't have major concerns with this patch -- I'd like to see
clarification done on the ownership of the sbitmaps (ie, who allocates
and releases those objects). I'd like to see if we can get a better
introduction as well.
Jeff