From patchwork Thu Oct 7 17:47:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515463 Delivered-To: patch@linaro.org Received: by 2002:ac0:b5cc:0:0:0:0:0 with SMTP id x12csp1412835ime; Thu, 7 Oct 2021 10:55:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEZQHrsdK/Y4CP28/2QgyxYXoAJFUciaNTPwZqV0hr4Ko6I0TWuhcT+MPfpW1juLHx4q5t X-Received: by 2002:ad4:4e72:: with SMTP id ec18mr4110018qvb.45.1633629311482; Thu, 07 Oct 2021 10:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633629311; cv=none; d=google.com; s=arc-20160816; b=bTYdfTG2+hnoCocwCIaknOeglJZK/UW+CeTCg0BCpW2JLU5O+MecxjQtxP/sKabarI m3mlOzhgWU2HzWe1Mtrj1oCjSZYdMMW6W5oOP80U3n+J4705Zv2PPbXECqekOiXgbb3y gU3BsS6dnmy+cxpw2ewFFksLXKftzQZQhRI9bgRI6zN/V3Hzc0R1Qx6oBfIku4gdHHft A7bY9fHDbe+qxqGDbhdRVctXdYVwzAzBChwd/dUyQE6a1XCGjTE91aosOcECekveEnXm KDRWe0DN/qyS11MVJ5oikXiCC6t0U0wREeSVDclYw/PZmIWAWqx7kJSdVCmyU7PPZA5t 2BPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=H87ppfQkVyn08RbjkKfsggea9i4sKXYDOxyW8HmfWE8=; b=GPuUwX83PZ88ZNpY7NpSEst7fDdMYSJOujUS++CIeCicivoM/7CuNPWRkHtyYOMj3L mZeVg5TgdnQnv5GTcKT4TE9IfYhM5WR0rUe1dDENFLQlOLkMwGmdwWq3wo5sd9HsOlzR rpXMnx6W3158eNeNdTA0piEGg01lC5jEInEhMSWtERS/vfGAl4fZOXh5sQDNdJqm6unH UOAcy1rpnhiTfm8hw3LXDg7c9rqxGzf4RLOh/nlE8fxyaih5DET67hPIxYDILrJQ5v2s veNZ/F+eQVJsgS4MDyHf7DUEMVRfhLjA9nqH2ZCVi6ZNQZEyykD2xBBKlbXX5rHQi3xl veAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fV0kqIUD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a9si59889qtn.211.2021.10.07.10.55.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Oct 2021 10:55:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fV0kqIUD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYXbr-00005M-11 for patch@linaro.org; Thu, 07 Oct 2021 13:55:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYXUV-00043f-6n for qemu-devel@nongnu.org; Thu, 07 Oct 2021 13:47:39 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:46985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYXUR-0006uB-Re for qemu-devel@nongnu.org; Thu, 07 Oct 2021 13:47:34 -0400 Received: by mail-pj1-x1031.google.com with SMTP id pi19-20020a17090b1e5300b0019fdd3557d3so5696184pjb.5 for ; Thu, 07 Oct 2021 10:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H87ppfQkVyn08RbjkKfsggea9i4sKXYDOxyW8HmfWE8=; b=fV0kqIUDiKSKvCiP1Ww839PeyZJXTJJg5selSPtXja45mDHsH5F1LaJvvmNZJQc+b5 l9V7hgQ2fE6v0drMW+0i+i8h0ikxEOGerm7PoRTGse2ldigbTNpwiPc2rfzclf9wlmNc kKPf5FdtL1+Q0ROw6QZQRZW09JeKdlrcD61J/wfvvIfYL7g5naoWU7MkCqES3TecEjFW Y3/2YV4QJ1wg0xRA6qaBPZRWcG0z4478xlVXBtjmZPtFNQh5uzWBZnxeH82d01rKIapd 33TnOyMrTajAurHWy4JSvdIX9u7kc0XvP/5rrLG+Cgop5r3e9SoU5XmtsbV2z9Ygwmwf pjhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H87ppfQkVyn08RbjkKfsggea9i4sKXYDOxyW8HmfWE8=; b=kXpk4xNQLSMxstDY8LpqXm0OOgn2osTJ7CJ3MK0Nbm/QNmu6Y7HCvVMRfaBl1eMpea sLoXOLWc+av67S6iLjCuRGYfaeoxb0efX/WycmcTiwiRi3NBY/NvPAD2aHxVpQw2QdbC ul5Uc3wUK/rUoxGPckblzQjvm1ElUktu1OMoyfz6MLtXF/LfDfOC7cwMlnF6p+oKTRgW jF1UuQtOxmr7nisLu/wToISlOdA/r9WudHIqMYxIfPYFxQzuiqrWW45dNeUT6qNJBXzv X9AbAtwQPFUxbyt/xh6q3p/5qAWbGU7XixuU2bov1E28GKCI50mQm34g2JzwigSnKtso bcJQ== X-Gm-Message-State: AOAM531mj51MNILf0nkOZuGznQeEpJCdnIzOx40vidGSxtW0oSK7dupz jea7oGNTyv00RlttTL6x/oYvESRn3CLeYQ== X-Received: by 2002:a17:90b:4f4b:: with SMTP id pj11mr6456275pjb.4.1633628850162; Thu, 07 Oct 2021 10:47:30 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id 197sm83318pfv.6.2021.10.07.10.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 10:47:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 08/13] target/riscv: Replace is_32bit with get_xl/get_xlen Date: Thu, 7 Oct 2021 10:47:17 -0700 Message-Id: <20211007174722.929993-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211007174722.929993-1-richard.henderson@linaro.org> References: <20211007174722.929993-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair.francis@wdc.com, frederic.petrot@univ-grenoble-alpes.fr, qemu-riscv@nongnu.org, fabien.portas@grenoble-inp.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In preparation for RV128, replace a simple predicate with a more versatile test. Signed-off-by: Richard Henderson --- target/riscv/translate.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) -- 2.25.1 diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 7e7bb67d15..5724a62bb0 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -91,16 +91,18 @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext) } #ifdef TARGET_RISCV32 -# define is_32bit(ctx) true +#define get_xl(ctx) MXL_RV32 #elif defined(CONFIG_USER_ONLY) -# define is_32bit(ctx) false +#define get_xl(ctx) MXL_RV64 #else -static inline bool is_32bit(DisasContext *ctx) -{ - return ctx->xl == MXL_RV32; -} +#define get_xl(ctx) ((ctx)->xl) #endif +static inline int get_xlen(DisasContext *ctx) +{ + return 16 << get_xl(ctx); +} + /* The word size for this operation. */ static inline int oper_len(DisasContext *ctx) { @@ -282,7 +284,7 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) static void mark_fs_dirty(DisasContext *ctx) { TCGv tmp; - target_ulong sd = is_32bit(ctx) ? MSTATUS32_SD : MSTATUS64_SD; + target_ulong sd = get_xl(ctx) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD; if (ctx->mstatus_fs != MSTATUS_FS) { /* Remember the state change for the rest of the TB. */ @@ -341,16 +343,16 @@ EX_SH(12) } \ } while (0) -#define REQUIRE_32BIT(ctx) do { \ - if (!is_32bit(ctx)) { \ - return false; \ - } \ +#define REQUIRE_32BIT(ctx) do { \ + if (get_xl(ctx) != MXL_RV32) { \ + return false; \ + } \ } while (0) -#define REQUIRE_64BIT(ctx) do { \ - if (is_32bit(ctx)) { \ - return false; \ - } \ +#define REQUIRE_64BIT(ctx) do { \ + if (get_xl(ctx) < MXL_RV64) { \ + return false; \ + } \ } while (0) static int ex_rvc_register(DisasContext *ctx, int reg)