From patchwork Thu May 25 18:10:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 685613 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp501048wrt; Thu, 25 May 2023 11:12:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Sz0TXKfDH3cQvvn362b3jTKIGBKEF2jAkgVSkVgtCvyCmqKRAS5DfYn6Kt1J5xpb3vECw X-Received: by 2002:a05:622a:18a7:b0:3e6:9766:c7e5 with SMTP id v39-20020a05622a18a700b003e69766c7e5mr327146qtc.31.1685038328346; Thu, 25 May 2023 11:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685038328; cv=none; d=google.com; s=arc-20160816; b=asABQTzIb3inirI8ArHmmiGvICJ4OdaMWUGLcA5axTeYApVqZ1nzmKNtHwIF/GKFjr OY6qrFOl5iw0SG1xjgchpZMgEFG1okyZ2jJINqX6XXEdcJmjPt1jlCXsn3ZoiEZb61ph uOSmeaV47c6T3YeFBBFcpe+eDL9zTp8vd8H/VrvtuikDjSEs8BuEClwUOSMVeIcHthJJ NCoS8Ka56QTqdoevxAyVpIB5X94RGDxO1TidKyP1G92+2fflDhQmHwfMwPoJ3PvUlVo1 uVuFZ1frBV/QH0SoXwhIAoiQ00oOnuuklEhyZy2edFWeHTpPHhozaHqeBeXuV1nQpQRa AV3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=1cuVcFNfYtthmtIf50Jsd3dfSKJk8+H2W+YHx6/HyPI=; b=dHuuLAGWGdvFtZ29NMxggT7af4Bgt8cgaZ2hZZt1afuaC40LgKhArcYr4DXI3IGqfH /qXEPbPdNeITb3RHcL53fX29URiAUxEGov99V3LtYHo1F+0qj2B3ykbZDBgGVxCfK6iY chPHuTge6VrnS/PgpyilH06bx7KktxqjLtVWrrWypZAcRZNEnvZkXBlNX2IgDdhcUkyp JBn1F/fRSCpps1vLHkBe9ME30JrQbfPtKNHcE7I3IVZbC8DlxoZjRsDFJxfwJV6WQB18 QEUSLMm+ME0i2i5QWE+64Q0Vsq03GP6Fgo5FKnVa5aiF6ONEOOXdzuAq15hxocd4LUkM Y1Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SxI2lNtA; 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 f22-20020a05622a105600b003f4f05686a4si667517qte.698.2023.05.25.11.12.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 May 2023 11:12:08 -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=SxI2lNtA; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2FQQ-0008Vj-Rr; Thu, 25 May 2023 14:10:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2FQN-0008SH-7q for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:55 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2FQL-0005y6-IC for qemu-devel@nongnu.org; Thu, 25 May 2023 14:10:55 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ae452c2777so148545ad.0 for ; Thu, 25 May 2023 11:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685038252; x=1687630252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1cuVcFNfYtthmtIf50Jsd3dfSKJk8+H2W+YHx6/HyPI=; b=SxI2lNtAAhjrfGAF5nGJP7WLiG2XOKloesvx9sNYPQQhvoECYofn2Hs1RgLAif0a3Q hxm7yuIjNsIO6DQPOVUg3NbPmSdEJBHU+uAnj4Vw4M2fh1sUfKL7DtJUHWim5SvfPubW xDT/8I86IgtE+G5ga7MnFpGBWwbCGkR9d2MZShuYQZvjmwSuLF8APah0e1KEtBOZQI8C Ua+fq2EDPSp0nyhE8ARzRXH73Qok254yaG7UJH2B0YJJDzuee7n7oSwsPNUPRSr4s3Ll YYu25eyEOzsqZ7nw5MH4NHgDf5Nsyu1lZUoY35BCEu3JFihl8fns1N7A2ts+ywcru9rf 5tGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685038252; x=1687630252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1cuVcFNfYtthmtIf50Jsd3dfSKJk8+H2W+YHx6/HyPI=; b=Rukke6rHWx2T9VpYJGDMkPhmOVPH8JP8S/B+q7T5ISnh//4frhaRWSkPJ1V5veFLLk E0KQLDXmOhNedg52zIsiZsonJ1zBr81EZAYGLxrtEcTVieuEobSzVPTo8wTjfKMZHww5 0Nc1nxapJZBFDKZZu0OvtdHduCYpaZKgBi5wQkG74MCuwmL3UEVRstwh4OaqHBcj/yh3 V2RYwqglNKgIa8HRLoJKU77zQU0CMP8c4Sdx4wVJxvpPfnD6kQR/LelAzKutDjEUaCAH uk6bkdIT/q7+7CMfBetIKLTphNzkNnPsTRDu+NAWc5fDp0KdCcpq6JimpJSqW6txD2NM Evwg== X-Gm-Message-State: AC+VfDzF0IS9sXIgOpxSTiVY4hhu1LaQ0VRLPT4CmbFiWmmv7Usa2CEO NaGo+5npUwnsZXdfRc+RM261kYwZ1c9X1Kleuzc= X-Received: by 2002:a17:903:44c:b0:1ae:4dda:c2e with SMTP id iw12-20020a170903044c00b001ae4dda0c2emr2591094plb.13.1685038252174; Thu, 25 May 2023 11:10:52 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id m18-20020a170902db1200b001aae64e9b36sm1710243plx.114.2023.05.25.11.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 11:10:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Daniel Henrique Barboza Subject: [PULL 17/23] tcg/riscv: Use ADD.UW for guest address generation Date: Thu, 25 May 2023 11:10:30 -0700 Message-Id: <20230525181036.1559435-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525181036.1559435-1-richard.henderson@linaro.org> References: <20230525181036.1559435-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The instruction is a combined zero-extend and add. Use it for exactly that. Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 297119817b..2fdd450da3 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1038,14 +1038,18 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, TCGReg *pbase, tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP0, TCG_REG_TMP1, 0); /* TLB Hit - translate address using addend. */ - addr_adj = addr_reg; - if (TARGET_LONG_BITS == 32) { - addr_adj = TCG_REG_TMP0; - tcg_out_ext32u(s, addr_adj, addr_reg); + if (TARGET_LONG_BITS == 64) { + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, addr_reg, TCG_REG_TMP2); + } else if (have_zba) { + tcg_out_opc_reg(s, OPC_ADD_UW, TCG_REG_TMP0, addr_reg, TCG_REG_TMP2); + } else { + tcg_out_ext32u(s, TCG_REG_TMP0, addr_reg); + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP0, TCG_REG_TMP2); } - tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP2, addr_adj); *pbase = TCG_REG_TMP0; #else + TCGReg base; + if (a_mask) { ldst = new_ldst_label(s); ldst->is_ld = is_ld; @@ -1060,14 +1064,21 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, TCGReg *pbase, tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP1, TCG_REG_ZERO, 0); } - TCGReg base = addr_reg; - if (TARGET_LONG_BITS == 32) { - tcg_out_ext32u(s, TCG_REG_TMP0, base); - base = TCG_REG_TMP0; - } if (guest_base != 0) { - tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_GUEST_BASE_REG, base); base = TCG_REG_TMP0; + if (TARGET_LONG_BITS == 64) { + tcg_out_opc_reg(s, OPC_ADD, base, addr_reg, TCG_GUEST_BASE_REG); + } else if (have_zba) { + tcg_out_opc_reg(s, OPC_ADD_UW, base, addr_reg, TCG_GUEST_BASE_REG); + } else { + tcg_out_ext32u(s, base, addr_reg); + tcg_out_opc_reg(s, OPC_ADD, base, base, TCG_GUEST_BASE_REG); + } + } else if (TARGET_LONG_BITS == 64) { + base = addr_reg; + } else { + base = TCG_REG_TMP0; + tcg_out_ext32u(s, base, addr_reg); } *pbase = base; #endif