From patchwork Tue Oct 19 00:01:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515941 Delivered-To: patch@linaro.org Received: by 2002:ac0:cd8c:0:0:0:0:0 with SMTP id d12csp72145imp; Mon, 18 Oct 2021 17:09:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAXzXTGml0OP4MsVC9EbhuORSE7cv5sTQn4yj2sgl5y/rUQZKbEvBAjfpShPlWpzL+zDvt X-Received: by 2002:a67:ab48:: with SMTP id k8mr32270513vsh.30.1634602143713; Mon, 18 Oct 2021 17:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634602143; cv=none; d=google.com; s=arc-20160816; b=dnyzW+NYbPV3cMkgcuMLBO8UPFXNPlfCeAZnXE3txktJzFQw89CumeNjpYcjIdVMug FVHzGmz4Yv2JDOuz1ygbbSjVV30WQsyM/5g/bb5KgAn5uEg2dPe9KDLwX7HiFL5CsxDZ EPFDHevJ0MlaeAh4M14ojLQ2a0L7TDhMscPriVVSgc94fjQDHc8S5lSq+HwrRoSfhB2J jZBd93wsu4QZB7ruCFiDLc//ZoKbn3aWT6Ly6OUTowzo7Kv5UJaMnk60Fb8NuciNLA6a ytGmgL3qIs9a5W76vHT7iL/1ItvbA3Dfk76+4gzm7rQJw8auNRWEjSIMJHaMC/j6OY9b HFbw== 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=edH/POVbw08zofw7DVs7aX5K2Qy9VoOU3+jO1Dt/KD8=; b=AbABRbFGMw9PbKkOJg7MZJExCgQ2+JE6Ytex1pA1rR24cV84PAeCdrtgTJDIpiFcOr mSU11dYne59fijDzc9+prRJDbpb0LbBEwrC0bDwM33RFfrh8cIlEBv++n3lYlwnO/oz7 j8asrrqaLegzbBeHb2ZlGwpQSkP3PNPU0rCoaiBOYkMOTi85RFSWm6pU/Ybg6ryz1CyI B0IkxGhk8oNDuVgUGH4uolbpI4KMc56v7BtClMZHlyGBpXWZOgx0ThrKDZMV1/a7Un51 c8h1MzGefLsck6129kwvoLUl75v22gyGHoiCDxV5EcUlz5HPLMlRBwrv2wV5nQlecN4H JfcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hIrPs1TD; 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 r5si1053585uah.138.2021.10.18.17.09.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Oct 2021 17:09:03 -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=hIrPs1TD; 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]:36546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mccgh-0000QC-47 for patch@linaro.org; Mon, 18 Oct 2021 20:09:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mccZG-0004om-KB for qemu-devel@nongnu.org; Mon, 18 Oct 2021 20:01:22 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:44031) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mccZB-0001hr-22 for qemu-devel@nongnu.org; Mon, 18 Oct 2021 20:01:22 -0400 Received: by mail-pl1-x632.google.com with SMTP id y1so12402547plk.10 for ; Mon, 18 Oct 2021 17:01:16 -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=edH/POVbw08zofw7DVs7aX5K2Qy9VoOU3+jO1Dt/KD8=; b=hIrPs1TDpOsgg1x1CJH8gJOIwQo+N/4Bn9Lm2oxdtvDghlaLGnmG0jiSTOBa3UM9u7 idiEWUgl4bWpAqdnAINX841WZOpXJWpepK21EoS6YToV7UlYkBudKNtBiZ0W15NNgar7 fFbzxwysWPLasm1cunHch+zYw/Nks4orrhh54AISHBDgiylSsUTOxj1EIN1TcGzwabH9 JxJXAq29aXcscFwBImqrU2T094nZI2gYFepjL+FVDXIExQcnaoKYynoesmReaFrl0QaU /KlrgWfJqp33IKTma6KsADpo/EZYMH1Unb21ZlcbtSHJKXwiDjMAQz82lSQqEZXrcGB5 06sg== 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=edH/POVbw08zofw7DVs7aX5K2Qy9VoOU3+jO1Dt/KD8=; b=x6AlAYxTpj+2vul139BlNOn8np4I27qx/90FaakY2/HbVnfgbCRUK1kRHd0DmF2EbR ROuz69L07k2ghbE5+zAGfyt9FqfuO2ZN2LIrT9q57p5IKGfvHOoW/a0jK5tCJQAcCVJg U+355gatUhncEqozwOiSkKFOKOhTbavrCfls/lktElZlARtTXyWKY+IhgFl1qKAlNtWZ uXyoiFz1itPvXWhfFL4pkebaJmZCPetHewGBC++nodopy4bX48GRyfX5SGM0l7Dh9TG/ D7/rmJohhQ/u/lLrsy4IdGWHcYyfEW8TEjYaoFw+dvoB0/Qg+MPdDVFimsGzhIEWbVql 4llw== X-Gm-Message-State: AOAM531vzVtpaNcjxeT37cnZaUSnfCDrF+UhWg1VJpbKwbm4DJROMK/J FjAX1DbF5fB6lq0Uh4vgVpOKIi8C3cB8QA== X-Received: by 2002:a17:90b:390d:: with SMTP id ob13mr2366528pjb.49.1634601675516; Mon, 18 Oct 2021 17:01:15 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id q14sm3068220pfk.3.2021.10.18.17.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 17:01:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 08/16] target/riscv: Replace is_32bit with get_xl/get_xlen Date: Mon, 18 Oct 2021 17:01:00 -0700 Message-Id: <20211019000108.3678724-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019000108.3678724-1-richard.henderson@linaro.org> References: <20211019000108.3678724-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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=unavailable 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, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com 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. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- target/riscv/translate.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) -- 2.25.1 diff --git a/target/riscv/translate.c b/target/riscv/translate.c index f7634c175a..3f1abbac5c 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -91,16 +91,19 @@ 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 +/* The word size for this machine mode. */ +static inline int __attribute__((unused)) get_xlen(DisasContext *ctx) +{ + return 16 << get_xl(ctx); +} + /* The word size for this operation. */ static inline int oper_len(DisasContext *ctx) { @@ -257,7 +260,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. */ @@ -316,16 +319,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)