From patchwork Sun Feb 27 02:04:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 546434 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f50:0:0:0:0:0 with SMTP id l16csp1609719imf; Sat, 26 Feb 2022 18:09:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/1oi9gKpZUbniKPG76Cy8Sn7D6rw12PnQUqxy+X7e3jbXQTYJl8vLDcPRV4mKIz9shXr3 X-Received: by 2002:a25:aea3:0:b0:624:7f0a:d46f with SMTP id b35-20020a25aea3000000b006247f0ad46fmr14345097ybj.212.1645927744633; Sat, 26 Feb 2022 18:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645927744; cv=none; d=google.com; s=arc-20160816; b=z+TvbfLb8FQy7aAk9otztkWZ8+KwS/S86sZ1w1LHe0Vob4g2cogRzo1rWLY+3Es5bF dbaLNBhgA5GjuYL3yv/gLp2nUCo0IyFjTQCwli0tmAXMfQ9LwkBghALWsX7nzNJAaC1H wPStI4D3lju++058RNYCRQ2DBbkpWbkpk3NJYMMHXhtmMD/iLe+dgCDLGRACv+XwI/r3 zsDNBpL+1XtSkFE+2mkIivuyvdWS9rj5gihERx4sNu39d8WqgBcXI1I2p7Sxdvedh/jQ DwmZY+c3SMdbclExniq197VYTjsvkpo9Cd5o4ulazxPd/HeJY7L/ExO2EStfgSuwowXL US8g== 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=Ho2jnp9wAsj5SBP8tX6ESXDweHDs0USlRJ9dHfy8f/A=; b=uSilPJ69s2+WKJ4mBuIzjE7ilaGC/xtXxdIHtuNPK5CXIll0G7jAU5/cLnCJxYNuu3 JqI2YUy+lEDGm2U6Lp7cQC1CMr7HpX52HSRtg/0EXyLrzxNjMxu/sCAvj4clfnp+zsLA 2UoiahgpN4hQa9ptDVD6iT8vz0iQLGaUpBqOsiiceWN+9jIze/rYtJ8qGittyUgt3Lp/ 2f4RKFDX2WIPhoe6LOFpUsFAdA8PTgedumoCJ9WJ1azIGReY3drozsh7CdQrw61aqMPv RUpzByB2ARFYEta8GVChWP+IjX++1rYCV9xIVoqt2zpxGPQPYZmZeXauk0vI5ACVNbS/ Kf1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KU+EWlGk; 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 o4-20020a252804000000b00627f4e2019csi2817900ybo.572.2022.02.26.18.09.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Feb 2022 18:09:04 -0800 (PST) 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=KU+EWlGk; 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]:46730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nO8zf-0008L5-5g for patch@linaro.org; Sat, 26 Feb 2022 21:09:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nO8vd-00033A-BD for qemu-devel@nongnu.org; Sat, 26 Feb 2022 21:04:53 -0500 Received: from [2607:f8b0:4864:20::42d] (port=46754 helo=mail-pf1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nO8vP-0007TJ-Tt for qemu-devel@nongnu.org; Sat, 26 Feb 2022 21:04:52 -0500 Received: by mail-pf1-x42d.google.com with SMTP id i21so7942546pfd.13 for ; Sat, 26 Feb 2022 18:04:28 -0800 (PST) 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=Ho2jnp9wAsj5SBP8tX6ESXDweHDs0USlRJ9dHfy8f/A=; b=KU+EWlGkQ0XR+qzYWE3RzOQp+DSmVlpFOjjDYia9HMFhKBPQWogyTReBDXXbt0NnBm 1qvOkLqc7GHYeU13lvRPJ/NKpoTAYJ3s7qnRuWd0vWad9ZEO6s2Q+fRcTekCOBAetI9K iEjENsLVMBhfSr6GHBrmJuToUf8ZFicH7Tl25phvX19M3mHGN7Y/Zk8alyfYYrq5w8g3 vJ30Zs4jTzC6Yz+jpyvItxbdvCHXsoXtSMSmC5ligLR4Z5zW9yZtHllFrPvYH/JyiGmp HiNoIMyDeU4FmUikEtJndgVk9SRqEDIVIa54Ii0lvcZmzoZSGe1BcLCNoz6lBPlRGM4f sHmQ== 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=Ho2jnp9wAsj5SBP8tX6ESXDweHDs0USlRJ9dHfy8f/A=; b=z3XutDY91WfgrVezh8CZReYFDzNMfTzTtPl5G5sHl1jX0ZWpAIaSvwjH3f9X3fubje 2FxXwwbVf178Yx6Y702+bIjWCFBR1ZgR59CTfGCrXuSEQpMu5ohHwCIYTcDfxWJUYsGX KCtQmVlYdBQOs08WxJzV0Kp1942y08v4Ot5s+DeegELjSfeIGSycq/myvQdjGRCte5qi OeEj6tbfiIjolUhTVv7xL/D3aVGUjze4VrTaaxnGtB8L/D4PbmBkWvCo9N3YO92gnViV rs59gPJMgyqBjsgGa6xjvIyg6y325txiJ8W0f2SlkgCAM/L2ZsA84EPugSJ5+wkkFEo6 yYMA== X-Gm-Message-State: AOAM532mb67axKfYqLRrRH77MlzuD+8wv1pNkJ12az8VbuThDTxNlVn/ PRSe3y94IUzOHHy3BuhFMy31C1A3dtveQxXS X-Received: by 2002:a62:7846:0:b0:4c7:f23e:1fd7 with SMTP id t67-20020a627846000000b004c7f23e1fd7mr14932903pfc.67.1645927467134; Sat, 26 Feb 2022 18:04:27 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-9001-d56a-9ee0-0246.res6.spectrum.com. [2603:800c:1201:c600:9001:d56a:9ee0:246]) by smtp.gmail.com with ESMTPSA id q13-20020a056a00088d00b004e1bea9c582sm8304021pfj.43.2022.02.26.18.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 18:04:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 8/9] tcg/riscv: Support TCG_TARGET_SIGNED_ADDR32 Date: Sat, 26 Feb 2022 16:04:12 -1000 Message-Id: <20220227020413.11741-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220227020413.11741-1-richard.henderson@linaro.org> References: <20220227020413.11741-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: Alistair Francis , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All RV64 32-bit operations sign-extend the output, so we are easily able to keep TCG_TYPE_I32 values sign-extended in host registers. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target-sa32.h | 6 +++++- tcg/riscv/tcg-target.c.inc | 8 ++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tcg/riscv/tcg-target-sa32.h b/tcg/riscv/tcg-target-sa32.h index cb185b1526..703467b37a 100644 --- a/tcg/riscv/tcg-target-sa32.h +++ b/tcg/riscv/tcg-target-sa32.h @@ -1 +1,5 @@ -#define TCG_TARGET_SIGNED_ADDR32 0 +/* + * Do not set TCG_TARGET_SIGNED_ADDR32 for RV32; + * TCG expects this to only be set for 64-bit hosts. + */ +#define TCG_TARGET_SIGNED_ADDR32 (__riscv_xlen == 64) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 6409d9c3d5..c999711494 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -951,10 +951,6 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP0, TCG_REG_TMP1, 0); /* TLB Hit - translate address using addend. */ - if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { - tcg_out_ext32u(s, TCG_REG_TMP0, addrl); - addrl = TCG_REG_TMP0; - } tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP2, addrl); } @@ -1175,7 +1171,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) data_regl, data_regh, addr_regl, addr_regh, s->code_ptr, label_ptr); #else - if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { + if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS && !guest_base_signed_addr32) { tcg_out_ext32u(s, base, addr_regl); addr_regl = base; } @@ -1247,7 +1243,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) data_regl, data_regh, addr_regl, addr_regh, s->code_ptr, label_ptr); #else - if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { + if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS && !guest_base_signed_addr32) { tcg_out_ext32u(s, base, addr_regl); addr_regl = base; }