[LLVMdev] JIT functions' signature known only at runtime

Dmitry Mikushin dmitry at kernelgen.org
Tue Oct 22 19:38:54 PDT 2013


If the question could be generalized to "how to call the external function
without knowing its interface in advance", then the general solution is
Foreign Function Interface (FFI). And LLVM's JIT is (at least - was) using
FFI for certain things. We faced the same need some time ago, maybe this
code can give a rough idea:

http://hpcforge.org/scm/viewvc.php/*checkout*/trunk/src/runtime/HostCall.cpp?root=kernelgen

- D.


2013/10/23 Frank Winter <fwinter at jlab.org>

> Hi there! I am trying to figure out how I can call the function returned
> by the JIT execution engine. The only circumstance that makes this case
> a little problematic is that the function's signature is only available as
> runtime state. More precisely the arguments to be passed are only
> available as a vector of, e.g.,
>
> union Types {
>   void   *ptr;
>   float  *ptr_float;
>   double *ptr_double;
>   float  fl;
>   int    in;
>   double db;
>   bool   bl;
> };
>
> std::vector<std::pair<int,**Types> > arguments;
>
> where the first element of the pair would clearly identify of which type
> the argument is.
>
> I thought that I might not be the first having this problem and checked
> the mailing list
> without success.
>
> Does LLVM has any glue code to call functions returned by the JIT
> execution engine?
>
> Or is the only solution in this case to pass the address of the whole
> vector and let the
> jitted function handle everything?
>
>
> Frank
>
> ______________________________**_________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131023/65c71fe0/attachment.html>


More information about the llvm-dev mailing list