Skip to content

MrRoy09/LLVM-PlugIR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLVM Interpreter

A simple LLVM IR interpreter written in C++ that can execute LLVM bitcode. It supports a plugin system for implementing custom program analysis.

Features

  • Executes LLVM IR (.ll files)
  • Supports basic arithmetic, control flow, memory operations, and function calls
  • Plugin system for custom program analysis

Limitations

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.

Building

Prerequisites

  • CMake 3.16 or higher
  • LLVM 18+ with development headers

Build Steps

  1. Clone or navigate to the project directory:

    cd /path/to/LLVM_Interpreter
    
  2. Create a build directory:

    mkdir build
    cd build
    
  3. Configure with CMake:

    cmake ..
    
  4. Build the project:

    make
    

This will build:

  • src/interpreter: Main interpreter executable
  • plugin-example/plugin_example: Interpreter with logging plugin

Usage

Running the Interpreter

Execute an LLVM IR file:

./build/src/interpreter path/to/program.ll [args...]

Running with Logging Plugin

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.

Test Files

The tests/ directory contains sample LLVM IR files:

  • arithmetic_control.ll: Arithmetic and control flow operations
  • arrays_pointers.ll: Array and pointer operations
  • functions.ll: Function calls
  • recursion.ll: Recursive functions

Example:

./build/plugin-example/plugin_example tests/arithmetic_control.ll

Project Structure

  • include/: Header files
  • src/: Source files and main CMakeLists.txt
  • plugin-example/: Example plugin implementation
  • tests/: Sample LLVM IR test files

Extending with Plugins

Implement the ExecutionPlugin interface to add custom functionality. See plugin-example/logging_plugin.hpp for an example.

About

LLVM interpreter with a Plugin system to enable LLVM IR based Program Analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published