aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-07-13 20:56:26 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-07-13 20:56:26 +0300
commitae9e103995c1d809be7b8717905593e7dbbf9d17 (patch)
tree0ceaf6ee66e1d67bb8d0b9dd6f37b5687e4c2f09 /tests
parente618924df98d4ee5037db86c768a8c8014e49c4c (diff)
downloadejit-ae9e103995c1d809be7b8717905593e7dbbf9d17.tar.gz
ejit-ae9e103995c1d809be7b8717905593e7dbbf9d17.zip
bytecode tests pass
Diffstat (limited to 'tests')
-rw-r--r--tests/divr.c152
-rw-r--r--tests/divr64.c151
-rw-r--r--tests/divr_f.c12
-rw-r--r--tests/ldxi_f.c2
-rw-r--r--tests/ldxi_i16.c6
-rw-r--r--tests/ldxi_i64.c8
-rw-r--r--tests/ldxi_u16.c8
-rw-r--r--tests/ldxi_u64.c13
-rw-r--r--tests/ldxr_i8.c14
-rw-r--r--tests/ldxr_u8.c14
-rw-r--r--tests/ler.c30
-rw-r--r--tests/ler64.c32
-rw-r--r--tests/ler_f.c18
-rw-r--r--tests/ltr.c4
-rw-r--r--tests/ltr_f.c15
-rw-r--r--tests/makefile6
-rw-r--r--tests/movi.c28
-rw-r--r--tests/movi_f.c28
-rw-r--r--tests/movr.c17
-rw-r--r--tests/movr_f.c17
-rw-r--r--tests/mulr.c64
-rw-r--r--tests/mulr64.c122
-rw-r--r--tests/mulr_f.c37
-rw-r--r--tests/negr.c64
-rw-r--r--tests/negr_f.c35
-rw-r--r--tests/ner.c2
-rw-r--r--tests/ner_f.c25
-rw-r--r--tests/ori.c31
-rw-r--r--tests/ori64.c26
-rw-r--r--tests/orr.c48
-rw-r--r--tests/orr64.c86
-rw-r--r--tests/remr.c60
-rw-r--r--tests/remr64.c100
-rw-r--r--tests/remr_u.c56
-rw-r--r--tests/remr_u64.c95
-rw-r--r--tests/rshi.c28
-rw-r--r--tests/rshi64.c22
-rw-r--r--tests/rshi_u.c28
-rw-r--r--tests/rshi_u64.c21
-rw-r--r--tests/rshr.c63
-rw-r--r--tests/rshr64.c115
-rw-r--r--tests/rshr_u.c62
-rw-r--r--tests/rshr_u64.c113
-rw-r--r--tests/sti_16.c28
-rw-r--r--tests/sti_32.c28
-rw-r--r--tests/sti_64.c28
-rw-r--r--tests/sti_8.c28
-rw-r--r--tests/sti_c.c31
-rw-r--r--tests/sti_d.c41
-rw-r--r--tests/sti_f.c41
-rw-r--r--tests/sti_i.c31
-rw-r--r--tests/sti_l.c33
-rw-r--r--tests/sti_s.c31
-rw-r--r--tests/str_atomic.c32
-rw-r--r--tests/str_c.c32
-rw-r--r--tests/str_d.c32
-rw-r--r--tests/str_f.c32
-rw-r--r--tests/str_i.c32
-rw-r--r--tests/str_l.c34
-rw-r--r--tests/str_s.c32
-rw-r--r--tests/stxi_16.c29
-rw-r--r--tests/stxi_32.c29
-rw-r--r--tests/stxi_64.c29
-rw-r--r--tests/stxi_8.c29
-rw-r--r--tests/stxi_c.c32
-rw-r--r--tests/stxi_d.c43
-rw-r--r--tests/stxi_f.c43
-rw-r--r--tests/stxi_i.c32
-rw-r--r--tests/stxi_l.c34
-rw-r--r--tests/stxi_s.c32
-rw-r--r--tests/stxr_16.c35
-rw-r--r--tests/stxr_32.c35
-rw-r--r--tests/stxr_64.c35
-rw-r--r--tests/stxr_8.c35
-rw-r--r--tests/stxr_c.c33
-rw-r--r--tests/stxr_d.c50
-rw-r--r--tests/stxr_f.c50
-rw-r--r--tests/stxr_i.c33
-rw-r--r--tests/stxr_l.c35
-rw-r--r--tests/stxr_s.c33
-rw-r--r--tests/subr.c33
-rw-r--r--tests/subr_f.c38
-rw-r--r--tests/swap_atomic.c32
-rw-r--r--tests/truncr_d_32.c27
-rw-r--r--tests/truncr_d_64.c27
-rw-r--r--tests/truncr_d_i.c30
-rw-r--r--tests/truncr_d_l.c32
-rw-r--r--tests/truncr_f_i.c30
-rw-r--r--tests/truncr_f_l.c32
-rw-r--r--tests/xori.c31
-rw-r--r--tests/xori64.c26
-rw-r--r--tests/xorr.c48
-rw-r--r--tests/xorr64.c89
93 files changed, 1790 insertions, 1815 deletions
diff --git a/tests/divr.c b/tests/divr.c
deleted file mode 100644
index e16a8bf..0000000
--- a/tests/divr.c
+++ /dev/null
@@ -1,152 +0,0 @@
-#include <ejit/ejit.h>
-#include <assert.h>
-#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_divr(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(0x7fffffff, long),
- EJIT_ARG(1, long)) == 0x7fffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(1, long),
- EJIT_ARG(0x7fffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x80000000, long),
- EJIT_ARG(1, long)) == 0x80000000);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(1, long),
- EJIT_ARG(0x80000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffff, long),
- EJIT_ARG(2, long)) == 0x3fffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(2, long),
- EJIT_ARG(0x7fffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(2, long),
- EJIT_ARG(0x80000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffff, long),
- EJIT_ARG(0x80000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0, long),
- EJIT_ARG(0x7fffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffff, long),
- EJIT_ARG(0xffffffff, long)) == 1);
-
-#warning "Some 32bit handling still unclear"
- /* 32bit specific stuff, unsure how this should be handled on 64bit
- * systems
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x80000000, long),
- EJIT_ARG(2, long)) == 0xc0000000);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x80000000, long),
- EJIT_ARG(0x7fffffff, long)) == 0xffffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffff, long),
- EJIT_ARG(0xffffffff, long)) == 0x80000001);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffff, long),
- EJIT_ARG(0x7fffffff, long)) == 0);
- */
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x80000000, long),
- EJIT_ARG(2, long)) == 0x40000000);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x80000000, long),
- EJIT_ARG(0x7fffffff, long)) == 1);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffff, long),
- EJIT_ARG(0xffffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffff, long),
- EJIT_ARG(0x7fffffff, long)) == 2);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffffffffffff, long),
- EJIT_ARG(1, long)) == 0x7fffffffffffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(1, long),
- EJIT_ARG(0x7fffffffffffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x8000000000000000, long),
- EJIT_ARG(1, long))
- == (int64_t)0x8000000000000000);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(1, long),
- EJIT_ARG(0x8000000000000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffffffffffff, long),
- EJIT_ARG(2, long))
- == (int64_t)0x3fffffffffffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(2, long),
- EJIT_ARG(0x7fffffffffffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x8000000000000000, long),
- EJIT_ARG(2, long))
- == (int64_t)0xc000000000000000);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(2, long),
- EJIT_ARG(0x8000000000000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffffffffffff, long),
- EJIT_ARG(0x8000000000000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x8000000000000000, long),
- EJIT_ARG(0x7fffffffffffffff, long))
- == (int32_t)0xffffffffffffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffffffffffff, long),
- EJIT_ARG(0xffffffffffffffff, long))
- == (int32_t)0x8000000000000001);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffffffffffff, long),
- EJIT_ARG(0x7fffffffffffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffffffffffff, long),
- EJIT_ARG(0xffffffffffffffff, long)) == 1);
-
- ejit_destroy_func(f);
-}
diff --git a/tests/divr64.c b/tests/divr64.c
new file mode 100644
index 0000000..33baa91
--- /dev/null
+++ b/tests/divr64.c
@@ -0,0 +1,151 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_divr(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(int64_t), do_jit);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x7fffffff);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x80000000);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(2, int64_t)) == 0x3fffffff);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)) == 1);
+
+ /* 32bit specific stuff, unsure how this should be handled on 64bit
+ * systems
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(2, int64_t)) == 0xc0000000);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0xffffffff);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)) == 0x80000001);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0);
+ */
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(2, int64_t)) == 0x40000000);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 2);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x7fffffffffffffff);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(1, int64_t))
+ == (int64_t)0x8000000000000000);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(2, int64_t))
+ == (int64_t)0x3fffffffffffffff);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(2, int64_t))
+ == (int64_t)0xc000000000000000);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)) == 1);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/divr_f.c b/tests/divr_f.c
index 081c63d..980844b 100644
--- a/tests/divr_f.c
+++ b/tests/divr_f.c
@@ -15,13 +15,13 @@ int main()
ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit);
- assert(ejit_run_func_2(f,
- EJIT_ARG(-0.5f, double),
- EJIT_ARG(0.5f, double)) == -1.0f);
+ assert(erff2(f,
+ EJIT_ARG(-0.5f, double),
+ EJIT_ARG(0.5f, double)) == -1.0f);
- assert(ejit_run_func_2(f,
- EJIT_ARG(1.25f, double),
- EJIT_ARG(0.5f, double)) == 2.5f);
+ assert(erff2(f,
+ EJIT_ARG(1.25f, double),
+ EJIT_ARG(0.5f, double)) == 2.5f);
ejit_destroy_func(f);
}
diff --git a/tests/ldxi_f.c b/tests/ldxi_f.c
index eb2ad58..955ef13 100644
--- a/tests/ldxi_f.c
+++ b/tests/ldxi_f.c
@@ -12,7 +12,7 @@ int main()
struct ejit_func *f = ejit_create_func(EJIT_TYPE(float), 1, operands);
- ejit_ldxi_d(f, EJIT_FPR(0), EJIT_GPR(0), (uintptr_t)data);
+ ejit_ldxi_f(f, EJIT_FPR(0), EJIT_GPR(0), (uintptr_t)data);
ejit_retr_f(f, EJIT_FPR(0));
ejit_select_compile_func(f, 1, 1, EJIT_USE64(long), do_jit);
diff --git a/tests/ldxi_i16.c b/tests/ldxi_i16.c
index e2af936..8fd1d0a 100644
--- a/tests/ldxi_i16.c
+++ b/tests/ldxi_i16.c
@@ -16,9 +16,9 @@ int main()
ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
- assert(erf1(f, EJIT_ARG(0, long)) == -1);
- assert(erf1(f, EJIT_ARG(1, long)) == 0);
- assert(erf1(f, EJIT_ARG(2, long)) == 0x4242);
+ assert(erf1(f, EJIT_ARG(sizeof(int16_t) * 0, long)) == -1);
+ assert(erf1(f, EJIT_ARG(sizeof(int16_t) * 1, long)) == 0);
+ assert(erf1(f, EJIT_ARG(sizeof(int16_t) * 2, long)) == 0x4242);
ejit_destroy_func(f);
}
diff --git a/tests/ldxi_i64.c b/tests/ldxi_i64.c
index 72112dd..c4b50c7 100644
--- a/tests/ldxi_i64.c
+++ b/tests/ldxi_i64.c
@@ -16,10 +16,10 @@ int main()
ejit_select_compile_func(f, 1, 0, true, do_jit);
- assert(erf1(f, EJIT_ARG(sizeof(int32_t) * 0, long)) == -1);
- assert(erf1(f, EJIT_ARG(sizeof(int32_t) * 1, long)) == 0);
- assert((uint64_t)erf1(f,
- EJIT_ARG(sizeof(int32_t) * 2, long)) == data[2]);
+ assert(erf1(f, EJIT_ARG(sizeof(int64_t) * 0, long)) == -1);
+ assert(erf1(f, EJIT_ARG(sizeof(int64_t) * 1, long)) == 0);
+ assert(erf1(f, EJIT_ARG(sizeof(int64_t) * 2, long)
+ ) == (int64_t)data[2]);
ejit_destroy_func(f);
}
diff --git a/tests/ldxi_u16.c b/tests/ldxi_u16.c
index a5d8fca..6d98944 100644
--- a/tests/ldxi_u16.c
+++ b/tests/ldxi_u16.c
@@ -11,14 +11,14 @@ int main()
};
struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
- ejit_ldxi_i16(f, EJIT_GPR(0), EJIT_GPR(0), (uintptr_t)&data);
+ ejit_ldxi_u16(f, EJIT_GPR(0), EJIT_GPR(0), (uintptr_t)&data);
ejit_retr(f, EJIT_GPR(0));
ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
- assert(erf1(f, EJIT_ARG(0, long)) == 0xffff);
- assert(erf1(f, EJIT_ARG(1, long)) == 0);
- assert(erf1(f, EJIT_ARG(2, long)) == 0x4242);
+ assert(erf1(f, EJIT_ARG(sizeof(int16_t) * 0, long)) == 0xffff);
+ assert(erf1(f, EJIT_ARG(sizeof(int16_t) * 1, long)) == 0);
+ assert(erf1(f, EJIT_ARG(sizeof(int16_t) * 2, long)) == 0x4242);
ejit_destroy_func(f);
}
diff --git a/tests/ldxi_u64.c b/tests/ldxi_u64.c
index 193fcf3..84f6dd1 100644
--- a/tests/ldxi_u64.c
+++ b/tests/ldxi_u64.c
@@ -16,11 +16,14 @@ int main()
ejit_select_compile_func(f, 1, 0, true, do_jit);
- assert((uint64_t)erf1(f,
- EJIT_ARG(sizeof(int32_t) * 0, long)) == data[0]);
- assert((uint64_t)erf1(f, EJIT_ARG(sizeof(int32_t) * 1, long)) == 0);
- assert((uint64_t)erf1(f,
- EJIT_ARG(sizeof(int32_t) * 2, long)) == data[2]);
+ assert(erf1(f, EJIT_ARG(sizeof(int64_t) * 0, long)
+ ) == (int64_t)data[0]);
+
+ assert(erf1(f, EJIT_ARG(sizeof(int64_t) * 1, long)
+ ) == 0);
+
+ assert(erf1(f, EJIT_ARG(sizeof(int64_t) * 2, long)
+ ) == (int64_t)data[2]);
ejit_destroy_func(f);
}
diff --git a/tests/ldxr_i8.c b/tests/ldxr_i8.c
index c5de17e..6fe910d 100644
--- a/tests/ldxr_i8.c
+++ b/tests/ldxr_i8.c
@@ -17,9 +17,17 @@ int main()
ejit_select_compile_func(f, 2, 0, false, do_jit);
- assert(erf2(f, EJIT_ARG(data, void *), EJIT_ARG(0, unsigned)) == -1);
- assert(erf2(f, EJIT_ARG(data, void *), EJIT_ARG(4, unsigned)) == 0);
- assert(erf2(f, EJIT_ARG(data, void *), EJIT_ARG(8, unsigned)) == 0x42);
+ assert(erf2(f, EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int8_t) * 0, unsigned)
+ ) == -1);
+
+ assert(erf2(f, EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int8_t) * 1, unsigned)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int8_t) * 2, unsigned)
+ ) == 0x42);
ejit_destroy_func(f);
}
diff --git a/tests/ldxr_u8.c b/tests/ldxr_u8.c
index d1f5023..83a0d36 100644
--- a/tests/ldxr_u8.c
+++ b/tests/ldxr_u8.c
@@ -17,9 +17,17 @@ int main()
ejit_select_compile_func(f, 2, 0, false, do_jit);
- assert(erf2(f, EJIT_ARG(data, void *), EJIT_ARG(0, unsigned)) == 0xff);
- assert(erf2(f, EJIT_ARG(data, void *), EJIT_ARG(4, unsigned)) == 0);
- assert(erf2(f, EJIT_ARG(data, void *), EJIT_ARG(8, unsigned)) == 0x42);
+ assert(erf2(f, EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int8_t) * 0, unsigned)
+ ) == 0xff);
+
+ assert(erf2(f, EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int8_t) * 1, unsigned)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int8_t) * 2, unsigned)
+ ) == 0x42);
ejit_destroy_func(f);
}
diff --git a/tests/ler.c b/tests/ler.c
deleted file mode 100644
index 90c4c4c..0000000
--- a/tests/ler.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <ejit/ejit.h>
-#include <assert.h>
-#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/ler64.c b/tests/ler64.c
new file mode 100644
index 0000000..322314c
--- /dev/null
+++ b/tests/ler64.c
@@ -0,0 +1,32 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 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(int64_t), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(1, int64_t)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x0fffffffffffffff, int64_t),
+ EJIT_ARG(0x0ffffffffffffff0, int64_t)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x6fffffffffffffff, int64_t)) == 0);
+ ejit_destroy_func(f);
+}
diff --git a/tests/ler_f.c b/tests/ler_f.c
index ecb4b3f..fa08b24 100644
--- a/tests/ler_f.c
+++ b/tests/ler_f.c
@@ -9,22 +9,16 @@ int main()
EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
};
- struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 2, operands);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
ejit_ler_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);
+ ejit_select_compile_func(f, 1, 2, EJIT_USE64(double), 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);
+ assert(erf2(f, EJIT_ARG(1, double), EJIT_ARG(1, double)) == 1);
+ assert(erf2(f, EJIT_ARG(1, double), EJIT_ARG(0, double)) == 0);
+ assert(erf2(f, EJIT_ARG(-1, double), EJIT_ARG(0, double)) == 1);
+ assert(erf2(f, EJIT_ARG(-1, double), EJIT_ARG(-1, double)) == 1);
ejit_destroy_func(f);
}
diff --git a/tests/ltr.c b/tests/ltr.c
index 85f7af0..310362c 100644
--- a/tests/ltr.c
+++ b/tests/ltr.c
@@ -17,11 +17,11 @@ int main()
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(1, long), EJIT_ARG(0, long)) == 0);
assert(ejit_run_func_2(f,
EJIT_ARG(0x0fffffffffffffff, long),
- EJIT_ARG(0x0ffffffffffffff0, long)) == 1);
+ EJIT_ARG(0x0ffffffffffffff0, long)) == 0);
assert(ejit_run_func_2(f,
EJIT_ARG(0x7fffffffffffffff, long),
diff --git a/tests/ltr_f.c b/tests/ltr_f.c
index f925c4f..20fadac 100644
--- a/tests/ltr_f.c
+++ b/tests/ltr_f.c
@@ -16,17 +16,10 @@ int main()
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(erf2(f, EJIT_ARG(1, double), EJIT_ARG(1, double)) == 0);
+ assert(erf2(f, EJIT_ARG(1, double), EJIT_ARG(0, double)) == 0);
+ assert(erf2(f, EJIT_ARG(-1, double), EJIT_ARG(0, double)) == 1);
+ assert(erf2(f, EJIT_ARG(-1, double), EJIT_ARG(-1, double)) == 0);
- 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/makefile b/tests/makefile
index 3ab921a..21f68dd 100644
--- a/tests/makefile
+++ b/tests/makefile
@@ -12,11 +12,11 @@ COMPILE_JIT_TEST := $(COMPILER) $(CFLAGS) $(INCLUDE_FLAGS)
COMPILE_BCODE_TEST := $(COMPILER) $(CFLAGS) $(INCLUDE_FLAGS) -DFORCE_BCODE=1
.PHONY: check
-check: $(BCODE_TESTS) $(JIT_TESTS)
+check: check-bcode check-jit
echo "Success!"
.PHONY: check-bcode
-check-bcode:
+check-bcode: $(BCODE_TESTS)
@echo "Running bytecode tests..."
@set -e; for test in $(BCODE_TESTS); do \
echo "Testing: $$test"; \
@@ -24,7 +24,7 @@ check-bcode:
done
.PHONY: check-jit
-check-jit:
+check-jit: $(JIT_TESTS)
@echo "Running jit tests..."
@set -e; for test in $(JIT_TESTS); do \
echo "Testing: $$test"; \
diff --git a/tests/movi.c b/tests/movi.c
index 1282b6f..9854088 100644
--- a/tests/movi.c
+++ b/tests/movi.c
@@ -1,22 +1,14 @@
-#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);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int), 0, NULL);
+ ejit_movi(f, EJIT_GPR(0), 0xa500a500);
+ ejit_retr(f, EJIT_GPR(0));
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int), do_jit);
- jit_movi(j, JIT_R0, 0xa500a500);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- jit_uword_t (*f)(void) = jit_end(j, NULL);
-
- ASSERT(f() == 0xa500a500);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func(f, 0, NULL) == 0xa500a500);
+ ejit_destroy_func(f);
}
diff --git a/tests/movi_f.c b/tests/movi_f.c
index 82e2d0a..73d22e3 100644
--- a/tests/movi_f.c
+++ b/tests/movi_f.c
@@ -1,22 +1,14 @@
-#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);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 0, NULL);
+ ejit_movi_f(f, EJIT_FPR(0), 3.14159f);
+ ejit_retr_f(f, EJIT_FPR(0));
+ ejit_select_compile_func(f, 0, 1, EJIT_USE64(double), do_jit);
- jit_movi_f(j, JIT_F0, 3.14159f);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr_f(j, JIT_F0);
-
- float (*f)(void) = jit_end(j, NULL);
-
- ASSERT(f() == 3.14159f);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_f(f, 0, NULL) == 3.14159f);
+ ejit_destroy_func(f);
}
diff --git a/tests/movr.c b/tests/movr.c
new file mode 100644
index 0000000..e9a0c9d
--- /dev/null
+++ b/tests/movr.c
@@ -0,0 +1,17 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ 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_movr(f, EJIT_GPR(1), EJIT_GPR(0));
+ ejit_retr(f, EJIT_GPR(1));
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(int), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(42, int)) == 42);
+ ejit_destroy_func(f);
+}
diff --git a/tests/movr_f.c b/tests/movr_f.c
new file mode 100644
index 0000000..8fa19a2
--- /dev/null
+++ b/tests/movr_f.c
@@ -0,0 +1,17 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 1, operands);
+ ejit_movr_f(f, EJIT_FPR(1), EJIT_FPR(0));
+ ejit_retr_f(f, EJIT_FPR(1));
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit);
+
+ assert(ejit_run_func_f_1(f, EJIT_ARG(42., double)) == 42.);
+ ejit_destroy_func(f);
+}
diff --git a/tests/mulr.c b/tests/mulr.c
deleted file mode 100644
index 3f0a6f8..0000000
--- a/tests/mulr.c
+++ /dev/null
@@ -1,64 +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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
-
- jit_mulr(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t, jit_word_t) = ret;
-
- ASSERT(f(0x7fffffff, 1) == 0x7fffffff);
- ASSERT(f(1, 0x7fffffff) == 0x7fffffff);
- ASSERT(f(0x80000000, 1) == 0x80000000);
- ASSERT(f(1, 0x80000000) == 0x80000000);
- ASSERT(f(0x7fffffff, 2) == 0xfffffffe);
- ASSERT(f(2, 0x7fffffff) == 0xfffffffe);
- ASSERT(f(0x7fffffff, 0) == 0);
- ASSERT(f(0, 0x7fffffff) == 0);
-#if EJIT_WORDSIZE == 32
- ASSERT(f(0x80000000, 2) == 0);
- ASSERT(f(2, 0x80000000) == 0);
- ASSERT(f(0x7fffffff, 0x80000000) == 0x80000000);
- ASSERT(f(0x80000000, 0x7fffffff) == 0x80000000);
- ASSERT(f(0x7fffffff, 0xffffffff) == 0x80000001);
- ASSERT(f(0xffffffff, 0x7fffffff) == 0x80000001);
- ASSERT(f(0xffffffff, 0xffffffff) == 1);
-#else
- ASSERT(f(0x80000000, 2) == 0x100000000);
- ASSERT(f(2, 0x80000000) == 0x100000000);
- ASSERT(f(0x7fffffff, 0x80000000) == 0x3fffffff80000000);
- ASSERT(f(0x80000000, 0x7fffffff) == 0x3fffffff80000000);
- ASSERT(f(0x7fffffff, 0xffffffff) == 0x7ffffffe80000001);
- ASSERT(f(0xffffffff, 0x7fffffff) == 0x7ffffffe80000001);
- ASSERT(f(0xffffffff, 0xffffffff) == 0xfffffffe00000001);
- ASSERT(f(0x7fffffffffffffff, 1) == 0x7fffffffffffffff);
- ASSERT(f(1, 0x7fffffffffffffff) == 0x7fffffffffffffff);
- ASSERT(f(0x8000000000000000, 1) == 0x8000000000000000);
- ASSERT(f(1, 0x8000000000000000) == 0x8000000000000000);
- ASSERT(f(0x7fffffffffffffff, 2) == 0xfffffffffffffffe);
- ASSERT(f(2, 0x7fffffffffffffff) == 0xfffffffffffffffe);
- ASSERT(f(0x8000000000000000, 2) == 0);
- ASSERT(f(2, 0x8000000000000000) == 0);
- ASSERT(f(0x7fffffffffffffff, 0x8000000000000000) == 0x8000000000000000);
- ASSERT(f(0x8000000000000000, 0x7fffffffffffffff) == 0x8000000000000000);
- ASSERT(f(0x7fffffffffffffff, 0xffffffffffffffff) == 0x8000000000000001);
- ASSERT(f(0xffffffffffffffff, 0x7fffffffffffffff) == 0x8000000000000001);
- ASSERT(f(0xffffffffffffffff, 0xffffffffffffffff) == 1);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/mulr64.c b/tests/mulr64.c
new file mode 100644
index 0000000..4b51745
--- /dev/null
+++ b/tests/mulr64.c
@@ -0,0 +1,122 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_mulr(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(int64_t), do_jit);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t), EJIT_ARG(0x7fffffff, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t), EJIT_ARG(0x80000000, int64_t)
+ ) == 0x80000000);
+
+ assert(erf2(f, EJIT_ARG(2, int64_t), EJIT_ARG(0x7fffffff, int64_t)
+ ) == 0xfffffffe);
+
+ assert(erf2(f, EJIT_ARG(0, int64_t), EJIT_ARG(0x7fffffff, int64_t)
+ ) == 0);
+
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t), EJIT_ARG(1, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t), EJIT_ARG(1, int64_t)
+ ) == 0x80000000);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t), EJIT_ARG(2, int64_t)
+ ) == 0xfffffffe);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t), EJIT_ARG(0, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(2, int64_t), EJIT_ARG(0x80000000, int64_t)
+ ) == 0x100000000);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == 0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0x8000000000000000);
+
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0xfffffffffffffffe);
+
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t), EJIT_ARG(2, int64_t)
+ ) == (int64_t)0x100000000);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0x80000000, int64_t)
+ ) == (int64_t)0x3fffffff80000000);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == (int64_t)0x3fffffff80000000);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == (int64_t)0x7ffffffe80000001);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == (int64_t)0x7ffffffe80000001);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == (int64_t)0xfffffffe00000001);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(1, int64_t)
+ ) == (int64_t)0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(1, int64_t)
+ ) == (int64_t)0x8000000000000000);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(2, int64_t)
+ ) == (int64_t)0xfffffffffffffffe);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(2, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0x8000000000000000);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0x8000000000000000);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == 1);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/mulr_f.c b/tests/mulr_f.c
index 5e5f46a..44d6030 100644
--- a/tests/mulr_f.c
+++ b/tests/mulr_f.c
@@ -1,27 +1,24 @@
-#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_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))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 2, operands);
- jit_mulr_f(j, JIT_F0, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr_f(j, JIT_F0);
+ ejit_mulr_f(f, EJIT_FPR(0), EJIT_FPR(0), EJIT_FPR(1));
+ ejit_retr_f(f, EJIT_FPR(0));
- size_t size = 0;
- void* ret = jit_end(j, &size);
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit);
- float (*f)(float, float) = ret;
- ASSERT(f(-0.5f, 0.5f) == -0.25f);
- ASSERT(f(0.25f, 0.75f) == 0.1875f);
-}
+ assert(erff2(f, EJIT_ARG(-0.5f, double),
+ EJIT_ARG(0.50f, double)) == -0.25f);
+ assert(erff2(f, EJIT_ARG(0.25f, double),
+ EJIT_ARG(0.75f, double)) == 0.1875f);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/negr.c b/tests/negr.c
index db65f3c..4e3b34c 100644
--- a/tests/negr.c
+++ b/tests/negr.c
@@ -1,39 +1,39 @@
-#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(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 1, operands);
- jit_negr(j, JIT_R0, JIT_R0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
+ ejit_negr(f, EJIT_GPR(0), EJIT_GPR(0));
+ ejit_retr(f, EJIT_GPR(0));
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int64_t), do_jit);
- ASSERT(f(0) == 0);
-#if EJIT_WORDSIZE == 32
- ASSERT(f(1) == 0xffffffff);
- ASSERT(f(0xffffffff) == 1);
- ASSERT(f(0x80000000) == 0x80000000);
- ASSERT(f(0x7fffffff) == 0x80000001);
- ASSERT(f(0x80000001) == 0x7fffffff);
-#else
- ASSERT(f(1) == 0xffffffffffffffff);
- ASSERT(f(0xffffffff) == 0xffffffff00000001);
- ASSERT(f(0x80000000) == 0xffffffff80000000);
- ASSERT(f(0x7fffffff) == 0xffffffff80000001);
- ASSERT(f(0x80000001) == 0xffffffff7fffffff);
- ASSERT(f(0xffffffffffffffff) == 1);
- ASSERT(f(0x8000000000000000) == 0x8000000000000000);
- ASSERT(f(0x7fffffffffffffff) == 0x8000000000000001);
-#endif
-}
+ assert(erf1(f, EJIT_ARG(0, int64_t)) == 0);
+ assert(erf1(f, EJIT_ARG(1, int64_t)) == (int64_t)0xffffffffffffffff);
+ assert(erf1(f,
+ EJIT_ARG(0xffffffff,
+ int64_t)) == (int64_t)0xffffffff00000001);
+ assert(erf1(f,
+ EJIT_ARG(0x80000000,
+ int64_t)) == (int64_t)0xffffffff80000000);
+ assert(erf1(f,
+ EJIT_ARG(0x7fffffff,
+ int64_t)) == (int64_t)0xffffffff80000001);
+ assert(erf1(f,
+ EJIT_ARG(0x80000001,
+ int64_t)) == (int64_t)0xffffffff7fffffff);
+ assert(erf1(f, EJIT_ARG(0xffffffffffffffff, int64_t)) == 1);
+ assert(erf1(f, EJIT_ARG(0x8000000000000000, int64_t))
+ == (int64_t)0x8000000000000000);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(erf1(f, EJIT_ARG(0x7fffffffffffffff, int64_t))
+ == (int64_t)0x8000000000000001);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/negr_f.c b/tests/negr_f.c
index 08b6364..d6fee7b 100644
--- a/tests/negr_f.c
+++ b/tests/negr_f.c
@@ -1,26 +1,23 @@
-#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_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 1, operands);
- jit_negr_f(j, JIT_F0, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr_f(j, JIT_F0);
+ ejit_negr_f(f, EJIT_FPR(0), EJIT_FPR(0));
+ ejit_retr_f(f, EJIT_FPR(0));
- float (*f)(float) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 0, 1, EJIT_USE64(double), do_jit);
- ASSERT(f(0.0f) == -0.0f);
- ASSERT(f(0.5f) == -0.5f);
- ASSERT(f(1.0f / 0.0f) == -1.0f / 0.0f);
- ASSERT(f(-1.25f) == 1.25f);
-}
+ assert(erff1(f, EJIT_ARG(0.0f, double)) == -0.0f);
+ assert(erff1(f, EJIT_ARG(0.5f, double)) == -0.5f);
+ assert(erff1(f, EJIT_ARG(1.0f / 0.0f, double)) == -1.0f / 0.0f);
+ assert(erff1(f, EJIT_ARG(-1.25f, double)) == 1.25f);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/ner.c b/tests/ner.c
index ca615d0..b83ccf3 100644
--- a/tests/ner.c
+++ b/tests/ner.c
@@ -5,7 +5,7 @@
int main()
{
struct ejit_operand operands[2] = {
- EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
};
diff --git a/tests/ner_f.c b/tests/ner_f.c
new file mode 100644
index 0000000..73bab90
--- /dev/null
+++ b/tests/ner_f.c
@@ -0,0 +1,25 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#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_ner_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);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/ori.c b/tests/ori.c
deleted file mode 100644
index 27f7b2c..0000000
--- a/tests/ori.c
+++ /dev/null
@@ -1,31 +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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
-
- jit_ori(j, JIT_R0, JIT_R0, 1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t) = ret;
-
- ASSERT(f(0x7fffffff) == 0x7fffffff);
- ASSERT(f(0x80000000) == 0x80000001);
-#if EJIT_WORDSIZE == 64
- ASSERT(f(0x7fffffffffffffff) == 0x7fffffffffffffff);
- ASSERT(f(0x8000000000000000) == 0x8000000000000001);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/ori64.c b/tests/ori64.c
new file mode 100644
index 0000000..352923e
--- /dev/null
+++ b/tests/ori64.c
@@ -0,0 +1,26 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 1, operands);
+
+ ejit_ori(f, EJIT_GPR(0), EJIT_GPR(0), 1);
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int64_t), do_jit);
+
+ assert(erf1(f, EJIT_ARG(0x7fffffff, int64_t)) == 0x7fffffff);
+ assert(erf1(f, EJIT_ARG(0x80000000, int64_t)) == 0x80000001);
+ assert(erf1(f, EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == 0x7fffffffffffffff);
+
+ assert(erf1(f, EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/orr.c b/tests/orr.c
deleted file mode 100644
index af8e141..0000000
--- a/tests/orr.c
+++ /dev/null
@@ -1,48 +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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
-
- jit_orr(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t, jit_word_t) = ret;
-
- ASSERT(f(0x7fffffff, 1) == 0x7fffffff);
- ASSERT(f(1, 0x7fffffff) == 0x7fffffff);
- ASSERT(f(0x80000000, 1) == 0x80000001);
- ASSERT(f(1, 0x80000000) == 0x80000001);
- ASSERT(f(0x7fffffff, 0x80000000) == 0xffffffff);
- ASSERT(f(0x80000000, 0x7fffffff) == 0xffffffff);
- ASSERT(f(0x7fffffff, 0xffffffff) == 0xffffffff);
- ASSERT(f(0xffffffff, 0x7fffffff) == 0xffffffff);
- ASSERT(f(0xffffffff, 0xffffffff) == 0xffffffff);
- ASSERT(f(0x7fffffff, 0) == 0x7fffffff);
- ASSERT(f(0, 0x7fffffff) == 0x7fffffff);
-#if EJIT_WORDSIZE == 64
- ASSERT(f(0x7fffffffffffffff, 1) == 0x7fffffffffffffff);
- ASSERT(f(1, 0x7fffffffffffffff) == 0x7fffffffffffffff);
- ASSERT(f(0x8000000000000000, 1) == 0x8000000000000001);
- ASSERT(f(1, 0x8000000000000000) == 0x8000000000000001);
- ASSERT(f(0x7fffffffffffffff, 0x8000000000000000) == 0xffffffffffffffff);
- ASSERT(f(0x8000000000000000, 0x7fffffffffffffff) == 0xffffffffffffffff);
- ASSERT(f(0x7fffffffffffffff, 0xffffffffffffffff) == 0xffffffffffffffff);
- ASSERT(f(0xffffffffffffffff, 0x7fffffffffffffff) == 0xffffffffffffffff);
- ASSERT(f(0xffffffffffffffff, 0xffffffffffffffff) == 0xffffffffffffffff);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/orr64.c b/tests/orr64.c
new file mode 100644
index 0000000..d113cec
--- /dev/null
+++ b/tests/orr64.c
@@ -0,0 +1,86 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_orr(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(int64_t), do_jit);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 0x80000001);
+
+ assert(erf2(f, EJIT_ARG(0, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x80000001);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0, int64_t)) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(1, int64_t)) == (int64_t)0x8000000000000001);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/remr.c b/tests/remr.c
deleted file mode 100644
index cd5bf4f..0000000
--- a/tests/remr.c
+++ /dev/null
@@ -1,60 +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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
-
- jit_remr(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t, jit_word_t) = ret;
-
- ASSERT(f(0x7fffffff, 1) == 0);
- ASSERT(f(1, 0x7fffffff) == 1);
- ASSERT(f(0x80000000, 1) == 0);
- ASSERT(f(1, 0x80000000) == 1);
- ASSERT(f(0x7fffffff, 2) == 1);
- ASSERT(f(2, 0x7fffffff) == 2);
- ASSERT(f(0x80000000, 2) == 0);
- ASSERT(f(2, 0x80000000) == 2);
- ASSERT(f(0x7fffffff, 0x80000000) == 0x7fffffff);
- ASSERT(f(0, 0x7fffffff) == 0);
- ASSERT(f(0xffffffff, 0xffffffff) == 0);
-
-#if EJIT_WORDSIZE == 32
- ASSERT(f(0x80000000, 0x7fffffff) == 0xffffffff);
- ASSERT(f(0x7fffffff, 0xffffffff) == 0);
- ASSERT(f(0xffffffff, 0x7fffffff) == 0xffffffff);
-#else
- ASSERT(f(0x80000000, 0x7fffffff) == 1);
- ASSERT(f(0x7fffffff, 0xffffffff) == 0x7fffffff);
- ASSERT(f(0xffffffff, 0x7fffffff) == 1);
- ASSERT(f(0x7fffffffffffffff, 1) == 0);
- ASSERT(f(1, 0x7fffffffffffffff) == 1);
- ASSERT(f(0x8000000000000000, 1) == 0);
- ASSERT(f(1, 0x8000000000000000) == 1);
- ASSERT(f(0x7fffffffffffffff, 2) == 1);
- ASSERT(f(2, 0x7fffffffffffffff) == 2);
- ASSERT(f(0x8000000000000000, 2) == 0);
- ASSERT(f(2, 0x8000000000000000) == 2);
- ASSERT(f(0x7fffffffffffffff, 0x8000000000000000) == 0x7fffffffffffffff);
- ASSERT(f(0x8000000000000000, 0x7fffffffffffffff) == 0xffffffffffffffff);
- ASSERT(f(0x7fffffffffffffff, 0xffffffffffffffff) == 0);
- ASSERT(f(0xffffffffffffffff, 0x7fffffffffffffff) == 0xffffffffffffffff);
- ASSERT(f(0xffffffffffffffff, 0xffffffffffffffff) == 0);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/remr64.c b/tests/remr64.c
new file mode 100644
index 0000000..c9c97aa
--- /dev/null
+++ b/tests/remr64.c
@@ -0,0 +1,100 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_remr(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(int64_t), do_jit);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 2);
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 2);
+ assert(erf2(f, EJIT_ARG(0, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(2, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(2, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0x80000000, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)) == 1);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)) == 1);
+
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)) == 2);
+
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)) == 2);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(2, int64_t)) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(2, int64_t)) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == 0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == 0);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/remr_u.c b/tests/remr_u.c
deleted file mode 100644
index ba015c1..0000000
--- a/tests/remr_u.c
+++ /dev/null
@@ -1,56 +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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
-
- jit_remr_u(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t, jit_word_t) = ret;
-
- ASSERT(f(0x7fffffff, 1) == 0);
- ASSERT(f(1, 0x7fffffff) == 1);
- ASSERT(f(0x80000000, 1) == 0);
- ASSERT(f(1, 0x80000000) == 1);
- ASSERT(f(0x7fffffff, 2) == 1);
- ASSERT(f(2, 0x7fffffff) == 2);
- ASSERT(f(0x80000000, 2) == 0);
- ASSERT(f(2, 0x80000000) == 2);
- ASSERT(f(0x7fffffff, 0x80000000) == 0x7fffffff);
- ASSERT(f(0x80000000, 0x7fffffff) == 1);
- ASSERT(f(0, 0x7fffffff) == 0);
- ASSERT(f(0x7fffffff, 0xffffffff) == 0x7fffffff);
- ASSERT(f(0xffffffff, 0x7fffffff) == 1);
- ASSERT(f(0xffffffff, 0xffffffff) == 0);
-
-#if EJIT_WORDSIZE != 32
- ASSERT(f(0x7fffffffffffffff, 1) == 0);
- ASSERT(f(1, 0x7fffffffffffffff) == 1);
- ASSERT(f(0x8000000000000000, 1) == 0);
- ASSERT(f(1, 0x8000000000000000) == 1);
- ASSERT(f(0x7fffffffffffffff, 2) == 1);
- ASSERT(f(2, 0x7fffffffffffffff) == 2);
- ASSERT(f(0x8000000000000000, 2) == 0);
- ASSERT(f(2, 0x8000000000000000) == 2);
- ASSERT(f(0x7fffffffffffffff, 0x8000000000000000) == 0x7fffffffffffffff);
- ASSERT(f(0x8000000000000000, 0x7fffffffffffffff) == 1);
- ASSERT(f(0x7fffffffffffffff, 0xffffffffffffffff) == 0x7fffffffffffffff);
- ASSERT(f(0xffffffffffffffff, 0x7fffffffffffffff) == 1);
- ASSERT(f(0xffffffffffffffff, 0xffffffffffffffff) == 0);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/remr_u64.c b/tests/remr_u64.c
new file mode 100644
index 0000000..c414ef7
--- /dev/null
+++ b/tests/remr_u64.c
@@ -0,0 +1,95 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_remr_u(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(int64_t), do_jit);
+
+ assert(erf2(f, EJIT_ARG(0, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 2);
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 2);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(2, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(2, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0x80000000, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == 0);
+
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)) == 2);
+ assert(erf2(f, EJIT_ARG(2, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)) == 2);
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(2, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(2, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == 0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == 0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == 0);
+
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/rshi.c b/tests/rshi.c
deleted file mode 100644
index ab5438a..0000000
--- a/tests/rshi.c
+++ /dev/null
@@ -1,28 +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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
-
- jit_rshi(j, JIT_R0, JIT_R0, 31);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
-
-#if EJIT_WORDSIZE == 32
- ASSERT(f(0x80000000) == -1);
-#else
- ASSERT(f(0x80000000) == 1);
- ASSERT(f(0x8000000000000000) == 0xffffffff00000000);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/rshi64.c b/tests/rshi64.c
new file mode 100644
index 0000000..b5279e9
--- /dev/null
+++ b/tests/rshi64.c
@@ -0,0 +1,22 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 1, operands);
+
+ ejit_rshi(f, EJIT_GPR(0), EJIT_GPR(0), 31);
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int64_t), do_jit);
+
+ assert(erf1(f, EJIT_ARG(0x80000000, int64_t)) == 1);
+ assert(erf1(f, EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0xffffffff00000000);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/rshi_u.c b/tests/rshi_u.c
deleted file mode 100644
index aa02206..0000000
--- a/tests/rshi_u.c
+++ /dev/null
@@ -1,28 +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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
-
- jit_rshi_u(j, JIT_R0, JIT_R0, 31);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
-
-#if EJIT_WORDSIZE == 32
- ASSERT(f(0x80000000) == 1);
-#else
- ASSERT(f(0x80000000) == 1);
- ASSERT(f(0x8000000000000000) == 0x100000000);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/rshi_u64.c b/tests/rshi_u64.c
new file mode 100644
index 0000000..4b6d5a9
--- /dev/null
+++ b/tests/rshi_u64.c
@@ -0,0 +1,21 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 1, operands);
+
+ ejit_rshi_u(f, EJIT_GPR(0), EJIT_GPR(0), 31);
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int64_t), do_jit);
+
+ assert(erf1(f, EJIT_ARG(0x80000000, int64_t)) == 1);
+ assert(erf1(f, EJIT_ARG(0x8000000000000000, int64_t)) == 0x100000000);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/rshr.c b/tests/rshr.c
deleted file mode 100644
index d14f64f..0000000
--- a/tests/rshr.c
+++ /dev/null
@@ -1,63 +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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
-
- jit_rshr(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t, jit_word_t) = ret;
-
- ASSERT(f(0xfe, 1) == 0x7f);
- ASSERT(f(0x1fffc, 2) == 0x7fff);
- ASSERT(f(0x40000000, 30) == 1);
- ASSERT(f(0x20000000, 29) == 1);
- ASSERT(f(0x10000000, 28) == 1);
- ASSERT(f(0x810000, 16) == 0x81);
- ASSERT(f(0x20000, 17) == 1);
- ASSERT(f(0x40000, 18) == 1);
- ASSERT(f(0x7f8000, 15) == 0xff);
- ASSERT(f(0x1000000, 24) == 1);
- ASSERT(f(0x7fffffff, 0) == 0x7fffffff);
-#if EJIT_WORDSIZE == 32
- ASSERT(f(0xfffffff8, 3) == 0xffffffff);
- ASSERT(f(0x80000000, 31) == 0xffffffff);
- ASSERT(f(0xffffff00, 8) == 0xffffffff);
-#else
- ASSERT(f(0x3fffffff8, 3) == 0x7fffffff);
- ASSERT(f(0xffffffc080000000, 31) == 0xffffffffffffff81);
- ASSERT(f(0xffffff00, 8) == 0xffffff);
- ASSERT(f(0xfe00000000, 33) == 0x7f);
- ASSERT(f(0x1ffffc00000000, 34) == 0x7ffff);
- ASSERT(f(0xfffffff800000000, 29) == 0xffffffffffffffc0);
- ASSERT(f(0x8000000000000000, 63) == 0xffffffffffffffff);
- ASSERT(f(0x4000000000000000, 62) == 1);
- ASSERT(f(0x2000000000000000, 61) == 1);
- ASSERT(f(0x1000000000000000, 60) == 1);
- ASSERT(f(0x81000000000000, 48) == 0x81);
- ASSERT(f(0x2000000000000, 49) == 1);
- ASSERT(f(0x10000000000, 40) == 1);
- ASSERT(f(0x7f800000000000, 47) == 0xff);
- ASSERT(f(0x100000000000000, 56) == 1);
- ASSERT(f(0xffffff0000000000, 40) == 0xffffffffffffffff);
- ASSERT(f(0xfffffffe00000000, 33) == 0xffffffffffffffff);
- ASSERT(f(0x8000000000000001, 63) == 0xffffffffffffffff);
- ASSERT(f(0x1000000000000, 48) == 1);
- ASSERT(f(0xffff800000000000, 47) == 0xffffffffffffffff);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/rshr64.c b/tests/rshr64.c
new file mode 100644
index 0000000..03cfae7
--- /dev/null
+++ b/tests/rshr64.c
@@ -0,0 +1,115 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_rshr(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(int64_t), do_jit);
+
+ assert(erf2(f, EJIT_ARG(0xfe, int64_t), EJIT_ARG(1, int64_t)) == 0x7f);
+ assert(erf2(f, EJIT_ARG(0x1fffc, int64_t),
+ EJIT_ARG(2, int64_t)) == 0x7fff);
+ assert(erf2(f, EJIT_ARG(0x40000000, int64_t),
+ EJIT_ARG(30, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x20000000, int64_t),
+ EJIT_ARG(29, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x10000000, int64_t),
+ EJIT_ARG(28, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x810000, int64_t),
+ EJIT_ARG(16, int64_t)) == 0x81);
+ assert(erf2(f, EJIT_ARG(0x20000, int64_t), EJIT_ARG(17, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x40000, int64_t), EJIT_ARG(18, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x7f8000, int64_t),
+ EJIT_ARG(15, int64_t)) == 0xff);
+ assert(erf2(f, EJIT_ARG(0x1000000, int64_t),
+ EJIT_ARG(24, int64_t)) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t), EJIT_ARG(0, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0x3fffffff8, int64_t), EJIT_ARG(3, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffff00, int64_t), EJIT_ARG(8, int64_t)
+ ) == 0xffffff);
+
+ assert(erf2(f, EJIT_ARG(0xfe00000000, int64_t), EJIT_ARG(33, int64_t)
+ ) == 0x7f);
+
+ assert(erf2(f, EJIT_ARG(0x1ffffc00000000, int64_t),
+ EJIT_ARG(34, int64_t)
+ ) == 0x7ffff);
+
+ assert(erf2(f, EJIT_ARG(0xfffffff800000000, int64_t),
+ EJIT_ARG(29, int64_t)
+ ) == (int64_t)0xffffffffffffffc0);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(63, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x4000000000000000, int64_t),
+ EJIT_ARG(62, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x2000000000000000, int64_t),
+ EJIT_ARG(61, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x1000000000000000, int64_t),
+ EJIT_ARG(60, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0xffffffc080000000, int64_t),
+ EJIT_ARG(31, int64_t)
+ ) == (int64_t)0xffffffffffffff81);
+
+ assert(erf2(f, EJIT_ARG(0x81000000000000, int64_t),
+ EJIT_ARG(48, int64_t)
+ ) == 0x81);
+
+ assert(erf2(f, EJIT_ARG(0x2000000000000, int64_t), EJIT_ARG(49, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x10000000000, int64_t), EJIT_ARG(40, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x7f800000000000, int64_t),
+ EJIT_ARG(47, int64_t)
+ ) == 0xff);
+
+ assert(erf2(f, EJIT_ARG(0x100000000000000, int64_t),
+ EJIT_ARG(56, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0xffffff0000000000, int64_t),
+ EJIT_ARG(40, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xfffffffe00000000, int64_t),
+ EJIT_ARG(33, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000001, int64_t),
+ EJIT_ARG(63, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x1000000000000, int64_t), EJIT_ARG(48, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0xffff800000000000, int64_t),
+ EJIT_ARG(47, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/rshr_u.c b/tests/rshr_u.c
deleted file mode 100644
index 082b9ed..0000000
--- a/tests/rshr_u.c
+++ /dev/null
@@ -1,62 +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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
-
- jit_rshr_u(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t, jit_word_t) = ret;
-
- ASSERT(f(0xfe, 1) == 0x7f);
- ASSERT(f(0x1fffc, 2) == 0x7fff);
- ASSERT(f(0x80000000, 31) == 1);
- ASSERT(f(0x40000000, 30) == 1);
- ASSERT(f(0x20000000, 29) == 1);
- ASSERT(f(0x10000000, 28) == 1);
- ASSERT(f(0x810000, 16) == 0x81);
- ASSERT(f(0x20000, 17) == 1);
- ASSERT(f(0x40000, 18) == 1);
- ASSERT(f(0x7f8000, 15) == 0xff);
- ASSERT(f(0x1000000, 24) == 1);
- ASSERT(f(0xffffff00, 8) == 0xffffff);
- ASSERT(f(0x7fffffff, 0) == 0x7fffffff);
-#if EJIT_WORDSIZE == 32
- ASSERT(f(0xfffffff8, 3) == 0x1fffffff);
-#else
- ASSERT(f(0x3fffffff8, 3) == 0x7fffffff);
- ASSERT(f(0xffffffc080000000, 31) == 0x1ffffff81);
- ASSERT(f(0xfe00000000, 33) == 0x7f);
- ASSERT(f(0x1ffffc00000000, 34) == 0x7ffff);
- ASSERT(f(0xfffffff800000000, 29) == 0x7ffffffc0);
- ASSERT(f(0x8000000000000000, 63) == 1);
- ASSERT(f(0x4000000000000000, 62) == 1);
- ASSERT(f(0x2000000000000000, 61) == 1);
- ASSERT(f(0x1000000000000000, 60) == 1);
- ASSERT(f(0x81000000000000, 48) == 0x81);
- ASSERT(f(0x2000000000000, 49) == 1);
- ASSERT(f(0x10000000000, 40) == 1);
- ASSERT(f(0x7f800000000000, 47) == 0xff);
- ASSERT(f(0x100000000000000, 56) == 1);
- ASSERT(f(0xffffff0000000000, 40) == 0xffffff);
- ASSERT(f(0xfffffffe00000000, 33) == 0x7fffffff);
- ASSERT(f(0x8000000000000001, 63) == 1);
- ASSERT(f(0x1000000000000, 48) == 1);
- ASSERT(f(0xffff800000000000, 47) == 0x1ffff);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/rshr_u64.c b/tests/rshr_u64.c
new file mode 100644
index 0000000..86ce416
--- /dev/null
+++ b/tests/rshr_u64.c
@@ -0,0 +1,113 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_rshr_u(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(int64_t), do_jit);
+
+ assert(erf2(f, EJIT_ARG(0xfe, int64_t), EJIT_ARG(1, int64_t)) == 0x7f);
+ assert(erf2(f, EJIT_ARG(0x1fffc, int64_t),
+ EJIT_ARG(2, int64_t)) == 0x7fff);
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(31, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x40000000, int64_t),
+ EJIT_ARG(30, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x20000000, int64_t),
+ EJIT_ARG(29, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x10000000, int64_t),
+ EJIT_ARG(28, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x810000, int64_t),
+ EJIT_ARG(16, int64_t)) == 0x81);
+ assert(erf2(f, EJIT_ARG(0x20000, int64_t), EJIT_ARG(17, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x40000, int64_t), EJIT_ARG(18, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x7f8000, int64_t),
+ EJIT_ARG(15, int64_t)) == 0xff);
+ assert(erf2(f, EJIT_ARG(0x1000000, int64_t),
+ EJIT_ARG(24, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0xffffff00, int64_t),
+ EJIT_ARG(8, int64_t)) == 0xffffff);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0, int64_t)) == 0x7fffffff);
+ assert(erf2(f, EJIT_ARG(0x3fffffff8, int64_t), EJIT_ARG(3, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffc080000000, int64_t),
+ EJIT_ARG(31, int64_t)
+ ) == 0x1ffffff81);
+
+ assert(erf2(f, EJIT_ARG(0xfe00000000, int64_t), EJIT_ARG(33, int64_t)
+ ) == 0x7f);
+
+ assert(erf2(f, EJIT_ARG(0x1ffffc00000000, int64_t),
+ EJIT_ARG(34, int64_t)
+ ) == 0x7ffff);
+
+ assert(erf2(f, EJIT_ARG(0xfffffff800000000, int64_t),
+ EJIT_ARG(29, int64_t)
+ ) == 0x7ffffffc0);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(63, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x4000000000000000, int64_t),
+ EJIT_ARG(62, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x2000000000000000, int64_t),
+ EJIT_ARG(61, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x1000000000000000, int64_t),
+ EJIT_ARG(60, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x81000000000000, int64_t),
+ EJIT_ARG(48, int64_t)
+ ) == 0x81);
+
+ assert(erf2(f, EJIT_ARG(0x2000000000000, int64_t), EJIT_ARG(49, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x10000000000, int64_t), EJIT_ARG(40, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x7f800000000000, int64_t),
+ EJIT_ARG(47, int64_t)
+ ) == 0xff);
+
+ assert(erf2(f, EJIT_ARG(0x100000000000000, int64_t),
+ EJIT_ARG(56, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0xffffff0000000000, int64_t),
+ EJIT_ARG(40, int64_t)
+ ) == 0xffffff);
+
+ assert(erf2(f, EJIT_ARG(0xfffffffe00000000, int64_t),
+ EJIT_ARG(33, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000001, int64_t),
+ EJIT_ARG(63, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x1000000000000, int64_t), EJIT_ARG(48, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0xffff800000000000, int64_t),
+ EJIT_ARG(47, int64_t)
+ ) == 0x1ffff);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/sti_16.c b/tests/sti_16.c
new file mode 100644
index 0000000..f2edbea
--- /dev/null
+++ b/tests/sti_16.c
@@ -0,0 +1,28 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint16_t data[] = { 0x1212, 0x0000, 0x3434 };
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int16_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 1, operands);
+
+ ejit_sti_16(f, EJIT_GPR(0), &data[1]);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int16_t), do_jit);
+
+ assert(data[0] == 0x1212);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x3434);
+ erf1(f, EJIT_ARG(-1, int16_t));
+ assert(data[0] == 0x1212);
+ assert(data[1] == 0xffff);
+ assert(data[2] == 0x3434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/sti_32.c b/tests/sti_32.c
new file mode 100644
index 0000000..12b2d7c
--- /dev/null
+++ b/tests/sti_32.c
@@ -0,0 +1,28 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint32_t data[] = { 0x12121212, 0x00000000, 0x34343434 };
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int32_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 1, operands);
+
+ ejit_sti_32(f, EJIT_GPR(0), &data[1]);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int32_t), do_jit);
+
+ assert(data[0] == 0x12121212);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x34343434);
+ erf1(f, EJIT_ARG(-1, int32_t));
+ assert(data[0] == 0x12121212);
+ assert(data[1] == 0xffffffff);
+ assert(data[2] == 0x34343434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/sti_64.c b/tests/sti_64.c
new file mode 100644
index 0000000..8985d2d
--- /dev/null
+++ b/tests/sti_64.c
@@ -0,0 +1,28 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 1, operands);
+
+ ejit_sti_64(f, EJIT_GPR(0), &data[1]);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int64_t), do_jit);
+
+ assert(data[0] == 0x1212121212121212);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x3434343434343434);
+ erf1(f, EJIT_ARG(-1, int64_t));
+ assert(data[0] == 0x1212121212121212);
+ assert(data[1] == 0xffffffffffffffff);
+ assert(data[2] == 0x3434343434343434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/sti_8.c b/tests/sti_8.c
new file mode 100644
index 0000000..5603c35
--- /dev/null
+++ b/tests/sti_8.c
@@ -0,0 +1,28 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint8_t data[] = { 0x12, 0x00, 0x34 };
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int8_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 1, operands);
+
+ ejit_sti_8(f, EJIT_GPR(0), &data[1]);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int8_t), do_jit);
+
+ assert(data[0] == 0x12);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x34);
+ erf1(f, EJIT_ARG(-1, int8_t));
+ assert(data[0] == 0x12);
+ assert(data[1] == 0xff);
+ assert(data[2] == 0x34);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/sti_c.c b/tests/sti_c.c
deleted file mode 100644
index e323b37..0000000
--- a/tests/sti_c.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "test.h"
-
-static uint8_t data[] = { 0x12, 0x00, 0x34 };
-
-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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_INT8, JIT_R1));
-
- jit_sti_c(j, &data[1], JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(int8_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34);
- f(-1);
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0xff);
- ASSERT(data[2] == 0x34);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/sti_d.c b/tests/sti_d.c
index 9fce200..157e24d 100644
--- a/tests/sti_d.c
+++ b/tests/sti_d.c
@@ -1,31 +1,28 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
static double data[] = { -1.0, 0.0, 0.5 };
-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_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 1, operands);
- jit_sti_d(j, &data[1], JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
+ ejit_sti_d(f, EJIT_FPR(0), &data[1]);
+ ejit_ret(f);
- void (*f)(double) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 0, 1, EJIT_USE64(double), do_jit);
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 0.0);
- ASSERT(data[2] == 0.5);
- f(42.5);
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 42.5);
- ASSERT(data[2] == 0.5);
-}
+ assert(data[0] == -1.0);
+ assert(data[1] == 0.0);
+ assert(data[2] == 0.5);
+ erf1(f, EJIT_ARG(42.5, double));
+ assert(data[0] == -1.0);
+ assert(data[1] == 42.5);
+ assert(data[2] == 0.5);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/sti_f.c b/tests/sti_f.c
index 67a0c38..6292353 100644
--- a/tests/sti_f.c
+++ b/tests/sti_f.c
@@ -1,31 +1,28 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
static float data[] = { -1.0, 0.0, 0.5 };
-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_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(float))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 1, operands);
- jit_sti_f(j, &data[1], JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
+ ejit_sti_f(f, EJIT_FPR(0), &data[1]);
+ ejit_ret(f);
- void (*f)(float) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 0, 1, EJIT_USE64(float), do_jit);
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 0.0f);
- ASSERT(data[2] == 0.5f);
- f(42.5f);
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 42.5f);
- ASSERT(data[2] == 0.5f);
-}
+ assert(data[0] == -1.0);
+ assert(data[1] == 0.0);
+ assert(data[2] == 0.5);
+ erf1(f, EJIT_ARG(42.5, float));
+ assert(data[0] == -1.0);
+ assert(data[1] == 42.5);
+ assert(data[2] == 0.5);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/sti_i.c b/tests/sti_i.c
deleted file mode 100644
index 1f014fd..0000000
--- a/tests/sti_i.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "test.h"
-
-static uint32_t data[] = { 0x12121212, 0x00000000, 0x34343434 };
-
-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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_INT32, JIT_R1));
-
- jit_sti_i(j, &data[1], JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(int32_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34343434);
- f(-1);
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0xffffffff);
- ASSERT(data[2] == 0x34343434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/sti_l.c b/tests/sti_l.c
deleted file mode 100644
index 36cca18..0000000
--- a/tests/sti_l.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
-#if EJIT_WORDSIZE > 32
- static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
-
- 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_INT64, JIT_R1));
-
- jit_sti_l(j, &data[1], JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(int64_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x3434343434343434);
- f(-1);
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0xffffffffffffffff);
- ASSERT(data[2] == 0x3434343434343434);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/sti_s.c b/tests/sti_s.c
deleted file mode 100644
index 00941ea..0000000
--- a/tests/sti_s.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "test.h"
-
-static uint16_t data[] = { 0x1212, 0x0000, 0x3434 };
-
-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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_INT16, JIT_R1));
-
- jit_sti_s(j, &data[1], JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(int16_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0);
- ASSERT(data[2] == 0x3434);
- f(-1);
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0xffff);
- ASSERT(data[2] == 0x3434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/str_atomic.c b/tests/str_atomic.c
deleted file mode 100644
index 5086078..0000000
--- a/tests/str_atomic.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static long data[] = { 0x12121212, 0x00000000, 0x34343434 };
-
-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_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_INT32, JIT_R1));
-
- jit_str_atomic(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, int32_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34343434);
- f(&data[1], 0x0f0f0f0f);
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x0f0f0f0f);
- ASSERT(data[2] == 0x34343434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/str_c.c b/tests/str_c.c
deleted file mode 100644
index 492cc73..0000000
--- a/tests/str_c.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static uint8_t data[] = { 0x12, 0x00, 0x34 };
-
-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_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_INT8, JIT_R1));
-
- jit_str_c(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, int8_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34);
- f(&data[1], -1);
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0xff);
- ASSERT(data[2] == 0x34);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/str_d.c b/tests/str_d.c
deleted file mode 100644
index 41db4fd..0000000
--- a/tests/str_d.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static double data[] = { -1.0, 0.0, 0.5 };
-
-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_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0));
-
- jit_str_d(j, JIT_R0, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, double) = jit_end(j, NULL);
-
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 0.0);
- ASSERT(data[2] == 0.5);
- f(&data[1], 42.5);
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 42.5);
- ASSERT(data[2] == 0.5);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/str_f.c b/tests/str_f.c
deleted file mode 100644
index 7b394ae..0000000
--- a/tests/str_f.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static float data[] = { -1.0, 0.0, 0.5 };
-
-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_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0));
-
- jit_str_f(j, JIT_R0, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, float) = jit_end(j, NULL);
-
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 0.0f);
- ASSERT(data[2] == 0.5f);
- f(&data[1], 42.5f);
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 42.5f);
- ASSERT(data[2] == 0.5f);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/str_i.c b/tests/str_i.c
deleted file mode 100644
index 39e88b9..0000000
--- a/tests/str_i.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static uint32_t data[] = { 0x12121212, 0x00000000, 0x34343434 };
-
-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_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_INT32, JIT_R1));
-
- jit_str_i(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, int32_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34343434);
- f(&data[1], -1);
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0xffffffff);
- ASSERT(data[2] == 0x34343434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/str_l.c b/tests/str_l.c
deleted file mode 100644
index c3338ff..0000000
--- a/tests/str_l.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)
-{
-#if EJIT_WORDSIZE > 32
- static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
-
- 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_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_INT64, JIT_R1));
-
- jit_str_l(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, int64_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x3434343434343434);
- f(&data[1], -1);
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0xffffffffffffffff);
- ASSERT(data[2] == 0x3434343434343434);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/str_s.c b/tests/str_s.c
deleted file mode 100644
index d2e7e45..0000000
--- a/tests/str_s.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static uint16_t data[] = { 0x1212, 0x0000, 0x3434 };
-
-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_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_INT16, JIT_R1));
-
- jit_str_s(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, int16_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0);
- ASSERT(data[2] == 0x3434);
- f(&data[1], -1);
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0xffff);
- ASSERT(data[2] == 0x3434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxi_16.c b/tests/stxi_16.c
new file mode 100644
index 0000000..eeec55c
--- /dev/null
+++ b/tests/stxi_16.c
@@ -0,0 +1,29 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint16_t data[] = { 0x1212, 0x0000, 0x3434 };
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int16_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 2, operands);
+
+ ejit_stxi_16(f, EJIT_GPR(1), EJIT_GPR(0), (uintptr_t)data);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(int), do_jit);
+
+ assert(data[0] == 0x1212);
+ assert(data[1] == 0);
+ assert(data[2] == 0x3434);
+ erf2(f, EJIT_ARG(sizeof(int16_t), int), EJIT_ARG(-1, int16_t));
+ assert(data[0] == 0x1212);
+ assert(data[1] == 0xffff);
+ assert(data[2] == 0x3434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxi_32.c b/tests/stxi_32.c
new file mode 100644
index 0000000..b853679
--- /dev/null
+++ b/tests/stxi_32.c
@@ -0,0 +1,29 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint32_t data[] = { 0x12121212, 0x00000000, 0x34343434 };
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int32_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 2, operands);
+
+ ejit_stxi_32(f, EJIT_GPR(1), EJIT_GPR(0), (uintptr_t)data);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(int32_t), do_jit);
+
+ assert(data[0] == 0x12121212);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x34343434);
+ erf2(f, EJIT_ARG(sizeof(int32_t), int), EJIT_ARG(-1, int32_t));
+ assert(data[0] == 0x12121212);
+ assert(data[1] == 0xffffffff);
+ assert(data[2] == 0x34343434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxi_64.c b/tests/stxi_64.c
new file mode 100644
index 0000000..83d3aae
--- /dev/null
+++ b/tests/stxi_64.c
@@ -0,0 +1,29 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 2, operands);
+
+ ejit_stxi_64(f, EJIT_GPR(1), EJIT_GPR(0), (uintptr_t)data);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(int64_t), do_jit);
+
+ assert(data[0] == 0x1212121212121212);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x3434343434343434);
+ erf2(f, EJIT_ARG(sizeof(int64_t), int), EJIT_ARG(-1, int64_t));
+ assert(data[0] == 0x1212121212121212);
+ assert(data[1] == 0xffffffffffffffff);
+ assert(data[2] == 0x3434343434343434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxi_8.c b/tests/stxi_8.c
new file mode 100644
index 0000000..c83d75d
--- /dev/null
+++ b/tests/stxi_8.c
@@ -0,0 +1,29 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint8_t data[] = { 0x12, 0x00, 0x34 };
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int8_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 2, operands);
+
+ ejit_stxi_8(f, EJIT_GPR(1), EJIT_GPR(0), (uintptr_t)data);
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(int), do_jit);
+
+ assert(data[0] == 0x12);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x34);
+ erf2(f, EJIT_ARG(sizeof(int8_t), int), EJIT_ARG(-1, int8_t));
+ assert(data[0] == 0x12);
+ assert(data[1] == 0xff);
+ assert(data[2] == 0x34);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxi_c.c b/tests/stxi_c.c
deleted file mode 100644
index 828a9d4..0000000
--- a/tests/stxi_c.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static uint8_t data[] = { 0x12, 0x00, 0x34 };
-
-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_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT8, JIT_R1));
-
- jit_stxi_c(j, (uintptr_t)data, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(jit_word_t, int8_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34);
- f(1, -1);
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0xff);
- ASSERT(data[2] == 0x34);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxi_d.c b/tests/stxi_d.c
index 85b3a4a..6de76f8 100644
--- a/tests/stxi_d.c
+++ b/tests/stxi_d.c
@@ -1,32 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
static double data[] = { -1.0, 0.0, 0.5 };
-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_R2),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int)),
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 2, operands);
- jit_stxi_d(j, (uintptr_t)data, JIT_R2, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
+ ejit_stxi_d(f, EJIT_FPR(0), EJIT_GPR(0), (uintptr_t)data);
+ ejit_ret(f);
- void (*f)(jit_word_t, double) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 1, 1, EJIT_USE64(double), do_jit);
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 0.0);
- ASSERT(data[2] == 0.5);
- f(8, 42.5);
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 42.5);
- ASSERT(data[2] == 0.5);
-}
+ assert(data[0] == -1.0f);
+ assert(data[1] == 0.0f);
+ assert(data[2] == 0.5f);
+ erf2(f, EJIT_ARG(sizeof(double), int), EJIT_ARG(42.5, double));
+ assert(data[0] == -1.0f);
+ assert(data[1] == 42.5);
+ assert(data[2] == 0.5f);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/stxi_f.c b/tests/stxi_f.c
index 7325b3c..0b700fe 100644
--- a/tests/stxi_f.c
+++ b/tests/stxi_f.c
@@ -1,32 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
static float data[] = { -1.0, 0.0, 0.5 };
-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_R2),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int)),
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(float))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 2, operands);
- jit_stxi_f(j, (uintptr_t)data, JIT_R2, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
+ ejit_stxi_f(f, EJIT_FPR(0), EJIT_GPR(0), (uintptr_t)data);
+ ejit_ret(f);
- void (*f)(jit_word_t, float) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 1, 1, EJIT_USE64(float), do_jit);
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 0.0f);
- ASSERT(data[2] == 0.5f);
- f(4, 42.5f);
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 42.5f);
- ASSERT(data[2] == 0.5f);
-}
+ assert(data[0] == -1.0);
+ assert(data[1] == 0.0);
+ assert(data[2] == 0.5);
+ erf2(f, EJIT_ARG(sizeof(float), int), EJIT_ARG(42.5, float));
+ assert(data[0] == -1.0);
+ assert(data[1] == 42.5);
+ assert(data[2] == 0.5);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/stxi_i.c b/tests/stxi_i.c
deleted file mode 100644
index 37bfd8f..0000000
--- a/tests/stxi_i.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static uint32_t data[] = { 0x12121212, 0x00000000, 0x34343434 };
-
-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_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT32, JIT_R1));
-
- jit_stxi_i(j, (uintptr_t)data, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(jit_word_t, int32_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34343434);
- f(4, -1);
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0xffffffff);
- ASSERT(data[2] == 0x34343434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxi_l.c b/tests/stxi_l.c
deleted file mode 100644
index a758fa9..0000000
--- a/tests/stxi_l.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)
-{
-#if EJIT_WORDSIZE > 32
- static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
-
- 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_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT64, JIT_R1));
-
- jit_stxi_l(j, (uintptr_t)data, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(jit_word_t, int64_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x3434343434343434);
- f(8, -1);
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0xffffffffffffffff);
- ASSERT(data[2] == 0x3434343434343434);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxi_s.c b/tests/stxi_s.c
deleted file mode 100644
index d3aebc3..0000000
--- a/tests/stxi_s.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static uint16_t data[] = { 0x1212, 0x0000, 0x3434 };
-
-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_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT16, JIT_R1));
-
- jit_stxi_s(j, (uintptr_t)data, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(jit_word_t, int16_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0);
- ASSERT(data[2] == 0x3434);
- f(2, -1);
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0xffff);
- ASSERT(data[2] == 0x3434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxr_16.c b/tests/stxr_16.c
new file mode 100644
index 0000000..865eda0
--- /dev/null
+++ b/tests/stxr_16.c
@@ -0,0 +1,35 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint16_t data[] = { 0x1212, 0x0000, 0x3434 };
+
+int main()
+{
+ struct ejit_operand operands[3] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(void *)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(2, EJIT_TYPE(int16_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 3, operands);
+
+ ejit_stxr_16(f, EJIT_GPR(2), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 3, 0, EJIT_USE64(void *), do_jit);
+
+ assert(data[0] == 0x1212);
+ assert(data[1] == 0);
+ assert(data[2] == 0x3434);
+ struct ejit_arg args[3] = {
+ EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int16_t), int),
+ EJIT_ARG(-1, int16_t)
+ };
+ ejit_run_func(f, 3, args);
+ assert(data[0] == 0x1212);
+ assert(data[1] == 0xffff);
+ assert(data[2] == 0x3434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxr_32.c b/tests/stxr_32.c
new file mode 100644
index 0000000..f23b902
--- /dev/null
+++ b/tests/stxr_32.c
@@ -0,0 +1,35 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint32_t data[] = { 0x12121212, 0x00000000, 0x34343434 };
+
+int main()
+{
+ struct ejit_operand operands[3] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(void *)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(2, EJIT_TYPE(int32_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 3, operands);
+
+ ejit_stxr_32(f, EJIT_GPR(2), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 3, 0, EJIT_USE64(void *), do_jit);
+
+ assert(data[0] == 0x12121212);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x34343434);
+ struct ejit_arg args[3] = {
+ EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int32_t), int),
+ EJIT_ARG(-1, int32_t)
+ };
+ ejit_run_func(f, 3, args);
+ assert(data[0] == 0x12121212);
+ assert(data[1] == 0xffffffff);
+ assert(data[2] == 0x34343434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxr_64.c b/tests/stxr_64.c
new file mode 100644
index 0000000..ae0a25c
--- /dev/null
+++ b/tests/stxr_64.c
@@ -0,0 +1,35 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
+
+int main()
+{
+ struct ejit_operand operands[3] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(void *)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(2, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 3, operands);
+
+ ejit_stxr_64(f, EJIT_GPR(2), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 3, 0, EJIT_USE64(int64_t), do_jit);
+
+ assert(data[0] == 0x1212121212121212);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x3434343434343434);
+ struct ejit_arg args[3] = {
+ EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int64_t), int),
+ EJIT_ARG(-1, int64_t)
+ };
+ ejit_run_func(f, 3, args);
+ assert(data[0] == 0x1212121212121212);
+ assert(data[1] == 0xffffffffffffffff);
+ assert(data[2] == 0x3434343434343434);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxr_8.c b/tests/stxr_8.c
new file mode 100644
index 0000000..ede62d0
--- /dev/null
+++ b/tests/stxr_8.c
@@ -0,0 +1,35 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+static uint8_t data[] = { 0x12, 0x00, 0x34 };
+
+int main()
+{
+ struct ejit_operand operands[3] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(void *)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int)),
+ EJIT_OPERAND_GPR(2, EJIT_TYPE(int8_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 3, operands);
+
+ ejit_stxr_8(f, EJIT_GPR(2), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_ret(f);
+
+ ejit_select_compile_func(f, 3, 0, EJIT_USE64(void *), do_jit);
+
+ assert(data[0] == 0x12);
+ assert(data[1] == 0x00);
+ assert(data[2] == 0x34);
+ struct ejit_arg args[3] = {
+ EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(int8_t), int),
+ EJIT_ARG(-1, int8_t)
+ };
+ ejit_run_func(f, 3, args);
+ assert(data[0] == 0x12);
+ assert(data[1] == 0xff);
+ assert(data[2] == 0x34);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/stxr_c.c b/tests/stxr_c.c
deleted file mode 100644
index 329083b..0000000
--- a/tests/stxr_c.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "test.h"
-
-static uint8_t data[] = { 0x12, 0x00, 0x34 };
-
-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_3(j, jit_operand_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT8, JIT_R1));
-
- jit_stxr_c(j, JIT_R0, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, jit_word_t, int8_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34);
- f(data, 1, -1);
- ASSERT(data[0] == 0x12);
- ASSERT(data[1] == 0xff);
- ASSERT(data[2] == 0x34);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxr_d.c b/tests/stxr_d.c
index ee6e86a..fe21a2a 100644
--- a/tests/stxr_d.c
+++ b/tests/stxr_d.c
@@ -1,33 +1,35 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
static double data[] = { -1.0, 0.0, 0.5 };
-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_3(j, jit_operand_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0));
+ struct ejit_operand operands[3] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(void *)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int)),
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 3, operands);
- jit_stxr_d(j, JIT_R0, JIT_R2, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
+ ejit_stxr_d(f, EJIT_FPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_ret(f);
- void (*f)(void*, jit_word_t, double) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 2, 1, EJIT_USE64(void *), do_jit);
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 0.0);
- ASSERT(data[2] == 0.5);
- f(data, 8, 42.5);
- ASSERT(data[0] == -1.0);
- ASSERT(data[1] == 42.5);
- ASSERT(data[2] == 0.5);
-}
+ assert(data[0] == -1.0);
+ assert(data[1] == 0.0);
+ assert(data[2] == 0.5);
+ struct ejit_arg args[3] = {
+ EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(double), int),
+ EJIT_ARG(42.5, double)
+ };
+ ejit_run_func(f, 3, args);
+ assert(data[0] == -1.0);
+ assert(data[1] == 42.5);
+ assert(data[2] == 0.5);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/stxr_f.c b/tests/stxr_f.c
index d5bf9bf..6b43c83 100644
--- a/tests/stxr_f.c
+++ b/tests/stxr_f.c
@@ -1,33 +1,35 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
static float data[] = { -1.0, 0.0, 0.5 };
-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_3(j, jit_operand_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0));
+ struct ejit_operand operands[3] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(void *)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int)),
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(float))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_VOID, 3, operands);
- jit_stxr_f(j, JIT_R0, JIT_R2, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
+ ejit_stxr_f(f, EJIT_FPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_ret(f);
- void (*f)(void*, jit_word_t, float) = jit_end(j, NULL);
+ ejit_select_compile_func(f, 2, 1, EJIT_USE64(void *), do_jit);
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 0.0f);
- ASSERT(data[2] == 0.5f);
- f(data, 4, 42.5f);
- ASSERT(data[0] == -1.0f);
- ASSERT(data[1] == 42.5f);
- ASSERT(data[2] == 0.5f);
-}
+ assert(data[0] == -1.0);
+ assert(data[1] == 0.0);
+ assert(data[2] == 0.5);
+ struct ejit_arg args[3] = {
+ EJIT_ARG(data, void *),
+ EJIT_ARG(sizeof(float), int),
+ EJIT_ARG(42.5, float)
+ };
+ ejit_run_func(f, 3, args);
+ assert(data[0] == -1.0);
+ assert(data[1] == 42.5);
+ assert(data[2] == 0.5);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/stxr_i.c b/tests/stxr_i.c
deleted file mode 100644
index 5ee69e7..0000000
--- a/tests/stxr_i.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "test.h"
-
-static uint32_t data[] = { 0x12121212, 0x00000000, 0x34343434 };
-
-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_3(j, jit_operand_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT32, JIT_R1));
-
- jit_stxr_i(j, JIT_R0, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, jit_word_t, int32_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34343434);
- f(data, 4, -1);
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0xffffffff);
- ASSERT(data[2] == 0x34343434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxr_l.c b/tests/stxr_l.c
deleted file mode 100644
index 6562dda..0000000
--- a/tests/stxr_l.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)
-{
-#if EJIT_WORDSIZE > 32
- static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
-
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_3(j, jit_operand_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT64, JIT_R1));
-
- jit_stxr_l(j, JIT_R0, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, jit_word_t, int64_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x3434343434343434);
- f(data, 8, -1);
- ASSERT(data[0] == 0x1212121212121212);
- ASSERT(data[1] == 0xffffffffffffffff);
- ASSERT(data[2] == 0x3434343434343434);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/stxr_s.c b/tests/stxr_s.c
deleted file mode 100644
index 8505892..0000000
--- a/tests/stxr_s.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "test.h"
-
-static uint16_t data[] = { 0x1212, 0x0000, 0x3434 };
-
-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_3(j, jit_operand_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R2),
- jit_operand_gpr (JIT_OPERAND_ABI_INT16, JIT_R1));
-
- jit_stxr_s(j, JIT_R0, JIT_R2, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, jit_word_t, int16_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0);
- ASSERT(data[2] == 0x3434);
- f(data, 2, -1);
- ASSERT(data[0] == 0x1212);
- ASSERT(data[1] == 0xffff);
- ASSERT(data[2] == 0x3434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/subr.c b/tests/subr.c
index e2c22bc..62ac130 100644
--- a/tests/subr.c
+++ b/tests/subr.c
@@ -1,26 +1,21 @@
-#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))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
- jit_subr(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
+ ejit_subr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
- size_t size = 0;
- void* ret = jit_end(j, &size);
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
- int (*f)(int, int) = ret;
- ASSERT(f(42, 69) == -27);
-}
+ assert(erf2(f, EJIT_ARG(42, long), EJIT_ARG(69, long)) == -27);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_destroy_func(f);
}
diff --git a/tests/subr_f.c b/tests/subr_f.c
index 3fdf071..02cb1c9 100644
--- a/tests/subr_f.c
+++ b/tests/subr_f.c
@@ -1,27 +1,25 @@
-#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_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))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 2, operands);
- jit_subr_f(j, JIT_F0, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr_f(j, JIT_F0);
+ ejit_subr_f(f, EJIT_FPR(0), EJIT_FPR(0), EJIT_FPR(1));
+ ejit_retr_f(f, EJIT_FPR(0));
- size_t size = 0;
- void* ret = jit_end(j, &size);
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit);
- float (*f)(float, float) = ret;
- ASSERT(f(42.f, 69.f) == -27.f);
- ASSERT(f(42.0f, 69.5f) == -27.5f);
-}
+ assert(erff2(f, EJIT_ARG(42., double), EJIT_ARG(69., double)
+ ) == -27.);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(erff2(f, EJIT_ARG(42.5, double), EJIT_ARG(69., double)
+ ) == -26.5);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/swap_atomic.c b/tests/swap_atomic.c
deleted file mode 100644
index 5803164..0000000
--- a/tests/swap_atomic.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static long data[] = { 0x12121212, 0x00000000, 0x34343434 };
-
-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_gpr (JIT_OPERAND_ABI_POINTER, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_INT32, JIT_R1));
-
- jit_swap_atomic(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_ret(j);
-
- void (*f)(void*, int32_t) = jit_end(j, NULL);
-
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x00);
- ASSERT(data[2] == 0x34343434);
- f(&data[1], 0x0f0f0f0f);
- ASSERT(data[0] == 0x12121212);
- ASSERT(data[1] == 0x0f0f0f0f);
- ASSERT(data[2] == 0x34343434);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/truncr_d_32.c b/tests/truncr_d_32.c
new file mode 100644
index 0000000..b7109b4
--- /dev/null
+++ b/tests/truncr_d_32.c
@@ -0,0 +1,27 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int32_t), 1, operands);
+
+ ejit_truncr_d_32(f, EJIT_GPR(0), EJIT_FPR(0));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 1, EJIT_TYPE(int32_t), do_jit);
+
+ assert(erf1(f, EJIT_ARG(0.0, double)) == 0);
+ assert(erf1(f, EJIT_ARG(-0.0, double)) == 0);
+ assert(erf1(f, EJIT_ARG(0.5, double)) == 0);
+ assert(erf1(f, EJIT_ARG(-0.5, double)) == 0);
+ assert(erf1(f, EJIT_ARG(1.5, double)) == 1);
+ assert(erf1(f, EJIT_ARG(-1.5, double)) == -1);
+ assert(erf1(f, EJIT_ARG(2.5, double)) == 2);
+ assert(erf1(f, EJIT_ARG(-2.5, double)) == -2);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/truncr_d_64.c b/tests/truncr_d_64.c
new file mode 100644
index 0000000..fad0ae9
--- /dev/null
+++ b/tests/truncr_d_64.c
@@ -0,0 +1,27 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 1, operands);
+
+ ejit_truncr_d_64(f, EJIT_GPR(0), EJIT_FPR(0));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 1, EJIT_TYPE(int64_t), do_jit);
+
+ assert(erf1(f, EJIT_ARG(0.0, double)) == 0);
+ assert(erf1(f, EJIT_ARG(-0.0, double)) == 0);
+ assert(erf1(f, EJIT_ARG(0.5, double)) == 0);
+ assert(erf1(f, EJIT_ARG(-0.5, double)) == 0);
+ assert(erf1(f, EJIT_ARG(1.5, double)) == 1);
+ assert(erf1(f, EJIT_ARG(-1.5, double)) == -1);
+ assert(erf1(f, EJIT_ARG(2.5, double)) == 2);
+ assert(erf1(f, EJIT_ARG(-2.5, double)) == -2);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/truncr_d_i.c b/tests/truncr_d_i.c
deleted file mode 100644
index 09e163e..0000000
--- a/tests/truncr_d_i.c
+++ /dev/null
@@ -1,30 +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_1(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0));
-
- jit_truncr_d_i(j, JIT_R0, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- int (*f)(double) = jit_end(j, NULL);
-
- ASSERT(f(0.0) == 0);
- ASSERT(f(-0.0) == 0);
- ASSERT(f(0.5) == 0);
- ASSERT(f(-0.5) == 0);
- ASSERT(f(1.5) == 1);
- ASSERT(f(-1.5) == -1);
- ASSERT(f(2.5) == 2);
- ASSERT(f(-2.5) == -2);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/truncr_d_l.c b/tests/truncr_d_l.c
deleted file mode 100644
index ee9b477..0000000
--- a/tests/truncr_d_l.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
-#if EJIT_WORDSIZE > 32
- 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_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0));
-
- jit_truncr_d_l(j, JIT_R0, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- int64_t (*f)(double) = jit_end(j, NULL);
-
- ASSERT(f(0.0) == 0);
- ASSERT(f(-0.0) == 0);
- ASSERT(f(0.5) == 0);
- ASSERT(f(-0.5) == 0);
- ASSERT(f(1.5) == 1);
- ASSERT(f(-1.5) == -1);
- ASSERT(f(2.5) == 2);
- ASSERT(f(-2.5) == -2);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/truncr_f_i.c b/tests/truncr_f_i.c
deleted file mode 100644
index 0314753..0000000
--- a/tests/truncr_f_i.c
+++ /dev/null
@@ -1,30 +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_1(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0));
-
- jit_truncr_f_i(j, JIT_R0, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- int (*f)(float) = jit_end(j, NULL);
-
- ASSERT(f(0.0) == 0);
- ASSERT(f(-0.0) == 0);
- ASSERT(f(0.5) == 0);
- ASSERT(f(-0.5) == 0);
- ASSERT(f(1.5) == 1);
- ASSERT(f(-1.5) == -1);
- ASSERT(f(2.5) == 2);
- ASSERT(f(-2.5) == -2);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/truncr_f_l.c b/tests/truncr_f_l.c
deleted file mode 100644
index ad95744..0000000
--- a/tests/truncr_f_l.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
-#if EJIT_WORDSIZE > 32
- 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_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0));
-
- jit_truncr_f_l(j, JIT_R0, JIT_F0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- int64_t (*f)(float) = jit_end(j, NULL);
-
- ASSERT(f(0.0) == 0);
- ASSERT(f(-0.0) == 0);
- ASSERT(f(0.5) == 0);
- ASSERT(f(-0.5) == 0);
- ASSERT(f(1.5) == 1);
- ASSERT(f(-1.5) == -1);
- ASSERT(f(2.5) == 2);
- ASSERT(f(-2.5) == -2);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/xori.c b/tests/xori.c
deleted file mode 100644
index 16197ce..0000000
--- a/tests/xori.c
+++ /dev/null
@@ -1,31 +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_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
-
- jit_xori(j, JIT_R0, JIT_R0, 1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t) = ret;
-
- ASSERT(f(0x7fffffff) == 0x7ffffffe);
- ASSERT(f(0x80000000) == 0x80000001);
-#if EJIT_WORDSIZE == 64
- ASSERT(f(0x7fffffffffffffff) == 0x7ffffffffffffffe);
- ASSERT(f(0x8000000000000000) == 0x8000000000000001);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/xori64.c b/tests/xori64.c
new file mode 100644
index 0000000..6f3984f
--- /dev/null
+++ b/tests/xori64.c
@@ -0,0 +1,26 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int), 1, operands);
+
+ ejit_xori(f, EJIT_GPR(0), EJIT_GPR(0), 1);
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int64_t), do_jit);
+
+ assert(erf1(f, EJIT_ARG(0x7fffffff, int64_t)) == 0x7ffffffe);
+ assert(erf1(f, EJIT_ARG(0x80000000, int64_t)) == 0x80000001);
+ assert(erf1(f,
+ EJIT_ARG(0x7fffffffffffffff,
+ int64_t)) == 0x7ffffffffffffffe);
+ assert(erf1(f, EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/xorr.c b/tests/xorr.c
deleted file mode 100644
index 123bfb7..0000000
--- a/tests/xorr.c
+++ /dev/null
@@ -1,48 +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_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
-
- jit_xorr(j, JIT_R0, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_retr(j, JIT_R0);
-
- size_t size = 0;
- void* ret = jit_end(j, &size);
-
- jit_word_t (*f)(jit_word_t, jit_word_t) = ret;
-
- ASSERT(f(0x7fffffff, 1) == 0x7ffffffe);
- ASSERT(f(1, 0x7fffffff) == 0x7ffffffe);
- ASSERT(f(0x80000000, 1) == 0x80000001);
- ASSERT(f(1, 0x80000000) == 0x80000001);
- ASSERT(f(0x7fffffff, 0x80000000) == 0xffffffff);
- ASSERT(f(0x80000000, 0x7fffffff) == 0xffffffff);
- ASSERT(f(0x7fffffff, 0xffffffff) == 0x80000000);
- ASSERT(f(0xffffffff, 0x7fffffff) == 0x80000000);
- ASSERT(f(0xffffffff, 0xffffffff) == 0);
- ASSERT(f(0x7fffffff, 0) == 0x7fffffff);
- ASSERT(f(0, 0x7fffffff) == 0x7fffffff);
-#if EJIT_WORDSIZE == 64
- ASSERT(f(0x7fffffffffffffff, 1) == 0x7ffffffffffffffe);
- ASSERT(f(1, 0x7fffffffffffffff) == 0x7ffffffffffffffe);
- ASSERT(f(0x8000000000000000, 1) == 0x8000000000000001);
- ASSERT(f(1, 0x8000000000000000) == 0x8000000000000001);
- ASSERT(f(0x7fffffffffffffff, 0x8000000000000000) == 0xffffffffffffffff);
- ASSERT(f(0x8000000000000000, 0x7fffffffffffffff) == 0xffffffffffffffff);
- ASSERT(f(0x7fffffffffffffff, 0xffffffffffffffff) == 0x8000000000000000);
- ASSERT(f(0xffffffffffffffff, 0x7fffffffffffffff) == 0x8000000000000000);
- ASSERT(f(0xffffffffffffffff, 0xffffffffffffffff) == 0);
-#endif
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/xorr64.c b/tests/xorr64.c
new file mode 100644
index 0000000..a553f5e
--- /dev/null
+++ b/tests/xorr64.c
@@ -0,0 +1,89 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(int64_t)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(int64_t))
+ };
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(int64_t), 2, operands);
+
+ ejit_xorr(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(int64_t), do_jit);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)) == 0x7ffffffe);
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x80000000, int64_t)) == 0x80000001);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x7ffffffe);
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0x80000001);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0, int64_t)) == 0x7fffffff);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0x80000000, int64_t)
+ ) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == 0x80000000);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ ) == 0x80000000);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0, int64_t), EJIT_ARG(0x7fffffff, int64_t)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == 0x7ffffffffffffffe);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(1, int64_t)
+ ) == (int64_t)0x8000000000000001);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(1, int64_t)
+ ) == (int64_t)0x7ffffffffffffffe);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == (int64_t)0x8000000000000000);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == (int64_t)0x8000000000000000);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == 0);
+
+
+ ejit_destroy_func(f);
+}