[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 45/86: Add extr tests
From: |
Andy Wingo |
Subject: |
[Guile-commits] 45/86: Add extr tests |
Date: |
Wed, 3 Apr 2019 11:38:56 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 082a629f62160371b848ebb45e48f01e2b78973d
Author: Andy Wingo <address@hidden>
Date: Tue Mar 26 10:29:31 2019 +0100
Add extr tests
---
tests/extr_c.c | 31 +++++++++++++++++++++++++++++++
tests/extr_i.c | 34 ++++++++++++++++++++++++++++++++++
tests/extr_s.c | 32 ++++++++++++++++++++++++++++++++
tests/extr_uc.c | 31 +++++++++++++++++++++++++++++++
tests/extr_ui.c | 33 +++++++++++++++++++++++++++++++++
tests/extr_us.c | 31 +++++++++++++++++++++++++++++++
6 files changed, 192 insertions(+)
diff --git a/tests/extr_c.c b/tests/extr_c.c
new file mode 100644
index 0000000..f4390a7
--- /dev/null
+++ b/tests/extr_c.c
@@ -0,0 +1,31 @@
+#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_t args[1];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R1 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_extr_c(j, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ uintmax_t (*f)(uintmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 0);
+ ASSERT(f(1) == 1);
+ ASSERT(f(0xf) == 0xf);
+ ASSERT(f(0xff) == -1);
+ ASSERT(f(0xfff) == -1);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/extr_i.c b/tests/extr_i.c
new file mode 100644
index 0000000..a0ec079
--- /dev/null
+++ b/tests/extr_i.c
@@ -0,0 +1,34 @@
+#include "test.h"
+
+static void
+run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+{
+#if __WORDSIZE > 32
+ jit_begin(j, arena_base, arena_size);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
+ jit_arg_t args[1];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R1 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_extr_i(j, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ uintmax_t (*f)(uintmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 0);
+ ASSERT(f(1) == 1);
+ ASSERT(f(0xfffffff) == 0xfffffff);
+ ASSERT(f(0xffffffff) == -1);
+ ASSERT(f(0xfffffffff) == -1);
+ ASSERT(f(0xf00000000) == 0);
+#endif
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/extr_s.c b/tests/extr_s.c
new file mode 100644
index 0000000..c12adb7
--- /dev/null
+++ b/tests/extr_s.c
@@ -0,0 +1,32 @@
+#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_t args[1];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R1 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_extr_s(j, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ uintmax_t (*f)(uintmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 0);
+ ASSERT(f(1) == 1);
+ ASSERT(f(0xfff) == 0xfff);
+ ASSERT(f(0xffff) == -1);
+ ASSERT(f(0xfffff) == -1);
+ ASSERT(f(0xf0000) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/extr_uc.c b/tests/extr_uc.c
new file mode 100644
index 0000000..fb700bd
--- /dev/null
+++ b/tests/extr_uc.c
@@ -0,0 +1,31 @@
+#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_t args[1];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R1 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_extr_uc(j, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ uintmax_t (*f)(uintmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 0);
+ ASSERT(f(1) == 1);
+ ASSERT(f(0xff) == 0xff);
+ ASSERT(f(0xfff) == 0xff);
+ ASSERT(f(0xf00) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/extr_ui.c b/tests/extr_ui.c
new file mode 100644
index 0000000..30706f0
--- /dev/null
+++ b/tests/extr_ui.c
@@ -0,0 +1,33 @@
+#include "test.h"
+
+static void
+run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+{
+#if __WORDSIZE > 32
+ jit_begin(j, arena_base, arena_size);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
+ jit_arg_t args[1];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R1 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_extr_ui(j, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ uintmax_t (*f)(uintmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 0);
+ ASSERT(f(1) == 1);
+ ASSERT(f(0xffffffff) == 0xffffffff);
+ ASSERT(f(0xfffffffff) == 0xffffffff);
+ ASSERT(f(0xf00000000) == 0);
+#endif
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/extr_us.c b/tests/extr_us.c
new file mode 100644
index 0000000..a10f6e9
--- /dev/null
+++ b/tests/extr_us.c
@@ -0,0 +1,31 @@
+#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_t args[1];
+ const jit_anyreg_t regs[] = { { .gpr=JIT_R1 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_extr_us(j, JIT_R0, JIT_R1);
+ jit_retr(j, JIT_R0);
+
+ uintmax_t (*f)(uintmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 0);
+ ASSERT(f(1) == 1);
+ ASSERT(f(0xffff) == 0xffff);
+ ASSERT(f(0xfffff) == 0xffff);
+ ASSERT(f(0xf0000) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
- [Guile-commits] 35/86: Add new tests, (continued)
- [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
- [Guile-commits] 15/86: Remove unneeded bits of lightning, Andy Wingo, 2019/04/03
- [Guile-commits] 45/86: Add extr tests,
Andy Wingo <=
- [Guile-commits] 42/86: Add comr/negr tests, Andy Wingo, 2019/04/03
- [Guile-commits] 55/86: Add .gitlab-ci.yml, Andy Wingo, 2019/04/03
- [Guile-commits] 43/86: Rework naming of test suite files, Andy Wingo, 2019/04/03
- [Guile-commits] 48/86: Add ldi tests, Andy Wingo, 2019/04/03
- [Guile-commits] 57/86: Fix stxi_d bug, Andy Wingo, 2019/04/03
- [Guile-commits] 49/86: Add ldxr tests, Andy Wingo, 2019/04/03
- [Guile-commits] 61/86: Add int/int reg/imm compare-and-branch tests, Andy Wingo, 2019/04/03
- [Guile-commits] 63/86: Add unordered float compare-and-branch tests, Andy Wingo, 2019/04/03
- [Guile-commits] 53/86: Add stxr tests, Andy Wingo, 2019/04/03
- [Guile-commits] 56/86: Tweak test build to run faster, and adapt CI, Andy Wingo, 2019/04/03