This is the mail archive of the gcc-patches@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]

Re: hookize function_arg_callee_copies


On Sep 15, 2004, Joern Rennecke <joern.rennecke@superh.com> wrote:

>> > Joern, please explain the rationale behind the current formation
>> > of sh_callee_copies.  It looks wrong to me.
>> 
>> This code has actually been written by Alexandre.
>> It is there for SHcompact support, and the callee copies for SHcompact are
>> performed by __GCC_shcompact_incoming_args.

> Hmm, we actually have caller copies here that look like and are described as
> callee copies to the target independent code, but are performed by
> __GCC_shcompact_call_trampoline.

Yup.  The problem here is that the SH5 ABI defines that some types are
to be passed in 64-bit registers, even when SHcompact only has access
to the lower 32 bits.  So we go through a number of contortions to
conform to the ABI.

One of the contortions is to have a call trampoline that takes a magic
cookie describing a number of operations to be performed, such as
copying registers around, popping contents off the stack, loading
contents from the addresses in them, etc, and then calling the actual
function.

In some such cases, we want neither the caller nor the callee to
perform a copy, leaving it up to the trampoline code to perform it if
needed.  The most common case is that of passing a 64-bit integer: we
pretend we're passing it by reference, so the call trampoline loads
its value from the address in the register without an excess memory
copy, and the callee (if SHcompact) calls an argument decoder that
stores the 64-bit value in the stack and replaces it with a pointer to
that location.  So we want the callee to not perform the copy either,
since it was already performed by the trampolines.

See the comments before struct sh_args::call_cookie and
shcompact_byref(), as well as the comments before the implementations
of GCC_shcompact_call_trampoline and GCC_shcompact_incoming_args if
you happen to be interested.

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}


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