aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/absr_f.c11
-rw-r--r--tests/addi.c34
-rw-r--r--tests/addr.c21
-rw-r--r--tests/addr_d.c27
-rw-r--r--tests/addr_f.c14
-rwxr-xr-xtests/test-bcode-absr_fbin288432 -> 0 bytes
6 files changed, 36 insertions, 71 deletions
diff --git a/tests/absr_f.c b/tests/absr_f.c
index cc070b6..94a0e42 100644
--- a/tests/absr_f.c
+++ b/tests/absr_f.c
@@ -7,13 +7,14 @@ int main()
struct ejit_operand operands[1] = {
EJIT_OPERAND_FPR(0, EJIT_DOUBLE)
};
- struct ejit_func *f = ejit_create_func(EJIT_DOUBLE, 1, operands);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 1, operands);
ejit_absr_f(f, EJIT_FPR(0), EJIT_FPR(0));
ejit_retr_f(f, EJIT_FPR(0));
ejit_select_compile_func(f, 0, 1, do_jit);
- assert(ejit_run_func_f_1(f, ejit_double(0.0)) == 0.0);
- assert(ejit_run_func_f_1(f, ejit_double(-0.0)) == 0.0);
- assert(ejit_run_func_f_1(f, ejit_double(0.5)) == 0.5);
- assert(ejit_run_func_f_1(f, ejit_double(-0.5)) == 0.5);
+ assert(ejit_run_func_f_1(f, EJIT_ARG(0.0, double)) == 0.0);
+ assert(ejit_run_func_f_1(f, EJIT_ARG(-0.0, double)) == 0.0);
+ assert(ejit_run_func_f_1(f, EJIT_ARG(0.5, double)) == 0.5);
+ assert(ejit_run_func_f_1(f, EJIT_ARG(-0.5, double)) == 0.5);
+ ejit_destroy_func(f);
}
diff --git a/tests/addi.c b/tests/addi.c
index 27cdfab..e0471d6 100644
--- a/tests/addi.c
+++ b/tests/addi.c
@@ -1,25 +1,17 @@
-#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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int), 1, operands);
+ ejit_addi(f, EJIT_GPR(0), EJIT_GPR(0), 69);
+ ejit_retr(f, EJIT_GPR(0));
+ ejit_select_compile_func(f, 1, 0, do_jit);
- jit_addi(j, JIT_R0, JIT_R0, 69);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- int (*f)(int) = ret;
- ASSERT(f(42) == 111);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_1(f, EJIT_ARG(42, int)) == 111);
+ ejit_destroy_func(f);
}
diff --git a/tests/addr.c b/tests/addr.c
index f524aa6..099536a 100644
--- a/tests/addr.c
+++ b/tests/addr.c
@@ -1,23 +1,22 @@
#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
int
main (int argc, char *argv[])
{
struct ejit_operand operands[2] = {
- EJIT_OPERAND_GPR(0, EJIT_LONG),
- EJIT_OPERAND_GPR(1, EJIT_LONG)
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
};
- struct ejit_func *f = ejit_create_func(EJIT_LONG, 2, operands);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
- ejit_addr(j, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
- ejit_retr(j, EJIT_GPR(0));
+ ejit_addr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
- ejit_compile(f);
+ ejit_select_compile_func(f, 2, 0, do_jit);
- struct ejit_arg args[2] = {
- EJIT_ARG(42, EJIT_LONG),
- EJIT_ARG(69, EJIT_LONG)
- };
- ASSERT(ejit_run_func(f, 2, args) == 111);
+ assert(ejit_run_func_2(f, EJIT_ARG(42, long), EJIT_ARG(69, long)) == 111);
+ ejit_destroy_func(f);
}
diff --git a/tests/addr_d.c b/tests/addr_d.c
deleted file mode 100644
index 2aa9002..0000000
--- a/tests/addr_d.c
+++ /dev/null
@@ -1,27 +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_addr_d(j, JIT_F0, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr_d(j, JIT_F0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- double (*f)(double, double) = ret;
- ASSERT(f(42., 69.) == 111.);
- ASSERT(f(42.5, 69.5) == 112.);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/addr_f.c b/tests/addr_f.c
index d27ce8b..2aa9002 100644
--- a/tests/addr_f.c
+++ b/tests/addr_f.c
@@ -5,19 +5,19 @@ 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_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
+ jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
- jit_addr_f(j, JIT_F0, JIT_F0, JIT_F1);
+ jit_addr_d(j, JIT_F0, JIT_F0, JIT_F1);
jit_leave_jit_abi(j, 0, 0, align);
- jit_retr_f(j, JIT_F0);
+ jit_retr_d(j, JIT_F0);
size_t size = 0;
void* ret = jit_end(j, &size);
- float (*f)(float, float) = ret;
- ASSERT(f(42.f, 69.f) == 111.f);
- ASSERT(f(42.5f, 69.5f) == 112.f);
+ double (*f)(double, double) = ret;
+ ASSERT(f(42., 69.) == 111.);
+ ASSERT(f(42.5, 69.5) == 112.);
}
int
diff --git a/tests/test-bcode-absr_f b/tests/test-bcode-absr_f
deleted file mode 100755
index 8e902b5..0000000
--- a/tests/test-bcode-absr_f
+++ /dev/null
Binary files differ