guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 60/86: Add floating-point reg/reg compare-and-branch tes


From: Andy Wingo
Subject: [Guile-commits] 60/86: Add floating-point reg/reg compare-and-branch tests
Date: Wed, 3 Apr 2019 11:39:00 -0400 (EDT)

wingo pushed a commit to branch lightening
in repository guile.

commit ab0d17286a2390f602ead7a1be3554536a879d45
Author: Andy Wingo <address@hidden>
Date:   Tue Mar 26 14:43:53 2019 +0100

    Add floating-point reg/reg compare-and-branch tests
---
 tests/beqr_d.c | 34 ++++++++++++++++++++++++++++++++++
 tests/beqr_f.c | 34 ++++++++++++++++++++++++++++++++++
 tests/bger_d.c | 33 +++++++++++++++++++++++++++++++++
 tests/bger_f.c | 33 +++++++++++++++++++++++++++++++++
 tests/bgtr_d.c | 33 +++++++++++++++++++++++++++++++++
 tests/bgtr_f.c | 33 +++++++++++++++++++++++++++++++++
 tests/bler_d.c | 33 +++++++++++++++++++++++++++++++++
 tests/bler_f.c | 33 +++++++++++++++++++++++++++++++++
 tests/bltr_d.c | 33 +++++++++++++++++++++++++++++++++
 tests/bltr_f.c | 33 +++++++++++++++++++++++++++++++++
 tests/bner_d.c | 33 +++++++++++++++++++++++++++++++++
 tests/bner_f.c | 33 +++++++++++++++++++++++++++++++++
 12 files changed, 398 insertions(+)

diff --git a/tests/beqr_d.c b/tests/beqr_d.c
new file mode 100644
index 0000000..9bc6c0f
--- /dev/null
+++ b/tests/beqr_d.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_ABI_DOUBLE };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_beqr_d(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(double, double) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 1);
+  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);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/beqr_f.c b/tests/beqr_f.c
new file mode 100644
index 0000000..00e1fcc
--- /dev/null
+++ b/tests/beqr_f.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_ABI_FLOAT };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_beqr_f(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(float, float) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 1);
+  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);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bger_d.c b/tests/bger_d.c
new file mode 100644
index 0000000..24a52dc
--- /dev/null
+++ b/tests/bger_d.c
@@ -0,0 +1,33 @@
+#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_ABI_DOUBLE };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bger_d(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(double, double) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 1);
+  ASSERT(f(0, 1) == 0);
+  ASSERT(f(1, 0) == 1);
+  ASSERT(f(-1, 0) == 0);
+  ASSERT(f(0, -1) == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bger_f.c b/tests/bger_f.c
new file mode 100644
index 0000000..f068d77
--- /dev/null
+++ b/tests/bger_f.c
@@ -0,0 +1,33 @@
+#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_ABI_FLOAT };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bger_f(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(float, float) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 1);
+  ASSERT(f(0, 1) == 0);
+  ASSERT(f(1, 0) == 1);
+  ASSERT(f(-1, 0) == 0);
+  ASSERT(f(0, -1) == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bgtr_d.c b/tests/bgtr_d.c
new file mode 100644
index 0000000..5bc6914
--- /dev/null
+++ b/tests/bgtr_d.c
@@ -0,0 +1,33 @@
+#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_ABI_DOUBLE };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bgtr_d(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(double, double) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 0);
+  ASSERT(f(0, 1) == 0);
+  ASSERT(f(1, 0) == 1);
+  ASSERT(f(-1, 0) == 0);
+  ASSERT(f(0, -1) == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bgtr_f.c b/tests/bgtr_f.c
new file mode 100644
index 0000000..da271b7
--- /dev/null
+++ b/tests/bgtr_f.c
@@ -0,0 +1,33 @@
+#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_ABI_FLOAT };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bgtr_f(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(float, float) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 0);
+  ASSERT(f(0, 1) == 0);
+  ASSERT(f(1, 0) == 1);
+  ASSERT(f(-1, 0) == 0);
+  ASSERT(f(0, -1) == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bler_d.c b/tests/bler_d.c
new file mode 100644
index 0000000..9550043
--- /dev/null
+++ b/tests/bler_d.c
@@ -0,0 +1,33 @@
+#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_ABI_DOUBLE };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bler_d(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(double, double) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 1);
+  ASSERT(f(0, 1) == 1);
+  ASSERT(f(1, 0) == 0);
+  ASSERT(f(-1, 0) == 1);
+  ASSERT(f(0, -1) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bler_f.c b/tests/bler_f.c
new file mode 100644
index 0000000..751f2bb
--- /dev/null
+++ b/tests/bler_f.c
@@ -0,0 +1,33 @@
+#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_ABI_FLOAT };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bler_f(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(float, float) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 1);
+  ASSERT(f(0, 1) == 1);
+  ASSERT(f(1, 0) == 0);
+  ASSERT(f(-1, 0) == 1);
+  ASSERT(f(0, -1) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bltr_d.c b/tests/bltr_d.c
new file mode 100644
index 0000000..fd7daf2
--- /dev/null
+++ b/tests/bltr_d.c
@@ -0,0 +1,33 @@
+#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_ABI_DOUBLE };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bltr_d(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(double, double) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 0);
+  ASSERT(f(0, 1) == 1);
+  ASSERT(f(1, 0) == 0);
+  ASSERT(f(-1, 0) == 1);
+  ASSERT(f(0, -1) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bltr_f.c b/tests/bltr_f.c
new file mode 100644
index 0000000..20075e3
--- /dev/null
+++ b/tests/bltr_f.c
@@ -0,0 +1,33 @@
+#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_ABI_FLOAT };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bltr_f(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(float, float) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 0);
+  ASSERT(f(0, 1) == 1);
+  ASSERT(f(1, 0) == 0);
+  ASSERT(f(-1, 0) == 1);
+  ASSERT(f(0, -1) == 0);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bner_d.c b/tests/bner_d.c
new file mode 100644
index 0000000..a4d361b
--- /dev/null
+++ b/tests/bner_d.c
@@ -0,0 +1,33 @@
+#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_ABI_DOUBLE };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bner_d(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(double, double) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 0);
+  ASSERT(f(0, 1) == 1);
+  ASSERT(f(1, 0) == 1);
+  ASSERT(f(-1, 0) == 1);
+  ASSERT(f(0, -1) == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return main_helper(argc, argv, run_test);
+}
diff --git a/tests/bner_f.c b/tests/bner_f.c
new file mode 100644
index 0000000..e2badd9
--- /dev/null
+++ b/tests/bner_f.c
@@ -0,0 +1,33 @@
+#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_ABI_FLOAT };
+  jit_arg_t args[2];
+  const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
+
+  jit_receive(j, 2, abi, args);
+  jit_load_args(j, 2, abi, args, regs);
+
+  jit_reloc_t r = jit_bner_f(j, JIT_F0, JIT_F1);
+  jit_reti(j, 0);
+  jit_patch_here(j, r);
+  jit_reti(j, 1);
+
+  intmax_t (*f)(float, float) = jit_end(j, NULL);
+
+  ASSERT(f(0, 0) == 0);
+  ASSERT(f(0, 1) == 1);
+  ASSERT(f(1, 0) == 1);
+  ASSERT(f(-1, 0) == 1);
+  ASSERT(f(0, -1) == 1);
+}
+
+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]