diff options
Diffstat (limited to 'tests/subr_f.c')
-rw-r--r-- | tests/subr_f.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/tests/subr_f.c b/tests/subr_f.c index 3fdf071..02cb1c9 100644 --- a/tests/subr_f.c +++ b/tests/subr_f.c @@ -1,27 +1,25 @@ -#include "test.h" +#include <ejit/ejit.h> +#include <assert.h> +#include "do_jit.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, 0, 0, 0); - jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_FPR(0, EJIT_TYPE(double)), + EJIT_OPERAND_FPR(1, EJIT_TYPE(double)) + }; + struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 2, operands); - jit_subr_f(j, JIT_F0, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_retr_f(j, JIT_F0); + ejit_subr_f(f, EJIT_FPR(0), EJIT_FPR(0), EJIT_FPR(1)); + ejit_retr_f(f, EJIT_FPR(0)); - size_t size = 0; - void* ret = jit_end(j, &size); + ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit); - float (*f)(float, float) = ret; - ASSERT(f(42.f, 69.f) == -27.f); - ASSERT(f(42.0f, 69.5f) == -27.5f); -} + assert(erff2(f, EJIT_ARG(42., double), EJIT_ARG(69., double) + ) == -27.); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(erff2(f, EJIT_ARG(42.5, double), EJIT_ARG(69., double) + ) == -26.5); + + ejit_destroy_func(f); } |