aboutsummaryrefslogtreecommitdiff
path: root/tests/beqr.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/beqr.c')
-rw-r--r--tests/beqr.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/tests/beqr.c b/tests/beqr.c
index 0cc4476..109b48c 100644
--- a/tests/beqr.c
+++ b/tests/beqr.c
@@ -1,32 +1,31 @@
-#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_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_beqr(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_beqr(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- 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);
-}
+ 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)) == 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);
}