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

Žiga Osolin ziga.osolin at gimb.org
Mon Nov 6 09:49:38 PST 2006


Hello!

I have a question how about JIT-ed code and the C++ compiler 
compatibily. My project (www.baadengine.org) will use
llvm and we will provide integration of JIT-ed code directly into C++ 
code. This means that C++ code can call JIT code just
like any other code and JIT-ed code can call C++ code. We will compile 
to your bytecode from our BSF format.

The question is if it is possible this to works. I am concerned with 
calling conversions (especially member call and the return values.
Thankfully, we only have to ensure that our internal string type, all 
native types and boost::smart_ptr type is returned correctly.

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.

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),
or any other type (other basics types, such as int, float, ... are 
probably returned into EAX as with GCC). Once again, we may
need specific return values per arhitecture.

I would be thankful for any suggestion,
Žiga Osolin



More information about the llvm-dev mailing list