setting the speed for the future of games programming
vectorc

contentsclose
 

CALLING CONVENTIONS

Calling conventions specify the way a function is called. The standard calling conventions, cdecl, place an underscore ('_') before the function name in the function's label and pass all parameters on the stack. The caller of the function must remove those arguments from the stack. Structure return values are also stored on the stack. These calling conventions are slow because they require all arguments and structure return values to be passed through memory and only 4-byte alignment is maintained. VectorC provides some other calling conventions that can speed up function calling and return.

CodePlay defined calling conventions cannot be called by code compiled in other compilers. You either need to compile all your code with VectorC or provide transfer functions compiled with VectorC, but with cdecl or fastcall calling conventions. Using codeplay_mmx, codeplay_3dnow or codeplay_sse when compiling for processors with the necessary support can speed up functions calls massively. Also, all CodePlay calling conventions maintain 16-byte alignment which can speed up MMX, SSE and floating-point code dramatically. Using codeplay_mmx, codeplay_3dnow and codeplay_sse will let VectorC use MMX and 3DNow! in more places than it would otherwise. This is because these calling conventions assume the processor is in MMX mode at the point of call and return. The compiler therefore doesn't have to include the cost of switching FPU/MMX mode when deciding whether to use MMX for a particular function.

You can specify a default calling convention on the command line. This makes it easier if you want to compile your entire program with VectorC.

For most calling conventions (apart from cdecl), function prototypes are required. Otherwise, cdecl will be assumed.

The "main" function will always be set to cdecl.

Name Format in C Source Format on Command Line Arguments Return Modifies
Alignment
Label Name Comments
cdecl cdecl /Gd
/cdecl
stack - caller cleanup

byte: al
word/dword: eax
8-byte: eax, edx
other structure: address passed on stack

eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7

4
_name Default
fastcall __fastcall /Gr
/fastcall
ecx, edx,
stack
byte: al
word/dword: eax
8-byte: eax, edx
other structure: address passed in eax

eax, ecx, edx, st(0)..st(7), mm0..mm7, xmm0..xmm7

4
@name@size Microsoft - defined register calling. Swaps to cdecl for non-prototyped functions or functions with variable number of arguments
watcom __declspec (wcall) /wcalls
/vec:wcalls
eax, ebx,
ecx, edx

byte: al
word/dword: eax
__int64: eax, edx
other structure: address passed in esi

 
4
name_ Register calling conventions used by Watcom C/C++. Arguments passed on the stack for non-prototyped functions or functions with variable number of arguments
pascal __pascal   stack byte: al
word/dword: eax
8-byte: eax, edx
other structure: address passed on stack
eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7
4
_NAME  
stdcall __stdcall /Gz stack byte: al
word/dword: eax
8-byte: eax, edx
other structure: address passed on stack
eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7
4
_name@size Used for DLLs.
syscall __syscall   stack byte: al
word/dword: eax
8-byte: eax, edx
other structure: address passed on stack
eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7
4
name Used in OS/2
codeplay __declspec (codeplay) /cpcalls
/vec:cpcalls
eax, ebx,
ecx, edx
stack
byte: al
word/dword: eax
8-byte: eax, edx
other structure: address passed in esi
eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7
16
@name@CP_size CodePlay defined calling conventions. Swapped to
codeplay
_mmx
__declspec (codeplay_
mmx)
/mmxcalls
/vec:mmxcalls
eax, ebx,,br.ecx, edx,
mm0..mm4
stack
byte: al
word/dword: eax
8-byte: mm0
12/16-byte: mm0,mm1
other structure: address passed in esi
eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7
16
@name@MMX_size CodePlay defined calling conventions. Swaps to "codeplay" if any parameters or return value are floating-point values. Called in MMX mode.
codeplay
_3dnow
__declspec (codeplay_
3dnow)
/3dnowcalls
/vec:3dnowcalls

eax, ebx,
ecx, edx
4,8,12,
16-byte: mm0..mm4
float: mm0..mm4
stack

byte: al
word/dword: eax
float: mm0
8-byte: mm0
12/16-byte: mm0,mm1
other structure: address passed in esi
eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7
16
@name@3DN_size CodePlay defined calling conventions. Swaps to "codeplay" if any parameters or return value are double or long double values. Called in MMX mode. Only works for processors with 3DNow! support
codeplay
_sse
__declspec (codeplay
_sse)
/ssecalls
/vec:ssecalls

eax, ebx,
ecx, edx,
mm0..mm4,
float: xmm0
..xmm4
stack

byte: al
word/dword: eax
float: xmm0
8-byte: mm0
12-byte: mm0,mm1
16-byte: xmm0
other structure: address passed in esi

eax, ecx, edx
st(0)..st(7)
mm0..mm7
xmm0..xmm7
16
@name@SSE_size CodePlay defined calling conventions. Swaps to "codeplay" if any parameters or return value are double or long double values. Called in MMX mode. Only works for processors with SSE support


top

contentsclose