A simple LLVM IR interpreter written in C++ that can execute LLVM bitcode. It supports a plugin system for implementing custom program analysis.
- Executes LLVM IR (.ll files)
- Supports basic arithmetic, control flow, memory operations, and function calls
- Plugin system for custom program analysis
This interpreter supports only a subset of LLVM instructions at the moment. Floating point operations, LLVM intrinsics etc, are currently not supported. I am working on adding support for these instructions.
- CMake 3.16 or higher
- LLVM 18+ with development headers
-
Clone or navigate to the project directory:
cd /path/to/LLVM_Interpreter -
Create a build directory:
mkdir build cd build -
Configure with CMake:
cmake .. -
Build the project:
make
This will build:
src/interpreter: Main interpreter executableplugin-example/plugin_example: Interpreter with logging plugin
Execute an LLVM IR file:
./build/src/interpreter path/to/program.ll [args...]
Execute with instruction logging:
./build/plugin-example/plugin_example path/to/program.ll [args...]
The logging plugin outputs [LOG] Executing instruction: ... for each executed instruction.
The tests/ directory contains sample LLVM IR files:
arithmetic_control.ll: Arithmetic and control flow operationsarrays_pointers.ll: Array and pointer operationsfunctions.ll: Function callsrecursion.ll: Recursive functions
Example:
./build/plugin-example/plugin_example tests/arithmetic_control.ll
include/: Header filessrc/: Source files and main CMakeLists.txtplugin-example/: Example plugin implementationtests/: Sample LLVM IR test files
Implement the ExecutionPlugin interface to add custom functionality. See plugin-example/logging_plugin.hpp for an example.