[llvm-dev] Query about JIT

Rajesh Jayaprakash via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 8 03:14:20 PST 2019


Dear llvm-dev list,

Apologies if this list is not the right venue for this query - suitable
redirection would be appreciated in that case.

I have a JIT use case that I'd like to know the best way to implement using
LLVM.

I am looking to migrate from the existing native compilation option (Tiny C
Compiler - TCC) for pLisp, a Lisp dialect and IDE.

At present, the native compilation is done by converting the Lisp code to
C, storing the C code in a char buffer, and passing it to TCC
programmatically via the API provided. I get a function pointer in return,
which I store and invoke as needed.

Delving into the LLVM documentation, I found that one possible way to
achieve the same functionality in LLVM is to use clag/libclang to convert
the C source to LLVM IR, load this IR into the the JIT context and
(skipping some steps I'm yet to figure out) get the desired function
pointer.

Is this approach the right one? One issue I foresee is that libclang's
clang_parseTranslateUnit() function expects the C code to be from a file
(although the file can be in-memory), whereas in my case the C code needs
to be picked up from a char buffer - necessitating fmemopen(), etc.

Thanks for your assistance.

Regards,
Rajesh Jayaprakash
(https://github.com/shikantaza/plisp)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190308/7b357f28/attachment-0001.html>


More information about the llvm-dev mailing list