I write a language lexer/parser/compiler in python, that should run in the LLVM JIT-VM (using llvm-py
) later. The first two steps are quite straightforward for
You can call external C functions from LLVM JIT-ed code. What else do you need?
These external functions will be found in the executing process, meaning that if you link Python into your VM you can call Python's C API functions.
The "VM" is probably less magic than you think it is :-) In the end, it's just machine code that gets emitted at runtime into a buffer and executed from there. To the extent that this code has access to other symbols in the process in which it's running, it can do everything any other code in that process can do.