Signed-off-by: Fredrik Noring <[email protected]>
---
tests/tcg/mips/mipsn32r5900/Makefile | 25 +++++++++++++++
tests/tcg/mips/mipsn32r5900/pcpyuld.c | 46 +++++++++++++++++++++++++++
2 files changed, 71 insertions(+)
create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile
create mode 100644 tests/tcg/mips/mipsn32r5900/pcpyuld.c
diff --git a/tests/tcg/mips/mipsn32r5900/Makefile
b/tests/tcg/mips/mipsn32r5900/Makefile
new file mode 100644
index 0000000000..f4887678ae
--- /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 = pcpyuld.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)
diff --git a/tests/tcg/mips/mipsn32r5900/pcpyuld.c
b/tests/tcg/mips/mipsn32r5900/pcpyuld.c
new file mode 100644
index 0000000000..c92af6330b
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/pcpyuld.c
@@ -0,0 +1,46 @@
+/*
+ * Test PCPYUD and PCPYLD.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+
+/* 128-bit multimedia register */
+struct mmr { uint64_t hi, lo; } __attribute__((aligned(16)));
+
+static void verify_zero(void)
+{
+ __asm__ __volatile__ (
+ " pcpyud $0, $0, $0\n"
+ " pcpyld $0, $0, $0\n"
+ );
+}
+
+static void verify_copy(void)
+{
+ const struct mmr value = {
+ .hi = 0x6665646362613938,
+ .lo = 0x3736353433323130
+ };
+ struct mmr result = { };
+
+ __asm__ __volatile__ (
+ " pcpyld %0, %2, %3\n"
+ " move %1, %0\n"
+ " pcpyud %0, %0, %0\n"
+ : "=r" (result.hi), "=r" (result.lo)
+ : "r" (value.hi), "r" (value.lo));
+
+ assert(value.hi == result.hi);
+ assert(value.lo == result.lo);
+}
+
+int main()
+{
+ verify_zero();
+ verify_copy();
+
+ return 0;
+}
--
2.19.2