qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Subject: [PATCH 05/11] target/arm: Implement CTZ, CNT, ABS
Date: Sun,  3 Aug 2025 11:40:13 +1000	[thread overview]
Message-ID: <20250803014019.416797-6-richard.henderson@linaro.org> (raw)
In-Reply-To: <20250803014019.416797-1-richard.henderson@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/tcg/translate-a64.c | 31 +++++++++++++++++++++++++++++++
 target/arm/tcg/a64.decode      |  4 ++++
 2 files changed, 35 insertions(+)

diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index 64a845d5fb..0c78d4bb79 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -8304,6 +8304,37 @@ static void gen_cls32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn)
 TRANS(CLZ, gen_rr, a->rd, a->rn, a->sf ? gen_clz64 : gen_clz32)
 TRANS(CLS, gen_rr, a->rd, a->rn, a->sf ? tcg_gen_clrsb_i64 : gen_cls32)
 
+static void gen_ctz32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn)
+{
+    TCGv_i32 t32 = tcg_temp_new_i32();
+
+    tcg_gen_extrl_i64_i32(t32, tcg_rn);
+    tcg_gen_ctzi_i32(t32, t32, 32);
+    tcg_gen_extu_i32_i64(tcg_rd, t32);
+}
+
+static void gen_ctz64(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn)
+{
+    tcg_gen_ctzi_i64(tcg_rd, tcg_rn, 64);
+}
+
+static void gen_cnt32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn)
+{
+    gen_wrap2_i32(tcg_rn, tcg_rn, tcg_gen_ctpop_i32);
+}
+
+static void gen_abs32(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn)
+{
+    gen_wrap2_i32(tcg_rn, tcg_rn, tcg_gen_abs_i32);
+}
+
+TRANS_FEAT(CTZ, aa64_cssc, gen_rr, a->rd, a->rn,
+           a->sf ? gen_ctz64 : gen_ctz32)
+TRANS_FEAT(CNT, aa64_cssc, gen_rr, a->rd, a->rn,
+           a->sf ? tcg_gen_ctpop_i64 : gen_cnt32)
+TRANS_FEAT(ABS, aa64_cssc, gen_rr, a->rd, a->rn,
+           a->sf ? tcg_gen_abs_i64 : gen_abs32)
+
 static bool gen_pacaut(DisasContext *s, arg_pacaut *a, NeonGenTwo64OpEnvFn fn)
 {
     TCGv_i64 tcg_rd, tcg_rn;
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
index a886b3ba4c..766c610c01 100644
--- a/target/arm/tcg/a64.decode
+++ b/target/arm/tcg/a64.decode
@@ -726,6 +726,10 @@ REV64           1 10 11010110 00000 000011 ..... .....  @rr
 CLZ             . 10 11010110 00000 000100 ..... .....  @rr_sf
 CLS             . 10 11010110 00000 000101 ..... .....  @rr_sf
 
+CTZ             . 10 11010110 00000 000110 ..... .....  @rr_sf
+CNT             . 10 11010110 00000 000111 ..... .....  @rr_sf
+ABS             . 10 11010110 00000 001000 ..... .....  @rr_sf
+
 &pacaut         rd rn z
 @pacaut         . .. ........ ..... .. z:1 ... rn:5 rd:5  &pacaut
 
-- 
2.43.0



  parent reply	other threads:[~2025-08-03  1:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-03  1:40 [PATCH 00/11] target/arm: Implement FEAT_CSSC, FEAT_CMPBR Richard Henderson
2025-08-03  1:40 ` [PATCH 01/11] target/arm: Add feature predicate for FEAT_CSSC Richard Henderson
2025-08-15 13:06   ` Peter Maydell
2025-08-03  1:40 ` [PATCH 02/11] target/arm: Implement MIN/MAX (immediate) Richard Henderson
2025-08-15 13:18   ` Peter Maydell
2025-08-15 13:33     ` Richard Henderson
2025-08-03  1:40 ` [PATCH 03/11] target/arm: Implement MIN/MAX (register) Richard Henderson
2025-08-15 13:20   ` Peter Maydell
2025-08-03  1:40 ` [PATCH 04/11] target/arm: Split out gen_wrap2_i32 helper Richard Henderson
2025-08-15 13:09   ` Peter Maydell
2025-08-15 16:05   ` Peter Maydell
2025-08-03  1:40 ` Richard Henderson [this message]
2025-08-15 13:26   ` [PATCH 05/11] target/arm: Implement CTZ, CNT, ABS Peter Maydell
2025-08-26 16:11   ` Peter Maydell
2025-08-03  1:40 ` [PATCH 06/11] target/arm: Enable FEAT_CSSC for -cpu max Richard Henderson
2025-08-15 13:10   ` Peter Maydell
2025-08-03  1:40 ` [PATCH 07/11] target/arm: Add feature predicate for FEAT_CMPBR Richard Henderson
2025-08-03  1:40 ` [PATCH 08/11] target/arm: Implement CB, CBB, CBH Richard Henderson
2025-08-03 12:31   ` Paolo Bonzini
2025-08-03 20:28     ` Richard Henderson
2025-08-03  1:40 ` [PATCH 09/11] target/arm: Implement CB (immediate) Richard Henderson
2025-08-03  1:40 ` [PATCH 10/11] linux-user: Change exported get_elf_hwcap to abi_ulong Richard Henderson
2025-08-15 13:28   ` Peter Maydell
2025-08-03  1:40 ` [PATCH 11/11] target/arm: Enable FEAT_CMPBR for -cpu max Richard Henderson
2025-08-15 14:10 ` [PATCH 00/11] target/arm: Implement FEAT_CSSC, FEAT_CMPBR Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250803014019.416797-6-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).