[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 08/69] target/arm: Convert CLZ, CLS to decodetree
From: |
Richard Henderson |
Subject: |
[PATCH v2 08/69] target/arm: Convert CLZ, CLS to decodetree |
Date: |
Tue, 10 Dec 2024 10:16:32 -0600 |
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/tcg/translate-a64.c | 72 ++++++++++++++--------------------
target/arm/tcg/a64.decode | 3 ++
2 files changed, 33 insertions(+), 42 deletions(-)
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index 1805d77f43..552b45b4e2 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -7738,6 +7738,32 @@ TRANS(REV16, gen_rr, a->rd, a->rn, a->sf ? gen_rev16_64
: gen_rev16_32)
TRANS(REV32, gen_rr, a->rd, a->rn, a->sf ? gen_rev32 : gen_rev_32)
TRANS(REV64, gen_rr, a->rd, a->rn, tcg_gen_bswap64_i64)
+static void gen_clz32(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_clzi_i32(t32, t32, 32);
+ tcg_gen_extu_i32_i64(tcg_rd, t32);
+}
+
+static void gen_clz64(TCGv_i64 tcg_rd, TCGv_i64 tcg_rn)
+{
+ tcg_gen_clzi_i64(tcg_rd, tcg_rn, 64);
+}
+
+static void gen_cls32(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_clrsb_i32(t32, t32);
+ tcg_gen_extu_i32_i64(tcg_rd, t32);
+}
+
+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)
+
/* Logical (shifted register)
* 31 30 29 28 24 23 22 21 20 16 15 10 9 5 4 0
* +----+-----+-----------+-------+---+------+--------+------+------+
@@ -8322,40 +8348,6 @@ static void disas_cond_select(DisasContext *s, uint32_t
insn)
}
}
-static void handle_clz(DisasContext *s, unsigned int sf,
- unsigned int rn, unsigned int rd)
-{
- TCGv_i64 tcg_rd, tcg_rn;
- tcg_rd = cpu_reg(s, rd);
- tcg_rn = cpu_reg(s, rn);
-
- if (sf) {
- tcg_gen_clzi_i64(tcg_rd, tcg_rn, 64);
- } else {
- TCGv_i32 tcg_tmp32 = tcg_temp_new_i32();
- tcg_gen_extrl_i64_i32(tcg_tmp32, tcg_rn);
- tcg_gen_clzi_i32(tcg_tmp32, tcg_tmp32, 32);
- tcg_gen_extu_i32_i64(tcg_rd, tcg_tmp32);
- }
-}
-
-static void handle_cls(DisasContext *s, unsigned int sf,
- unsigned int rn, unsigned int rd)
-{
- TCGv_i64 tcg_rd, tcg_rn;
- tcg_rd = cpu_reg(s, rd);
- tcg_rn = cpu_reg(s, rn);
-
- if (sf) {
- tcg_gen_clrsb_i64(tcg_rd, tcg_rn);
- } else {
- TCGv_i32 tcg_tmp32 = tcg_temp_new_i32();
- tcg_gen_extrl_i64_i32(tcg_tmp32, tcg_rn);
- tcg_gen_clrsb_i32(tcg_tmp32, tcg_tmp32);
- tcg_gen_extu_i32_i64(tcg_rd, tcg_tmp32);
- }
-}
-
/* Data-processing (1 source)
* 31 30 29 28 21 20 16 15 10 9 5 4 0
* +----+---+---+-----------------+---------+--------+------+------+
@@ -8381,14 +8373,6 @@ static void disas_data_proc_1src(DisasContext *s,
uint32_t insn)
#define MAP(SF, O2, O1) ((SF) | (O1 << 1) | (O2 << 7))
switch (MAP(sf, opcode2, opcode)) {
- case MAP(0, 0x00, 0x04): /* CLZ */
- case MAP(1, 0x00, 0x04):
- handle_clz(s, sf, rn, rd);
- break;
- case MAP(0, 0x00, 0x05): /* CLS */
- case MAP(1, 0x00, 0x05):
- handle_cls(s, sf, rn, rd);
- break;
case MAP(1, 0x01, 0x00): /* PACIA */
if (s->pauth_active) {
tcg_rd = cpu_reg(s, rd);
@@ -8542,6 +8526,10 @@ static void disas_data_proc_1src(DisasContext *s,
uint32_t insn)
case MAP(0, 0x00, 0x02): /* REV/REV32 */
case MAP(1, 0x00, 0x02):
case MAP(1, 0x00, 0x03): /* REV64 */
+ case MAP(0, 0x00, 0x04): /* CLZ */
+ case MAP(1, 0x00, 0x04):
+ case MAP(0, 0x00, 0x05): /* CLS */
+ case MAP(1, 0x00, 0x05):
unallocated_encoding(s);
break;
}
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
index dd44651f34..410eaa9333 100644
--- a/target/arm/tcg/a64.decode
+++ b/target/arm/tcg/a64.decode
@@ -696,6 +696,9 @@ REV16 . 10 11010110 00000 000001 ..... .....
@rr_sf
REV32 . 10 11010110 00000 000010 ..... ..... @rr_sf
REV64 1 10 11010110 00000 000011 ..... ..... @rr
+CLZ . 10 11010110 00000 000100 ..... ..... @rr_sf
+CLS . 10 11010110 00000 000101 ..... ..... @rr_sf
+
# Logical (shifted reg)
# Add/subtract (shifted reg)
# Add/subtract (extended reg)
--
2.43.0
- [PATCH v2 00/69] target/arm: AArch64 decodetree conversion, final part, Richard Henderson, 2024/12/10
- [PATCH v2 01/69] target/arm: Add section labels for "Data Processing (register)", Richard Henderson, 2024/12/10
- [PATCH v2 02/69] target/arm: Convert UDIV, SDIV to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 03/69] target/arm: Convert LSLV, LSRV, ASRV, RORV to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 04/69] target/arm: Convert CRC32, CRC32C to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 05/69] target/arm: Convert SUBP, IRG, GMI to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 06/69] target/arm: Convert PACGA to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 07/69] target/arm: Convert RBIT, REV16, REV32, REV64 to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 08/69] target/arm: Convert CLZ, CLS to decodetree,
Richard Henderson <=
- [PATCH v2 09/69] target/arm: Convert PAC[ID]*, AUT[ID]* to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 10/69] target/arm: Convert XPAC[ID] to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 11/69] target/arm: Convert disas_logic_reg to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 12/69] target/arm: Convert disas_add_sub_ext_reg to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 13/69] target/arm: Convert disas_add_sub_reg to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 14/69] target/arm: Convert disas_data_proc_3src to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 15/69] target/arm: Convert disas_adc_sbc to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 18/69] target/arm: Convert CCMP, CCMN to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 19/69] target/arm: Convert disas_cond_select to decodetree, Richard Henderson, 2024/12/10
- [PATCH v2 21/69] target/arm: Introduce fp_access_check_vector_hsd, Richard Henderson, 2024/12/10