On Wed, Nov 7, 2012 at 4:49 AM, phi gcc <phi.gcc@xxxxxxxxx> wrote: > > Is there a documnent or a way to know the various procedure calling > convention used by gcc over time (i.e by gcc version) for regular > compile, fastcall, (eventually static function). > > For instance I got occurences of some gcc version that do > a0 in ax, a1 in dx, a2 in 0(sp), a3 in 4(sp) ... > > and other occurences that do > a0 in cx, a1 in dx, a2 in 0(sp), a3 in 4(sp) ... Andrew pointed you at the 32-bit API. The 64-bit API is at http://www.x86-64.org/documentation/abi.pdf . The fastcall ABI, used for functions with the fastcall attribute, is defined in the documentation. Likewise for the function attributes thiscall, stdcall, ms_abi, and sysv_abi. And the slightly different regparm attribute. Not to mention the command line options -mno-fp-ret-in-387, -mregparm, -msseregparm, -mvect8-ret-in-mem. And we haven't gotten into required stack alignment, which comes with its own set of function attributes and command line options. As you can see, the x86 ABI world is complex and has evolved significantly over time. And you're right to mention static functions: GCC is free to change the calling convention for static functions whose address is not taken, since it can safely identify every possible caller of such a function. GCC takes advantages of this in various ways, and those ways are not documented, nor need they be. Ian