[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 69/86: Add abs/sqrt tests
From: |
Andy Wingo |
Subject: |
[Guile-commits] 69/86: Add abs/sqrt tests |
Date: |
Wed, 3 Apr 2019 11:39:02 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 69665c7f80a0cf65859aba2e0e735a2f4f97ca69
Author: Andy Wingo <address@hidden>
Date: Tue Mar 26 22:01:52 2019 +0100
Add abs/sqrt tests
---
tests/absr_d.c | 30 ++++++++++++++++++++++++++++++
tests/absr_f.c | 30 ++++++++++++++++++++++++++++++
tests/sqrtr_d.c | 29 +++++++++++++++++++++++++++++
tests/sqrtr_f.c | 29 +++++++++++++++++++++++++++++
4 files changed, 118 insertions(+)
diff --git a/tests/absr_d.c b/tests/absr_d.c
new file mode 100644
index 0000000..5671c4f
--- /dev/null
+++ b/tests/absr_d.c
@@ -0,0 +1,30 @@
+#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_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_absr_d(j, JIT_F0, JIT_F0);
+ jit_retr_d(j, JIT_F0);
+
+ double (*f)(double) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0.0);
+ ASSERT(f(-0.0) == 0.0);
+ ASSERT(f(0.5) == 0.5);
+ ASSERT(f(-0.5) == 0.5);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/absr_f.c b/tests/absr_f.c
new file mode 100644
index 0000000..e93fb49
--- /dev/null
+++ b/tests/absr_f.c
@@ -0,0 +1,30 @@
+#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_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_absr_f(j, JIT_F0, JIT_F0);
+ jit_retr_f(j, JIT_F0);
+
+ float (*f)(float) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0.0);
+ ASSERT(f(-0.0) == 0.0);
+ ASSERT(f(0.5) == 0.5);
+ ASSERT(f(-0.5) == 0.5);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/sqrtr_d.c b/tests/sqrtr_d.c
new file mode 100644
index 0000000..cb17b56
--- /dev/null
+++ b/tests/sqrtr_d.c
@@ -0,0 +1,29 @@
+#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_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_sqrtr_d(j, JIT_F0, JIT_F0);
+ jit_retr_d(j, JIT_F0);
+
+ double (*f)(double) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0.0);
+ ASSERT(f(4.0) == 2.0);
+ ASSERT(f(-4.0) != f(-4.0)); // nan
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/sqrtr_f.c b/tests/sqrtr_f.c
new file mode 100644
index 0000000..ffa9211
--- /dev/null
+++ b/tests/sqrtr_f.c
@@ -0,0 +1,29 @@
+#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_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_sqrtr_f(j, JIT_F0, JIT_F0);
+ jit_retr_f(j, JIT_F0);
+
+ float (*f)(float) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0.0);
+ ASSERT(f(4.0) == 2.0);
+ ASSERT(f(-4.0) != f(-4.0)); // nan
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
- [Guile-commits] 61/86: Add int/int reg/imm compare-and-branch tests, (continued)
- [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, 2019/04/03
- [Guile-commits] 69/86: Add abs/sqrt tests,
Andy Wingo <=
- [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
- [Guile-commits] 70/86: Add truncr_[df]_[li] tests, Andy Wingo, 2019/04/03