From patchwork Wed May 3 08:56:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 678799 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp940037wrs; Wed, 3 May 2023 01:58:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6J4NtLir17APkLrW0fHnebGqB5bRDKTFniIdo9GQDR4OfvXBiQbDZ8pkyigAvKjLXCDkSC X-Received: by 2002:a05:6214:762:b0:5ef:a772:2731 with SMTP id f2-20020a056214076200b005efa7722731mr8364456qvz.11.1683104307009; Wed, 03 May 2023 01:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683104306; cv=none; d=google.com; s=arc-20160816; b=Z+mz8ngAuPwYVG1X106/4j4ZQL18MGYiju1Cmi9nlbDl7OKkrd3xZG/mNwW/wiQVuB 86COaKRaY8fkVwFumif2ClO4ApSA2MD4JEQN3uG9R2VgDsdYUlHNOeOr3zq8Nysf0vBA aUIN5eHQdLNPbeSc1xOlKa3rBn1o8RGBfEAjaOAwoav9gmMoqN6Y3Nv54soVOZ6Tj0uJ 2xPS8971KlcYE9kje1lSuL8pdhTWCxrPAtRKyLh8q/SSpFT0T9ec6pV3bpjdxtXai2tM AKyZD23AZ7uAyOca46Ie680tOaxXJKSpyLtR6kA5mDpRosT92Hgksz5pCoq5qfpypLEu 5d/Q== 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=HW8JSRn5RMrJ+UuW0TSqtYpPCYz7WFz757nhPdtnQaI=; b=QlZ5nMjjWZQrCSmBC4Am79c2InqxWeaK6Qf1pJEjJZH3rwvMVDfOWXWp5TfYw79Lx+ BGKs7EdB5YX3eUmC25ivtAkEo8aFhqwt0Hc37A1oTbNWRwopRBcfP+2NBU3E6Xhmzo9E lwRH9nRSG97Hmw0SB7m/8XgaGj93j/A4kX9YvOgMJEVD1auabWeYvtEldA6TY+28FCL3 w1r1O5O6ROzmw9QckR6N2yiAABMTh6KTaF+laSfE6DnWZ260zzIxDf5h7/wPuDHbO6QI 3Ls5bJAqHJ1s3tnnlhHQJENAlrjyAysODl5IocZ5ae1EF1J9ApV46Tc+kFqMNIhR2ANj HnmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M+mbFJCy; 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 x9-20020ac85f09000000b003e3fd9085d6si18638906qta.475.2023.05.03.01.58.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 May 2023 01:58:26 -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=M+mbFJCy; 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 1pu8IM-0000wl-Ft; Wed, 03 May 2023 04:57:06 -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 1pu8IK-0000vW-67 for qemu-devel@nongnu.org; Wed, 03 May 2023 04:57:04 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pu8II-0006c2-De for qemu-devel@nongnu.org; Wed, 03 May 2023 04:57:03 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f19afc4fbfso48537875e9.2 for ; Wed, 03 May 2023 01:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683104221; x=1685696221; 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=HW8JSRn5RMrJ+UuW0TSqtYpPCYz7WFz757nhPdtnQaI=; b=M+mbFJCyxGsW+d7QWHayicsLeOACU+PoQ0mv0bg3ALw0ZmOvU07Agn+TmaFs6729Q1 e7qFTEB87AgWw2kT2GKPkSiLl4sWMzcEV0BCRrq3x8jj97jqfk55gkyqeBRoN2+lIY2J QKMIONfK0ZQPV2gfikQzfO25sGXb8El7v98S2Q73D3DnQWEUIFz2BhcT9ebDTOkI5Xmr acL5pFfxu1AmKIEvJZgLvL11OyWKN1y+FtidJtni8apzGhdr4mCYa29jmrpJ9ZIKS00v Q/KkBjg98oMnk2pTk0CW4NQ0aL1pWIYk/056yWM1LR7XcH861AA7v2LgJGXR5El5mVr7 4jhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683104221; x=1685696221; 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=HW8JSRn5RMrJ+UuW0TSqtYpPCYz7WFz757nhPdtnQaI=; b=aciB3Umt7tmtO6UnmWPbLB0ovPSLAZdw3hGjRm8Yvaby+OQFlaSEfIpMd9C15AMfM9 RGtAZCK8qKeJYKZ0++mNTGNbkB4DRLHYb8FgHYtCUrfifzFEf/ug92yxC2Ueg86Jq3O7 YH7Ev4rWZAPs9r1/UBXqkyLo7JW0pWIIJzzLwpo4vTfeg25fHrHswLWHj2tDTYx6R1Vn cV0JOmzC34QOSER7QwSZcZPqu0/q5zmfmpQgNZVVotUCa+gxdVYmMxob7Aa0Mg/NryQt lqtwkBEpg7zANzZeesUQdSB9dKOMf6WyWM2+QGPSaEt2QBIBh5iKmzIEnuFH2+jev+Bu k7jw== X-Gm-Message-State: AC+VfDzv2f3hqHmTvGpLxCkHJzuja9z/ERw4KysxppW3KIsxI0t78RiI Pb7Ow5O9rWBwqIbVHQrkB5hezsyINBc6EzBTxNpKlQ== X-Received: by 2002:a1c:f30b:0:b0:3f1:75d2:a6a7 with SMTP id q11-20020a1cf30b000000b003f175d2a6a7mr14614605wmq.36.1683104220894; Wed, 03 May 2023 01:57:00 -0700 (PDT) Received: from stoup.Home ([2a02:c7c:74db:8d00:c01d:9d74:b630:9087]) by smtp.gmail.com with ESMTPSA id f26-20020a7bcd1a000000b003ef5f77901dsm1191307wmj.45.2023.05.03.01.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 01:57:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: dbarboza@ventanamicro.com Subject: [PATCH 05/11] tcg/riscv: Use ADD.UW for guest address generation Date: Wed, 3 May 2023 09:56:51 +0100 Message-Id: <20230503085657.1814850-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230503085657.1814850-1-richard.henderson@linaro.org> References: <20230503085657.1814850-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x334.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. Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza Acked-by: Alistair Francis --- 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 53a7f97b29..f64eaa8515 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1039,14 +1039,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; @@ -1061,14 +1065,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