A simple C programming language JIT project. Dynamicaly generate code from c code.
Currently I only have MIR backend for generating binary code.
- init sub modules:
git submodule update --init --recursive
- create build folder:
mkdir build && cd build/
. - run cmake:
cmake .. && make
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));