A LLVM pass that lowers LLVM IR to Brainfuck.
Work in progress -- not all instructions and types are supported yet.
mkdir build && cd build
cmake .. && make
clang -O1 -S -fpass-plugin=./lib/libLLVMBrainfuck.so -o /dev/null ../tests/c/helloworld.c > helloworld.bf
./interpreter/BFInterp helloworld.bf
# For opt, use `-load-pass-plugin`
# opt -load-pass-plugin ./lib/libLLVMBrainfuck.so -disable-output xxx.ll
- Basic support for arithmetic, memory and function calls.
- Currently, all types are treated as
i8and conversion are simply ignored. - ⚡ Fun Fact: Now it can compile a Brainfuck interpreter to Brainfuck. (See: tests/c/bf-interp.c)
- ret
- br
- switch
- indirectbr
- invoke
- callbr
- resume
- catchswitch
- catchret
- cleanupret
- unreachable
- fneg
- add
- fadd
- sub
- fsub
- mul
- fmul
- udiv
- sdiv
- fdiv
- urem
- srem
- frem
- shl
- lshr
- ashr
- and
- or
- xor
- extractelement
- insertelement
- shufflevector
- extractvalue
- insertvalue
- alloca
- load
- store
- fence
- cmpxchg
- atomicrmw
- getelementptr
- trunc ... to
- zext ... to
- sext ... to
- fptrunc ... to
- fpext ... to
- fptoui ... to
- fptosi ... to
- uitofp ... to
- sitofp ... to
- ptrtoint ... to
- inttoptr ... to
- bitcast ... to
- addrspacecast ... to
- icmp
- fcmp
- phi (demote to memory)
- select
- freeze
- call
- va_arg
- landingpad
- catchpad
- cleanuppad
- i8
- ...
This project is licensed under the MIT License.
See LICENSE for details.