[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/21] tests/tcg/loongarch64: Add pcadd related instructions test
From: |
Richard Henderson |
Subject: |
[PULL 15/21] tests/tcg/loongarch64: Add pcadd related instructions test |
Date: |
Tue, 19 Jul 2022 23:29:54 +0530 |
From: Song Gao <gaosong@loongson.cn>
This includes:
- PCADDI
- PCADDU12I
- PCADDU18I
- PCALAU12I
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20220716085426.3098060-9-gaosong@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tests/tcg/loongarch64/test_pcadd.c | 38 +++++++++++++++++++++++++++
tests/tcg/loongarch64/Makefile.target | 1 +
2 files changed, 39 insertions(+)
create mode 100644 tests/tcg/loongarch64/test_pcadd.c
diff --git a/tests/tcg/loongarch64/test_pcadd.c
b/tests/tcg/loongarch64/test_pcadd.c
new file mode 100644
index 0000000000..da2a64db82
--- /dev/null
+++ b/tests/tcg/loongarch64/test_pcadd.c
@@ -0,0 +1,38 @@
+#include <assert.h>
+#include <inttypes.h>
+#include <string.h>
+
+#define TEST_PCADDU(N) \
+void test_##N(int a) \
+{ \
+ uint64_t rd1 = 0; \
+ uint64_t rd2 = 0; \
+ uint64_t rm, rn; \
+ \
+ asm volatile(""#N" %0, 0x104\n\t" \
+ ""#N" %1, 0x12345\n\t" \
+ : "=r"(rd1), "=r"(rd2) \
+ : ); \
+ rm = rd2 - rd1; \
+ if (!strcmp(#N, "pcalau12i")) { \
+ rn = ((0x12345UL - 0x104) << a) & ~0xfff; \
+ } else { \
+ rn = ((0x12345UL - 0x104) << a) + 4; \
+ } \
+ assert(rm == rn); \
+}
+
+TEST_PCADDU(pcaddi)
+TEST_PCADDU(pcaddu12i)
+TEST_PCADDU(pcaddu18i)
+TEST_PCADDU(pcalau12i)
+
+int main()
+{
+ test_pcaddi(2);
+ test_pcaddu12i(12);
+ test_pcaddu18i(18);
+ test_pcalau12i(12);
+
+ return 0;
+}
diff --git a/tests/tcg/loongarch64/Makefile.target
b/tests/tcg/loongarch64/Makefile.target
index b320d9fd9c..0115de78ef 100644
--- a/tests/tcg/loongarch64/Makefile.target
+++ b/tests/tcg/loongarch64/Makefile.target
@@ -14,5 +14,6 @@ LOONGARCH64_TESTS = test_bit
LOONGARCH64_TESTS += test_div
LOONGARCH64_TESTS += test_fclass
LOONGARCH64_TESTS += test_fpcom
+LOONGARCH64_TESTS += test_pcadd
TESTS += $(LOONGARCH64_TESTS)
--
2.34.1
- [PULL 07/21] target/loongarch/cpu: Fix cpucfg default value, (continued)
- [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, 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 <=
- [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
- [PULL 21/21] hw/loongarch: Add fdt support, Richard Henderson, 2022/07/19
- Re: [PULL 00/21] loongarch patch queue, Peter Maydell, 2022/07/20