[LLVMdev] Question about llvm JIT

Peng Cheng gm4cheng at gmail.com
Thu Aug 9 18:14:02 PDT 2012


Thanks!

On Monday, August 6, 2012, Eli Friedman wrote:

> On Mon, Aug 6, 2012 at 9:35 AM, Peng Cheng <gm4cheng at gmail.com<javascript:;>>
> wrote:
> > I have a function in llvm ir as follows:
> >
> >   def [2 x [3 x double]] @fun()
> >   {
> >     return [ ... ]; // a [2 x [3 x double]] constant
> >   }
> >
> > I would like to JIT this function in C.
> >
> > I first get the void pointer using:
> >
> >   void *FPtr = TheExecutionEngine->getPointerToFunction( func );
> >
> > Then I need to conver this void pointer to the corresponding C function
> > pointer
> > type, and then call the function pointer.
> >
> >   double a[2][3];
> >
> >   CType *FP = (CType*) FPtr;
> >
> >   a = FP();
> >
> > My question is that:
> >
> > 1. Is this JIT work flow supported by LLVM?
>
> Sort of?
>
> > 2. If yes, what is correct CType for the JITted function?
>
> Probably "typedef void FPtr(double*);", but that's not guaranteed.
>
> > 3. If not, what are requirements on the LLVM function IRs such that they
> > could be JIT and called in C?
>
> If you want to generate functions which are easily callable from C,
> make sure the return type and all the parameters are pointers or
> simple values; otherwise, the correct rule for converting from C types
> to IR types is complicated and platform-specific.
>
> -Eli
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120809/346c447e/attachment.html>


More information about the llvm-dev mailing list