From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CGMvEOwhe2CaOgAAWB0awg (envelope-from ) for ; Sat, 17 Apr 2021 13:59:08 -0400 Received: by simark.ca (Postfix, from userid 112) id E9ED01F104; Sat, 17 Apr 2021 13:59:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 76D7F1E813 for ; Sat, 17 Apr 2021 13:59:06 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C60D389850D; Sat, 17 Apr 2021 17:59:06 +0000 (GMT) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 3EC79389850D for ; Sat, 17 Apr 2021 17:59:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3EC79389850D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jimw@sifive.com Received: by mail-pl1-x62d.google.com with SMTP id d8so15602132plh.11 for ; Sat, 17 Apr 2021 10:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5S7R8CAOpKG4VVSk9YLIGwcTeAXYGODh42ZYSLn9X18=; b=iNC0oPJ2ZsS4AqSSEMv6g8RIC8c5k95CYupU2L1askZN8lkI5JUBEAeKx7CxOF85rw mepwDvIQmP8eoRmPomdPLtC789vwIFuFuF3E0afNWvAkC4ZaJmTWww+Mqd79vdYSm2qx D5IsBChU8Qvu3EVx5MYOIiQYi6Fyk/ugQUicW4+4AVzhtPrltmZShcpt/RcJ2TXn4qs3 48VboYsHB9u0iFDxE63xOLiZUGcGDEN2yLzMOK+7RatAJ9YinXhtAI2Drjpn4ssxn1kG c96o5DNo2Eei5+UOouWRYOcn9CbbeWDNlanY2sHT8/pQSDreOcKy7KmnUCHcSYloPl8S sGVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5S7R8CAOpKG4VVSk9YLIGwcTeAXYGODh42ZYSLn9X18=; b=mMV1uWkvvXfFV4uvKS/dUoCN9qngNxYktFPi4JCbJwCj/0CQoyBSRKguq6eF6alWVf HtkcUUMPA2xT8gVh6bLuxJG75LPF2Vomo1I6uFDlxEz8aD2epdBHM8ZptyY/+nSGoTO5 FGsYrmdqaqfVkFnU4IfNxZd4Km7Wzn9QXXFjvTQ8Mm0X8T7jI0esnoi7X0IZg+3p0f/E P+mlQJx3EeXMoVPN0vFDpp5br6/3E15GzOOl/O0lEAUhGjiczRGbFMdT8w9pP3+cBvVm oFghjtmRWZU4ccF/bh6V9S8PZSFE+NfOGTbh+UDN2kuEIGS5K4bgbyqnMXVanGrpobvV LcHA== X-Gm-Message-State: AOAM532ACL46Je0zN6+MtOHwXvKDR+ThHKQkrzlniYLU6ZH5ydRLl5Yr LZyXWdWelY4HxRIPohBoYGHU7ssadaoUHw== X-Google-Smtp-Source: ABdhPJztuUGrDjynN4H3kcsPrW75UKg3JIaxfAHNZs3YD0iD4//sYVTSznbGtH6KX9ntUhaEc1YCcA== X-Received: by 2002:a17:90a:138b:: with SMTP id i11mr15691728pja.220.1618682337217; Sat, 17 Apr 2021 10:58:57 -0700 (PDT) Received: from rohan.hsd1.ca.comcast.net ([2601:646:c180:b150:1820:3ed4:975:3fbe]) by smtp.gmail.com with ESMTPSA id u4sm5030705pfk.56.2021.04.17.10.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Apr 2021 10:58:56 -0700 (PDT) From: Jim Wilson To: gdb-patches@sourceware.org Subject: [PATCH 02/24] RISC-V sim: Fix for jalr. Date: Sat, 17 Apr 2021 10:58:09 -0700 Message-Id: <20210417175831.16413-3-jimw@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210417175831.16413-1-jimw@sifive.com> References: <20210417175831.16413-1-jimw@sifive.com> 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Palmer Dabbelt When rd and rs1 are the same reg, must read rs1 before writing rd. Jal is also fixed for consistency. sim/riscv/ * sim-main.c (execute_i): In case MATCH_JAL, move store_rd call after assignment to pc. In case MATCH_JALR, likewise. --- sim/riscv/sim-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c index ccab3ba..ddc1060 100644 --- a/sim/riscv/sim-main.c +++ b/sim/riscv/sim-main.c @@ -417,14 +417,14 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) case MATCH_JAL: TRACE_INSN (cpu, "jal %s, %" PRIiTW ";", rd_name, EXTRACT_JTYPE_IMM (iw)); - store_rd (cpu, rd, cpu->pc + 4); pc = cpu->pc + EXTRACT_JTYPE_IMM (iw); + store_rd (cpu, rd, cpu->pc + 4); TRACE_BRANCH (cpu, "to %#" PRIxTW, pc); break; case MATCH_JALR: TRACE_INSN (cpu, "jalr %s, %s, %" PRIiTW ";", rd_name, rs1_name, i_imm); - store_rd (cpu, rd, cpu->pc + 4); pc = cpu->regs[rs1] + i_imm; + store_rd (cpu, rd, cpu->pc + 4); TRACE_BRANCH (cpu, "to %#" PRIxTW, pc); break; -- 2.7.4