From nobody Tue Feb 10 20:49:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657961841976628.938953805553; Sat, 16 Jul 2022 01:57:21 -0700 (PDT) Received: from localhost ([::1]:58518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oCdc0-00004v-Qr for importer@patchew.org; Sat, 16 Jul 2022 04:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oCdZO-0005cr-Nu for qemu-devel@nongnu.org; Sat, 16 Jul 2022 04:54:42 -0400 Received: from mail.loongson.cn ([114.242.206.163]:50142 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oCdZL-0006eg-PD for qemu-devel@nongnu.org; Sat, 16 Jul 2022 04:54:38 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxz9PCfNJijWQiAA--.28082S7; Sat, 16 Jul 2022 16:54:31 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, alex.bennee@linaro.org, f4bug@amsat.org, gaosong@loongson.cn, peter.maydell@linaro.org, yangxiaojuan@loongson.cn Subject: [PATCH 5/8] tests/tcg/loongarch64: Add div and mod related instructions test Date: Sat, 16 Jul 2022 16:54:23 +0800 Message-Id: <20220716085426.3098060-6-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220716085426.3098060-1-gaosong@loongson.cn> References: <20220716085426.3098060-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9Dxz9PCfNJijWQiAA--.28082S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Cw1fCF1rJFyxXw4rZFyxXwb_yoW8tF1rpr 1UCF1rKrWxGFWS9r1fJry5WF1ftan3ua4UZa47Gw12v397uryxZw1UKrnrXFW7Ka18Wr42 v3s5ZrWag3WUtaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1657961844047100001 Content-Type: text/plain; charset="utf-8" This includes: - DIV.{W[U]/D[U]} - MOD.{W[U]/D[U]} Signed-off-by: Song Gao --- tests/tcg/loongarch64/Makefile.target | 1 + tests/tcg/loongarch64/test_div.c | 54 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/tcg/loongarch64/test_div.c diff --git a/tests/tcg/loongarch64/Makefile.target b/tests/tcg/loongarch64/= Makefile.target index c0bd8b9b86..24d6bb11e9 100644 --- a/tests/tcg/loongarch64/Makefile.target +++ b/tests/tcg/loongarch64/Makefile.target @@ -11,5 +11,6 @@ VPATH +=3D $(LOONGARCH64_SRC) LDFLAGS+=3D-lm =20 LOONGARCH64_TESTS =3D test_bit +LOONGARCH64_TESTS +=3D test_div =20 TESTS +=3D $(LOONGARCH64_TESTS) diff --git a/tests/tcg/loongarch64/test_div.c b/tests/tcg/loongarch64/test_= div.c new file mode 100644 index 0000000000..6c31fe97ae --- /dev/null +++ b/tests/tcg/loongarch64/test_div.c @@ -0,0 +1,54 @@ +#include +#include +#include + +#define TEST_DIV(N, M) \ +static void test_div_ ##N(uint ## M ## _t rj, \ + uint ## M ## _t rk, \ + uint64_t rm) \ +{ \ + uint64_t rd =3D 0; \ + \ + asm volatile("div."#N" %0,%1,%2\n\t" \ + : "=3Dr"(rd) \ + : "r"(rj), "r"(rk) \ + : ); \ + assert(rd =3D=3D rm); \ +} + +#define TEST_MOD(N, M) \ +static void test_mod_ ##N(uint ## M ## _t rj, \ + uint ## M ## _t rk, \ + uint64_t rm) \ +{ \ + uint64_t rd =3D 0; \ + \ + asm volatile("mod."#N" %0,%1,%2\n\t" \ + : "=3Dr"(rd) \ + : "r"(rj), "r"(rk) \ + : ); \ + assert(rd =3D=3D rm); \ +} + +TEST_DIV(w, 32) +TEST_DIV(wu, 32) +TEST_DIV(d, 64) +TEST_DIV(du, 64) +TEST_MOD(w, 32) +TEST_MOD(wu, 32) +TEST_MOD(d, 64) +TEST_MOD(du, 64) + +int main(void) +{ + test_div_w(0xffaced97, 0xc36abcde, 0x0); + test_div_wu(0xffaced97, 0xc36abcde, 0x1); + test_div_d(0xffaced973582005f, 0xef56832a358b, 0xffffffffffffffa8); + test_div_du(0xffaced973582005f, 0xef56832a358b, 0x11179); + test_mod_w(0x7cf18c32, 0xa04da650, 0x1d3f3282); + test_mod_wu(0x7cf18c32, 0xc04da650, 0x7cf18c32); + test_mod_d(0x7cf18c3200000000, 0xa04da65000000000, 0x1d3f328200000000); + test_mod_du(0x7cf18c3200000000, 0xc04da65000000000, 0x7cf18c3200000000= ); + + return 0; +} --=20 2.31.1