[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 52/86: Add sti tests
From: |
Andy Wingo |
Subject: |
[Guile-commits] 52/86: Add sti tests |
Date: |
Wed, 3 Apr 2019 11:38:59 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit ee2c6ab8068107735a2c35ebfb4441031f77831a
Author: Andy Wingo <address@hidden>
Date: Tue Mar 26 12:03:24 2019 +0100
Add sti tests
---
tests/sti_c.c | 35 +++++++++++++++++++++++++++++++++++
tests/sti_d.c | 35 +++++++++++++++++++++++++++++++++++
tests/sti_f.c | 35 +++++++++++++++++++++++++++++++++++
tests/sti_i.c | 35 +++++++++++++++++++++++++++++++++++
tests/sti_l.c | 37 +++++++++++++++++++++++++++++++++++++
tests/sti_s.c | 35 +++++++++++++++++++++++++++++++++++
6 files changed, 212 insertions(+)
diff --git a/tests/sti_c.c b/tests/sti_c.c
new file mode 100644
index 0000000..10b7b6a
--- /dev/null
+++ b/tests/sti_c.c
@@ -0,0 +1,35 @@
+#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);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INT8 };
+ 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_sti_c(j, &data[1], JIT_R1);
+ 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
new file mode 100644
index 0000000..6f5960e
--- /dev/null
+++ b/tests/sti_d.c
@@ -0,0 +1,35 @@
+#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);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE };
+ jit_arg_t args[1];
+ const jit_anyreg_t regs[] = { { .fpr=JIT_F0 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_sti_d(j, &data[1], JIT_R0);
+ jit_ret(j);
+
+ void (*f)(double) = jit_end(j, NULL);
+
+ 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);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/sti_f.c b/tests/sti_f.c
new file mode 100644
index 0000000..eb008b4
--- /dev/null
+++ b/tests/sti_f.c
@@ -0,0 +1,35 @@
+#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);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT };
+ jit_arg_t args[1];
+ const jit_anyreg_t regs[] = { { .fpr=JIT_F0 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_sti_f(j, &data[1], JIT_R0);
+ jit_ret(j);
+
+ void (*f)(float) = jit_end(j, NULL);
+
+ 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);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/sti_i.c b/tests/sti_i.c
new file mode 100644
index 0000000..b0e6d83
--- /dev/null
+++ b/tests/sti_i.c
@@ -0,0 +1,35 @@
+#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);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INT32 };
+ 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_sti_i(j, &data[1], JIT_R1);
+ 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
new file mode 100644
index 0000000..e997b01
--- /dev/null
+++ b/tests/sti_l.c
@@ -0,0 +1,37 @@
+#include "test.h"
+
+static uint64_t data[] = { 0x1212121212121212, 0, 0x3434343434343434 };
+
+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_INT64 };
+ 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_sti_l(j, &data[1], JIT_R1);
+ 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
new file mode 100644
index 0000000..95cfd33
--- /dev/null
+++ b/tests/sti_s.c
@@ -0,0 +1,35 @@
+#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);
+
+ const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INT16 };
+ 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_sti_s(j, &data[1], JIT_R1);
+ 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);
+}
- [Guile-commits] 26/86: Inline private.h into jit.c, (continued)
- [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, 2019/04/03
- [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 <=
- [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, 2019/04/03
- [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