From patchwork Sun May 1 05:49:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568554 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp7698099map; Sat, 30 Apr 2022 23:20:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0dDPvZZwDIxSui86ChWAekKzR+vbRVHMnbLjjnGX4lfVOHNM4bGN1wvrd9bAg7//dmtZX X-Received: by 2002:a05:622a:1911:b0:2f3:4621:4bfa with SMTP id w17-20020a05622a191100b002f346214bfamr5752525qtc.360.1651386001444; Sat, 30 Apr 2022 23:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651386001; cv=none; d=google.com; s=arc-20160816; b=IAodzOHaUh/XT96Y+6FBdhK2SGh39LUJ7eyFi6qCMrKdnKS0f4rzWagvrJWHj/0PBO MDBvbtEFuOFJc0xqnQr44ED5OW7IeLRrE3LrvyvUPyOzvQpbXJD/YUTvseaJ/GUVcPiS ClqqzZVTKfz/TtSYzY0K5OIggVGzm+hr5YelT3WlX/gWQJc3M3pIgzk3nM2++aH+vagC SJTxL+UDJKbdak40DO63L7iGmIv/jGnoIi9H5P2eiGVp6c1hHyR175NK+aX/IUnuzDy3 PYFA24B1sjkxJLKX/EcDrMSnY6XJNhulHcM6xu+IMXMt6qWp4vPshYyAB7A6ai0sLBom IFbw== 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=quTC6tTsjrVSG7RTQMFQxNix8MmA7vsc1c94ro1M6BU=; b=tiel1eOPocX28nS8pujmR4Q6O7zk3g86tjdGTYr1+niVsBx6ie113k4/BLn9UkDFBC REaBanfEnfLaFpHKBe3o8Z5ZiUJxLMCHKzi5zkwq5WA3jKgvxoZ+g95pYE8bbQFRan6S kzw8NEqSj7RRkt9LhuedRxIn6xKY2LFCbGC9iuLWzG3S2MF6dZYoyWSG1fqlIs/cFsso h57LuWD2Nc6Gw+CQfy5fb3vVsLSijgIvtz3MVh4TKdqTSScAzVH+VpPoxob1FH4/6KNf dKSAALNqNISjeVf8z6Uuyd+ikOGm8UT++NqbgeSh4OlYb0+QbXLHu3XAcaH2R6Szh7OX L84Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GAaMlrPs; 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=pass (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 bs18-20020ac86f12000000b002f387d0ff25si254786qtb.505.2022.04.30.23.20.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Apr 2022 23:20:01 -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=pass header.i=@linaro.org header.s=google header.b=GAaMlrPs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl2w4-00082s-Vs for patch@linaro.org; Sun, 01 May 2022 02:20:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl2Tp-0006t7-Bl for qemu-devel@nongnu.org; Sun, 01 May 2022 01:50:57 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:41550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nl2Tl-0001HQ-HR for qemu-devel@nongnu.org; Sun, 01 May 2022 01:50:48 -0400 Received: by mail-pj1-x102a.google.com with SMTP id z5-20020a17090a468500b001d2bc2743c4so10494077pjf.0 for ; Sat, 30 Apr 2022 22:50:43 -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=quTC6tTsjrVSG7RTQMFQxNix8MmA7vsc1c94ro1M6BU=; b=GAaMlrPsCUAKgd4ifuF74NLDzajJdiMSssMgoXVuxe/PhIqvNkznvXLkzcgSb4zIfS TeJbN30lQ2SEyg1HbpDIcTskbRUl0WXEA053PCs9ROdHLNm6btDswIXIThYYYSgdNAta qx3IgFdVR2lOd5wu6keMsZCiAhdIBpVfvl6e681283mImO7Dvo4PaANbaxpC/WnE57RI HXx9+66u6ZdDq8iJD2Ghfnjtmv1g4iykmK9vlIITE53NwY/ni5cGT6zLlYws9ve58UjC nxdgdeC4eX+qIDfZ8NO5bcHtK4UTwKaRVEtmHYwWRr8AzVvdECTVXIkx/F8/QS/cZehb s78w== 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=quTC6tTsjrVSG7RTQMFQxNix8MmA7vsc1c94ro1M6BU=; b=gQex4dQkqPzaXJEqdHQAMeMG6e1RKd2/ZftsRC/Irx/eeflg1+w/Kzb2pG1TgXVNaA DqNNFRmt1vpI2HjtxJpvEQwP47QA2RNb3fiJr5sam0ETV0KcCuz8rYycDLuq6eQcr8ZK HBSjiCU2jjIi+leEwyzlTLCvyFyJneFTC2ikyjMEKy8vpHNGg8KHJoC+fLd+74bJgoB5 mRg+gwaMG3mGMrb+guOJF2T4xIJxkWBxM+80zyUZF72B4c2XKHl1eygJ1xP36ruGVe7H 4nnLur0R4v8bdG/s2TSwqWbXKndYQqwr+DJrbv0LIlD9VUChv2YZ2t4MA3BwPhJG054a FGGQ== X-Gm-Message-State: AOAM530IeKeYFM0765N+nwNK3MeYzF62AyI9LJTjSqz7/lykGiOZtqvd 9ODA92I7zZ/gCrlrfgcpDUdF3Db4Fzosyg== X-Received: by 2002:a17:90a:fac:b0:1ca:5eb8:f3b2 with SMTP id 41-20020a17090a0fac00b001ca5eb8f3b2mr7145887pjz.37.1651384242469; Sat, 30 Apr 2022 22:50:42 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id cm18-20020a17090afa1200b001cd8e9ea22asm17310342pjb.52.2022.04.30.22.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Apr 2022 22:50:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 13/45] target/arm: Hoist computation of key in add_cpreg_to_hashtable Date: Sat, 30 Apr 2022 22:49:55 -0700 Message-Id: <20220501055028.646596-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220501055028.646596-1-richard.henderson@linaro.org> References: <20220501055028.646596-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move the computation of key to the top of the function. Hoist the resolution of cp as well, as an input to the computation of key. This will be required by a subsequent patch. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 49 +++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 44c05deb5b..118422d672 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8509,8 +8509,34 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, ARMCPRegInfo *r2; int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0; + int cp = r->cp; size_t name_len; + switch (state) { + case ARM_CP_STATE_AA32: + /* We assume it is a cp15 register if the .cp field is left unset. */ + if (cp == 0 && r->state == ARM_CP_STATE_BOTH) { + cp = 15; + } + key = ENCODE_CP_REG(cp, is64, ns, r->crn, crm, opc1, opc2); + break; + case ARM_CP_STATE_AA64: + /* + * To allow abbreviation of ARMCPRegInfo definitions, we treat + * cp == 0 as equivalent to the value for "standard guest-visible + * sysreg". STATE_BOTH definitions are also always "standard sysreg" + * in their AArch64 view (the .cp value may be non-zero for the + * benefit of the AArch32 view). + */ + if (cp == 0 || r->state == ARM_CP_STATE_BOTH) { + cp = CP_REG_ARM64_SYSREG_CP; + } + key = ENCODE_AA64_CP_REG(cp, r->crn, crm, r->opc0, opc1, opc2); + break; + default: + g_assert_not_reached(); + } + /* Combine cpreg and name into one allocation. */ name_len = strlen(name) + 1; r2 = g_malloc(sizeof(*r2) + name_len); @@ -8554,12 +8580,6 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, } if (r->state == ARM_CP_STATE_BOTH) { - /* We assume it is a cp15 register if the .cp field is left unset. - */ - if (r2->cp == 0) { - r2->cp = 15; - } - #if HOST_BIG_ENDIAN if (r2->fieldoffset) { r2->fieldoffset += sizeof(uint32_t); @@ -8567,22 +8587,6 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, #endif } } - if (state == ARM_CP_STATE_AA64) { - /* To allow abbreviation of ARMCPRegInfo - * definitions, we treat cp == 0 as equivalent to - * the value for "standard guest-visible sysreg". - * STATE_BOTH definitions are also always "standard - * sysreg" in their AArch64 view (the .cp value may - * be non-zero for the benefit of the AArch32 view). - */ - if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) { - r2->cp = CP_REG_ARM64_SYSREG_CP; - } - key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm, - r2->opc0, opc1, opc2); - } else { - key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2); - } if (opaque) { r2->opaque = opaque; } @@ -8593,6 +8597,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, /* Make sure reginfo passed to helpers for wildcarded regs * has the correct crm/opc1/opc2 for this reg, not CP_ANY: */ + r2->cp = cp; r2->crm = crm; r2->opc1 = opc1; r2->opc2 = opc2;