From 9fe8ccf4ae09018fdde01a9d83f9db10ad354221 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 29 Jun 2024 20:11:34 +0300 Subject: work through branching instructions --- tests/andr.c | 4 +-- tests/beqi.c | 4 +-- tests/beqr.c | 12 ++++---- tests/beqr_d.c | 35 ----------------------- tests/beqr_f.c | 70 +++++++++++++++++++++++++--------------------- tests/bgei.c | 41 +++++++++++++-------------- tests/bgei_u.c | 39 ++++++++++++-------------- tests/bger.c | 46 +++++++++++++++--------------- tests/bger_d.c | 34 ----------------------- tests/bger_f.c | 34 ----------------------- tests/bger_u.c | 46 +++++++++++++++--------------- tests/bgti.c | 41 +++++++++++++-------------- tests/bgti_u.c | 41 +++++++++++++-------------- tests/bgtr.c | 46 +++++++++++++++--------------- tests/bgtr_d.c | 34 ----------------------- tests/bgtr_f.c | 57 ++++++++++++++++++++----------------- tests/bgtr_u.c | 46 +++++++++++++++--------------- tests/blei.c | 41 +++++++++++++-------------- tests/blei_u.c | 39 ++++++++++++-------------- tests/bler.c | 46 +++++++++++++++--------------- tests/bler_d.c | 34 ----------------------- tests/bler_f.c | 57 ++++++++++++++++++++----------------- tests/bler_u.c | 46 +++++++++++++++--------------- tests/bltgtr_d.c | 36 ------------------------ tests/bltgtr_f.c | 61 +++++++++++++++++++++------------------- tests/blti.c | 41 +++++++++++++-------------- tests/blti_u.c | 41 +++++++++++++-------------- tests/bltr.c | 46 +++++++++++++++--------------- tests/bltr_d.c | 34 ----------------------- tests/bltr_f.c | 57 ++++++++++++++++++++----------------- tests/bltr_u.c | 46 +++++++++++++++--------------- tests/bmci.c | 42 +++++++++++++--------------- tests/bmcr.c | 54 +++++++++++++++++------------------ tests/bmsi.c | 42 +++++++++++++--------------- tests/bmsr.c | 54 +++++++++++++++++------------------ tests/bnei.c | 41 +++++++++++++-------------- tests/bner.c | 48 ++++++++++++++++---------------- tests/bner_d.c | 36 ------------------------ tests/bner_f.c | 85 +++++++++++++++++++++++++++++++++++--------------------- tests/eqr.c | 30 ++++++++++++++++++++ tests/eqr_f.c | 32 +++++++++++++++++++++ tests/ger.c | 30 ++++++++++++++++++++ tests/gtr.c | 30 ++++++++++++++++++++ tests/gtr_f.c | 25 +++++++++++++++++ tests/ler.c | 30 ++++++++++++++++++++ tests/ler_f.c | 30 ++++++++++++++++++++ tests/ltr.c | 30 ++++++++++++++++++++ tests/ltr_f.c | 32 +++++++++++++++++++++ tests/ner.c | 30 ++++++++++++++++++++ 49 files changed, 995 insertions(+), 961 deletions(-) delete mode 100644 tests/beqr_d.c delete mode 100644 tests/bger_d.c delete mode 100644 tests/bger_f.c delete mode 100644 tests/bgtr_d.c delete mode 100644 tests/bler_d.c delete mode 100644 tests/bltgtr_d.c delete mode 100644 tests/bltr_d.c delete mode 100644 tests/bner_d.c create mode 100644 tests/eqr.c create mode 100644 tests/eqr_f.c create mode 100644 tests/ger.c create mode 100644 tests/gtr.c create mode 100644 tests/gtr_f.c create mode 100644 tests/ler.c create mode 100644 tests/ler_f.c create mode 100644 tests/ltr.c create mode 100644 tests/ltr_f.c create mode 100644 tests/ner.c (limited to 'tests') diff --git a/tests/andr.c b/tests/andr.c index e714794..ada0751 100644 --- a/tests/andr.c +++ b/tests/andr.c @@ -94,7 +94,7 @@ int main() == 0x7fffffffffffffff); assert((uint64_t)ejit_run_func_2(f, - EJIT_ARG(0xffffffffffffffff, long), - EJIT_ARG(0xffffffffffffffff, long)) + EJIT_ARG(0xffffffffffffffff, long), + EJIT_ARG(0xffffffffffffffff, long)) == 0xffffffffffffffff); } diff --git a/tests/beqi.c b/tests/beqi.c index 147cd50..ebf149f 100644 --- a/tests/beqi.c +++ b/tests/beqi.c @@ -19,8 +19,8 @@ int main() ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); - assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1); - assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 0); assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0); ejit_destroy_func(f); diff --git a/tests/beqr.c b/tests/beqr.c index 109b48c..9fc74a6 100644 --- a/tests/beqr.c +++ b/tests/beqr.c @@ -20,12 +20,12 @@ int main() ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); - assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1); - assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0); - assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0); - assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0); - assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0); - assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 1); ejit_destroy_func(f); } diff --git a/tests/beqr_d.c b/tests/beqr_d.c deleted file mode 100644 index 8d61e6e..0000000 --- a/tests/beqr_d.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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_DOUBLE, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1)); - - jit_reloc_t r = jit_beqr_d(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(double, double) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 0); - ASSERT(f(1, 1) == 1); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/beqr_f.c b/tests/beqr_f.c index 7463ed6..2f12db7 100644 --- a/tests/beqr_f.c +++ b/tests/beqr_f.c @@ -1,35 +1,43 @@ -#include "test.h" +#include +#include +#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)); - - jit_reloc_t r = jit_beqr_f(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(float, float) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 0); - ASSERT(f(1, 1) == 1); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} + struct ejit_operand operands[2] = { + EJIT_OPERAND_FPR(0, EJIT_TYPE(double)), + EJIT_OPERAND_FPR(1, EJIT_TYPE(double)) + }; -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + struct ejit_reloc r = ejit_beqr_f(f, EJIT_FPR(0), EJIT_FPR(1)); + ejit_reti(f, 0); + + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + + ejit_reti(f, 1); + + ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(1, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(-1, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(1, double)) == 1); + + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0.0/0.0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double), + EJIT_ARG(0, double)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bgei.c b/tests/bgei.c index e0b8e1a..c6fefc4 100644 --- a/tests/bgei.c +++ b/tests/bgei.c @@ -1,28 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bgei(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_bgei(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 1); - ASSERT(f(1) == 1); - ASSERT(f(-1) == 0); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bgei_u.c b/tests/bgei_u.c index d2997ff..eb649a2 100644 --- a/tests/bgei_u.c +++ b/tests/bgei_u.c @@ -1,28 +1,25 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bgei_u(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_bgei_u(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 1); - ASSERT(f(1) == 1); - ASSERT(f(-1) == 1); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1); } diff --git a/tests/bger.c b/tests/bger.c index 651a9e8..473296b 100644 --- a/tests/bger.c +++ b/tests/bger.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bger(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bger(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bger_d.c b/tests/bger_d.c deleted file mode 100644 index 6a9cea3..0000000 --- a/tests/bger_d.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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_DOUBLE, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1)); - - jit_reloc_t r = jit_bger_d(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(double, double) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/bger_f.c b/tests/bger_f.c deleted file mode 100644 index 7c4974f..0000000 --- a/tests/bger_f.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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)); - - jit_reloc_t r = jit_bger_f(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(float, float) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/bger_u.c b/tests/bger_u.c index 05038d5..e720cca 100644 --- a/tests/bger_u.c +++ b/tests/bger_u.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bger_u(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bger_u(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bgti.c b/tests/bgti.c index 79ea2d4..8e89d52 100644 --- a/tests/bgti.c +++ b/tests/bgti.c @@ -1,28 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bgti(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_bgti(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 0); - ASSERT(f(1) == 1); - ASSERT(f(-1) == 0); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bgti_u.c b/tests/bgti_u.c index 69325df..8701fa6 100644 --- a/tests/bgti_u.c +++ b/tests/bgti_u.c @@ -1,28 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bgti_u(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_bgti_u(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 0); - ASSERT(f(1) == 1); - ASSERT(f(-1) == 1); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bgtr.c b/tests/bgtr.c index c6c1fda..ae59e5b 100644 --- a/tests/bgtr.c +++ b/tests/bgtr.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bgtr(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bgtr(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bgtr_d.c b/tests/bgtr_d.c deleted file mode 100644 index aa9b23a..0000000 --- a/tests/bgtr_d.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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_DOUBLE, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1)); - - jit_reloc_t r = jit_bgtr_d(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(double, double) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/bgtr_f.c b/tests/bgtr_f.c index 6245644..0b5b7f4 100644 --- a/tests/bgtr_f.c +++ b/tests/bgtr_f.c @@ -1,34 +1,39 @@ -#include "test.h" +#include +#include +#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)) + }; - jit_reloc_t r = jit_bgtr_f(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bgtr_f(f, EJIT_FPR(0), EJIT_FPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(float, float) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); + ejit_select_compile_func(f, 0, 2, EJIT_USE64(long), do_jit); - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(1, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(-1, double)) == 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0.0/0.0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double), + EJIT_ARG(0, double)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bgtr_u.c b/tests/bgtr_u.c index 53373f0..5334825 100644 --- a/tests/bgtr_u.c +++ b/tests/bgtr_u.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bgtr_u(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bgtr_u(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/blei.c b/tests/blei.c index 46ce461..3aabad6 100644 --- a/tests/blei.c +++ b/tests/blei.c @@ -1,28 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_blei(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_blei(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 1); - ASSERT(f(1) == 0); - ASSERT(f(-1) == 1); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/blei_u.c b/tests/blei_u.c index f8ed875..b4fb009 100644 --- a/tests/blei_u.c +++ b/tests/blei_u.c @@ -1,28 +1,25 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_blei_u(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_blei_u(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 1); - ASSERT(f(1) == 0); - ASSERT(f(-1) == 0); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0); } diff --git a/tests/bler.c b/tests/bler.c index cf835e0..72582b0 100644 --- a/tests/bler.c +++ b/tests/bler.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bler(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bler(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bler_d.c b/tests/bler_d.c deleted file mode 100644 index f67df1a..0000000 --- a/tests/bler_d.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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_DOUBLE, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1)); - - jit_reloc_t r = jit_bler_d(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(double, double) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/bler_f.c b/tests/bler_f.c index ff18190..f3ff780 100644 --- a/tests/bler_f.c +++ b/tests/bler_f.c @@ -1,34 +1,39 @@ -#include "test.h" +#include +#include +#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)) + }; - jit_reloc_t r = jit_bler_f(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bler_f(f, EJIT_FPR(0), EJIT_FPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(float, float) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); + ejit_select_compile_func(f, 0, 2, EJIT_USE64(long), do_jit); - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(1, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, double), + EJIT_ARG(0, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(-1, double)) == 0); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0.0/0.0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double), + EJIT_ARG(0, double)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bler_u.c b/tests/bler_u.c index 87ac322..8bcd8ef 100644 --- a/tests/bler_u.c +++ b/tests/bler_u.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bler_u(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bler_u(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bltgtr_d.c b/tests/bltgtr_d.c deleted file mode 100644 index d549d08..0000000 --- a/tests/bltgtr_d.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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_DOUBLE, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1)); - - jit_reloc_t r = jit_bltgtr_d(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(double, double) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 1); - ASSERT(f(1, 1) == 0); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); - ASSERT(f(0.0/0.0, 0.0/0.0) == 0); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/bltgtr_f.c b/tests/bltgtr_f.c index 6f4e6ac..32b2a96 100644 --- a/tests/bltgtr_f.c +++ b/tests/bltgtr_f.c @@ -1,36 +1,41 @@ -#include "test.h" +#include +#include +#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)), + }; - jit_reloc_t r = jit_bltgtr_f(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bltgtr_f(f, EJIT_FPR(0), EJIT_FPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(float, float) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 1); - ASSERT(f(1, 1) == 0); + ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit); - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); - ASSERT(f(0.0/0.0, 0.0/0.0) == 0); -} + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(1, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(-1, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, double), + EJIT_ARG(0, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(1, double)) == 0); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0.0/0.0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double), + EJIT_ARG(0.0/0.0, double)) == 0); } diff --git a/tests/blti.c b/tests/blti.c index dd9c907..9f7fbcb 100644 --- a/tests/blti.c +++ b/tests/blti.c @@ -1,28 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_blti(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_blti(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 0); - ASSERT(f(1) == 0); - ASSERT(f(-1) == 1); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/blti_u.c b/tests/blti_u.c index 13582c3..ca30e7e 100644 --- a/tests/blti_u.c +++ b/tests/blti_u.c @@ -1,28 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_blti_u(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_blti_u(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); - ASSERT(f(0) == 0); - ASSERT(f(1) == 0); - ASSERT(f(-1) == 0); -} + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bltr.c b/tests/bltr.c index b5c7976..c5b3b87 100644 --- a/tests/bltr.c +++ b/tests/bltr.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bltr(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bltr(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bltr_d.c b/tests/bltr_d.c deleted file mode 100644 index d19be55..0000000 --- a/tests/bltr_d.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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_DOUBLE, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1)); - - jit_reloc_t r = jit_bltr_d(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(double, double) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); - - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/bltr_f.c b/tests/bltr_f.c index 35eb77b..e69569a 100644 --- a/tests/bltr_f.c +++ b/tests/bltr_f.c @@ -1,34 +1,39 @@ -#include "test.h" +#include +#include +#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)) + }; - jit_reloc_t r = jit_bltr_f(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bltr_f(f, EJIT_FPR(0), EJIT_FPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(float, float) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 0); + ejit_select_compile_func(f, 0, 2, EJIT_USE64(long), do_jit); - ASSERT(f(0, 0.0/0.0) == 0); - ASSERT(f(0.0/0.0, 0) == 0); -} + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(1, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, double), + EJIT_ARG(0, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(-1, double)) == 0); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(0.0/0.0, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double), + EJIT_ARG(0, double)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bltr_u.c b/tests/bltr_u.c index d0a9f39..c96cd4d 100644 --- a/tests/bltr_u.c +++ b/tests/bltr_u.c @@ -1,31 +1,29 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bltr_u(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bltr_u(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 1); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bmci.c b/tests/bmci.c index e8310e0..75f235d 100644 --- a/tests/bmci.c +++ b/tests/bmci.c @@ -1,29 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bmci(j, JIT_R0, 1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_bmci(f, EJIT_GPR(0), 1); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0) == 1); - ASSERT(f(1) == 0); - ASSERT(f(-1) == 0); - ASSERT(f(2) == 1); -} + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG( 2, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bmcr.c b/tests/bmcr.c index 3dbc98a..731b9a6 100644 --- a/tests/bmcr.c +++ b/tests/bmcr.c @@ -1,35 +1,33 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bmcr(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bmcr(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 1); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 1); - ASSERT(f(1, 1) == 0); - ASSERT(f(1, -1) == 0); - ASSERT(f(-1, 1) == 0); - ASSERT(f(-1, -1) == 0); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG(-1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(-1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bmsi.c b/tests/bmsi.c index aaad68a..f189218 100644 --- a/tests/bmsi.c +++ b/tests/bmsi.c @@ -1,29 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bmsi(j, JIT_R0, 1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); + struct ejit_reloc r = ejit_bmsi(f, EJIT_GPR(0), 1); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0) == 0); - ASSERT(f(1) == 1); - ASSERT(f(-1) == 1); - ASSERT(f(2) == 0); -} + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG( 2, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bmsr.c b/tests/bmsr.c index d471fdf..b4e344e 100644 --- a/tests/bmsr.c +++ b/tests/bmsr.c @@ -1,35 +1,33 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bmsr(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + struct ejit_reloc r = ejit_bmsr(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 0); - ASSERT(f(1, 0) == 0); - ASSERT(f(-1, 0) == 0); - ASSERT(f(0, -1) == 0); - ASSERT(f(1, 1) == 1); - ASSERT(f(1, -1) == 1); - ASSERT(f(-1, 1) == 1); - ASSERT(f(-1, -1) == 1); -} + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG(-1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bnei.c b/tests/bnei.c index 3e9e376..7ac32a6 100644 --- a/tests/bnei.c +++ b/tests/bnei.c @@ -1,28 +1,27 @@ -#include "test.h" +#include +#include +#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0)); + struct ejit_operand operands[1] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bnei(j, JIT_R0, 0); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands); - jit_word_t (*f)(jit_word_t) = jit_end(j, NULL); + struct ejit_reloc r = ejit_bnei(f, EJIT_GPR(0), 0); + ejit_reti(f, 0); - ASSERT(f(0) == 0); - ASSERT(f(1) == 1); - ASSERT(f(-1) == 1); -} + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 1); + assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/bner.c b/tests/bner.c index d9b2305..7d96f95 100644 --- a/tests/bner.c +++ b/tests/bner.c @@ -1,31 +1,31 @@ -#include "test.h" +#include +#include +#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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0), - jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1)); + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)), + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; - jit_reloc_t r = jit_bner(j, JIT_R0, JIT_R1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); - jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL); + struct ejit_reloc r = ejit_bner(f, EJIT_GPR(0), EJIT_GPR(1)); + ejit_reti(f, 0); - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 1); -} + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + ejit_reti(f, 1); -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 0); + + ejit_destroy_func(f); } diff --git a/tests/bner_d.c b/tests/bner_d.c deleted file mode 100644 index b45deed..0000000 --- a/tests/bner_d.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "test.h" - -static void -run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) -{ - 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_DOUBLE, JIT_F0), - jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1)); - - jit_reloc_t r = jit_bner_d(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(double, double) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 1); - ASSERT(f(1, 1) == 0); - - ASSERT(f(0, 0.0/0.0) == 1); - ASSERT(f(0.0/0.0, 0) == 1); - ASSERT(f(0.0/0.0, 0.0/0.0) == 1); -} - -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); -} diff --git a/tests/bner_f.c b/tests/bner_f.c index f57bbc4..5ac83bd 100644 --- a/tests/bner_f.c +++ b/tests/bner_f.c @@ -1,36 +1,57 @@ -#include "test.h" +#include +#include +#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)); - - jit_reloc_t r = jit_bner_f(j, JIT_F0, JIT_F1); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 0); - jit_patch_here(j, r); - jit_leave_jit_abi(j, 0, 0, align); - jit_reti(j, 1); - - jit_word_t (*f)(float, float) = jit_end(j, NULL); - - ASSERT(f(0, 0) == 0); - ASSERT(f(0, 1) == 1); - ASSERT(f(1, 0) == 1); - ASSERT(f(-1, 0) == 1); - ASSERT(f(0, -1) == 1); - ASSERT(f(1, 1) == 0); - - ASSERT(f(0, 0.0/0.0) == 1); - ASSERT(f(0.0/0.0, 0) == 1); - ASSERT(f(0.0/0.0, 0.0/0.0) == 1); -} + struct ejit_operand operands[2] = { + EJIT_OPERAND_FPR(0, EJIT_TYPE(double)), + EJIT_OPERAND_FPR(1, EJIT_TYPE(double)) + }; -int -main (int argc, char *argv[]) -{ - return main_helper(argc, argv, run_test); + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + struct ejit_reloc r = ejit_bner_f(f, EJIT_FPR(0), EJIT_FPR(1)); + ejit_reti(f, 0); + + struct ejit_label l = ejit_label(f); + ejit_patch(f, r, l); + + ejit_reti(f, 1); + + ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit); + + assert(ejit_run_func_2(f, + EJIT_ARG(0, double), + EJIT_ARG(0, double)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0, double), + EJIT_ARG(1, double)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(-1, double), + EJIT_ARG(0, double)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0, double), + EJIT_ARG(-1, double)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(1, double), + EJIT_ARG(1, double)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0, double), + EJIT_ARG(0.0/0.0, double)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0.0/0.0, double), + EJIT_ARG(0, double)) == 1); + + ejit_destroy_func(f); } diff --git a/tests/eqr.c b/tests/eqr.c new file mode 100644 index 0000000..7f33b19 --- /dev/null +++ b/tests/eqr.c @@ -0,0 +1,30 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; + + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + ejit_eqr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, long), + EJIT_ARG(0x7ffffffffffffff0, long)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x6fffffffffffffff, long), + EJIT_ARG(0x7fffffffffffffff, long)) == 0); + ejit_destroy_func(f); +} diff --git a/tests/eqr_f.c b/tests/eqr_f.c new file mode 100644 index 0000000..7afe002 --- /dev/null +++ b/tests/eqr_f.c @@ -0,0 +1,32 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + 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(long), 2, operands); + + ejit_eqr_f(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(1, double)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, double), + EJIT_ARG(0x7ffffffffffffff0, double)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x6fffffffffffffff, double), + EJIT_ARG(0x7fffffffffffffff, double)) == 0); + ejit_destroy_func(f); +} diff --git a/tests/ger.c b/tests/ger.c new file mode 100644 index 0000000..195d4c1 --- /dev/null +++ b/tests/ger.c @@ -0,0 +1,30 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; + + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + ejit_gtr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x0fffffffffffffff, long), + EJIT_ARG(0x0ffffffffffffff0, long)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, long), + EJIT_ARG(0x6fffffffffffffff, long)) == 1); + ejit_destroy_func(f); +} diff --git a/tests/gtr.c b/tests/gtr.c new file mode 100644 index 0000000..34dfd39 --- /dev/null +++ b/tests/gtr.c @@ -0,0 +1,30 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; + + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + ejit_gtr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x0fffffffffffffff, long), + EJIT_ARG(0x0ffffffffffffff0, long)) == 0); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, long), + EJIT_ARG(0x6fffffffffffffff, long)) == 1); + ejit_destroy_func(f); +} diff --git a/tests/gtr_f.c b/tests/gtr_f.c new file mode 100644 index 0000000..4c07bfe --- /dev/null +++ b/tests/gtr_f.c @@ -0,0 +1,25 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + 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(long), 2, operands); + + ejit_gtr(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(1, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(0, double), + EJIT_ARG(1, double)) == 1); + + ejit_destroy_func(f); +} diff --git a/tests/ler.c b/tests/ler.c new file mode 100644 index 0000000..0bd6e26 --- /dev/null +++ b/tests/ler.c @@ -0,0 +1,30 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; + + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + ejit_ler(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x0fffffffffffffff, long), + EJIT_ARG(0x0ffffffffffffff0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, long), + EJIT_ARG(0x6fffffffffffffff, long)) == 0); + ejit_destroy_func(f); +} diff --git a/tests/ler_f.c b/tests/ler_f.c new file mode 100644 index 0000000..00fe9ef --- /dev/null +++ b/tests/ler_f.c @@ -0,0 +1,30 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + 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); + + ejit_ler(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x0fffffffffffffff, long), + EJIT_ARG(0x0ffffffffffffff0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, long), + EJIT_ARG(0x6fffffffffffffff, long)) == 0); + ejit_destroy_func(f); +} diff --git a/tests/ltr.c b/tests/ltr.c new file mode 100644 index 0000000..2deb6ae --- /dev/null +++ b/tests/ltr.c @@ -0,0 +1,30 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; + + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + ejit_ltr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x0fffffffffffffff, long), + EJIT_ARG(0x0ffffffffffffff0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, long), + EJIT_ARG(0x6fffffffffffffff, long)) == 0); + ejit_destroy_func(f); +} diff --git a/tests/ltr_f.c b/tests/ltr_f.c new file mode 100644 index 0000000..5e5a98b --- /dev/null +++ b/tests/ltr_f.c @@ -0,0 +1,32 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + 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(long), 2, operands); + + ejit_ltr_f(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(1, double)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, double), + EJIT_ARG(0, double)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x0fffffffffffffff, double), + EJIT_ARG(0x0ffffffffffffff0, double)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, double), + EJIT_ARG(0x6fffffffffffffff, double)) == 0); + ejit_destroy_func(f); +} diff --git a/tests/ner.c b/tests/ner.c new file mode 100644 index 0000000..ca615d0 --- /dev/null +++ b/tests/ner.c @@ -0,0 +1,30 @@ +#include +#include +#include "do_jit.h" + +int main() +{ + struct ejit_operand operands[2] = { + EJIT_OPERAND_GPR(0, EJIT_TYPE(long)) + EJIT_OPERAND_GPR(1, EJIT_TYPE(long)) + }; + + struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands); + + ejit_ner(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1)); + ejit_retr(f, EJIT_GPR(0)); + + ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit); + + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 0); + assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x7fffffffffffffff, long), + EJIT_ARG(0x7ffffffffffffff0, long)) == 1); + + assert(ejit_run_func_2(f, + EJIT_ARG(0x6fffffffffffffff, long), + EJIT_ARG(0x7fffffffffffffff, long)) == 1); + ejit_destroy_func(f); +} -- cgit v1.2.3