diff options
Diffstat (limited to 'tests/ldxr_f.c')
-rw-r--r-- | tests/ldxr_f.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/tests/ldxr_f.c b/tests/ldxr_f.c index c6dacba..202a4a1 100644 --- a/tests/ldxr_f.c +++ b/tests/ldxr_f.c @@ -1,28 +1,33 @@ -#include "test.h" +#include <ejit/ejit.h> +#include <assert.h> +#include "do_jit.h" static float 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_2(j, jit_operand_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_POINTER), + EJIT_OPERAND_GPR(1, EJIT_TYPE(unsigned)) + }; + struct ejit_func *f = ejit_create_func(EJIT_TYPE(float), 2, operands); - jit_ldxr_f(j, JIT_F0, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_retr_f(j, JIT_F0); + ejit_ldxr_f(f, EJIT_FPR(0), EJIT_GPR(0), EJIT_GPR(1)); + ejit_retr_f(f, EJIT_FPR(0)); - float (*f)(void*, jit_uword_t) = jit_end(j, NULL); + ejit_select_compile_func(f, 2, 1, false, do_jit); - ASSERT(f(data, 0) == data[0]); - ASSERT(f(data, 4) == data[1]); - ASSERT(f(data, 8) == data[2]); -} + assert(erff2(f, + EJIT_ARG(data, void *), + EJIT_ARG(0 * sizeof(float), unsigned)) == data[0]); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(erff2(f, + EJIT_ARG(data, void *), + EJIT_ARG(1 * sizeof(float), unsigned)) == data[1]); + + assert(erff2(f, + EJIT_ARG(data, void *), + EJIT_ARG(2 * sizeof(float), unsigned)) == data[2]); + + ejit_destroy_func(f); } |