[LLVMdev] Calling Conventions Cont'd

Owen Anderson resistor at mac.com
Mon Apr 14 13:23:12 PDT 2008


On Apr 12, 2008, at 3:22 PM, Jon Sargeant wrote:

> What is the correct procedure for translating a function signature  
> from
> a high-order language to LLVM?  It looks like I replace each
> struct/array parameter with a 'byval' pointer parameter, and I  
> replace a
> result struct/array with an 'sret' pointer parameter.  The reason I  
> ask
> is that each calling convention has subtle variations for each
> architecture and platform.  For example, cdecl in Win32 returns  
> small (8
> bytes or less) structures in EAX or EAX:EDX; whereas, cdecl in Linux
> always returns structures "in memory" (Source:
> http://www.programmersheaven.com/2/Calling-conventions).  Does LLVM
> handle all of these nuances for me?
>


While other people have pointed out some of the intricacies involved  
in ABI compliance, I'd just like to point that you only need to be  
concerned with this if you're trying to interoperate with C/C++.  If  
you're making the function signatures for use entirely with your own  
language, then none of this matters.  You're free to invent your own  
calling convention and, as long as you apply it consistently,  
everything will work.

--Owen



More information about the llvm-dev mailing list