[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 36/42] tests/tcg/mips: Test user mode DMULT for the R5900
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 36/42] tests/tcg/mips: Test user mode DMULT for the R5900 |
Date: |
Sun, 14 Feb 2021 18:59:06 +0100 |
From: Fredrik Noring <noring@nocrew.org>
The R5900 reports itself as MIPS III but does not implement DMULT.
Verify that DMULT is emulated properly in user mode by multiplying
two 64-bit numbers to produce a 128-bit number.
Signed-off-by: Fredrik Noring <noring@nocrew.org>
Message-Id:
<b04427024562b10c852a5519b57033e094fcdc3b.1541701393.git.noring@nocrew.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
tests/tcg/mips/mipsn32r5900/dmult.c | 40 ++++++++++++++++++++++++++++
tests/tcg/mips/mipsn32r5900/Makefile | 25 +++++++++++++++++
2 files changed, 65 insertions(+)
create mode 100644 tests/tcg/mips/mipsn32r5900/dmult.c
create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile
diff --git a/tests/tcg/mips/mipsn32r5900/dmult.c
b/tests/tcg/mips/mipsn32r5900/dmult.c
new file mode 100644
index 00000000000..2827ab5358f
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/dmult.c
@@ -0,0 +1,40 @@
+/*
+ * Test DMULT.
+ */
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <assert.h>
+
+struct hi_lo { int64_t hi; uint64_t lo; };
+
+static struct hi_lo dmult(int64_t rs, int64_t rt)
+{
+ int64_t hi;
+ uint64_t lo;
+
+ /*
+ * The R5900 reports itself as MIPS III but does not implement DMULT.
+ * Verify that DMULT is emulated properly in user mode.
+ */
+ __asm__ __volatile__ (
+ " .set mips3\n"
+ " dmult %2, %3\n"
+ " mfhi %0\n"
+ " mflo %1\n"
+ : "=r" (hi), "=r" (lo)
+ : "r" (rs), "r" (rt));
+
+ return (struct hi_lo) { .hi = hi, .lo = lo };
+}
+
+int main()
+{
+ /* Verify that multiplying two 64-bit numbers yields a 128-bit number. */
+ struct hi_lo r = dmult(2760727302517, 5665449960167);
+
+ assert(r.hi == 847887);
+ assert(r.lo == 7893651516417804947);
+
+ return 0;
+}
diff --git a/tests/tcg/mips/mipsn32r5900/Makefile
b/tests/tcg/mips/mipsn32r5900/Makefile
new file mode 100644
index 00000000000..7dd16723fea
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/Makefile
@@ -0,0 +1,25 @@
+-include ../../config-host.mak
+
+CROSS=mips64r5900el-unknown-linux-gnu-
+
+SIM=qemu-mipsn32el
+SIM_FLAGS=-cpu R5900
+
+CC = $(CROSS)gcc
+CFLAGS = -Wall -mabi=n32 -march=r5900 -static
+
+TESTCASES = dmult.tst
+
+all: $(TESTCASES)
+
+%.tst: %.c
+ $(CC) $(CFLAGS) $< -o $@
+
+check: $(TESTCASES)
+ @for case in $(TESTCASES); do \
+ echo $(SIM) $(SIM_FLAGS) ./$$case;\
+ $(SIM) $(SIM_FLAGS) ./$$case; \
+ done
+
+clean:
+ $(RM) -rf $(TESTCASES)
--
2.26.2
- [RFC PATCH 30/42] target/mips: Reintroduce the R5900 CPU, (continued)
- [RFC PATCH 30/42] target/mips: Reintroduce the R5900 CPU, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 31/42] default-configs: Support o32 ABI with R5900 64-bit MIPS CPU, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 32/42] docker: Add gentoo-mipsr5900el-cross image, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 33/42] gitlab-ci: Pass optional EXTRA_FILES when building docker images, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 34/42] gitlab-ci: Build MIPS R5900 cross-toolchain (Gentoo based), Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 35/42] tests/tcg: Add MIPS R5900 to arches filter, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 36/42] tests/tcg/mips: Test user mode DMULT for the R5900,
Philippe Mathieu-Daudé <=
- [RFC PATCH 37/42] gitlab-ci: Add job to test the MIPS r5900o32el target, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 38/42] tests/acceptance: Extract QemuBaseTest from Test, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 39/42] tests/acceptance: Make pick_default_qemu_bin() more generic, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 40/42] tests/acceptance: Introduce QemuUserTest base class, Philippe Mathieu-Daudé, 2021/02/14
- [RFC PATCH 41/42] tests/acceptance: Test R5900 CPU with BusyBox from Sony PS2, Philippe Mathieu-Daudé, 2021/02/14