From patchwork Sat Jun 19 18:14:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463918 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp1057603jao; Sat, 19 Jun 2021 11:37:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjgT+KdAe3nO+rZLMQH2/ptf+dmRJM7mxFdVtM1BEgGAczyjL4pWT0yGbOZFnRnwpe+Rb2 X-Received: by 2002:ac8:5d47:: with SMTP id g7mr15834335qtx.351.1624127841438; Sat, 19 Jun 2021 11:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624127841; cv=none; d=google.com; s=arc-20160816; b=0JeKiys/85bvydtUih4+MSk8TW9Aeu4e83Y0XDXMJQA/Es8D1vBxC9iEFc6dVMS/gr GmC4GL4cxIj507l9ZFBjag3tkSyJbOujUBgIvR/EfbmgPVpUyQxAOV9KgUEnQlaVSEHZ CYX4OHh3Rg8YXvxtv3rN2Vc78D3ftr2u4yonZaoHYaPTs22kstjUNU13gLkdqHC8KD9K zMv9PlUCqE7SH/333MhY9ClBw6SAHm/6iOTwjd86TDOnm0PbrAfW7K0rVAdiPbM+S3Ql cN2jiNiTlGbUxVPApwvenS9MXaeTixNaMDMEYdrzaaMV1Pfm9WPb+G+bUcUMhZ+vTba5 VnCg== 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=lDQh3RHIBvFFZ/5eKksAkO3SIZPBgL6PLHQwDZAQ6is=; b=KGMkznCsk43qXSdVctRIwaIoyTYUTt5OuvOMExKhw5RMiFWegQ6PWFKs6XoA70OnBM Xn1Sdkm3PZXHWL5JZWrQjuRZgemHR0eQjObhBEGimCOrrQj+HSwMqKQjtRWC+CBkTpZI IVTKiQvjwKRicUwX14UDludrRUVMRRNwbzy5jcc/GM4OyvdMNURO7YXeMlFShLaYlNk0 U349G6pB7cOfDFwvDbaXj8PlZPj6biNuNGeyoCBhKLHQAS0SvU6Ud4MJllyT6z5lYkoA s63Fq1shSj1ZfkY4Z/JQAwJ+x0eMDCWauqRQCD8ta6m+2vWUddSWeZm4CLcBa+hD9BNk 9sFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uQplcpC/"; 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 u5si9481909qtq.336.2021.06.19.11.37.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 19 Jun 2021 11:37:21 -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="uQplcpC/"; 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]:43190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lufqK-0005zA-Qy for patch@linaro.org; Sat, 19 Jun 2021 14:37:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lufUz-0000x0-6k for qemu-devel@nongnu.org; Sat, 19 Jun 2021 14:15:19 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:34515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lufUq-0002MO-Jj for qemu-devel@nongnu.org; Sat, 19 Jun 2021 14:15:16 -0400 Received: by mail-pg1-x536.google.com with SMTP id g22so10605449pgk.1 for ; Sat, 19 Jun 2021 11:15:08 -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=lDQh3RHIBvFFZ/5eKksAkO3SIZPBgL6PLHQwDZAQ6is=; b=uQplcpC/l1nzKRaEP/u/BzTQnEptuxX+qEP4qq8QTb0ZZ/fjPRUDbrZOZHvtHjdR4u VVrc35A6n2r3lPBe06rHj1kMYGP/vIZf7ydw3XqipHFbO8/FPOcC6Ry9ldgl83w0oCog OXdIiymm2k/oI4QAqlxwit8+pZzmWipwoqRnk4rMuH2kI9/nToP/Xs92310gmR5Py+Wf kBnHqoZ92ZjBCwKE0mRd+yo7dPM3lnFN1XoyY0CtE5w7CCc4J8RlWO2uxZ5Oa3HoLekT N8T357C8uS9o/1td34SNfiiI/7MGoaznCD7ImBCETzeRePQ3KDvQI6/ENWFa1wFKepoP i2pA== 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:mime-version:content-transfer-encoding; bh=lDQh3RHIBvFFZ/5eKksAkO3SIZPBgL6PLHQwDZAQ6is=; b=Oqp4UZWbjGvf6IS6Riz9vBPb18tENgkJuGTWdFmFluLtLbPbVbvdEjxR62tLwpOAoo jKCfHMIFc2WyuJzhOfOEprvFXd6guMJVaGpwqwm0GEAa/UJiseSSOIWzISgnLDq5sRBA 4rnA4jDa+3ANXmfbjiIGKT+TldBFfGgWLiCLeeOZGD7q3GdMzGJUnDNb/gnxVW4sf99h jwc+RCDAnW9SxFp+5OLEv9jsyxbYv2H4IZ1AL2CtG6NWy2SnOZc1gVrodDjEKhPYPE7d vB0sO8uZdExDASTToBG9O52Szzkk4BS1mfn3ssvTJZYsfiF/GAFtDGnQBsmMMh4YhCyR pLiA== X-Gm-Message-State: AOAM532aBKcBa56PKyX716cWBROF1bQXJ3Asg02RvnM2Ri3qOHGjQOdw EoOl3h32GNAPTD6nKuezNL8xH+Yyk19/PQ== X-Received: by 2002:aa7:82cb:0:b029:2e6:f397:d248 with SMTP id f11-20020aa782cb0000b02902e6f397d248mr11575950pfn.52.1624126507338; Sat, 19 Jun 2021 11:15:07 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id k35sm12059113pgi.21.2021.06.19.11.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Jun 2021 11:15:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/33] tcg/tci: Remove the qemu_ld/st_type macros Date: Sat, 19 Jun 2021 11:14:44 -0700 Message-Id: <20210619181452.877683-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210619181452.877683-1-richard.henderson@linaro.org> References: <20210619181452.877683-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These macros are only used in one place. By expanding, we get to apply some common-subexpression elimination and create some local variables. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tci.c | 165 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 100 insertions(+), 65 deletions(-) -- 2.25.1 diff --git a/tcg/tci.c b/tcg/tci.c index cbe1afa289..a5670f2109 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -288,85 +288,88 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) return result; } -#ifdef CONFIG_SOFTMMU -# define qemu_ld_ub \ - helper_ret_ldub_mmu(env, taddr, oi, (uintptr_t)tb_ptr) -# define qemu_ld_leuw \ - helper_le_lduw_mmu(env, taddr, oi, (uintptr_t)tb_ptr) -# define qemu_ld_leul \ - helper_le_ldul_mmu(env, taddr, oi, (uintptr_t)tb_ptr) -# define qemu_ld_leq \ - helper_le_ldq_mmu(env, taddr, oi, (uintptr_t)tb_ptr) -# define qemu_ld_beuw \ - helper_be_lduw_mmu(env, taddr, oi, (uintptr_t)tb_ptr) -# define qemu_ld_beul \ - helper_be_ldul_mmu(env, taddr, oi, (uintptr_t)tb_ptr) -# define qemu_ld_beq \ - helper_be_ldq_mmu(env, taddr, oi, (uintptr_t)tb_ptr) -# define qemu_st_b(X) \ - helper_ret_stb_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) -# define qemu_st_lew(X) \ - helper_le_stw_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) -# define qemu_st_lel(X) \ - helper_le_stl_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) -# define qemu_st_leq(X) \ - helper_le_stq_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) -# define qemu_st_bew(X) \ - helper_be_stw_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) -# define qemu_st_bel(X) \ - helper_be_stl_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) -# define qemu_st_beq(X) \ - helper_be_stq_mmu(env, taddr, X, oi, (uintptr_t)tb_ptr) -#else -# define qemu_ld_ub ldub_p(g2h(env_cpu(env), taddr)) -# define qemu_ld_leuw lduw_le_p(g2h(env_cpu(env), taddr)) -# define qemu_ld_leul (uint32_t)ldl_le_p(g2h(env_cpu(env), taddr)) -# define qemu_ld_leq ldq_le_p(g2h(env_cpu(env), taddr)) -# define qemu_ld_beuw lduw_be_p(g2h(env_cpu(env), taddr)) -# define qemu_ld_beul (uint32_t)ldl_be_p(g2h(env_cpu(env), taddr)) -# define qemu_ld_beq ldq_be_p(g2h(env_cpu(env), taddr)) -# define qemu_st_b(X) stb_p(g2h(env_cpu(env), taddr), X) -# define qemu_st_lew(X) stw_le_p(g2h(env_cpu(env), taddr), X) -# define qemu_st_lel(X) stl_le_p(g2h(env_cpu(env), taddr), X) -# define qemu_st_leq(X) stq_le_p(g2h(env_cpu(env), taddr), X) -# define qemu_st_bew(X) stw_be_p(g2h(env_cpu(env), taddr), X) -# define qemu_st_bel(X) stl_be_p(g2h(env_cpu(env), taddr), X) -# define qemu_st_beq(X) stq_be_p(g2h(env_cpu(env), taddr), X) -#endif - static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, TCGMemOpIdx oi, const void *tb_ptr) { MemOp mop = get_memop(oi) & (MO_BSWAP | MO_SSIZE); +#ifdef CONFIG_SOFTMMU + uintptr_t ra = (uintptr_t)tb_ptr; + switch (mop) { case MO_UB: - return qemu_ld_ub; + return helper_ret_ldub_mmu(env, taddr, oi, ra); case MO_SB: - return (int8_t)qemu_ld_ub; + return helper_ret_ldsb_mmu(env, taddr, oi, ra); case MO_LEUW: - return qemu_ld_leuw; + return helper_le_lduw_mmu(env, taddr, oi, ra); case MO_LESW: - return (int16_t)qemu_ld_leuw; + return helper_le_ldsw_mmu(env, taddr, oi, ra); case MO_LEUL: - return qemu_ld_leul; + return helper_le_ldul_mmu(env, taddr, oi, ra); case MO_LESL: - return (int32_t)qemu_ld_leul; + return helper_le_ldsl_mmu(env, taddr, oi, ra); case MO_LEQ: - return qemu_ld_leq; + return helper_le_ldq_mmu(env, taddr, oi, ra); case MO_BEUW: - return qemu_ld_beuw; + return helper_be_lduw_mmu(env, taddr, oi, ra); case MO_BESW: - return (int16_t)qemu_ld_beuw; + return helper_be_ldsw_mmu(env, taddr, oi, ra); case MO_BEUL: - return qemu_ld_beul; + return helper_be_ldul_mmu(env, taddr, oi, ra); case MO_BESL: - return (int32_t)qemu_ld_beul; + return helper_be_ldsl_mmu(env, taddr, oi, ra); case MO_BEQ: - return qemu_ld_beq; + return helper_be_ldq_mmu(env, taddr, oi, ra); default: g_assert_not_reached(); } +#else + void *haddr = g2h(env_cpu(env), taddr); + uint64_t ret; + + switch (mop) { + case MO_UB: + ret = ldub_p(haddr); + break; + case MO_SB: + ret = ldsb_p(haddr); + break; + case MO_LEUW: + ret = lduw_le_p(haddr); + break; + case MO_LESW: + ret = ldsw_le_p(haddr); + break; + case MO_LEUL: + ret = (uint32_t)ldl_le_p(haddr); + break; + case MO_LESL: + ret = (int32_t)ldl_le_p(haddr); + break; + case MO_LEQ: + ret = ldq_le_p(haddr); + break; + case MO_BEUW: + ret = lduw_be_p(haddr); + break; + case MO_BESW: + ret = ldsw_be_p(haddr); + break; + case MO_BEUL: + ret = (uint32_t)ldl_be_p(haddr); + break; + case MO_BESL: + ret = (int32_t)ldl_be_p(haddr); + break; + case MO_BEQ: + ret = ldq_be_p(haddr); + break; + default: + g_assert_not_reached(); + } + return ret; +#endif } static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t val, @@ -374,31 +377,63 @@ static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t val, { MemOp mop = get_memop(oi) & (MO_BSWAP | MO_SSIZE); +#ifdef CONFIG_SOFTMMU + uintptr_t ra = (uintptr_t)tb_ptr; + switch (mop) { case MO_UB: - qemu_st_b(val); + helper_ret_stb_mmu(env, taddr, val, oi, ra); break; case MO_LEUW: - qemu_st_lew(val); + helper_le_stw_mmu(env, taddr, val, oi, ra); break; case MO_LEUL: - qemu_st_lel(val); + helper_le_stl_mmu(env, taddr, val, oi, ra); break; case MO_LEQ: - qemu_st_leq(val); + helper_le_stq_mmu(env, taddr, val, oi, ra); break; case MO_BEUW: - qemu_st_bew(val); + helper_be_stw_mmu(env, taddr, val, oi, ra); break; case MO_BEUL: - qemu_st_bel(val); + helper_be_stl_mmu(env, taddr, val, oi, ra); break; case MO_BEQ: - qemu_st_beq(val); + helper_be_stq_mmu(env, taddr, val, oi, ra); break; default: g_assert_not_reached(); } +#else + void *haddr = g2h(env_cpu(env), taddr); + + switch (mop) { + case MO_UB: + stb_p(haddr, val); + break; + case MO_LEUW: + stw_le_p(haddr, val); + break; + case MO_LEUL: + stl_le_p(haddr, val); + break; + case MO_LEQ: + stq_le_p(haddr, val); + break; + case MO_BEUW: + stw_be_p(haddr, val); + break; + case MO_BEUL: + stl_be_p(haddr, val); + break; + case MO_BEQ: + stq_be_p(haddr, val); + break; + default: + g_assert_not_reached(); + } +#endif } #if TCG_TARGET_REG_BITS == 64