I am creating a toy language, for my personal use and to help me learn rust.
Right now I am creating the interpreter. I have read some articles on the optimizations that interpreters carry out.
One thing that really interested me, is the ability to JIT.
I am looking for a way to compile rust code to LLVM IR, within my rust interpreter.
Then proceed to invoke that LLVM IR code and run it, again within my Rust Interpreter.
I have seen that this is possible with C++. What I am mainly looking for is a safe way to use LLVM within Rust.
If anyone has any suggestions, it will be much appreciated.
You might want to have a look at Cretonne. It is written entirely in Rust and is designed for this sort of use-case. It’s still a work in progress, but, my understanding (I’ve only recently become aware of it myself) is that it is coming along rather nicely. see https://github.com/Cretonne/cretonne.
EDIT: Also, although not directly relevant, the following discussions on Reddit and this discourse here regarding LLVM/RLLVM and Cretonne may help to inform some background:
Alright, thank you very much will have a look at it.
which is based on https://llvm.org/docs/tutorial/
While Cretonne is cool, we don’t have any tutorials yet, or documentation about what to do, what works, and what doesn’t, yet. I can answer questions though :-).
Thank you all for the suggestions
iron-kaleidoscope looks really good!