guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 71/86: Add float/double cast inst tests


From: Andy Wingo
Subject: [Guile-commits] 71/86: Add float/double cast inst tests
Date: Wed, 3 Apr 2019 11:39:03 -0400 (EDT)

wingo pushed a commit to branch lightening
in repository guile.

commit ece71ef64c96717b1f50bcac2933a97075e9198c
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 26 22:29:48 2019 +0100

    Add float/double cast inst tests
---
 tests/extr_d_f.c | 30 ++++++++++++++++++++++++++++++
 tests/extr_f_d.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/tests/extr_d_f.c b/tests/extr_d_f.c
new file mode 100644
index 0000000..570bae8
--- /dev/null
+++ b/tests/extr_d_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_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_extr_d_f(j, JIT_F0, JIT_F0);
+  jit_retr_f(j, JIT_F0);
+
+  float (*f)(double) = jit_end(j, NULL);
+
+  ASSERT(f(0.0) == 0.0f);
+  ASSERT(f(0.5) == 0.5f);
+  ASSERT(f(1.0 / 0.0) == 1.0f / 0.0f);
+  ASSERT(f(1.25) == 1.25f);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/extr_f_d.c b/tests/extr_f_d.c
new file mode 100644
index 0000000..5e90be4
--- /dev/null
+++ b/tests/extr_f_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_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_extr_f_d(j, JIT_F0, JIT_F0);
+  jit_retr_d(j, JIT_F0);
+
+  double (*f)(float) = jit_end(j, NULL);
+
+  ASSERT(f(0.0f) == 0.0);
+  ASSERT(f(0.5f) == 0.5);
+  ASSERT(f(1.0f / 0.0f) == 1.0 / 0.0);
+  ASSERT(f(1.25f) == 1.25);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]