This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++/i86 thunk patch
- From: Jason Merrill <jason at redhat dot com>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, rth at redhat dot com, mark at codesourcery dot com
- Date: Mon, 15 Jul 2002 11:35:38 +0100
- Subject: Re: C++/i86 thunk patch
- References: <3D328BED.6BBBEC3C@codesourcery.com>
>>>>> "Nathan" == Nathan Sidwell <nathan@codesourcery.com> writes:
> The new ABI also requires return value adjusting thunks,
> for covariant return types. I can't see how to do those without
> cloning the thunked function.
For non-variadic functions, we might as well just use the generic wrapper
like we currently do for targets without the appropriate macro. But even
for variadic functions it isn't necessary to clone.
At the point of definition, we know all the return types we will need. We
could add a hidden parameter to specify which one we want, something like
f_A:
rettype = A; /* pass on stack or in scratch register */
goto f_internal;
f:
rettype = B;
goto f_internal; /* or just fall through */
f_internal:
...body...
if (rettype == A)
return (A*)retval;
else
return retval;
This would be more efficient if we had generic support for multiple entry
points to a function, of course.
> ! /* We might be able to do better by looking for a
> ! caller-save register that is not passing a parameter. */
Yes. -mregparm=2 still leaves %ecx as a scratch register, assuming we
don't need a static chain.
Jason