Fastcall in 64 bit

3.5k Views Asked by At

I've been reading up on the differences in 32bit calling conventions. The fastcall vs. stdcall ordeal that is.

From what I read there was great confusion with the two conventions, and 64 bit was standardized to avoid this confusion.

I have to ask, why was fastcall chosen?

Also, since fastcall and stdcall are win32 terms, what is the UNIX term for function calling that does or does not use registers for passing arguments?

1

There are 1 best solutions below

3
On

x86 Calling Conventions - Wikipedia, the free encyclopedia provides a list.

The common calling convention on x86-32 is cdecl. GCC provides a function attribute __attribute__((regparm(n))) to indicate that n arguments are passed by register, but this is not the same as fastcall. Either way, arguments are passed in callee-clobberable registers, so there is no additional cost (and saves the effort of adding stack space for arguments then cleaning it up) for function calls relative to cdecl (for regparm) and stdcall (for fastcall).

To aid in your confusion, the x86-64 calling conventions on Windows and Linux are different both from those on x86-32 and from each other. Neither is fastcall, although both use a significant number of registers to pass arguments.