#include #include #include "do_jit.h" static float func(int32_t a, float b) { return b + a; } static float escape_func(size_t argc, const struct ejit_arg args[argc]) { assert(argc == 2); int32_t a = EJIT_PARAM(argc, args, 0, int32_t); float b = EJIT_PARAM(argc, args, 1, float); 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_FLOAT, 2, operands); EJIT_LDXI(f, int32_t, EJIT_GPR(0), EJIT_GPR(0), 0); EJIT_LDXI(f, float, EJIT_FPR(0), EJIT_GPR(1), 0); struct ejit_operand args[2] = { EJIT_OPERAND_GPR(0, EJIT_INT32), EJIT_OPERAND_FPR(0, EJIT_FLOAT) }; ejit_escapei_f(f, escape_func, 2, args); ejit_retval_f(f, EJIT_FPR(0)); ejit_retr_f(f, EJIT_FPR(0)); ejit_select_compile_func(f, 2, 1, false, do_jit, true); float d = 22.0f; int32_t i = 20; assert(erff2(f, EJIT_ARG(&i, void *), EJIT_ARG(&d, void *)) == 42.0f); ejit_destroy_func(f); }