From patchwork Thu Nov 8 18:43:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fredrik Noring X-Patchwork-Id: 995140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nocrew.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42rXKn1RFJz9s8T for ; Fri, 9 Nov 2018 05:45:49 +1100 (AEDT) Received: from localhost ([::1]:58542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKpJK-00075a-Nd for incoming@patchwork.ozlabs.org; Thu, 08 Nov 2018 13:45:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKpIc-0006ye-Hx for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:45:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKpIW-0003B6-Cy for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:45:02 -0500 Received: from ste-pvt-msa1.bahnhof.se ([213.80.101.70]:30573) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKpIV-0002PI-R6 for qemu-devel@nongnu.org; Thu, 08 Nov 2018 13:44:56 -0500 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id BEDBB3F7AA; Thu, 8 Nov 2018 19:43:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bahnhof.se Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iRYpDMhthPjl; Thu, 8 Nov 2018 19:43:40 +0100 (CET) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 399C23F671; Thu, 8 Nov 2018 19:43:40 +0100 (CET) Date: Thu, 8 Nov 2018 19:43:40 +0100 From: Fredrik Noring To: Aleksandar Markovic , Aurelien Jarno , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.70 Subject: [Qemu-devel] [PATCH 2/2] tests/tcg/mips: Test user mode DMULT for the R5900 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?J=C3=BCrgen?= Urban , qemu-devel@nongnu.org, "Maciej W. Rozycki" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- tests/tcg/mips/mipsn32r5900/Makefile | 25 +++++++++++++++++ tests/tcg/mips/mipsn32r5900/dmult.c | 40 ++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile create mode 100644 tests/tcg/mips/mipsn32r5900/dmult.c diff --git a/tests/tcg/mips/mipsn32r5900/Makefile b/tests/tcg/mips/mipsn32r5900/Makefile new file mode 100644 index 0000000000..7dd16723fe --- /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) diff --git a/tests/tcg/mips/mipsn32r5900/dmult.c b/tests/tcg/mips/mipsn32r5900/dmult.c new file mode 100644 index 0000000000..2827ab5358 --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/dmult.c @@ -0,0 +1,40 @@ +/* + * Test DMULT. + */ + +#include +#include +#include + +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; +}