From nobody Sun May 19 16:27:44 2024 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=1670966782; cv=none; d=zohomail.com; s=zohoarc; b=J0aV3U3DWoNPZd4Wvv19HgcBDPGeEIyIw+v7Kd259DvYx5fa5EhWhskbDTChnk0rotCR+oZH46LA5RRCzXi5qHu3SJQEn5F/euQAAj5TXSyiweYRVhdWshYsM1itQH29r/GvJr/Yb1w5hTOK3J4KgPSqkZ9BWudTfjrUXqQ/P0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966782; h=Content-Transfer-Encoding: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=14I+QLaNg6Y9e4H/8QMxuuyCzHk2ngznUAbtAPjHaRo=; b=QVtYJ/rzR8TEoJOAvl7VJM8F0kEHC5xcDIebfliLnQ/KUkXVdNbfQu4eyw1muJ8VuAMoR1HjKzSY5VbwuOoSrRZHUkC6Rv93kVg724cv0rpQGDryipdoInCaSdkYUHPlfa+i5roqqcZymoIl3Xlk1r88HN9nc6vZ9fNKGRli2vE= 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 1670966782355320.4050149171586; Tue, 13 Dec 2022 13:26:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmb-0000Zg-Nc; Tue, 13 Dec 2022 16:25:49 -0500 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 1p5Cma-0000ZF-1u for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:48 -0500 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5CmY-0003BD-7r for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:47 -0500 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1443a16b71cso14157372fac.13 for ; Tue, 13 Dec 2022 13:25:45 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=14I+QLaNg6Y9e4H/8QMxuuyCzHk2ngznUAbtAPjHaRo=; b=ktBkQfAUxQRmVBbwJCanoaPTPlYSrnlCuCEJuLx//tzf9L3msFVgjDBglNksqRVRMm 6jZ2v/dtnQoh9JG4LfcHGMP91nvLAX2r9WkDQkBY56AQNVr5Ss/9GHCGp6yUF8lqUwQO UWmvDh6ECKNjY/IX1EAF03ZLNJ8J1Nv4sISJIFXvhsTIog2i/hj6gnqVM4guOJ7LBcE5 bHXO91Qe5f/0Xize5qDV3KLTeJPkdk6iVwqPf+8dXIE3CdcdFkEoPAv7L45RDt/n/Qj3 3ZP4LG66FC7t6eeNjcyh15N0YTdymiY6gtfBQu3jY7xpzk8gTj7NUAgybHVkQmNV5BcZ K9KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=14I+QLaNg6Y9e4H/8QMxuuyCzHk2ngznUAbtAPjHaRo=; b=h4jgz2XHZ3RQwrXn57O5/6RTzwTbzcLt/4Vsy0J/ja9E8OvGTtfl2REaYFAfe7ZJMM lYuIL69/MSZFklZ9GAO+cwcHUEhD0UjrCJU1TtP9OZUNXBrNKCRJHJcyO7m1sKUwtEsX ojyT6eCC5ImTrFPPfYljjoGwBKe4rAahjPYwKlf/zpELSD/uOkHeO44l7gUCXAzYLnQl 3eaMP17zECA9DHSXuuM+VQ8cg+zhVR1rgunItNqxCpXlypO8eGlxGnnr1mwuSdsyMHnW nHT6bsMxKgTa1K9q7L0o4TP/CQNDK4BxmS/eGefMjFk4/CxdmtJRyurHbDao+vL4MjlO nXqA== X-Gm-Message-State: ANoB5plCcLRlSgR2SQFr/4AxqwMkIvuPvF5goCYUYZdtInM5TqqLqWyM +LZ2exv8R//MUeGdn4Z3vZWTnAKdA4prpCSfqh0= X-Google-Smtp-Source: AA0mqf7vVQzugblCvdnAuZb4F+psDky8WffjiY62FICODZ1eRBFeNkofFR5pdo/N/rg+hukEzQBVPg== X-Received: by 2002:a05:6870:4e03:b0:148:15ba:8869 with SMTP id pl3-20020a0568704e0300b0014815ba8869mr7026936oab.8.1670966744258; Tue, 13 Dec 2022 13:25:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 01/27] tcg: Fix tcg_reg_alloc_dup* Date: Tue, 13 Dec 2022 15:25:15 -0600 Message-Id: <20221213212541.1820840-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:4860:4864:20::2e; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966783245100001 Content-Type: text/plain; charset="utf-8" The assignment to mem_coherent should be done with any modification, not simply with a newly allocated register. Signed-off-by: Richard Henderson --- tcg/tcg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 05d2b70ab7..371908b34b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3498,7 +3498,6 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *op) ots->reg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, op->output_pref[0], ots->indirect_base); ots->val_type =3D TEMP_VAL_REG; - ots->mem_coherent =3D 0; s->reg_to_temp[ots->reg] =3D ots; } =20 @@ -3552,6 +3551,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *op) tcg_debug_assert(ok); =20 done: + ots->mem_coherent =3D 0; if (IS_DEAD_ARG(1)) { temp_dead(s, its); } @@ -3779,7 +3779,6 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const T= CGOp *op) ots->reg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, op->output_pref[0], ots->indirect_base); ots->val_type =3D TEMP_VAL_REG; - ots->mem_coherent =3D 0; s->reg_to_temp[ots->reg] =3D ots; } =20 @@ -3823,6 +3822,7 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const T= CGOp *op) return false; =20 done: + ots->mem_coherent =3D 0; if (IS_DEAD_ARG(1)) { temp_dead(s, itsl); } --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966964; cv=none; d=zohomail.com; s=zohoarc; b=WWYFtdbyMNws7vONj9pZBX0EWo3b0gKd25uZrlznLt4hdQFTtbAXGN0lGIj2NY74pDrDRJZUIonWZtIhfNDTna80JqPYUA2UKUYM9WNX8nLQzn87/GKgM/Iv7rJUZ1tfZG3o9Bkou3Zv4nlk5TVnwlUJhzkbMoZ11gIAiOxSZbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966964; h=Content-Transfer-Encoding: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=N3sySCaF9rSphjulz1xhjVx4WxKD4+O2ThBsDAIIR60=; b=aGAjhCGAFyuWShErAaGEWnMy6vCAes3IQiD0qaqJKfP3CO6DfGDZPasW5w7YRWtiUbRZHzm+kZ6a7NQKSz6NVsRs3Xt2elEsOzDj1EfQKenPk9aVaTk4EXwLTerwM9jhUNFXZ2WvItFyq4nQhaErp30z/axpxDeHKIVgP/aql5w= 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 16709669648631020.6302103206596; Tue, 13 Dec 2022 13:29:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmc-0000a7-CZ; Tue, 13 Dec 2022 16:25:50 -0500 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 1p5Cma-0000ZP-T7 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:48 -0500 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5CmY-0003BY-NL for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:48 -0500 Received: by mail-oi1-x235.google.com with SMTP id n205so1059398oib.1 for ; Tue, 13 Dec 2022 13:25:46 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=N3sySCaF9rSphjulz1xhjVx4WxKD4+O2ThBsDAIIR60=; b=KqvWpd8r7GDSPTjtK9ucX3jTZ1pc95NI5vTuN2Phr7CslWbTqvGSU0Xlyx/TZG0QxA BObv5Xk4dXj7VpJ69xfOp/t5wn8hOJDDCItoiaObEY0ar9DvoCnLS/K26Pmynoy8VqYQ UN3/ot7qzc7LobgapUJVT7PNkUl8mu7zmGJe4OcJ77g7+ouQvhXiQBU2wmCjUgHrs5Ha /u+OzaEWOWjyIE59gF8oF7hn668Oq0fFOjV3b5DMIOdsaZcCUjGYpSz+fXzfiGCSBb1p hMuetq03uy4bGjmiP9ACT4z3J536D/RrjmP8NPu8fF/tdtsGJRdjrTrAiee2hXfF2/D9 9mEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N3sySCaF9rSphjulz1xhjVx4WxKD4+O2ThBsDAIIR60=; b=mLjnjvP/TgxAaFo3jXydSr1ISV2JZig/owbQyh2tGu7msD1tlZpGnC90Z7XdRUDEd7 bYUFwX1qU+zumAo/22nsO3SKJzICMjTTTSqJRo/Xt3lWgG7dgXClcIVNwJNo6nAe7mh2 StipbafqVrSmWY3UlLlM5kHi9yJi8YedJtwQmo9ycbf/FAk08r1AetVU6VJNQg7Zltf3 IOTSQnRDlWXqI3DP3pDO5mOSv4P+Z6nrrp9Bb9YhsXg5OOKsMNmNmIz2pzbHTsG9ybrT A2JrFuVb0XKnNjweR0SzoiktkKYxmTiFnKJANj/kW1PuISOfMwNA0ECbFZjd6GvC7gvz V/0Q== X-Gm-Message-State: ANoB5pm0zu7LTGUvix+4zmOsaoJIGf7oKVS4DEItRh8TqfkqqYQ/jBem +df2C1Q+XbwRyQO2oxYlZi3n/h0IYNnyFXHakLA= X-Google-Smtp-Source: AA0mqf7uDU2R35nFH4MAFDanFqed9xiqXUkliGnIQucOpYBtQpCAi+tbcE36g7IywLJrkmFSFz9a7g== X-Received: by 2002:a54:440d:0:b0:35e:73dd:9cff with SMTP id k13-20020a54440d000000b0035e73dd9cffmr6293204oiw.6.1670966745256; Tue, 13 Dec 2022 13:25:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 02/27] tcg: Centralize updates to reg_to_temp Date: Tue, 13 Dec 2022 15:25:16 -0600 Message-Id: <20221213212541.1820840-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966965733100002 Content-Type: text/plain; charset="utf-8" Create two new functions, set_temp_val_{reg,nonreg}. Assert that the reg_to_temp mapping is correct before any changes are made. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- tcg/tcg.c | 159 +++++++++++++++++++++++++++++------------------------- 1 file changed, 85 insertions(+), 74 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 371908b34b..a1ae761a58 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3019,6 +3019,35 @@ static void temp_allocate_frame(TCGContext *s, TCGTe= mp *ts) ts->mem_allocated =3D 1; } =20 +/* Assign @reg to @ts, and update reg_to_temp[]. */ +static void set_temp_val_reg(TCGContext *s, TCGTemp *ts, TCGReg reg) +{ + if (ts->val_type =3D=3D TEMP_VAL_REG) { + TCGReg old =3D ts->reg; + tcg_debug_assert(s->reg_to_temp[old] =3D=3D ts); + if (old =3D=3D reg) { + return; + } + s->reg_to_temp[old] =3D NULL; + } + tcg_debug_assert(s->reg_to_temp[reg] =3D=3D NULL); + s->reg_to_temp[reg] =3D ts; + ts->val_type =3D TEMP_VAL_REG; + ts->reg =3D reg; +} + +/* Assign a non-register value type to @ts, and update reg_to_temp[]. */ +static void set_temp_val_nonreg(TCGContext *s, TCGTemp *ts, TCGTempVal typ= e) +{ + tcg_debug_assert(type !=3D TEMP_VAL_REG); + if (ts->val_type =3D=3D TEMP_VAL_REG) { + TCGReg reg =3D ts->reg; + tcg_debug_assert(s->reg_to_temp[reg] =3D=3D ts); + s->reg_to_temp[reg] =3D NULL; + } + ts->val_type =3D type; +} + static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet, TCGRe= gSet); =20 /* Mark a temporary as free or dead. If 'free_or_dead' is negative, @@ -3044,10 +3073,7 @@ static void temp_free_or_dead(TCGContext *s, TCGTemp= *ts, int free_or_dead) default: g_assert_not_reached(); } - if (ts->val_type =3D=3D TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] =3D NULL; - } - ts->val_type =3D new_type; + set_temp_val_nonreg(s, ts, new_type); } =20 /* Mark a temporary as dead. */ @@ -3227,9 +3253,7 @@ static void temp_load(TCGContext *s, TCGTemp *ts, TCG= RegSet desired_regs, default: tcg_abort(); } - ts->reg =3D reg; - ts->val_type =3D TEMP_VAL_REG; - s->reg_to_temp[reg] =3D ts; + set_temp_val_reg(s, ts, reg); } =20 /* Save a temporary to memory. 'allocated_regs' is used in case a @@ -3341,10 +3365,7 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCG= Temp *ots, tcg_debug_assert(!temp_readonly(ots)); =20 /* The movi is not explicitly generated here. */ - if (ots->val_type =3D=3D TEMP_VAL_REG) { - s->reg_to_temp[ots->reg] =3D NULL; - } - ots->val_type =3D TEMP_VAL_CONST; + set_temp_val_nonreg(s, ots, TEMP_VAL_CONST); ots->val =3D val; ots->mem_coherent =3D 0; if (NEED_SYNC_ARG(0)) { @@ -3363,6 +3384,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *op) TCGRegSet allocated_regs, preferred_regs; TCGTemp *ts, *ots; TCGType otype, itype; + TCGReg oreg, ireg; =20 allocated_regs =3D s->reserved_regs; preferred_regs =3D op->output_pref[0]; @@ -3394,8 +3416,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *op) temp_load(s, ts, tcg_target_available_regs[itype], allocated_regs, preferred_regs); } - tcg_debug_assert(ts->val_type =3D=3D TEMP_VAL_REG); + ireg =3D ts->reg; + if (IS_DEAD_ARG(0)) { /* mov to a non-saved dead register makes no sense (even with liveness analysis disabled). */ @@ -3403,52 +3426,53 @@ static void tcg_reg_alloc_mov(TCGContext *s, const = TCGOp *op) if (!ots->mem_allocated) { temp_allocate_frame(s, ots); } - tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset); + tcg_out_st(s, otype, ireg, ots->mem_base->reg, ots->mem_offset); if (IS_DEAD_ARG(1)) { temp_dead(s, ts); } temp_dead(s, ots); + return; + } + + if (IS_DEAD_ARG(1) && ts->kind !=3D TEMP_FIXED) { + /* + * The mov can be suppressed. Kill input first, so that it + * is unlinked from reg_to_temp, then set the output to the + * reg that we saved from the input. + */ + temp_dead(s, ts); + oreg =3D ireg; } else { - if (IS_DEAD_ARG(1) && ts->kind !=3D TEMP_FIXED) { - /* the mov can be suppressed */ - if (ots->val_type =3D=3D TEMP_VAL_REG) { - s->reg_to_temp[ots->reg] =3D NULL; - } - ots->reg =3D ts->reg; - temp_dead(s, ts); + if (ots->val_type =3D=3D TEMP_VAL_REG) { + oreg =3D ots->reg; } else { - if (ots->val_type !=3D TEMP_VAL_REG) { - /* When allocating a new register, make sure to not spill = the - input one. */ - tcg_regset_set_reg(allocated_regs, ts->reg); - ots->reg =3D tcg_reg_alloc(s, tcg_target_available_regs[ot= ype], - allocated_regs, preferred_regs, - ots->indirect_base); - } - if (!tcg_out_mov(s, otype, ots->reg, ts->reg)) { - /* - * Cross register class move not supported. - * Store the source register into the destination slot - * and leave the destination temp as TEMP_VAL_MEM. - */ - assert(!temp_readonly(ots)); - if (!ts->mem_allocated) { - temp_allocate_frame(s, ots); - } - tcg_out_st(s, ts->type, ts->reg, - ots->mem_base->reg, ots->mem_offset); - ots->mem_coherent =3D 1; - temp_free_or_dead(s, ots, -1); - return; - } + /* Make sure to not spill the input register during allocation= . */ + oreg =3D tcg_reg_alloc(s, tcg_target_available_regs[otype], + allocated_regs | ((TCGRegSet)1 << ireg), + preferred_regs, ots->indirect_base); } - ots->val_type =3D TEMP_VAL_REG; - ots->mem_coherent =3D 0; - s->reg_to_temp[ots->reg] =3D ots; - if (NEED_SYNC_ARG(0)) { - temp_sync(s, ots, allocated_regs, 0, 0); + if (!tcg_out_mov(s, otype, oreg, ireg)) { + /* + * Cross register class move not supported. + * Store the source register into the destination slot + * and leave the destination temp as TEMP_VAL_MEM. + */ + assert(!temp_readonly(ots)); + if (!ts->mem_allocated) { + temp_allocate_frame(s, ots); + } + tcg_out_st(s, ts->type, ireg, ots->mem_base->reg, ots->mem_off= set); + set_temp_val_nonreg(s, ts, TEMP_VAL_MEM); + ots->mem_coherent =3D 1; + return; } } + set_temp_val_reg(s, ots, oreg); + ots->mem_coherent =3D 0; + + if (NEED_SYNC_ARG(0)) { + temp_sync(s, ots, allocated_regs, 0, 0); + } } =20 /* @@ -3490,15 +3514,15 @@ static void tcg_reg_alloc_dup(TCGContext *s, const = TCGOp *op) /* Allocate the output register now. */ if (ots->val_type !=3D TEMP_VAL_REG) { TCGRegSet allocated_regs =3D s->reserved_regs; + TCGReg oreg; =20 if (!IS_DEAD_ARG(1) && its->val_type =3D=3D TEMP_VAL_REG) { /* Make sure to not spill the input register. */ tcg_regset_set_reg(allocated_regs, its->reg); } - ots->reg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); - ots->val_type =3D TEMP_VAL_REG; - s->reg_to_temp[ots->reg] =3D ots; + oreg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, + op->output_pref[0], ots->indirect_base); + set_temp_val_reg(s, ots, oreg); } =20 switch (its->val_type) { @@ -3535,10 +3559,12 @@ static void tcg_reg_alloc_dup(TCGContext *s, const = TCGOp *op) #else endian_fixup =3D 0; #endif + /* Attempt to dup directly from the input memory slot. */ if (tcg_out_dupm_vec(s, vtype, vece, ots->reg, its->mem_base->reg, its->mem_offset + endian_fixup)) { goto done; } + /* Load the input into the destination vector register. */ tcg_out_ld(s, itype, ots->reg, its->mem_base->reg, its->mem_offset= ); break; =20 @@ -3707,17 +3733,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TC= GOp *op) op->output_pref[k], ts->indirect_base); } tcg_regset_set_reg(o_allocated_regs, reg); - if (ts->val_type =3D=3D TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] =3D NULL; - } - ts->val_type =3D TEMP_VAL_REG; - ts->reg =3D reg; - /* - * Temp value is modified, so the value kept in memory is - * potentially not the same. - */ + set_temp_val_reg(s, ts, reg); ts->mem_coherent =3D 0; - s->reg_to_temp[reg] =3D ts; new_args[i] =3D reg; } } @@ -3767,6 +3784,7 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const T= CGOp *op) TCGRegSet allocated_regs =3D s->reserved_regs; TCGRegSet dup_out_regs =3D tcg_op_defs[INDEX_op_dup_vec].args_ct[0].regs; + TCGReg oreg; =20 /* Make sure to not spill the input registers. */ if (!IS_DEAD_ARG(1) && itsl->val_type =3D=3D TEMP_VAL_REG) { @@ -3776,10 +3794,9 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const = TCGOp *op) tcg_regset_set_reg(allocated_regs, itsh->reg); } =20 - ots->reg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); - ots->val_type =3D TEMP_VAL_REG; - s->reg_to_temp[ots->reg] =3D ots; + oreg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, + op->output_pref[0], ots->indirect_base); + set_temp_val_reg(s, ots, oreg); } =20 /* Promote dup2 of immediates to dupi_vec. */ @@ -3962,14 +3979,8 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp = *op) tcg_debug_assert(!temp_readonly(ts)); =20 reg =3D tcg_target_call_oarg_regs[i]; - tcg_debug_assert(s->reg_to_temp[reg] =3D=3D NULL); - if (ts->val_type =3D=3D TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] =3D NULL; - } - ts->val_type =3D TEMP_VAL_REG; - ts->reg =3D reg; + set_temp_val_reg(s, ts, reg); ts->mem_coherent =3D 0; - s->reg_to_temp[reg] =3D ts; if (NEED_SYNC_ARG(i)) { temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967500; cv=none; d=zohomail.com; s=zohoarc; b=ZG7tfR8dzH2QNXxbLCfw2V9Ot8K6mxtUCEasaxVZmkxv4W36iXndA50QV8wC6Aww04xKQ2hK9gHFNa8hUfOVOG1H5NgAHgNkx5N6zJIWsPjVZ711Zx0owSZvl/NGLD5YjbnO5zHoBA6zdxGar1s8+/ZClNK7oBJQhiPWwyfnxPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967500; h=Content-Transfer-Encoding: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=u4Ky9gC35TAkBsuNbUJu2Aor4xy7gS6Z6s1EhQume6U=; b=DaZKyw9znD/wK2tF7ICRjr9FdZXtQfAzNxZRAdX/PJ5qS/2z2g0ovYYkw+JCof9OphFqjSBdp6HmnRLK1GmPdwo/4yskt7ksnv9IzNa7JxQvPCWmgzOckjBQ1szZ8z/OdBjEZu8EmplGFAAMuUV9p/ocwuHzFGT5jpARjtbxOpc= 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 1670967500909258.281897885871; Tue, 13 Dec 2022 13:38:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmd-0000aQ-AF; Tue, 13 Dec 2022 16:25:51 -0500 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 1p5Cmb-0000ZY-FS for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:49 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5CmZ-0003Bt-Qo for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:49 -0500 Received: by mail-oi1-x22b.google.com with SMTP id t62so1010905oib.12 for ; Tue, 13 Dec 2022 13:25:47 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=u4Ky9gC35TAkBsuNbUJu2Aor4xy7gS6Z6s1EhQume6U=; b=oD6eZdeIJj+22opYimFKb4iAGMx2kgqr+sjRTrG41pIDYtz9li2BFiqoLhO5gAMEMP Wn611PgtHe9GcmZELCBTU1WQtpd5ivt3qswvQk/HNUdHP3PN+V6iVoHPLaWIx7jj6DEN R55PlVn6UYOginAoCyilb5kfBfPiuSFzn+jz65q2a2lDaiWTnbUUNIvzuI2L4eKsWBWT arT3alA9+/j5uw5bfPKT/2R2KSKIg6m9ZsMnCdMXKnmMG4U4YrnvsYXSt7pml38+dWWy UJZeKLM6mlPfwncoNrwrg8ho9Z97ig1BY6BEsl2VWCLGu/aXSTYes184q2E10ka8WX7W CkKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u4Ky9gC35TAkBsuNbUJu2Aor4xy7gS6Z6s1EhQume6U=; b=gs0xjmavqqlw6O0fQvigJyAvYstaaPhfQf+noer0wP3jb4UgNjRrMaNck2YDYEZ4aU peyUG4BrouFQCRH2tvOHEJbwR+Bbm0Y8km4aKOSHhL7Q1BhUfeCUzSD0RKOYiZId3WN5 nYauPCBmN2/wXo8jgOAH2gC4PhzqHF4sa4nd0jk9mS/MMwctEJVRzx3/1F5HWVPpGn5X pFxQHpbQAlNdcEmba9J61QenzhdsEHTF7ezRmXgxSU5xnm1fJnA/azVnjU0G1exObUfN KT4KuRBXk8BIKk3qUxjk1YMt3YdCXUChUZubr5gyGQAqsanIirTXdmr4SgF4tC7hv6Gj UOUQ== X-Gm-Message-State: ANoB5pkMWNYWJKpC6etBXlOJCENdSayPhMRCu3qjDdxqKrNnZUw2fcST cOLbs50GlihRjRo903hCiLp6j54ES0YXlsv1Eps= X-Google-Smtp-Source: AA0mqf5DmdpLuFzSJ+caLMCC+maoyVhG0fYsBqtvTVM14acnRDmAyTP6asMBHiPOK4VijOO4izWRrA== X-Received: by 2002:aca:f057:0:b0:35b:dea6:18fa with SMTP id o84-20020acaf057000000b0035bdea618famr8897962oih.36.1670966746314; Tue, 13 Dec 2022 13:25:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 03/27] tcg: Remove check_regs Date: Tue, 13 Dec 2022 15:25:17 -0600 Message-Id: <20221213212541.1820840-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967501490100003 Content-Type: text/plain; charset="utf-8" We now check the consistency of reg_to_temp[] with each update, so the utility of checking consistency at the end of each opcode is minimal. In addition, the form of this check is quite expensive, consuming 10% of a checking-enabled build. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- tcg/tcg.c | 76 ------------------------------------------------------- 1 file changed, 76 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index a1ae761a58..c330d114bc 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2900,79 +2900,6 @@ static bool liveness_pass_2(TCGContext *s) return changes; } =20 -#ifdef CONFIG_DEBUG_TCG -static void dump_regs(TCGContext *s) -{ - TCGTemp *ts; - int i; - char buf[64]; - - for(i =3D 0; i < s->nb_temps; i++) { - ts =3D &s->temps[i]; - printf(" %10s: ", tcg_get_arg_str_ptr(s, buf, sizeof(buf), ts)); - switch(ts->val_type) { - case TEMP_VAL_REG: - printf("%s", tcg_target_reg_names[ts->reg]); - break; - case TEMP_VAL_MEM: - printf("%d(%s)", (int)ts->mem_offset, - tcg_target_reg_names[ts->mem_base->reg]); - break; - case TEMP_VAL_CONST: - printf("$0x%" PRIx64, ts->val); - break; - case TEMP_VAL_DEAD: - printf("D"); - break; - default: - printf("???"); - break; - } - printf("\n"); - } - - for(i =3D 0; i < TCG_TARGET_NB_REGS; i++) { - if (s->reg_to_temp[i] !=3D NULL) { - printf("%s: %s\n", - tcg_target_reg_names[i], - tcg_get_arg_str_ptr(s, buf, sizeof(buf), s->reg_to_temp= [i])); - } - } -} - -static void check_regs(TCGContext *s) -{ - int reg; - int k; - TCGTemp *ts; - char buf[64]; - - for (reg =3D 0; reg < TCG_TARGET_NB_REGS; reg++) { - ts =3D s->reg_to_temp[reg]; - if (ts !=3D NULL) { - if (ts->val_type !=3D TEMP_VAL_REG || ts->reg !=3D reg) { - printf("Inconsistency for register %s:\n", - tcg_target_reg_names[reg]); - goto fail; - } - } - } - for (k =3D 0; k < s->nb_temps; k++) { - ts =3D &s->temps[k]; - if (ts->val_type =3D=3D TEMP_VAL_REG - && ts->kind !=3D TEMP_FIXED - && s->reg_to_temp[ts->reg] !=3D ts) { - printf("Inconsistency for temp %s:\n", - tcg_get_arg_str_ptr(s, buf, sizeof(buf), ts)); - fail: - printf("reg state:\n"); - dump_regs(s); - tcg_abort(); - } - } -} -#endif - static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { intptr_t off, size, align; @@ -4297,9 +4224,6 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb,= target_ulong pc_start) tcg_reg_alloc_op(s, op); break; } -#ifdef CONFIG_DEBUG_TCG - check_regs(s); -#endif /* Test for (pending) buffer overflow. The assumption is that any one operation beginning below the high water mark cannot overrun the buffer completely. Thus we can test for overflow after --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966968; cv=none; d=zohomail.com; s=zohoarc; b=Qa5MfX/ZPsR+bbE1mbfuAoeQv2IUxZZuKGV7ssPtuGQkd7C3VHlI5JmGbBN4VOYBn+mrUDlxYSQWDtSr0GKGgIZMr4orJXEBIyorfgUPW5vTKhPiWXozglyhIaI3NH8nIhqNa1BApOspOVCASTYZdtAJjA8323UVbUmNEU78DGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966968; h=Content-Transfer-Encoding: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=ImfiOOXQwh4PwSWoZGHVE8bb0E4t8sc3pStkm/RJybk=; b=iLU2B44YA0274tvhBc+w8oe5w1RHZOZcFVpiIabPDI8RB4qekfG1Y3jyR8itghXI6ZsW+UtpGI2egTXFnhB4IZ1Tm3B7PwYSVzlui66G6aaZuwmjA4g6MboCgOXczt+h4cu1ELG8WV738Hw2eFnk5bRfVCooy54xs/Z6sua0Dy0= 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 1670966968338311.1940154519406; Tue, 13 Dec 2022 13:29:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmf-0000b0-0j; Tue, 13 Dec 2022 16:25:53 -0500 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 1p5Cmd-0000af-GD for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:51 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cma-0003CR-Sx for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:51 -0500 Received: by mail-oi1-x234.google.com with SMTP id m204so1037718oib.6 for ; Tue, 13 Dec 2022 13:25:48 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ImfiOOXQwh4PwSWoZGHVE8bb0E4t8sc3pStkm/RJybk=; b=H05iihv6nnNi4tD2oAlszmu5VWYTBgJxvm9Ty9/nDn2SZQUXUcK2F7SBx35nU5QKOt Mm02qfwjWTWrHQ9FJY2S2VAM2KiJY41beCNxmUXg82YSPeWD41JBhdkmDi2sOxVwJHQO nIPX0dO7f8I2JYVE3j37aHZM3xprQHQljLdRVtWAvnIu1qMM3uBIRpIz43tGhHKSrb8K rIp1WuttIfFL6cWcb9FQr0mkoykzYUBaUBeyU58K88Go03i+i3LqwstsOFCvOGZqYcp2 y3Y/kVSI8jksgdRzANQ9GRPM4M5g/+hITugagvp40jBtZ1W2sKJS+iVE5Hx49AG/vryH 3VGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ImfiOOXQwh4PwSWoZGHVE8bb0E4t8sc3pStkm/RJybk=; b=uR/rn/FTXQBvsg/s19wE2kgm053Jm6EDX07c0Z2zmF0x3bzd68C5ndv9CeytSrSzlB tuG1GUdrRVaQwzRSl/U0EbRQdbTpnRUI7GOpaSOn2aOnWQ4us/S1f5zcJxLe2a4o+reQ N9vF7yrtt9RUcnwDQE7kA9/Gdf7XoJETEzlUtj6Rsy1nxeXo3e5GAijiGb6lmrmxW7Hu Tn1N/I5SzwctmseVUlOkiAkU9G7Vmc3uwuVeh1GZzAu6b+pqkiTnDnoyRjeUQKiumpli VK6aPlGMZRhk/0QeVT8CZXYPUa1O/ZdE4nKWM52jcSL4jLopq75GQMyZB49W+rAxx+jg KGqA== X-Gm-Message-State: ANoB5pnSVvVtKB8m8Uq479i/WR+9Q/PYz1LgQaFyDbZjdLBquOguKZ8j UwRotNP9n2XN65Fc3DTJjSMiNyo3sbcYirPQyF4= X-Google-Smtp-Source: AA0mqf7Blam8pQFZe9VrNJuni0Guh7qzkIlqGEwmuleR0+WtNoYXeQ0YjGDvBfVLg4RLLh99fmrhxg== X-Received: by 2002:aca:f0e:0:b0:35e:85a8:2dc7 with SMTP id 14-20020aca0f0e000000b0035e85a82dc7mr4565659oip.26.1670966747411; Tue, 13 Dec 2022 13:25:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 04/27] tcg: Introduce paired register allocation Date: Tue, 13 Dec 2022 15:25:18 -0600 Message-Id: <20221213212541.1820840-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966969735100001 Content-Type: text/plain; charset="utf-8" There are several instances where we need to be able to allocate a pair of registers to related inputs/outputs. Add 'p' and 'm' register constraints for this, in order to be able to allocate the even/odd register first or second. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 + tcg/tcg.c | 475 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 403 insertions(+), 74 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d84bae6e3f..5c2254ce9f 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -951,6 +951,8 @@ typedef struct TCGArgConstraint { unsigned ct : 16; unsigned alias_index : 4; unsigned sort_index : 4; + unsigned pair_index : 4; + unsigned pair : 2; /* 0: none, 1: first, 2: second, 3: second alias */ bool oalias : 1; bool ialias : 1; bool newreg : 1; diff --git a/tcg/tcg.c b/tcg/tcg.c index c330d114bc..98d51e538c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1969,15 +1969,32 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bo= ol have_prefs) static int get_constraint_priority(const TCGOpDef *def, int k) { const TCGArgConstraint *arg_ct =3D &def->args_ct[k]; - int n; + int n =3D ctpop64(arg_ct->regs); =20 - if (arg_ct->oalias) { - /* an alias is equivalent to a single register */ - n =3D 1; - } else { - n =3D ctpop64(arg_ct->regs); + /* + * Sort constraints of a single register first, which includes output + * aliases (which must exactly match the input already allocated). + */ + if (n =3D=3D 1 || arg_ct->oalias) { + return INT_MAX; } - return TCG_TARGET_NB_REGS - n + 1; + + /* + * Sort register pairs next, first then second immediately after. + * Arbitrarily sort multiple pairs by the index of the first reg; + * there shouldn't be many pairs. + */ + switch (arg_ct->pair) { + case 1: + case 3: + return (k + 1) * 2; + case 2: + return (arg_ct->pair_index + 1) * 2 - 1; + } + + /* Finally, sort by decreasing register count. */ + assert(n > 1); + return -n; } =20 /* sort from highest priority to lowest */ @@ -2012,7 +2029,8 @@ static void process_op_defs(TCGContext *s) for (op =3D 0; op < NB_OPS; op++) { TCGOpDef *def =3D &tcg_op_defs[op]; const TCGTargetOpDef *tdefs; - int i, nb_args; + bool saw_alias_pair =3D false; + int i, o, i2, o2, nb_args; =20 if (def->flags & TCG_OPF_NOT_PRESENT) { continue; @@ -2034,58 +2052,175 @@ static void process_op_defs(TCGContext *s) =20 for (i =3D 0; i < nb_args; i++) { const char *ct_str =3D tdefs->args_ct_str[i]; + bool input_p =3D i >=3D def->nb_oargs; + /* Incomplete TCGTargetOpDef entry. */ tcg_debug_assert(ct_str !=3D NULL); =20 - while (*ct_str !=3D '\0') { - switch(*ct_str) { - case '0' ... '9': - { - int oarg =3D *ct_str - '0'; - tcg_debug_assert(ct_str =3D=3D tdefs->args_ct_str[= i]); - tcg_debug_assert(oarg < def->nb_oargs); - tcg_debug_assert(def->args_ct[oarg].regs !=3D 0); - def->args_ct[i] =3D def->args_ct[oarg]; - /* The output sets oalias. */ - def->args_ct[oarg].oalias =3D true; - def->args_ct[oarg].alias_index =3D i; - /* The input sets ialias. */ - def->args_ct[i].ialias =3D true; - def->args_ct[i].alias_index =3D oarg; - } - ct_str++; - break; - case '&': - def->args_ct[i].newreg =3D true; - ct_str++; - break; + switch (*ct_str) { + case '0' ... '9': + o =3D *ct_str - '0'; + tcg_debug_assert(input_p); + tcg_debug_assert(o < def->nb_oargs); + tcg_debug_assert(def->args_ct[o].regs !=3D 0); + tcg_debug_assert(!def->args_ct[o].oalias); + def->args_ct[i] =3D def->args_ct[o]; + /* The output sets oalias. */ + def->args_ct[o].oalias =3D 1; + def->args_ct[o].alias_index =3D i; + /* The input sets ialias. */ + def->args_ct[i].ialias =3D 1; + def->args_ct[i].alias_index =3D o; + if (def->args_ct[i].pair) { + saw_alias_pair =3D true; + } + tcg_debug_assert(ct_str[1] =3D=3D '\0'); + continue; + + case '&': + tcg_debug_assert(!input_p); + def->args_ct[i].newreg =3D true; + ct_str++; + break; + + case 'p': /* plus */ + /* Allocate to the register after the previous. */ + tcg_debug_assert(i > (input_p ? def->nb_oargs : 0)); + o =3D i - 1; + tcg_debug_assert(!def->args_ct[o].pair); + tcg_debug_assert(!def->args_ct[o].ct); + def->args_ct[i] =3D (TCGArgConstraint){ + .pair =3D 2, + .pair_index =3D o, + .regs =3D def->args_ct[o].regs << 1, + }; + def->args_ct[o].pair =3D 1; + def->args_ct[o].pair_index =3D i; + tcg_debug_assert(ct_str[1] =3D=3D '\0'); + continue; + + case 'm': /* minus */ + /* Allocate to the register before the previous. */ + tcg_debug_assert(i > (input_p ? def->nb_oargs : 0)); + o =3D i - 1; + tcg_debug_assert(!def->args_ct[o].pair); + tcg_debug_assert(!def->args_ct[o].ct); + def->args_ct[i] =3D (TCGArgConstraint){ + .pair =3D 1, + .pair_index =3D o, + .regs =3D def->args_ct[o].regs >> 1, + }; + def->args_ct[o].pair =3D 2; + def->args_ct[o].pair_index =3D i; + tcg_debug_assert(ct_str[1] =3D=3D '\0'); + continue; + } + + do { + switch (*ct_str) { case 'i': def->args_ct[i].ct |=3D TCG_CT_CONST; - ct_str++; break; =20 /* Include all of the target-specific constraints. */ =20 #undef CONST #define CONST(CASE, MASK) \ - case CASE: def->args_ct[i].ct |=3D MASK; ct_str++; break; + case CASE: def->args_ct[i].ct |=3D MASK; break; #define REGS(CASE, MASK) \ - case CASE: def->args_ct[i].regs |=3D MASK; ct_str++; break; + case CASE: def->args_ct[i].regs |=3D MASK; break; =20 #include "tcg-target-con-str.h" =20 #undef REGS #undef CONST default: + case '0' ... '9': + case '&': + case 'p': + case 'm': /* Typo in TCGTargetOpDef constraint. */ g_assert_not_reached(); } - } + } while (*++ct_str !=3D '\0'); } =20 /* TCGTargetOpDef entry with too much information? */ tcg_debug_assert(i =3D=3D TCG_MAX_OP_ARGS || tdefs->args_ct_str[i]= =3D=3D NULL); =20 + /* + * Fix up output pairs that are aliased with inputs. + * When we created the alias, we copied pair from the output. + * There are three cases: + * (1a) Pairs of inputs alias pairs of outputs. + * (1b) One input aliases the first of a pair of outputs. + * (2) One input aliases the second of a pair of outputs. + * + * Case 1a is handled by making sure that the pair_index'es are + * properly updated so that they appear the same as a pair of inpu= ts. + * + * Case 1b is handled by setting the pair_index of the input to + * itself, simply so it doesn't point to an unrelated argument. + * Since we don't encounter the "second" during the input allocati= on + * phase, nothing happens with the second half of the input pair. + * + * Case 2 is handled by setting the second input to pair=3D3, the + * first output to pair=3D3, and the pair_index'es to match. + */ + if (saw_alias_pair) { + for (i =3D def->nb_oargs; i < nb_args; i++) { + /* + * Since [0-9pm] must be alone in the constraint string, + * the only way they can both be set is if the pair comes + * from the output alias. + */ + if (!def->args_ct[i].ialias) { + continue; + } + switch (def->args_ct[i].pair) { + case 0: + break; + case 1: + o =3D def->args_ct[i].alias_index; + o2 =3D def->args_ct[o].pair_index; + tcg_debug_assert(def->args_ct[o].pair =3D=3D 1); + tcg_debug_assert(def->args_ct[o2].pair =3D=3D 2); + if (def->args_ct[o2].oalias) { + /* Case 1a */ + i2 =3D def->args_ct[o2].alias_index; + tcg_debug_assert(def->args_ct[i2].pair =3D=3D 2); + def->args_ct[i2].pair_index =3D i; + def->args_ct[i].pair_index =3D i2; + } else { + /* Case 1b */ + def->args_ct[i].pair_index =3D i; + } + break; + case 2: + o =3D def->args_ct[i].alias_index; + o2 =3D def->args_ct[o].pair_index; + tcg_debug_assert(def->args_ct[o].pair =3D=3D 2); + tcg_debug_assert(def->args_ct[o2].pair =3D=3D 1); + if (def->args_ct[o2].oalias) { + /* Case 1a */ + i2 =3D def->args_ct[o2].alias_index; + tcg_debug_assert(def->args_ct[i2].pair =3D=3D 1); + def->args_ct[i2].pair_index =3D i; + def->args_ct[i].pair_index =3D i2; + } else { + /* Case 2 */ + def->args_ct[i].pair =3D 3; + def->args_ct[o2].pair =3D 3; + def->args_ct[i].pair_index =3D o2; + def->args_ct[o2].pair_index =3D i; + } + break; + default: + g_assert_not_reached(); + } + } + } + /* sort the constraints (XXX: this is just an heuristic) */ sort_constraints(def, 0, def->nb_oargs); sort_constraints(def, def->nb_oargs, def->nb_iargs); @@ -3134,6 +3269,52 @@ static TCGReg tcg_reg_alloc(TCGContext *s, TCGRegSet= required_regs, tcg_abort(); } =20 +static TCGReg tcg_reg_alloc_pair(TCGContext *s, TCGRegSet required_regs, + TCGRegSet allocated_regs, + TCGRegSet preferred_regs, bool rev) +{ + int i, j, k, fmin, n =3D ARRAY_SIZE(tcg_target_reg_alloc_order); + TCGRegSet reg_ct[2]; + const int *order; + + /* Ensure that if I is not in allocated_regs, I+1 is not either. */ + reg_ct[1] =3D required_regs & ~(allocated_regs | (allocated_regs >> 1)= ); + tcg_debug_assert(reg_ct[1] !=3D 0); + reg_ct[0] =3D reg_ct[1] & preferred_regs; + + order =3D rev ? indirect_reg_alloc_order : tcg_target_reg_alloc_order; + + /* + * Skip the preferred_regs option if it cannot be satisfied, + * or if the preference made no difference. + */ + k =3D reg_ct[0] =3D=3D 0 || reg_ct[0] =3D=3D reg_ct[1]; + + /* + * Minimize the number of flushes by looking for 2 free registers firs= t, + * then a single flush, then two flushes. + */ + for (fmin =3D 2; fmin >=3D 0; fmin--) { + for (j =3D k; j < 2; j++) { + TCGRegSet set =3D reg_ct[j]; + + for (i =3D 0; i < n; i++) { + TCGReg reg =3D order[i]; + + if (tcg_regset_test_reg(set, reg)) { + int f =3D !s->reg_to_temp[reg] + !s->reg_to_temp[reg += 1]; + if (f >=3D fmin) { + tcg_reg_free(s, reg, allocated_regs); + tcg_reg_free(s, reg + 1, allocated_regs); + return reg; + } + } + } + } + } + tcg_abort(); +} + /* Make sure the temporary is in a register. If needed, allocate the regi= ster from DESIRED while avoiding ALLOCATED. */ static void temp_load(TCGContext *s, TCGTemp *ts, TCGRegSet desired_regs, @@ -3543,8 +3724,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const TC= GOp *op) =20 /* satisfy input constraints */ for (k =3D 0; k < nb_iargs; k++) { - TCGRegSet i_preferred_regs; - bool allocate_new_reg; + TCGRegSet i_preferred_regs, i_required_regs; + bool allocate_new_reg, copyto_new_reg; + TCGTemp *ts2; + int i1, i2; =20 i =3D def->args_ct[nb_oargs + k].sort_index; arg =3D op->args[i]; @@ -3561,43 +3744,156 @@ static void tcg_reg_alloc_op(TCGContext *s, const = TCGOp *op) =20 reg =3D ts->reg; i_preferred_regs =3D 0; + i_required_regs =3D arg_ct->regs; allocate_new_reg =3D false; + copyto_new_reg =3D false; =20 - if (arg_ct->ialias) { + switch (arg_ct->pair) { + case 0: /* not paired */ + if (arg_ct->ialias) { + i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + + /* + * If the input is not dead after the instruction, + * we must allocate a new register and move it. + */ + if (!IS_DEAD_ARG(i)) { + allocate_new_reg =3D true; + } else if (ts->val_type =3D=3D TEMP_VAL_REG) { + /* + * Check if the current register has already been + * allocated for another input. + */ + allocate_new_reg =3D + tcg_regset_test_reg(i_allocated_regs, reg); + } + } + if (!allocate_new_reg) { + temp_load(s, ts, i_required_regs, i_allocated_regs, + i_preferred_regs); + reg =3D ts->reg; + allocate_new_reg =3D !tcg_regset_test_reg(i_required_regs,= reg); + } + if (allocate_new_reg) { + /* + * Allocate a new register matching the constraint + * and move the temporary register into it. + */ + temp_load(s, ts, tcg_target_available_regs[ts->type], + i_allocated_regs, 0); + reg =3D tcg_reg_alloc(s, i_required_regs, i_allocated_regs, + i_preferred_regs, ts->indirect_base); + copyto_new_reg =3D true; + } + break; + + case 1: + /* First of an input pair; if i1 =3D=3D i2, the second is an o= utput. */ + i1 =3D i; + i2 =3D arg_ct->pair_index; + ts2 =3D i1 !=3D i2 ? arg_temp(op->args[i2]) : NULL; + + /* + * It is easier to default to allocating a new pair + * and to identify a few cases where it's not required. + */ + if (arg_ct->ialias) { + i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + if (IS_DEAD_ARG(i1) && + IS_DEAD_ARG(i2) && + ts->val_type =3D=3D TEMP_VAL_REG && + ts->reg < TCG_TARGET_NB_REGS - 1 && + tcg_regset_test_reg(i_required_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg + 1) && + (ts2 + ? ts2->val_type =3D=3D TEMP_VAL_REG && + ts2->reg =3D=3D reg + 1 + : s->reg_to_temp[reg + 1] =3D=3D NULL)) { + break; + } + } else { + /* Without aliasing, the pair must also be an input. */ + tcg_debug_assert(ts2); + if (ts->val_type =3D=3D TEMP_VAL_REG && + ts2->val_type =3D=3D TEMP_VAL_REG && + ts2->reg =3D=3D reg + 1 && + tcg_regset_test_reg(i_required_regs, reg)) { + break; + } + } + reg =3D tcg_reg_alloc_pair(s, i_required_regs, i_allocated_reg= s, + 0, ts->indirect_base); + goto do_pair; + + case 2: /* pair second */ + reg =3D new_args[arg_ct->pair_index] + 1; + goto do_pair; + + case 3: /* ialias with second output, no first input */ + tcg_debug_assert(arg_ct->ialias); i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; =20 - /* - * If the input is readonly, then it cannot also be an - * output and aliased to itself. If the input is not - * dead after the instruction, we must allocate a new - * register and move it. - */ - if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { - allocate_new_reg =3D true; - } else if (ts->val_type =3D=3D TEMP_VAL_REG) { - /* - * Check if the current register has already been - * allocated for another input. - */ - allocate_new_reg =3D tcg_regset_test_reg(i_allocated_regs,= reg); + if (IS_DEAD_ARG(i) && + ts->val_type =3D=3D TEMP_VAL_REG && + reg > 0 && + s->reg_to_temp[reg - 1] =3D=3D NULL && + tcg_regset_test_reg(i_required_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg - 1)) { + tcg_regset_set_reg(i_allocated_regs, reg - 1); + break; } - } + reg =3D tcg_reg_alloc_pair(s, i_required_regs >> 1, + i_allocated_regs, 0, + ts->indirect_base); + tcg_regset_set_reg(i_allocated_regs, reg); + reg +=3D 1; + goto do_pair; =20 - if (!allocate_new_reg) { - temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_r= egs); - reg =3D ts->reg; - allocate_new_reg =3D !tcg_regset_test_reg(arg_ct->regs, reg); - } - - if (allocate_new_reg) { + do_pair: /* - * Allocate a new register matching the constraint - * and move the temporary register into it. + * If an aliased input is not dead after the instruction, + * we must allocate a new register and move it. */ - temp_load(s, ts, tcg_target_available_regs[ts->type], - i_allocated_regs, 0); - reg =3D tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs, - i_preferred_regs, ts->indirect_base); + if (arg_ct->ialias && !IS_DEAD_ARG(i)) { + /* + * Because of the alias, and the continued life, make sure + * that the temp is somewhere *other* than reg, and we get + * a copy in reg. + */ + tcg_regset_set_reg(i_allocated_regs, reg); + if (ts->val_type =3D=3D TEMP_VAL_REG && ts->reg =3D=3D reg= ) { + /* If ts was already in reg, copy it somewhere else. */ + TCGReg nr; + bool ok; + + tcg_debug_assert(ts->kind !=3D TEMP_FIXED); + nr =3D tcg_reg_alloc(s, tcg_target_available_regs[ts->= type], + i_allocated_regs, 0, ts->indirect_b= ase); + ok =3D tcg_out_mov(s, ts->type, nr, reg); + tcg_debug_assert(ok); + + set_temp_val_reg(s, ts, nr); + } else { + temp_load(s, ts, tcg_target_available_regs[ts->type], + i_allocated_regs, 0); + copyto_new_reg =3D true; + } + } else { + /* Preferably allocate to reg, otherwise copy. */ + i_required_regs =3D (TCGRegSet)1 << reg; + temp_load(s, ts, i_required_regs, i_allocated_regs, + i_preferred_regs); + copyto_new_reg =3D ts->reg !=3D reg; + } + break; + + default: + g_assert_not_reached(); + } + + if (copyto_new_reg) { if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { /* * Cross register class move not supported. Sync the @@ -3649,15 +3945,46 @@ static void tcg_reg_alloc_op(TCGContext *s, const T= CGOp *op) /* ENV should not be modified. */ tcg_debug_assert(!temp_readonly(ts)); =20 - if (arg_ct->oalias && !const_args[arg_ct->alias_index]) { - reg =3D new_args[arg_ct->alias_index]; - } else if (arg_ct->newreg) { - reg =3D tcg_reg_alloc(s, arg_ct->regs, - i_allocated_regs | o_allocated_regs, - op->output_pref[k], ts->indirect_base); - } else { - reg =3D tcg_reg_alloc(s, arg_ct->regs, o_allocated_regs, - op->output_pref[k], ts->indirect_base); + switch (arg_ct->pair) { + case 0: /* not paired */ + if (arg_ct->oalias && !const_args[arg_ct->alias_index]) { + reg =3D new_args[arg_ct->alias_index]; + } else if (arg_ct->newreg) { + reg =3D tcg_reg_alloc(s, arg_ct->regs, + i_allocated_regs | o_allocated_reg= s, + op->output_pref[k], ts->indirect_b= ase); + } else { + reg =3D tcg_reg_alloc(s, arg_ct->regs, o_allocated_reg= s, + op->output_pref[k], ts->indirect_b= ase); + } + break; + + case 1: /* first of pair */ + tcg_debug_assert(!arg_ct->newreg); + if (arg_ct->oalias) { + reg =3D new_args[arg_ct->alias_index]; + break; + } + reg =3D tcg_reg_alloc_pair(s, arg_ct->regs, o_allocated_re= gs, + op->output_pref[k], ts->indirect_= base); + break; + + case 2: /* second of pair */ + tcg_debug_assert(!arg_ct->newreg); + if (arg_ct->oalias) { + reg =3D new_args[arg_ct->alias_index]; + } else { + reg =3D new_args[arg_ct->pair_index] + 1; + } + break; + + case 3: /* first of pair, aliasing with a second input */ + tcg_debug_assert(!arg_ct->newreg); + reg =3D new_args[arg_ct->pair_index] - 1; + break; + + default: + g_assert_not_reached(); } tcg_regset_set_reg(o_allocated_regs, reg); set_temp_val_reg(s, ts, reg); --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966795; cv=none; d=zohomail.com; s=zohoarc; b=m7qlzgq0OLcI5PrOCk9k6vPIUCmt8w+HXPjS00efpr1EQsd48Dhge7NxDKSbunq9tmEu40ZRkLlze08wxcJva5xjuP8e1HlSlYXw3u30vZm8/2d0wwSztMgZv4BRjCPkefk3oih5lsbo4+4LchdfV1pklloDM9wxUAZeRjuxYok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966795; h=Content-Transfer-Encoding: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=1fcBWbZUmm5Jnpz4Izudl/A6K0HNswQpl9r23JhxDb4=; b=mqXnYjN0ob/XeT5/iLCZMZtAtVD2funipnByPvcAc+9KfIfFY434F1H4KQYzH7rEBdGOZoNygyDHTJdoTUeKkEguXUVyEr3l6vniubGylWtAiePthk6RLiPFSVnWGT66OOG0EwUjAFYJpkJcxb4YMOGtExclbqLIASz7XPcJaZk= 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 1670966795983755.2533469666904; Tue, 13 Dec 2022 13:26:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cme-0000as-KK; Tue, 13 Dec 2022 16:25:52 -0500 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 1p5Cmd-0000aM-5i for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:51 -0500 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmb-0003Cd-Il for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:50 -0500 Received: by mail-oi1-x22d.google.com with SMTP id q186so1022121oia.9 for ; Tue, 13 Dec 2022 13:25:49 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1fcBWbZUmm5Jnpz4Izudl/A6K0HNswQpl9r23JhxDb4=; b=h/hzm/2FHR1E88XejO8s29lpgq/7aDGg3/Qn4G/blVonnpyeqNPO6Ay9cz2tEP5rkW s5RX6KfDAAZnMoOGfK877pxGROA4qgWlrtt0dRLECySMjKBob4gv9Gw2/8FFCR/h/vgf AQcWTBUiz12fRNU0GPvHFdRkwazEXRoX55TKiqGhM65eVxWWrm2izhsMcqXhlTB9x/MR 7CfRqoxeJDmO0gdsEodm0liPvZSWRjcW2/VnqYRx/NYlfaXQ6W1zZb95+CiMMRQJ/CeF KgZpZFg9vkq2qSbACf/Chf4itF9Wsp6h4vOF++H+Sh92O/UnGCCSyI+3nQRKK2Qj/6nQ kZLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1fcBWbZUmm5Jnpz4Izudl/A6K0HNswQpl9r23JhxDb4=; b=HWbVJigd8Xy6R0JbbNQzi2RA3L/vspS5oSlykrc6fTJwUF/Su8LwBLYXGaX91xEaMG IgOCZpAH62N4kNnPp/iIjRwGiKT1MNRYK8wy8apGchaGk1SW1NaQyYxx3FhncoHvTLJV 3PVccMIDamuafZkfVdzVPuHvUks/6rF0hfrVOMRAVVG7jrzFIIAoOycnf7nhJjDQtE8M JHhxhwP9bq2sI2vZEv6obHAn5WbHzekjmxeAS0mDzhCYPEod6HtZrU2+fsB4wV+bls8s vZvjZCTpKNP2HBkkN8h8vT+MAaVDFP8/Z2hmy1TKOYc/ER7AqGxF+6nx+COJh4Rx8Udj +oRA== X-Gm-Message-State: ANoB5pnsSiEroqqSbiYmAigc69DcufnpUg2UNKWlfuSE1AoufX21pfBU FM0gDT3YDEOQ9IDag+lmu73BHMX3kPzE3XRJN9s= X-Google-Smtp-Source: AA0mqf6GkiNTL8d3NXEWxTtJjbqoM9LmGzubJUEqMjCFGyFDwruYUiDj0655eSi7VncAzzoyw1rjLg== X-Received: by 2002:a05:6808:23d6:b0:35b:eddd:653c with SMTP id bq22-20020a05680823d600b0035beddd653cmr13015445oib.40.1670966748410; Tue, 13 Dec 2022 13:25:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 05/27] accel/tcg: Set cflags_next_tb in cpu_common_initfn Date: Tue, 13 Dec 2022 15:25:19 -0600 Message-Id: <20221213212541.1820840-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::22d; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966796867100001 Content-Type: text/plain; charset="utf-8" While we initialize this value in cpu_common_reset, that isn't called during startup, so set it as well in init. This fixes -singlestep versus the very first TB. Fixes: 04f5b647ed07 ("accel/tcg: Handle -singlestep in curr_cflags") Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- hw/core/cpu-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index f9fdd46b9d..6a4022eb14 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -235,6 +235,7 @@ static void cpu_common_initfn(Object *obj) /* the default value is changed by qemu_init_vcpu() for softmmu */ cpu->nr_cores =3D 1; cpu->nr_threads =3D 1; + cpu->cflags_next_tb =3D -1; =20 qemu_mutex_init(&cpu->work_mutex); QSIMPLEQ_INIT(&cpu->work_list); --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967396; cv=none; d=zohomail.com; s=zohoarc; b=I7tS4s1YLUcs6hiOG9ZFLN8Jn7EtsFLaoYkOSwFYnfiEbj6VRgiY8xi7/EehhRtz+KvIybwHK0rDsMahU1rE7/QCNeTUSFksjd3HYp/VoVGcLnr/0kSVtw6rn3QGcXpFiOtbOwPwNONLCLacdGxnPyJbKK8o3Jm1i3xdl0pS0sU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967396; 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=RqkUbgBv122Thnf546PHquT7r6o6Y94wYiKV+lBMbFo=; b=LvkdBIjUtkSPv8Bu2am7spjJDDM3b1jQ0GAAEEYsmMC2r4FsaqxK7m1br9JghFBMF5PEotAAU4Rq5qKg2u83Hk79SIa7FaXW4Of9fyjJCicpuHdtgh3eTvQzZsPqvrq536tbH2qGuDgB6BTOXak/M+ZmCNJh1IEY7FaF7TEWEw8= 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 1670967396271841.1268185904211; Tue, 13 Dec 2022 13:36:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmf-0000b1-Ay; Tue, 13 Dec 2022 16:25:53 -0500 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 1p5Cme-0000aq-BK for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:52 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmc-0003D0-Qc for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:52 -0500 Received: by mail-oi1-x236.google.com with SMTP id l127so1027872oia.8 for ; Tue, 13 Dec 2022 13:25:50 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=RqkUbgBv122Thnf546PHquT7r6o6Y94wYiKV+lBMbFo=; b=cT8jZ6EFQ9OPoDOINglVzMKkw4wuswZtoI/gnMYY5sAI03Vsahb0GVBaqfKRZJEFzi /5eDN/DdUgROXToXW16+qjF/U/XnznuWhPslNlpwiYqT9ikvKAjvLGIpOoufRP2p7m+m HB6fN0sHSwyORKljizgdyPEAAfe8fPl5nQa61BBcPBsRojM2+E/Y6/c0Grsx0Cng1bH2 E7mntDxzWlYiN8+RAwjH+7PJEECtT1TpMJjCbkYxK4/7sTfii/6Z67OtuqiAeeucdVHR owfD+el12GVYbN68RqnevrnvpMxJOxGiyEFGO6SAn5pt2f6kTaHXUYl7fMd60RvNhrp+ qS7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=RqkUbgBv122Thnf546PHquT7r6o6Y94wYiKV+lBMbFo=; b=I9kAVxnwo4+uyod2Gcf85WD3jC1Lkc3Kg4IaFvLH8TuMXIrBhTXS/T23fwpcdZKgWf b/r/qGf0YzlAWLjwcNjH8+USp0t7mCx+2cDlmTU2qMunfjBmAve22+KBNMknc90ONCzn 8RahkyLCPrsk9qIYXY/9SVFEjNsAPMpTHpEJY0V1HY4svX1Z7oZDU8no9YmH2DdQy1w3 kO1no4tIXJY7KSk5iW4O8Rd0ELaI9r9MyUT2PMo8CGcITAAYil7/BYjzhb1i98AJMIQb PoY4zmD99NnEe18AkWpzMf7eFIEHa30X1viUYh4HSWKhiCdFs9AVCHkutAmvDrLWnKuy Fzpg== X-Gm-Message-State: ANoB5pmPUf7Kr9KlvKqEqwxMIOro5SGHBag9N9LnrBIp3pGR4u0RmhpP wFty6I9bm0mQ3SFHYTbh9GIIKYwUUfjQCut+mtE= X-Google-Smtp-Source: AA0mqf5cZhTlplP3K0cz8wzpzaHoggX8D1f8ggvNKpcD+4ly34cmSq19e8qxx8oawsFDZRtMjZNhAg== X-Received: by 2002:a05:6808:ecc:b0:35b:d885:97c with SMTP id q12-20020a0568080ecc00b0035bd885097cmr11607416oiv.53.1670966749421; Tue, 13 Dec 2022 13:25:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PATCH v4 06/27] target/sparc: Avoid TCGV_{LOW,HIGH} Date: Tue, 13 Dec 2022 15:25:20 -0600 Message-Id: <20221213212541.1820840-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967396768100001 Content-Type: text/plain; charset="utf-8" Use the official extend/extract functions instead of routines that will shortly be internal to tcg. Cc: Mark Cave-Ayland Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/sparc/translate.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 34858eb95f..150aeecd14 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -163,13 +163,6 @@ static inline void gen_update_fprs_dirty(DisasContext = *dc, int rd) /* floating point registers moves */ static TCGv_i32 gen_load_fpr_F(DisasContext *dc, unsigned int src) { -#if TCG_TARGET_REG_BITS =3D=3D 32 - if (src & 1) { - return TCGV_LOW(cpu_fpr[src / 2]); - } else { - return TCGV_HIGH(cpu_fpr[src / 2]); - } -#else TCGv_i32 ret =3D get_temp_i32(dc); if (src & 1) { tcg_gen_extrl_i64_i32(ret, cpu_fpr[src / 2]); @@ -177,22 +170,16 @@ static TCGv_i32 gen_load_fpr_F(DisasContext *dc, unsi= gned int src) tcg_gen_extrh_i64_i32(ret, cpu_fpr[src / 2]); } return ret; -#endif } =20 static void gen_store_fpr_F(DisasContext *dc, unsigned int dst, TCGv_i32 v) { -#if TCG_TARGET_REG_BITS =3D=3D 32 - if (dst & 1) { - tcg_gen_mov_i32(TCGV_LOW(cpu_fpr[dst / 2]), v); - } else { - tcg_gen_mov_i32(TCGV_HIGH(cpu_fpr[dst / 2]), v); - } -#else - TCGv_i64 t =3D (TCGv_i64)v; + TCGv_i64 t =3D tcg_temp_new_i64(); + + tcg_gen_extu_i32_i64(t, v); tcg_gen_deposit_i64(cpu_fpr[dst / 2], cpu_fpr[dst / 2], t, (dst & 1 ? 0 : 32), 32); -#endif + tcg_temp_free_i64(t); gen_update_fprs_dirty(dc, dst); } =20 --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967018; cv=none; d=zohomail.com; s=zohoarc; b=iut/xikcOPR/kulDCC51wDyscJkVPElZq1XAPykaHCxN4ttofr3oO7HsWsfAVCTeyh9S5kcxVpPokEy0ddGmRB2jOeiT0KPmsJg1mqggdH1s6Q/w2VHbKb8xPxmbZk/uhEMmAHJuYUM1Hf1FWdhUHJSBKGzncVPY4tlfaGI/yfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967018; 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=vcQlxYY7mFIcT5pvKb1eZPHlZnAn92mI9Ka1689AM7M=; b=NvRpFkqBdpsDqPO2XvalCDK+r2IxuwncNrdRjtUqow/P1T3i4krWA1+x/E5PD3a5dMJDxJL5QyjZrmBqCbB8KtzxPXsCz2e/wm4ah9aZgXDKPkg5h/BYsPGLzDQ57a1I9hEtZIDYFAgZFt679lR9VOUdQULVek2pWemB298ZjLk= 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 1670967018785245.2402664462221; Tue, 13 Dec 2022 13:30:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmg-0000bt-VM; Tue, 13 Dec 2022 16:25:54 -0500 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 1p5Cmf-0000b9-Hm for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:53 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmd-0003DK-OO for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:53 -0500 Received: by mail-oi1-x231.google.com with SMTP id m204so1037829oib.6 for ; Tue, 13 Dec 2022 13:25:51 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=vcQlxYY7mFIcT5pvKb1eZPHlZnAn92mI9Ka1689AM7M=; b=t29JFW9WGAPib60zxr+mdozspVkf/RZ0Dvi9AOFfDlq6lSEgD+0jtgerkKBHhWRD6f Z/L8N8MR5CW3aIE3hN/Cxo/TsmX4Sr1TBI5zFJVJnpgb9kA9K5AzihFu8VZfaf3+jEY3 QVV5o+knYTwmL6TSWZpgMof9GfKjfWsJ7f0TkQaT7cMv/bC/Sdo4u1w1xnmj/cfiw5Ci cMqmv/toL2I/fFk/yZlFf3JGIvKHB3tELMq2DmopQd+bn5Vgb8ZKlT7aH0RND8Pk3nzB OeNCbDYvJAdBB+1m8YxjT18lojX30G2NC2bwCzrrIYee3QP4DJ3DoGt4RIW81sqiIp0s pFXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vcQlxYY7mFIcT5pvKb1eZPHlZnAn92mI9Ka1689AM7M=; b=eM2FNpLbM6fg2DdvIb8PMoUurYIcXY76MV4NEy9I5VjjMNHtA02F+xCnT8xPg1Dutp JAzRpA+ybujv/WpGN0XJI1FDfe6gig8H9+0f7R2pZVx3NVCapfp0iOAyuXnaiR+Xf3J0 QsfYGpPIff5QSfmpki8XTGvFN8JnwMuza0TzQ0C6FjaCamGlPmtmI+o6ofpJu11ed8YW JAs/DHxn3YPk+jFOxiNyTKlW2RvWa6FSXJdRz03baNH3i86wx5swedGSBjklxsp+AwJk qiprJkQX6jT+dvUVLpLwnn575V+R+4kKyRpijS6COycJtDd1tGPL9GgW5Wf5/9L63VuC ZYOw== X-Gm-Message-State: ANoB5pnpUomAHzNCzS2qWXiizSHmPyYCSYLshwCjNEhdw+MThyjDwuCV zDgr9wWIrniEXHcsY4ElG3rHZcLGfB3pohUdQXE= X-Google-Smtp-Source: AA0mqf7ZNohG0AEVsYzsPMNfVpKS19+onjE9ZjdGg/vWKaCc0kzYKzYavm/L6FL+0/nuUenZCMlTNQ== X-Received: by 2002:a05:6808:355:b0:35c:4d3a:6ce4 with SMTP id j21-20020a056808035500b0035c4d3a6ce4mr10147906oie.54.1670966750475; Tue, 13 Dec 2022 13:25:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 07/27] tcg: Move TCG_{LOW,HIGH} to tcg-internal.h Date: Tue, 13 Dec 2022 15:25:21 -0600 Message-Id: <20221213212541.1820840-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::231; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967019901100001 Move the error-generating fallback from tcg-op.c, and replace "_link_error" with modern QEMU_ERROR markup. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg-op.h | 33 +++++---------------------------- include/tcg/tcg.h | 12 ------------ tcg/tcg-internal.h | 14 ++++++++++++++ tcg/tcg-op-vec.c | 2 ++ tcg/tcg-op.c | 37 ++++++++++++++++++++++++++++--------- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 209e168305..8176f194cb 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -667,35 +667,12 @@ static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv= _i64 arg1, TCGv_i64 arg2) tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2); } #else /* TCG_TARGET_REG_BITS =3D=3D 32 */ -static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, - tcg_target_long offset) -{ - tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset); -} +void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); +void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset= ); +void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset= ); =20 -static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, - tcg_target_long offset) -{ - tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset); -} - -static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, - tcg_target_long offset) -{ - tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); -} - -static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 a= rg2) -{ - tcg_gen_add2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), - TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); -} - -static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 a= rg2) -{ - tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), - TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); -} +void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); +void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); =20 void tcg_gen_discard_i64(TCGv_i64 arg); void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg); diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 5c2254ce9f..d207bc47be 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -737,18 +737,6 @@ static inline TCGv_vec temp_tcgv_vec(TCGTemp *t) return (TCGv_vec)temp_tcgv_i32(t); } =20 -#if TCG_TARGET_REG_BITS =3D=3D 32 -static inline TCGv_i32 TCGV_LOW(TCGv_i64 t) -{ - return temp_tcgv_i32(tcgv_i64_temp(t)); -} - -static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) -{ - return temp_tcgv_i32(tcgv_i64_temp(t) + 1); -} -#endif - static inline TCGArg tcg_get_insn_param(TCGOp *op, int arg) { return op->args[arg]; diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index cc82088d52..a9ea27f67a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -59,4 +59,18 @@ static inline unsigned tcg_call_flags(TCGOp *op) return tcg_call_info(op)->flags; } =20 +#if TCG_TARGET_REG_BITS =3D=3D 32 +static inline TCGv_i32 TCGV_LOW(TCGv_i64 t) +{ + return temp_tcgv_i32(tcgv_i64_temp(t)); +} +static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) +{ + return temp_tcgv_i32(tcgv_i64_temp(t) + 1); +} +#else +extern TCGv_i32 TCGV_LOW(TCGv_i64) QEMU_ERROR("32-bit code path is reachab= le"); +extern TCGv_i32 TCGV_HIGH(TCGv_i64) QEMU_ERROR("32-bit code path is reacha= ble"); +#endif + #endif /* TCG_INTERNAL_H */ diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 463dabf515..5bf100ea7d 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -21,6 +21,8 @@ #include "tcg/tcg.h" #include "tcg/tcg-op.h" #include "tcg/tcg-mo.h" +#include "tcg-internal.h" + =20 /* Reduce the number of ifdefs below. This assumes that all uses of TCGV_HIGH and TCGV_LOW are properly protected by a conditional that diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 019fab00cc..6168327030 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -28,16 +28,8 @@ #include "tcg/tcg-op.h" #include "tcg/tcg-mo.h" #include "exec/plugin-gen.h" +#include "tcg-internal.h" =20 -/* Reduce the number of ifdefs below. This assumes that all uses of - TCGV_HIGH and TCGV_LOW are properly protected by a conditional that - the compiler can eliminate. */ -#if TCG_TARGET_REG_BITS =3D=3D 64 -extern TCGv_i32 TCGV_LOW_link_error(TCGv_i64); -extern TCGv_i32 TCGV_HIGH_link_error(TCGv_i64); -#define TCGV_LOW TCGV_LOW_link_error -#define TCGV_HIGH TCGV_HIGH_link_error -#endif =20 void tcg_gen_op1(TCGOpcode opc, TCGArg a1) { @@ -1171,6 +1163,21 @@ void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg= _target_long offset) #endif } =20 +void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) +{ + tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset); +} + +void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) +{ + tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset); +} + +void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) +{ + tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); +} + void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) { #if HOST_BIG_ENDIAN @@ -1182,6 +1189,18 @@ void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tc= g_target_long offset) #endif } =20 +void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) +{ + tcg_gen_add2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), + TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); +} + +void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) +{ + tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), + TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); +} + void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) { tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967232; cv=none; d=zohomail.com; s=zohoarc; b=i0SONBGW8Z2bmewHgmgOshwB1vSJl3AUobkKq7SYiI6lvriwOdUXtIahJRn73jHs+a1JV40cYvDERnMpkhp0OD9kN6JYy3GYy7QPMZPwzyY3XKP2l7VtbjTE8MD93c/S636jP5u+BuLbkrz8iBYRD59PgAMV+ALTaI0T/9crHfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967232; 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=8dgmD8yUJnIF7Ep3YQaKEZ2wvp15A3Cnw31rhHlanTU=; b=L6z+2To6FpgxtJdxO6Nf7fTorOQxubC6xnR6QNtAW2zhV5xySLOJZvewjrIXwOWMVSLr22awrWSqEb8t0khsJIWC0x3muLz55JSuMhOm7qMD8o1xU4mnhM4R+V63vDVleyDe/XE3m8XwKI1BbsjbPqcPxH1YsjeoGky1f/bGsfg= 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 1670967232281901.0465774370957; Tue, 13 Dec 2022 13:33:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmj-0000cr-Gz; Tue, 13 Dec 2022 16:25:57 -0500 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 1p5Cmg-0000bf-1s for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:54 -0500 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cme-0003Dd-GN for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:53 -0500 Received: by mail-oi1-x235.google.com with SMTP id r130so1053550oih.2 for ; Tue, 13 Dec 2022 13:25:52 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=8dgmD8yUJnIF7Ep3YQaKEZ2wvp15A3Cnw31rhHlanTU=; b=aU+O4mvxw5bX9XZhJZU2W3+XsCtCVzbE3gkB2JYs3U8+KM7HT48o6y73sswI7DYrJ2 IpI5JCnOK/MF+mlpvISC+qQh7I49LP4Dw7gDMq0LqzYxlkewY2h01zks1+LQKFctfNZC UZOKOmt0Qpvs5ztbIIKU9tYBhS5kxwNWC23HTeDbEnzowH+INfwgwIlZCfHM0kxHJVxG p4zv8cCRtxp5NMImzqTc4j0Y84Ak1ZvacXtYAAxhoB4m9Qe8b3S9hGwp3bqrK4/krtj9 PWghPyXUep9Z/kWNCMpf1j1y8lUs6tsELG9N7iLP1MjglD6Tct0TPvUBtAIYlgJRtaFo j7ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8dgmD8yUJnIF7Ep3YQaKEZ2wvp15A3Cnw31rhHlanTU=; b=0q7ranpKfCA/95r8Di83FKBeXnmi4P80jgcHyUdQrelzq5C9h83k6Lr4sg7X5ShoB+ ashbe3QmteYauG/1yXtIItdF6R/ryyC1/iX4odgW97ALor5V0EhkNXDKkn6lAxZCKVwS DQovshZEBjpVLnbCtxeDA0pRmyllwCdhutwlJjUpPbjKzTTw6WYtpjC2RH6cqVDJO66P yfiWEVlbVtKxxph1iyagojn7WPep18TrFRnK8ZxVv04QgCgY/yFdHblZQepATWKox+sK R+pure+lksjqhTGhR4qZdiRo8ur5tqeSoz6zoOA3K4OUqk9rHJg4hz3PSs03Z5mBKDJp gEjA== X-Gm-Message-State: ANoB5pnY7Bj8exmF+fCfH/9yEBOYFzKDIGZPHeZEA1wRU3vpqR/Ilg0S e3bvh7S+cw6kMKyIF2o2m1OwM9MXJJ6p+L6O7bM= X-Google-Smtp-Source: AA0mqf4wndWqM+d5At1Y3IaVG33FBN5mLGUegRqYsQZYLRnPfwFV0Np8BcHnk55vXIn/16sgzfb/Ag== X-Received: by 2002:a05:6808:1c6:b0:35e:30a7:b00a with SMTP id x6-20020a05680801c600b0035e30a7b00amr9728672oic.40.1670966751532; Tue, 13 Dec 2022 13:25:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 08/27] tcg: Add temp_subindex to TCGTemp Date: Tue, 13 Dec 2022 15:25:22 -0600 Message-Id: <20221213212541.1820840-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967233072100003 Record the location of a TCGTemp within a larger object. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 1 + tcg/tcg.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d207bc47be..afa18986b1 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -456,6 +456,7 @@ typedef struct TCGTemp { unsigned int mem_coherent:1; unsigned int mem_allocated:1; unsigned int temp_allocated:1; + unsigned int temp_subindex:1; =20 int64_t val; struct TCGTemp *mem_base; diff --git a/tcg/tcg.c b/tcg/tcg.c index 98d51e538c..0f58013a5a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -928,6 +928,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv= _ptr base, ts2->mem_allocated =3D 1; ts2->mem_base =3D base_ts; ts2->mem_offset =3D offset + (1 - bigendian) * 4; + ts2->temp_subindex =3D 1; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_1"); ts2->name =3D strdup(buf); @@ -974,6 +975,7 @@ TCGTemp *tcg_temp_new_internal(TCGType type, bool temp_= local) ts2->base_type =3D TCG_TYPE_I64; ts2->type =3D TCG_TYPE_I32; ts2->temp_allocated =3D 1; + ts2->temp_subindex =3D 1; ts2->kind =3D kind; } else { ts->base_type =3D type; @@ -1092,6 +1094,7 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_t = val) ts2->type =3D TCG_TYPE_I32; ts2->kind =3D TEMP_CONST; ts2->temp_allocated =3D 1; + ts2->temp_subindex =3D 1; ts2->val =3D val >> 32; } else { ts->base_type =3D type; --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966802; cv=none; d=zohomail.com; s=zohoarc; b=cUNKOo4lzVdmbtwDI/eDyIdYSKwQ2Ke7M8c39OOAZU9LUPfGhX7C+/W0/xRVMj4sPXeGisYB7yfYwmhKZbjc65+kG/gevYIgZC6A15bzBmksILhPun9G5fpMtbb6k56vbpd7zcD9Lf8dLJB5Pqrl7NO44RW9x6WeXPZdW3bUbDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966802; h=Content-Transfer-Encoding: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=AADJsK1S30bnJazg8/q+dVkIQuSQjRIPsLPoQjmDJDw=; b=mPOcL83ggjrowT5tVM/JOwBb/5Kvaw+NFDA3OAUiNxvlgk01H6mSsL69+oh7LVDDR+wvGs3avPFw08ZR6Kjp4VpuDJJVRszXqCixd58Hs/jUMbEOiDHM535aiUTGXAN8aXM8Keb/qEzahQH+r3//K5QSGAyFbHCfPPACMrQLhjY= 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 1670966802863884.7276392765581; Tue, 13 Dec 2022 13:26:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmj-0000cq-DI; Tue, 13 Dec 2022 16:25:57 -0500 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 1p5Cmh-0000cC-D9 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:55 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmf-0003Dw-S0 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:55 -0500 Received: by mail-oi1-x22f.google.com with SMTP id v70so1049422oie.3 for ; Tue, 13 Dec 2022 13:25:53 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=AADJsK1S30bnJazg8/q+dVkIQuSQjRIPsLPoQjmDJDw=; b=iitDdmIfdl6DKWI5km3kvb8jeGi8uGmBr/j0jyHHPXH8dtDj0TZ4iqz2WrcMf6R7my VQx6ei64MTRif+2nb0+xFhFr5bfFICudb4xdKi89D7GcJmlVywzm+gchIGZePyRuD+HS 512u/7f0iAAkwxuwdY54VNKrCsH3i57ZKDZ35VtW+mChxBbgyvCZJ009M72yD0k7SPRw QBBlPILVOuaYbmPXJGpym383JYTsUcbjwqwJlpxN7Lu2beoWsRPNXBLC1cxUr9GoIHH9 BpxZSdteDg+oRxkmK+lC8lMisRoJ+lNKMYDZFc55rpn2C5uCbokg5qCBUcTz6+6uZvTo XcjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AADJsK1S30bnJazg8/q+dVkIQuSQjRIPsLPoQjmDJDw=; b=hh06pQiW7SCC4vCbF2DHUWLTt8cSTKS5LAw4J+Pa/BnLW6LnEoTtuvw18T8dWQ3S/v 1dieMNyhquLr9oIuB4zfLj6muHlfYPUbvv733+lFtDCZum3v6TSpD9KHzDI91MpLNTHr 1ldmKAiQHTQMDsrAbNQtuOz41PA+obbd60KSOLEuqjUW+uEJ1775GEsShUmkFmhjdqLm HJT9PEhOvLH6f/K6q8sZGfqk2cbb/9EOwn29mGZHQZwlpzLzXp9+8Td33+PSN8wFsekh sr8OGg0uvijK0etawdzEHMkQQ3TvvNF+el0s1brHlL5g4QEL09EA+CV6Yc/HSKnBa+D9 4A6Q== X-Gm-Message-State: ANoB5pn6i+MchjUmmF8up1qFcfk4dWi2zRabDK3n7nvNfABpHRiqQ9g5 08sPt5A43illV9DEKuTQYsSe1PTS94lI3Ve2ZwU= X-Google-Smtp-Source: AA0mqf56x8vw6lZaP61EOJF5wdDIxXJx9cl2LdoUmUuNWaKCEHyL4AsVGyUJUU6TdMNhiR1uBL2aOA== X-Received: by 2002:a05:6808:64a:b0:35e:34b9:f793 with SMTP id z10-20020a056808064a00b0035e34b9f793mr9295179oih.20.1670966752538; Tue, 13 Dec 2022 13:25:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 09/27] tcg: Simplify calls to temp_sync vs mem_coherent Date: Tue, 13 Dec 2022 15:25:23 -0600 Message-Id: <20221213212541.1820840-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966804892100001 Content-Type: text/plain; charset="utf-8" The first thing that temp_sync does is check mem_coherent, so there's no need for the caller to do so. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 0f58013a5a..36a33a122c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4075,12 +4075,8 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const = TCGOp *op) =20 /* If the two inputs form one 64-bit value, try dupm_vec. */ if (itsl + 1 =3D=3D itsh && itsl->base_type =3D=3D TCG_TYPE_I64) { - if (!itsl->mem_coherent) { - temp_sync(s, itsl, s->reserved_regs, 0, 0); - } - if (!itsh->mem_coherent) { - temp_sync(s, itsh, s->reserved_regs, 0, 0); - } + temp_sync(s, itsl, s->reserved_regs, 0, 0); + temp_sync(s, itsh, s->reserved_regs, 0, 0); #if HOST_BIG_ENDIAN TCGTemp *its =3D itsh; #else --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967068; cv=none; d=zohomail.com; s=zohoarc; b=LqENpdC0TkViAw3QaOtQiBzCr8Su9tsvAjOFdiZG5l1XgucshzabLdrcbMpDW2+wV6HaGMO4OEFhNB1uJHrHRzrROVQ09QALNfCq+u/HWSfr2l3d4gU8c3PDMd1+JLg6/u+kUXUzx3mdBRZoM5jKgu99ZC4Z99S5hCUWOzXYmYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967068; 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=7stba5MTNOn1+WsG6fk76btOm9hVHehrjjbFHXB3kBc=; b=Q0WJjrMwOfH6Ih0qoR9nMWJlXQxNXpGygdnOPvx0tolfQkU7LAqQlJOWko7BCbMCA0VA1h9tZ+z2JeoNVYKEakgVXvwTIaoAs1v/vLOs1M5sMG04BpaMJjdwPkYFY1DhPGVQOYQyAeCAgHkaIj5/cQ85AjMdz46qtiTUoyCiqL0= 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 1670967068452786.9853310486777; Tue, 13 Dec 2022 13:31:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmk-0000dG-68; Tue, 13 Dec 2022 16:25:58 -0500 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 1p5Cmi-0000cg-JH for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:56 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmg-0003EK-MC for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:56 -0500 Received: by mail-oi1-x229.google.com with SMTP id s186so1043795oia.5 for ; Tue, 13 Dec 2022 13:25:54 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=7stba5MTNOn1+WsG6fk76btOm9hVHehrjjbFHXB3kBc=; b=VBP517C3Rzo5ZLnrvqUhkE9MIbJNYhILQAyqFZ1EKqcuLvGQ92rIiLkDi5xWgikn1T PGbD2kP1YeTyR44GyomDC2NL0gngHMCqEUyLGFsgvevPBZcongsC+ZpTF+asJVgAoFXk N0ue1889ROuZULSzT3TBXxVE0UPAnwlcEg8Ll9PYxNYbVy3WVFSyExCRezK0xuVoBJ1i ZRSaiWmkydD36EZd/lAFYRu7voc/bKYTvQ+hlk2Ir1/G9RmXtU9QzVLVAepY0P4N6meS XioNDJmfmZkO/hvq9pDM+M71/EXEGI2PyuIuNyjhjR44DDfJpD7mEoDm0gq6sQPCYjb9 31QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=7stba5MTNOn1+WsG6fk76btOm9hVHehrjjbFHXB3kBc=; b=U9okHEBi8z7P5X/XBWVGd5C0m9qnpOqK6sRKWdkUe1AY8+oHTKxf6nfmY16Iwgwu9Z 3PSdj2EhveWNfvA87HBqpx8DeC/Grm2codv34XsE1hFK4HmZ6TYYJJVskEv7RqzJ0PCj m3/bw0RBqVgB5pbLJH3ACIjDHREw6f+wtZrA9OxoM4XAD2V5Wt2KzN4Zdf612CKZ1GrC E7cO9sq9YXSj/9i+HsVJg8WLFLEvriJ+qgKYJ0MdH1hMTVtbp9tT6uP59LqgQB/7FRSK PFWqmHe2l6ooP+uXqnKeigFBv5xM3Wx65vdFhvABQhGD0PDCimfx+ViPTwg/TBtV8Lfm VVZA== X-Gm-Message-State: ANoB5pmgxsn0IFDhCfGxDFuZZ693iranqifZ2ByCJPyGamv2Y16P9Egp p/AUDtjvhmtmAh3/l9e6SdSbuOXYgv4Zy/y05WA= X-Google-Smtp-Source: AA0mqf5HoVshjw8ItevUoMkK6QLrILApwRR2rLeZUVzSQKxyQTYPCCb/VQOK755dPUim18Vv2tL96g== X-Received: by 2002:a05:6808:d1:b0:35b:625f:898f with SMTP id t17-20020a05680800d100b0035b625f898fmr10597909oic.24.1670966753621; Tue, 13 Dec 2022 13:25:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 10/27] tcg: Allocate TCGTemp pairs in host memory order Date: Tue, 13 Dec 2022 15:25:24 -0600 Message-Id: <20221213212541.1820840-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967070300100003 Allocate the first of a pair at the lower address, and the second of a pair at the higher address. This will make it easier to find the beginning of the larger memory block. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 4 ++-- tcg/tcg.c | 58 ++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index a9ea27f67a..2c06b5116a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -62,11 +62,11 @@ static inline unsigned tcg_call_flags(TCGOp *op) #if TCG_TARGET_REG_BITS =3D=3D 32 static inline TCGv_i32 TCGV_LOW(TCGv_i64 t) { - return temp_tcgv_i32(tcgv_i64_temp(t)); + return temp_tcgv_i32(tcgv_i64_temp(t) + HOST_BIG_ENDIAN); } static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) { - return temp_tcgv_i32(tcgv_i64_temp(t) + 1); + return temp_tcgv_i32(tcgv_i64_temp(t) + !HOST_BIG_ENDIAN); } #else extern TCGv_i32 TCGV_LOW(TCGv_i64) QEMU_ERROR("32-bit code path is reachab= le"); diff --git a/tcg/tcg.c b/tcg/tcg.c index 36a33a122c..dbf4e864eb 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -887,10 +887,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCG= v_ptr base, TCGContext *s =3D tcg_ctx; TCGTemp *base_ts =3D tcgv_ptr_temp(base); TCGTemp *ts =3D tcg_global_alloc(s); - int indirect_reg =3D 0, bigendian =3D 0; -#if HOST_BIG_ENDIAN - bigendian =3D 1; -#endif + int indirect_reg =3D 0; =20 switch (base_ts->kind) { case TEMP_FIXED: @@ -916,7 +913,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv= _ptr base, ts->indirect_reg =3D indirect_reg; ts->mem_allocated =3D 1; ts->mem_base =3D base_ts; - ts->mem_offset =3D offset + bigendian * 4; + ts->mem_offset =3D offset; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_0"); ts->name =3D strdup(buf); @@ -927,7 +924,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv= _ptr base, ts2->indirect_reg =3D indirect_reg; ts2->mem_allocated =3D 1; ts2->mem_base =3D base_ts; - ts2->mem_offset =3D offset + (1 - bigendian) * 4; + ts2->mem_offset =3D offset + 4; ts2->temp_subindex =3D 1; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_1"); @@ -1073,37 +1070,43 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_= t val) =20 ts =3D g_hash_table_lookup(h, &val); if (ts =3D=3D NULL) { + int64_t *val_ptr; + ts =3D tcg_temp_alloc(s); =20 if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64) { TCGTemp *ts2 =3D tcg_temp_alloc(s); =20 + tcg_debug_assert(ts2 =3D=3D ts + 1); + ts->base_type =3D TCG_TYPE_I64; ts->type =3D TCG_TYPE_I32; ts->kind =3D TEMP_CONST; ts->temp_allocated =3D 1; - /* - * Retain the full value of the 64-bit constant in the low - * part, so that the hash table works. Actual uses will - * truncate the value to the low part. - */ - ts->val =3D val; =20 - tcg_debug_assert(ts2 =3D=3D ts + 1); ts2->base_type =3D TCG_TYPE_I64; ts2->type =3D TCG_TYPE_I32; ts2->kind =3D TEMP_CONST; ts2->temp_allocated =3D 1; ts2->temp_subindex =3D 1; - ts2->val =3D val >> 32; + + /* + * Retain the full value of the 64-bit constant in the low + * part, so that the hash table works. Actual uses will + * truncate the value to the low part. + */ + ts[HOST_BIG_ENDIAN].val =3D val; + ts[!HOST_BIG_ENDIAN].val =3D val >> 32; + val_ptr =3D &ts[HOST_BIG_ENDIAN].val; } else { ts->base_type =3D type; ts->type =3D type; ts->kind =3D TEMP_CONST; ts->temp_allocated =3D 1; ts->val =3D val; + val_ptr =3D &ts->val; } - g_hash_table_insert(h, &ts->val, ts); + g_hash_table_insert(h, val_ptr, ts); } =20 return ts; @@ -1515,13 +1518,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nar= gs, TCGTemp **args) pi =3D 0; if (ret !=3D NULL) { if (TCG_TARGET_REG_BITS < 64 && (typemask & 6) =3D=3D dh_typecode_= i64) { -#if HOST_BIG_ENDIAN - op->args[pi++] =3D temp_arg(ret + 1); - op->args[pi++] =3D temp_arg(ret); -#else op->args[pi++] =3D temp_arg(ret); op->args[pi++] =3D temp_arg(ret + 1); -#endif nb_rets =3D 2; } else { op->args[pi++] =3D temp_arg(ret); @@ -1555,8 +1553,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int narg= s, TCGTemp **args) } =20 if (TCG_TARGET_REG_BITS < 64 && is_64bit) { - op->args[pi++] =3D temp_arg(args[i] + HOST_BIG_ENDIAN); - op->args[pi++] =3D temp_arg(args[i] + !HOST_BIG_ENDIAN); + op->args[pi++] =3D temp_arg(args[i]); + op->args[pi++] =3D temp_arg(args[i] + 1); real_args +=3D 2; continue; } @@ -4074,14 +4072,14 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const= TCGOp *op) } =20 /* If the two inputs form one 64-bit value, try dupm_vec. */ - if (itsl + 1 =3D=3D itsh && itsl->base_type =3D=3D TCG_TYPE_I64) { - temp_sync(s, itsl, s->reserved_regs, 0, 0); - temp_sync(s, itsh, s->reserved_regs, 0, 0); -#if HOST_BIG_ENDIAN - TCGTemp *its =3D itsh; -#else - TCGTemp *its =3D itsl; -#endif + if (itsl->temp_subindex =3D=3D HOST_BIG_ENDIAN && + itsh->temp_subindex =3D=3D !HOST_BIG_ENDIAN && + itsl =3D=3D itsh + (HOST_BIG_ENDIAN ? 1 : -1)) { + TCGTemp *its =3D itsl - HOST_BIG_ENDIAN; + + temp_sync(s, its + 0, s->reserved_regs, 0, 0); + temp_sync(s, its + 1, s->reserved_regs, 0, 0); + if (tcg_out_dupm_vec(s, vtype, MO_64, ots->reg, its->mem_base->reg, its->mem_offset)) { goto done; --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966816; cv=none; d=zohomail.com; s=zohoarc; b=OMQH02DiFOmrJEBRPDbG/8yho3Ru8jaTkMrM84GQnUcJ9DN3tR5X3vuHVrqRP1j8Aw1O0wT1tZhz0YRRaNLdQVTTp2LPFTq2J+T+vJwaXG57ljUF4tYKJTkNcWWlAqLKL+RRJSjhBfoMMKCRpgG7h9C75mq64LcniiqpPOtmcPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966816; 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=g+8yoDAKtbWcn6kd6zbMcipsZN6xB1eyyko6EmQwVd4=; b=F96UfzgnNyUAsh5DMj3xWv5bMUeKLQE/SbMWQf366pxpGFBKU/8J/rkhLX5N7CmvgkWwPE+n6V8GZsGbGzBmLQkFkyyDJMr0AlaFr8jogX/pNXcFWI1D23RDtmgmkTc2JLBbAS1GRkrLDP3zu8XWsb6gjdwvdTxJi7R4/62/aEA= 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 1670966816520894.3852182244868; Tue, 13 Dec 2022 13:26:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmn-0000ey-IK; Tue, 13 Dec 2022 16:26:01 -0500 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 1p5Cmj-0000d8-S2 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:57 -0500 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmh-0003Dd-93 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:57 -0500 Received: by mail-oi1-x235.google.com with SMTP id r130so1053666oih.2 for ; Tue, 13 Dec 2022 13:25:54 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=g+8yoDAKtbWcn6kd6zbMcipsZN6xB1eyyko6EmQwVd4=; b=u2VYPKwTiOzufQhtwVhv/H7VrnIXSasov7WRww9TT82jmeEwxD6cOYxrV0yfGRZYps z+Q4DNUERk8wBghRze+IwTI1sIKqgqn+di7ypjF8pkclsLgbcUlgen4O+WXrdmvzEeRc kiHVLlHOnr+Vc87qJUD65OcAaLGmZh/nMqsmgO7W7iIW40G1XkMvxTPNFND5KxE8zN1n J290vYJbhiqor6dyRGqTFWHDAv7GlBiqOFtShCN0jAMij14VtK2kDz2tSyNm2ut2pkNa 8aGMHvW0c/RMvVLT9bThekneGuvbYr3oQ+CNGXbKF7GBgCLrX0cit3lGga5jV0jZtTVh fgoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=g+8yoDAKtbWcn6kd6zbMcipsZN6xB1eyyko6EmQwVd4=; b=1I40lw40mdvyLvl3n/eN5q0SByeGGndYWE60XjY9Ig3mbaZEQZbZCctMA5CkXjU1FW bA2NbvU21kR167uooyZk9i5jnX4ifmL9QxG/xKgAxGn6Yj37WOFKYxQ8QpOSu/mIKQPn pE83jxacfAP91LpaYSRpQjJz8akh9Yb4XJ1kHVio/oNeOyxLAMUHS9ZYTGkkU522E+yI Smp85Fy1NAEfruItw7LWGXOBcooL9O7Z4Pu3/05OmlQQ2REHNHDj4nQdiN6Yyb6PKrpG H6u2FkQgsrYRKswkcw3JDVVt47I/bgeO8iEPZYYPYnvbIURtdrJ7REfwf6jkPTR3H556 /izw== X-Gm-Message-State: ANoB5pkON4x5i91vy61MdQUvfuoaQqxdoWfaJSOVWcInwsDN+f+8X0EM 2++GWG943HtWfE1scU8XkYVHwtl94TdRtceeKxA= X-Google-Smtp-Source: AA0mqf4PNhkyZa4gInsybScGOCVYXezR9zB7gpMro//5bhTQeE0NTOMD0fy/W0AcvU4vGemoIQcddg== X-Received: by 2002:a05:6808:491:b0:35e:8855:1f2f with SMTP id z17-20020a056808049100b0035e88551f2fmr5502380oid.31.1670966754631; Tue, 13 Dec 2022 13:25:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 11/27] tcg: Move TCG_TYPE_COUNT outside enum Date: Tue, 13 Dec 2022 15:25:25 -0600 Message-Id: <20221213212541.1820840-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966816947100002 The count is not itself an enumerator. Move it outside to prevent the compiler from considering it with -Wswitch-enum. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index afa18986b1..f2da340bb9 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -294,7 +294,8 @@ typedef enum TCGType { TCG_TYPE_V128, TCG_TYPE_V256, =20 - TCG_TYPE_COUNT, /* number of different types */ + /* Number of different types (integer not enum) */ +#define TCG_TYPE_COUNT (TCG_TYPE_V256 + 1) =20 /* An alias for the size of the host register. */ #if TCG_TARGET_REG_BITS =3D=3D 32 --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967056; cv=none; d=zohomail.com; s=zohoarc; b=Y6VqioXv1mcoQmksFlB9szBS63fJqMA8tTpGgqw9IdLuqRyD9EGRKBqPZPh1ncBPW2GEavOl6kEEFxv4U7AzECbh65RmRPDg2Qk0Ffqcy2zQaVSfUP6RtCjEYRj2sdGM1RgBNkVohlr2C4H/f2tRs96zB6FW0Jk9vi0I3z44FT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967056; 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=3PNalx9xC9o37R0T2TRvL9fvT6DAngOYvV1/eVoQctk=; b=AEZPH7B3h1sEWcPUkRoDkEZt2cA3OwlagD8TQqFVbrNbjeTfzje+6PH6+CRM2GWqaYjoLB/mL88qFrZlDqhBFvRJ7lDl6Vn/gfQgYFTAAMKWoYRJngF2Qs1CyComMk9xwMpBv4IP293VKnFj43LL+F4LcperqgJKvmVrJ4yOdSw= 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 1670967056930837.8417686592107; Tue, 13 Dec 2022 13:30:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cml-0000e8-TG; Tue, 13 Dec 2022 16:25:59 -0500 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 1p5Cmk-0000dO-BW for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:58 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmi-0003Ep-PD for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:25:58 -0500 Received: by mail-oi1-x22b.google.com with SMTP id v82so1042740oib.4 for ; Tue, 13 Dec 2022 13:25:56 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=3PNalx9xC9o37R0T2TRvL9fvT6DAngOYvV1/eVoQctk=; b=Qynv2f2/vRtNDVUKBo6HgeFZD8XuMJA+SSC0Cq6RS9h3xa9sFQmJPSBdMTWMQOIE9n bEDGMdWnyV01yeI0dhnum3xF0fgTF4KrHpGVwHY9cSVU3r3PJMtn5AQTrDLJrx5LVH5i dFR0GmEKX6XPK/aajWcoRYMDrEkhuhGPvsHkSbPhpFANurqJsq6U3jB4mu7m1QHVs7Os T4c8fQazaL+w5bh7Lej5m56hU0JmaOiogzOuL2KjbHmjliV9N/by/SuC0P0z7l/uDyme fav+h5j8MyYFSi1r1L9M5HUsc4lFiu4OAIMJcTqeCzf9q/CNo58k0M+2RcRKAbg2fTG2 q6+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3PNalx9xC9o37R0T2TRvL9fvT6DAngOYvV1/eVoQctk=; b=YJI/sN4WWZWTm0DerhhQ9xCc434m0CiRRIQ4efdgfZkWAp2/d/IzFnsIyH3InBqFG0 vB9uZowDWQBaNnVfxzNDfcb4AxTmN+VXqsSVWpplaH5ZBnLfe8OIMgjKu56Dx8Odb1T5 AuFaEr7fFVkcKb8SYcQC0gPqJTyOeKJt+abI7Xn3vq/d3g8/nBkzBN3TY4JJ+INjEsCf fV6zJmz19p21eFRLIzUTOoLBgCST36c78LztbeqBPQdqVQDSO0+wxT8mr6eGjiwYdw2Z 2AEDdDB0fiQUSDnEDL80QmzPYcrCzkjRz7OPDoVNap5JmZj4ID+5xNVTTzIndJAWIlwV /s1g== X-Gm-Message-State: ANoB5pl6QoOcXqV5IhjIa0cJyjMFrT/V5f0t3T9IjohdcPUQwC7qSygu FmKFo8whe1wtqHJH04EmScqb8nz9G3eXhK8XsY0= X-Google-Smtp-Source: AA0mqf7BCEqaa9nWwr7dwlzf84FA6nTD/bOag2tFWKIYEXZE1hZfBPRZh8KFwtD1m6XRNCHgc59ZpQ== X-Received: by 2002:a05:6808:1a9c:b0:35a:2589:1c2d with SMTP id bm28-20020a0568081a9c00b0035a25891c2dmr8982882oib.44.1670966755674; Tue, 13 Dec 2022 13:25:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 12/27] tcg: Introduce tcg_type_size Date: Tue, 13 Dec 2022 15:25:26 -0600 Message-Id: <20221213212541.1820840-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967058087100001 Add a helper function for computing the size of a type. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 16 ++++++++++++++++ tcg/tcg.c | 27 ++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index f2da340bb9..8bcd60d0ed 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -319,6 +319,22 @@ typedef enum TCGType { #endif } TCGType; =20 +/** + * tcg_type_size + * @t: type + * + * Return the size of the type in bytes. + */ +static inline int tcg_type_size(TCGType t) +{ + unsigned i =3D t; + if (i >=3D TCG_TYPE_V64) { + tcg_debug_assert(i < TCG_TYPE_COUNT); + i -=3D TCG_TYPE_V64 - 1; + } + return 4 << i; +} + /** * get_alignment_bits * @memop: MemOp value diff --git a/tcg/tcg.c b/tcg/tcg.c index dbf4e864eb..12676268a2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3038,22 +3038,22 @@ static bool liveness_pass_2(TCGContext *s) =20 static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - intptr_t off, size, align; + int size =3D tcg_type_size(ts->type); + int align; + intptr_t off; =20 switch (ts->type) { case TCG_TYPE_I32: - size =3D align =3D 4; + align =3D 4; break; case TCG_TYPE_I64: case TCG_TYPE_V64: - size =3D align =3D 8; + align =3D 8; break; case TCG_TYPE_V128: - size =3D align =3D 16; - break; case TCG_TYPE_V256: /* Note that we do not require aligned storage for V256. */ - size =3D 32, align =3D 16; + align =3D 16; break; default: g_assert_not_reached(); @@ -3593,8 +3593,8 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *op) TCGRegSet dup_out_regs, dup_in_regs; TCGTemp *its, *ots; TCGType itype, vtype; - intptr_t endian_fixup; unsigned vece; + int lowpart_ofs; bool ok; =20 ots =3D arg_temp(op->args[0]); @@ -3662,15 +3662,12 @@ static void tcg_reg_alloc_dup(TCGContext *s, const = TCGOp *op) /* fall through */ =20 case TEMP_VAL_MEM: -#if HOST_BIG_ENDIAN - endian_fixup =3D itype =3D=3D TCG_TYPE_I32 ? 4 : 8; - endian_fixup -=3D 1 << vece; -#else - endian_fixup =3D 0; -#endif - /* Attempt to dup directly from the input memory slot. */ + lowpart_ofs =3D 0; + if (HOST_BIG_ENDIAN) { + lowpart_ofs =3D tcg_type_size(itype) - (1 << vece); + } if (tcg_out_dupm_vec(s, vtype, vece, ots->reg, its->mem_base->reg, - its->mem_offset + endian_fixup)) { + its->mem_offset + lowpart_ofs)) { goto done; } /* Load the input into the destination vector register. */ --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966930; cv=none; d=zohomail.com; s=zohoarc; b=U72SR73DBDzPErrk39IouRLby2SWxuThBfzNHwK1HtEh3pK0kI5fHfOjqMVcUCzrfBd2IY1jVEP5Tm33xVomT8fe8dt9XSAad/kYTkUsIKDFhOUdAhQhG02Fs8xhbvjebXTvS4FjR8VjCG/vmysb13RZZB+R1T4cUnwbTPqIN4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966930; 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=9Ca1OA5nQYbr0k/TE8wJLN+t11Y9wq6hjnrCkBaDjgo=; b=Ud+PWruzESIYq8NJksNPUullpv7c3XsTaqI0AeWnyow9bc/5e6MTtC69QpveRP2PfrQkK0ok2+onRraZbsC5+LWea2yDNLA7DxvEWLElYkzWzlBB6IbQkUAxaqbqFu6+MxShF/IjpCMSEBjkKNfhOZg1mewuKBl1SkbqKUQt3rU= 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 1670966930184979.7532716012535; Tue, 13 Dec 2022 13:28:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmo-0000fS-4U; Tue, 13 Dec 2022 16:26:02 -0500 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 1p5Cmm-0000eN-A1 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:00 -0500 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmk-0003FD-PE for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:00 -0500 Received: by mail-ot1-x335.google.com with SMTP id z14-20020a9d65ce000000b0067059c25facso674739oth.6 for ; Tue, 13 Dec 2022 13:25:58 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=9Ca1OA5nQYbr0k/TE8wJLN+t11Y9wq6hjnrCkBaDjgo=; b=qLr9LWKMyAP4fEaLG+14DODryiXI41PaQw94DI2wktR5q+S1j8iM0+6eO7MqMs53/v Yi3ZTLEohnXgk8H7jZlyQSgVIlATbq8H5YlHKpDoxUFv8uDTqw4Ytsdu6LK6ZgadXEsi 9+eiui95TJMUFkRulR4hLfaSOvtf1zaps9avYh6VOAJNUum43FJ1tkKpmbwTOwGOf7jn 5rZ+v84AbiGF/RbaAat1Yaes818TNMm7GUPKpe0xMKRENMiEFDMki4JmtoTtD36XPpJ/ 44B//qxYxtU+xKHx9+zpiVFobbHFePyfgLDtlN+q3JKSh95YXp1r00mhlJL9XYXzohG+ 9JNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=9Ca1OA5nQYbr0k/TE8wJLN+t11Y9wq6hjnrCkBaDjgo=; b=mOYXihDkdZjRFqEiE78CHG+RZvtg7wbS8nSL0pOAZjXyBg/ImisVZR2GyJdi1kWN64 AcxNvgTCMos/6ZU/pWmMXcP4fhkj8Cwvz9UipS4Xzhk7dsk+Np7QwGwkK1/Dm+ZE8pMi dXrXXYnvbbRon4L/cmey39YcMmODNTheDYljVPdnNTG+i8d1yHkFG6t1U2LwfTDuJOH8 FMd/NXknw6DP5O39t/dPcpmbulp+9C3FwCZPMiNMt3+bro6lTbabP2X1B8me5s0wZOVj VvXjHzWc9/Co0NEiV7GSwqma33EbzR/cvrgW2nhqr76sKzb1K9xxCOOgADBgyfguQse6 nnJA== X-Gm-Message-State: ANoB5pl89Gev6b5zpOuCbmWiGP475bhbBcSHXtWCOtSz5lfYM/Ez9zAf h5dc8U3vDpAU4KzHkEOfFL2vQ2iBAgbtxqCWgKU= X-Google-Smtp-Source: AA0mqf53z3fXcks66VznapKgkmj8LbOVUNxaLUSYfPIagsTIWQXVGRMWqae4DfjGwRpn8nWlIIrSPg== X-Received: by 2002:a9d:6c07:0:b0:66e:ab28:cced with SMTP id f7-20020a9d6c07000000b0066eab28ccedmr10112979otq.13.1670966756791; Tue, 13 Dec 2022 13:25:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 13/27] tcg: Introduce TCGCallReturnKind and TCGCallArgumentKind Date: Tue, 13 Dec 2022 15:25:27 -0600 Message-Id: <20221213212541.1820840-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::335; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966931488100001 Prepare to replace a bunch of separate ifdefs with a consistent way to describe the ABI of a function call. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- tcg/tcg-internal.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 2c06b5116a..f574743ff8 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -27,6 +27,21 @@ =20 #define TCG_HIGHWATER 1024 =20 +/* + * Describe the calling convention of a given argument type. + */ +typedef enum { + TCG_CALL_RET_NORMAL, /* by registers */ +} TCGCallReturnKind; + +typedef enum { + TCG_CALL_ARG_NORMAL, /* by registers (continuing onto stack) */ + TCG_CALL_ARG_EVEN, /* like normal, but skipping odd slots */ + TCG_CALL_ARG_EXTEND, /* for i32, as a sign/zero-extended i64 */ + TCG_CALL_ARG_EXTEND_U, /* ... as a zero-extended i64 */ + TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */ +} TCGCallArgumentKind; + typedef struct TCGHelperInfo { void *func; const char *name; --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966824; cv=none; d=zohomail.com; s=zohoarc; b=mYBNvt9lHh9alMiCfAW1ULpI+7eHpwJGysBBdzUMF7O2DhZuaV/DKaGaTddHOFjO7Oqt2cVJGaT5VI3reWo3IP6IRXdxAIMQGIooNVgKOATCbGYT2Lu2CSJiPdEF5C15qpY/4249F1YvQkYN9s+InsZZaACvCe9AbY01NcCenUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966824; 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=8cQIWEMyleaE9VnutdzGpBw5zrz24lsmhK3egVV5Q0E=; b=gJM8cIxcnYwsFkVMbHEBcSDc/nkPLqROZOglnkEwibmWJ5J/OzdThZLTHeUPM0u4rJl98dMjIVSJofWRFg0TW0l1UvVC5PaWPIwZrFIeL4dfsbjj81e8hfXkllB5EK1kNY89z0WFZzej+whhUOnw3fGmKsyIrIx0k0UkEWh9B/Q= 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 1670966824528579.941247960254; Tue, 13 Dec 2022 13:27:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmo-0000fU-6j; Tue, 13 Dec 2022 16:26:02 -0500 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 1p5Cmm-0000eY-Km for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:00 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmk-0003D0-JT for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:00 -0500 Received: by mail-oi1-x236.google.com with SMTP id l127so1028155oia.8 for ; Tue, 13 Dec 2022 13:25:58 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=8cQIWEMyleaE9VnutdzGpBw5zrz24lsmhK3egVV5Q0E=; b=hVGVuizWF32FMUOC+5cRaZA7hmwDoq09RIiF8KblKBGhmnsYwzAtbRZ2L6v4JYXw1a Srmsvq5fGEMfYXKcvGf/uf9zG7zNlLpIvhWWKibKalvb95hZHdL+Jmqrx36PKTJSgR6W Z60/r6a/EksuIoHDW7q7+eyQV8keE0NCeg5kencGb0oLvx5Tq7yBtJ9SiCFdwz3xK7Or 1rMMZGt+M7SvOvcaihVUDXuFAboCi7GybAiwYWIN/F9qd7CIIt/8Ll4+YifCrAMAhYkr tz5/t4nrTlBL9xbh+Y0u359nx/1cYGTgQeJDp3+qj8JbMGxI+420n5ZF6kT5+2Sll6t3 dnBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8cQIWEMyleaE9VnutdzGpBw5zrz24lsmhK3egVV5Q0E=; b=oE3aV8BSg+34KNwF8MGLDdVktMYk9MxuFMCJ8a6zgQJG7fe/UxhEqQT6hdi2MgaJay cxWw47YNQGaFl+UBB399oSJQRTIpWlyucR4dEA8aguuBNPEQB6s9sSDQngKEc7EUKPXY UvBrTsp15OVRFtnLy6TI+ta2Xj/LvJDkjNB+MAAHCAx2UANntYR4sQcB9p3sHUAz6l87 pSLXLmIl9u4PezbI2an7WyorlWAknSKLkJr0iL9mu4dbnU3nmcJwCp5vpxfpwcaSkPh/ nEgwOaR1BQ05EPto20gmwhat3ocmFstXH6LBSI0JxoBM+hNupmTSfluAMGLoAbbRksPV vHGg== X-Gm-Message-State: ANoB5pnHikKuHVgH2K9k2OoFU7acfxJgyi8bTMWkrwQ5M09Pkbg0lUdf lX9A3w4ijOUJBwK2xIpJberW3DhZ0UOH5IrnCkA= X-Google-Smtp-Source: AA0mqf6WhPCFrGOtROXD7YN8lGwlH8DEQMcgPLytXhoWgqt2nnh0ddax5NQx3kmDyudepE179MqeKg== X-Received: by 2002:a05:6808:f13:b0:35b:e0ba:37a with SMTP id m19-20020a0568080f1300b0035be0ba037amr13002452oiw.54.1670966757872; Tue, 13 Dec 2022 13:25:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 14/27] tcg: Replace TCG_TARGET_CALL_ALIGN_ARGS with TCG_TARGET_CALL_ARG_I64 Date: Tue, 13 Dec 2022 15:25:28 -0600 Message-Id: <20221213212541.1820840-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966825062100001 For 32-bit hosts when TCG_TARGET_CALL_ALIGN_ARGS was set, use TCG_CALL_ARG_EVEN. For 64-bit hosts, TCG_TARGET_CALL_ALIGN_ARGS was silently ignored, so always use TCG_CALL_ARG_NORMAL. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 +- tcg/arm/tcg-target.h | 2 +- tcg/i386/tcg-target.h | 1 + tcg/loongarch64/tcg-target.h | 2 +- tcg/mips/tcg-target.h | 3 ++- tcg/riscv/tcg-target.h | 6 +++++- tcg/s390x/tcg-target.h | 1 + tcg/sparc64/tcg-target.h | 1 + tcg/tci/tcg-target.h | 5 +++++ tcg/tcg.c | 6 ++++-- tcg/ppc/tcg-target.c.inc | 21 ++++++++------------- 11 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index e145d50fef..d9dd777caa 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -51,8 +51,8 @@ typedef enum { /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 /* optional instructions */ #define TCG_TARGET_HAS_div_i32 1 diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 56c1ac4586..09dd0550aa 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -88,8 +88,8 @@ extern bool use_neon_instructions; =20 /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN =20 /* optional instructions */ #define TCG_TARGET_HAS_ext8s_i32 1 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 00fcbe297d..42628a2791 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -98,6 +98,7 @@ typedef enum { #else #define TCG_TARGET_CALL_STACK_OFFSET 0 #endif +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 extern bool have_bmi1; extern bool have_popcnt; diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index a659c8d6fd..19d4c07170 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -92,8 +92,8 @@ typedef enum { /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 7669213175..bb7312aed4 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -83,10 +83,11 @@ typedef enum { #define TCG_TARGET_STACK_ALIGN 16 #if _MIPS_SIM =3D=3D _ABIO32 # define TCG_TARGET_CALL_STACK_OFFSET 16 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else # define TCG_TARGET_CALL_STACK_OFFSET 0 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif -#define TCG_TARGET_CALL_ALIGN_ARGS 1 =20 /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >=3D 1)) || \ diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 11c9b3e4f4..2ab4b8d04a 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -81,8 +81,12 @@ typedef enum { /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#if TCG_TARGET_REG_BITS =3D=3D 32 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#endif =20 /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index 23e2063667..3f77fcf5b3 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -166,6 +166,7 @@ extern uint64_t s390_facilities[3]; /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 #define TCG_TARGET_CALL_STACK_OFFSET 160 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 #define TCG_TARGET_EXTEND_ARGS 1 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index 8655acdbe5..44ac164b31 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -72,6 +72,7 @@ typedef enum { #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET (128 + 6*8 + TCG_TARGET_STACK_BIAS) #define TCG_TARGET_EXTEND_ARGS 1 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 #if defined(__VIS__) && __VIS__ >=3D 0x300 #define use_vis3_instructions 1 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index ceb36c4f7a..e11c293906 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -158,6 +158,11 @@ typedef enum { /* Used for function call generation. */ #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_STACK_ALIGN 8 +#if TCG_TARGET_REG_BITS =3D=3D 32 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#endif =20 #define HAVE_TCG_QEMU_TB_EXEC #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/tcg.c b/tcg/tcg.c index 12676268a2..3ca25f7a28 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1542,9 +1542,11 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nar= gs, TCGTemp **args) * for passing off to ffi_call. */ want_align =3D true; -#elif defined(TCG_TARGET_CALL_ALIGN_ARGS) +#else /* Some targets want aligned 64 bit args */ - want_align =3D is_64bit; + if (is_64bit) { + want_align =3D TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVE= N; + } #endif =20 if (TCG_TARGET_REG_BITS < 64 && want_align && (real_args & 1)) { diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 9e34df94ba..c2e6bc3296 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -45,7 +45,9 @@ #endif =20 #ifdef _CALL_SYSV -# define TCG_TARGET_CALL_ALIGN_ARGS 1 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif =20 /* For some memory operations, we need a scratch that isn't R0. For the A= IX @@ -2202,9 +2204,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) lo =3D lb->addrlo_reg; hi =3D lb->addrhi_reg; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVEN); tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); tcg_out_mov(s, TCG_TYPE_I32, arg++, lo); } else { @@ -2250,9 +2250,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) lo =3D lb->addrlo_reg; hi =3D lb->addrhi_reg; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVEN); tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); tcg_out_mov(s, TCG_TYPE_I32, arg++, lo); } else { @@ -2266,9 +2264,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) if (TCG_TARGET_REG_BITS =3D=3D 32) { switch (s_bits) { case MO_64: -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVEN); tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); /* FALLTHRU */ case MO_32: @@ -2324,9 +2320,8 @@ static bool tcg_out_fail_alignment(TCGContext *s, TCG= LabelQemuLdst *l) =20 if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { TCGReg arg =3D TCG_REG_R4; -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVEN); if (l->addrlo_reg !=3D arg) { tcg_out_mov(s, TCG_TYPE_I32, arg, l->addrhi_reg); tcg_out_mov(s, TCG_TYPE_I32, arg + 1, l->addrlo_reg); --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966784; cv=none; d=zohomail.com; s=zohoarc; b=YSp0AecMvYgry0lgF9fmsK58ufwdFLHbdlibMm5H7hnYheMcMiQ4QCm9lTz4mr6V2JI2Hpsz2Gv85vJnO1qTpcMfF1BCnw6ctoonKZtL/v7z9hB4KytvQ1BTR0XeQGkkfpPoU4PNfrt5QGA3xyjqcJpmC7lcZaESURRGyvUJsKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966784; 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=ZOnun1gj2MJ7bcEZ/RrytneSuuImjXAZrtV+jstCUNA=; b=Bw812hwlGfpBcHG/b+ugmM87mFO3+2ted8Jr1DNalkmE/szVqvYi0klOUbA4H8pLMGVo154cSpxdMtBPw/+XyYRgLDw2LOHH1fYIZ8kR2S5DG8NFFXfwgjOwX3Zw0vxn8UnEaH5g7pk1nuiM9UiOYOsOr119D/vc+Djhw+wC5cQ= 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 1670966784185163.08174861933958; Tue, 13 Dec 2022 13:26:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmt-0000fp-Pr; Tue, 13 Dec 2022 16:26:07 -0500 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 1p5Cmo-0000fT-Gb for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:02 -0500 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmm-0003Fb-4L for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:01 -0500 Received: by mail-oi1-x22c.google.com with SMTP id r11so1006200oie.13 for ; Tue, 13 Dec 2022 13:25:59 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=ZOnun1gj2MJ7bcEZ/RrytneSuuImjXAZrtV+jstCUNA=; b=Vdibtv/jy3hdrrPXyviVT762Q2IJEfrm/SCzKMrDEK16Lsut6qEHzhm/30ZJpjgS3x 3AzYgUMqsj6PqisKrUCx16uysAtDz/Vmqs2MYmo2bl3oDBuygGy6XtGLeyTKaH3xeVtI qtH0YTArYfm8nRmMmp/ReVIeQ8ndeROr4MGcbfDR2yiLX/6e/1IZnMb/8GE3w+rS9P7J QTQuxAWt9l4pJesTCan1pE9yGFq5YjgUdevx0FGh6t0ek9bOeM7wuRoGfo1zhuPgQiPL rlUL5w43xjkLOd+6SMWbL0qDk/qo4r/1PpuMw55y/GvnzwVBGGjN5QkGEOhlmEPl4gFB yL4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ZOnun1gj2MJ7bcEZ/RrytneSuuImjXAZrtV+jstCUNA=; b=DY5mxH9QL8gfDz2MB9Yjejzx06KEkbLRllS0NHJ8KeVh+CF3yb0TpphSByhztqfvnF kxUWHGiHBOHYWGbq647x//h2ZT6BSY7BZrUQ6ZLixdSbS1nLfMG7X5rcttLDjgmEkfZV HUEqra1G/KE1ICucK1U/BEe0Uv6Pj6IAKPSiRqx6Y34ZBbQF/xJW7uhL6ijl60KKR7/K humNQTzxswRuELXCr484gUkYAeWCZ1bBrZvOzAiHSGp9owlhXoRoG0HAXHnTWpi7LpNM DAfWvpNrMNixxgIyFem7zzuTt+3ce15HJVpIGDK8exP93/6Z304QvZxAdtcqkUntGdZf ZwlA== X-Gm-Message-State: ANoB5pmhBUPQ+ngJu1CyZ6n4Q1PdhHfqNaoB52VEk/9q2UqyIHgDhGpx MKSZEh+auZMjKZUGj6nYdsisUpk00x0NTBMieQY= X-Google-Smtp-Source: AA0mqf7SBeIV2AXXC2FQORK3ADfaPc9v78Z+5rPrz9G5SQRaXdib23L+729YNJ6gL5ZOvlnIRyIFnA== X-Received: by 2002:a05:6808:51:b0:35a:6dc0:2138 with SMTP id v17-20020a056808005100b0035a6dc02138mr10883715oic.17.1670966759036; Tue, 13 Dec 2022 13:25:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 15/27] tcg: Replace TCG_TARGET_EXTEND_ARGS with TCG_TARGET_CALL_ARG_I32 Date: Tue, 13 Dec 2022 15:25:29 -0600 Message-Id: <20221213212541.1820840-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::22c; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966784872100005 For 64-bit hosts that had TCG_TARGET_EXTEND_ARGS, set TCG_TARGET_CALL_ARG_I32 to TCG_CALL_ARG_EXTEND. Otherwise, use TCG_CALL_ARG_NORMAL. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 1 + tcg/loongarch64/tcg-target.h | 1 + tcg/mips/tcg-target.h | 1 + tcg/riscv/tcg-target.h | 1 + tcg/s390x/tcg-target.h | 2 +- tcg/sparc64/tcg-target.h | 2 +- tcg/tci/tcg-target.h | 1 + tcg/tcg.c | 42 ++++++++++++++++++------------------ tcg/ppc/tcg-target.c.inc | 6 +++++- 11 files changed, 35 insertions(+), 24 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index d9dd777caa..413a5410c5 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -52,6 +52,7 @@ typedef enum { #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 /* optional instructions */ diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 09dd0550aa..b7843d2d54 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -89,6 +89,7 @@ extern bool use_neon_instructions; /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN =20 /* optional instructions */ diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 42628a2791..7edb7f1d9a 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -98,6 +98,7 @@ typedef enum { #else #define TCG_TARGET_CALL_STACK_OFFSET 0 #endif +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 extern bool have_bmi1; diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 19d4c07170..e5f7a1f09d 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -93,6 +93,7 @@ typedef enum { #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 /* optional instructions */ diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index bb7312aed4..15721c3e42 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -88,6 +88,7 @@ typedef enum { # define TCG_TARGET_CALL_STACK_OFFSET 0 # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL =20 /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >=3D 1)) || \ diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 2ab4b8d04a..232537ccea 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -82,6 +82,7 @@ typedef enum { #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS =3D=3D 32 #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index 3f77fcf5b3..22d70d431b 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -166,9 +166,9 @@ extern uint64_t s390_facilities[3]; /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 #define TCG_TARGET_CALL_STACK_OFFSET 160 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 -#define TCG_TARGET_EXTEND_ARGS 1 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 #define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index 44ac164b31..0044ac8d78 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -71,7 +71,7 @@ typedef enum { #define TCG_TARGET_STACK_BIAS 2047 #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET (128 + 6*8 + TCG_TARGET_STACK_BIAS) -#define TCG_TARGET_EXTEND_ARGS 1 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL =20 #if defined(__VIS__) && __VIS__ >=3D 0x300 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index e11c293906..d6e0450ed8 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -158,6 +158,7 @@ typedef enum { /* Used for function call generation. */ #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_STACK_ALIGN 8 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS =3D=3D 32 # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else diff --git a/tcg/tcg.c b/tcg/tcg.c index 3ca25f7a28..4c397cb0fa 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1494,24 +1494,24 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int na= rgs, TCGTemp **args) } #endif =20 -#if defined(TCG_TARGET_EXTEND_ARGS) && TCG_TARGET_REG_BITS =3D=3D 64 - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; - bool is_signed =3D argtype & 1; + if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { + for (i =3D 0; i < nargs; ++i) { + int argtype =3D extract32(typemask, (i + 1) * 3, 3); + bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; + bool is_signed =3D argtype & 1; =20 - if (is_32bit) { - TCGv_i64 temp =3D tcg_temp_new_i64(); - TCGv_i32 orig =3D temp_tcgv_i32(args[i]); - if (is_signed) { - tcg_gen_ext_i32_i64(temp, orig); - } else { - tcg_gen_extu_i32_i64(temp, orig); + if (is_32bit) { + TCGv_i64 temp =3D tcg_temp_new_i64(); + TCGv_i32 orig =3D temp_tcgv_i32(args[i]); + if (is_signed) { + tcg_gen_ext_i32_i64(temp, orig); + } else { + tcg_gen_extu_i32_i64(temp, orig); + } + args[i] =3D tcgv_i64_temp(temp); } - args[i] =3D tcgv_i64_temp(temp); } } -#endif /* TCG_TARGET_EXTEND_ARGS */ =20 op =3D tcg_emit_op(INDEX_op_call); =20 @@ -1572,16 +1572,16 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int na= rgs, TCGTemp **args) tcg_debug_assert(TCGOP_CALLI(op) =3D=3D real_args); tcg_debug_assert(pi <=3D ARRAY_SIZE(op->args)); =20 -#if defined(TCG_TARGET_EXTEND_ARGS) && TCG_TARGET_REG_BITS =3D=3D 64 - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; + if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { + for (i =3D 0; i < nargs; ++i) { + int argtype =3D extract32(typemask, (i + 1) * 3, 3); + bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; =20 - if (is_32bit) { - tcg_temp_free_internal(args[i]); + if (is_32bit) { + tcg_temp_free_internal(args[i]); + } } } -#endif /* TCG_TARGET_EXTEND_ARGS */ } =20 static void tcg_reg_alloc_start(TCGContext *s) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index c2e6bc3296..38ee9974cd 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -44,6 +44,11 @@ # endif #endif =20 +#if TCG_TARGET_REG_BITS =3D=3D 64 +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND +#else +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL +#endif #ifdef _CALL_SYSV # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else @@ -2520,7 +2525,6 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int co= unt) =20 /* Parameters for function call generation, used in tcg.c. */ #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_EXTEND_ARGS 1 =20 #ifdef _CALL_AIX # define LINK_AREA_SIZE (6 * SZR) --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966787; cv=none; d=zohomail.com; s=zohoarc; b=gHyDZ2K/dSjB66DatwHqXBH0++op+fUWFtUMA2aS1OyCI33l4KGyqpBPmI+WUV3NFlC6H8k+lD4rC5zCzHhF+LVADTtFeyGS1+0Wpr7Ld7Y0qw2+YrtFIH7JhJaaBxg+ALuaYVu8xFIL98fzS7pX7zXnq8y5rpujUBcoQ3nitwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966787; 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=kcsaITVUaZwX2W3VYFeAudOGzYmg0UWJ+TXMDg4IToo=; b=RCsYwzi1MlX+kvvtDDl8ITPJ1pd3ZFuH3JYqfjl3RQwIaN9N8Nb6uk7JeUV9de33DVLnZCETC7F65FSqrZb/Koe7YgyZLlKKmOTDM0jvr+hUom3S+InwduZMXJ/CB27I/FMGL6fcedZFJQoK7CG25HU53KmrrTZ3hNxI0qUE06c= 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 1670966787539545.806975366576; Tue, 13 Dec 2022 13:26:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmv-0000gg-EV; Tue, 13 Dec 2022 16:26:09 -0500 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 1p5Cmu-0000g3-2V for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:08 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmm-0003EK-PK for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:03 -0500 Received: by mail-oi1-x229.google.com with SMTP id s186so1044038oia.5 for ; Tue, 13 Dec 2022 13:26:00 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=kcsaITVUaZwX2W3VYFeAudOGzYmg0UWJ+TXMDg4IToo=; b=kx0pnFcthsKGbAbpVx4cshbd9Bl0sGXGRBqTqBJa6AH0L4i4fYPd5n87jgMjbuGUi7 3q7OkH1WDbw20toRhp0/Rm2zIZRwVj8X0Uv48Zao/g/LlupdP/v64l+svNiC06aMa0xJ D2bC4onp1tCrM9eEfLLwXPzK5nNanKW+rIRc2iLUqtyJjk+d6pW2EoOK3Pqd8U2kLud6 aZXk1vN+FeLahxKbv4g+MwRetR6R928jIYiJW2lAZQvpy9i2nfEqhB5jqEO2pJjP3wUs W6ul3bh1De/hJM8Hq2Ojc470ZGLzgpceYOwy43jUnwJOKU4VYH2jF5vugSUxZoUF8pHe Ellw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kcsaITVUaZwX2W3VYFeAudOGzYmg0UWJ+TXMDg4IToo=; b=y/LfQY7ODOBXuBpfjTuRuQ9wF8mY6tfoj3pU2ucOu4jRgwBbHMyW0yjJ23vlBUeGwM CUqbICAbEsFLushbQHKsCKD5PJpMAGGM4bLPw7nNjb6ZZCdQRMswMRJypTkNHYSrsv5f yiRwHQtSmxUQOvQ6Hrf9E96Vi5vYaY8qtMdRNkaqAjrfWxGA4vpN6FO54bIvaBXJJhEN ghjQEX77KYgh/rbAL2FSFfLdxPZTOPuz3T+HR21xOKYR9XcD+7XbR0TpoSxMYU3F1vIf tDD2YOOBqMkcvgAKPGJQJfdGZVEKoGPAVl1u8uFid97A93s+4SynX06UK2oRiee+89/K t49A== X-Gm-Message-State: ANoB5plNoFP0H7jjdC3BmnNXD0QNAL5fAfqFLudVkrSwfRaGWTpCntHC fyk40tProkHo+I+sUCtQ0FRmsokmImRKblZjS0Q= X-Google-Smtp-Source: AA0mqf796GG+wzckXRkswO2qpjpY8efJlcTUXZTXILjr+JMxEtefGIcHfC82JYUq9g/l4HglFyNRig== X-Received: by 2002:a05:6808:404c:b0:35e:bc7b:20ea with SMTP id cz12-20020a056808404c00b0035ebc7b20eamr213228oib.57.1670966760075; Tue, 13 Dec 2022 13:26:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 16/27] tcg: Use TCG_CALL_ARG_EVEN for TCI special case Date: Tue, 13 Dec 2022 15:25:30 -0600 Message-Id: <20221213212541.1820840-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966789025100005 Change 32-bit tci TCG_TARGET_CALL_ARG_I32 to TCG_CALL_ARG_EVEN, to force 32-bit values to be aligned to 64-bit. With a small reorg to the argument processing loop, this neatly replaces an ifdef for CONFIG_TCG_INTERPRETER. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 3 +- tcg/tcg.c | 70 ++++++++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index d6e0450ed8..94ec541b4e 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -158,10 +158,11 @@ typedef enum { /* Used for function call generation. */ #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_STACK_ALIGN 8 -#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS =3D=3D 32 +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EVEN # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index 4c397cb0fa..aae4046e1b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1533,36 +1533,56 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int na= rgs, TCGTemp **args) real_args =3D 0; for (i =3D 0; i < nargs; i++) { int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_64bit =3D (argtype & ~1) =3D=3D dh_typecode_i64; - bool want_align =3D false; + TCGCallArgumentKind kind; + TCGType type; =20 -#if defined(CONFIG_TCG_INTERPRETER) - /* - * Align all arguments, so that they land in predictable places - * for passing off to ffi_call. - */ - want_align =3D true; -#else - /* Some targets want aligned 64 bit args */ - if (is_64bit) { - want_align =3D TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVE= N; - } -#endif - - if (TCG_TARGET_REG_BITS < 64 && want_align && (real_args & 1)) { - op->args[pi++] =3D TCG_CALL_DUMMY_ARG; - real_args++; + switch (argtype) { + case dh_typecode_i32: + case dh_typecode_s32: + type =3D TCG_TYPE_I32; + break; + case dh_typecode_i64: + case dh_typecode_s64: + type =3D TCG_TYPE_I64; + break; + case dh_typecode_ptr: + type =3D TCG_TYPE_PTR; + break; + default: + g_assert_not_reached(); } =20 - if (TCG_TARGET_REG_BITS < 64 && is_64bit) { + switch (type) { + case TCG_TYPE_I32: + kind =3D TCG_TARGET_CALL_ARG_I32; + break; + case TCG_TYPE_I64: + kind =3D TCG_TARGET_CALL_ARG_I64; + break; + default: + g_assert_not_reached(); + } + + switch (kind) { + case TCG_CALL_ARG_EVEN: + if (real_args & 1) { + op->args[pi++] =3D TCG_CALL_DUMMY_ARG; + real_args++; + } + /* fall through */ + case TCG_CALL_ARG_NORMAL: + if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64)= { + op->args[pi++] =3D temp_arg(args[i]); + op->args[pi++] =3D temp_arg(args[i] + 1); + real_args +=3D 2; + break; + } op->args[pi++] =3D temp_arg(args[i]); - op->args[pi++] =3D temp_arg(args[i] + 1); - real_args +=3D 2; - continue; + real_args++; + break; + default: + g_assert_not_reached(); } - - op->args[pi++] =3D temp_arg(args[i]); - real_args++; } op->args[pi++] =3D (uintptr_t)func; op->args[pi++] =3D (uintptr_t)info; --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967196; cv=none; d=zohomail.com; s=zohoarc; b=W6/JajtdAH8ZcYzKKJ4VasPt5Dx5c8sOYb06dP9TJFdgpLJ+jxn7CuhnpJM7A7VKBGvH8eQnE2yIBkZVTY3lrWUnRY8kxsE+FcHQjQkaaOYxW9BMIAX6+rBR7IVUq/xOs1KwlkhOqkEQAtq39dLrTikCJJrrT4fo7Xu7YEu3VhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967196; 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=CGY8Ocb88UTBGvcjSvAAW2LYpXpJS1Nv/WKvbXwBWeI=; b=lgmdqrjF3fvqsG17dp60SihhRg75RKYWKMH9SE5J+rUdy/SLWyjZqDv/25q/FvOPy1h5ACJjgAdARvucaRxn0B/hHH6aWGv+m0raxZVRJPEhSHcjlgNM7hOYWZ0RLEOV0/Ioj8whN76phr2HsFwHKbBTE4Y8WIQ3y8yPXaWDomQ= 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 1670967195994327.5262902904384; Tue, 13 Dec 2022 13:33:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmw-0000h8-W2; Tue, 13 Dec 2022 16:26:11 -0500 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 1p5Cmu-0000g1-2V for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:08 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmo-0003GD-3q for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:06 -0500 Received: by mail-oi1-x234.google.com with SMTP id e205so1017016oif.11 for ; Tue, 13 Dec 2022 13:26:01 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=CGY8Ocb88UTBGvcjSvAAW2LYpXpJS1Nv/WKvbXwBWeI=; b=OZA4qz5waQctmW1fgO35pijZNJoRZWj127B4MreWmWuTMkG73aBxYQ+mhI+3NbJ45r 3LyDFXipIpZ0FWPezqMUuHu+BAnuPH+QR0VpKKG972C6ztMdK6TD0AgXavirX+mlwJVW H7XSg5Pe7nfoAUNqstSyJxNa5gVsKP0eOLSMi5Md0Jx80ZEc6m6V//+LSBjTCfQ+HZNq TRLr5/8CoQedGPnIo/0YZ0sDByTNo/vT6rpgwXejp5U+XhLqXFQ4vrhDB1S9p+Iz1edD 64oJvv+P/w1EeUpAYHm3hVlOi8hW1YBzYF5V8AhaX7vx6kAIqDwRe4Z/okM861xM8pOG ez0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=CGY8Ocb88UTBGvcjSvAAW2LYpXpJS1Nv/WKvbXwBWeI=; b=ESzfaLnleJHyKJr5rqOqyLSEDTzP04LyFv1SCgko8d9zgUFmcSDriZJeTLUFM8XJEv qDsLFXBVdZXjjepvhH73Upur122hudaPUlftiazwWf+62RKqbEBBdMRxYtmO7xu4H7sh aizJVOfs4ofjV/wBl13R0tAgIIUmXd69Qz3/ioaAp8MvkLmBPd99UWLS7fBR1EoqgVz6 bVEQvP2QMyngcY7Mhpr2UQONAX/+TM6+OxmkTjGBrH4f87x1Cloid0QirnFb1weZkWQw Aj2zicYwSG7asNNJ6qHjb7S1WwfSg7XZLKi7zVpFjkNaCBRNlPYYnqA3wHXru2LKEYUS X2OA== X-Gm-Message-State: ANoB5pkwng03fwv90ZtU+IgRQvqRSgB4iYPep9AwDAtfkTIrYeiQoFb5 1+IafdrSgppJA+rW4ahtRXPXGAqSI6stSLX9b60= X-Google-Smtp-Source: AA0mqf7a2FwFkBGQ0T5J2iZf35t8wAXMIuhBzXn+wIJ8R3QqDS1aHicFSnpVV+g80suk6RRNBPbPWg== X-Received: by 2002:a05:6808:e90:b0:359:a851:dfc1 with SMTP id k16-20020a0568080e9000b00359a851dfc1mr12150415oil.0.1670966761108; Tue, 13 Dec 2022 13:26:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 17/27] accel/tcg/plugin: Don't search for the function pointer index Date: Tue, 13 Dec 2022 15:25:31 -0600 Message-Id: <20221213212541.1820840-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967197189100001 The function pointer is immediately after the output and input operands; no need to search. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Cc: Alex Benn=C3=A9e --- accel/tcg/plugin-gen.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 80dff68934..9e359c006a 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -381,32 +381,25 @@ static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func, void *func, int *cb_idx) { + TCGOp *old_op; + int func_idx; + /* copy all ops until the call */ do { op =3D copy_op_nocheck(begin_op, op); } while (op->opc !=3D INDEX_op_call); =20 /* fill in the op call */ - op->param1 =3D (*begin_op)->param1; - op->param2 =3D (*begin_op)->param2; + old_op =3D *begin_op; + TCGOP_CALLI(op) =3D TCGOP_CALLI(old_op); + TCGOP_CALLO(op) =3D TCGOP_CALLO(old_op); tcg_debug_assert(op->life =3D=3D 0); - if (*cb_idx =3D=3D -1) { - int i; =20 - /* - * Instead of working out the position of the callback in args[], = just - * look for @empty_func, since it should be a unique pointer. - */ - for (i =3D 0; i < MAX_OPC_PARAM_ARGS; i++) { - if ((uintptr_t)(*begin_op)->args[i] =3D=3D (uintptr_t)empty_fu= nc) { - *cb_idx =3D i; - break; - } - } - tcg_debug_assert(i < MAX_OPC_PARAM_ARGS); - } - op->args[*cb_idx] =3D (uintptr_t)func; - op->args[*cb_idx + 1] =3D (*begin_op)->args[*cb_idx + 1]; + func_idx =3D TCGOP_CALLO(op) + TCGOP_CALLI(op); + *cb_idx =3D func_idx; + + op->args[func_idx] =3D (uintptr_t)func; + op->args[func_idx + 1] =3D old_op->args[func_idx + 1]; =20 return op; } --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966826; cv=none; d=zohomail.com; s=zohoarc; b=aerYwJjjZ2lnU3W97R5BWojlexa8vt0tJuWExT78tcxU5v//ue10kVZgseVpdbXIn2m7aOqh/762S0A8oIuNul0zHNSJnRr7qMgG6YndSMMKNMmFh3c0Xt8exBHBGGHXpyOt36P7Lq6pV9aISQfK/7yYUmBC/HKXZZPtitMDLAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966826; 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=0EHWQ74OByxZK6+6bk+BFaesKcqluoqr4XzyR1zvNEg=; b=GxdH/aOKpZmrtZmMcbAMOJrqSB6kiGuzLe3BWVeCOsWmnc8vXOklleBMsEwJnRKPEqYffa1RysId+gPnR4AD90/Egdjcbc71dfi7rVi+vK14sAAcIcVp9OjtnV2kgh28r4S14y5MJSWG3W7HSnP/geTE06ZkSXKz++wZMoAnOyk= 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 1670966826809296.50534021205647; Tue, 13 Dec 2022 13:27:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmx-0000hq-LC; Tue, 13 Dec 2022 16:26:11 -0500 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 1p5Cmu-0000g2-2q for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:08 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmo-0003Dw-TU for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:06 -0500 Received: by mail-oi1-x22f.google.com with SMTP id v70so1049807oie.3 for ; Tue, 13 Dec 2022 13:26:02 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=0EHWQ74OByxZK6+6bk+BFaesKcqluoqr4XzyR1zvNEg=; b=Gk1fOzRC3WJm44NRNJYyGD0xGEfKt24xNB9nCingYr746yCIS/yryamoOABxGsByqB 55zJlE5OVlaIQYvMBv0+skk25hbwmeeIlO14ntojHrzOd1r3gYOhphn4b6jmqonaoBl7 xhv62L8Q/JRfbOuIJoao4XV+iT4/2RQ2tpjiNIDl08DpVeU6X8esuLEQOvUAq0leXNA5 9xHdP98szmYCo9dhxYgXv3R1BYsb/C2t3pTvN3x3rL7Gwp+x+0/dBYiUaASPy7VfUQjU MFNcAtBEY07t6sSKtUh7wfJtGuZoTMY4tzZ2ENpQsmbGVFZvfgnxsolzhVAXx9jOY9Ze zyvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=0EHWQ74OByxZK6+6bk+BFaesKcqluoqr4XzyR1zvNEg=; b=JQ6mbLcHYoxU4y7Uzxiibs+MO7nfBSNyaUMyFEt/E1ta7FjNAieyBRTeapLfHuf1+f Iitahfs7Gdm6wALBPW3FhAY9MCWIz6RQ6ANqnOFpcUg45qyQ/NSMfsfApcHuUJnoeJF3 qe1NIhjlxOXAk4fnyD3McBlkgOUtleIxDLh2DyKui7Bt32NTgtkNYs0zLeZItR9TI5HX IM5Td7V/MsmFSOCHDDz5bOH3fVUX8aK+88B7ESMtStMFRWdv1AOozG0Oh4cVwGWb9gHw 950jTqfFP7fyzGL78pb45Qx9hOcWqi7aFB2J2Xh/K4Z2asdcp67ke8w+T4L1yLz6IQ2H s92w== X-Gm-Message-State: ANoB5pm6StUt9NhFobZE1zvCZjSkfw7zotq99cakAefwxH3VYNrCb5jH bFkWwUArd5bqlnXSU1UxPmIMjr0wKJYnt00Eqbk= X-Google-Smtp-Source: AA0mqf7j88q3RNHlAZ5PJYOythYw6aIaB1lyFfa4EhLZ8Gi+eDevKy2qjDpThQB9QJkEpq90/sF/qw== X-Received: by 2002:a54:4596:0:b0:35e:1be8:2354 with SMTP id z22-20020a544596000000b0035e1be82354mr9309906oib.48.1670966762238; Tue, 13 Dec 2022 13:26:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 18/27] accel/tcg/plugin: Avoid duplicate copy in copy_call Date: Tue, 13 Dec 2022 15:25:32 -0600 Message-Id: <20221213212541.1820840-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966826975100005 We copied all of the arguments in copy_op_nocheck. We only need to replace the one argument that we change. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Acked-by: Alex Benn=C3=A9e --- Cc: Alex Benn=C3=A9e --- accel/tcg/plugin-gen.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 9e359c006a..77e6823d6b 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -397,9 +397,7 @@ static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, vo= id *empty_func, =20 func_idx =3D TCGOP_CALLO(op) + TCGOP_CALLI(op); *cb_idx =3D func_idx; - op->args[func_idx] =3D (uintptr_t)func; - op->args[func_idx + 1] =3D old_op->args[func_idx + 1]; =20 return op; } --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670966851755212.5973678874111; Tue, 13 Dec 2022 13:27:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cn0-0000jE-7u; Tue, 13 Dec 2022 16:26:14 -0500 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 1p5Cmv-0000gf-FQ for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:10 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmt-0003H5-HS for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:09 -0500 Received: by mail-ot1-x32c.google.com with SMTP id db10-20020a0568306b0a00b0066d43e80118so689507otb.1 for ; Tue, 13 Dec 2022 13:26:04 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=mMNzNph6e5r2svno188/dE/TADl+oZbDomGCeY1Dcjs=; b=Uw+nC2BCJ0PNJERXJeyBgmvOCCYs3/S8CSvZBN4SEYCb+CWJTEVxdkbksyO8MBGu4k sRE6iFHjCERcZEK9MW1XsM/7k6x38R8P6W3X+n2fb9GrqR3umEzlvP+Yk2RFy65w17yT bMpvYJwXUkXz/sxNLpOsuS8YCwVO7z2V5HTgXFTlSAwW8bCQTCwpFYCA0DDTElpe0u+d Eq55ASjlSa2MZ+lY8Q6YY0VmQUePtK35k2xhZc/6zZSu7H2NwMYbwbatPs8CObwZNLRV nsaStPeSmEj9XX9lReVPgGQ6T8jJaaeNu5zQ37unIqWzfICiK9xQVw7ez+TpxvKPOJFl We4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=mMNzNph6e5r2svno188/dE/TADl+oZbDomGCeY1Dcjs=; b=2rxk+9McnbZtVcIXfYyr5bTiXRfjAznIc3t5LEBGsxcUcdtRbjV27gERLaCcne72gc S7RgYMstpaw8KD+gjrcAXkpZlcGAozFrg78YrnCOZK+W4ANyd8cjH5jBlYiVWjTq6WbQ lvM/QdAXDR12pqvrAcojNIgeKGRvbQoQ7ewGRETXRKWG9T9r3CHizylJEEJ+AlKKJFwo b8c1qjhft9p8cKJ/8jiNEoQksMuH2YCRTw970guez/Vl0JsoItyzQxagGA58Zbn9Hmv7 lqakKdR0ggliZ0I2temo5xJ/Z9fR+AEgIga5tcnNqcErSLLbFVjBdoRipdDFQj3gAOjT gq5Q== X-Gm-Message-State: ANoB5pn1aIJnNmVrlcOsc2qJHwvaBhSFW43H9FE3crY78fN2D2X0PUbo WulVYSS1YE3Fscnd15SLjKR+yzfnmbpl24SU6BE= X-Google-Smtp-Source: AA0mqf6Cj+hQ1kwShXd+L/Z+xt+2CKuIhaJ42T3SllqYqPoSqZgJyzoFHv5jZ0fWipuaOcNy3RD6Zg== X-Received: by 2002:a9d:734e:0:b0:670:6b4d:78b5 with SMTP id l14-20020a9d734e000000b006706b4d78b5mr11024582otk.16.1670966763308; Tue, 13 Dec 2022 13:26:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 19/27] accel/tcg/plugin: Use copy_op in append_{udata, mem}_cb Date: Tue, 13 Dec 2022 15:25:33 -0600 Message-Id: <20221213212541.1820840-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1670966853276100003 Better to re-use the existing function for copying ops. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Acked-by: Alex Benn=C3=A9e --- Cc: Alex Benn=C3=A9e --- accel/tcg/plugin-gen.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 77e6823d6b..a6aaacd053 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -415,11 +415,11 @@ static TCGOp *append_udata_cb(const struct qemu_plugi= n_dyn_cb *cb, op =3D copy_const_ptr(&begin_op, op, cb->userp); =20 /* copy the ld_i32, but note that we only have to copy it once */ - begin_op =3D QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); if (*cb_idx =3D=3D -1) { - op =3D tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); - memcpy(op->args, begin_op->args, sizeof(op->args)); + op =3D copy_op(&begin_op, op, INDEX_op_ld_i32); + } else { + begin_op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); } =20 /* call */ @@ -462,11 +462,11 @@ static TCGOp *append_mem_cb(const struct qemu_plugin_= dyn_cb *cb, op =3D copy_const_ptr(&begin_op, op, cb->userp); =20 /* copy the ld_i32, but note that we only have to copy it once */ - begin_op =3D QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); if (*cb_idx =3D=3D -1) { - op =3D tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); - memcpy(op->args, begin_op->args, sizeof(op->args)); + op =3D copy_op(&begin_op, op, INDEX_op_ld_i32); + } else { + begin_op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); } =20 /* extu_tl_i64 */ --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967375; cv=none; d=zohomail.com; s=zohoarc; b=nXF3Ki7hv6P4fSEg0ZhCoaMGZKer03bDOoQUpTmzDsT+ghcBrttRgyV/A+vayLEkJSAy6XOcQpmzE0Z5p/9BYWxy4nKXax2o/3wnsD3aYo1cnXPz3FwZ5RYDV+ddKbquf2PNl+OUNf6J1lTyPY0RF3HALqIj3GJkvYlHxyWQM1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967375; h=Content-Transfer-Encoding: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=KxCamUeUIq5ZNxrpta7OQIQz8HOjJD91HgCQ1yrQkYo=; b=PLY5gfI5PCTsuR/1w9JCVEhQOPKdxQfVb2sCKPfQhI0oEtDiR46xKVuN9YGgjKD6oPFsvLzr4r/A1B5BkNMSWS0qzY8VJJMRNixSeZkm2RLZPaovoyWx/HedtrAZePRsRz3iUMnkQaOzM+UI/sFXUX1rh7lCmAd5XNXlBzVusJ4= 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 1670967375810672.1760363343685; Tue, 13 Dec 2022 13:36:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmz-0000il-49; Tue, 13 Dec 2022 16:26:13 -0500 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 1p5Cmx-0000ho-EO for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:11 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmt-0003HG-SM for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:11 -0500 Received: by mail-oi1-x22b.google.com with SMTP id s186so1044200oia.5 for ; Tue, 13 Dec 2022 13:26:05 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KxCamUeUIq5ZNxrpta7OQIQz8HOjJD91HgCQ1yrQkYo=; b=Qxo/R8wPpWtP4494uxwRpLrxb9EXVrp6X9O3PuPH3wdgijBb3GxxFGYx6SM3lDQCD0 8ratugMRfNr8QdrUAhr7WQTxyu/+vDfcuTPmlECbN6/aBdCQNEg2MkKxYRd21SEzfNcZ t/O5lPpEqcAsG2hDOBn12q5YSuEjtWxtqQhkaNib1NgZKFt87vvONqxF8Ja3QSzjn4J5 3vVvmLaFXKfYCkI4pD1P3EF7faCUg+v3UiCJCi32tn3T4mpWD7J98DRGRVszxfGdbCRL 8/QF9KL/kMoBYSHPS5/52RjvUkiCUmdYpNeBjpyoWYg/XRb1vMSdtiLvgagIZTRaeBkM XbYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KxCamUeUIq5ZNxrpta7OQIQz8HOjJD91HgCQ1yrQkYo=; b=VxDK1qO7FiaQMXmvH8S3+9IXVTOrfs5d0P210EPYxZ6GUTwqDTi+5BfKAG6cyMgGo6 3Lf0VUwjv0lZq2ABhhdb5jT+w/VkbiPXZZNecSKjGyH94mkizm9HVlh3hxBzCQwAcDfD 5Ah0915WBhbKAnzOGtuITSWNdzwYTR1xtiBHsHXxrnQP77GP5a5nbEJRk+AHp7ZBw40h reL5pHC/nBFt+6JwrvO3qtwUvt3PJt+gZsrv4OmueqDwLf6F+MNKO39QBkYMsXkQN7/8 wd+U2RQJRl+f5TfRC5MOOwKvUC/OvfsgK5y8jKL9h04pJ+zRPodlUtZyOE6+M7oK3tmA iNVg== X-Gm-Message-State: ANoB5pkbp/+2+hz8L0Ej0DugQjL2EK+DZItfIXaR89BG9uXTkoOeRF+I /370SoqqpSSPAf6MQVzLJN2A+rrQRXWd6scf6Jk= X-Google-Smtp-Source: AA0mqf5iBsFpZs5wnT/TfxfAoNyD3Na9/GckSGT+vroLcnjy0NUWIrY06BYEm0CYXWyi9PfVJPWdJQ== X-Received: by 2002:aca:6503:0:b0:35e:4620:ee8b with SMTP id m3-20020aca6503000000b0035e4620ee8bmr9953867oim.33.1670966764313; Tue, 13 Dec 2022 13:26:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 20/27] tcg: Vary the allocation size for TCGOp Date: Tue, 13 Dec 2022 15:25:34 -0600 Message-Id: <20221213212541.1820840-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967376952100001 Content-Type: text/plain; charset="utf-8" We have been allocating a worst case number of arguments to support calls. Instead, allow the size to vary. By default leave space for 4 args, to maximize reuse, but allow calls to increase the number of args to 32. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- include/exec/helper-head.h | 2 -- include/tcg/tcg-op.h | 2 +- include/tcg/tcg.h | 54 +++++++++++++-------------------- accel/tcg/plugin-gen.c | 11 ++++--- tcg/optimize.c | 4 +-- tcg/tcg-op-vec.c | 8 ++--- tcg/tcg-op.c | 12 ++++---- tcg/tcg.c | 61 +++++++++++++++++++++++++------------- 8 files changed, 82 insertions(+), 72 deletions(-) diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index e242fed46e..8bdf0f6ea2 100644 --- a/include/exec/helper-head.h +++ b/include/exec/helper-head.h @@ -133,6 +133,4 @@ #define DEF_HELPER_7(name, ret, t1, t2, t3, t4, t5, t6, t7) \ DEF_HELPER_FLAGS_7(name, 0, ret, t1, t2, t3, t4, t5, t6, t7) =20 -/* MAX_OPC_PARAM_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_= n. */ - #endif /* EXEC_HELPER_HEAD_H */ diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 8176f194cb..79b1cf786f 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -818,7 +818,7 @@ static inline void tcg_gen_plugin_cb_start(unsigned fro= m, unsigned type, =20 static inline void tcg_gen_plugin_cb_end(void) { - tcg_emit_op(INDEX_op_plugin_cb_end); + tcg_emit_op(INDEX_op_plugin_cb_end, 0); } =20 #if TARGET_LONG_BITS =3D=3D 32 diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 8bcd60d0ed..d430ea10c8 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -38,20 +38,6 @@ /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 =20 -#if HOST_LONG_BITS =3D=3D 32 -#define MAX_OPC_PARAM_PER_ARG 2 -#else -#define MAX_OPC_PARAM_PER_ARG 1 -#endif -#define MAX_OPC_PARAM_IARGS 7 -#define MAX_OPC_PARAM_OARGS 1 -#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) - -/* A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N =3D number of input arguments + output arguments). */ -#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) - #define CPU_TEMP_BUF_NLONGS 128 #define TCG_STATIC_FRAME_SIZE (CPU_TEMP_BUF_NLONGS * sizeof(long)) =20 @@ -493,34 +479,34 @@ typedef struct TCGTempSet { unsigned long l[BITS_TO_LONGS(TCG_MAX_TEMPS)]; } TCGTempSet; =20 -/* While we limit helpers to 6 arguments, for 32-bit hosts, with padding, - this imples a max of 6*2 (64-bit in) + 2 (64-bit out) =3D 14 operands. - There are never more than 2 outputs, which means that we can store all - dead + sync data within 16 bits. */ -#define DEAD_ARG 4 -#define SYNC_ARG 1 -typedef uint16_t TCGLifeData; +/* + * With 1 128-bit output, a 32-bit host requires 4 output parameters, + * which leaves a maximum of 28 other slots. Which is enough for 7 + * 128-bit operands. + */ +#define DEAD_ARG (1 << 4) +#define SYNC_ARG (1 << 0) +typedef uint32_t TCGLifeData; =20 -/* The layout here is designed to avoid a bitfield crossing of - a 32-bit boundary, which would cause GCC to add extra padding. */ typedef struct TCGOp { - TCGOpcode opc : 8; /* 8 */ + TCGOpcode opc : 8; + unsigned nargs : 8; =20 /* Parameters for this opcode. See below. */ - unsigned param1 : 4; /* 12 */ - unsigned param2 : 4; /* 16 */ + unsigned param1 : 8; + unsigned param2 : 8; =20 /* Lifetime data of the operands. */ - unsigned life : 16; /* 32 */ + TCGLifeData life; =20 /* Next and previous opcodes. */ QTAILQ_ENTRY(TCGOp) link; =20 - /* Arguments for the opcode. */ - TCGArg args[MAX_OPC_PARAM]; - /* Register preferences for the output(s). */ TCGRegSet output_pref[2]; + + /* Arguments for the opcode. */ + TCGArg args[]; } TCGOp; =20 #define TCGOP_CALLI(X) (X)->param1 @@ -1014,10 +1000,12 @@ bool tcg_op_supported(TCGOpcode op); =20 void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args); =20 -TCGOp *tcg_emit_op(TCGOpcode opc); +TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs); void tcg_op_remove(TCGContext *s, TCGOp *op); -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc); -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc); +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, + TCGOpcode opc, unsigned nargs); +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, + TCGOpcode opc, unsigned nargs); =20 /** * tcg_remove_ops_after: diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index a6aaacd053..c7d6514840 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -258,10 +258,13 @@ static TCGOp *rm_ops(TCGOp *op) =20 static TCGOp *copy_op_nocheck(TCGOp **begin_op, TCGOp *op) { - *begin_op =3D QTAILQ_NEXT(*begin_op, link); - tcg_debug_assert(*begin_op); - op =3D tcg_op_insert_after(tcg_ctx, op, (*begin_op)->opc); - memcpy(op->args, (*begin_op)->args, sizeof(op->args)); + TCGOp *old_op =3D QTAILQ_NEXT(*begin_op, link); + unsigned nargs =3D old_op->nargs; + + *begin_op =3D old_op; + op =3D tcg_op_insert_after(tcg_ctx, op, old_op->opc, nargs); + memcpy(op->args, old_op->args, sizeof(op->args[0]) * nargs); + return op; } =20 diff --git a/tcg/optimize.c b/tcg/optimize.c index ae081ab29c..1afd50175b 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -962,7 +962,7 @@ static bool fold_addsub2(OptContext *ctx, TCGOp *op, bo= ol add) rh =3D op->args[1]; =20 /* The proper opcode is supplied by tcg_opt_gen_mov. */ - op2 =3D tcg_op_insert_before(ctx->tcg, op, 0); + op2 =3D tcg_op_insert_before(ctx->tcg, op, 0, 2); =20 tcg_opt_gen_movi(ctx, op, rl, al); tcg_opt_gen_movi(ctx, op2, rh, ah); @@ -1613,7 +1613,7 @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op) rh =3D op->args[1]; =20 /* The proper opcode is supplied by tcg_opt_gen_mov. */ - op2 =3D tcg_op_insert_before(ctx->tcg, op, 0); + op2 =3D tcg_op_insert_before(ctx->tcg, op, 0, 2); =20 tcg_opt_gen_movi(ctx, op, rl, l); tcg_opt_gen_movi(ctx, op2, rh, h); diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 5bf100ea7d..966d41d65a 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -152,7 +152,7 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list, =20 void vec_gen_2(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGAr= g a) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 2); TCGOP_VECL(op) =3D type - TCG_TYPE_V64; TCGOP_VECE(op) =3D vece; op->args[0] =3D r; @@ -162,7 +162,7 @@ void vec_gen_2(TCGOpcode opc, TCGType type, unsigned ve= ce, TCGArg r, TCGArg a) void vec_gen_3(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a, TCGArg b) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 3); TCGOP_VECL(op) =3D type - TCG_TYPE_V64; TCGOP_VECE(op) =3D vece; op->args[0] =3D r; @@ -173,7 +173,7 @@ void vec_gen_3(TCGOpcode opc, TCGType type, unsigned ve= ce, void vec_gen_4(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a, TCGArg b, TCGArg c) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 4); TCGOP_VECL(op) =3D type - TCG_TYPE_V64; TCGOP_VECE(op) =3D vece; op->args[0] =3D r; @@ -185,7 +185,7 @@ void vec_gen_4(TCGOpcode opc, TCGType type, unsigned ve= ce, static void vec_gen_6(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a, TCGArg b, TCGArg c, TCGArg d, TCGArg e) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 6); TCGOP_VECL(op) =3D type - TCG_TYPE_V64; TCGOP_VECE(op) =3D vece; op->args[0] =3D r; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 6168327030..cd1cd4e736 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -33,20 +33,20 @@ =20 void tcg_gen_op1(TCGOpcode opc, TCGArg a1) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 1); op->args[0] =3D a1; } =20 void tcg_gen_op2(TCGOpcode opc, TCGArg a1, TCGArg a2) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 2); op->args[0] =3D a1; op->args[1] =3D a2; } =20 void tcg_gen_op3(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 3); op->args[0] =3D a1; op->args[1] =3D a2; op->args[2] =3D a3; @@ -54,7 +54,7 @@ void tcg_gen_op3(TCGOpcode opc, TCGArg a1, TCGArg a2, TCG= Arg a3) =20 void tcg_gen_op4(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 4); op->args[0] =3D a1; op->args[1] =3D a2; op->args[2] =3D a3; @@ -64,7 +64,7 @@ void tcg_gen_op4(TCGOpcode opc, TCGArg a1, TCGArg a2, TCG= Arg a3, TCGArg a4) void tcg_gen_op5(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4, TCGArg a5) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 5); op->args[0] =3D a1; op->args[1] =3D a2; op->args[2] =3D a3; @@ -75,7 +75,7 @@ void tcg_gen_op5(TCGOpcode opc, TCGArg a1, TCGArg a2, TCG= Arg a3, void tcg_gen_op6(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4, TCGArg a5, TCGArg a6) { - TCGOp *op =3D tcg_emit_op(opc); + TCGOp *op =3D tcg_emit_op(opc, 6); op->args[0] =3D a1; op->args[1] =3D a2; op->args[2] =3D a3; diff --git a/tcg/tcg.c b/tcg/tcg.c index aae4046e1b..ccbe947222 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1479,7 +1479,7 @@ bool tcg_op_supported(TCGOpcode op) and endian swap in tcg_reg_alloc_call(). */ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) { - int i, real_args, nb_rets, pi; + int i, real_args, nb_rets, pi, max_args; unsigned typemask; const TCGHelperInfo *info; TCGOp *op; @@ -1513,7 +1513,13 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nar= gs, TCGTemp **args) } } =20 - op =3D tcg_emit_op(INDEX_op_call); + /* + * A Call op needs up to 4 + 2N parameters on 32-bit archs, + * and up to 4 + N parameters on 64-bit archs + * (N =3D number of input arguments + output arguments). + */ + max_args =3D (64 / TCG_TARGET_REG_BITS) * nargs + 4; + op =3D tcg_emit_op(INDEX_op_call, max_args); =20 pi =3D 0; if (ret !=3D NULL) { @@ -1590,7 +1596,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int narg= s, TCGTemp **args) =20 /* Make sure the fields didn't overflow. */ tcg_debug_assert(TCGOP_CALLI(op) =3D=3D real_args); - tcg_debug_assert(pi <=3D ARRAY_SIZE(op->args)); + tcg_debug_assert(pi <=3D max_args); =20 if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { for (i =3D 0; i < nargs; ++i) { @@ -2294,41 +2300,56 @@ void tcg_remove_ops_after(TCGOp *op) } } =20 -static TCGOp *tcg_op_alloc(TCGOpcode opc) +static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs) { TCGContext *s =3D tcg_ctx; - TCGOp *op; + TCGOp *op =3D NULL; =20 - if (likely(QTAILQ_EMPTY(&s->free_ops))) { - op =3D tcg_malloc(sizeof(TCGOp)); - } else { - op =3D QTAILQ_FIRST(&s->free_ops); - QTAILQ_REMOVE(&s->free_ops, op, link); + if (unlikely(!QTAILQ_EMPTY(&s->free_ops))) { + QTAILQ_FOREACH(op, &s->free_ops, link) { + if (nargs <=3D op->nargs) { + QTAILQ_REMOVE(&s->free_ops, op, link); + nargs =3D op->nargs; + goto found; + } + } } + + /* Most opcodes have 3 or 4 operands: reduce fragmentation. */ + nargs =3D MAX(4, nargs); + op =3D tcg_malloc(sizeof(TCGOp) + sizeof(TCGArg) * nargs); + + found: memset(op, 0, offsetof(TCGOp, link)); op->opc =3D opc; - s->nb_ops++; + op->nargs =3D nargs; =20 + /* Check for bitfield overflow. */ + tcg_debug_assert(op->nargs =3D=3D nargs); + + s->nb_ops++; return op; } =20 -TCGOp *tcg_emit_op(TCGOpcode opc) +TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs) { - TCGOp *op =3D tcg_op_alloc(opc); + TCGOp *op =3D tcg_op_alloc(opc, nargs); QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); return op; } =20 -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, TCGOpcode opc) +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, + TCGOpcode opc, unsigned nargs) { - TCGOp *new_op =3D tcg_op_alloc(opc); + TCGOp *new_op =3D tcg_op_alloc(opc, nargs); QTAILQ_INSERT_BEFORE(old_op, new_op, link); return new_op; } =20 -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, TCGOpcode opc) +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, + TCGOpcode opc, unsigned nargs) { - TCGOp *new_op =3D tcg_op_alloc(opc); + TCGOp *new_op =3D tcg_op_alloc(opc, nargs); QTAILQ_INSERT_AFTER(&s->ops, old_op, new_op, link); return new_op; } @@ -2937,7 +2958,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode lopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 ? INDEX_op_ld_i32 : INDEX_op_ld_i64); - TCGOp *lop =3D tcg_op_insert_before(s, op, lopc); + TCGOp *lop =3D tcg_op_insert_before(s, op, lopc, 3); =20 lop->args[0] =3D temp_arg(dir_ts); lop->args[1] =3D temp_arg(arg_ts->mem_base); @@ -3003,7 +3024,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode sopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); - TCGOp *sop =3D tcg_op_insert_after(s, op, sopc); + TCGOp *sop =3D tcg_op_insert_after(s, op, sopc, 3); TCGTemp *out_ts =3D dir_ts; =20 if (IS_DEAD_ARG(0)) { @@ -3039,7 +3060,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode sopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); - TCGOp *sop =3D tcg_op_insert_after(s, op, sopc); + TCGOp *sop =3D tcg_op_insert_after(s, op, sopc, 3); =20 sop->args[0] =3D temp_arg(dir_ts); sop->args[1] =3D temp_arg(arg_ts->mem_base); --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967450; cv=none; d=zohomail.com; s=zohoarc; b=CRpV0jJkzU0+e4pGWSqBztNx+9S9Z8+qZF3dWW/oayN+sLJt1O7iM3JL3iUpU3XzBQUSIzhUCDru/95QD/8bMIwohyW2Hprl1gnpzNRg4rvEq0qvRahe9C7n+7Muyi/N/UlmW/AEFo9ghuBUdsX5D4YmkgcEXqn5Fv/uc28FttU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967450; 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=HrfsNyGJ4cFlPj1QXpR5FkACHHSum2rmLa4iU9J/XqE=; b=XrbysHRPK9YNwcA7xSqDZggczZkYU3R2rJt5Ig9WiqaRPl6f+w9cI1jlr6I+bvrfZuK3iBZFdaiJaSo4OKlgx25AfX7+kTYyql2nNtGHjK4Pv8pDJKM1lMVGERttxEJJZsCxoOI7RKHs/aQK00mcwFoWHhP0tDlrDLNX859lyLg= 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 167096745066544.667413938764525; Tue, 13 Dec 2022 13:37:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmy-0000i6-BY; Tue, 13 Dec 2022 16:26:12 -0500 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 1p5Cmv-0000gi-JO for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:10 -0500 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmt-0003HS-JB for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:09 -0500 Received: by mail-oi1-x233.google.com with SMTP id k189so1036419oif.7 for ; Tue, 13 Dec 2022 13:26:06 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=HrfsNyGJ4cFlPj1QXpR5FkACHHSum2rmLa4iU9J/XqE=; b=gT5v+iVW9Fn1RXwKCtUHljwXk8vzEiKklrXDRW79V5U4duuAxkbmHivJGvar2wKgK/ FIkd6CcsJHmlqi0o8OcPwtE+C0a1V1Q9E0WQZsf9ImCWHiW+2MJ5IMk9rXbb7VCS+/j3 R5VkwLnZXnVPb6V/SK/DFS27xZL7NmHmjm0px7c8CVCXPA9mANCarYWx69s6zsb7xRTW 45rqZ6txKvKZAXxtKVnkP0Cc9RYWJT6Y4lyNJQpwgcVv4lEVmDque3ta5M67fNKlAqrn BMGJWEqNeIlI4swZqmpR/lhalZGI+2HKU3OQJUMFCVZNQX5Libe5JmR9WVFiRv4zKPVb 2T4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=HrfsNyGJ4cFlPj1QXpR5FkACHHSum2rmLa4iU9J/XqE=; b=o8hBfIudfCRSi+KfH+zlXvMcaOBh3O0lX1N9cdqkSxP6+i/50SsUMAQcKD4gCE9Lvw +GeYhpZLyc+aongXKDVo+9t77vTlyp1xDKLPSfH+xN289sGxrKnFkHqyRVzCo7MTc+/4 PLI3ScZkLhlBaR009mjF+0JXreGLmgUHe7otn8GNv9XRRQDPbaWxXgRCa1NwzhL55uDS eGFg9ErfDLq5V8HjKNF0YbkbC5toGjsOitoCSjoKXmnQqgYsURkD2waf/q8IkZ2ab7Wx ivuK+jF3tHhUoTYsD3Xbjl09gY150x/K1RUQCc/W21xC1dLRup4DDwIyRUm97gdWguX5 Zm6w== X-Gm-Message-State: ANoB5pkOCW1k2WxqKXSiAoD8NqX3s5jEObfvVt/AIcayXU/F6I7mwTT/ GWpH+x4RQK1aLiTZ2CQ5RSHqWbh8t96YE3L3KpU= X-Google-Smtp-Source: AA0mqf4X/zSGsmAXbdxDGaodszVgO9YZ3v49Qcu9NJDmD/yhNLEpV3pA9fKUecu2eyyCHOYzfd1MUA== X-Received: by 2002:a54:440a:0:b0:35c:84f:7357 with SMTP id k10-20020a54440a000000b0035c084f7357mr10781756oiw.37.1670966765521; Tue, 13 Dec 2022 13:26:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 21/27] tcg: Use output_pref wrapper function Date: Tue, 13 Dec 2022 15:25:35 -0600 Message-Id: <20221213212541.1820840-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::233; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967451319100001 We will shortly have the possibility of more that two outputs, though only for calls (for which preferences are moot). Avoid direct references to op->output_pref[] when possible. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 5 +++++ tcg/tcg.c | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d430ea10c8..a6310b898f 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -518,6 +518,11 @@ typedef struct TCGOp { /* Make sure operands fit in the bitfields above. */ QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8)); =20 +static inline TCGRegSet output_pref(const TCGOp *op, unsigned i) +{ + return i < ARRAY_SIZE(op->output_pref) ? op->output_pref[i] : 0; +} + typedef struct TCGProfile { int64_t cpu_exec_time; int64_t tb_count1; diff --git a/tcg/tcg.c b/tcg/tcg.c index ccbe947222..d08323db49 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1966,7 +1966,7 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool= have_prefs) =20 if (have_prefs) { for (i =3D 0; i < nb_oargs; ++i) { - TCGRegSet set =3D op->output_pref[i]; + TCGRegSet set =3D output_pref(op, i); =20 if (i =3D=3D 0) { ne_fprintf(f, " pref=3D"); @@ -2636,11 +2636,11 @@ static void liveness_pass_1(TCGContext *s) } ts->state =3D TS_DEAD; la_reset_pref(ts); - - /* Not used -- it will be tcg_target_call_oarg_regs[i]= . */ - op->output_pref[i] =3D 0; } =20 + /* Not used -- it will be tcg_target_call_oarg_reg(). */ + memset(op->output_pref, 0, sizeof(op->output_pref)); + if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | TCG_CALL_NO_READ_GLOBALS))) { la_global_kill(s, nb_globals); @@ -2802,7 +2802,9 @@ static void liveness_pass_1(TCGContext *s) ts =3D arg_temp(op->args[i]); =20 /* Remember the preference of the uses that followed. */ - op->output_pref[i] =3D *la_temp_pref(ts); + if (i < ARRAY_SIZE(op->output_pref)) { + op->output_pref[i] =3D *la_temp_pref(ts); + } =20 /* Output args are dead. */ if (ts->state & TS_DEAD) { @@ -2872,7 +2874,7 @@ static void liveness_pass_1(TCGContext *s) =20 set &=3D ct->regs; if (ct->ialias) { - set &=3D op->output_pref[ct->alias_index]; + set &=3D output_pref(op, ct->alias_index); } /* If the combination is not possible, restart. */ if (set =3D=3D 0) { @@ -3539,7 +3541,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *op) TCGReg oreg, ireg; =20 allocated_regs =3D s->reserved_regs; - preferred_regs =3D op->output_pref[0]; + preferred_regs =3D output_pref(op, 0); ots =3D arg_temp(op->args[0]); ts =3D arg_temp(op->args[1]); =20 @@ -3656,7 +3658,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *op) if (IS_DEAD_ARG(1)) { temp_dead(s, its); } - tcg_reg_alloc_do_movi(s, ots, val, arg_life, op->output_pref[0]); + tcg_reg_alloc_do_movi(s, ots, val, arg_life, output_pref(op, 0)); return; } =20 @@ -3673,7 +3675,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *op) tcg_regset_set_reg(allocated_regs, its->reg); } oreg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); + output_pref(op, 0), ots->indirect_base); set_temp_val_reg(s, ots, oreg); } =20 @@ -3792,7 +3794,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) switch (arg_ct->pair) { case 0: /* not paired */ if (arg_ct->ialias) { - i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + i_preferred_regs =3D output_pref(op, arg_ct->alias_index); =20 /* * If the input is not dead after the instruction, @@ -3839,7 +3841,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) * and to identify a few cases where it's not required. */ if (arg_ct->ialias) { - i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + i_preferred_regs =3D output_pref(op, arg_ct->alias_index); if (IS_DEAD_ARG(i1) && IS_DEAD_ARG(i2) && ts->val_type =3D=3D TEMP_VAL_REG && @@ -3873,7 +3875,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) =20 case 3: /* ialias with second output, no first input */ tcg_debug_assert(arg_ct->ialias); - i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + i_preferred_regs =3D output_pref(op, arg_ct->alias_index); =20 if (IS_DEAD_ARG(i) && ts->val_type =3D=3D TEMP_VAL_REG && @@ -3993,10 +3995,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const T= CGOp *op) } else if (arg_ct->newreg) { reg =3D tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs | o_allocated_reg= s, - op->output_pref[k], ts->indirect_b= ase); + output_pref(op, k), ts->indirect_b= ase); } else { reg =3D tcg_reg_alloc(s, arg_ct->regs, o_allocated_reg= s, - op->output_pref[k], ts->indirect_b= ase); + output_pref(op, k), ts->indirect_b= ase); } break; =20 @@ -4007,7 +4009,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) break; } reg =3D tcg_reg_alloc_pair(s, arg_ct->regs, o_allocated_re= gs, - op->output_pref[k], ts->indirect_= base); + output_pref(op, k), ts->indirect_= base); break; =20 case 2: /* second of pair */ @@ -4090,7 +4092,7 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const T= CGOp *op) } =20 oreg =3D tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); + output_pref(op, 0), ots->indirect_base); set_temp_val_reg(s, ots, oreg); } =20 --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967053; cv=none; d=zohomail.com; s=zohoarc; b=VDDe04G4JzT99cSD8gwn9PeyqlB5ujA5u8Pu1hEj7DYY0VA5w3V8g5TRVUGSkg7kdFDGdAwYEWe0vQU1zRYZEujATCVQqZUhk+V6de6x70Qx/hEd7VmE8csqryR7+Uy0BiwhS63/CP3LXv7yRDdvUhyGIbTS3wGwLHIt2DkDCbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967053; h=Content-Transfer-Encoding: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=P90EeKH4/pTjIHbulrXvG19OO1n2b3uUvSh0tREkpus=; b=hEqQiWR+bgT7gKvPKW07fGF3YmXYNaQLrdl/AhRx2E3I52DfrBZH2IMUE9p8g38FpmaFFoYCAXL0TArsgP4yd05NRUIu+LXt55sirxVu104aoHTkQqlk0PiMhJh0djqvO5OpJp3nc9tEMSa7Mn/J0c3m0gPpZCe/LCDesFBL71g= 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 1670967053648741.9529354567012; Tue, 13 Dec 2022 13:30:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cn1-0000jv-T3; Tue, 13 Dec 2022 16:26:15 -0500 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 1p5Cmy-0000i1-8I for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:12 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmt-0003CR-SX for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:11 -0500 Received: by mail-oi1-x234.google.com with SMTP id m204so1038431oib.6 for ; Tue, 13 Dec 2022 13:26:07 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=P90EeKH4/pTjIHbulrXvG19OO1n2b3uUvSh0tREkpus=; b=fsHGpTAnYEYu+SJ9gR20KnxizcKh/0BoVLiaYjNazDfveduPSCeZntaCPtgvM7uNS6 TV2dFvVvGYj4CCqU/QbEQtU3qN0yn07Q72BzPGsU6kNZWyu7g0ybeec1CbXDGcG/VxJm lJCmvZ3moJIOqYtzzSjpKmyON+wC4cjBfP3rCtmWLA1Yy9w4mJOFKJqMa9elcRpwRxVS qGMPky8/v+GvMWyXIjBPu8DhAope+1sgAzHkhHWDADLewu+Id90yvCKzEtWfd3R0XAPv 66WORHIZf0PJjVreW95F5Uy32jAIISv4s90tSpVszMmYEFQX09Q2skI/7VsXGvYVyWls db2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P90EeKH4/pTjIHbulrXvG19OO1n2b3uUvSh0tREkpus=; b=5JhEPXObus0ABmKMFZflEmdUdkgPIx0Dfk16G9dx/pV0l/R8XrvwZptkG4m51+0+LR AF7FnixW3qn7vE3v+nUeHqD14ILdhvsM4u93m3ClccbfJ+zjQIZUxztfgLeOI+JJm2+N aCK+0zV838SOnaTgLmtSiU+5N5MaBhVv4fRtwimF3yZhFqo0GQ0J89BoTMOLyu0Y+fB/ cfbhzgg0EmC702/Kvg1koILaCESlB5SMSas9eafzfOHu3p/xEdaR+kv7WBcJNJ68rveI CH7ucQnTtstLbnZIOmhvbRQj0AO0SeKdnM5+NK3GjaD7nNGXX/1uh5XdGA5EsI4y3THK zsuQ== X-Gm-Message-State: ANoB5pkcNQVpin4GVIVMQdH4fIOZYNUh0dKaAPy4jjzWmj2D+jW55Bmg GN0jydZK59vOdKwwCdJLzrqJK+DQnS7Vn+4a37E= X-Google-Smtp-Source: AA0mqf5EGnuEHVcbx+TRKVJkFPhDQjTUl2VDphRztZhuXNMenRaQuswudaxX5cjT6zqg3cDKmkQO6Q== X-Received: by 2002:a05:6808:30a2:b0:35e:a90b:6289 with SMTP id bl34-20020a05680830a200b0035ea90b6289mr3206898oib.15.1670966766618; Tue, 13 Dec 2022 13:26:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 22/27] tcg: Reorg function calls Date: Tue, 13 Dec 2022 15:25:36 -0600 Message-Id: <20221213212541.1820840-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967054137100001 Content-Type: text/plain; charset="utf-8" Pre-compute the function call layout for each helper at startup. Drop TCG_CALL_DUMMY_ARG, as we no longer need to leave gaps in the op->args[] array. This allows several places to stop checking for NULL TCGTemp, to which TCG_CALL_DUMMY_ARG mapped. For tcg_gen_callN, loop over the arguments once. Allocate the TCGOp for the call early but delay emitting it, collecting arguments first. This allows the argument processing loop to emit code for extensions and have them sequenced before the call. For tcg_reg_alloc_call, loop over the arguments in reverse order, which allows stack slots to be filled first naturally. Signed-off-by: Richard Henderson --- include/exec/helper-head.h | 2 + include/tcg/tcg.h | 5 +- tcg/tcg-internal.h | 22 +- tcg/optimize.c | 6 +- tcg/tcg.c | 609 ++++++++++++++++++++++--------------- 5 files changed, 394 insertions(+), 250 deletions(-) diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index 8bdf0f6ea2..bc6698b19f 100644 --- a/include/exec/helper-head.h +++ b/include/exec/helper-head.h @@ -133,4 +133,6 @@ #define DEF_HELPER_7(name, ret, t1, t2, t3, t4, t5, t6, t7) \ DEF_HELPER_FLAGS_7(name, 0, ret, t1, t2, t3, t4, t5, t6, t7) =20 +/* MAX_CALL_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */ + #endif /* EXEC_HELPER_HEAD_H */ diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index a6310b898f..b949d75fdd 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -38,6 +38,8 @@ /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 =20 +#define MAX_CALL_IARGS 7 + #define CPU_TEMP_BUF_NLONGS 128 #define TCG_STATIC_FRAME_SIZE (CPU_TEMP_BUF_NLONGS * sizeof(long)) =20 @@ -411,9 +413,6 @@ typedef TCGv_ptr TCGv_env; #define TCG_CALL_NO_RWG_SE (TCG_CALL_NO_RWG | TCG_CALL_NO_SE) #define TCG_CALL_NO_WG_SE (TCG_CALL_NO_WG | TCG_CALL_NO_SE) =20 -/* Used to align parameters. See the comment before tcgv_i32_temp. */ -#define TCG_CALL_DUMMY_ARG ((TCGArg)0) - /* * Flags for the bswap opcodes. * If IZ, the input is zero-extended, otherwise unknown. diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index f574743ff8..c7e87e193d 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -42,11 +42,29 @@ typedef enum { TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */ } TCGCallArgumentKind; =20 +typedef struct TCGCallArgumentLoc { + TCGCallArgumentKind kind : 8; + unsigned arg_slot : 8; + unsigned ref_slot : 8; + unsigned arg_idx : 4; + unsigned tmp_subindex : 2; +} TCGCallArgumentLoc; + +/* Avoid "unsigned < 0 is always false" Werror, when iarg_regs is empty. */ +#define REG_P(L) \ + ((int)(L)->arg_slot < (int)ARRAY_SIZE(tcg_target_call_iarg_regs)) + typedef struct TCGHelperInfo { void *func; const char *name; - unsigned flags; - unsigned typemask; + unsigned typemask : 32; + unsigned flags : 8; + unsigned nr_in : 8; + unsigned nr_out : 8; + TCGCallReturnKind out_kind : 8; + + /* Maximum physical arguments are constrained by TCG_TYPE_I128. */ + TCGCallArgumentLoc in[MAX_CALL_IARGS * (128 / TCG_TARGET_REG_BITS)]; } TCGHelperInfo; =20 extern TCGContext tcg_init_ctx; diff --git a/tcg/optimize.c b/tcg/optimize.c index 1afd50175b..763bca9ea6 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -667,9 +667,7 @@ static void init_arguments(OptContext *ctx, TCGOp *op, = int nb_args) { for (int i =3D 0; i < nb_args; i++) { TCGTemp *ts =3D arg_temp(op->args[i]); - if (ts) { - init_ts_info(ctx, ts); - } + init_ts_info(ctx, ts); } } =20 @@ -680,7 +678,7 @@ static void copy_propagate(OptContext *ctx, TCGOp *op, =20 for (int i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { TCGTemp *ts =3D arg_temp(op->args[i]); - if (ts && ts_is_copy(ts)) { + if (ts_is_copy(ts)) { op->args[i] =3D temp_arg(find_better_copy(s, ts)); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index d08323db49..74f7491d73 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -547,7 +547,7 @@ void tcg_pool_reset(TCGContext *s) =20 #include "exec/helper-proto.h" =20 -static const TCGHelperInfo all_helpers[] =3D { +static TCGHelperInfo all_helpers[] =3D { #include "exec/helper-tcg.h" }; static GHashTable *helper_table; @@ -565,6 +565,154 @@ static ffi_type * const typecode_to_ffi[8] =3D { }; #endif =20 +typedef struct TCGCumulativeArgs { + int arg_idx; /* tcg_gen_callN args[] */ + int info_in_idx; /* TCGHelperInfo in[] */ + int arg_slot; /* regs+stack slot */ + int ref_slot; /* stack slots for references */ +} TCGCumulativeArgs; + +static void layout_arg_even(TCGCumulativeArgs *cum) +{ + cum->arg_slot +=3D cum->arg_slot & 1; +} + +static void layout_arg_1(TCGCumulativeArgs *cum, TCGHelperInfo *info, + TCGCallArgumentKind kind) +{ + TCGCallArgumentLoc *loc =3D &info->in[cum->info_in_idx]; + + *loc =3D (TCGCallArgumentLoc){ + .kind =3D kind, + .arg_idx =3D cum->arg_idx, + .arg_slot =3D cum->arg_slot, + }; + cum->info_in_idx++; + cum->arg_slot++; +} + +static void layout_arg_normal_n(TCGCumulativeArgs *cum, + TCGHelperInfo *info, int n) +{ + TCGCallArgumentLoc *loc =3D &info->in[cum->info_in_idx]; + + for (int i =3D 0; i < n; ++i) { + /* Layout all using the same arg_idx, adjusting the subindex. */ + loc[i] =3D (TCGCallArgumentLoc){ + .kind =3D TCG_CALL_ARG_NORMAL, + .arg_idx =3D cum->arg_idx, + .tmp_subindex =3D i, + .arg_slot =3D cum->arg_slot + i, + }; + } + cum->info_in_idx +=3D n; + cum->arg_slot +=3D n; +} + +static void init_call_layout(TCGHelperInfo *info) +{ + int max_reg_slots =3D ARRAY_SIZE(tcg_target_call_iarg_regs); + int max_stk_slots =3D TCG_STATIC_CALL_ARGS_SIZE / sizeof(tcg_target_lo= ng); + unsigned typemask =3D info->typemask; + unsigned typecode; + TCGCumulativeArgs cum =3D { }; + + /* + * Parse and place any function return value. + */ + typecode =3D typemask & 7; + switch (typecode) { + case dh_typecode_void: + info->nr_out =3D 0; + break; + case dh_typecode_i32: + case dh_typecode_s32: + case dh_typecode_ptr: + info->nr_out =3D 1; + info->out_kind =3D TCG_CALL_RET_NORMAL; + break; + case dh_typecode_i64: + case dh_typecode_s64: + info->nr_out =3D 64 / TCG_TARGET_REG_BITS; + info->out_kind =3D TCG_CALL_RET_NORMAL; + break; + default: + g_assert_not_reached(); + } + assert(info->nr_out <=3D ARRAY_SIZE(tcg_target_call_oarg_regs)); + + /* + * Parse and place function arguments. + */ + for (typemask >>=3D 3; typemask; typemask >>=3D 3, cum.arg_idx++) { + TCGCallArgumentKind kind; + TCGType type; + + typecode =3D typemask & 7; + switch (typecode) { + case dh_typecode_i32: + case dh_typecode_s32: + type =3D TCG_TYPE_I32; + break; + case dh_typecode_i64: + case dh_typecode_s64: + type =3D TCG_TYPE_I64; + break; + case dh_typecode_ptr: + type =3D TCG_TYPE_PTR; + break; + default: + g_assert_not_reached(); + } + + switch (type) { + case TCG_TYPE_I32: + switch (TCG_TARGET_CALL_ARG_I32) { + case TCG_CALL_ARG_EVEN: + layout_arg_even(&cum); + /* fall through */ + case TCG_CALL_ARG_NORMAL: + layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); + break; + case TCG_CALL_ARG_EXTEND: + kind =3D TCG_CALL_ARG_EXTEND_U + (typecode & 1); + layout_arg_1(&cum, info, kind); + break; + default: + qemu_build_not_reached(); + } + break; + + case TCG_TYPE_I64: + switch (TCG_TARGET_CALL_ARG_I64) { + case TCG_CALL_ARG_EVEN: + layout_arg_even(&cum); + /* fall through */ + case TCG_CALL_ARG_NORMAL: + if (TCG_TARGET_REG_BITS =3D=3D 32) { + layout_arg_normal_n(&cum, info, 2); + } else { + layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); + } + break; + default: + qemu_build_not_reached(); + } + break; + + default: + g_assert_not_reached(); + } + } + info->nr_in =3D cum.info_in_idx; + + /* Validate that we didn't overrun the input array. */ + assert(cum.info_in_idx <=3D ARRAY_SIZE(info->in)); + /* Validate the backend has enough argument space. */ + assert(cum.arg_slot <=3D max_reg_slots + max_stk_slots); + assert(cum.ref_slot <=3D max_stk_slots); +} + static int indirect_reg_alloc_order[ARRAY_SIZE(tcg_target_reg_alloc_order)= ]; static void process_op_defs(TCGContext *s); static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type, @@ -604,6 +752,7 @@ static void tcg_context_init(unsigned max_cpus) helper_table =3D g_hash_table_new(NULL, NULL); =20 for (i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { + init_call_layout(&all_helpers[i]); g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func, (gpointer)&all_helpers[i]); } @@ -1474,18 +1623,19 @@ bool tcg_op_supported(TCGOpcode op) } } =20 -/* Note: we convert the 64 bit args to 32 bit and do some alignment - and endian swap. Maybe it would be better to do the alignment - and endian swap in tcg_reg_alloc_call(). */ +static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs); + void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) { - int i, real_args, nb_rets, pi, max_args; - unsigned typemask; const TCGHelperInfo *info; + TCGv_i64 extend_free[MAX_CALL_IARGS]; + int n_extend =3D 0; TCGOp *op; + int i, n, pi =3D 0, total_args; =20 info =3D g_hash_table_lookup(helper_table, (gpointer)func); - typemask =3D info->typemask; + total_args =3D info->nr_out + info->nr_in + 2; + op =3D tcg_op_alloc(INDEX_op_call, total_args); =20 #ifdef CONFIG_PLUGIN /* detect non-plugin helpers */ @@ -1494,119 +1644,65 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int n= args, TCGTemp **args) } #endif =20 - if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; - bool is_signed =3D argtype & 1; + TCGOP_CALLO(op) =3D n =3D info->nr_out; + switch (n) { + case 0: + tcg_debug_assert(ret =3D=3D NULL); + break; + case 1: + tcg_debug_assert(ret !=3D NULL); + op->args[pi++] =3D temp_arg(ret); + break; + case 2: + tcg_debug_assert(ret !=3D NULL); + tcg_debug_assert(ret->base_type =3D=3D ret->type + 1); + tcg_debug_assert(ret->temp_subindex =3D=3D 0); + op->args[pi++] =3D temp_arg(ret); + op->args[pi++] =3D temp_arg(ret + 1); + break; + default: + g_assert_not_reached(); + } =20 - if (is_32bit) { + TCGOP_CALLI(op) =3D n =3D info->nr_in; + for (i =3D 0; i < n; i++) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + TCGTemp *ts =3D args[loc->arg_idx] + loc->tmp_subindex; + + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + op->args[pi++] =3D temp_arg(ts); + break; + + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + { TCGv_i64 temp =3D tcg_temp_new_i64(); - TCGv_i32 orig =3D temp_tcgv_i32(args[i]); - if (is_signed) { + TCGv_i32 orig =3D temp_tcgv_i32(ts); + + if (loc->kind =3D=3D TCG_CALL_ARG_EXTEND_S) { tcg_gen_ext_i32_i64(temp, orig); } else { tcg_gen_extu_i32_i64(temp, orig); } - args[i] =3D tcgv_i64_temp(temp); + op->args[pi++] =3D tcgv_i64_arg(temp); + extend_free[n_extend++] =3D temp; } - } - } - - /* - * A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N =3D number of input arguments + output arguments). - */ - max_args =3D (64 / TCG_TARGET_REG_BITS) * nargs + 4; - op =3D tcg_emit_op(INDEX_op_call, max_args); - - pi =3D 0; - if (ret !=3D NULL) { - if (TCG_TARGET_REG_BITS < 64 && (typemask & 6) =3D=3D dh_typecode_= i64) { - op->args[pi++] =3D temp_arg(ret); - op->args[pi++] =3D temp_arg(ret + 1); - nb_rets =3D 2; - } else { - op->args[pi++] =3D temp_arg(ret); - nb_rets =3D 1; - } - } else { - nb_rets =3D 0; - } - TCGOP_CALLO(op) =3D nb_rets; - - real_args =3D 0; - for (i =3D 0; i < nargs; i++) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - TCGCallArgumentKind kind; - TCGType type; - - switch (argtype) { - case dh_typecode_i32: - case dh_typecode_s32: - type =3D TCG_TYPE_I32; break; - case dh_typecode_i64: - case dh_typecode_s64: - type =3D TCG_TYPE_I64; - break; - case dh_typecode_ptr: - type =3D TCG_TYPE_PTR; - break; - default: - g_assert_not_reached(); - } =20 - switch (type) { - case TCG_TYPE_I32: - kind =3D TCG_TARGET_CALL_ARG_I32; - break; - case TCG_TYPE_I64: - kind =3D TCG_TARGET_CALL_ARG_I64; - break; - default: - g_assert_not_reached(); - } - - switch (kind) { - case TCG_CALL_ARG_EVEN: - if (real_args & 1) { - op->args[pi++] =3D TCG_CALL_DUMMY_ARG; - real_args++; - } - /* fall through */ - case TCG_CALL_ARG_NORMAL: - if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64)= { - op->args[pi++] =3D temp_arg(args[i]); - op->args[pi++] =3D temp_arg(args[i] + 1); - real_args +=3D 2; - break; - } - op->args[pi++] =3D temp_arg(args[i]); - real_args++; - break; default: g_assert_not_reached(); } } op->args[pi++] =3D (uintptr_t)func; op->args[pi++] =3D (uintptr_t)info; - TCGOP_CALLI(op) =3D real_args; + tcg_debug_assert(pi =3D=3D total_args); =20 - /* Make sure the fields didn't overflow. */ - tcg_debug_assert(TCGOP_CALLI(op) =3D=3D real_args); - tcg_debug_assert(pi <=3D max_args); + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); =20 - if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; - - if (is_32bit) { - tcg_temp_free_internal(args[i]); - } - } + tcg_debug_assert(n_extend < ARRAY_SIZE(extend_free)); + for (i =3D 0; i < n_extend; ++i) { + tcg_temp_free_i64(extend_free[i]); } } =20 @@ -1822,10 +1918,7 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, boo= l have_prefs) } for (i =3D 0; i < nb_iargs; i++) { TCGArg arg =3D op->args[nb_oargs + i]; - const char *t =3D ""; - if (arg !=3D TCG_CALL_DUMMY_ARG) { - t =3D tcg_get_arg_str(s, buf, sizeof(buf), arg); - } + const char *t =3D tcg_get_arg_str(s, buf, sizeof(buf), arg= ); col +=3D ne_fprintf(f, ",%s", t); } } else { @@ -2606,12 +2699,11 @@ static void liveness_pass_1(TCGContext *s) switch (opc) { case INDEX_op_call: { - int call_flags; - int nb_call_regs; + const TCGHelperInfo *info =3D tcg_call_info(op); + int call_flags =3D tcg_call_flags(op); =20 nb_oargs =3D TCGOP_CALLO(op); nb_iargs =3D TCGOP_CALLI(op); - call_flags =3D tcg_call_flags(op); =20 /* pure functions can be removed if their result is unused= */ if (call_flags & TCG_CALL_NO_SIDE_EFFECTS) { @@ -2651,7 +2743,7 @@ static void liveness_pass_1(TCGContext *s) /* Record arguments that die in this helper. */ for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { ts =3D arg_temp(op->args[i]); - if (ts && ts->state & TS_DEAD) { + if (ts->state & TS_DEAD) { arg_life |=3D DEAD_ARG << i; } } @@ -2659,31 +2751,59 @@ static void liveness_pass_1(TCGContext *s) /* For all live registers, remove call-clobbered prefs. */ la_cross_call(s, nb_temps); =20 - nb_call_regs =3D ARRAY_SIZE(tcg_target_call_iarg_regs); + /* + * Input arguments are live for preceding opcodes. + * + * For those arguments that die, and will be allocated in + * registers, clear the register set for that arg, to be + * filled in below. For args that will be on the stack, + * reset to any available reg. Process arguments in rever= se + * order so that if a temp is used more than once, the sta= ck + * reset to max happens before the register reset to 0. + */ + for (i =3D nb_iargs - 1; i >=3D 0; i--) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + ts =3D arg_temp(op->args[nb_oargs + i]); =20 - /* Input arguments are live for preceding opcodes. */ - for (i =3D 0; i < nb_iargs; i++) { - ts =3D arg_temp(op->args[i + nb_oargs]); - if (ts && ts->state & TS_DEAD) { - /* For those arguments that die, and will be alloc= ated - * in registers, clear the register set for that a= rg, - * to be filled in below. For args that will be on - * the stack, reset to any available reg. - */ - *la_temp_pref(ts) - =3D (i < nb_call_regs ? 0 : - tcg_target_available_regs[ts->type]); + if (ts->state & TS_DEAD) { + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + if (REG_P(loc)) { + *la_temp_pref(ts) =3D 0; + break; + } + /* fall through */ + default: + *la_temp_pref(ts) =3D + tcg_target_available_regs[ts->type]; + break; + } ts->state &=3D ~TS_DEAD; } } =20 - /* For each input argument, add its input register to pref= s. - If a temp is used once, this produces a single set bit.= */ - for (i =3D 0; i < MIN(nb_call_regs, nb_iargs); i++) { - ts =3D arg_temp(op->args[i + nb_oargs]); - if (ts) { - tcg_regset_set_reg(*la_temp_pref(ts), - tcg_target_call_iarg_regs[i]); + /* + * For each input argument, add its input register to pref= s. + * If a temp is used once, this produces a single set bit; + * if a temp is used multiple times, this produces a set. + */ + for (i =3D 0; i < nb_iargs; i++) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + ts =3D arg_temp(op->args[nb_oargs + i]); + + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + if (REG_P(loc)) { + tcg_regset_set_reg(*la_temp_pref(ts), + tcg_target_call_iarg_regs[loc->arg_slot]); + } + break; + default: + break; } } } @@ -2954,21 +3074,19 @@ static bool liveness_pass_2(TCGContext *s) /* Make sure that input arguments are available. */ for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_ts =3D arg_temp(op->args[i]); - if (arg_ts) { - dir_ts =3D arg_ts->state_ptr; - if (dir_ts && arg_ts->state =3D=3D TS_DEAD) { - TCGOpcode lopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 - ? INDEX_op_ld_i32 - : INDEX_op_ld_i64); - TCGOp *lop =3D tcg_op_insert_before(s, op, lopc, 3); + dir_ts =3D arg_ts->state_ptr; + if (dir_ts && arg_ts->state =3D=3D TS_DEAD) { + TCGOpcode lopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 + ? INDEX_op_ld_i32 + : INDEX_op_ld_i64); + TCGOp *lop =3D tcg_op_insert_before(s, op, lopc, 3); =20 - lop->args[0] =3D temp_arg(dir_ts); - lop->args[1] =3D temp_arg(arg_ts->mem_base); - lop->args[2] =3D arg_ts->mem_offset; + lop->args[0] =3D temp_arg(dir_ts); + lop->args[1] =3D temp_arg(arg_ts->mem_base); + lop->args[2] =3D arg_ts->mem_offset; =20 - /* Loaded, but synced with memory. */ - arg_ts->state =3D TS_MEM; - } + /* Loaded, but synced with memory. */ + arg_ts->state =3D TS_MEM; } } =20 @@ -2977,14 +3095,12 @@ static bool liveness_pass_2(TCGContext *s) so that we reload when needed. */ for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_ts =3D arg_temp(op->args[i]); - if (arg_ts) { - dir_ts =3D arg_ts->state_ptr; - if (dir_ts) { - op->args[i] =3D temp_arg(dir_ts); - changes =3D true; - if (IS_DEAD_ARG(i)) { - arg_ts->state =3D TS_DEAD; - } + dir_ts =3D arg_ts->state_ptr; + if (dir_ts) { + op->args[i] =3D temp_arg(dir_ts); + changes =3D true; + if (IS_DEAD_ARG(i)) { + arg_ts->state =3D TS_DEAD; } } } @@ -4147,106 +4263,107 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, con= st TCGOp *op) return true; } =20 +static void load_arg_reg(TCGContext *s, TCGReg reg, TCGTemp *ts, + TCGRegSet allocated_regs) +{ + if (ts->val_type =3D=3D TEMP_VAL_REG) { + if (ts->reg !=3D reg) { + tcg_reg_free(s, reg, allocated_regs); + if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { + /* + * Cross register class move not supported. Sync the + * temp back to its slot and load from there. + */ + temp_sync(s, ts, allocated_regs, 0, 0); + tcg_out_ld(s, ts->type, reg, + ts->mem_base->reg, ts->mem_offset); + } + } + } else { + TCGRegSet arg_set =3D 0; + + tcg_reg_free(s, reg, allocated_regs); + tcg_regset_set_reg(arg_set, reg); + temp_load(s, ts, arg_set, allocated_regs, 0); + } +} + +static void load_arg_stk(TCGContext *s, int stk_slot, TCGTemp *ts, + TCGRegSet allocated_regs) +{ + /* + * When the destination is on the stack, load up the temp and store. + * If there are many call-saved registers, the temp might live to + * see another use; otherwise it'll be discarded. + */ + temp_load(s, ts, tcg_target_available_regs[ts->type], allocated_regs, = 0); + tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, + TCG_TARGET_CALL_STACK_OFFSET + + stk_slot * sizeof(tcg_target_long)); +} + +static void load_arg_normal(TCGContext *s, const TCGCallArgumentLoc *l, + TCGTemp *ts, TCGRegSet *allocated_regs) +{ + if (REG_P(l)) { + TCGReg reg =3D tcg_target_call_iarg_regs[l->arg_slot]; + load_arg_reg(s, reg, ts, *allocated_regs); + tcg_regset_set_reg(*allocated_regs, reg); + } else { + load_arg_stk(s, l->arg_slot - ARRAY_SIZE(tcg_target_call_iarg_regs= ), + ts, *allocated_regs); + } +} + static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { const int nb_oargs =3D TCGOP_CALLO(op); const int nb_iargs =3D TCGOP_CALLI(op); const TCGLifeData arg_life =3D op->life; - const TCGHelperInfo *info; - int flags, nb_regs, i; - TCGReg reg; - TCGArg arg; - TCGTemp *ts; - intptr_t stack_offset; - size_t call_stack_size; - tcg_insn_unit *func_addr; - int allocate_args; - TCGRegSet allocated_regs; + const TCGHelperInfo *info =3D tcg_call_info(op); + TCGRegSet allocated_regs =3D s->reserved_regs; + int i; =20 - func_addr =3D tcg_call_func(op); - info =3D tcg_call_info(op); - flags =3D info->flags; + /* + * Move inputs into place in reverse order, + * so that we place stacked arguments first. + */ + for (i =3D nb_iargs - 1; i >=3D 0; --i) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + TCGTemp *ts =3D arg_temp(op->args[nb_oargs + i]); =20 - nb_regs =3D ARRAY_SIZE(tcg_target_call_iarg_regs); - if (nb_regs > nb_iargs) { - nb_regs =3D nb_iargs; - } - - /* assign stack slots first */ - call_stack_size =3D (nb_iargs - nb_regs) * sizeof(tcg_target_long); - call_stack_size =3D (call_stack_size + TCG_TARGET_STACK_ALIGN - 1) & - ~(TCG_TARGET_STACK_ALIGN - 1); - allocate_args =3D (call_stack_size > TCG_STATIC_CALL_ARGS_SIZE); - if (allocate_args) { - /* XXX: if more than TCG_STATIC_CALL_ARGS_SIZE is needed, - preallocate call stack */ - tcg_abort(); - } - - stack_offset =3D TCG_TARGET_CALL_STACK_OFFSET; - for (i =3D nb_regs; i < nb_iargs; i++) { - arg =3D op->args[nb_oargs + i]; - if (arg !=3D TCG_CALL_DUMMY_ARG) { - ts =3D arg_temp(arg); - temp_load(s, ts, tcg_target_available_regs[ts->type], - s->reserved_regs, 0); - tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, stack_off= set); - } - stack_offset +=3D sizeof(tcg_target_long); - } - - /* assign input registers */ - allocated_regs =3D s->reserved_regs; - for (i =3D 0; i < nb_regs; i++) { - arg =3D op->args[nb_oargs + i]; - if (arg !=3D TCG_CALL_DUMMY_ARG) { - ts =3D arg_temp(arg); - reg =3D tcg_target_call_iarg_regs[i]; - - if (ts->val_type =3D=3D TEMP_VAL_REG) { - if (ts->reg !=3D reg) { - tcg_reg_free(s, reg, allocated_regs); - if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { - /* - * Cross register class move not supported. Sync = the - * temp back to its slot and load from there. - */ - temp_sync(s, ts, allocated_regs, 0, 0); - tcg_out_ld(s, ts->type, reg, - ts->mem_base->reg, ts->mem_offset); - } - } - } else { - TCGRegSet arg_set =3D 0; - - tcg_reg_free(s, reg, allocated_regs); - tcg_regset_set_reg(arg_set, reg); - temp_load(s, ts, arg_set, allocated_regs, 0); - } - - tcg_regset_set_reg(allocated_regs, reg); + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + load_arg_normal(s, loc, ts, &allocated_regs); + break; + default: + g_assert_not_reached(); } } =20 - /* mark dead temporaries and free the associated registers */ + /* Mark dead temporaries and free the associated registers. */ for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { if (IS_DEAD_ARG(i)) { temp_dead(s, arg_temp(op->args[i])); } } =20 - /* clobber call registers */ + /* Clobber call registers. */ for (i =3D 0; i < TCG_TARGET_NB_REGS; i++) { if (tcg_regset_test_reg(tcg_target_call_clobber_regs, i)) { tcg_reg_free(s, i, allocated_regs); } } =20 - /* Save globals if they might be written by the helper, sync them if - they might be read. */ - if (flags & TCG_CALL_NO_READ_GLOBALS) { + /* + * Save globals if they might be written by the helper, + * sync them if they might be read. + */ + if (info->flags & TCG_CALL_NO_READ_GLOBALS) { /* Nothing to do */ - } else if (flags & TCG_CALL_NO_WRITE_GLOBALS) { + } else if (info->flags & TCG_CALL_NO_WRITE_GLOBALS) { sync_globals(s, allocated_regs); } else { save_globals(s, allocated_regs); @@ -4257,25 +4374,35 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp= *op) gpointer hash =3D (gpointer)(uintptr_t)info->typemask; ffi_cif *cif =3D g_hash_table_lookup(ffi_table, hash); assert(cif !=3D NULL); - tcg_out_call(s, func_addr, cif); + tcg_out_call(s, tcg_call_func(op), cif); } #else - tcg_out_call(s, func_addr); + tcg_out_call(s, tcg_call_func(op)); #endif =20 - /* assign output registers and emit moves if needed */ - for(i =3D 0; i < nb_oargs; i++) { - arg =3D op->args[i]; - ts =3D arg_temp(arg); + /* Assign output registers and emit moves if needed. */ + switch (info->out_kind) { + case TCG_CALL_RET_NORMAL: + for (i =3D 0; i < nb_oargs; i++) { + TCGTemp *ts =3D arg_temp(op->args[i]); + TCGReg reg =3D tcg_target_call_oarg_regs[i]; =20 - /* ENV should not be modified. */ - tcg_debug_assert(!temp_readonly(ts)); + /* ENV should not be modified. */ + tcg_debug_assert(!temp_readonly(ts)); =20 - reg =3D tcg_target_call_oarg_regs[i]; - set_temp_val_reg(s, ts, reg); - ts->mem_coherent =3D 0; + set_temp_val_reg(s, ts, reg); + ts->mem_coherent =3D 0; + } + break; + default: + g_assert_not_reached(); + } + + /* Flush or discard output registers as needed. */ + for (i =3D 0; i < nb_oargs; i++) { + TCGTemp *ts =3D arg_temp(op->args[i]); if (NEED_SYNC_ARG(i)) { - temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); + temp_sync(s, ts, s->reserved_regs, 0, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { temp_dead(s, ts); } --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670967460; cv=none; d=zohomail.com; s=zohoarc; b=fBEsiLuD/7dGI8QUPV7OaWqxmpVelLmbVFyVowy9vaAH9r8UF31xIomzFTD1vVZaVwZvm+YDc3xhYMTm/brzZn9Q59Ou0mhXCb2WWNFqKVy8n5JwEWoDRvDL2jj/RqWB6Fr4dlhc8RnfAbGj3ehmn1g42eiSGx/MJoFCURxeuqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670967460; 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=QFUsNAuul+J55fC7tXSY0WCt3qBCcqJEW4LFQbi3f+k=; b=CZi1G0qfZGwEo3MafMrYjNGJVj3DULYYQPJmxS+FdwG7XfKTiK4VtQP1pUOlmT9zSGNUCDjGJUgYboKkUV5MlPdj+5cdAuffA6daeNEATn4CCU8Itd+1n9viorwsiG7ky6LIV+MERY0taDzQ6lpUwuIWNCuaa6kf4/D3Dqa2sa4= 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 1670967460349221.59377924550654; Tue, 13 Dec 2022 13:37:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmy-0000iV-RA; Tue, 13 Dec 2022 16:26:12 -0500 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 1p5Cmw-0000h2-Og for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:10 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmu-0003Dw-QI for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:10 -0500 Received: by mail-oi1-x22f.google.com with SMTP id v70so1050002oie.3 for ; Tue, 13 Dec 2022 13:26:07 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=QFUsNAuul+J55fC7tXSY0WCt3qBCcqJEW4LFQbi3f+k=; b=VccumtVuwewimi/cUVu4XEDvuSAlRKh9q3tJP0rNqXR9hr8hbqn5jv0rUaieYRKvj3 ZmU6L5EGH9nEteYUPwg6/7wmlPR6MEJL9tQVl8UQYgB++3uNkP/SiCTMx5yvbMJAp9N0 qlCeQOIVeR4yd+l+pEUKT52iksA9OFi+KZlAz2vLzsQiJ067/RDuVSJVcmkLkTSfE7Cc uU8hN2r5dT6bkQfQy0c5nT2lalEzSrrOEBvKnIcjV8OIqd05dey1Y83v56orDFxPlBTW kQ36PVdI1Kpr4iRnTtwu1YF/u6QI5uCu4sQD4cxLqc845r6757zRYVfouFk3zmk6CQFb lbYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=QFUsNAuul+J55fC7tXSY0WCt3qBCcqJEW4LFQbi3f+k=; b=U3qxo04I85vkIWswN14WOwg5pi0seLrQl7nrfnu1uzA254YgkTBs7H2q2QPtfC6Z6o Z3ks7YAO3hxUh/4H0QdhEO7FVV/kM3hVlxP9IgdCWShybeUuy8kIdZwnzzjcasgvYgpm tpnNKsrO8Ij2fWSqbnxXIL8LuNTa6IV9f3hEVGngqOOTYo0poajN3arQF6iES5TtTwr3 qjmXxxSijSoH3s4seJDF43lCt1TqLl7QTgktPP8jy+H7FAc7ZLN299IgXLU3fyW7xi1b Uv2tcWqqvBwK1wVWv5PUPNse8EQPx5tM1G3U7lrytNSclQttxFNv8yNTZjdIhZg6pLZD +Q5g== X-Gm-Message-State: ANoB5plhqNeHudvcyYr0A0xa40zAHAK0I+4MY9RZGrgiIViEZP0GBJbt lfjUlsgWgIzjtHxLHFNRoLPaTUumXZ578pMFDvQ= X-Google-Smtp-Source: AA0mqf713G84k2alDtMS5LYcQn08OSfD6+v+sJ8NKjNJd5Sx7CbePRIMQ3i7q10mwh8GxtCK99jDdA== X-Received: by 2002:a05:6808:1b1e:b0:35e:4589:19cf with SMTP id bx30-20020a0568081b1e00b0035e458919cfmr13206339oib.42.1670966767685; Tue, 13 Dec 2022 13:26:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 23/27] tcg: Convert typecode_to_ffi from array to function Date: Tue, 13 Dec 2022 15:25:37 -0600 Message-Id: <20221213212541.1820840-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670967461268100003 From: Philippe Mathieu-Daud=C3=A9 In the unlikely case of invalid typecode mask, the function will abort instead of returning a NULL pointer. Signed-off-by: Richard Henderson Message-Id: <20221111074101.2069454-27-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20221122180804.938-2-philmd@linaro.org> --- tcg/tcg.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 74f7491d73..46cce228a0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -555,14 +555,24 @@ static GHashTable *helper_table; #ifdef CONFIG_TCG_INTERPRETER static GHashTable *ffi_table; =20 -static ffi_type * const typecode_to_ffi[8] =3D { - [dh_typecode_void] =3D &ffi_type_void, - [dh_typecode_i32] =3D &ffi_type_uint32, - [dh_typecode_s32] =3D &ffi_type_sint32, - [dh_typecode_i64] =3D &ffi_type_uint64, - [dh_typecode_s64] =3D &ffi_type_sint64, - [dh_typecode_ptr] =3D &ffi_type_pointer, -}; +static ffi_type *typecode_to_ffi(int argmask) +{ + switch (argmask) { + case dh_typecode_void: + return &ffi_type_void; + case dh_typecode_i32: + return &ffi_type_uint32; + case dh_typecode_s32: + return &ffi_type_sint32; + case dh_typecode_i64: + return &ffi_type_uint64; + case dh_typecode_s64: + return &ffi_type_sint64; + case dh_typecode_ptr: + return &ffi_type_pointer; + } + g_assert_not_reached(); +} #endif =20 typedef struct TCGCumulativeArgs { @@ -779,14 +789,14 @@ static void tcg_context_init(unsigned max_cpus) nargs =3D DIV_ROUND_UP(nargs, 3); =20 ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); - ca->cif.rtype =3D typecode_to_ffi[typemask & 7]; + ca->cif.rtype =3D typecode_to_ffi(typemask & 7); ca->cif.nargs =3D nargs; =20 if (nargs !=3D 0) { ca->cif.arg_types =3D ca->args; for (int j =3D 0; j < nargs; ++j) { int typecode =3D extract32(typemask, (j + 1) * 3, 3); - ca->args[j] =3D typecode_to_ffi[typecode]; + ca->args[j] =3D typecode_to_ffi(typecode); } } =20 --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966846; cv=none; d=zohomail.com; s=zohoarc; b=KuIEe16GQbtprFmz9qElqtFPVl02b0kUOgOM6/Pujiwpi/sPV5r2xKNuA89XRuQH7vH8Hgf8E4+KgJQBH90ojGvBT4Lm/BtwWbcevHa1DeQWnQMbS3dTTDTuN9JLVKNZ5gTSdsBgDD2eoDrm/p+rfG7FZLypTl4u8kKbfBz8hak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966846; 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=7o/uTcMX+wfPe8sHfpNtvUDYBEo1al5HudozA0YE4Gk=; b=O7mlqQllmqSc0IlOuDiUYPEcUSE5hyl7lLgnuFo+m5uKu2VgJQUfWQoHUVBKVAxborXesYhekM2it7x4s9v7C9pHJgY5qSrJMiDRG/m80mZrEhdghWCTLiut+75wDKD2dLxbZR/jHbWFaBQ57wjtUy7eSDyf+mWJQMExXeXE3ao= 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 1670966846402198.12506773373946; Tue, 13 Dec 2022 13:27:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cmz-0000ik-3N; Tue, 13 Dec 2022 16:26:13 -0500 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 1p5Cmx-0000hD-1D for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:11 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmv-0003D0-DP for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:10 -0500 Received: by mail-oi1-x236.google.com with SMTP id l127so1028567oia.8 for ; Tue, 13 Dec 2022 13:26:09 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=7o/uTcMX+wfPe8sHfpNtvUDYBEo1al5HudozA0YE4Gk=; b=xKI1dESWd2pYyhQUd6WIcEc11vhstWeuqvoC4ADEoizfZaQp4fhZtQIGU5C7EW9lxC W0XtoyVsl99lAUdqMLcskX6a4yh65clr4GnEOya7ry+8gRMgGykNB/j2L9g9l0aovrZF Pbt0vY3vFmPb607r84Wed3xlB2xXcL4P3jM9mHIpIoKhqnHw8P40oYsZ2xjgVrH0cLfW Sh0215CnMGcqGI7sZZJxTFVmID7JwpUGqx1VCROGW6CBDcpNA+Fwam9/el7mAD71KUaN Y/VRRG9KtRYpPdY+19+XPyejEfCItYYA+4a/VjnzpYqdqdAydroGVdL5FJNxmiT7fBqa reSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=7o/uTcMX+wfPe8sHfpNtvUDYBEo1al5HudozA0YE4Gk=; b=7WO1wBp/aaSIDYf/Mh05GsiudbssRaIX8++2fwgjNQDvY7TBglkmEMvl4/Fm/QqrAI 0KJXsRRi824NkXNWDrCYHPR8AIbh9y96Vrsbimx5FvRu9bwIbst4/7UzeO1yp6fhmy3m VotP0/L6bMIVddcgfy5MjWX4DUFjZIGVoy3yRjjOleS3ZP45TORN1cXMbGx62hiwZHR/ 9Ugm0933n+Ty3i/KRAClr+QxUeXHbe0FaYYqeRekQQUCTR8mENsP5k5PzrJcERqDq5r1 CcWtv1S64fi/+xyaLZf/vsLpapHsmUqNQe2urDhZ5o8/5yfeRGP4eKtGgTIerJgQrfpO OA3g== X-Gm-Message-State: ANoB5pmdU3pVPBtR+xgnWRI7BcTynxJ3rzGvapZvlGnI9DLvK9UUnT2F Ax6UuOV6mQEwkNa+D5KhoWKqYZGLMSGXsqemT8c= X-Google-Smtp-Source: AA0mqf7sEEzmlRLAAQP9PBSNUcFOdoKkpkZs63Mc0kuB5zYarUiijHnzhW65LPXz7J6wYtOh9pXwuQ== X-Received: by 2002:a05:6808:2085:b0:35e:915c:f0b4 with SMTP id s5-20020a056808208500b0035e915cf0b4mr5552667oiw.16.1670966768708; Tue, 13 Dec 2022 13:26:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 24/27] tcg: Factor init_ffi_layouts() out of tcg_context_init() Date: Tue, 13 Dec 2022 15:25:38 -0600 Message-Id: <20221213212541.1820840-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966847052100001 From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-Id: <20221111074101.2069454-27-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20221122180804.938-3-philmd@linaro.org> --- tcg/tcg.c | 83 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 46cce228a0..3c3bb2d422 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -573,7 +573,49 @@ static ffi_type *typecode_to_ffi(int argmask) } g_assert_not_reached(); } -#endif + +static void init_ffi_layouts(void) +{ + /* g_direct_hash/equal for direct comparisons on uint32_t. */ + ffi_table =3D g_hash_table_new(NULL, NULL); + for (int i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { + uint32_t typemask =3D all_helpers[i].typemask; + gpointer hash =3D (gpointer)(uintptr_t)typemask; + struct { + ffi_cif cif; + ffi_type *args[]; + } *ca; + ffi_status status; + int nargs; + + if (g_hash_table_lookup(ffi_table, hash)) { + continue; + } + + /* Ignoring the return type, find the last non-zero field. */ + nargs =3D 32 - clz32(typemask >> 3); + nargs =3D DIV_ROUND_UP(nargs, 3); + + ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); + ca->cif.rtype =3D typecode_to_ffi(typemask & 7); + ca->cif.nargs =3D nargs; + + if (nargs !=3D 0) { + ca->cif.arg_types =3D ca->args; + for (int j =3D 0; j < nargs; ++j) { + int typecode =3D extract32(typemask, (j + 1) * 3, 3); + ca->args[j] =3D typecode_to_ffi(typecode); + } + } + + status =3D ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, + ca->cif.rtype, ca->cif.arg_types); + assert(status =3D=3D FFI_OK); + + g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); + } +} +#endif /* CONFIG_TCG_INTERPRETER */ =20 typedef struct TCGCumulativeArgs { int arg_idx; /* tcg_gen_callN args[] */ @@ -768,44 +810,7 @@ static void tcg_context_init(unsigned max_cpus) } =20 #ifdef CONFIG_TCG_INTERPRETER - /* g_direct_hash/equal for direct comparisons on uint32_t. */ - ffi_table =3D g_hash_table_new(NULL, NULL); - for (i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { - struct { - ffi_cif cif; - ffi_type *args[]; - } *ca; - uint32_t typemask =3D all_helpers[i].typemask; - gpointer hash =3D (gpointer)(uintptr_t)typemask; - ffi_status status; - int nargs; - - if (g_hash_table_lookup(ffi_table, hash)) { - continue; - } - - /* Ignoring the return type, find the last non-zero field. */ - nargs =3D 32 - clz32(typemask >> 3); - nargs =3D DIV_ROUND_UP(nargs, 3); - - ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); - ca->cif.rtype =3D typecode_to_ffi(typemask & 7); - ca->cif.nargs =3D nargs; - - if (nargs !=3D 0) { - ca->cif.arg_types =3D ca->args; - for (int j =3D 0; j < nargs; ++j) { - int typecode =3D extract32(typemask, (j + 1) * 3, 3); - ca->args[j] =3D typecode_to_ffi(typecode); - } - } - - status =3D ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, - ca->cif.rtype, ca->cif.arg_types); - assert(status =3D=3D FFI_OK); - - g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); - } + init_ffi_layouts(); #endif =20 tcg_target_init(s); --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966818; cv=none; d=zohomail.com; s=zohoarc; b=MSkK1hKK+5slzkT/v3Xf6ECH2EK5FH7FSR8hUsBtXqihZkWZK+zrq9VQys5D2sL3F+huRMa4ZHiuN4aAGPxT6kkbJgjhIRvg+AbNFF/q5/2NQTZKkbEml5p/viIdNrvajNaNaA+3Hu5JtqsIZRfHotjsxKxw8vqcPF7CjndIjAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966818; 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=ejdHuoy1Jq/BbeHpGWM1PuHE72TqekmQLGqKh44eCOc=; b=Rip8OVtERqoGokbRflHewpZ8m2HB6vLuz21xJSPmnYmoazfasXs+TSG/8Z54j1NadBqoXWKdvysEe7XU9rGeikfog1KZzTxKZ0A6hmDe317/kEs3kve+P7LhMvHUeVd7cs1b3tXI2oGAgf053/mwsZhUeyyTNYmAMcVjSEYtpkA= 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 1670966818939759.1410623561753; Tue, 13 Dec 2022 13:26:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cn1-0000ju-Qz; Tue, 13 Dec 2022 16:26:15 -0500 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 1p5Cmy-0000hy-36 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:12 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmw-0003DK-G7 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:11 -0500 Received: by mail-oi1-x231.google.com with SMTP id m204so1038543oib.6 for ; Tue, 13 Dec 2022 13:26:10 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=ejdHuoy1Jq/BbeHpGWM1PuHE72TqekmQLGqKh44eCOc=; b=keSGhGgYSvSljmvxnViZ+P/5XEkv4WewGZFhZ2Bc6QpUH/DGHU2C2vmtaKI9EY3K3v eQnrXVV2j2hwXRMAGFWFYlAG4TCXHnUvn6agHYtYrvbsq80EOPVXXo+F6DUFGlVA5P6F HdVmL+cXsoI5ubkhIphAZhujAM5fAHeOhmO41EG+ZcbKHAOL8DVyFA02zI3flHTFhQ/4 XcToNTvWFZts0v+truFeMK3yaFvIq0Q3CbbXh9APni2dFU4gQNJf8huyIVG5+QDqXnRJ YOEyhjuYVmdFymIwKPw7vZNmOEvkCBMsHtm07LMP3JECX8IM6cRL6UuBuXHIZQYiuKst 0Z6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ejdHuoy1Jq/BbeHpGWM1PuHE72TqekmQLGqKh44eCOc=; b=cu4zUqnPDY/0ePWkDx7DOBiJC5VCmQxjJV9OCDN4VD32hu7Iw4dfnaLOOrFHYreM9l F4fmFYvmgS3ZWqb8iSlN4OVFC48S4zuldVALr+BFlBmxLwy4d5CmNJ/wQkiwiqoVBefP cgGslnGDZmbwOF4SPNZZ6iE+cT4U2/Vzk5iNU4M0pTdD1RX/L0201snYyAD+ZIY0o9Cp hvirC0GPfdo95MnaRwDAtluP0DZtpmuV/ibe9+OFFL1cpB+7mv4Q6QI7oPzgxRGurc0e cjU9PfaXEHAoQHcx2PQH5OnC6op5DQCPwBmLece0fCd8P/rNVuTHGQxQy5ovDBAwuTRh Q79Q== X-Gm-Message-State: ANoB5pkgCe5QdRfyGbyPoeLnz6mdBZR4VMcZNwZ87vLI38LoJ3Zzxaa2 gx5syJ/X5VZQJLNtqCW/ZwiZOBLKze/wb8YWvSw= X-Google-Smtp-Source: AA0mqf7wY4HT7gAGb91EDYKLFPPadIIxTN6WxLIe+3ZrgrkZQEOinB/7jCUMm5VMEziPvAc+7hZvcQ== X-Received: by 2002:a05:6808:1520:b0:35b:e67:40b9 with SMTP id u32-20020a056808152000b0035b0e6740b9mr11820094oiw.45.1670966769798; Tue, 13 Dec 2022 13:26:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 25/27] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Tue, 13 Dec 2022 15:25:39 -0600 Message-Id: <20221213212541.1820840-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::231; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966820995100002 Instead of requiring a separate hash table lookup, put a pointer to the CIF into TCGHelperInfo. Signed-off-by: Richard Henderson Message-Id: <20221111074101.2069454-27-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20221122180804.938-4-philmd@linaro.org> --- tcg/tcg-internal.h | 7 +++++++ tcg/tcg.c | 30 ++++++++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index c7e87e193d..6e50aeba3a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -25,6 +25,10 @@ #ifndef TCG_INTERNAL_H #define TCG_INTERNAL_H =20 +#ifdef CONFIG_TCG_INTERPRETER +#include +#endif + #define TCG_HIGHWATER 1024 =20 /* @@ -57,6 +61,9 @@ typedef struct TCGCallArgumentLoc { typedef struct TCGHelperInfo { void *func; const char *name; +#ifdef CONFIG_TCG_INTERPRETER + ffi_cif *cif; +#endif unsigned typemask : 32; unsigned flags : 8; unsigned nr_in : 8; diff --git a/tcg/tcg.c b/tcg/tcg.c index 3c3bb2d422..9092473cf0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -62,10 +62,6 @@ #include "tcg/tcg-ldst.h" #include "tcg-internal.h" =20 -#ifdef CONFIG_TCG_INTERPRETER -#include -#endif - /* Forward declarations for functions declared in tcg-target.c.inc and used here. */ static void tcg_target_init(TCGContext *s); @@ -553,8 +549,6 @@ static TCGHelperInfo all_helpers[] =3D { static GHashTable *helper_table; =20 #ifdef CONFIG_TCG_INTERPRETER -static GHashTable *ffi_table; - static ffi_type *typecode_to_ffi(int argmask) { switch (argmask) { @@ -577,9 +571,11 @@ static ffi_type *typecode_to_ffi(int argmask) static void init_ffi_layouts(void) { /* g_direct_hash/equal for direct comparisons on uint32_t. */ - ffi_table =3D g_hash_table_new(NULL, NULL); + GHashTable *ffi_table =3D g_hash_table_new(NULL, NULL); + for (int i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { - uint32_t typemask =3D all_helpers[i].typemask; + TCGHelperInfo *info =3D &all_helpers[i]; + unsigned typemask =3D info->typemask; gpointer hash =3D (gpointer)(uintptr_t)typemask; struct { ffi_cif cif; @@ -587,8 +583,11 @@ static void init_ffi_layouts(void) } *ca; ffi_status status; int nargs; + ffi_cif *cif; =20 - if (g_hash_table_lookup(ffi_table, hash)) { + cif =3D g_hash_table_lookup(ffi_table, hash); + if (cif) { + info->cif =3D cif; continue; } =20 @@ -612,8 +611,12 @@ static void init_ffi_layouts(void) ca->cif.rtype, ca->cif.arg_types); assert(status =3D=3D FFI_OK); =20 - g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); + cif =3D &ca->cif; + info->cif =3D cif; + g_hash_table_insert(ffi_table, hash, (gpointer)cif); } + + g_hash_table_destroy(ffi_table); } #endif /* CONFIG_TCG_INTERPRETER */ =20 @@ -4385,12 +4388,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp = *op) } =20 #ifdef CONFIG_TCG_INTERPRETER - { - gpointer hash =3D (gpointer)(uintptr_t)info->typemask; - ffi_cif *cif =3D g_hash_table_lookup(ffi_table, hash); - assert(cif !=3D NULL); - tcg_out_call(s, tcg_call_func(op), cif); - } + tcg_out_call(s, tcg_call_func(op), info->cif); #else tcg_out_call(s, tcg_call_func(op)); #endif --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966965; cv=none; d=zohomail.com; s=zohoarc; b=jnIlKL9yHNfcY267zeLYd22Vdui5OBLhSQxmLjBw34fmQpVLOm7W9AFFMGDrJ1jqlZUG3HnqGKZdo0iywaxU+ddBVT0+bO2uc4DocJy4jRi9GEYyYk+lsjUxlP2w1i8Qv7QBeFkZOG+j7MzIeh2DcGnYxGp4+Ho1u8ytxO+WrdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966965; h=Content-Transfer-Encoding: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=tSbRzCjHlrSQSoghRByzLuEHEpXHbvdfoP5b3KIKF+c=; b=X3iETVpO+t7cJhYVOPTruxeiMYsuqzbsr5OABnZ9tQLWPzm6AIwlYjM0cWT3UK+ho1pW05bCItv3VeNaR1ivaCGNrJKX6r05kd4P58GKrGWF55lS1dp/ZFDDI2d0wcQigefk6kjuPiFaMQCiGcY67oJu+r7ltNN5F4VXD06j68c= 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 1670966965058542.7729959867222; Tue, 13 Dec 2022 13:29:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cn2-0000jx-8T; Tue, 13 Dec 2022 16:26:16 -0500 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 1p5Cmz-0000im-4v for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:13 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmx-0003Bt-JF for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:12 -0500 Received: by mail-oi1-x22b.google.com with SMTP id t62so1011753oib.12 for ; Tue, 13 Dec 2022 13:26:11 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tSbRzCjHlrSQSoghRByzLuEHEpXHbvdfoP5b3KIKF+c=; b=GjMlv7FRRMsK9hP4CDuuondcV4EqJA40IfkY8yIpNhfFyCYdzvZsUr1e6X6XmGWJ+C 68h5zoTu8/Co81I7GQvXdSGVLKg69vlugXjb5vEHmqTRIjo1XXE7GPTwi7sS3zTHKnpw XMqkBw1zjH9vrwsEv9p/bCn4Zbshs07vi3ULGO9AhD0zeJVvkqrl0Ua/DtxYLAaaXam5 8VSjsip7bf5gSdPy2L/M+gCK2CRjhUNmqdRchmhOSBHiuFY6EFN8KGHqTxBlWCf4Jk6Z w8QjZ8+GWXWxqVEZ5SOKgM9mLhTgEeUbxVT0tDLI3LV21socR7Hu/MuDa0/k+DY+9hxr 2w8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tSbRzCjHlrSQSoghRByzLuEHEpXHbvdfoP5b3KIKF+c=; b=ZfRMlEqW1YyVBrA/nqjZIjaiOP82Yll6v8CThKVZioR0sT/YUUzVJj+q0QV3F9Bhjy n45vTI7h3/AJszs4ubDlpBsjRjKiKE1rL9ZMpKtpcZzKGAfFGxWFSDyh+EGqZ5ft4u9+ U6OemIlwVRrcnx29qDridwmDxx2D+uwrOH2vn5fu0x6QLCQiuxccYMoH8Vh34BF+bLgc YKLuv20B/KJkbpTKVZh0X0MJsEnbLsjXNrhnUHM4xo8ArktLdM3QQ/scjfftZlPh38Lp TFeNcpHsmtADbRGHcDU9ftt4n2v+2NXOwVXwvKDU+ltawxFdrTxmqYrWhuzSQCXV42Ot We6g== X-Gm-Message-State: ANoB5plFW12+OP0uYpNaTHWH5QGMpTro9zM6RL8VPWlU9APllgdgmTxk rOhB0TkOl1G3SYpJcU2cSii6Y2Fr6PBk1BOfL88= X-Google-Smtp-Source: AA0mqf6MrKDhDu01slG51lMTMIDDU8xKXIC54r1BXwN17lmlLtxYmk18K7Gz4se8BY6XuWy8ENLVnA== X-Received: by 2002:a05:6808:15a7:b0:35c:4a91:79bd with SMTP id t39-20020a05680815a700b0035c4a9179bdmr12990980oiw.41.1670966770920; Tue, 13 Dec 2022 13:26:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 26/27] tcg/aarch64: Merge tcg_out_callr into tcg_out_call Date: Tue, 13 Dec 2022 15:25:40 -0600 Message-Id: <20221213212541.1820840-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966965681100001 Content-Type: text/plain; charset="utf-8" There is only one use, and BLR is perhaps even more self-documentary than CALLR. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/aarch64/tcg-target.c.inc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 344b63e20f..1af879e6f5 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1336,11 +1336,6 @@ static void tcg_out_goto_long(TCGContext *s, const t= cg_insn_unit *target) } } =20 -static inline void tcg_out_callr(TCGContext *s, TCGReg reg) -{ - tcg_out_insn(s, 3207, BLR, reg); -} - static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset =3D tcg_pcrel_diff(s, target) >> 2; @@ -1348,7 +1343,7 @@ static void tcg_out_call(TCGContext *s, const tcg_ins= n_unit *target) tcg_out_insn(s, 3206, BL, offset); } else { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (intptr_t)target); - tcg_out_callr(s, TCG_REG_TMP); + tcg_out_insn(s, 3207, BLR, TCG_REG_TMP); } } =20 --=20 2.34.1 From nobody Sun May 19 16:27:44 2024 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=1670966788; cv=none; d=zohomail.com; s=zohoarc; b=Ez+MgQxmWKQ00u1BVm7lhqKnRPpB3ArEVn4vfmKdW1j0HiHtfv9tx1VPSfBTvjz9DFrATwhmQNGUQxueN2qQZ+4tjULMJEhHPl4tg3Z0WhR5QR0cw/KI51TM6IuaJOvco4o4tNZteb8TEgF7pUsG6Y2yEX0XCOhoKw2H1ZxzosE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670966788; 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=t90UzdI6bBWuX61bW3oSKKHPeT/DJfZGV++tUHFjEmI=; b=HPUN9ib94lnUXhZNNajz62UvhR2b9WnUNaqwgBtWcbKrwGZ4pqplc1BtiSNqbEDf6yj/GHJ12doMk4bH9MFL5dpeJzU0/OdOIFkjfwWkoW+jC9oV8IMcBTvRht2+qFyVSGXXwxbh0u80I0aJIa3gCzMnx+5BhDW8R+QkIYbCGe0= 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 1670966788392175.02886346043454; Tue, 13 Dec 2022 13:26:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Cn3-0000kS-QZ; Tue, 13 Dec 2022 16:26:17 -0500 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 1p5Cn1-0000jm-7J for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:15 -0500 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmz-0003BY-1S for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:14 -0500 Received: by mail-oi1-x235.google.com with SMTP id n205so1060423oib.1 for ; Tue, 13 Dec 2022 13:26:12 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=t90UzdI6bBWuX61bW3oSKKHPeT/DJfZGV++tUHFjEmI=; b=Ebf94ZQUwG39admOLNdwQp//9p37CKs1jN1zS2FJ/Vs2oowe69YBq5QU7+avmBl5ML LjvBpA9+oeM9D9hhHNFb0w3LcR6JxfTAzsgaDp6m+eWwYbOH6hBZEkYu/lnparu/3B/F v9GStbE0RhSLiFD86XPqskFVWrY7lSvWgSOBBVMcpj5JktEY1JBXXh5ieBHxeegobvTx EE+zaUAPWUzFyNYWOoqZJQAgDZHNB0bBcrGH8E98QMgaJSjON5hEtelBP397lLe3Hill +L04NLzXd1aMkOUyuqz176++YQMQPeb5NbKj41HN35q/mDMN1XH07zAEnKf/6GKsKNEb bFPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=t90UzdI6bBWuX61bW3oSKKHPeT/DJfZGV++tUHFjEmI=; b=IzlUS6hWm5mW1GGNDIcbhYsLIgCf80uQjmc0CT7aCTihsMONU3rnkQvuX3r+Uraj8B 9g9Qb4PWD6a0k6PO8fvqNqJqLoDYY+ocU7T4tb2XPvrXSIBF0CNU+XHpBexqTZvnKRte tdNkMYFC1TtRXygPWX+b8izjjkbenKFs5FepxUsPByRuSWOP1C8a5nDT4foUOVdMRGL2 sqkcxCqOTP4WwiWYSkHB1yIWE4kKlyNH8rip5YkkWF6Q0ZLtVWg8SpfP65LrWGWBjKGJ OuOS+0o6Bk0xT3NijY0/W0xvoBkJ7XjQGarVWU7617Bf97vrL1gvWRKijgOibJZvVNMw cgDA== X-Gm-Message-State: ANoB5pmtLTq+AcVE+/TQDxeHLscfK1eXH11IXlJWXVgopt29opyZ0myN 3KZmF6VbmMOF+YxjGN4M3MO+uHwybpiR+1GzHTk= X-Google-Smtp-Source: AA0mqf7aOapBIxEoDH2U7phAoR5aJJDZ37aFVAWis3+PivGdo38mOCjCZlwUmmtiyg/mMtWqU+EesQ== X-Received: by 2002:a05:6808:2114:b0:35e:bc7c:59a1 with SMTP id r20-20020a056808211400b0035ebc7c59a1mr280948oiw.47.1670966772282; Tue, 13 Dec 2022 13:26:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 27/27] tcg: Add TCGHelperInfo argument to tcg_out_call Date: Tue, 13 Dec 2022 15:25:41 -0600 Message-Id: <20221213212541.1820840-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670966789044100006 This eliminates an ifdef for TCI, and will be required for expanding the call for TCGv_i128. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/tcg.c | 12 ++---------- tcg/aarch64/tcg-target.c.inc | 12 +++++++++--- tcg/arm/tcg-target.c.inc | 10 ++++++++-- tcg/i386/tcg-target.c.inc | 5 +++-- tcg/loongarch64/tcg-target.c.inc | 7 ++++--- tcg/mips/tcg-target.c.inc | 3 ++- tcg/ppc/tcg-target.c.inc | 7 ++++--- tcg/riscv/tcg-target.c.inc | 7 ++++--- tcg/s390x/tcg-target.c.inc | 12 +++++++++--- tcg/sparc64/tcg-target.c.inc | 3 ++- tcg/tci/tcg-target.c.inc | 3 ++- 11 files changed, 49 insertions(+), 32 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 9092473cf0..acd73d09bf 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -145,12 +145,8 @@ static void tcg_out_st(TCGContext *s, TCGType type, TC= GReg arg, TCGReg arg1, intptr_t arg2); static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, TCGReg base, intptr_t ofs); -#ifdef CONFIG_TCG_INTERPRETER static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, - ffi_cif *cif); -#else -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target); -#endif + const TCGHelperInfo *info); static bool tcg_target_const_match(int64_t val, TCGType type, int ct); #ifdef TCG_TARGET_NEED_LDST_LABELS static int tcg_out_ldst_finalize(TCGContext *s); @@ -4387,11 +4383,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp = *op) save_globals(s, allocated_regs); } =20 -#ifdef CONFIG_TCG_INTERPRETER - tcg_out_call(s, tcg_call_func(op), info->cif); -#else - tcg_out_call(s, tcg_call_func(op)); -#endif + tcg_out_call(s, tcg_call_func(op), info); =20 /* Assign output registers and emit moves if needed. */ switch (info->out_kind) { diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 1af879e6f5..ad1816e32d 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1336,7 +1336,7 @@ static void tcg_out_goto_long(TCGContext *s, const tc= g_insn_unit *target) } } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset =3D tcg_pcrel_diff(s, target) >> 2; if (offset =3D=3D sextract64(offset, 0, 26)) { @@ -1347,6 +1347,12 @@ static void tcg_out_call(TCGContext *s, const tcg_in= sn_unit *target) } } =20 +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, + const TCGHelperInfo *info) +{ + tcg_out_call_int(s, target); +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, uintptr_t jmp_rw, uintptr_t addr) { @@ -1594,7 +1600,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) tcg_out_mov(s, TARGET_LONG_BITS =3D=3D 64, TCG_REG_X1, lb->addrlo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X2, oi); tcg_out_adr(s, TCG_REG_X3, lb->raddr); - tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_ld_helpers[opc & MO_SIZE]); if (opc & MO_SIGN) { tcg_out_sxt(s, lb->type, size, lb->datalo_reg, TCG_REG_X0); } else { @@ -1620,7 +1626,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) tcg_out_mov(s, size =3D=3D MO_64, TCG_REG_X2, lb->datalo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X3, oi); tcg_out_adr(s, TCG_REG_X4, lb->raddr); - tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_st_helpers[opc & MO_SIZE]); tcg_out_goto(s, lb->raddr); return true; } diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 2c6c353eea..9245ea86d0 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1131,7 +1131,7 @@ static void tcg_out_goto(TCGContext *s, ARMCond cond,= const tcg_insn_unit *addr) * The call case is mostly used for helpers - so it's not unreasonable * for them to be beyond branch range. */ -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *addr) { intptr_t addri =3D (intptr_t)addr; ptrdiff_t disp =3D tcg_pcrel_diff(s, addr); @@ -1150,6 +1150,12 @@ static void tcg_out_call(TCGContext *s, const tcg_in= sn_unit *addr) tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); } =20 +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr, + const TCGHelperInfo *info) +{ + tcg_out_call_int(s, addr); +} + static void tcg_out_goto_label(TCGContext *s, ARMCond cond, TCGLabel *l) { if (l->has_value) { @@ -1515,7 +1521,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) argreg =3D tcg_out_arg_reg32(s, argreg, TCG_REG_R14); =20 /* Use the canonical unsigned helpers and minimize icache usage. */ - tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_ld_helpers[opc & MO_SIZE]); =20 datalo =3D lb->datalo_reg; datahi =3D lb->datahi_reg; diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index cb04e4b3ad..58bd5873f5 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1661,7 +1661,8 @@ static void tcg_out_branch(TCGContext *s, int call, c= onst tcg_insn_unit *dest) } } =20 -static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, + const TCGHelperInfo *info) { tcg_out_branch(s, 1, dest); } @@ -1885,7 +1886,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) (uintptr_t)l->raddr); } =20 - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_branch(s, 1, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); =20 data_reg =3D l->datalo_reg; switch (opc & MO_SSIZE) { diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.= c.inc index d326e28740..c9e99e8ec3 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -567,7 +567,8 @@ static void tcg_out_call_int(TCGContext *s, const tcg_i= nsn_unit *arg, bool tail) } } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg, + const TCGHelperInfo *info) { tcg_out_call_int(s, arg, false); } @@ -760,7 +761,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TC= GLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A2, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A3, (tcg_target_long)l->raddr); =20 - tcg_out_call(s, qemu_ld_helpers[size]); + tcg_out_call_int(s, qemu_ld_helpers[size], false); =20 switch (opc & MO_SSIZE) { case MO_SB: @@ -821,7 +822,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TC= GLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A3, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A4, (tcg_target_long)l->raddr); =20 - tcg_out_call(s, qemu_st_helpers[size]); + tcg_out_call_int(s, qemu_st_helpers[size], false); =20 return tcg_out_goto(s, l->raddr); } diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index bd76f0c97f..292e490b5c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1020,7 +1020,8 @@ static void tcg_out_call_int(TCGContext *s, const tcg= _insn_unit *arg, bool tail) } } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg, + const TCGHelperInfo *info) { tcg_out_call_int(s, arg, false); tcg_out_nop(s); diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 38ee9974cd..e0621463f6 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2002,7 +2002,8 @@ static void tcg_out_call_int(TCGContext *s, int lk, #endif } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, + const TCGHelperInfo *info) { tcg_out_call_int(s, LK, target); } @@ -2221,7 +2222,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) tcg_out_movi(s, TCG_TYPE_I32, arg++, oi); tcg_out32(s, MFSPR | RT(arg) | LR); =20 - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call_int(s, LK, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); =20 lo =3D lb->datalo_reg; hi =3D lb->datahi_reg; @@ -2290,7 +2291,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) tcg_out_movi(s, TCG_TYPE_I32, arg++, oi); tcg_out32(s, MFSPR | RT(arg) | LR); =20 - tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call_int(s, LK, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); =20 tcg_out_b(s, 0, lb->raddr); return true; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 81a83e45b1..aa017d665a 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -819,7 +819,8 @@ static void tcg_out_call_int(TCGContext *s, const tcg_i= nsn_unit *arg, bool tail) } } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg, + const TCGHelperInfo *info) { tcg_out_call_int(s, arg, false); } @@ -1002,7 +1003,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, a2, oi); tcg_out_movi(s, TCG_TYPE_PTR, a3, (tcg_target_long)l->raddr); =20 - tcg_out_call(s, qemu_ld_helpers[opc & MO_SSIZE]); + tcg_out_call_int(s, qemu_ld_helpers[opc & MO_SSIZE], false); tcg_out_mov(s, (opc & MO_SIZE) =3D=3D MO_64, l->datalo_reg, a0); =20 tcg_out_goto(s, l->raddr); @@ -1047,7 +1048,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, a3, oi); tcg_out_movi(s, TCG_TYPE_PTR, a4, (tcg_target_long)l->raddr); =20 - tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_st_helpers[opc & MO_SIZE], false); =20 tcg_out_goto(s, l->raddr); return true; diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index f1d3907cd8..b9ba7b605e 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -1691,7 +1691,7 @@ static void tgen_brcond(TCGContext *s, TCGType type, = TCGCond c, tgen_branch(s, cc, l); } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *dest) { ptrdiff_t off =3D tcg_pcrel_diff(s, dest) >> 1; if (off =3D=3D (int32_t)off) { @@ -1702,6 +1702,12 @@ static void tcg_out_call(TCGContext *s, const tcg_in= sn_unit *dest) } } =20 +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, + const TCGHelperInfo *info) +{ + tcg_out_call_int(s, dest); +} + static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg data, TCGReg base, TCGReg index, int disp) { @@ -1897,7 +1903,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) } tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R4, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R5, (uintptr_t)lb->raddr); - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)]); + tcg_out_call_int(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)]); tcg_out_mov(s, TCG_TYPE_I64, data_reg, TCG_REG_R2); =20 tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr); @@ -1938,7 +1944,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) } tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R5, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R6, (uintptr_t)lb->raddr); - tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call_int(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); =20 tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr); return true; diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index cb9453efdd..eb913f33c8 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -859,7 +859,8 @@ static void tcg_out_call_nodelay(TCGContext *s, const t= cg_insn_unit *dest, } } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, + const TCGHelperInfo *info) { tcg_out_call_nodelay(s, dest, false); tcg_out_nop(s); diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index c1acaa943e..d36a7ebdd1 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -558,8 +558,9 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } =20 static void tcg_out_call(TCGContext *s, const tcg_insn_unit *func, - ffi_cif *cif) + const TCGHelperInfo *info) { + ffi_cif *cif =3D info->cif; tcg_insn_unit insn =3D 0; uint8_t which; =20 --=20 2.34.1