https://github.com/vaivaswatha/lljit
LLVM JIT: An Example
https://github.com/vaivaswatha/lljit
jit-compiler llvm
Last synced: 11 months ago
JSON representation
LLVM JIT: An Example
- Host: GitHub
- URL: https://github.com/vaivaswatha/lljit
- Owner: vaivaswatha
- Created: 2020-01-24T07:50:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-07T13:45:27.000Z (over 5 years ago)
- Last Synced: 2025-03-29T04:12:20.221Z (12 months ago)
- Topics: jit-compiler, llvm
- Language: C++
- Size: 16.6 KB
- Stars: 14
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LLVM JIT: An Example
This code builds a minimal JIT engine to execute LLVM-IR.
It does not cover generation of LLVM-IR.
## Build
- Adding repository for [LLVM-10](https://apt.llvm.org/)
* For Ubuntu 18.04 (Ubuntu 20.04 already has LLVM-10 in the repository)
```bash
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
```
* Others: Visit the LLVM apt website above and follow instructions.
- `sudo apt-get install libllvm10 llvm-10-dev clang-10`
- `make`
This should produce an executable named `lljit.exe`.
## Run
- This will JIT compile the LLVM-IR in `examples/helloworld.ll` and
execute the function `jitentry` in it. It should print
"Hello world" on your terminal.
```bash
./lljit.exe examples/helloworld.ll
```
- The helloworld example LLVM-IR was generated from
its C file using the command
```bash
clang-10 -emit-llvm -S helloworld.c
```
### Testsuite
Building the project should also build `testsuite.exe`, which can
simply be run as `./testsuite.exe`, and it will JIT compile and
run the `helloworld.ll` example described above.