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: C++/i86 thunk patch


>>>>> "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


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