[cfe-dev] How to use clang and llvm for JIT, preferably via the C API

Lang Hames via cfe-dev cfe-dev at lists.llvm.org
Mon Aug 31 14:02:05 PDT 2015


Hi Joel,

As far as I know libclang doesn't provide an API for code generation
(though I would double-check this on clang-dev).

If you can get hold of IR (e.g. by exec'ing "clang -c -emit-llvm ...") you
can use the stable MCJIT API to JIT that. The performance of such a scheme
may not be great though.

Cheers,
Lang.


On Mon, Aug 31, 2015 at 7:57 AM, David Blaikie <dblaikie at gmail.com> wrote:

> +Lang for JIT stuff
>
> On Mon, Aug 31, 2015 at 6:22 AM, Joel Andersson via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> Hi!
>>
>> I'm trying to add JIT support to our software for mathematical
>> optimization (http://casadi.org), but it's proving difficult. Since we
>> already support generation of C code, the natural approach is to generate C
>> code (either as temporary files or as strings) and parse this code using
>> clang. Although we've managed to implement a proof-of-concept, I'm
>> struggling to implement something more maintainable.
>>
>> In particular, I'd like to use the C API (libclang), but I don't see how
>> this can be combined with JIT. If I want to do clang+JIT, am I forced to
>> use the (unstable) C++ API?
>>
>> Here is a stackoverflow post I posted on the subject (without luck):
>>
>>
>> http://stackoverflow.com/questions/32254862/just-in-time-compilation-using-libclang-and-llvm-c
>>
>> Best regards,
>> Joel
>>
>> P.S. I'm also struggling to set up our (CMake-based) build system so that
>> it works with multiple llvm versions and multiple platforms. The
>> "llvm-config" doesn't appear to have anything clang-related. But I guess
>> that's a separate issue.
>>
>> --
>> --
>> Joel Andersson, PhD
>> Ptge. Busquets 11-13, atico 3
>> E-08940 Cornella de Llobregat (Barcelona), Spain
>> Home: +34-93-6034011
>> Mobile: +34-63-4408800 (in Sweden also +46-707-360512)
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150831/a664d9bf/attachment.html>


More information about the cfe-dev mailing list