[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 64/86: Add flag-checking test-and-branch tests
From: |
Andy Wingo |
Subject: |
[Guile-commits] 64/86: Add flag-checking test-and-branch tests |
Date: |
Wed, 3 Apr 2019 11:39:01 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 0d0c6b1a4b182e1f12af7cb2b5ed4f931a913352
Author: Andy Wingo <address@hidden>
Date: Tue Mar 26 15:25:57 2019 +0100
Add flag-checking test-and-branch tests
---
tests/bmci.c | 32 ++++++++++++++++++++++++++++++++
tests/bmcr.c | 37 +++++++++++++++++++++++++++++++++++++
tests/bmsi.c | 32 ++++++++++++++++++++++++++++++++
tests/bmsr.c | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 138 insertions(+)
diff --git a/tests/bmci.c b/tests/bmci.c
new file mode 100644
index 0000000..0ffe415
--- /dev/null
+++ b/tests/bmci.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_R0 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_reloc_t r = jit_bmci(j, JIT_R0, 1);
+ jit_reti(j, 0);
+ jit_patch_here(j, r);
+ jit_reti(j, 1);
+
+ intmax_t (*f)(intmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 1);
+ ASSERT(f(1) == 0);
+ ASSERT(f(-1) == 0);
+ ASSERT(f(2) == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bmcr.c b/tests/bmcr.c
new file mode 100644
index 0000000..03591fc
--- /dev/null
+++ b/tests/bmcr.c
@@ -0,0 +1,37 @@
+#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_reloc_t r = jit_bmcr(j, JIT_R0, JIT_R1);
+ jit_reti(j, 0);
+ jit_patch_here(j, r);
+ jit_reti(j, 1);
+
+ intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0, 0) == 1);
+ ASSERT(f(0, 1) == 1);
+ ASSERT(f(1, 0) == 1);
+ ASSERT(f(-1, 0) == 1);
+ ASSERT(f(0, -1) == 1);
+ ASSERT(f(1, 1) == 0);
+ ASSERT(f(1, -1) == 0);
+ ASSERT(f(-1, 1) == 0);
+ ASSERT(f(-1, -1) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bmsi.c b/tests/bmsi.c
new file mode 100644
index 0000000..21f986f
--- /dev/null
+++ b/tests/bmsi.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_R0 } };
+
+ jit_receive(j, 1, abi, args);
+ jit_load_args(j, 1, abi, args, regs);
+
+ jit_reloc_t r = jit_bmsi(j, JIT_R0, 1);
+ jit_reti(j, 0);
+ jit_patch_here(j, r);
+ jit_reti(j, 1);
+
+ intmax_t (*f)(intmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0) == 0);
+ ASSERT(f(1) == 1);
+ ASSERT(f(-1) == 1);
+ ASSERT(f(2) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bmsr.c b/tests/bmsr.c
new file mode 100644
index 0000000..cd58951
--- /dev/null
+++ b/tests/bmsr.c
@@ -0,0 +1,37 @@
+#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_reloc_t r = jit_bmsr(j, JIT_R0, JIT_R1);
+ jit_reti(j, 0);
+ jit_patch_here(j, r);
+ jit_reti(j, 1);
+
+ intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
+
+ ASSERT(f(0, 0) == 0);
+ ASSERT(f(0, 1) == 0);
+ ASSERT(f(1, 0) == 0);
+ ASSERT(f(-1, 0) == 0);
+ ASSERT(f(0, -1) == 0);
+ ASSERT(f(1, 1) == 1);
+ ASSERT(f(1, -1) == 1);
+ ASSERT(f(-1, 1) == 1);
+ ASSERT(f(-1, -1) == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
- [Guile-commits] 49/86: Add ldxr tests, (continued)
- [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
- [Guile-commits] 40/86: Add bitops tests, Andy Wingo, 2019/04/03
- [Guile-commits] 78/86: Clean up stack after calls, Andy Wingo, 2019/04/03
- [Guile-commits] 75/86: get_temp_{gpr, xpr} returns a jit_{gpr, fpr}_t, Andy Wingo, 2019/04/03
- [Guile-commits] 66/86: Add sub-and-branch-on-overflow tests, Andy Wingo, 2019/04/03
- [Guile-commits] 73/86: Add movi_[df] tests, Andy Wingo, 2019/04/03
- [Guile-commits] 64/86: Add flag-checking test-and-branch tests,
Andy Wingo <=
- [Guile-commits] 69/86: Add abs/sqrt tests, Andy Wingo, 2019/04/03
- [Guile-commits] 67/86: Add some nop and jmp tests, and fix a hazard with jmpi/calli, Andy Wingo, 2019/04/03
- [Guile-commits] 62/86: Add anti-float comparison tests, Andy Wingo, 2019/04/03
- [Guile-commits] 51/86: Add str tests, Andy Wingo, 2019/04/03
- [Guile-commits] 58/86: Add bltr test, Andy Wingo, 2019/04/03
- [Guile-commits] 65/86: Add add-and-branch-on-overflow tests, Andy Wingo, 2019/04/03
- [Guile-commits] 59/86: Add more integer reg/reg branch-and-compare tests, Andy Wingo, 2019/04/03
- [Guile-commits] 80/86: Add subdir-objects option to libguile makefile., Andy Wingo, 2019/04/03
- [Guile-commits] 82/86: Merge in changes from upstream lightening, Andy Wingo, 2019/04/03
- [Guile-commits] 68/86: Add push/pop test, Andy Wingo, 2019/04/03