From nobody Tue Feb 10 19:17:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=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