Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 692 Bytes

README.md

File metadata and controls

25 lines (16 loc) · 692 Bytes

C-Jit Project

A simple C programming language JIT project. Dynamicaly generate code from c code.

Currently I only have MIR backend for generating binary code.

Build

  1. init sub modules: git submodule update --init --recursive
  2. create build folder: mkdir build && cd build/.
  3. run cmake: cmake .. && make

Simple Example

    auto *compiler = cjit::create<cjit::MirCompiler>();

    const char *c_code = "int func_add(int a, int b) { return a + b; } \n";
    cjit::CompiledInfo info = compiler->compile(c_code);

    typedef int (*fun_p)(int, int);
    fun_p fun = (fun_p)info.binary;

    ASSERT_EQ(3, fun(1, 2));