Call Python code from LLVM JIT

后端 未结 2 2021
轮回少年
轮回少年 2021-01-12 21:41

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

2条回答
  •  Happy的楠姐
    2021-01-12 22:07

    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.

提交回复
热议问题