Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Bleakcabal

Fastcall calling covention

This topic is 6593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anyway beside the compiler setting, preferably at the start of a file, to tell the compiler to use the fastcall calling convention ?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You could put __fastcall on the function itself. e.g. void __fastcall Foo().

If you''re worried about portability use a #define.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
what is fastcall convenction..i have seen it around but what it is?

Share this post


Link to post
Share on other sites
fastcall convention in MSVC on the x86 means that: the first two DWORD or smaller arguments are passed in ECX and EDX, all other arguments are passed right to left.

fastcall convention in Borland C++ on the x86 means that: the first three DWORD or smaller arguments are passed in EAX, ECX and EDX. All other arguments are passed left to right

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I was the first anon poster... I have no clue what a Hugi is.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How does that make it faster? Does a normal call use only the stack for passing parameters?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
For cdecl (the standard for C programs) and pascal calling conventions all parameters are passed on the stack on x86 processors. These are standard calling conventions used by essentially everybody. I don''t know where these standards came from.

Microsoft also made up some other calling conventions stdcall (which also uses the stack), fastcall (which uses some registers also), and thiscall (which puts the C++ this pointer in a register and the rest on the stack). stdcall is required for any compiler that supports Windows, the others vary from compiler to compiler and may or may not be supported. The calling convention also defines who cleans up the stack. e.g. in cdecl the caller and in pascal/stdcall/thiscall the callee.

Other processors have different standards. RISC chips usually pass the first several parameters in registers and then any extra are passed on the stack. Different rules may apply to floating point types, by-value structures, etc. It can get really complicated. These standards are usually defined by the processor vender.

And just to make life really complicated fastcall is not necessarily faster. Because the compiler has to put certain parameters in certain registers there is more pressure on how freely the compiler can allocate registers for other purposes in the callee. x86 processors are really a nightmare because you have so few registers - of course RISC is a nightmare because you have so many .

-Mike

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!