llvm2cryptoline
===== Introduction =====
llvm2cryptoline is a tool aiming to translate LLVM IR code into the Cryptoline domain-specific language.
===== Requirements =====
- cmake (>= 3.4.3, lower version may be viable, you are welcomed to have a try)
- LLVM (>= 3.7.0, checked until version 7.0.0)
NOTE: the LLVM version used for compiling llvm2cryptoline SHOULD be the same as the one corresponding to the IR code.
===== LLVM Installation =====
NOTE: If you have already installed LLVM, you can skip this part.
-
Download LLVM (3.7.0 <= version <= 7.0.0) source code from http://releases.llvm.org/download.html
-
Extract the source code from the downloaded package. Assume that the top-level directory of the source code is SRC_ROOT.
-
Enter BUILD_DIR, where you want to build your LLVM. For example, create directory SRC_ROOT/build and enter in:
cd SRC_ROOT mkdir build && cd build
-
Assume that you want to install LLVM into the directory INSTALL_DIR, then:
cmake -DCMAKE_INSTALL_PREFIX=INSTALL_DIR SRC_ROOT
For example, if you are in SRC_ROOT/build, you can:
cmake -DCMAKE_INSTALL_PREFIX=INSTALL_DIR ..
-
Build:
make
Or use n processors to speed up:
make -jn
-
Install:
make install
-
Now you can delete all files in SRC_ROOT and BUILD_DIR.
===== llvm2cryptoline Compilation =====
Assume that SRC_ROOT is the top-level directory of the llvm2cryptoline source code, LLVM_INSTALL_DIR is the directory where you installed your LLVM (i.e. INSTALL_DIR in the previous part).
-
cd SRC_ROOT
-
mkdir build && cd build
-
if the installed LLVM version < 3.9.0, run:
cmake -DLLVM_DIR=LLVM_INSTALL_DIR/share/llvm/cmake/ ..
if the installed LLVM version >= 3.9.0, then run:
cmake -DLLVM_DIR=LLVM_INSTALL_DIR/lib/cmake/llvm/ ..
-
make
===== llvm2cryptoline Usage =====
Use the following command line:
translate FILE FUNCTION_NAME [BLOCK_NAME]
- FILE the LLVM IR code (.ll) file
- FUNCTION_NAME the translated function name
- BLOCK_NAME the translated basic block name