Compiles brainfuck code to LLVM IR, and potentially runs it with McJIT.
- Python 3
llvmlite
(install withpython3 -m pip install --user llvmlite
)
Place some brainfuck code into a file, and name it what you want. For the sake
of simplicity, we'll assume your file is named example.bf
.
After installing the requirements, you can choose to:
-
Run your brainfuck code directly by running
python3 bf_compiler.py --run example.bf
. -
Compile your brainfuck to bitcode by running
python3 bf_compiler.py --bitcode example.bf
, which will emit aexample.bc
file.
You can compile your LLVM bitcode to machine code by running clang example.bc -o example
, which will compile your LLVM bitcode directly to machine code. You
may get a warning about a "triple", but don't worry about that. ;)
My friend Zaab1t for giving me the idea and the
llvmlite
reccomendation.
I made this to get my feet wet with LLVM, and to have fun.