aboutsummaryrefslogtreecommitdiff
path: root/tests/bltr_u.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bltr_u.c')
-rw-r--r--tests/bltr_u.c46
1 files changed, 22 insertions, 24 deletions
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 <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_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);
}