From nobody Thu Jul 3 15:52:58 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.zoho.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 1486046267038832.205241728908; Thu, 2 Feb 2017 06:37:47 -0800 (PST) Received: from localhost ([::1]:56987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIW7-0006mY-9i for importer@patchew.org; Thu, 02 Feb 2017 09:37:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIU1-0005KY-0D for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:35:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZITw-0005ON-1G for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:35:32 -0500 Received: from bran.ispras.ru ([83.149.199.196]:39762 helo=smtp.ispras.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZITv-0005NK-Ja for qemu-devel@nongnu.org; Thu, 02 Feb 2017 09:35:27 -0500 Received: from bulbul.intra.ispras.ru (spartak.intra.ispras.ru [10.10.3.51]) by smtp.ispras.ru (Postfix) with ESMTP id 074BB612B2; Thu, 2 Feb 2017 17:35:25 +0300 (MSK) From: Kirill Batuzov To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 17:34:41 +0300 Message-Id: <1486046099-17726-4-git-send-email-batuzovk@ispras.ru> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1486046099-17726-1-git-send-email-batuzovk@ispras.ru> References: <1486046099-17726-1-git-send-email-batuzovk@ispras.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.196 Subject: [Qemu-devel] [PATCH v2.1 03/21] tcg: support representing vector type with smaller vector or scalar types 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 , Peter Crosthwaite , Kirill Batuzov , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kirill Batuzov --- This is not as bad as I thought it would be. Only two cases: type =3D=3D base_type and type !=3D base_type. --- tcg/tcg.c | 136 +++++++++++++++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 91 insertions(+), 45 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 5e69103..18d97ec 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -523,12 +523,54 @@ TCGv_i64 tcg_global_reg_new_i64(TCGReg reg, const cha= r *name) return MAKE_TCGV_I64(idx); } =20 -int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, +static TCGType tcg_choose_type(TCGType type) +{ + switch (type) { + case TCG_TYPE_I64: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + return TCG_TYPE_I64; + } + /* Fallthrough */ + case TCG_TYPE_I32: + return TCG_TYPE_I32; + case TCG_TYPE_V128: +#ifdef TCG_TARGET_HAS_REG128 + return TCG_TYPE_V128; +#endif + /* Fallthrough */ + case TCG_TYPE_V64: +#ifdef TCG_TARGET_HAS_REGV64 + return TCG_TYPE_V64; +#else + return tcg_choose_type(TCG_TYPE_I64); +#endif + default: + g_assert_not_reached(); + } +} + +static intptr_t tcg_type_size(TCGType type) +{ + switch (type) { + case TCG_TYPE_I32: + return 4; + case TCG_TYPE_I64: + case TCG_TYPE_V64: + return 8; + case TCG_TYPE_V128: + return 16; + default: + g_assert_not_reached(); + } +} + +int tcg_global_mem_new_internal(TCGType base_type, TCGv_ptr base, intptr_t offset, const char *name) { TCGContext *s =3D &tcg_ctx; TCGTemp *base_ts =3D &s->temps[GET_TCGV_PTR(base)]; TCGTemp *ts =3D tcg_global_alloc(s); + TCGType type =3D tcg_choose_type(base_type); int indirect_reg =3D 0, bigendian =3D 0; #ifdef HOST_WORDS_BIGENDIAN bigendian =3D 1; @@ -543,47 +585,51 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_pt= r base, indirect_reg =3D 1; } =20 - if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64) { - TCGTemp *ts2 =3D tcg_global_alloc(s); - char buf[64]; - - ts->base_type =3D TCG_TYPE_I64; - ts->type =3D TCG_TYPE_I32; + if (type =3D=3D base_type) { + ts->base_type =3D type; + ts->type =3D type; ts->indirect_reg =3D indirect_reg; ts->mem_allocated =3D 1; ts->mem_base =3D base_ts; - ts->mem_offset =3D offset + bigendian * 4; - pstrcpy(buf, sizeof(buf), name); - pstrcat(buf, sizeof(buf), "_0"); - ts->name =3D strdup(buf); - - tcg_debug_assert(ts2 =3D=3D ts + 1); - ts2->base_type =3D TCG_TYPE_I64; - ts2->type =3D TCG_TYPE_I32; - 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; - pstrcpy(buf, sizeof(buf), name); - pstrcat(buf, sizeof(buf), "_1"); - ts2->name =3D strdup(buf); + ts->mem_offset =3D offset; + ts->name =3D name; } else { - ts->base_type =3D type; + int i, count =3D tcg_type_size(base_type) / tcg_type_size(type); + TCGTemp *ts2, *ts1 =3D ts; + int cur_offset =3D + bigendian ? tcg_type_size(base_type) - tcg_type_size(type)= : 0; + + ts->base_type =3D base_type; ts->type =3D type; ts->indirect_reg =3D indirect_reg; ts->mem_allocated =3D 1; ts->mem_base =3D base_ts; - ts->mem_offset =3D offset; - ts->name =3D name; + ts->mem_offset =3D offset + cur_offset; + ts->name =3D g_strdup_printf("%s_0", name); + + for (i =3D 1; i < count; i++) { + ts2 =3D tcg_global_alloc(s); + tcg_debug_assert(ts2 =3D=3D ts1 + 1); + cur_offset +=3D (bigendian ? -1 : 1) * tcg_type_size(type); + ts2->base_type =3D base_type; + ts2->type =3D type; + ts2->indirect_reg =3D indirect_reg; + ts2->mem_allocated =3D 1; + ts2->mem_base =3D base_ts; + ts2->mem_offset =3D offset + cur_offset; + ts2->name =3D g_strdup_printf("%s_%d", name, i); + ts1 =3D ts2; + } } return temp_idx(s, ts); } =20 -static int tcg_temp_new_internal(TCGType type, int temp_local) +static int tcg_temp_new_internal(TCGType base_type, int temp_local) { TCGContext *s =3D &tcg_ctx; TCGTemp *ts; int idx, k; + TCGType type =3D tcg_choose_type(base_type); =20 k =3D type + (temp_local ? TCG_TYPE_COUNT : 0); idx =3D find_first_bit(s->free_temps[k].l, TCG_MAX_TEMPS); @@ -593,28 +639,28 @@ static int tcg_temp_new_internal(TCGType type, int te= mp_local) =20 ts =3D &s->temps[idx]; ts->temp_allocated =3D 1; - tcg_debug_assert(ts->base_type =3D=3D type); + tcg_debug_assert(ts->base_type =3D=3D base_type); tcg_debug_assert(ts->temp_local =3D=3D temp_local); } else { ts =3D tcg_temp_alloc(s); - if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64) { - TCGTemp *ts2 =3D tcg_temp_alloc(s); - - ts->base_type =3D type; - ts->type =3D TCG_TYPE_I32; - ts->temp_allocated =3D 1; - ts->temp_local =3D temp_local; - - tcg_debug_assert(ts2 =3D=3D ts + 1); - ts2->base_type =3D TCG_TYPE_I64; - ts2->type =3D TCG_TYPE_I32; - ts2->temp_allocated =3D 1; - ts2->temp_local =3D temp_local; - } else { - ts->base_type =3D type; - ts->type =3D type; - ts->temp_allocated =3D 1; - ts->temp_local =3D temp_local; + ts->base_type =3D base_type; + ts->type =3D type; + ts->temp_allocated =3D 1; + ts->temp_local =3D temp_local; + + if (type !=3D base_type) { + int i, count =3D tcg_type_size(base_type) / tcg_type_size(type= ); + TCGTemp *ts2, *ts1 =3D ts; + + for (i =3D 1; i < count; i++) { + ts2 =3D tcg_temp_alloc(s); + tcg_debug_assert(ts2 =3D=3D ts1 + 1); + ts2->base_type =3D base_type; + ts2->type =3D type; + ts2->temp_allocated =3D 1; + ts2->temp_local =3D temp_local; + ts1 =3D ts2; + } } idx =3D temp_idx(s, ts); } --=20 2.1.4