This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: vararg calls with libffi on x86_64
- From: Richard Henderson <rth at redhat dot com>
- To: Andreas Degert <ad at papyrus-gmbh dot de>
- Cc: gcc-patches at gcc dot gnu dot org, Andrew Haley <aph at redhat dot com>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Wed, 4 May 2005 11:11:27 -0700
- Subject: Re: vararg calls with libffi on x86_64
- References: <E1DRZei-0000Tc-00@pluto.noname> <17010.31036.654251.593520@cuddles.cambridge.redhat.com> <20050429232348.GD8858@redhat.com> <87is1z99lz.fsf@pluto.noname> <20050504012859.GA3209@redhat.com> <878y2v88gu.fsf@pluto.noname>
On Wed, May 04, 2005 at 02:46:25PM +0200, Andreas Degert wrote:
> The patch survives the testsuite. I hope it's sound enough now to be
> applied :-)
Two more small changes...
> - tramp[10] = 0xff49; /* jmp *%r11 */
> - tramp[11] = 0x00e3;
> + tramp[10] = 0x49f8; /* clc; jmp *%r11 */
> + tramp[11] = 0xe3ff;
> *(void * volatile *) &tramp[1] = ffi_closure_unix64;
> *(void * volatile *) &tramp[6] = closure;
> + if (cif->flags & (1 << 11))
> + *(volatile char*) &tramp[10] = 0xf9; /* stc */
I'd prefer to write this
/* Set the carry bit iff the function uses any sse registers.
This is clc or stc, together with the first byte of the jmp. */
tramp[10] = cif->flags & (1 << 11) ? 0x49f9 : 0x49f8;
tramp[11] = 0xe3ff; /* jmp *%r11 */
> ffi_closure_unix64:
> .LUW4:
> + setc %al /* carry set by trampoline iff SSE registers are used
> subq $200, %rsp
You don't need the stc (and following test) if you change the subq to leaq.
r~