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 v2 06/12] tests/tcg/mips: Test R5900 three-operand MADD
Date: Thu, 1 Nov 2018 18:35:24 +0100 [thread overview]
Message-ID: <ac0bb45b84ccff38f996689d20851507a5a53771.1541093316.git.noring@nocrew.org> (raw)
In-Reply-To: <cover.1541093316.git.noring@nocrew.org>
Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
tests/tcg/mips/mipsr5900/Makefile | 1 +
tests/tcg/mips/mipsr5900/madd.c | 45 +++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 tests/tcg/mips/mipsr5900/madd.c
diff --git a/tests/tcg/mips/mipsr5900/Makefile b/tests/tcg/mips/mipsr5900/Makefile
index a1c388bc3c..97ca2a671c 100644
--- a/tests/tcg/mips/mipsr5900/Makefile
+++ b/tests/tcg/mips/mipsr5900/Makefile
@@ -10,6 +10,7 @@ CFLAGS = -Wall -mabi=32 -march=r5900 -static
TESTCASES = div1.tst
TESTCASES += divu1.tst
+TESTCASES += madd.tst
TESTCASES += mflohi1.tst
TESTCASES += mtlohi1.tst
TESTCASES += mult.tst
diff --git a/tests/tcg/mips/mipsr5900/madd.c b/tests/tcg/mips/mipsr5900/madd.c
new file mode 100644
index 0000000000..9ad2ea6dbb
--- /dev/null
+++ b/tests/tcg/mips/mipsr5900/madd.c
@@ -0,0 +1,45 @@
+/*
+ * Test R5900-specific three-operand MADD.
+ */
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <assert.h>
+
+int64_t madd(int64_t a, int32_t rs, int32_t rt)
+{
+ int32_t lo = a;
+ int32_t hi = a >> 32;
+ int32_t rd;
+ int64_t r;
+
+ __asm__ __volatile__ (
+ " mtlo %5\n"
+ " mthi %6\n"
+ " madd %0, %3, %4\n"
+ " mflo %1\n"
+ " mfhi %2\n"
+ : "=r" (rd), "=r" (lo), "=r" (hi)
+ : "r" (rs), "r" (rt), "r" (lo), "r" (hi));
+ r = ((int64_t)hi << 32) | (uint32_t)lo;
+
+ assert(a + (int64_t)rs * rt == r);
+ assert(rd == lo);
+
+ return r;
+}
+
+static void verify_madd(int64_t a, int32_t rs, int32_t rt, int64_t expected)
+{
+ assert(madd(a, rs, rt) == expected);
+ assert(madd(a, -rs, rt) == a + a - expected);
+ assert(madd(a, rs, -rt) == a + a - expected);
+ assert(madd(a, -rs, -rt) == expected);
+}
+
+int main()
+{
+ verify_madd(13, 17, 19, 336);
+
+ return 0;
+}
--
2.18.1
next prev parent reply other threads:[~2018-11-01 17:35 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-01 17:33 [Qemu-devel] [PATCH v2 00/12] target/mips: Amend R5900 support Fredrik Noring
2018-11-01 17:34 ` [Qemu-devel] [PATCH v2 01/12] target/mips: Generate R5900 MFLO1, MFHI1, MTLO1 and MTHI1 in gen_HILO1_tx79 Fredrik Noring
2018-11-01 17:34 ` [Qemu-devel] [PATCH v2 02/12] target/mips: Generate R5900 DIV1 and DIVU1 in gen_div1_tx79 Fredrik Noring
2018-11-01 17:34 ` [Qemu-devel] [PATCH v2 03/12] target/mips: R5900 LQ and SQ also belong to the Toshiba MMI ASE Fredrik Noring
2018-11-01 17:35 ` [Qemu-devel] [PATCH v2 04/12] target/mips: Support Toshiba specific three-operand MADD and MADDU Fredrik Noring
2018-12-27 21:00 ` Aleksandar Markovic
2018-11-01 17:35 ` [Qemu-devel] [PATCH v2 05/12] target/mips: Support R5900 three-operand MADD1 and MADDU1 Fredrik Noring
2018-12-27 21:01 ` Aleksandar Markovic
2018-11-01 17:35 ` Fredrik Noring [this message]
2018-12-27 21:02 ` [Qemu-devel] [PATCH v2 06/12] tests/tcg/mips: Test R5900 three-operand MADD Aleksandar Markovic
2018-11-01 17:35 ` [Qemu-devel] [PATCH v2 07/12] tests/tcg/mips: Test R5900 three-operand MADD1 Fredrik Noring
2018-12-27 21:02 ` Aleksandar Markovic
2018-11-01 17:35 ` [Qemu-devel] [PATCH v2 08/12] tests/tcg/mips: Test R5900 three-operand MADDU Fredrik Noring
2018-12-27 21:03 ` Aleksandar Markovic
2018-11-01 17:35 ` [Qemu-devel] [PATCH v2 09/12] tests/tcg/mips: Test R5900 three-operand MADDU1 Fredrik Noring
2018-12-27 21:03 ` Aleksandar Markovic
2019-01-01 18:27 ` Fredrik Noring
2019-01-04 15:03 ` Aleksandar Markovic
2019-01-07 16:51 ` Fredrik Noring
2019-01-13 18:57 ` Fredrik Noring
2019-01-14 0:44 ` Aleksandar Markovic
2019-01-14 19:49 ` Fredrik Noring
2019-01-15 2:58 ` Aleksandar Markovic
2018-11-01 17:36 ` [Qemu-devel] [PATCH v2 10/12] disas/mips: Increase 'member of ISAs' flag holder size Fredrik Noring
2018-11-01 17:36 ` [Qemu-devel] [PATCH v2 11/12] disas/mips: Define R5900 disassembly constants Fredrik Noring
2018-11-01 17:36 ` [Qemu-devel] [PATCH v2 12/12] disas/mips: Disassemble R5900 DIV[U]1, M{F, T}{LO, HI}1 and MULT[U]1 Fredrik Noring
2018-11-05 15:04 ` Aleksandar Markovic
2018-11-07 19:10 ` Fredrik Noring
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=ac0bb45b84ccff38f996689d20851507a5a53771.1541093316.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).