From patchwork Tue Oct 19 15:24:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515962 Delivered-To: patch@linaro.org Received: by 2002:ac0:cd8c:0:0:0:0:0 with SMTP id d12csp793786imp; Tue, 19 Oct 2021 08:54:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfZOjwV/t7bPbELzJyfFEPslQxlnvpSG+yhNxRht9aG1d88wGi7Z03ko9n0cSC1TnWZvKj X-Received: by 2002:a05:6102:304e:: with SMTP id w14mr24187241vsa.52.1634658872478; Tue, 19 Oct 2021 08:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634658872; cv=none; d=google.com; s=arc-20160816; b=ll+dcCnqYYidcQO+f8TD9KkWXqiXJDVZkZiwv1L0gkmesNPoqcvqaDipN1fLYWNBP1 t/yOY0tlFwPRvoiLFTVOrfx9NjTNZOEt+hk5awEUwZ++XZoHbMqDko9Ot8WdKwAMzImU n1ks8CgdTlEERVXLHyPcPw3oU68G441QJ1wSPfEq+JIvbyzvBVrozYmFjP6Vi9Ul7i7e lQxlHXHPWKFlfHSzE5iJzRdE0IqkkGDwz3Z/7aLBEyGaMUjHQyvksMFAC4IryCYb4acl Qbh5xBOZQ8c3cp7/3hZYuMSdfv6eHgV947vh+sg7fGiPIxUapNcbpEcXhpZpaPjhzFNZ JDgw== 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=j7Pnm201+k1ejBARpgS6HHyig0p2JvkuuzU/R/CvTXS8lFQUMJ1/D7tMLWZVn4Vyki dIHktzsF9lwdEgQV4ghB44PbsR78IXXi9AsooTMjccjZAfz7cnsXJE52L/rOLo6hQ37v AXK4tp8I6d/lXSSiUfDv/L0bqv6D7RwU8zWDllDQ+YKhWhvFz3MTC0Zbx4c+zU9TMv8/ cEffYFVXVpvHKW+W2ZSeldaOsUP4c+ZtKeVcUvnORh/KwBRaoZ/DZPAAuTApnWmXGJug fTIEgbWJI/VUIAfLMKCXdR1KgYgvSGatj59/sn5hjEtsJxc6ZjF5M+mi5FbM7VwQMNi0 snsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WDn2ev7F; 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 f29si6743466vsj.346.2021.10.19.08.54.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Oct 2021 08:54:32 -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=WDn2ev7F; 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]:32970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcrRf-0007wf-OF for patch@linaro.org; Tue, 19 Oct 2021 11:54:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcqyz-00050x-B9 for qemu-devel@nongnu.org; Tue, 19 Oct 2021 11:24:53 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:42940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcqys-0007YF-MD for qemu-devel@nongnu.org; Tue, 19 Oct 2021 11:24:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id w17so2057695plg.9 for ; Tue, 19 Oct 2021 08:24:46 -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=WDn2ev7F8Y+8lBeRgNTY4J3JqABh1A4rHd9wV5zuPgz2ye5a4mAOq6jnE8XbQZEgPc 2c19grunndK0SMTrpswRNUo6CQNZanENPPpakHIgZzGrKlulsTum/S/1I3UAEUGyzC/u hplB+rdkPwrtgNzjU9eSWVZQ0kXOh7FnubsHDIb18wTBJ6TN9swlMUx9jjo10nlM6Aov KF4eau/jDSmZoxV7FrCpBUvjZ4UcvIVEgfHewajDm3bOACQpQtQauMNevA35034E5JRI 2xjHVI2QX81J0HF66QcVQBPAczf5KLOdzXWaIG8a69M5daH685dlfEi08hX9XC+NILzW H7HA== 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=HLaTueQu3Xa2aTW5LR/4tW9VANVvvST4kEBW29j6t4XtOBNzVz8s2qrLKOKuwcyjzD +aiTh31NdnXClEI2qmlmZTlfInMoxq4Eb0MjluwoSG3/uvQXOczKkZIFCXPDmDHbSN67 ufSQoCqdYv62guxKJJIQf0DZH9O9qinlugqSZY3Rmk62LES45OBzvd6RrzHfL/dTAN7W 8cfOQYuh1O8rr8Us54xYLgy9lWMJZufRIxWHXPfHymrIEZ8pkEN6zNpVxXzo5ic8DHdK 4gbwGEnQ1280qrfOoQxHJ347rXpqLGCexhUUxbcDrNdyoiS4uV1Z+yjRhHHZ1OjVv7H9 JWwQ== X-Gm-Message-State: AOAM530JkrqRQwRMG8WOP0XFyeUICuTbt2m3mRq3HnMtx0T0q60PW8r7 UINuM3/WznyK4C/2XEYNjanshLrSSfjobw== X-Received: by 2002:a17:90a:530f:: with SMTP id x15mr495525pjh.156.1634657085224; Tue, 19 Oct 2021 08:24:45 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id i2sm3293814pjt.19.2021.10.19.08.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 08:24:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 08/16] target/riscv: Replace is_32bit with get_xl/get_xlen Date: Tue, 19 Oct 2021 08:24:30 -0700 Message-Id: <20211019152438.269077-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019152438.269077-1-richard.henderson@linaro.org> References: <20211019152438.269077-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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, 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)