From nobody Tue Feb 10 19:50:02 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=1671927184; cv=none; d=zohomail.com; s=zohoarc; b=Wy2R8C5kbixnzaZ+71YE93cPv2WB59pjgaNfbNTtRfnYIMpx7AxqQ5BLhjssH1Q+WmaY5tETpExeN62RlYZn1p7WqI5I+Up+Xdm9RR2owLIRdMOHs071k0ipMVNa4eMHsArJWOswL7JQxqufGU+/qnMaoeUYYyhXkGRsvJ8fkcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671927184; 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=OBljFhYIHpDHYp33JDsunVI9K3ZsXt/tBvc3MWwAFFM=; b=ELR4sMlomboW5Fgqd+DaYUqO35MSPsaYtudaIOJ0bA0R2B9tMMkcJT7BHGmoyDO/i8qWBJTdKpnQeuJrnsGZKYnJ3ZEmvXYWzzX0UBZtKAFfoaIPqLA8MomgphKWJeooYXD6zLXzn0gtJ5Ube3yJwym/jEXf76q8SaEiDFifmqo= 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 1671927184622176.47096003847048; Sat, 24 Dec 2022 16:13:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9ES4-0007OQ-Lu; Sat, 24 Dec 2022 19:01: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 1p9ERt-0007NF-Au for qemu-devel@nongnu.org; Sat, 24 Dec 2022 19:01:06 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9ERr-0000hV-2L for qemu-devel@nongnu.org; Sat, 24 Dec 2022 19:01:05 -0500 Received: by mail-pj1-x1029.google.com with SMTP id v23so7965251pju.3 for ; Sat, 24 Dec 2022 16:01:01 -0800 (PST) Received: from stoup.. (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id e32-20020a630f20000000b00478fd9bb6c7sm4161280pgl.75.2022.12.24.16.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Dec 2022 16:01: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=OBljFhYIHpDHYp33JDsunVI9K3ZsXt/tBvc3MWwAFFM=; b=x6hPkZedHFS9asNrOOvRyaILARQszcH/ErxYSNFWPCWyt/1OBl7hCyRn4QTfLxm37X 0NJy47FN+xlkbgsVK3uhivLU2tsYFcaJ7iQ2I1ieE2dOA1VKQAkYx3SLy+TxY192rnww qdFoVmU2O1NlHOh1CENtx+QXtafQ+we8yY1v+m+Ld0xP9nI/ql10u/ALC1SFwNdpodaQ HA/0ySRSLpDP2FVQitGq+ubYZwXNWW/zW5Vuk+obAfp4NtoI09rKiwqg0TMfHwecXjr9 N09RI9l+ErzsbyhWgJJE1QPJv2LAzh7BCziPCdx58wSDM3CAMf6h2I3UnoQh4jEz2tvD ID8g== 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=OBljFhYIHpDHYp33JDsunVI9K3ZsXt/tBvc3MWwAFFM=; b=HV0bm6hfiAtq6rEJtLZjIirKgrzxCz6s9X8rPurqyhi6Ha4o/kuVMrLmHln6pfdIBp 6jnRDntfs89gQztex9befQV9AAdYLudTmBsinpz1Z4I0M3WmHZtAyuSQVklGOHtXgG/n G4blSadNIhMDBB3jBHTTdc6o+oUI1mJVF5VTtQUYv3fYyyzvERPCnhdUwtmT6uQ7xHsI YaTSYvPtr2oQxg7S+hHdWK4skzA80obtonTKwETJmQYP52U0fhOCZr+DVr6haw39dU+d CoJbEP1QKIz7dreFh403I3QX+Rkk3k2FxMsTsmUgy41ubg7Eb7qWoLdFVHbI9lrqZ/yf okOg== X-Gm-Message-State: AFqh2krVGoEN+TyVet/2Up3nMj5x47Y/WIfyFBG1noIN1fLToEvd2WDr nPIBKbPxpY2L6X1Amswet1ZVQZLG6xJyNMnE X-Google-Smtp-Source: AMrXdXspavDN86zA6c1xeDvKlrN7q5Ulz+mlQT8tRVCv+gmv4p/jf828qbU8TsvfmE7fM+aCcTV2xw== X-Received: by 2002:a17:90a:8b14:b0:219:752e:c071 with SMTP id y20-20020a17090a8b1400b00219752ec071mr31651582pjn.6.1671926460733; Sat, 24 Dec 2022 16:01:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH v5 40/43] tcg: Factor init_ffi_layouts() out of tcg_context_init() Date: Sat, 24 Dec 2022 15:57:17 -0800 Message-Id: <20221224235720.842093-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221224235720.842093-1-richard.henderson@linaro.org> References: <20221224235720.842093-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::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: 1671927186490100003 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] Reviewed-by: Richard Henderson 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