From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644306851; cv=none; d=zohomail.com; s=zohoarc; b=ZpyGZ6GJJMAk5aGxCIKWU7U1s0JsEF7Ui+5dng1ZeiUKyndTP0tttgd7CqKTMJVyHE0lzO7L+PbyjY809mf0HtGL8pshuy8/xsa24OWW0weeVzoc5QtVY7q7dLvvepJ4bmd5wWgAMaoMqwhfBGVW9EzNVa1p9CJXamsnldjbiqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644306851; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8UZVMY0pvo1xV7MrFt0a3sWDGzIB2xwb969t7jjX7iw=; b=jWIre4KhCEoCWD7eaLK/dzcu00xNCeaN7BxxyVDUb0ZhncbAcxTnLa1dHkChkaJAhRh7L2MZu6SHa0PuKQ+4NSz8ndavIbEiHbCOwIHWGxPPG1hGLjhSAh7MsQ0Mms0k3+ZS5neQBmFnRjA4sLUGD1U0cz5DPZzSD3y/b9a1Ds8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644306851108679.7110071100171; Mon, 7 Feb 2022 23:54:11 -0800 (PST) Received: from localhost ([::1]:38160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLKD-0006AA-Gq for importer@patchew.org; Tue, 08 Feb 2022 02:54:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKkc-0000Ns-1Z for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:22 -0500 Received: from [2607:f8b0:4864:20::102d] (port=42553 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKkZ-00017u-24 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:21 -0500 Received: by mail-pj1-x102d.google.com with SMTP id my12-20020a17090b4c8c00b001b528ba1cd7so1794139pjb.1 for ; Mon, 07 Feb 2022 23:17:18 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:17 -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=8UZVMY0pvo1xV7MrFt0a3sWDGzIB2xwb969t7jjX7iw=; b=ekHLtPDnLfgwIVfYaq/1dnHpgedAFmkBDXfrE0z51GOeDbykevx1ppb6hjkLjb1KUu gBS791CA7fMAa2WmuWEupxK86U5Jxj5jKNU8heZeHaxO0QYTcIYUwWTgfUEwgDUAuyCK OF+28rgTsUNT0hruhY5qebRAUePB7mBuQ/2CC+CW7oIgr3uu/8GTtC2DuIP4v1XVMmO8 euNcdbwneuzrHxhe5b/lRzOpPOgA+Avz0afg1A49k5VUmgu2WZKRGIT6fpijQ4NwvrJA qPNHNpbj4Zd/HfSUMaNNWKH1M/13wMdSJeeKAN4pVFB149NTI0fVxRV7ZvE7d/6M+s2W 4IZA== 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=8UZVMY0pvo1xV7MrFt0a3sWDGzIB2xwb969t7jjX7iw=; b=zapE5CTQBrEpDpoVKjXDVVpKJvPG9ZgTUHk9X1+nQ83UqDAy4wxqsrzl51I4Xp/xCd HULrFXIVY/2OXcQoZmir7T2Pr0pLgN7hNE5cIPkh5vV25lmKYlR1SQ/T2XtCMHL5PXtm Y8Npb/CH6gAjxCr8OluQlFmA64tVcThYsErMv23TOwQctWc6ENAjAFNzy9dOoDUIp8Vf nW6VBVeWw5aJFCORK2thjd3r2cIQ6s3hV9Yy1XL7MSIMNNdyuYRfM04bbxQVo+76SCen C30EIulNoNZMMjKqOTHwUMvhduWG+OwaQgqjDTgXUt6RhNn12OvGWPbsME4BFETN1f2l x47w== X-Gm-Message-State: AOAM531iGmmURXMXkjh1CY/qU3YMNPhvFBvY2l+2RKF4+sthq3eP03jC 6Hq7swZpqLrctwR+Q1HCuXfqaNucyNK1Tg== X-Google-Smtp-Source: ABdhPJwxHwpVU0TQ6fG3hsDdaRWwCinrDqzEBYt6gMSGWt/sP2mQHL2WF7czatcD8NPMisuElEUmIQ== X-Received: by 2002:a17:902:dac8:: with SMTP id q8mr3325550plx.57.1644304637771; Mon, 07 Feb 2022 23:17:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 1/8] tcg/sparc: Use tcg_out_movi_imm13 in tcg_out_addsub2_i64 Date: Tue, 8 Feb 2022 18:17:03 +1100 Message-Id: <20220208071710.320122-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644306852905100001 Content-Type: text/plain; charset="utf-8" When BH is constant, it is constrained to 10 bits for use in MOVCC. For the cases in which we must load the constant BH into a register, we do not need the full logic of tcg_out_movi; we can use the simpler function for emitting a 13 bit constant. This eliminates the only case in which TCG_REG_T2 was passed to tcg_out_movi, which will shortly become invalid. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- tcg/sparc/tcg-target.c.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 0c062c60eb..82a7c684b6 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -795,7 +795,7 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg r= l, TCGReg rh, if (use_vis3_instructions && !is_sub) { /* Note that ADDXC doesn't accept immediates. */ if (bhconst && bh !=3D 0) { - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_T2, bh); + tcg_out_movi_imm13(s, TCG_REG_T2, bh); bh =3D TCG_REG_T2; } tcg_out_arith(s, rh, ah, bh, ARITH_ADDXC); @@ -811,9 +811,13 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg = rl, TCGReg rh, tcg_out_movcc(s, TCG_COND_GEU, MOVCC_XCC, rh, ah, 0); } } else { - /* Otherwise adjust BH as if there is carry into T2 ... */ + /* + * Otherwise adjust BH as if there is carry into T2. + * Note that constant BH is constrained to 10 bits for the MOVCC, + * so the adjustment fits 11 bits. + */ if (bhconst) { - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_T2, bh + (is_sub ? -1 : = 1)); + tcg_out_movi_imm13(s, TCG_REG_T2, bh + (is_sub ? -1 : 1)); } else { tcg_out_arithi(s, TCG_REG_T2, bh, 1, is_sub ? ARITH_SUB : ARITH_ADD); --=20 2.25.1 From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644307444; cv=none; d=zohomail.com; s=zohoarc; b=L/A/3DaHqNxYguTZsXvJe1QPBDOCE3q4xzko3vk8/BwcTLyXPRX0wl6WfR3j92Ev9W/qNUED35Eum+mdKz5TMLPe/88Qy3NSzvBaF86qgltJpkDjfT3j9MYFTVRtfmczxcVrYWmDo67cDtPB4n0Pgu7pyj/kTAeDLMJSLw1Bzco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644307444; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iWGhaZHijfvDesszGrFn/aH0aQI0aOahuchhLdkaRxg=; b=gJqRv1tjTJ5880L4Npg7tGPD8BA/bVvhWGpFCkYRazqDRLzoJn32p5BW5PBpxfUJ2B1utu5BNNwW8BhF+qtmz/GLj0krkEpqW03YKv4xoyK0PG8k4+Hp7wtSryDBhDEjBW1uGOJgDNgroD/jswyTcOenVo5mz9zaNU6P1Lod0vU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16443074446640.32079124716096885; Tue, 8 Feb 2022 00:04:04 -0800 (PST) Received: from localhost ([::1]:45946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLTl-0003GB-KD for importer@patchew.org; Tue, 08 Feb 2022 03:04:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKke-0000ON-B9 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:26 -0500 Received: from [2607:f8b0:4864:20::102b] (port=37443 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKkb-00018A-Av for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:22 -0500 Received: by mail-pj1-x102b.google.com with SMTP id v5-20020a17090a4ec500b001b8b702df57so1317089pjl.2 for ; Mon, 07 Feb 2022 23:17:20 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:19 -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=iWGhaZHijfvDesszGrFn/aH0aQI0aOahuchhLdkaRxg=; b=gmYbOyHnRRx25PqbtkoldsWGj829upddaG0l7dqxwlvXsg+T6IxD9Yv/R8r+7IlAP1 4jRt0juUpwoJtaLKj6THF/6QZUp0YHDm4hUuXV9rzfl/CSQqQxpIpWC1NZr/nGk3HKwr 8YPt7BEtviv3xnJYkkcjgdTqhtB0kZavxSHTH662tTHQI6Ix1QmHwR6d/9DyN3PzjRGN Ctfa5yWOf/NlLp8YrRC9HnZcCZhTi8eZlDHXSLliZV0qjVcpXGkyhzR+KeXBzecL/p1r PsNh8WnLBVGvHuQYT1oHjv+iq4QvtyzhXiJo+GeuvPeM8Asun73x2dokIcGx5/EasENu hfLw== 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=iWGhaZHijfvDesszGrFn/aH0aQI0aOahuchhLdkaRxg=; b=Jb78veqw5OQOJa/CkVa4MEHNtxUaChKNidM17uZ9weaiwjboJ61kvPQYD2VLwhRFd6 msB758iNkMNa/saO/E+wz1NV5fCr8KcllTcVHYDe76J1m5dmFvGgOgF+MasCLVuKfP9W X3JMOuA4gjs7ZECVc8O7K62NivbGgfqnU5Ivdnj2QRkM6lPcy3V1I+gF1DlV8UeBS0A7 1G3wx2pdPrcglkH87DHb3sRnOJfJcWE/tiR6uBedZ/tIyDpilaSXekvYsTeVkeRUAOOV 8sGmItFjBuqwtOLKOn/ndEGmizjqmsNczGHzEbrYcgdLZHhkszF8W9Ofi8IpSE5mpH7V w/HQ== X-Gm-Message-State: AOAM533lle2/WIUGje7yPPOfUVY46hv1KAvystVDxaK/w8upmdWwoXpL jKNLehG+hRRU3BfPdp7sHIFT4nT5Y9pJzw== X-Google-Smtp-Source: ABdhPJxW4p+7gfKLDPLWMeY7uxeLBwAsuf0WXOKJ5N5qNYwn/ihqXzbH69sur0QUJHP4+HWFrCw7Zw== X-Received: by 2002:a17:902:eccc:: with SMTP id a12mr3371454plh.140.1644304639970; Mon, 07 Feb 2022 23:17:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 2/8] tcg/sparc: Split out tcg_out_movi_imm32 Date: Tue, 8 Feb 2022 18:17:04 +1100 Message-Id: <20220208071710.320122-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644307446807100001 Content-Type: text/plain; charset="utf-8" Handle 32-bit constants with a separate function, so that tcg_out_movi_int does not need to recurse. This slightly rearranges the order of tests for small constants, but produces the same output. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- tcg/sparc/tcg-target.c.inc | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 82a7c684b6..576903e0d8 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -413,15 +413,30 @@ static void tcg_out_movi_imm13(TCGContext *s, TCGReg = ret, int32_t arg) tcg_out_arithi(s, ret, TCG_REG_G0, arg, ARITH_OR); } =20 +static void tcg_out_movi_imm32(TCGContext *s, TCGReg ret, int32_t arg) +{ + if (check_fit_i32(arg, 13)) { + /* A 13-bit constant sign-extended to 64-bits. */ + tcg_out_movi_imm13(s, ret, arg); + } else { + /* A 32-bit constant zero-extended to 64 bits. */ + tcg_out_sethi(s, ret, arg); + if (arg & 0x3ff) { + tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); + } + } +} + static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, bool in_prologue) { tcg_target_long hi, lo =3D (int32_t)arg; tcg_target_long test, lsb; =20 - /* Make sure we test 32-bit constants for imm13 properly. */ - if (type =3D=3D TCG_TYPE_I32) { - arg =3D lo; + /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ + if (type =3D=3D TCG_TYPE_I32 || arg =3D=3D (uint32_t)arg) { + tcg_out_movi_imm32(s, ret, arg); + return; } =20 /* A 13-bit constant sign-extended to 64-bits. */ @@ -439,15 +454,6 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, } } =20 - /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ - if (type =3D=3D TCG_TYPE_I32 || arg =3D=3D (uint32_t)arg) { - tcg_out_sethi(s, ret, arg); - if (arg & 0x3ff) { - tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); - } - return; - } - /* A 32-bit constant sign-extended to 64-bits. */ if (arg =3D=3D lo) { tcg_out_sethi(s, ret, ~arg); @@ -471,13 +477,13 @@ static void tcg_out_movi_int(TCGContext *s, TCGType t= ype, TCGReg ret, /* A 64-bit constant decomposed into 2 32-bit pieces. */ if (check_fit_i32(lo, 13)) { hi =3D (arg - lo) >> 32; - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); + tcg_out_movi_imm32(s, ret, hi); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); tcg_out_arithi(s, ret, ret, lo, ARITH_ADD); } else { hi =3D arg >> 32; - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); - tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T2, lo); + tcg_out_movi_imm32(s, ret, hi); + tcg_out_movi_imm32(s, TCG_REG_T2, lo); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR); } --=20 2.25.1 From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644308063; cv=none; d=zohomail.com; s=zohoarc; b=KuKKoUWGWJ3P/E/mrBND2wlDtVZn8d5z+ajogaeysJW9EIjjtkVnJM+/ZG1t2pjaxYFqdjhq8UfuX55RdLRno9xwjA9qKRbrAGelXTMpcBL1cYNP2dYQiRTZvusOT/Is2dNzOr98H7sNRgAiM7eKdYVwd0P8JY3MknpjSHdV/K4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644308063; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dUr/cOpdXcovl9VYgkicbpsTWqKsk7pQ35LtJatklyk=; b=FUflqnrXeXp/U30lZQ/ZAXt8NrGViWjls53yBW/VVl0AxHf+yz6PEuClau4lFVzY3mb+Lz11Izf3CoqrrTbqpAJMntdZv/f6zIdBEHVynhGQl6zv2KQA5/qI/g5F1oEdD4nut/RkaLx3orQFiNRAvjBTqajmFefQCzWQdqUKYoM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644308063878109.61545927743805; Tue, 8 Feb 2022 00:14:23 -0800 (PST) Received: from localhost ([::1]:52200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLdm-0008Mf-BI for importer@patchew.org; Tue, 08 Feb 2022 03:14:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKkg-0000Of-93 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:27 -0500 Received: from [2607:f8b0:4864:20::42d] (port=47098 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 1nHKke-00018K-1m for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:25 -0500 Received: by mail-pf1-x42d.google.com with SMTP id i17so17347279pfq.13 for ; Mon, 07 Feb 2022 23:17:23 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:21 -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=dUr/cOpdXcovl9VYgkicbpsTWqKsk7pQ35LtJatklyk=; b=nxkp5w1fGUhwgZ7w84j/t1iyduJopxKEfF01+BEaYZJfE8SjdCT74G7PmIYOFhPmqT WulOjJx82n4mozGvoK47R77aIsA2+jM5AK6/d1sSw/Pl1haN6yKuulIzaMh0HOVXpEko fMwDkDL6m66bIkpbcByhxjulVKBMSSXEjuj/bODRo4sXqSBUG0nE2u3fbmynZFhJ8+YI m1dFbpn5rw2s2sA6KvB3WEV/AwIQR6r8mV/ti961p3piOEAg864vD0ObsLGB1y9DeyLs DOU4SMp8hodXrIzQsw/QUGQsvPh6WBsM2vwFi4fE+b9hKkhPMg5mC2V7ElUvXcGfo1ZL /GAg== 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=dUr/cOpdXcovl9VYgkicbpsTWqKsk7pQ35LtJatklyk=; b=recEhbjy9syCSa32YEjawh2OzWN9TqWJ+NnrUPsoK61PRO3QU9mu9gi56aGsim2MAc pshgUyJrmMB7ThtLC5RkMR/GkzHS9qDuI/rlkAhmlIEDNkNDha1eP8AiuDhQPmzj3oCr 6yUlRDauhNfOxCo0tu2roqMsIUgHeLV/WdhB0HLzwIzWaVYDAps/KENs6dboDCBKLCcR XuG7pVBFPVxeoBHsfWjtbZ/xdiQBbO1OnebGE4tB2c651wKHP3W6uodcXuhcaNSx2UMu VWwlonEek2Owv3ZNAEVMrWe75XklAvvqU8GrB9jk+t+RxWUsamXSfhyozaN44ZehNrKR +poQ== X-Gm-Message-State: AOAM530sooPPqFnK+QaEEbjvPYAN9VncBxAzvuhuSwwIdWKAL7KKhYkm McP2Ac5DLi/Z6EmINESbnE2O5ZwxN3lGjQ== X-Google-Smtp-Source: ABdhPJwfLKDM4zBi/Q664TRQv96BHjDYLNobWEZJlu7mztKx0KONGu7jEXCNPL9K0W22eQdcRV/qcg== X-Received: by 2002:a63:f508:: with SMTP id w8mr2557383pgh.236.1644304642178; Mon, 07 Feb 2022 23:17:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 3/8] tcg/sparc: Add scratch argument to tcg_out_movi_int Date: Tue, 8 Feb 2022 18:17:05 +1100 Message-Id: <20220208071710.320122-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644308066636100001 Content-Type: text/plain; charset="utf-8" This will allow us to control exactly what scratch register is used for loading the constant. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- tcg/sparc/tcg-target.c.inc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 576903e0d8..7b970d58e3 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -428,7 +428,8 @@ static void tcg_out_movi_imm32(TCGContext *s, TCGReg re= t, int32_t arg) } =20 static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, - tcg_target_long arg, bool in_prologue) + tcg_target_long arg, bool in_prologue, + TCGReg scratch) { tcg_target_long hi, lo =3D (int32_t)arg; tcg_target_long test, lsb; @@ -483,16 +484,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType t= ype, TCGReg ret, } else { hi =3D arg >> 32; tcg_out_movi_imm32(s, ret, hi); - tcg_out_movi_imm32(s, TCG_REG_T2, lo); + tcg_out_movi_imm32(s, scratch, lo); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); - tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR); + tcg_out_arith(s, ret, ret, scratch, ARITH_OR); } } =20 static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { - tcg_out_movi_int(s, type, ret, arg, false); + tcg_debug_assert(ret !=3D TCG_REG_T2); + tcg_out_movi_int(s, type, ret, arg, false, TCG_REG_T2); } =20 static void tcg_out_ldst_rr(TCGContext *s, TCGReg data, TCGReg a1, @@ -847,7 +849,7 @@ static void tcg_out_call_nodelay(TCGContext *s, const t= cg_insn_unit *dest, } else { uintptr_t desti =3D (uintptr_t)dest; tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, - desti & ~0xfff, in_prologue); + desti & ~0xfff, in_prologue, TCG_REG_O7); tcg_out_arithi(s, TCG_REG_O7, TCG_REG_T1, desti & 0xfff, JMPL); } } @@ -1023,7 +1025,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) =20 #ifndef CONFIG_SOFTMMU if (guest_base !=3D 0) { - tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base, = true); + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, + guest_base, true, TCG_REG_T1); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif --=20 2.25.1 From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644311792; cv=none; d=zohomail.com; s=zohoarc; b=k0BFf/jAMYJnXEmdpPMVGHFGjoCzcRh7vcuxG7rRy72vJ4qb9Vrr4MoHeVKhUMuLwfoY+9Bz/tlpSzTjaWFotRNRL4gx6HtKNiRatWco0BgOPN8UA6zFkGyNAi2yVWnVW7d9G/mwCtpvIO3+dABKK2VXvPiEVhZpA2BvT6Tblzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644311792; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jgtTnfo81kkT6c5wNQ4JQkcFM5VRPLfNjOe5kccFu/k=; b=hK2lor5QpCw2CniF0nKdOcFSCC8D7vN5flrkj0Oe762xuXtqhHd/dr6UXkCoBhNWMMqhhN6imF8A/CBTKwUmowPbCLd2mJlcUEPAVUVb+VahaV/pnvHKoIUHjACfvLufjDdLFTK9w7ETN/gOz7Yvdo8R6ugoBHMAGwlyVFMKcPo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644311792406441.85714436299827; Tue, 8 Feb 2022 01:16:32 -0800 (PST) Received: from localhost ([::1]:53014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHMbv-0001HU-8p for importer@patchew.org; Tue, 08 Feb 2022 04:16:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKkh-0000Ov-WF for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:33 -0500 Received: from [2607:f8b0:4864:20::42c] (port=40785 helo=mail-pf1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKkg-00018U-0w for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:27 -0500 Received: by mail-pf1-x42c.google.com with SMTP id e6so17357236pfc.7 for ; Mon, 07 Feb 2022 23:17:25 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:24 -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=jgtTnfo81kkT6c5wNQ4JQkcFM5VRPLfNjOe5kccFu/k=; b=FNheBTqHJ8zzzq+Lg/svYEqqr3NvAoKpD1HFGU9DQDNkwZf408wCEWrSHhhjSxmT1u b/222yxlPxvDFwbwMfCTRe98AqnIPyMc0i8xUYpBRLJa6ZHfMDjSKfG8GTbUyva1onvQ JT4ihTlG4At6l09HVnT+NmzpO/eSmnkV5lPVk2Q2YDtR4yqixfUD021K6xBLVxozvKnn /sUj15Rm3nTGrXFiR8/YoIexAkHyTkW3zfPsK7b9+lhZRnm8/NcgTaUZe6YXGBUZGDnf tiJZ/EpraQPzSi1yAft8mRZe5aiGy6XCxmh9YkgAHyeMjg2JbdmMLYgSwrfAKoQEJY7W 6zPQ== 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=jgtTnfo81kkT6c5wNQ4JQkcFM5VRPLfNjOe5kccFu/k=; b=T8DaL+wa5ub7JL7BnsNrhBVoS17/CYkjzXxd5FixCJyJPMkNHGx4henTba1gE94v8K 6CC9cpoVGFBPI/elk+E89ds6qHm+PvRdWyyWceWyZEigH87/I25bWCsiOcASjZ1S5DKW VVM04OIFl337e2hXvEJiAj3ftSjKETs3Az3LjHBVH09kYJ7wWGwGhls+lao4iPrnrnIl UxB+Y1mzPQFF+n7oVrG8QgVe5/d0ncluH+xZTfeMu7N8sBgOJE5Luj68Bl6OCmaPbYIc 8hdAiPv6oXAUUG9hitlYruGpYoAUD06ieS1bhNGLMFK5vMxzB2tbDCt6gryvcOeUwfRW hHEA== X-Gm-Message-State: AOAM530XJwTKyUCmuRW6uO0VR3lx30YqQCgwGbGXg/muwf2sxOm5uKOv 5YnTjX0TOeI+QDawBdlxKNQG6RXgPsFlJA== X-Google-Smtp-Source: ABdhPJyecpKFfOS+dSMC0KgJm9IppgIqoVzAFjIXt+S/LnoBwLWHSTHeN8YmNTokqFyHPpPYEDz20Q== X-Received: by 2002:a63:2f82:: with SMTP id v124mr2454768pgv.139.1644304644718; Mon, 07 Feb 2022 23:17:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 4/8] tcg/sparc: Improve code gen for shifted 32-bit constants Date: Tue, 8 Feb 2022 18:17:06 +1100 Message-Id: <20220208071710.320122-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644311793966100001 We had code for checking for 13 and 21-bit shifted constants, but we can do better and allow 32-bit shifted constants. This is still 2 insns shorter than the full 64-bit sequence. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 7b970d58e3..088c680f37 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -462,17 +462,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType t= ype, TCGReg ret, return; } =20 - /* A 21-bit constant, shifted. */ + /* A 32-bit constant, shifted. */ lsb =3D ctz64(arg); test =3D (tcg_target_long)arg >> lsb; - if (check_fit_tl(test, 13)) { - tcg_out_movi_imm13(s, ret, test); - tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); - return; - } else if (lsb > 10 && test =3D=3D extract64(test, 0, 21)) { + if (lsb > 10 && test =3D=3D extract64(test, 0, 21)) { tcg_out_sethi(s, ret, test << 10); tcg_out_arithi(s, ret, ret, lsb - 10, SHIFT_SLLX); return; + } else if (test =3D=3D (uint32_t)test || test =3D=3D (int32_t)test) { + tcg_out_movi_int(s, TCG_TYPE_I64, ret, test, in_prologue, scratch); + tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); + return; } =20 /* A 64-bit constant decomposed into 2 32-bit pieces. */ --=20 2.25.1 From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644312132; cv=none; d=zohomail.com; s=zohoarc; b=l1iKSDzNnBqnAWl+3Ekh638nGXuAu0A5BMY/3kF9FW1dfpKNO0xNc2og4Wl/TI7yT/2ArIhuTCuaEefiLs22Gw980OsiDbbDjh84CCM7FK3hX2m0kAa/NUgmebJElqRMFrrRBDHuJYM1iaXyAejp4esqOrgJe1kHk/UFTvHg8vA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644312132; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xAVP1v46orjMrIoCb3miSswpoEMk3ZlxrVr6Eb87UTs=; b=daNPpQzWsJ1KKdf2yA1YjMIStNsKOGS4lXYD6BiZUBiMZhh3SAP2c/Bajhm5Gd0hbjSbZxAD2EH/VBhghNqqthKoIHITXEZTeSIBJhehJtBXEmPqglpFv5TGkfgB6sUGGQjrK+6Hf0QGykP21GiRoRD5DpEYzA8f9FYJfPcKB8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644312132956928.4643676640586; Tue, 8 Feb 2022 01:22:12 -0800 (PST) Received: from localhost ([::1]:33248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHMhO-0007Ux-Hs for importer@patchew.org; Tue, 08 Feb 2022 04:22:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKkn-0000Pb-AA for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:35 -0500 Received: from [2607:f8b0:4864:20::1029] (port=44800 helo=mail-pj1-x1029.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKki-00018d-Re for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:31 -0500 Received: by mail-pj1-x1029.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so1787201pjh.3 for ; Mon, 07 Feb 2022 23:17:27 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:26 -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=xAVP1v46orjMrIoCb3miSswpoEMk3ZlxrVr6Eb87UTs=; b=oPgcIO/DwkUyxrpQmSuOGmDH6y+oLuV7gk7tfeZO0b9686Qhjwe6Xq45J9lKmfPSeA O9+VzvfBxZwAH1scxKlN6OkcIKPF3iqRqzmbRVU+ZYDS9VidcWQ8THp7J4WaPNl47cum W0wpJavwcYHIq/FYGDNe0iA2jzqMp0GB8zYhLBKttSLMW7qhPs/zNsev6Ih3FXgeZmC/ hcCA/U8pWmyzwqm0rzjp90IcMe8qvuc8rCx+kVrpaRTJSfzzaznDqHA83Pz1d1PwjzgB RbUxlaawMq63p9eaxeJDpQ+8hAsHDCXtEE1HvP+MVaUewX1Ui1+eQCjLmXEkRxLHvKVg udGQ== 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=xAVP1v46orjMrIoCb3miSswpoEMk3ZlxrVr6Eb87UTs=; b=zOL0PDPZLUEWA6kXVWUmrtMKhekSzfsY9vKo/QG9nLJCaphpApjcBghxmQ0Z6kM5uY FW1dv3i1PJFbOWxbwYgYwzhzeNaRNtB0Xcz+ej32Y8DuWh9PJ1AE1zbjpttnsh9v8YwM XKqxGWxsKVfYo7smBZHlm+kFgoTW4Va1jff9YRBN6x83SVLdDQlopBg5eqowpA91jr56 Cf9ukQAQy5Low2O4H1GyHIAsOcVf1I4tZgKeRmQf2xoSNY0PqQwXYu0H/MS1oUPrHd+f 3cdeTMl9HmtldZT/tg/cFKt78P912DN4QfeRxtTYVqHwo2YHXEZfPhE/rbRLZUXxXX9p 2NNw== X-Gm-Message-State: AOAM531g1mX8o448PbZFlJG7CNQxC5Shi5zyFns9L1cxoGtqXlVJdQl7 T/CioOO3WqrMUnwWWGUnmBWvjbUfjqWIsg== X-Google-Smtp-Source: ABdhPJx+EywqFySp9FIRwrJaLZczbA8a01abyR3ieNnxY/VfaH9M5l3oI8hWs5+QfJmS91a/6c9ssg== X-Received: by 2002:a17:90b:3803:: with SMTP id mq3mr2906786pjb.95.1644304646768; Mon, 07 Feb 2022 23:17:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 5/8] tcg/sparc: Convert patch_reloc to return bool Date: Tue, 8 Feb 2022 18:17:07 +1100 Message-Id: <20220208071710.320122-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1029 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644312135825100001 Content-Type: text/plain; charset="utf-8" Since 7ecd02a06f8, if patch_reloc fails we restart translation with a smaller TB. Sparc had its function signature changed, but not the logic. Replace assert with return false. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/sparc/tcg-target.c.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 088c680f37..ae809c9941 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -323,12 +323,16 @@ static bool patch_reloc(tcg_insn_unit *src_rw, int ty= pe, =20 switch (type) { case R_SPARC_WDISP16: - assert(check_fit_ptr(pcrel >> 2, 16)); + if (!check_fit_ptr(pcrel >> 2, 16)) { + return false; + } insn &=3D ~INSN_OFF16(-1); insn |=3D INSN_OFF16(pcrel); break; case R_SPARC_WDISP19: - assert(check_fit_ptr(pcrel >> 2, 19)); + if (!check_fit_ptr(pcrel >> 2, 19)) { + return false; + } insn &=3D ~INSN_OFF19(-1); insn |=3D INSN_OFF19(pcrel); break; --=20 2.25.1 From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644308633; cv=none; d=zohomail.com; s=zohoarc; b=KRuTMFMsiC7lO6zn/21xthDenAN8EWFTfdUjIqg8Ij1o3dj6E4BIEgokjdCUqa0XcqB6RT+SU7F39JAW4mwab5hK3B9eWCQQ4hn3RvcUW3pjySQtTuc/qEp5TNf3Brz2DuPreBLPkx8z4nVK0+qBoNMWeONfzIrKgS8dvyuYCi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644308633; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EzinD8/kPioX6Z6jBf7AkBmyvisWOi+WtFsuBRSv8ks=; b=bihKnGTYrYujL7K6oAG8mRbw4dx0udhpPLCX9ahCBVfSJjGxNFac2FflIYlh8QcGJtAcjHQvPIwfHZsyzOEdvVNXWUwQK0W11yWP4fQMthLa86fLJzmI+fIDza+0CxQjino7FM2A2Fn8WYVarAA7ASkuJX5m0bWDscSmHvSHGvM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644308633263961.8566670716529; Tue, 8 Feb 2022 00:23:53 -0800 (PST) Received: from localhost ([::1]:60820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLmy-0006tI-1i for importer@patchew.org; Tue, 08 Feb 2022 03:23:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKkn-0000Pc-BC for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:35 -0500 Received: from [2607:f8b0:4864:20::429] (port=45864 helo=mail-pf1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKkl-00018o-8c for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:32 -0500 Received: by mail-pf1-x429.google.com with SMTP id x65so2860148pfx.12 for ; Mon, 07 Feb 2022 23:17:29 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17: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=EzinD8/kPioX6Z6jBf7AkBmyvisWOi+WtFsuBRSv8ks=; b=JBzMq8E/+9abiygCT9Wr9gbuvta9xKLADFxQ25n5mb+YgGDo7wCFFM+TDtg86St8cM RYlQb0lVYyxgjLhesHBKSr/1PFwD3opr/iySzwtdvsfqtM8NBBA6RgOmDGwYZlpaXAgU x0ocFXn0DbbPcTgXigsU0hVKe8YAOjEVHoPnZ+xSQKxCWgIolmUIh138Y+Uk47YzqeQW +chH1IIbS+0fIk1rR+F5uaKqIFzmfJXiZUeKCJNBXLOlPbWCPS+6wNEZI6LAPEZyUBq2 mCuc9MpE6AG6iM9bogsP4w/6wdXmJHNRlplpQ5g+CpwI8SwNb0T/N3v+wCp0yg727tax ak6w== 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=EzinD8/kPioX6Z6jBf7AkBmyvisWOi+WtFsuBRSv8ks=; b=sIidDOfA0KXFSzYsuOsgaG/Fx8me64F/ol3PX3Jlu7F9oIcBjp1VnG6m4V2O/ccLFu YexJe72JrijMeR//t/N3KfiZOpagcpbJdG/i9wtZFLoBwJgt+QlgwhTDafYnVw3kJEGB uD8Djz09CGZuU/7f72ACly77DbqqkZ0v+F0QE6O471HHgfNpL8cXF3/GZTjNf5oXllGk VOQ6lmy2rqJTsJljrQgglsVD1FGqdHQVu7qOkMAzCqBMaakPWYvRBX8R30nlSzg1bX+P NnttSgfkJ1hC0HESEO9ErTAQ8nkAo2owscyeA4PiQnGQRrlyLdAOzlLqGUsT82U4vYLp E8zg== X-Gm-Message-State: AOAM532b9OtJoAf0xwI9EP+Wwcm0Hvvq0hMAz9bV2n2pqS/FtMV15shx 1e4qqmAJvTXg0/u3CzOASCSwyQxmsNSJhg== X-Google-Smtp-Source: ABdhPJyKOxFBjN/lRXgBpQs92eq5WciclNgcerdCELGD6O3vxcVAYWpjkCtKRgPjdk0oYljNbbIWBw== X-Received: by 2002:a63:2c54:: with SMTP id s81mr2473814pgs.197.1644304649004; Mon, 07 Feb 2022 23:17:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 6/8] tcg/sparc: Use the constant pool for 64-bit constants Date: Tue, 8 Feb 2022 18:17:08 +1100 Message-Id: <20220208071710.320122-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::429 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644308635001100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index ae809c9941..21b0dd6734 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -336,6 +336,13 @@ static bool patch_reloc(tcg_insn_unit *src_rw, int typ= e, insn &=3D ~INSN_OFF19(-1); insn |=3D INSN_OFF19(pcrel); break; + case R_SPARC_13: + if (!check_fit_ptr(value, 13)) { + return false; + } + insn &=3D ~INSN_IMM13(-1); + insn |=3D INSN_IMM13(value); + break; default: g_assert_not_reached(); } @@ -479,6 +486,14 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, return; } =20 + /* Use the constant pool, if possible. */ + if (!in_prologue && USE_REG_TB) { + new_pool_label(s, arg, R_SPARC_13, s->code_ptr, + tcg_tbrel_diff(s, NULL)); + tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(TCG_REG_TB)); + return; + } + /* A 64-bit constant decomposed into 2 32-bit pieces. */ if (check_fit_i32(lo, 13)) { hi =3D (arg - lo) >> 32; --=20 2.25.1 From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644308732; cv=none; d=zohomail.com; s=zohoarc; b=W5+t6VAtkZNIFN6R+PCP5IA5Ps3uvdI/GY5F3Sxp6iIelhLBxiSedZeoyFP/xloId6S2JSKb9kA0psVXFSqCEjRQYbUljtwglYQ5mT4coKoZCssOGFtWPTGiVyRVpbhFZ6WuadCbUQC8NSq97Xod1F7k71/ssAsWqJJJKCYEf8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644308732; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P/YZ4Y+tth+cY5venKo3+zC18iniWfePDGcuQD9g22E=; b=JHloHs/OOLk37HgDyO4F1NqQFAgGoWrxrcx09jO1GKvEwFC0zWQpadW162LJ2UWzRTMrM1JID9ic77HIbPcIwG1KeWg63kZq8Hgse163pJ+4viS3p0dfMbGTALi0lzQAKt2T0d33lVwUbb3KlFj9xw5MojZyfQiKqeAvThi6tYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644308732410392.69351349709746; Tue, 8 Feb 2022 00:25:32 -0800 (PST) Received: from localhost ([::1]:34154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLoX-0007yH-JT for importer@patchew.org; Tue, 08 Feb 2022 03:25:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKkp-0000R2-FH for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:37 -0500 Received: from [2607:f8b0:4864:20::102d] (port=38560 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKkn-00018z-0d for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:35 -0500 Received: by mail-pj1-x102d.google.com with SMTP id h14-20020a17090a130e00b001b88991a305so1295144pja.3 for ; Mon, 07 Feb 2022 23:17:32 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:30 -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=P/YZ4Y+tth+cY5venKo3+zC18iniWfePDGcuQD9g22E=; b=h5SGgLCIv3YD/fPge8X2RwmcYvtCK9pAYMdQ2fOpN0dL1gcEMGirx838uMw5cF+qTP zqiyUtJnMyModc3vFpPXAUpnQrB1CFBI32DwXgnBGHJZf547lNLe0lIvi9rgRAfy+6yb MWa0homJDuvuabYN7VheiVTxv8hcLewl2kjDsRi9EWtlB8QiwJpiyma+ix72or/kCjLf vMwwwdrQy49wP3qJPsctrilgj56KhYK4Eu+PGgqGSmDGp/izv56fWHbibwwUI3KTM4/5 PNOsV5Ktc3vRFHei1qjVhisYTu8h5MEBkRDTttTJye+aCcZlKESY6aw/cWQnaKAXMyHi jbNA== 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=P/YZ4Y+tth+cY5venKo3+zC18iniWfePDGcuQD9g22E=; b=7VzkaBK/PwSHIXvqRTt0UoUqaQruxzM2cno0v4vVHsszSo8DZst8NU2REGVS1TpAqa xOEq0ErpRWFQ1pxXpdXfsIY6vt1AsHFgJ9xMrMoJYguzdDJkTL9az9cL9Soy2Uxbhyot SfcRxoh7S6/t+uAPuKrsiRMccoIWImtu1+oNj7cYLbk628ak9fSBomgUTf5X5zm5attt VLNL2f5JIYu3O64SWPO6UeHpxbuFUZ2a2hQYdtVpvi8BdOw12mrkntEQ05nfx76ld6NF x4iVej7Ggmv2hVN/LAJaco7PgwxlukAp8bnSGZGPJCKqDN9ZI3dN6QIoooabb5eAMuC6 bp/A== X-Gm-Message-State: AOAM530UhU6hw+l77IilU/E3SNcFExWtewy/IhxjLrEuZrm9indYyMCt 1+qtZfBoRLAhRHL1hIuZaYpmb0+UOO/+AA== X-Google-Smtp-Source: ABdhPJwjrOWk8LQJujQ3Bk0DLrg3mLKGz5Qg1GOjcI7wpktuffw6vQg1mZByUpaYi2YFXHImT0DUAA== X-Received: by 2002:a17:902:da91:: with SMTP id j17mr3007359plx.89.1644304651239; Mon, 07 Feb 2022 23:17:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 7/8] tcg/sparc: Add tcg_out_jmpl_const for better tail calls Date: Tue, 8 Feb 2022 18:17:09 +1100 Message-Id: <20220208071710.320122-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644308734157100001 Content-Type: text/plain; charset="utf-8" Due to mapping changes, we now rarely place the code_gen_buffer near the main executable. Which means that direct calls will now rarely be in range. So, always use indirect calls for tail calls, which allows us to avoid clobbering %o7, and therefore we need not save and restore it. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 21b0dd6734..ed83e2dcd7 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -858,6 +858,19 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg = rl, TCGReg rh, tcg_out_mov(s, TCG_TYPE_I64, rl, tmp); } =20 +static void tcg_out_jmpl_const(TCGContext *s, const tcg_insn_unit *dest, + bool in_prologue, bool tail_call) +{ + uintptr_t desti =3D (uintptr_t)dest; + + /* Be careful not to clobber %o7 for a tail call. */ + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, + desti & ~0xfff, in_prologue, + tail_call ? TCG_REG_G2 : TCG_REG_O7); + tcg_out_arithi(s, tail_call ? TCG_REG_G0 : TCG_REG_O7, + TCG_REG_T1, desti & 0xfff, JMPL); +} + static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, bool in_prologue) { @@ -866,10 +879,7 @@ static void tcg_out_call_nodelay(TCGContext *s, const = tcg_insn_unit *dest, if (disp =3D=3D (int32_t)disp) { tcg_out32(s, CALL | (uint32_t)disp >> 2); } else { - uintptr_t desti =3D (uintptr_t)dest; - tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, - desti & ~0xfff, in_prologue, TCG_REG_O7); - tcg_out_arithi(s, TCG_REG_O7, TCG_REG_T1, desti & 0xfff, JMPL); + tcg_out_jmpl_const(s, dest, in_prologue, false); } } =20 @@ -960,11 +970,10 @@ static void build_trampolines(TCGContext *s) =20 /* Set the retaddr operand. */ tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); - /* Set the env operand. */ - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O0, TCG_AREG0); /* Tail call. */ - tcg_out_call_nodelay(s, qemu_ld_helpers[i], true); - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O7, ra); + tcg_out_jmpl_const(s, qemu_ld_helpers[i], true, true); + /* delay slot -- set the env argument */ + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); } =20 for (i =3D 0; i < ARRAY_SIZE(qemu_st_helpers); ++i) { @@ -1006,14 +1015,14 @@ static void build_trampolines(TCGContext *s) if (ra >=3D TCG_REG_O6) { tcg_out_st(s, TCG_TYPE_PTR, TCG_REG_O7, TCG_REG_CALL_STACK, TCG_TARGET_CALL_STACK_OFFSET); - ra =3D TCG_REG_G1; + } else { + tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); } - tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); - /* Set the env operand. */ - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O0, TCG_AREG0); + /* Tail call. */ - tcg_out_call_nodelay(s, qemu_st_helpers[i], true); - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O7, ra); + tcg_out_jmpl_const(s, qemu_st_helpers[i], true, true); + /* delay slot -- set the env argument */ + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); } } #endif --=20 2.25.1 From nobody Mon Feb 9 08:59:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644312393; cv=none; d=zohomail.com; s=zohoarc; b=TRqPsdOO5U9/qJ5K3qs+qP2JuRed5vs7VJQIWBuTo72ZpeKxP1BETw8Q3wquy3tY2xKHOHFvWjgrtfh9j96xUE/ADKPRNqpAr76winh2ZqRBpgZJsLzTY1+66hMY5IPG+5Kd4xOUoWTMXy5cLISqj6Um6fbcszkosTu9ogxt/uk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644312393; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M6tf4FpZ+qAz3lmkXbhG0Fyk59+5/pweIZaBuGXoNnA=; b=gUexVXz/zHzITnJmHUWhkd+6WqKXXR4wKEb5FU4B3pwA6FcBjN1mLhTRvQTfiQzPrlRz+Nj7yPxZbdm68H9ZxcgcULpOV5A7MoR6odrhPOr0d2RxAIBteqHI6vYGbdk86/XcDzmAkskQVn9oJMyGzBV8eEN02nFpukfQQsMv4tQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644312393788624.2835545314024; Tue, 8 Feb 2022 01:26:33 -0800 (PST) Received: from localhost ([::1]:41876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHMlc-0005FR-V5 for importer@patchew.org; Tue, 08 Feb 2022 04:26:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKkr-0000Rs-IT for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:37 -0500 Received: from [2607:f8b0:4864:20::435] (port=36382 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKko-00019J-Qf for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:17:37 -0500 Received: by mail-pf1-x435.google.com with SMTP id s14so2389552pfw.3 for ; Mon, 07 Feb 2022 23:17:34 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id mi11sm1543422pjb.37.2022.02.07.23.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:17:33 -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=M6tf4FpZ+qAz3lmkXbhG0Fyk59+5/pweIZaBuGXoNnA=; b=bZ5vWpTb7kCWKkK0WlxW3/79wa0O2/FF488z1+bC07L0BJtcl8HUMm167D3S4Iiu6c sbiH9ieNZH6rFRzHLZzBx+0GaqpZp9OqlN22Gu3Ds1SfySjQ9lVP5rZY/6BLoHZUCqsA /4UZ6HQjXrS9rH+KNAjvXi6nFp4ImvRaniP8wdn14xt3/tOfF103Ru6stBTpn1+EZUEv PgSpzif8xrhsyDvuo8S6PObWqfc7VyPqB1BnEQ2WvkCgUv8FpkKGLhZIYkwj3+D6SKIg K07NpWva0pvYiZwbW3Lqz30KVBrrqHXliS3a3u/0eIwFmqbCn+9cqehrXN01njqZ5ysx qaww== 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=M6tf4FpZ+qAz3lmkXbhG0Fyk59+5/pweIZaBuGXoNnA=; b=KbCYz+lbMCkrSNHmLczKqkdUnmUwkEjLkNtr3rOXaRPvwYEyAgEpUj01OlAPg4jbF5 DKqHSQWVwf6cuFnUWK9M45KDuc5KfmG1eDEcTHl3/nyCuaGkKaZDaMa3I0HgXyaNQulL tHFGmlau8CijXWY7iI8ZJ7dFn+JQFvSGDn5v6PbKFlsbOPRUFCptOX+piERDExWOntfS rBKY/WRfSHWNK+ZMO2qygQnj8SmR0X25q1YGCDb2dhjH0sRaHmO/NDWTcenMwP/ezbC/ bNQlQPlv9Z1pGAEewyX3Pod6R4btReg6qLDzzJcJ1RHdmINq9Cw5gov5R9W/86m0zczA 9t8w== X-Gm-Message-State: AOAM530H60jzdx2SbfuPXTr5oZPFZsDAG+AwF49c4m7JBB4Ld2IA6aO0 F/al2biIZAUrm+4E1A8ocWE/LzjLOiylyw== X-Google-Smtp-Source: ABdhPJxLsTfbRXLRHHX/Ejd80LuFWQNBlCd+josNvAz01djcww9pkp2OoLqLUgBaW7OZeNq8hSxnQA== X-Received: by 2002:a05:6a00:21c6:: with SMTP id t6mr3172813pfj.81.1644304653336; Mon, 07 Feb 2022 23:17:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 8/8] tcg/sparc: Support unaligned access for user-only Date: Tue, 8 Feb 2022 18:17:10 +1100 Message-Id: <20220208071710.320122-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071710.320122-1-richard.henderson@linaro.org> References: <20220208071710.320122-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::435 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644312406541100003 Content-Type: text/plain; charset="utf-8" This is kinda sorta the opposite of the other tcg hosts, where we get (normal) alignment checks for free with host SIGBUS and need to add code to support unaligned accesses. This inline code expansion is somewhat large, but it takes quite a few instructions to make a function call to a helper anyway. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 219 +++++++++++++++++++++++++++++++++++-- 1 file changed, 211 insertions(+), 8 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index ed83e2dcd7..f227572857 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -211,6 +211,7 @@ static const int tcg_target_call_oarg_regs[] =3D { #define ARITH_ADD (INSN_OP(2) | INSN_OP3(0x00)) #define ARITH_ADDCC (INSN_OP(2) | INSN_OP3(0x10)) #define ARITH_AND (INSN_OP(2) | INSN_OP3(0x01)) +#define ARITH_ANDCC (INSN_OP(2) | INSN_OP3(0x11)) #define ARITH_ANDN (INSN_OP(2) | INSN_OP3(0x05)) #define ARITH_OR (INSN_OP(2) | INSN_OP3(0x02)) #define ARITH_ORCC (INSN_OP(2) | INSN_OP3(0x12)) @@ -1025,6 +1026,38 @@ static void build_trampolines(TCGContext *s) tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); } } +#else +static const tcg_insn_unit *qemu_unalign_ld_trampoline; +static const tcg_insn_unit *qemu_unalign_st_trampoline; + +static void build_trampolines(TCGContext *s) +{ + for (int ld =3D 0; ld < 2; ++ld) { + void *helper; + + while ((uintptr_t)s->code_ptr & 15) { + tcg_out_nop(s); + } + + if (ld) { + helper =3D helper_unaligned_ld; + qemu_unalign_ld_trampoline =3D tcg_splitwx_to_rx(s->code_ptr); + } else { + helper =3D helper_unaligned_st; + qemu_unalign_st_trampoline =3D tcg_splitwx_to_rx(s->code_ptr); + } + + if (!SPARC64 && TARGET_LONG_BITS =3D=3D 64) { + /* Install the high part of the address. */ + tcg_out_arithi(s, TCG_REG_O1, TCG_REG_O2, 32, SHIFT_SRLX); + } + + /* Tail call. */ + tcg_out_jmpl_const(s, helper, true, true); + /* delay slot -- set the env argument */ + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); + } +} #endif =20 /* Generate global QEMU prologue and epilogue code */ @@ -1075,9 +1108,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); =20 -#ifdef CONFIG_SOFTMMU build_trampolines(s); -#endif } =20 static void tcg_out_nop_fill(tcg_insn_unit *p, int count) @@ -1162,18 +1193,22 @@ static TCGReg tcg_out_tlb_load(TCGContext *s, TCGRe= g addr, int mem_index, static const int qemu_ld_opc[(MO_SSIZE | MO_BSWAP) + 1] =3D { [MO_UB] =3D LDUB, [MO_SB] =3D LDSB, + [MO_UB | MO_LE] =3D LDUB, + [MO_SB | MO_LE] =3D LDSB, =20 [MO_BEUW] =3D LDUH, [MO_BESW] =3D LDSH, [MO_BEUL] =3D LDUW, [MO_BESL] =3D LDSW, [MO_BEUQ] =3D LDX, + [MO_BESQ] =3D LDX, =20 [MO_LEUW] =3D LDUH_LE, [MO_LESW] =3D LDSH_LE, [MO_LEUL] =3D LDUW_LE, [MO_LESL] =3D LDSW_LE, [MO_LEUQ] =3D LDX_LE, + [MO_LESQ] =3D LDX_LE, }; =20 static const int qemu_st_opc[(MO_SIZE | MO_BSWAP) + 1] =3D { @@ -1192,11 +1227,12 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg d= ata, TCGReg addr, MemOpIdx oi, bool is_64) { MemOp memop =3D get_memop(oi); + tcg_insn_unit *label_ptr; + #ifdef CONFIG_SOFTMMU unsigned memi =3D get_mmuidx(oi); TCGReg addrz, param; const tcg_insn_unit *func; - tcg_insn_unit *label_ptr; =20 addrz =3D tcg_out_tlb_load(s, addr, memi, memop, offsetof(CPUTLBEntry, addr_read)); @@ -1260,13 +1296,99 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg d= ata, TCGReg addr, =20 *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #else + TCGReg index =3D (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0); + unsigned a_bits =3D get_alignment_bits(memop); + unsigned s_bits =3D memop & MO_SIZE; + unsigned t_bits; + if (SPARC64 && TARGET_LONG_BITS =3D=3D 32) { tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL); addr =3D TCG_REG_T1; } - tcg_out_ldst_rr(s, data, addr, - (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0), + + /* + * Normal case: alignment equal to access size. + */ + if (a_bits =3D=3D s_bits) { + tcg_out_ldst_rr(s, data, addr, index, + qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); + return; + } + + /* + * Test for at least natural alignment, and assume most accesses + * will be aligned -- perform a straight load in the delay slot. + * This is required to preserve atomicity for aligned accesses. + */ + t_bits =3D MAX(a_bits, s_bits); + tcg_debug_assert(t_bits < 13); + tcg_out_arithi(s, TCG_REG_G0, addr, (1u << t_bits) - 1, ARITH_ANDCC); + + /* beq,a,pt %icc, label */ + label_ptr =3D s->code_ptr; + tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT | BPCC_ICC, 0); + /* delay slot */ + tcg_out_ldst_rr(s, data, addr, index, qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); + + if (a_bits >=3D s_bits) { + /* + * Overalignment: A successful alignment test will perform the mem= ory + * operation in the delay slot, and failure need only invoke the + * handler for SIGBUS. + */ + TCGReg arg_low =3D TCG_REG_O1 + (!SPARC64 && TARGET_LONG_BITS =3D= =3D 64); + tcg_out_call_nodelay(s, qemu_unalign_ld_trampoline, false); + /* delay slot -- move to low part of argument reg */ + tcg_out_mov_delay(s, arg_low, addr); + } else { + /* Underalignment: load by pieces of minimum alignment. */ + int ld_opc, a_size, s_size, i; + + /* + * Force full address into T1 early; avoids problems with + * overlap between @addr and @data. + */ + tcg_out_arith(s, TCG_REG_T1, addr, index, ARITH_ADD); + + a_size =3D 1 << a_bits; + s_size =3D 1 << s_bits; + if ((memop & MO_BSWAP) =3D=3D MO_BE) { + ld_opc =3D qemu_ld_opc[a_bits | MO_BE | (memop & MO_SIGN)]; + tcg_out_ldst(s, data, TCG_REG_T1, 0, ld_opc); + ld_opc =3D qemu_ld_opc[a_bits | MO_BE]; + for (i =3D a_size; i < s_size; i +=3D a_size) { + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, ld_opc); + tcg_out_arithi(s, data, data, a_size, SHIFT_SLLX); + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); + } + } else if (a_bits =3D=3D 0) { + ld_opc =3D LDUB; + tcg_out_ldst(s, data, TCG_REG_T1, 0, ld_opc); + for (i =3D a_size; i < s_size; i +=3D a_size) { + if ((memop & MO_SIGN) && i =3D=3D s_size - a_size) { + ld_opc =3D LDSB; + } + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, ld_opc); + tcg_out_arithi(s, TCG_REG_T2, TCG_REG_T2, i * 8, SHIFT_SLL= X); + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); + } + } else { + ld_opc =3D qemu_ld_opc[a_bits | MO_LE]; + tcg_out_ldst_rr(s, data, TCG_REG_T1, TCG_REG_G0, ld_opc); + for (i =3D a_size; i < s_size; i +=3D a_size) { + tcg_out_arithi(s, TCG_REG_T1, TCG_REG_T1, a_size, ARITH_AD= D); + if ((memop & MO_SIGN) && i =3D=3D s_size - a_size) { + ld_opc =3D qemu_ld_opc[a_bits | MO_LE | MO_SIGN]; + } + tcg_out_ldst_rr(s, TCG_REG_T2, TCG_REG_T1, TCG_REG_G0, ld_= opc); + tcg_out_arithi(s, TCG_REG_T2, TCG_REG_T2, i * 8, SHIFT_SLL= X); + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); + } + } + } + + *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #endif /* CONFIG_SOFTMMU */ } =20 @@ -1274,11 +1396,12 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg d= ata, TCGReg addr, MemOpIdx oi) { MemOp memop =3D get_memop(oi); + tcg_insn_unit *label_ptr; + #ifdef CONFIG_SOFTMMU unsigned memi =3D get_mmuidx(oi); TCGReg addrz, param; const tcg_insn_unit *func; - tcg_insn_unit *label_ptr; =20 addrz =3D tcg_out_tlb_load(s, addr, memi, memop, offsetof(CPUTLBEntry, addr_write)); @@ -1315,13 +1438,93 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg d= ata, TCGReg addr, =20 *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #else + TCGReg index =3D (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0); + unsigned a_bits =3D get_alignment_bits(memop); + unsigned s_bits =3D memop & MO_SIZE; + unsigned t_bits; + if (SPARC64 && TARGET_LONG_BITS =3D=3D 32) { tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL); addr =3D TCG_REG_T1; } - tcg_out_ldst_rr(s, data, addr, - (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0), + + /* + * Normal case: alignment equal to access size. + */ + if (a_bits =3D=3D s_bits) { + tcg_out_ldst_rr(s, data, addr, index, + qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]); + return; + } + + /* + * Test for at least natural alignment, and assume most accesses + * will be aligned -- perform a straight store in the delay slot. + * This is required to preserve atomicity for aligned accesses. + */ + t_bits =3D MAX(a_bits, s_bits); + tcg_debug_assert(t_bits < 13); + tcg_out_arithi(s, TCG_REG_G0, addr, (1u << t_bits) - 1, ARITH_ANDCC); + + /* beq,a,pt %icc, label */ + label_ptr =3D s->code_ptr; + tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT | BPCC_ICC, 0); + /* delay slot */ + tcg_out_ldst_rr(s, data, addr, index, qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]); + + if (a_bits >=3D s_bits) { + /* + * Overalignment: A successful alignment test will perform the mem= ory + * operation in the delay slot, and failure need only invoke the + * handler for SIGBUS. + */ + TCGReg arg_low =3D TCG_REG_O1 + (!SPARC64 && TARGET_LONG_BITS =3D= =3D 64); + tcg_out_call_nodelay(s, qemu_unalign_st_trampoline, false); + /* delay slot -- move to low part of argument reg */ + tcg_out_mov_delay(s, arg_low, addr); + } else { + /* Underalignment: store by pieces of minimum alignment. */ + int st_opc, a_size, s_size, i; + + /* + * Force full address into T1 early; avoids problems with + * overlap between @addr and @data. + */ + tcg_out_arith(s, TCG_REG_T1, addr, index, ARITH_ADD); + + a_size =3D 1 << a_bits; + s_size =3D 1 << s_bits; + if ((memop & MO_BSWAP) =3D=3D MO_BE) { + st_opc =3D qemu_st_opc[a_bits | MO_BE]; + for (i =3D 0; i < s_size; i +=3D a_size) { + TCGReg d =3D data; + int shift =3D (s_size - a_size - i) * 8; + if (shift) { + d =3D TCG_REG_T2; + tcg_out_arithi(s, d, data, shift, SHIFT_SRLX); + } + tcg_out_ldst(s, d, TCG_REG_T1, i, st_opc); + } + } else if (a_bits =3D=3D 0) { + tcg_out_ldst(s, data, TCG_REG_T1, 0, STB); + for (i =3D 1; i < s_size; i++) { + tcg_out_arithi(s, TCG_REG_T2, data, i * 8, SHIFT_SRLX); + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, STB); + } + } else { + /* Note that ST*A with immediate asi must use indexed address.= */ + st_opc =3D qemu_st_opc[a_bits + MO_LE]; + tcg_out_ldst_rr(s, data, TCG_REG_T1, TCG_REG_G0, st_opc); + for (i =3D a_size; i < s_size; i +=3D a_size) { + tcg_out_arithi(s, TCG_REG_T2, data, i * 8, SHIFT_SRLX); + tcg_out_arithi(s, TCG_REG_T1, TCG_REG_T1, a_size, ARITH_AD= D); + tcg_out_ldst_rr(s, TCG_REG_T2, TCG_REG_T1, TCG_REG_G0, st_= opc); + } + } + } + + *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #endif /* CONFIG_SOFTMMU */ } =20 --=20 2.25.1