From nobody Wed Nov 19 00:18:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.46 as permitted sender) client-ip=209.85.221.46; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f46.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1613325736; cv=none; d=zohomail.com; s=zohoarc; b=YaRozKiBef+/Tq/nCmnt1Eh/QXf4byH7yK9XTRbSFtNyegUbmsAk/l+1DUuhPLyDqCcRsCWAShEvBxvxQJIGdZ/Cg2Abfd0JTuk4gWsiZ8p/uKBJtAu546Ux/NEs561h5siX6mw+70PiImkK3y+jcQ3oI1H4ndMRA1DHH4uqna0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613325736; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2vMyIhd6/VBZs5ihm1NaO9PG2ec31gzKDVWlQG7z8HU=; b=N0RoBwebMNKtr6tbctw0jJkXFJTiznFDzvYPLzzm/SF8II1xjhw5HFClW4GHb3GJzKa9X//uP6MQGYEs3a2fk5O6jX272LzdmFFvlg3e355n/RVzkscabAA0uF/BYIoUGDKyvF+IQkIdYx/DuPnJnBa6WIuB5+b2c1/sbs8V6X4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mx.zohomail.com with SMTPS id 1613325736372943.0137031156336; Sun, 14 Feb 2021 10:02:16 -0800 (PST) Received: by mail-wr1-f46.google.com with SMTP id t15so6053098wrx.13 for ; Sun, 14 Feb 2021 10:02:15 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id k11sm20150228wrl.84.2021.02.14.10.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 10:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2vMyIhd6/VBZs5ihm1NaO9PG2ec31gzKDVWlQG7z8HU=; b=r3R1W83eptrSLJql6b+Bx6N2/n4fwaszbEkWzmiumAKJfaiiArM6KbU2Ai9TUUdn9b +49A3iJqqPb98lNeOKnNymwteN6hd/cxbu1mISpOJZ9MBevZcCCe9AgEaTotSpR52jIy xwfrUDrjV56F1s2uuvdqPIYktjZGs/srDKBrrqlVZv96hlowDAJT6k1mASlNuxC0fuxS NRfUlYHoprWWZtqFLiUZuUacOYeSlBzD2I1wue0z26T/g/I4wdeDGPPpceecFMHaaYh/ Akj5licEsoMVpdTv5Rqugkz9bH94qpA63KS+xL6g20aZl8ey97L9EcUG9KfPS3C3zTdg mTlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2vMyIhd6/VBZs5ihm1NaO9PG2ec31gzKDVWlQG7z8HU=; b=TyfDLxfsY89p2RQhdIpo9Bx5BwLzRjvDLhJoi03ZKGIOw8ORZwwzd6c2hhDS6zv9H7 QtMwx/Kgczg4qHD4zd+I+J37/YDBwoWmUbcGpZT8hkktHYH/PMZAQcN7xFjMJjTXf5iR 04E/Blc86GTkIFUZJuU8SlmwMlDiPZnzkIaV/sFFjdAzTQaZIJ6y8ridmRHI15GZY1tU D21rnJxJV5GrPpZfIVb6i6qcURcwgDPPSv+pScNFN7xSAdA66AwPhS1eS+UDz+IxguPx Ijf1QZ0CLLJIU+8VKFcRCQUDT5cCgLLcElNTMwEAqRaBpLSvUp7Sr87gSqg1j3A9ThVS Lmjg== X-Gm-Message-State: AOAM533PT4ZL+j7hDeIDnSV/b6ylFmmjV2YyyzOdsHCzHe2ngCguGlRf vPlJS0c7tsEKht18jm9xa5+ruXk6SxA= X-Google-Smtp-Source: ABdhPJxKuWc+zHmYIJFlZbqSkrb38ulUg+e4f8WKu8hLaqGvaMun3AsWWCoBGCQqzu9R1zpvILkH+Q== X-Received: by 2002:a5d:6942:: with SMTP id r2mr9563940wrw.222.1613325735005; Sun, 14 Feb 2021 10:02:15 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Fredrik Noring , Laurent Vivier , Jiaxun Yang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Maciej W. Rozycki" , Thomas Huth , Aurelien Jarno , Richard Henderson , Aleksandar Rikalo Subject: [RFC PATCH 36/42] tests/tcg/mips: Test user mode DMULT for the R5900 Date: Sun, 14 Feb 2021 18:59:06 +0100 Message-Id: <20210214175912.732946-37-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210214175912.732946-1-f4bug@amsat.org> References: <20210214175912.732946-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Fredrik Noring 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 Message-Id: Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/tcg/mips/mipsn32r5900/dmult.c | 40 ++++++++++++++++++++++++++++ tests/tcg/mips/mipsn32r5900/Makefile | 25 +++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/tcg/mips/mipsn32r5900/dmult.c create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile diff --git a/tests/tcg/mips/mipsn32r5900/dmult.c b/tests/tcg/mips/mipsn32r5= 900/dmult.c new file mode 100644 index 00000000000..2827ab5358f --- /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" + : "=3Dr" (hi), "=3Dr" (lo) + : "r" (rs), "r" (rt)); + + return (struct hi_lo) { .hi =3D hi, .lo =3D lo }; +} + +int main() +{ + /* Verify that multiplying two 64-bit numbers yields a 128-bit number.= */ + struct hi_lo r =3D dmult(2760727302517, 5665449960167); + + assert(r.hi =3D=3D 847887); + assert(r.lo =3D=3D 7893651516417804947); + + return 0; +} diff --git a/tests/tcg/mips/mipsn32r5900/Makefile b/tests/tcg/mips/mipsn32r= 5900/Makefile new file mode 100644 index 00000000000..7dd16723fea --- /dev/null +++ b/tests/tcg/mips/mipsn32r5900/Makefile @@ -0,0 +1,25 @@ +-include ../../config-host.mak + +CROSS=3Dmips64r5900el-unknown-linux-gnu- + +SIM=3Dqemu-mipsn32el +SIM_FLAGS=3D-cpu R5900 + +CC =3D $(CROSS)gcc +CFLAGS =3D -Wall -mabi=3Dn32 -march=3Dr5900 -static + +TESTCASES =3D 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) --=20 2.26.2