Translation of LLVM bitcode to C
The only requirements are CMake in version at least 3.1 and LLVM 5 or newer. The project is not compilable on older LLVM's at the moment. (Patches are welcome 😄)
git clone https://github.com/staticafi/llvm2c
cd llvm2c
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=installation/path/
make
Just run make check
.
To test llvm2c
with csmith:
- compile
csmith
andllvm2c
- copy
csmith/src/csmith
binary totest/
folder - copy
csmith/runtime
totest/
folder and rename it tocsmith-runtime
cd test/
mkdir csmith-tests/
./csmith_testing.py
The script generates 1000 testing programs. Each program is translated to LLVM
via clang
and then back to C via llvm2c
. The only thing that is currently
tested is, that llvm2c
binary does not crash.
- vector instructions
- atomic operations
- some special intrinsics
- the code generation is currently fitted to x86_64 bitcode