[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/21] tests/tcg/loongarch64: Add clo related instructions test
|
From: |
Richard Henderson |
|
Subject: |
[PULL 11/21] tests/tcg/loongarch64: Add clo related instructions test |
|
Date: |
Tue, 19 Jul 2022 23:29:50 +0530 |
From: Song Gao <gaosong@loongson.cn>
This includes:
- CL{O/Z}.{W/D}
- CT{O/Z}.{W/D}
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20220716085426.3098060-5-gaosong@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tests/tcg/loongarch64/test_bit.c | 88 +++++++++++++++++++++++++++
tests/tcg/loongarch64/Makefile.target | 15 +++++
2 files changed, 103 insertions(+)
create mode 100644 tests/tcg/loongarch64/test_bit.c
create mode 100644 tests/tcg/loongarch64/Makefile.target
diff --git a/tests/tcg/loongarch64/test_bit.c b/tests/tcg/loongarch64/test_bit.c
new file mode 100644
index 0000000000..a6d9904909
--- /dev/null
+++ b/tests/tcg/loongarch64/test_bit.c
@@ -0,0 +1,88 @@
+#include <assert.h>
+#include <inttypes.h>
+
+#define ARRAY_SIZE(X) (sizeof(X) / sizeof(*(X)))
+#define TEST_CLO(N) \
+static uint64_t test_clo_##N(uint64_t rj) \
+{ \
+ uint64_t rd = 0; \
+ \
+ asm volatile("clo."#N" %0, %1\n\t" \
+ : "=r"(rd) \
+ : "r"(rj) \
+ : ); \
+ return rd; \
+}
+
+#define TEST_CLZ(N) \
+static uint64_t test_clz_##N(uint64_t rj) \
+{ \
+ uint64_t rd = 0; \
+ \
+ asm volatile("clz."#N" %0, %1\n\t" \
+ : "=r"(rd) \
+ : "r"(rj) \
+ : ); \
+ return rd; \
+}
+
+#define TEST_CTO(N) \
+static uint64_t test_cto_##N(uint64_t rj) \
+{ \
+ uint64_t rd = 0; \
+ \
+ asm volatile("cto."#N" %0, %1\n\t" \
+ : "=r"(rd) \
+ : "r"(rj) \
+ : ); \
+ return rd; \
+}
+
+#define TEST_CTZ(N) \
+static uint64_t test_ctz_##N(uint64_t rj) \
+{ \
+ uint64_t rd = 0; \
+ \
+ asm volatile("ctz."#N" %0, %1\n\t" \
+ : "=r"(rd) \
+ : "r"(rj) \
+ : ); \
+ return rd; \
+}
+
+TEST_CLO(w)
+TEST_CLO(d)
+TEST_CLZ(w)
+TEST_CLZ(d)
+TEST_CTO(w)
+TEST_CTO(d)
+TEST_CTZ(w)
+TEST_CTZ(d)
+
+struct vector {
+ uint64_t (*func)(uint64_t);
+ uint64_t u;
+ uint64_t r;
+};
+
+static struct vector vectors[] = {
+ {test_clo_w, 0xfff11fff392476ab, 0},
+ {test_clo_d, 0xabd28a64000000, 0},
+ {test_clz_w, 0xfaffff42392476ab, 2},
+ {test_clz_d, 0xabd28a64000000, 8},
+ {test_cto_w, 0xfff11fff392476ab, 2},
+ {test_cto_d, 0xabd28a64000000, 0},
+ {test_ctz_w, 0xfaffff42392476ab, 0},
+ {test_ctz_d, 0xabd28a64000000, 26},
+};
+
+int main()
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(vectors); i++) {
+ assert((*vectors[i].func)(vectors[i].u) == vectors[i].r);
+ }
+
+ return 0;
+}
diff --git a/tests/tcg/loongarch64/Makefile.target
b/tests/tcg/loongarch64/Makefile.target
new file mode 100644
index 0000000000..c0bd8b9b86
--- /dev/null
+++ b/tests/tcg/loongarch64/Makefile.target
@@ -0,0 +1,15 @@
+# -*- Mode: makefile -*-
+#
+# LoongArch64 specific tweaks
+
+# Loongarch64 doesn't support gdb, so skip the EXTRA_RUNS
+EXTRA_RUNS =
+
+LOONGARCH64_SRC=$(SRC_PATH)/tests/tcg/loongarch64
+VPATH += $(LOONGARCH64_SRC)
+
+LDFLAGS+=-lm
+
+LOONGARCH64_TESTS = test_bit
+
+TESTS += $(LOONGARCH64_TESTS)
--
2.34.1
- [PULL 00/21] loongarch patch queue, Richard Henderson, 2022/07/19
- [PULL 01/21] tests/docker/dockerfiles: Add debian-loongarch-cross.docker, Richard Henderson, 2022/07/19
- [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 <=
- [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, 2022/07/19
- [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