[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 46/86: Add bswap tests, and fix missing breaks in jit_lo
From: |
Andy Wingo |
Subject: |
[Guile-commits] 46/86: Add bswap tests, and fix missing breaks in jit_load_args |
Date: |
Wed, 3 Apr 2019 11:38:58 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 1808239ec8b8810506895b536556b52bf7779e0a
Author: Andy Wingo <address@hidden>
Date: Tue Mar 26 10:47:22 2019 +0100
Add bswap tests, and fix missing breaks in jit_load_args
---
jit/x86.c | 2 ++
tests/bswapr_ui.c | 32 ++++++++++++++++++++++++++++++++
tests/bswapr_ul.c | 31 +++++++++++++++++++++++++++++++
tests/bswapr_us.c | 28 ++++++++++++++++++++++++++++
4 files changed, 93 insertions(+)
diff --git a/jit/x86.c b/jit/x86.c
index 08bda79..7dc6e2d 100644
--- a/jit/x86.c
+++ b/jit/x86.c
@@ -483,6 +483,7 @@ jit_load_args(jit_state_t *_jit, size_t argc,
args[i].loc.gpr = reg.gpr;
}
}
+ break;
case JIT_ARG_LOC_FPR:
{
if (arg.loc.fpr != reg.fpr)
@@ -508,6 +509,7 @@ jit_load_args(jit_state_t *_jit, size_t argc,
args[i].loc.fpr = reg.fpr;
}
}
+ break;
case JIT_ARG_LOC_MEM:
/* Load spilled arguments once we're done with registers. */
break;
diff --git a/tests/bswapr_ui.c b/tests/bswapr_ui.c
new file mode 100644
index 0000000..f566ad4
--- /dev/null
+++ b/tests/bswapr_ui.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_bswapr_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(0x12345678) == 0x78563412);
+#if __WORDSIZE > 32
+ ASSERT(f(0xff12345678) == 0x78563412);
+ ASSERT(f(0xff00000000) == 0);
+#endif
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bswapr_ul.c b/tests/bswapr_ul.c
new file mode 100644
index 0000000..28a2f03
--- /dev/null
+++ b/tests/bswapr_ul.c
@@ -0,0 +1,31 @@
+#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_bswapr_ul(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(0x12345678) == 0x7856341200000000);
+ ASSERT(f(0xff12345678) == 0x78563412ff000000);
+#endif
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bswapr_us.c b/tests/bswapr_us.c
new file mode 100644
index 0000000..10028df
--- /dev/null
+++ b/tests/bswapr_us.c
@@ -0,0 +1,28 @@
+#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_bswapr_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(0x12345678) == 0x7856);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
- [Guile-commits] 34/86: Add note about current status, (continued)
- [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, 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 <=
- [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
- [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