[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/21] tests/tcg/loongarch64: Add div and mod related instructions
From: |
Richard Henderson |
Subject: |
[PULL 12/21] tests/tcg/loongarch64: Add div and mod related instructions test |
Date: |
Tue, 19 Jul 2022 23:29:51 +0530 |
From: Song Gao <gaosong@loongson.cn>
This includes:
- DIV.{W[U]/D[U]}
- MOD.{W[U]/D[U]}
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20220716085426.3098060-6-gaosong@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tests/tcg/loongarch64/test_div.c | 54 +++++++++++++++++++++++++++
tests/tcg/loongarch64/Makefile.target | 1 +
2 files changed, 55 insertions(+)
create mode 100644 tests/tcg/loongarch64/test_div.c
diff --git a/tests/tcg/loongarch64/test_div.c b/tests/tcg/loongarch64/test_div.c
new file mode 100644
index 0000000000..6c31fe97ae
--- /dev/null
+++ b/tests/tcg/loongarch64/test_div.c
@@ -0,0 +1,54 @@
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+
+#define TEST_DIV(N, M) \
+static void test_div_ ##N(uint ## M ## _t rj, \
+ uint ## M ## _t rk, \
+ uint64_t rm) \
+{ \
+ uint64_t rd = 0; \
+ \
+ asm volatile("div."#N" %0,%1,%2\n\t" \
+ : "=r"(rd) \
+ : "r"(rj), "r"(rk) \
+ : ); \
+ assert(rd == rm); \
+}
+
+#define TEST_MOD(N, M) \
+static void test_mod_ ##N(uint ## M ## _t rj, \
+ uint ## M ## _t rk, \
+ uint64_t rm) \
+{ \
+ uint64_t rd = 0; \
+ \
+ asm volatile("mod."#N" %0,%1,%2\n\t" \
+ : "=r"(rd) \
+ : "r"(rj), "r"(rk) \
+ : ); \
+ assert(rd == rm); \
+}
+
+TEST_DIV(w, 32)
+TEST_DIV(wu, 32)
+TEST_DIV(d, 64)
+TEST_DIV(du, 64)
+TEST_MOD(w, 32)
+TEST_MOD(wu, 32)
+TEST_MOD(d, 64)
+TEST_MOD(du, 64)
+
+int main(void)
+{
+ test_div_w(0xffaced97, 0xc36abcde, 0x0);
+ test_div_wu(0xffaced97, 0xc36abcde, 0x1);
+ test_div_d(0xffaced973582005f, 0xef56832a358b, 0xffffffffffffffa8);
+ test_div_du(0xffaced973582005f, 0xef56832a358b, 0x11179);
+ test_mod_w(0x7cf18c32, 0xa04da650, 0x1d3f3282);
+ test_mod_wu(0x7cf18c32, 0xc04da650, 0x7cf18c32);
+ test_mod_d(0x7cf18c3200000000, 0xa04da65000000000, 0x1d3f328200000000);
+ test_mod_du(0x7cf18c3200000000, 0xc04da65000000000, 0x7cf18c3200000000);
+
+ return 0;
+}
diff --git a/tests/tcg/loongarch64/Makefile.target
b/tests/tcg/loongarch64/Makefile.target
index c0bd8b9b86..24d6bb11e9 100644
--- a/tests/tcg/loongarch64/Makefile.target
+++ b/tests/tcg/loongarch64/Makefile.target
@@ -11,5 +11,6 @@ VPATH += $(LOONGARCH64_SRC)
LDFLAGS+=-lm
LOONGARCH64_TESTS = test_bit
+LOONGARCH64_TESTS += test_div
TESTS += $(LOONGARCH64_TESTS)
--
2.34.1
- [PULL 02/21] target/loongarch: Fix loongarch_cpu_class_by_name, (continued)
- [PULL 02/21] target/loongarch: Fix loongarch_cpu_class_by_name, Richard Henderson, 2022/07/19
- [PULL 03/21] hw/intc/loongarch_pch_pic: Fix bugs for update_irq function, Richard Henderson, 2022/07/19
- [PULL 04/21] target/loongarch/cpu: Fix coverity errors about excp_names, Richard Henderson, 2022/07/19
- [PULL 05/21] target/loongarch/tlb_helper: Fix coverity integer overflow error, Richard Henderson, 2022/07/19
- [PULL 06/21] target/loongarch/op_helper: Fix coverity cond_at_most error, Richard Henderson, 2022/07/19
- [PULL 07/21] target/loongarch/cpu: Fix cpucfg default value, Richard Henderson, 2022/07/19
- [PULL 08/21] fpu/softfloat: Add LoongArch specializations for pickNaN*, Richard Henderson, 2022/07/19
- [PULL 09/21] target/loongarch: Fix float_convd/float_convs test failing, Richard Henderson, 2022/07/19
- [PULL 11/21] tests/tcg/loongarch64: Add clo related instructions test, Richard Henderson, 2022/07/19
- [PULL 10/21] tests/tcg/loongarch64: Add float reference files, Richard Henderson, 2022/07/19
- [PULL 12/21] tests/tcg/loongarch64: Add div and mod related instructions test,
Richard Henderson <=
- [PULL 13/21] tests/tcg/loongarch64: Add fclass test, Richard Henderson, 2022/07/19
- [PULL 14/21] tests/tcg/loongarch64: Add fp comparison instructions test, Richard Henderson, 2022/07/19
- [PULL 16/21] hw/loongarch: Add fw_cfg table support, Richard Henderson, 2022/07/19
- [PULL 17/21] hw/loongarch: Add uefi bios loading support, Richard Henderson, 2022/07/19
- [PULL 15/21] tests/tcg/loongarch64: Add pcadd related instructions test, Richard Henderson, 2022/07/19
- [PULL 18/21] hw/loongarch: Add linux kernel booting support, Richard Henderson, 2022/07/19
- [PULL 19/21] hw/loongarch: Add smbios support, Richard Henderson, 2022/07/19
- [PULL 20/21] hw/loongarch: Add acpi ged support, Richard Henderson, 2022/07/19