[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 70/86: Add truncr_[df]_[li] tests
From: |
Andy Wingo |
Subject: |
[Guile-commits] 70/86: Add truncr_[df]_[li] tests |
Date: |
Wed, 3 Apr 2019 11:39:02 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 44fc164098d5c395c537270a05ce72989261767f
Author: Andy Wingo <address@hidden>
Date: Tue Mar 26 22:26:05 2019 +0100
Add truncr_[df]_[li] tests
---
tests/truncr_d_i.c | 34 ++++++++++++++++++++++++++++++++++
tests/truncr_d_l.c | 36 ++++++++++++++++++++++++++++++++++++
tests/truncr_f_i.c | 34 ++++++++++++++++++++++++++++++++++
tests/truncr_f_l.c | 36 ++++++++++++++++++++++++++++++++++++
4 files changed, 140 insertions(+)
diff --git a/tests/truncr_d_i.c b/tests/truncr_d_i.c
new file mode 100644
index 0000000..c703ae8
--- /dev/null
+++ b/tests/truncr_d_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)
+{
+ 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_truncr_d_i(j, JIT_R0, JIT_F0);
+ jit_retr(j, JIT_R0);
+
+ int (*f)(double) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0);
+ ASSERT(f(-0.0) == 0);
+ ASSERT(f(0.5) == 0);
+ ASSERT(f(-0.5) == 0);
+ ASSERT(f(1.5) == 1);
+ ASSERT(f(-1.5) == -1);
+ ASSERT(f(2.5) == 2);
+ ASSERT(f(-2.5) == -2);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/truncr_d_l.c b/tests/truncr_d_l.c
new file mode 100644
index 0000000..752a76f
--- /dev/null
+++ b/tests/truncr_d_l.c
@@ -0,0 +1,36 @@
+#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_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_truncr_d_l(j, JIT_R0, JIT_F0);
+ jit_retr(j, JIT_R0);
+
+ int64_t (*f)(double) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0);
+ ASSERT(f(-0.0) == 0);
+ ASSERT(f(0.5) == 0);
+ ASSERT(f(-0.5) == 0);
+ ASSERT(f(1.5) == 1);
+ ASSERT(f(-1.5) == -1);
+ ASSERT(f(2.5) == 2);
+ ASSERT(f(-2.5) == -2);
+#endif
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/truncr_f_i.c b/tests/truncr_f_i.c
new file mode 100644
index 0000000..32fd71f
--- /dev/null
+++ b/tests/truncr_f_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)
+{
+ 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_truncr_f_i(j, JIT_R0, JIT_F0);
+ jit_retr(j, JIT_R0);
+
+ int (*f)(float) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0);
+ ASSERT(f(-0.0) == 0);
+ ASSERT(f(0.5) == 0);
+ ASSERT(f(-0.5) == 0);
+ ASSERT(f(1.5) == 1);
+ ASSERT(f(-1.5) == -1);
+ ASSERT(f(2.5) == 2);
+ ASSERT(f(-2.5) == -2);
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
diff --git a/tests/truncr_f_l.c b/tests/truncr_f_l.c
new file mode 100644
index 0000000..af3a116
--- /dev/null
+++ b/tests/truncr_f_l.c
@@ -0,0 +1,36 @@
+#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_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_truncr_f_l(j, JIT_R0, JIT_F0);
+ jit_retr(j, JIT_R0);
+
+ int64_t (*f)(float) = jit_end(j, NULL);
+
+ ASSERT(f(0.0) == 0);
+ ASSERT(f(-0.0) == 0);
+ ASSERT(f(0.5) == 0);
+ ASSERT(f(-0.5) == 0);
+ ASSERT(f(1.5) == 1);
+ ASSERT(f(-1.5) == -1);
+ ASSERT(f(2.5) == 2);
+ ASSERT(f(-2.5) == -2);
+#endif
+}
+
+int
+main (int argc, char *argv[])
+{
+ return main_helper(argc, argv, run_test);
+}
- [Guile-commits] 69/86: Add abs/sqrt tests, (continued)
- [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
- [Guile-commits] 70/86: Add truncr_[df]_[li] tests,
Andy Wingo <=
- [Guile-commits] 72/86: Add int->float tests, Andy Wingo, 2019/04/03
- [Guile-commits] 54/86: Add stxi tests, Andy Wingo, 2019/04/03
- [Guile-commits] 16/86: Create beginning of stripped-down lightning interface, Andy Wingo, 2019/04/03
- [Guile-commits] 84/86: Allow users to pass custom allocators, Andy Wingo, 2019/04/03
- [Guile-commits] 85/86: Fix jit_reset to be useful, Andy Wingo, 2019/04/03
- [Guile-commits] 76/86: Implement arg shuffling for jit_call{i,r}, Andy Wingo, 2019/04/03
- [Guile-commits] 86/86: Merge from upstream Lightening, Andy Wingo, 2019/04/03
- [Guile-commits] 81/86: Change headers and files to be named "lightening" instead of "jit", Andy Wingo, 2019/04/03
- [Guile-commits] 71/86: Add float/double cast inst tests, Andy Wingo, 2019/04/03
- [Guile-commits] 60/86: Add floating-point reg/reg compare-and-branch tests, Andy Wingo, 2019/04/03