From nobody Thu Nov 6 10:38:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540490663971476.4093517904262; Thu, 25 Oct 2018 11:04:23 -0700 (PDT) Received: from localhost ([::1]:56252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjzS-0006XG-Ov for importer@patchew.org; Thu, 25 Oct 2018 14:04:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjKp-0006ix-31 for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFjJl-0008Pf-Ez for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:11 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:59947) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFjJl-0008P8-8Z for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:09 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id D2ECC21FFB; Thu, 25 Oct 2018 13:21:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 Oct 2018 13:21:08 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 7E737E455F; Thu, 25 Oct 2018 13:21:08 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=HLL/G79KuxQKfKUIsck2JrML9KIg9iIgCze5lz6eDBk=; b=CV0H0 K9+gdwCpVm2NmuI7Zu9zhrRQTw1YW6ctcX17E66NJulneAgZk0KyT7f+NNKmzdrj md0EyHPE7a/+yihm1PkFU2RAFbL877Bec7myJnNfyAH01jx8ddh9/knj1bUK7k3j 7fHYu2rfpzOIpobCudNopzqLbpPZQJcbLnqzBY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=HLL/G79KuxQKfKUIsck2JrML9KIg9 iIgCze5lz6eDBk=; b=tyEAM1VkszmST+LMfI4sXcQCVk0CNnWrk5txeKCPxikaF IJ/5stpxOQWYGNrvLhqvyDh43v8G63hu/IeNwuLCMpNU9ca7sJv6uUSn7nCZ9IwG wBcuMZ9SCO4vvl7i876Q6kWshRu01bUjNYZG+L8mm4NBqmpRdA2KFq1l2wvpRb2b ZxtBbO5pyeYpd/oV9Pkofh2FH6yrjP+NEw0dtribjbtHpmKIreH/ccEwl8p3r/7s 2I/yfZKHGbR+cE+etDbj3sv3idXt9raO6ne/bRBuA/K9gyLfwOVjh64aWsn3tU/a UqXoCVW2qgYf9AWWGe6vb00D3Kw1+riH0oMKWruUw== X-ME-Sender: X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 25 Oct 2018 13:20:17 -0400 Message-Id: <20181025172057.20414-9-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025172057.20414-1-cota@braap.org> References: <20181025172057.20414-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC 08/48] tcg: export tcg_gen_runtime_helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Pavel Dovgalyuk , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This takes the TCGHelperInfo directly, which will allow us to generate helpers at run-time. Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- tcg/tcg.h | 2 ++ tcg/tcg.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index 9f9643b470..3fa434d891 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1077,6 +1077,8 @@ do {\ bool tcg_op_supported(TCGOpcode op); =20 void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args); +void tcg_gen_runtime_helper(const TCGHelperInfo *orig, TCGTemp *ret, int n= args, + TCGTemp **args); =20 TCGOp *tcg_emit_op(TCGOpcode opc); void tcg_op_remove(TCGContext *s, TCGOp *op); diff --git a/tcg/tcg.c b/tcg/tcg.c index 08b6926894..87e02da740 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1642,15 +1642,13 @@ bool tcg_op_supported(TCGOpcode op) /* 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(). */ -void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) +static void do_tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, int nargs, + TCGTemp **args) { int i, real_args, nb_rets, pi; unsigned sizemask, flags; - TCGHelperInfo *info; - uint32_t hash =3D tcg_helper_func_hash(func); TCGOp *op; =20 - info =3D qht_lookup_custom(&helper_table, func, hash, tcg_helper_looku= p_cmp); flags =3D info->flags; sizemask =3D info->sizemask; =20 @@ -1774,7 +1772,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int narg= s, TCGTemp **args) op->args[pi++] =3D temp_arg(args[i]); real_args++; } - op->args[pi++] =3D (uintptr_t)func; + op->args[pi++] =3D (uintptr_t)info->func; op->args[pi++] =3D flags; TCGOP_CALLI(op) =3D real_args; =20 @@ -1812,6 +1810,48 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nar= gs, TCGTemp **args) #endif /* TCG_TARGET_EXTEND_ARGS */ } =20 +void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) +{ + TCGHelperInfo *info; + uint32_t hash =3D tcg_helper_func_hash(func); + + /* + * Here we can get away with tcg_helper_lookup_cmp, which only looks + * at the function pointer, since we have the compile-time guarantee + * that @func can only be in one TCGHelperInfo. + */ + info =3D qht_lookup_custom(&helper_table, func, hash, tcg_helper_looku= p_cmp); + do_tcg_gen_callN(info, ret, nargs, args); +} + +void tcg_gen_runtime_helper(const TCGHelperInfo *orig, TCGTemp *ret, int n= args, + TCGTemp **args) +{ + TCGHelperInfo *info; + uint32_t hash =3D tcg_helper_func_hash(orig->func); + + /* + * Use the full TCGHelperInfo lookup, since there is no guarantee that= func + * will be unique to each TCGHelperInfo. For instance, we could have t= he + * same helper function registered in several TCGHelperInfo's, each of= them + * with different flags. + */ + info =3D qht_lookup(&helper_table, orig, hash); + if (info =3D=3D NULL) { + void *existing =3D NULL; + + /* @orig might be in the stack, so we need to allocate a new struc= t */ + info =3D g_new(TCGHelperInfo, 1); + memcpy(info, orig, sizeof(TCGHelperInfo)); + qht_insert(&helper_table, info, hash, &existing); + if (unlikely(existing)) { + g_free(info); + info =3D existing; + } + } + do_tcg_gen_callN(info, ret, nargs, args); +} + static void tcg_reg_alloc_start(TCGContext *s) { int i, n; --=20 2.17.1