diff --git a/tests/beqr_d.c b/tests/beqr_d.c new file mode 100644 index 000000000..9bc6c0fda --- /dev/null +++ b/tests/beqr_d.c @@ -0,0 +1,34 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_beqr_d(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +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 new file mode 100644 index 000000000..00e1fcced --- /dev/null +++ b/tests/beqr_f.c @@ -0,0 +1,34 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_beqr_f(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +int +main (int argc, char *argv[]) +{ + return main_helper(argc, argv, run_test); +} diff --git a/tests/bger_d.c b/tests/bger_d.c new file mode 100644 index 000000000..24a52dcf2 --- /dev/null +++ b/tests/bger_d.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bger_d(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +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 new file mode 100644 index 000000000..f068d77d6 --- /dev/null +++ b/tests/bger_f.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bger_f(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +int +main (int argc, char *argv[]) +{ + return main_helper(argc, argv, run_test); +} diff --git a/tests/bgtr_d.c b/tests/bgtr_d.c new file mode 100644 index 000000000..5bc69146e --- /dev/null +++ b/tests/bgtr_d.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bgtr_d(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +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 new file mode 100644 index 000000000..da271b77e --- /dev/null +++ b/tests/bgtr_f.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bgtr_f(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_t (*f)(float, float) = 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); +} + +int +main (int argc, char *argv[]) +{ + return main_helper(argc, argv, run_test); +} diff --git a/tests/bler_d.c b/tests/bler_d.c new file mode 100644 index 000000000..955004356 --- /dev/null +++ b/tests/bler_d.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bler_d(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +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 new file mode 100644 index 000000000..751f2bb77 --- /dev/null +++ b/tests/bler_f.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bler_f(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_t (*f)(float, float) = 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); +} + +int +main (int argc, char *argv[]) +{ + return main_helper(argc, argv, run_test); +} diff --git a/tests/bltr_d.c b/tests/bltr_d.c new file mode 100644 index 000000000..fd7daf2c1 --- /dev/null +++ b/tests/bltr_d.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bltr_d(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +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 new file mode 100644 index 000000000..20075e30d --- /dev/null +++ b/tests/bltr_f.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bltr_f(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_t (*f)(float, float) = 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); +} + +int +main (int argc, char *argv[]) +{ + return main_helper(argc, argv, run_test); +} diff --git a/tests/bner_d.c b/tests/bner_d.c new file mode 100644 index 000000000..a4d361b73 --- /dev/null +++ b/tests/bner_d.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bner_d(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +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 new file mode 100644 index 000000000..e2badd907 --- /dev/null +++ b/tests/bner_f.c @@ -0,0 +1,33 @@ +#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); + + const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT }; + jit_arg_t args[2]; + const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } }; + + jit_receive(j, 2, abi, args); + jit_load_args(j, 2, abi, args, regs); + + jit_reloc_t r = jit_bner_f(j, JIT_F0, JIT_F1); + jit_reti(j, 0); + jit_patch_here(j, r); + jit_reti(j, 1); + + intmax_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); +} + +int +main (int argc, char *argv[]) +{ + return main_helper(argc, argv, run_test); +}