[LLVMdev] LLVM code emittion and C++ compiler compatibily

Anton Korobeynikov asl at math.spbu.ru
Mon Nov 6 13:22:00 PST 2006


Hello, Ziga.

> First the calling conversion. The so called __thiscall conversion on 
> VC++ passes arguments on stack, while this pointer is passed
> into ECX register. For GCC, as far as I am aware, the this pointer is 
> pushed as if it were a special (first) argument. The fix would
> be preaty simple but we want the bytecode to be OS independant, so we 
> cannot change the bytecode.
You're right. There are two flavours of thiscall CC: one using in MS
VCPP, another one used by GCC.

1. Visual C++
pointer to this is passed in the ECX register, callee clears the stack,
so mirroring stdcall CC. If function is varargs the caller calls the
stack, mirroring cdecl CC.
2. GCC
Everything is much clearer :) Just standard cdecl CC with one hidden
argument (the same as struct return on Darwin).

> The other thing are the return types. I don't know (it is probably even 
> not documented) how VC++ returns smart pointer (boost::smart_ptr),
I think it's the same as struct return. Some investigation will be
needed.

> or any other type (other basics types, such as int, float, ... are 
> probably returned into EAX as with GCC).
They're definitely returned via EAX.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.





More information about the llvm-dev mailing list