From: Fredrik Noring <noring@nocrew.org>
To: "Aleksandar Markovic" <amarkovic@wavecomp.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Jürgen Urban" <JuergenUrban@gmx.de>,
"Maciej W. Rozycki" <macro@linux-mips.org>,
qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 9/9] tests/tcg/mips: Test R5900 multimedia instruction SQ
Date: Sun, 13 Jan 2019 20:09:44 +0100 [thread overview]
Message-ID: <f12b05b6581daa925e253a9639dd44d34441a511.1547403692.git.noring@nocrew.org> (raw)
In-Reply-To: <cover.1547403692.git.noring@nocrew.org>
Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
tests/tcg/mips/mipsn32r5900/Makefile | 1 +
tests/tcg/mips/mipsn32r5900/sq.c | 105 +++++++++++++++++++++++++++
2 files changed, 106 insertions(+)
create mode 100644 tests/tcg/mips/mipsn32r5900/sq.c
diff --git a/tests/tcg/mips/mipsn32r5900/Makefile b/tests/tcg/mips/mipsn32r5900/Makefile
index cb3ef9d26a..a9e9481457 100644
--- a/tests/tcg/mips/mipsn32r5900/Makefile
+++ b/tests/tcg/mips/mipsn32r5900/Makefile
@@ -10,6 +10,7 @@ CFLAGS = -Wall -mabi=n32 -march=r5900 -static
TESTCASES = lq.tst
TESTCASES += pcpyuld.tst
+TESTCASES += sq.tst
all: $(TESTCASES)
diff --git a/tests/tcg/mips/mipsn32r5900/sq.c b/tests/tcg/mips/mipsn32r5900/sq.c
new file mode 100644
index 0000000000..97b21711ba
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/sq.c
@@ -0,0 +1,105 @@
+/*
+ * Test SQ.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#define GUARD_BYTE 0xA9
+
+/* 128-bit multimedia register */
+struct mmr { uint64_t hi, lo; } __attribute__((aligned(16)));
+
+static uint8_t data[64];
+
+#define SQ(value, base, offset) \
+ __asm__ __volatile__ ( \
+ " pcpyld %0, %0, %1\n" \
+ " sq %0, %3(%2)\n" \
+ : \
+ : "r" (value.hi), "r" (value.lo), \
+ "r" (base), "i" (offset))
+
+static void verify_sq(struct mmr value, const void *base, int16_t offset)
+{
+ /*
+ * The least significant four bits of the effective address are
+ * masked to zero, effectively creating an aligned address. No
+ * address exceptions due to alignment are possible.
+ */
+ const uint8_t *b = base;
+ const uint8_t *o = &b[offset];
+ const uint8_t *a = (const uint8_t*)((unsigned long)o & ~0xFUL);
+ size_t i;
+
+ for (i = 0; i < sizeof(data); i++) {
+ ssize_t d = &data[i] - &a[0];
+
+ if (d < 0) {
+ assert(data[i] == GUARD_BYTE);
+ } else if (d < 8) {
+ assert(data[i] == ((value.lo >> (8 * (d - 0))) & 0xFF));
+ } else if (d < 16) {
+ assert(data[i] == ((value.hi >> (8 * (d - 8))) & 0xFF));
+ } else {
+ assert(data[i] == GUARD_BYTE);
+ }
+ }
+}
+
+#define VERIFY_SQ(base, offset) \
+ do { \
+ struct mmr value = { \
+ .hi = 0x6665646362613938, \
+ .lo = 0x3736353433323130 \
+ }; \
+ \
+ memset(data, GUARD_BYTE, sizeof(data)); \
+ SQ(value, base, offset); \
+ verify_sq(value, base, offset); \
+ } while (0)
+
+int main()
+{
+ int i;
+
+ for (i = 16; i < 48; i++) {
+ VERIFY_SQ(&data[i], -16);
+ VERIFY_SQ(&data[i], -15);
+ VERIFY_SQ(&data[i], -14);
+ VERIFY_SQ(&data[i], -13);
+ VERIFY_SQ(&data[i], -12);
+ VERIFY_SQ(&data[i], -11);
+ VERIFY_SQ(&data[i], -10);
+ VERIFY_SQ(&data[i], -9);
+ VERIFY_SQ(&data[i], -8);
+ VERIFY_SQ(&data[i], -7);
+ VERIFY_SQ(&data[i], -6);
+ VERIFY_SQ(&data[i], -5);
+ VERIFY_SQ(&data[i], -4);
+ VERIFY_SQ(&data[i], -3);
+ VERIFY_SQ(&data[i], -2);
+ VERIFY_SQ(&data[i], -1);
+ VERIFY_SQ(&data[i], 0);
+ VERIFY_SQ(&data[i], 1);
+ VERIFY_SQ(&data[i], 2);
+ VERIFY_SQ(&data[i], 3);
+ VERIFY_SQ(&data[i], 4);
+ VERIFY_SQ(&data[i], 5);
+ VERIFY_SQ(&data[i], 6);
+ VERIFY_SQ(&data[i], 7);
+ VERIFY_SQ(&data[i], 8);
+ VERIFY_SQ(&data[i], 9);
+ VERIFY_SQ(&data[i], 10);
+ VERIFY_SQ(&data[i], 11);
+ VERIFY_SQ(&data[i], 12);
+ VERIFY_SQ(&data[i], 13);
+ VERIFY_SQ(&data[i], 14);
+ VERIFY_SQ(&data[i], 15);
+ VERIFY_SQ(&data[i], 16);
+ }
+
+ return 0;
+}
--
2.19.2
next prev parent reply other threads:[~2019-01-13 19:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-13 19:00 [Qemu-devel] [PATCH 0/9] target/mips: Limited support for R5900 multimedia instructions Fredrik Noring
2019-01-13 19:02 ` [Qemu-devel] [PATCH 1/9] target/mips: Require TARGET_MIPS64 " Fredrik Noring
2019-01-15 21:03 ` Aleksandar Markovic
2019-01-16 15:36 ` Fredrik Noring
2019-01-16 19:20 ` Aleksandar Markovic
2019-01-20 18:18 ` "Jürgen Urban"
2019-01-13 19:03 ` [Qemu-devel] [PATCH 2/9] target/mips: Introduce 32 R5900 128-bit multimedia registers Fredrik Noring
2019-01-15 21:20 ` Aleksandar Markovic
2019-01-17 17:03 ` Aleksandar Markovic
2019-01-13 19:03 ` [Qemu-devel] [PATCH 3/9] target/mips: Support the R5900 PCPYLD multimedia instruction Fredrik Noring
2019-01-15 21:24 ` Aleksandar Markovic
2019-01-13 19:04 ` [Qemu-devel] [PATCH 4/9] target/mips: Support the R5900 PCPYUD " Fredrik Noring
2019-01-15 21:28 ` Aleksandar Markovic
2019-01-13 19:05 ` [Qemu-devel] [PATCH 5/9] target/mips: Support the R5900 LQ " Fredrik Noring
2019-01-15 21:34 ` Aleksandar Markovic
2019-01-13 19:06 ` [Qemu-devel] [PATCH 6/9] target/mips: Support the R5900 SQ " Fredrik Noring
2019-01-15 21:37 ` Aleksandar Markovic
2019-01-13 19:07 ` [Qemu-devel] [PATCH 7/9] tests/tcg/mips: Test R5900 multimedia instructions PCPYUD and PCPYLD Fredrik Noring
2019-01-15 21:45 ` Aleksandar Markovic
2019-01-13 19:08 ` [Qemu-devel] [PATCH 8/9] tests/tcg/mips: Test R5900 multimedia instruction LQ Fredrik Noring
2019-01-15 21:56 ` Aleksandar Markovic
2019-01-13 19:09 ` Fredrik Noring [this message]
2019-01-15 21:57 ` [Qemu-devel] [PATCH 9/9] tests/tcg/mips: Test R5900 multimedia instruction SQ Aleksandar Markovic
2019-01-14 2:53 ` [Qemu-devel] [PATCH 0/9] target/mips: Limited support for R5900 multimedia instructions no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f12b05b6581daa925e253a9639dd44d34441a511.1547403692.git.noring@nocrew.org \
--to=noring@nocrew.org \
--cc=JuergenUrban@gmx.de \
--cc=amarkovic@wavecomp.com \
--cc=aurelien@aurel32.net \
--cc=f4bug@amsat.org \
--cc=macro@linux-mips.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).