All of lore.kernel.org
 help / color / mirror / Atom feed
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 06/11] tests/tcg/mips: Test R5900 three-operand MADD1
Date: Thu, 25 Oct 2018 19:32:50 +0200	[thread overview]
Message-ID: <edd7dd4e42e2b874333999341734cb6acfe8df82.1540487815.git.noring@nocrew.org> (raw)
In-Reply-To: <cover.1540487815.git.noring@nocrew.org>

Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 tests/tcg/mips/mipsr5900/madd.c | 43 +++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/tests/tcg/mips/mipsr5900/madd.c b/tests/tcg/mips/mipsr5900/madd.c
index 9ad2ea6dbb..f6f215e1c3 100644
--- a/tests/tcg/mips/mipsr5900/madd.c
+++ b/tests/tcg/mips/mipsr5900/madd.c
@@ -1,5 +1,5 @@
 /*
- * Test R5900-specific three-operand MADD.
+ * Test R5900-specific three-operand MADD and MADD1.
  */
 
 #include <stdio.h>
@@ -29,12 +29,45 @@ int64_t madd(int64_t a, int32_t rs, int32_t rt)
     return r;
 }
 
+int64_t madd1(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__ (
+            "    mtlo1 %5\n"
+            "    mthi1 %6\n"
+            "    madd1 %0, %3, %4\n"
+            "    mflo1 %1\n"
+            "    mfhi1 %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 int64_t madd_variants(int64_t a, int32_t rs, int32_t rt)
+{
+    int64_t rd  = madd(a, rs, rt);
+    int64_t rd1 = madd1(a, rs, rt);
+
+    assert(rd == rd1);
+
+    return rd;
+}
+
 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);
+    assert(madd_variants(a, rs, rt) == expected);
+    assert(madd_variants(a, -rs, rt) == a + a - expected);
+    assert(madd_variants(a, rs, -rt) == a + a - expected);
+    assert(madd_variants(a, -rs, -rt) == expected);
 }
 
 int main()
-- 
2.18.1

  parent reply	other threads:[~2018-10-25 17:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 17:28 [Qemu-devel] [PATCH 00/11] target/mips: Amend R5900 support Fredrik Noring
2018-10-25 17:30 ` [Qemu-devel] [PATCH 01/11] target/mips: Rename ASE_MMI to ASE_TOSHIBA_MMI, with Toshiba namespace Fredrik Noring
2018-10-26 14:00   ` Aleksandar Markovic
2018-10-25 17:30 ` [Qemu-devel] [PATCH 02/11] target/mips: R5900 LQ and SQ also belong to the Toshiba MMI ASE Fredrik Noring
2018-10-25 17:31 ` [Qemu-devel] [PATCH 03/11] target/mips: Support Toshiba specific three-operand MADD and MADDU Fredrik Noring
2018-10-25 17:32 ` [Qemu-devel] [PATCH 04/11] target/mips: Support R5900 three-operand MADD1 and MADDU1 Fredrik Noring
2018-10-25 17:32 ` [Qemu-devel] [PATCH 05/11] tests/tcg/mips: Test R5900 three-operand MADD Fredrik Noring
2018-10-25 17:32 ` Fredrik Noring [this message]
2018-10-25 17:33 ` [Qemu-devel] [PATCH 07/11] tests/tcg/mips: Test R5900 three-operand MADDU Fredrik Noring
2018-10-25 17:33 ` [Qemu-devel] [PATCH 08/11] tests/tcg/mips: Test R5900 three-operand MADDU1 Fredrik Noring
2018-10-25 17:34 ` [Qemu-devel] [PATCH 09/11] disas/mips: Increase 'member of ISAs' flag holder size Fredrik Noring
2018-10-25 17:34 ` [Qemu-devel] [PATCH 10/11] disas/mips: Define R5900 disassembly constants Fredrik Noring
2018-10-25 17:34 ` [Qemu-devel] [PATCH 11/11] disas/mips: Disassemble R5900 DIV[U]1, M{F, T}{LO, HI}1 and MULT[U]1 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=edd7dd4e42e2b874333999341734cb6acfe8df82.1540487815.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.