public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Problems with sibling calls
@ 2009-05-29 14:16 Georg-Johann Lay
  2009-05-29 16:14 ` Dave Korn
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Georg-Johann Lay @ 2009-05-29 14:16 UTC (permalink / raw)
  To: gcc

Hi,

I'd like to support sibling calls for a target where function args can 
be passed in call-saved registers, namely AVR.

The trouble is this: If a callee gets some arguments passed on the stack 
or in call-saved regs, the callee is not ok for a sibling call. That's 
because sibcall_epilogue executes before sibcall insns.

All this information is pretty easy available in FUNCTION_ARGS resp. 
FUNCTION_ARG_ADVANCE and can be stored in CUMULATIVE_ARGS.

However, the place where the information is needed is in 
targetm.function_ok_for_sibcall (aka. TARGET_FUNCTION_OK_FOR_SIBCALL), 
and that hook only gets the function decl and call expression trees, but 
these trees do not contain information about where the calle's arguments 
get passed.

How can that be fixed? Most probably, I am missing something, and the 
information is hidden somewhere is the trees passed to 
targetm.function_ok_for_sibcall?
All of the following fixed I considered are not nice:

=1=
Store the needed information in a static backend variable. Store in 
FUNCTION_ARG et al. and use it in TARGET_FUNCTION_OK_FOR_SIBCALL.
Bad, because this makes implications on the way calls.c runs the backend 
hooks. May break if local functions are involved.

=2=
Copy the machinery that elaborates the function arguments from calls.c 
to the backend and redo all the work on the arguments to be passed.

=3=
Introduce a new backend hook
    bool targetm.function_ok_for_sibcall_with_cum (tree, tree, 
CUMULATIVE_ARGS*);
and call it with &args_so_far from calls.c:expand_call

I'd prefer =3= but I don't want to change the middle end. =1= works 
(AVR does not implement local functions) fine but seems too hacky. =2= 
might work but is overkill.

So what am I missing here? Is there some other approach to solve this?

If =3= is appropriate I could workout a patch and provide it (calls.c, 
targetm, docs/tm.texi, ...).

Thanks much

cheers, Georg-Johann



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-06-01 14:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-29 14:16 Problems with sibling calls Georg-Johann Lay
2009-05-29 16:14 ` Dave Korn
2009-05-29 16:56   ` Georg-Johann Lay
2009-05-29 16:57     ` Dave Korn
2009-05-29 16:26 ` Ian Lance Taylor
2009-05-29 16:38   ` Georg-Johann Lay
2009-05-29 16:59     ` Dave Korn
2009-05-30 18:26 ` Ulrich Weigand
2009-06-01 14:03   ` Georg-Johann Lay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).