diff options
Diffstat (limited to 'tests/ldxi_d.c')
-rw-r--r-- | tests/ldxi_d.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/tests/ldxi_d.c b/tests/ldxi_d.c index a93e582..da3ed0a 100644 --- a/tests/ldxi_d.c +++ b/tests/ldxi_d.c @@ -1,27 +1,25 @@ -#include "test.h" +#include <ejit/ejit.h> +#include <assert.h> +#include "do_jit.h" static double data[] = { -1.0, 0.0, 0.5 }; -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, 0, 0, 0); - jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_ldxi_d(j, JIT_F0, JIT_R0, (uintptr_t)data); - jit_leave_jit_abi(j, 0, 0, align); - jit_retr_d(j, JIT_F0); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 1, operands); - double (*f)(jit_uword_t) = jit_end(j, NULL); + ejit_ldxi_d(f, EJIT_FPR(0), EJIT_GPR(0), (uintptr_t)data); + ejit_retr_f(f, EJIT_FPR(0)); - ASSERT(f(0) == data[0]); - ASSERT(f(8) == data[1]); - ASSERT(f(16) == data[2]); -} + ejit_select_compile_func(f, 1, 1, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(erff1(f, EJIT_ARG(sizeof(double) * 0, long)) == data[0]); + assert(erff1(f, EJIT_ARG(sizeof(double) * 1, long)) == data[1]); + assert(erff1(f, EJIT_ARG(sizeof(double) * 2, long)) == data[2]); + + ejit_destroy_func(f); } |