On 22-04-14 17:05, Tom de Vries wrote:
I've updated the fuse-caller-save patch series to model non-callee call clobbers
in CALL_INSN_FUNCTION_USAGE.

Eric,

this patch adds a post_expand_call_insn hook.

The hook is called right after expansion of calls, and allows a target to do additional processing, such as f.i. adding clobbers to CALL_INSN_FUNCTION_USAGE.

Instead of using the hook, we could add code to the preparation statements operand of the different call expands, but that requires those expands not to use the rtl template, and generate all the rtl through c code. Which requires a rewrite of the call expands in case of Aarch64.

Bootstrapped and reg-tested on x86_64 as part of the fuse-caller-save patch 
series.

OK for trunk?

Thanks,
- Tom

2014-04-18  Tom de Vries  <t...@codesourcery.com

        * target.def (post_expand_call_insn): New DEFHOOK.
        * calls.c (expand_call, emit_library_call_value_1): Call
        post_expand_call_insn hook.
        * tm.texi.in (@section Storage Layout): Add hook
        TARGET_POST_EXPAND_CALL_INSN.
        * hooks.c (hook_void_rtx): New function.
        * hooks.h (hook_void_rtx): Declare function.
diff --git a/gcc/calls.c b/gcc/calls.c
index e798c7a..0777a02 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -3507,6 +3507,8 @@ expand_call (tree exp, rtx target, int ignore)
 
   free (stack_usage_map_buf);
 
+  targetm.post_expand_call_insn (last_call_insn ());
+
   return target;
 }
 
@@ -4344,6 +4346,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
 
   free (stack_usage_map_buf);
 
+  targetm.post_expand_call_insn (last_call_insn ());
+
   return value;
 
 }
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 8af8efd..40b5bb1 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -1408,6 +1408,11 @@ registers whenever the function being expanded has any SDmode
 usage.
 @end deftypefn
 
+@deftypefn {Target Hook} void TARGET_POST_EXPAND_CALL_INSN (rtx)
+This hook is called just after expansion of a call_expr into rtl, allowing
+the target to perform additional processing.
+@end deftypefn
+
 @deftypefn {Target Hook} void TARGET_INSTANTIATE_DECLS (void)
 This hook allows the backend to perform additional instantiations on rtl
 that are not actually in any insns yet, but will be later.
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 8991c3c..812b0b8 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -1285,6 +1285,8 @@ The default definition of this macro returns false for all sizes.
 
 @hook TARGET_EXPAND_TO_RTL_HOOK
 
+@hook TARGET_POST_EXPAND_CALL_INSN
+
 @hook TARGET_INSTANTIATE_DECLS
 
 @hook TARGET_MANGLE_TYPE
diff --git a/gcc/hooks.c b/gcc/hooks.c
index 1c67bdf..53e8591 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -461,6 +461,13 @@ hook_void_rtx_int (rtx insn ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
 {
 }
 
+/* Generic hook that takes a rtx and an int and returns void.  */
+
+void
+hook_void_rtx (rtx insn ATTRIBUTE_UNUSED)
+{
+}
+
 /* Generic hook that takes a struct gcc_options * and returns void.  */
 
 void
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 896b41d..4df5ae0 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -66,6 +66,7 @@ extern bool hook_bool_dint_dint_uint_bool_true (double_int, double_int,
 
 extern void hook_void_void (void);
 extern void hook_void_constcharptr (const char *);
+extern void hook_void_rtx (rtx);
 extern void hook_void_rtx_int (rtx, int);
 extern void hook_void_FILEptr_constcharptr (FILE *, const char *);
 extern bool hook_bool_FILEptr_rtx_false (FILE *, rtx);
diff --git a/gcc/target.def b/gcc/target.def
index ae0bc9c..2f7178c 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4639,6 +4639,15 @@ usage.",
  hook_void_void)
 
 /* This target hook allows the backend to perform additional
+   processing after expansion of a call insn.  */
+DEFHOOK
+(post_expand_call_insn,
+ "This hook is called just after expansion of a call_expr into rtl, allowing\n\
+the target to perform additional processing.",
+ void, (rtx),
+ hook_void_rtx)
+
+/* This target hook allows the backend to perform additional
    instantiations on rtx that are not actually in insns yet,
    but will be later.  */
 DEFHOOK

Reply via email to