[cfe-dev] How to use clang and llvm for JIT, preferably via the C API
Joel Andersson via cfe-dev
cfe-dev at lists.llvm.org
Mon Aug 31 14:39:13 PDT 2015
Thanks a lot, I should have thought of that... I can use libclang to get
hold of the IR - that way I can avoid the command-line completely.
I don't think performance will be an issue, our generated code is quite
large so the extra overhead will probably be dwarfed by other steps in the
When you refer to the "stable MCJIT API", you mean the C API, right? From
what I can tell, it indeed appears to have the required functionality (
2015-08-31 23:02 GMT+02:00 Lang Hames <lhames at gmail.com>:
> 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.
> 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:
>>> 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):
>>> Best regards,
>>> 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
Joel Andersson, PhD
Ptge. Busquets 11-13, atico 3
E-08940 Cornella de Llobregat (Barcelona), Spain
Mobile: +34-63-4408800 (in Sweden also +46-707-360512)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev