From patchwork Fri Dec 13 17:31:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 850165 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp1640252wry; Fri, 13 Dec 2024 09:38:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX++QPY6BBn2T5CtL/wdgnk1zyi1sx6Ujr6zQ06nz+kk26ZZe8TaL/xC+4LD7HZ2sp6YuHA4w==@linaro.org X-Google-Smtp-Source: AGHT+IGCrKrT6s7XsGE7E0V2vgP41Ub2rNTMgx+M7MmpRHWEr0Q7oLFoc7O+sl6GPWYMx6d2sVDM X-Received: by 2002:a05:600c:3d15:b0:434:a1d3:a321 with SMTP id 5b1f17b1804b1-4362aa1b06cmr40426935e9.3.1734111513551; Fri, 13 Dec 2024 09:38:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734111513; cv=none; d=google.com; s=arc-20240605; b=Wy12XPmv50y8nCFHsqKMcjux7Xil3bft1JgFRqPvYr8FV337bgspCSILPsu0EBPUIp SBTT2TPE4LkikB5DEHtbzOpmYN2mX2ZzM9aJsLKySKFV2gMB/eeJ2Wr6bjP0iBDyubmo 6nuKuUNHTX7JxTVx5qFr/fLPq1LJmegSY/4hm4tOZV+7v4MGCt7SY+b0ZvYKAvmGZfkM EgLTPVwFW5XnyqogsX8jfa/WXhxLtJ8JimYUuNSKWAm6EHJu4CxK/QAEqd57GabjGzct Kh/mHw1Q1Wf1GSD5GoP0P+EFbN2WKskx/hMbLnNZWObwD+2yAo6bjiMuAH42LKFV952Z BpUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vwJE9b7WCZuCYFg4jHXixdsKsYlZPKs8bvwJbKgKnCE=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=IGv4Y3D4fG1uEVJEKlbitauaAZwK04XAw6WE4fX/9XQWjFZ29Z0acE4CDRVpeNYJ8M eUQE+JbRPpMSUbrG5oFCeLLNiC5EJIgxjGU7rL9v2bRc/LUYhjf5FGCZBA+WzUhzDLY6 kdQxddJ38NUtkl0eaTWqyHxz9kkwm+bjaXet1UcBPXr0Fd26FcOcekpgYJL43IVE+siJ 0SaQ6STykjokUJ5tBaccFBuG6ieKY2PlooKHHPwjyNjUC2hbHnO+oPXeUD5OLSFSeevM yO02aP72/QBOoVoKWQfXTl55dYf+aLnuA0/NdjxMS2F9G61fUjwqQ/pTYR6qgxDrL95U eT/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UHVBy5s9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 5b1f17b1804b1-43625557f54si22948265e9.45.2024.12.13.09.38.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Dec 2024 09:38:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UHVBy5s9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tM9Y6-0008Mx-92; Fri, 13 Dec 2024 12:33:58 -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 1tM9XO-0007Bx-5m for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:33:14 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tM9XM-0001b2-E0 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:33:13 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-435004228c0so24462055e9.0 for ; Fri, 13 Dec 2024 09:33:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734111191; x=1734715991; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vwJE9b7WCZuCYFg4jHXixdsKsYlZPKs8bvwJbKgKnCE=; b=UHVBy5s9pMlQf+pjAxtzotgLA7P095ps3Yym8HrNkktACImatr0Fn+3g22PD7zhUp6 lYxML4eu5kAiBr7EQSSSqZOALZDtKSevGgaufCSUG80+btrLFpLa2eOFkjatJsOzvtkN W8vVMbeXqW/ydJeOHWrmH5QVn6fyQgoWstI8sKOuDdTFCExKyegY3xO8mlIrVHQYupxo 1ne4waWi7lSt/ilPZivAGn6HaATPWZDeI9yYZ15sMX1TLxfcdSgpKUVS6VSCFpFNvlyL PNtV53sZaq4DXr4/MAtWixCz5LtNMRTloErUGXa9DrugmtqEn2DcH+zWNIMUCuBwZDnr jWaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734111191; x=1734715991; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vwJE9b7WCZuCYFg4jHXixdsKsYlZPKs8bvwJbKgKnCE=; b=LuA9SpcS4Qj1XXiWysaNboCxLABeUgElBJXXvPmGhVH25FmIymjdkQJZwzePXDDyQw ETO9z+e/iU53AhilAsiNWAxi3815UFp6+pQemgUbKk9edBbaiJMYGMoECEt6q7uuuj56 F6WeovKZXdmYqUbb914wijup0owiCMmU6z4N4MHHm0xI+YhUfvf4XFB9jYspRTJS+TZf 7tjWaNDbsGGWQGRISdNQjB8DKEqubzkOXLoFvwfuaIeDjNnF3TutLsDr1jsxJUeKanm6 fKBF4L5H/nKtANZrgAnchrbBt/vevxKbuNwMuDTscJC3MPDO867oCe217FZC81gB1Lst +ouQ== X-Gm-Message-State: AOJu0YzPF+xYH5lYaoMGSkFtqm8iUpjBqJzt7XZe+6N7P1d0PAxN7P4s JPxUVJwWUSOtsIukdCI4E64SrqXbA4uIjDLXTlVUQHj9P5zle50NXhHvLISqeJFEUpVVY0Ti9PH w X-Gm-Gg: ASbGncv6JTczdq/pvew9sFNxd1lliE/KV7tu5QDLY8DakVYLEmEW4kEs7pTGQvpO09G HB8Y4co2SBdsn8CwdZFDnRFLDWIRww8W2X40A1cUbMaPVVyc5ccivYvUBvJr145GmwWoAHUo+Lx GEacZQ+BEHyHhDTUz1NoSgw/lSJCVqfomaoDHP2cFRznmwE2sXa+Bqm+kInnEARFMC2T0RY4pp9 wYeTZx3HVI4jmncKFxL/1bE1l0DpdL/2knS3XlyECQ5nWeEWiO2iMBn3qE5TA== X-Received: by 2002:a05:6000:4028:b0:385:e2d5:cdf2 with SMTP id ffacd0b85a97d-38880ad9012mr3345755f8f.19.1734111190867; Fri, 13 Dec 2024 09:33:10 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c80162ddsm87026f8f.37.2024.12.13.09.33.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:33:09 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/85] target/arm: Introduce gen_gvec_cls, gen_gvec_clz Date: Fri, 13 Dec 2024 17:31:41 +0000 Message-Id: <20241213173229.3308926-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213173229.3308926-1-peter.maydell@linaro.org> References: <20241213173229.3308926-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Add gvec interfaces for CLS and CLZ operations. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-id: 20241211163036.2297116-38-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/tcg/translate.h | 5 +++++ target/arm/tcg/gengvec.c | 35 +++++++++++++++++++++++++++++++++ target/arm/tcg/translate-a64.c | 29 +++++++-------------------- target/arm/tcg/translate-neon.c | 29 ++------------------------- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index 20cd0e851c4..5c6c24f0575 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -578,6 +578,11 @@ void gen_gvec_umaxp(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, void gen_gvec_uminp(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz); +void gen_gvec_cls(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, + uint32_t opr_sz, uint32_t max_sz); +void gen_gvec_clz(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, + uint32_t opr_sz, uint32_t max_sz); + /* * Forward to the isar_feature_* tests given a DisasContext pointer. */ diff --git a/target/arm/tcg/gengvec.c b/target/arm/tcg/gengvec.c index f652520b652..834b2961c06 100644 --- a/target/arm/tcg/gengvec.c +++ b/target/arm/tcg/gengvec.c @@ -2358,3 +2358,38 @@ void gen_gvec_urhadd(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, assert(vece <= MO_32); tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, &g[vece]); } + +void gen_gvec_cls(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, + uint32_t opr_sz, uint32_t max_sz) +{ + static const GVecGen2 g[] = { + { .fni4 = gen_helper_neon_cls_s8, + .vece = MO_8 }, + { .fni4 = gen_helper_neon_cls_s16, + .vece = MO_16 }, + { .fni4 = tcg_gen_clrsb_i32, + .vece = MO_32 }, + }; + assert(vece <= MO_32); + tcg_gen_gvec_2(rd_ofs, rn_ofs, opr_sz, max_sz, &g[vece]); +} + +static void gen_clz32_i32(TCGv_i32 d, TCGv_i32 n) +{ + tcg_gen_clzi_i32(d, n, 32); +} + +void gen_gvec_clz(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, + uint32_t opr_sz, uint32_t max_sz) +{ + static const GVecGen2 g[] = { + { .fni4 = gen_helper_neon_clz_u8, + .vece = MO_8 }, + { .fni4 = gen_helper_neon_clz_u16, + .vece = MO_16 }, + { .fni4 = gen_clz32_i32, + .vece = MO_32 }, + }; + assert(vece <= MO_32); + tcg_gen_gvec_2(rd_ofs, rn_ofs, opr_sz, max_sz, &g[vece]); +} diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index c697f0e9441..387bbbf906b 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -10321,6 +10321,13 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) } switch (opcode) { + case 0x4: /* CLZ, CLS */ + if (u) { + gen_gvec_fn2(s, is_q, rd, rn, gen_gvec_clz, size); + } else { + gen_gvec_fn2(s, is_q, rd, rn, gen_gvec_cls, size); + } + return; case 0x5: if (u && size == 0) { /* NOT */ gen_gvec_fn2(s, is_q, rd, rn, tcg_gen_gvec_not, 0); @@ -10379,13 +10386,6 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) if (size == 2) { /* Special cases for 32 bit elements */ switch (opcode) { - case 0x4: /* CLS */ - if (u) { - tcg_gen_clzi_i32(tcg_res, tcg_op, 32); - } else { - tcg_gen_clrsb_i32(tcg_res, tcg_op); - } - break; case 0x2f: /* FABS */ gen_vfp_abss(tcg_res, tcg_op); break; @@ -10450,21 +10450,6 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) gen_helper_neon_cnt_u8(tcg_res, tcg_op); } break; - case 0x4: /* CLS, CLZ */ - if (u) { - if (size == 0) { - gen_helper_neon_clz_u8(tcg_res, tcg_op); - } else { - gen_helper_neon_clz_u16(tcg_res, tcg_op); - } - } else { - if (size == 0) { - gen_helper_neon_cls_s8(tcg_res, tcg_op); - } else { - gen_helper_neon_cls_s16(tcg_res, tcg_op); - } - } - break; default: case 0x7: /* SQABS, SQNEG */ g_assert_not_reached(); diff --git a/target/arm/tcg/translate-neon.c b/target/arm/tcg/translate-neon.c index 9c8829ad7d2..1c89a532722 100644 --- a/target/arm/tcg/translate-neon.c +++ b/target/arm/tcg/translate-neon.c @@ -3120,6 +3120,8 @@ DO_2MISC_VEC(VCGT0, gen_gvec_cgt0) DO_2MISC_VEC(VCLE0, gen_gvec_cle0) DO_2MISC_VEC(VCGE0, gen_gvec_cge0) DO_2MISC_VEC(VCLT0, gen_gvec_clt0) +DO_2MISC_VEC(VCLS, gen_gvec_cls) +DO_2MISC_VEC(VCLZ, gen_gvec_clz) static bool trans_VMVN(DisasContext *s, arg_2misc *a) { @@ -3227,33 +3229,6 @@ static bool trans_VREV16(DisasContext *s, arg_2misc *a) return do_2misc(s, a, gen_rev16); } -static bool trans_VCLS(DisasContext *s, arg_2misc *a) -{ - static NeonGenOneOpFn * const fn[] = { - gen_helper_neon_cls_s8, - gen_helper_neon_cls_s16, - gen_helper_neon_cls_s32, - NULL, - }; - return do_2misc(s, a, fn[a->size]); -} - -static void do_VCLZ_32(TCGv_i32 rd, TCGv_i32 rm) -{ - tcg_gen_clzi_i32(rd, rm, 32); -} - -static bool trans_VCLZ(DisasContext *s, arg_2misc *a) -{ - static NeonGenOneOpFn * const fn[] = { - gen_helper_neon_clz_u8, - gen_helper_neon_clz_u16, - do_VCLZ_32, - NULL, - }; - return do_2misc(s, a, fn[a->size]); -} - static bool trans_VCNT(DisasContext *s, arg_2misc *a) { if (a->size != 0) {