From nobody Tue Oct 28 01:56:35 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; dkim=fail; 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 1516206388245101.48231227471376; Wed, 17 Jan 2018 08:26:28 -0800 (PST) Received: from localhost ([::1]:45719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebqXj-0007co-DW for importer@patchew.org; Wed, 17 Jan 2018 11:26:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebqHa-0001gd-DE for qemu-devel@nongnu.org; Wed, 17 Jan 2018 11:09:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebqHU-0001Cr-Cw for qemu-devel@nongnu.org; Wed, 17 Jan 2018 11:09:46 -0500 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:37776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebqHU-0001Ce-4R for qemu-devel@nongnu.org; Wed, 17 Jan 2018 11:09:40 -0500 Received: by mail-pl0-x243.google.com with SMTP id s3so9227204plp.4 for ; Wed, 17 Jan 2018 08:09:40 -0800 (PST) Received: from cloudburst.twiddle.net.com (24-181-135-63.dhcp.knwc.wa.charter.com. [24.181.135.63]) by smtp.gmail.com with ESMTPSA id t25sm6368905pfk.162.2018.01.17.08.09.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2018 08:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hWNeV+zOx+oAfKu9VCxGrhv2jH/fOaNDlWpbf3/FB4Y=; b=GHTImdDgw5r/4Sh2aVeZjsCsUwpN1AainE5+Z6rVAX3PeYKAy8tZyRg6LPOz0ZPHSr KCnlU0r6u4pCbiW8Moe9vuwrCkgLb1rgh2O1IkA64FlxVzG/gu/Gh0lR0rzY7JNKNZgq HeTIY03/co+MVgn62rqeFypHv1ZV7sTvvSS10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hWNeV+zOx+oAfKu9VCxGrhv2jH/fOaNDlWpbf3/FB4Y=; b=fUSIejoDb401JcPVeJBiezJqD7mWe2DX8vmNUeEatayDTfMCQDMxy5HtU2KQRm7307 3zNFQQdiLk45fQuHwRXxKDn9xK1Mk00nkOH71+i1bKTZY/ouOIPEXAAfuj9XGT/eKqSF PTXbv14bzWk0lHpSe6yaDzzYRJn6HnmMRDS2njeW3gvnJFf8haJM8XLJuPJhYARgnUad Jhj8KvgNz6QNSoNUNxI+9hXQlsL2Aby2xHxML+ZFdoFdcmNmRpzsdhNn3C0y47R0c6JQ soTWLNZWr+kVJrj9qltQpU6onEZGODo6CkIZO2MB5Lczb9H+0u+R+7n3SPWeqouT8RKx 6T2w== X-Gm-Message-State: AKGB3mLjFaqGXP3r2KqLKGhxarAWZdqcWLQXLSyNPQGm25O5gerr0zWT 9H3AbmanMz9LP161EjYTgVh0ReRQT8s= X-Google-Smtp-Source: ACJfBovBG1VI5iZ/YrqIa86LB7ufuPDBsIpD9dPN8AIrCWtB/EJTB0o2ocBLGhpKxF4O1tenr4EcQQ== X-Received: by 10.84.244.72 with SMTP id e8mr37303035plt.420.1516205378866; Wed, 17 Jan 2018 08:09:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 17 Jan 2018 08:09:13 -0800 Message-Id: <20180117160933.28086-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180117160933.28086-1-richard.henderson@linaro.org> References: <20180117160933.28086-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v10 01/21] tcg: Allow multiple word entries into the constant pool 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@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This will be required for storing vector constants. Signed-off-by: Richard Henderson --- tcg/tcg-pool.inc.c | 115 +++++++++++++++++++++++++++++++++++++++++++------= ---- 1 file changed, 93 insertions(+), 22 deletions(-) diff --git a/tcg/tcg-pool.inc.c b/tcg/tcg-pool.inc.c index 8a85131405..0f76e7bee3 100644 --- a/tcg/tcg-pool.inc.c +++ b/tcg/tcg-pool.inc.c @@ -22,39 +22,110 @@ =20 typedef struct TCGLabelPoolData { struct TCGLabelPoolData *next; - tcg_target_ulong data; tcg_insn_unit *label; - intptr_t addend; - int type; + int addend : 32; + int rtype : 16; + int nlong : 16; + tcg_target_ulong data[]; } TCGLabelPoolData; =20 =20 -static void new_pool_label(TCGContext *s, tcg_target_ulong data, int type, - tcg_insn_unit *label, intptr_t addend) +static TCGLabelPoolData *new_pool_alloc(TCGContext *s, int nlong, int rtyp= e, + tcg_insn_unit *label, int addend) { - TCGLabelPoolData *n =3D tcg_malloc(sizeof(*n)); - TCGLabelPoolData *i, **pp; + TCGLabelPoolData *n =3D tcg_malloc(sizeof(TCGLabelPoolData) + + sizeof(tcg_target_ulong) * nlong); =20 - n->data =3D data; n->label =3D label; - n->type =3D type; n->addend =3D addend; + n->rtype =3D rtype; + n->nlong =3D nlong; + return n; +} + +static void new_pool_insert(TCGContext *s, TCGLabelPoolData *n) +{ + TCGLabelPoolData *i, **pp; + int nlong =3D n->nlong; =20 /* Insertion sort on the pool. */ - for (pp =3D &s->pool_labels; (i =3D *pp) && i->data < data; pp =3D &i-= >next) { - continue; + for (pp =3D &s->pool_labels; (i =3D *pp) !=3D NULL; pp =3D &i->next) { + if (nlong > i->nlong) { + break; + } + if (nlong < i->nlong) { + continue; + } + if (memcmp(n->data, i->data, sizeof(tcg_target_ulong) * nlong) >= =3D 0) { + break; + } } n->next =3D *pp; *pp =3D n; } =20 +/* The "usual" for generic integer code. */ +static inline void new_pool_label(TCGContext *s, tcg_target_ulong d, int r= type, + tcg_insn_unit *label, int addend) +{ + TCGLabelPoolData *n =3D new_pool_alloc(s, 1, rtype, label, addend); + n->data[0] =3D d; + new_pool_insert(s, n); +} + +/* For v64 or v128, depending on the host. */ +static inline void new_pool_l2(TCGContext *s, int rtype, tcg_insn_unit *la= bel, + int addend, tcg_target_ulong d0, + tcg_target_ulong d1) +{ + TCGLabelPoolData *n =3D new_pool_alloc(s, 2, rtype, label, addend); + n->data[0] =3D d0; + n->data[1] =3D d1; + new_pool_insert(s, n); +} + +/* For v128 or v256, depending on the host. */ +static inline void new_pool_l4(TCGContext *s, int rtype, tcg_insn_unit *la= bel, + int addend, tcg_target_ulong d0, + tcg_target_ulong d1, tcg_target_ulong d2, + tcg_target_ulong d3) +{ + TCGLabelPoolData *n =3D new_pool_alloc(s, 4, rtype, label, addend); + n->data[0] =3D d0; + n->data[1] =3D d1; + n->data[2] =3D d2; + n->data[3] =3D d3; + new_pool_insert(s, n); +} + +/* For v256, for 32-bit host. */ +static inline void new_pool_l8(TCGContext *s, int rtype, tcg_insn_unit *la= bel, + int addend, tcg_target_ulong d0, + tcg_target_ulong d1, tcg_target_ulong d2, + tcg_target_ulong d3, tcg_target_ulong d4, + tcg_target_ulong d5, tcg_target_ulong d6, + tcg_target_ulong d7) +{ + TCGLabelPoolData *n =3D new_pool_alloc(s, 8, rtype, label, addend); + n->data[0] =3D d0; + n->data[1] =3D d1; + n->data[2] =3D d2; + n->data[3] =3D d3; + n->data[4] =3D d4; + n->data[5] =3D d5; + n->data[6] =3D d6; + n->data[7] =3D d7; + new_pool_insert(s, n); +} + /* To be provided by cpu/tcg-target.inc.c. */ static void tcg_out_nop_fill(tcg_insn_unit *p, int count); =20 static bool tcg_out_pool_finalize(TCGContext *s) { TCGLabelPoolData *p =3D s->pool_labels; - tcg_target_ulong d, *a; + TCGLabelPoolData *l =3D NULL; + void *a; =20 if (p =3D=3D NULL) { return true; @@ -62,24 +133,24 @@ static bool tcg_out_pool_finalize(TCGContext *s) =20 /* ??? Round up to qemu_icache_linesize, but then do not round again when allocating the next TranslationBlock structure. */ - a =3D (void *)ROUND_UP((uintptr_t)s->code_ptr, sizeof(tcg_target_ulong= )); + a =3D (void *)ROUND_UP((uintptr_t)s->code_ptr, + sizeof(tcg_target_ulong) * p->nlong); tcg_out_nop_fill(s->code_ptr, (tcg_insn_unit *)a - s->code_ptr); s->data_gen_ptr =3D a; =20 - /* Ensure the first comparison fails. */ - d =3D p->data + 1; - for (; p !=3D NULL; p =3D p->next) { - if (p->data !=3D d) { - d =3D p->data; - if (unlikely((void *)a > s->code_gen_highwater)) { + size_t size =3D sizeof(tcg_target_ulong) * p->nlong; + if (!l || l->nlong !=3D p->nlong || memcmp(l->data, p->data, size)= ) { + if (unlikely(a > s->code_gen_highwater)) { return false; } - *a++ =3D d; + memcpy(a, p->data, size); + a +=3D size; + l =3D p; } - patch_reloc(p->label, p->type, (intptr_t)(a - 1), p->addend); + patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend); } =20 - s->code_ptr =3D (void *)a; + s->code_ptr =3D a; return true; } --=20 2.14.3