diff options
Diffstat (limited to 'tests/callee_9.c')
-rw-r--r-- | tests/callee_9.c | 102 |
1 files changed, 56 insertions, 46 deletions
diff --git a/tests/callee_9.c b/tests/callee_9.c index 9d4e217..7dd131f 100644 --- a/tests/callee_9.c +++ b/tests/callee_9.c @@ -1,68 +1,78 @@ -#include "test.h" +#include <ejit/ejit.h> +#include <assert.h> +#include "do_jit.h" struct args { int8_t a; int16_t b; int32_t c; - jit_word_t d; + long d; uint16_t e; float f; double g; float h; }; -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) +int main() { - jit_begin(j, arena_base, arena_size); - size_t align = jit_enter_jit_abi(j, 3, 0, 0); - - jit_operand_t args[9] = { - jit_operand_gpr(JIT_OPERAND_ABI_POINTER, JIT_R0), - jit_operand_gpr(JIT_OPERAND_ABI_INT8, JIT_R1), - jit_operand_gpr(JIT_OPERAND_ABI_INT16, JIT_R2), - jit_operand_gpr(JIT_OPERAND_ABI_INT32, JIT_V0), - jit_operand_gpr(JIT_OPERAND_ABI_WORD, JIT_V1), - jit_operand_gpr(JIT_OPERAND_ABI_UINT16, JIT_V2), - jit_operand_fpr(JIT_OPERAND_ABI_FLOAT, JIT_F0), - jit_operand_fpr(JIT_OPERAND_ABI_DOUBLE, JIT_F1), - jit_operand_fpr(JIT_OPERAND_ABI_FLOAT, JIT_F2), + struct ejit_operand operands[9] = { + EJIT_OPERAND_GPR(0, EJIT_POINTER), + EJIT_OPERAND_GPR(1, EJIT_INT8), + EJIT_OPERAND_GPR(2, EJIT_INT16), + EJIT_OPERAND_GPR(3, EJIT_INT32), + EJIT_OPERAND_GPR(4, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(5, EJIT_UINT16), + EJIT_OPERAND_FPR(0, EJIT_FLOAT), + EJIT_OPERAND_FPR(1, EJIT_DOUBLE), + EJIT_OPERAND_FPR(2, EJIT_FLOAT) }; - jit_load_args(j, 9, args); - jit_stxi_c(j, offsetof(struct args, a), JIT_R0, JIT_R1); // a - jit_stxi_s(j, offsetof(struct args, b), JIT_R0, JIT_R2); // b - jit_stxi_i(j, offsetof(struct args, c), JIT_R0, JIT_V0); // c - jit_stxi(j, offsetof(struct args, d), JIT_R0, JIT_V1);// d - jit_stxi_s(j, offsetof(struct args, e), JIT_R0, JIT_V2); // e - jit_stxi_f(j, offsetof(struct args, f), JIT_R0, JIT_F0); // f - jit_stxi_d(j, offsetof(struct args, g), JIT_R0, JIT_F1); // g - jit_stxi_f(j, offsetof(struct args, h), JIT_R0, JIT_F2); // h - jit_leave_jit_abi(j, 3, 0, align); - jit_retr(j, JIT_R0); + struct ejit_func *f = ejit_create_func(EJIT_POINTER, 9, operands); + EJIT_STXI(f, int8_t, EJIT_GPR(1), EJIT_GPR(0), + offsetof(struct args, a)); // a + EJIT_STXI(f, int16_t, EJIT_GPR(2), EJIT_GPR(0), + offsetof(struct args, b)); // b + EJIT_STXI(f, int32_t, EJIT_GPR(3), EJIT_GPR(0), + offsetof(struct args, c)); // c + EJIT_STXI(f, long, EJIT_GPR(4), EJIT_GPR(0), + offsetof(struct args, d)); // d + EJIT_STXI(f, uint16_t, EJIT_GPR(5), EJIT_GPR(0), + offsetof(struct args, e)); // e + EJIT_STXI(f, float, EJIT_FPR(0), EJIT_GPR(0), + offsetof(struct args, f)); // f + EJIT_STXI(f, double, EJIT_FPR(1), EJIT_GPR(0), + offsetof(struct args, g)); // g + EJIT_STXI(f, float, EJIT_FPR(2), EJIT_GPR(0), + offsetof(struct args, h)); // h - size_t size = 0; - void* ret = jit_end(j, &size); + ejit_retr(f, EJIT_GPR(0)); - struct args* (*f)(struct args*, int8_t, int16_t, int32_t, jit_word_t, - uint16_t, float, double, float) = ret; + ejit_select_compile_func(f, 6, 3, EJIT_USE64(long), do_jit); struct args in = { 0, 1, 2, 3, 4, 5, 6, 7 }; struct args out; - ASSERT(f(&out, in.a, in.b, in.c, in.d, in.e, in.f, in.g, in.h) == &out); - ASSERT(in.a == out.a); - ASSERT(in.b == out.b); - ASSERT(in.c == out.c); - ASSERT(in.d == out.d); - ASSERT(in.e == out.e); - ASSERT(in.f == out.f); - ASSERT(in.g == out.g); - ASSERT(in.h == out.h); -} -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + struct ejit_arg args[9] = { + EJIT_ARG(&out, void *), + EJIT_ARG(in.a, int8_t), + EJIT_ARG(in.b, int16_t), + EJIT_ARG(in.c, int32_t), + EJIT_ARG(in.d, long), + EJIT_ARG(in.e, uint16_t), + EJIT_ARG(in.f, float), + EJIT_ARG(in.g, double), + EJIT_ARG(in.h, float) + }; + assert((void *)ejit_run_func(f, 8, args) == &out); + assert(in.a == out.a); + assert(in.b == out.b); + assert(in.c == out.c); + assert(in.d == out.d); + assert(in.e == out.e); + assert(in.f == out.f); + assert(in.g == out.g); + assert(in.h == out.h); + + ejit_destroy_func(f); } |