Thanks!<span></span><br><br>On Monday, August 6, 2012, Eli Friedman  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Aug 6, 2012 at 9:35 AM, Peng Cheng <<a href="javascript:;" onclick="_e(event, 'cvml', 'gm4cheng@gmail.com')">gm4cheng@gmail.com</a>> wrote:<br>

> I have a function in llvm ir as follows:<br>
><br>
>   def [2 x [3 x double]] @fun()<br>
>   {<br>
>     return [ ... ]; // a [2 x [3 x double]] constant<br>
>   }<br>
><br>
> I would like to JIT this function in C.<br>
><br>
> I first get the void pointer using:<br>
><br>
>   void *FPtr = TheExecutionEngine->getPointerToFunction( func );<br>
><br>
> Then I need to conver this void pointer to the corresponding C function<br>
> pointer<br>
> type, and then call the function pointer.<br>
><br>
>   double a[2][3];<br>
><br>
>   CType *FP = (CType*) FPtr;<br>
><br>
>   a = FP();<br>
><br>
> My question is that:<br>
><br>
> 1. Is this JIT work flow supported by LLVM?<br>
<br>
Sort of?<br>
<br>
> 2. If yes, what is correct CType for the JITted function?<br>
<br>
Probably "typedef void FPtr(double*);", but that's not guaranteed.<br>
<br>
> 3. If not, what are requirements on the LLVM function IRs such that they<br>
> could be JIT and called in C?<br>
<br>
If you want to generate functions which are easily callable from C,<br>
make sure the return type and all the parameters are pointers or<br>
simple values; otherwise, the correct rule for converting from C types<br>
to IR types is complicated and platform-specific.<br>
<br>
-Eli<br>
</blockquote>