[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/8] tests/tcg/loongarch64: Add pcadd related instructions test
From: |
Song Gao |
Subject: |
[PATCH 8/8] tests/tcg/loongarch64: Add pcadd related instructions test |
Date: |
Sat, 16 Jul 2022 16:54:26 +0800 |
This includes:
- PCADDI
- PCADDU12I
- PCADDU18I
- PCALAU12I
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
tests/tcg/loongarch64/Makefile.target | 1 +
tests/tcg/loongarch64/test_pcadd.c | 38 +++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
create mode 100644 tests/tcg/loongarch64/test_pcadd.c
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)
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;
+}
--
2.31.1
- [PATCH 0/8] tests/tcg/loongarch64: Add some tests., Song Gao, 2022/07/16
- [PATCH 5/8] tests/tcg/loongarch64: Add div and mod related instructions test, Song Gao, 2022/07/16
- [PATCH 4/8] tests/tcg/loongarch64: Add clo related instructions test, Song Gao, 2022/07/16
- [PATCH 1/8] tests/tcg/loongarch64: Add float reference files, Song Gao, 2022/07/16
- [PATCH 6/8] tests/tcg/loongarch64: Add fclass test, Song Gao, 2022/07/16
- [PATCH 2/8] fpu/softfloat: Add LoongArch specialization for pickNaNMulAdd, Song Gao, 2022/07/16
- [PATCH 8/8] tests/tcg/loongarch64: Add pcadd related instructions test,
Song Gao <=
- [PATCH 3/8] target/loongarch: Fix float_convd/float_convs test failing, Song Gao, 2022/07/16
- [PATCH 7/8] tests/tcg/loongarch64: Add som comparison instructions test, Song Gao, 2022/07/16
- Re: [PATCH 0/8] tests/tcg/loongarch64: Add some tests., Richard Henderson, 2022/07/19