aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/andr.c102
-rw-r--r--tests/andr64.c92
-rw-r--r--tests/bgei_u.c8
-rw-r--r--tests/blei_u.c8
-rw-r--r--tests/comr.c64
-rw-r--r--tests/escapei_double.c2
-rw-r--r--tests/escapei_float.c2
-rw-r--r--tests/ldxr_d.c2
8 files changed, 142 insertions, 138 deletions
diff --git a/tests/andr.c b/tests/andr.c
deleted file mode 100644
index 1ea25e3..0000000
--- a/tests/andr.c
+++ /dev/null
@@ -1,102 +0,0 @@
-#include <ejit/ejit.h>
-#include <assert.h>
-#include "do_jit.h"
-
-int main(int argc, char *argv[])
-{
- (void)argv;
- bool do_jit = argc > 1;
- 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_andr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
- ejit_retr(f, EJIT_GPR(0));
-
- ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffff, long),
- EJIT_ARG(1, long)) == 1);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(1, long),
- EJIT_ARG(0x7fffffff, long)) == 1);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x80000000, long),
- EJIT_ARG(1, long)) == 0);
-
- 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(0x80000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x80000000, long),
- EJIT_ARG(0x7fffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffff, long),
- EJIT_ARG(0xffffffff, long)) == 0x7fffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffff, long),
- EJIT_ARG(0x7fffffff, long)) == 0x7fffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffff, long),
- EJIT_ARG(0xffffffff, long)) == 0xffffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffff, long),
- EJIT_ARG(0, 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(0x7fffffffffffffff, long),
- EJIT_ARG(1, long)) == 1);
- assert(ejit_run_func_2(f,
- EJIT_ARG(1, long),
- EJIT_ARG(0x7fffffffffffffff, long)) == 1);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x8000000000000000, long),
- EJIT_ARG(1, long)) == 0);
-
- 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(0x8000000000000000, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x8000000000000000, long),
- EJIT_ARG(0x7fffffffffffffff, long)) == 0);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0x7fffffffffffffff, long),
- EJIT_ARG(0xffffffffffffffff, long))
- == 0x7fffffffffffffff);
-
- assert(ejit_run_func_2(f,
- EJIT_ARG(0xffffffffffffffff, long),
- EJIT_ARG(0x7fffffffffffffff, long))
- == 0x7fffffffffffffff);
-
- assert((uint64_t)ejit_run_func_2(f,
- EJIT_ARG(0xffffffffffffffff, long),
- EJIT_ARG(0xffffffffffffffff, long))
- == 0xffffffffffffffff);
-}
diff --git a/tests/andr64.c b/tests/andr64.c
new file mode 100644
index 0000000..6d7f09e
--- /dev/null
+++ b/tests/andr64.c
@@ -0,0 +1,92 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main(int argc, char *argv[])
+{
+ (void)argv;
+ bool do_jit = argc > 1;
+ 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_andr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(int64_t), do_jit);
+
+ 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)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(1, int64_t)) == 1);
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(1, int64_t)) == 0);
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t),
+ EJIT_ARG(0x80000000, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x80000000, int64_t),
+ EJIT_ARG(0x7fffffff, int64_t)
+ )== 0);
+
+ 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)
+ ) == 0x7fffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffff, int64_t),
+ EJIT_ARG(0xffffffff, int64_t)
+ ) == 0xffffffff);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffff, int64_t), EJIT_ARG(0, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0, int64_t), EJIT_ARG(0x7fffffff, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(1, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == 1);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(1, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(1, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x7fffffffffffffff, int64_t),
+ EJIT_ARG(0x8000000000000000, int64_t)
+ ) == 0);
+
+ assert(erf2(f, EJIT_ARG(0x8000000000000000, int64_t),
+ EJIT_ARG(0x7fffffffffffffff, int64_t)
+ ) == 0);
+
+ 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)
+ ) == 0x7fffffffffffffff);
+
+ assert(erf2(f, EJIT_ARG(0xffffffffffffffff, int64_t),
+ EJIT_ARG(0xffffffffffffffff, int64_t)
+ ) == (int64_t)0xffffffffffffffff);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/bgei_u.c b/tests/bgei_u.c
index 4edb5c7..20ac961 100644
--- a/tests/bgei_u.c
+++ b/tests/bgei_u.c
@@ -21,7 +21,9 @@ int main(int argc, char *argv[])
ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
- assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1);
- assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1);
- assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1);
+ assert(erf1(f, EJIT_ARG(0, long)) == 1);
+ assert(erf1(f, EJIT_ARG(1, long)) == 1);
+ assert(erf1(f, EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/blei_u.c b/tests/blei_u.c
index 98c8fcc..b078995 100644
--- a/tests/blei_u.c
+++ b/tests/blei_u.c
@@ -21,7 +21,9 @@ int main(int argc, char *argv[])
ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
- assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1);
- assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0);
- assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0);
+ assert(erf1(f, EJIT_ARG(0, long)) == 1);
+ assert(erf1(f, EJIT_ARG(1, long)) == 0);
+ assert(erf1(f, EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/comr.c b/tests/comr.c
index 70d79e8..a22dfc9 100644
--- a/tests/comr.c
+++ b/tests/comr.c
@@ -17,47 +17,51 @@ int main(int argc, char *argv[])
ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
- assert((int32_t)ejit_run_func_1(f, EJIT_ARG(0, long))
- == (int32_t)0xffffffff);
+ assert((int32_t)erf1(f, EJIT_ARG(0, long)
+ ) == (int32_t)0xffffffff);
- assert((int32_t)ejit_run_func_1(f, EJIT_ARG(1, long))
- == (int32_t)0xfffffffe);
+ assert((int32_t)erf1(f, EJIT_ARG(1, long)
+ ) == (int32_t)0xfffffffe);
- assert((int32_t)ejit_run_func_1(f, EJIT_ARG(0xffffffff, long)) == 0);
- assert((int32_t)ejit_run_func_1(f, EJIT_ARG(0x80000000, long))
- == 0x7fffffff);
+ assert((int32_t)erf1(f, EJIT_ARG(0xffffffff, long)
+ ) == 0);
- assert((int32_t)ejit_run_func_1(f, EJIT_ARG(0x7fffffff, long))
- == (int32_t)0x80000000);
+ assert((int32_t)erf1(f, EJIT_ARG(0x80000000, long)
+ ) == 0x7fffffff);
- assert((int32_t)ejit_run_func_1(f, EJIT_ARG(0x80000001, long))
- == (int32_t)0x7ffffffe);
+ assert((int32_t)erf1(f, EJIT_ARG(0x7fffffff, long)
+ ) == (int32_t)0x80000000);
- assert(ejit_run_func_1(f, EJIT_ARG(0, long))
- == (int64_t)0xffffffffffffffff);
+ assert((int32_t)erf1(f, EJIT_ARG(0x80000001, long)
+ ) == (int32_t)0x7ffffffe);
- assert(ejit_run_func_1(f, EJIT_ARG(1, long))
- == (int64_t)0xfffffffffffffffe);
+ assert(erf1(f, EJIT_ARG(0, long)
+ ) == (int64_t)0xffffffffffffffff);
- assert(ejit_run_func_1(f, EJIT_ARG(0xffffffff, long))
- == (int64_t)0xffffffff00000000);
+ assert(erf1(f, EJIT_ARG(1, long)
+ ) == (int64_t)0xfffffffffffffffe);
- assert(ejit_run_func_1(f, EJIT_ARG(0x80000000, long))
- == (int64_t)0xffffffff7fffffff);
+ assert(erf1(f, EJIT_ARG(0xffffffff, long)
+ ) == (int64_t)0xffffffff00000000);
- assert(ejit_run_func_1(f, EJIT_ARG(0x7fffffff, long))
- == (int64_t)0xffffffff80000000);
+ assert(erf1(f, EJIT_ARG(0x80000000, long)
+ ) == (int64_t)0xffffffff7fffffff);
- assert(ejit_run_func_1(f, EJIT_ARG(0x80000001, long))
- == (int64_t)0xffffffff7ffffffe);
+ assert(erf1(f, EJIT_ARG(0x7fffffff, long)
+ ) == (int64_t)0xffffffff80000000);
- assert(ejit_run_func_1(f, EJIT_ARG(0xffffffffffffffff, long)) == 0);
- assert(ejit_run_func_1(f, EJIT_ARG(0x8000000000000000, long))
- == (int64_t)0x7fffffffffffffff);
+ assert(erf1(f, EJIT_ARG(0x80000001, long)
+ ) == (int64_t)0xffffffff7ffffffe);
- assert(ejit_run_func_1(f, EJIT_ARG(0x7fffffffffffffff, long))
- == (int64_t)0x8000000000000000);
+ assert(erf1(f, EJIT_ARG(0xffffffffffffffff, long)) == 0);
+ assert(erf1(f, EJIT_ARG(0x8000000000000000, long)
+ ) == (int64_t)0x7fffffffffffffff);
- assert(ejit_run_func_1(f, EJIT_ARG(0x8000000000000001, long))
- == (int64_t)0x7ffffffffffffffe);
+ assert(erf1(f, EJIT_ARG(0x7fffffffffffffff, long)
+ ) == (int64_t)0x8000000000000000);
+
+ assert(erf1(f, EJIT_ARG(0x8000000000000001, long)
+ ) == (int64_t)0x7ffffffffffffffe);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/escapei_double.c b/tests/escapei_double.c
index bae6902..7eb9a27 100644
--- a/tests/escapei_double.c
+++ b/tests/escapei_double.c
@@ -42,4 +42,6 @@ int main(int argc, char *argv[])
double d = 22.0f;
int32_t i = 20;
assert(erff2(f, EJIT_ARG(&i, void *), EJIT_ARG(&d, void *)) == 42.0f);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/escapei_float.c b/tests/escapei_float.c
index e92e3e0..c1c0993 100644
--- a/tests/escapei_float.c
+++ b/tests/escapei_float.c
@@ -42,4 +42,6 @@ int main(int argc, char *argv[])
float d = 22.0f;
int32_t i = 20;
assert(erff2(f, EJIT_ARG(&i, void *), EJIT_ARG(&d, void *)) == 42.0f);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/ldxr_d.c b/tests/ldxr_d.c
index a2ed0b8..993952a 100644
--- a/tests/ldxr_d.c
+++ b/tests/ldxr_d.c
@@ -30,4 +30,6 @@ int main(int argc, char *argv[])
assert(erff2(f,
EJIT_ARG(data, void *),
EJIT_ARG(2 * sizeof(double), unsigned)) == data[2]);
+
+ ejit_destroy_func(f);
}