[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 39/86: Add remr tests
From: |
Andy Wingo |
Subject: |
[Guile-commits] 39/86: Add remr tests |
Date: |
Wed, 3 Apr 2019 11:38:55 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 0127664fb394304de3e4c6551bd0c934d060a0c8
Author: Andy Wingo <address@hidden>
Date: Tue Mar 26 09:17:49 2019 +0100
Add remr tests
---
.gitignore | 2 ++
tests/test-remr.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/test-remr_u.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 124 insertions(+)
diff --git a/.gitignore b/.gitignore
index 0b8c0ec..fb5c45a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@
/tests/test-divr_f
/tests/test-qdivr
/tests/test-qdivr_u
+/tests/test-remr
+/tests/test-remr_u
diff --git a/tests/test-remr.c b/tests/test-remr.c
new file mode 100644
index 0000000..a06e240
--- /dev/null
+++ b/tests/test-remr.c
@@ -0,0 +1,63 @@
+#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);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
+ jit_arg_t args[2];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 }};
+
+ jit_receive(j, 2, abi, args);
+ jit_load_args(j, 2, abi, args, regs);
+
+ jit_remr(j, JIT_R0, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ size_t size = 0;
+ void* ret = jit_end(j, &size);
+
+ intmax_t (*f)(intmax_t, intmax_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 __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/test-remr_u.c b/tests/test-remr_u.c
new file mode 100644
index 0000000..0250181
--- /dev/null
+++ b/tests/test-remr_u.c
@@ -0,0 +1,59 @@
+#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);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
+ jit_arg_t args[2];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 }};
+
+ jit_receive(j, 2, abi, args);
+ jit_load_args(j, 2, abi, args, regs);
+
+ jit_remr_u(j, JIT_R0, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ size_t size = 0;
+ void* ret = jit_end(j, &size);
+
+ intmax_t (*f)(intmax_t, intmax_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 __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);
+}
- [Guile-commits] 11/86: Rename include to jit.h, move all files to jit/, (continued)
- [Guile-commits] 11/86: Rename include to jit.h, move all files to jit/, Andy Wingo, 2019/04/03
- [Guile-commits] 33/86: Flesh out README, Andy Wingo, 2019/04/03
- [Guile-commits] 36/86: Add more tests, Andy Wingo, 2019/04/03
- [Guile-commits] 18/86: Add endian.h, Andy Wingo, 2019/04/03
- [Guile-commits] 30/86: Add "addi" test, Andy Wingo, 2019/04/03
- [Guile-commits] 31/86: Better loading of args to registers; add tests, Andy Wingo, 2019/04/03
- [Guile-commits] 26/86: Inline private.h into jit.c, Andy Wingo, 2019/04/03
- [Guile-commits] 32/86: Convert tests to jit_load_args, Andy Wingo, 2019/04/03
- [Guile-commits] 34/86: Add note about current status, Andy Wingo, 2019/04/03
- [Guile-commits] 14/86: Simplify file names, Andy Wingo, 2019/04/03
- [Guile-commits] 39/86: Add remr tests,
Andy Wingo <=
- [Guile-commits] 37/86: Tests for some div operations, Andy Wingo, 2019/04/03
- [Guile-commits] 35/86: Add new tests, Andy Wingo, 2019/04/03
- [Guile-commits] 28/86: Beginnings of port of x86 to new design, Andy Wingo, 2019/04/03
- [Guile-commits] 44/86: Add mov_addr test, Andy Wingo, 2019/04/03
- [Guile-commits] 38/86: Add more div tests, Andy Wingo, 2019/04/03
- [Guile-commits] 52/86: Add sti tests, Andy Wingo, 2019/04/03
- [Guile-commits] 47/86: Add ldr tests, Andy Wingo, 2019/04/03
- [Guile-commits] 46/86: Add bswap tests, and fix missing breaks in jit_load_args, Andy Wingo, 2019/04/03
- [Guile-commits] 50/86: Add ldxi tests, Andy Wingo, 2019/04/03
- [Guile-commits] 41/86: Add lsh/rsh tests, Andy Wingo, 2019/04/03