[LLVMdev] How to call native functions from bytecode run in JIT?

Chris Lattner sabre at nondot.org
Tue Jun 12 10:55:38 PDT 2007


On Tue, 12 Jun 2007, Jan Rehders wrote:
>> Jan, how are you doing this?  Are you creating an external LLVM 
>> Function object named "get5", then using EE::addGlobalMapping?  If 
>> 'get5' exists in the address space, why not just let the JIT resolve it 
>> (which will then create the stub)?
>
> Yes. I create a Function with matching signature, calling conventions
> and external linkage which I pass together with the function's
> address to addGlobalMapping.

Okay.  If the function exists in your application's address space already, 
just name the LLVM function the same name as the native function and the 
JIT should find it an do the right thing.  This is how it finds printf and 
a variety of other things.  You don't need to call addGlobalMapping at 
all.

Does this work?

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list