#include #include #include "do_jit.h" static double func(int32_t a, double b) { return b + a; } static double escape_func(size_t argc, const struct ejit_arg args[argc]) { assert(argc == 2); assert(args[0].type == EJIT_INT32); assert(args[1].type == EJIT_DOUBLE); int32_t a = args[0].i32; double b = args[1].d; return func(a, b); } int main(int argc, char *argv[]) { (void)argv; bool do_jit = argc > 1; struct ejit_operand operands[2] = { EJIT_OPERAND_GPR(0, EJIT_POINTER), EJIT_OPERAND_GPR(1, EJIT_POINTER) }; struct ejit_func *f = ejit_create_func(EJIT_DOUBLE, 2, operands); EJIT_LDXI(f, int32_t, EJIT_GPR(0), EJIT_GPR(0), 0); EJIT_LDXI(f, double, EJIT_FPR(0), EJIT_GPR(1), 0); struct ejit_operand args[2] = { EJIT_OPERAND_GPR(0, EJIT_INT32), EJIT_OPERAND_FPR(0, EJIT_DOUBLE) }; ejit_escapei_f(f, escape_func, 2, args); ejit_retval_d(f, EJIT_FPR(0)); ejit_retr_d(f, EJIT_FPR(0)); ejit_select_compile_func(f, 2, 1, false, do_jit); double d = 22.0f; int32_t i = 20; assert(erff2(f, EJIT_ARG(&i, void *), EJIT_ARG(&d, void *)) == 42.0f); }