From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 3268F385843A for ; Wed, 14 Sep 2022 10:56:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3268F385843A Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 926E2300089; Wed, 14 Sep 2022 10:56:06 +0000 (UTC) From: Tsukasa OI To: Tsukasa OI Cc: gdb-patches@sourceware.org Subject: [PING^1 PATCH 1/1] sim/riscv: Fix RISC-V multiply instructions on the simulator Date: Wed, 14 Sep 2022 10:55:51 +0000 Message-Id: <21f573ea4f45dabe96918adb8ded280774aef1ed.1663152886.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Sep 2022 10:56:09 -0000 Because of recent 'Zmmul' support, the simulator is broken. This is caused by instruction classification changes: [Before] - INSN_CLASS_M : multiply / divide [After Zmmul] - INSN_CLASS_M : divide - INSN_CLASS_ZMMUL : multiply The simulator checks the instruction class to execute an instruction: - INSN_CLASS_I : 'I' - INSN_CLASS_M : 'M' (multiply / divide) - INSN_CLASS_A : 'A' 'Zmmul' moved multiply instructions to INSN_CLASS_ZMMUL and that instruction class is not handled by the simulator. This commit handles INSN_CLASS_ZMMUL for all 'M' instructions and adds a testcase to test all RV32M instructions run without any faults. sim/ChangeLog: * riscv/sim-main.c (execute_one): Add INSN_CLASS_ZMMUL to run multiply instructions correctly. * testsuite/riscv/m-ext.s: New test. --- sim/riscv/sim-main.c | 1 + sim/testsuite/riscv/m-ext.s | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 sim/testsuite/riscv/m-ext.s diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c index 30d2f1e1c9a..0156f791d4b 100644 --- a/sim/riscv/sim-main.c +++ b/sim/riscv/sim-main.c @@ -936,6 +936,7 @@ execute_one (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) case INSN_CLASS_I: return execute_i (cpu, iw, op); case INSN_CLASS_M: + case INSN_CLASS_ZMMUL: return execute_m (cpu, iw, op); default: TRACE_INSN (cpu, "UNHANDLED EXTENSION: %d", op->insn_class); diff --git a/sim/testsuite/riscv/m-ext.s b/sim/testsuite/riscv/m-ext.s new file mode 100644 index 00000000000..b85397a32a0 --- /dev/null +++ b/sim/testsuite/riscv/m-ext.s @@ -0,0 +1,18 @@ +# check that the RV32M instructions run without any fault. +# mach: riscv + +.include "testutils.inc" + + start + + .option arch, +m + mul x0, x1, x2 + mulh x0, x1, x2 + mulhu x0, x1, x2 + mulhsu x0, x1, x2 + div x0, x1, x2 + divu x0, x1, x2 + rem x0, x1, x2 + remu x0, x1, x2 + + pass -- 2.34.1