This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: [4.7] Adding CUMULATIVE_ARGS to targetm.calls.function_ok_for_sibcall?


Is it ok to extend targetm.function_ok_for_sibcall so that it passes
also a pointer to the callee's CUMULATIVE_ARGS structure?

In some situation it is quite tedious to recompute information like
which hard regs are used to pass arguments from the passed trees (call
expression resp., decl). This information in readily available in
args_so_far.

Ports like s390 or avr could avoid recomputation of information just
computed. (avr does not implement tail calls yet).

Patch lined out below (not yet patched any backends).

Technically, shall docs patch be against doc/tm.texi or doc/tm.texi.in?

Johann

--

Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 170651)
+++ doc/tm.texi.in	(working copy)
@@ -4889,7 +4889,14 @@ the function prologue.  Normally, the pr
 @hook TARGET_FUNCTION_OK_FOR_SIBCALL
 True if it is ok to do sibling call optimization for the specified
 call expression @var{exp}.  @var{decl} will be the called function,
-or @code{NULL} if this is an indirect call.
+or @code{NULL} if this is an indirect call. The argument @var{cum}
+points to the @code{CUMULATIVE_ARGS} data structure of the called
+function. This hook runs just before the last call to
+@code{FUNCTION_ARG} resp. @code{FUNCTION_INCOMING_ARG} with
+@code{mode=VOIDmode}.  @var{cum} serves informational purposes like,
+e.g. what hard registers are used to pass arguments to the
+callee (which might be tedious to recompute from @var{exp} or
+@var{decl} alone).

 It is not uncommon for limitations of calling conventions to prevent
 tail calls to functions outside the current unit of translation, or
Index: target.def
===================================================================
--- target.def	(revision 170651)
+++ target.def	(working copy)
@@ -1424,7 +1424,7 @@ DEFHOOK
 DEFHOOK
 (function_ok_for_sibcall,
  "",
- bool, (tree decl, tree exp),
+ bool, (tree decl, tree exp, CUMULATIVE_ARGS *cum),
  hook_bool_tree_tree_false)

 /* Establish appropriate back-end context for processing the function
Index: calls.c
===================================================================
--- calls.c	(revision 170651)
+++ calls.c	(working copy)
@@ -2323,7 +2323,7 @@ expand_call (tree exp, rtx target, int i
 #endif
       /* Check whether the target is able to optimize the call
 	 into a sibcall.  */
-      || !targetm.function_ok_for_sibcall (fndecl, exp)
+      || !targetm.function_ok_for_sibcall (fndecl, exp, &args_so_far)
       /* Functions that do not return exactly once may not be sibcall
 	 optimized.  */
       || (flags & (ECF_RETURNS_TWICE | ECF_NORETURN))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]