[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 47/60] AArch64: Add clz instruction emulation
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH 47/60] AArch64: Add clz instruction emulation |
Date: |
Fri, 27 Sep 2013 02:48:41 +0200 |
This patch adds emlulation support for the clz instruction.
Signed-off-by: Alexander Graf <address@hidden>
---
target-arm/helper-a64.c | 5 +++++
target-arm/helper-a64.h | 1 +
target-arm/translate-a64.c | 31 +++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
index e20b89f..a8a8499 100644
--- a/target-arm/helper-a64.c
+++ b/target-arm/helper-a64.c
@@ -256,3 +256,8 @@ uint64_t HELPER(rbit64)(uint64_t x)
| ((x & 0x1111111111111111ULL) << 3);
return x;
}
+
+uint64_t HELPER(clz64)(uint64_t x)
+{
+ return clz64(x);
+}
diff --git a/target-arm/helper-a64.h b/target-arm/helper-a64.h
index 5e5cda0..607ba8a 100644
--- a/target-arm/helper-a64.h
+++ b/target-arm/helper-a64.h
@@ -27,3 +27,4 @@ DEF_HELPER_FLAGS_4(cinc, TCG_CALL_NO_RWG_SE, i64, i32, i32,
i64, i64)
DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64)
+DEF_HELPER_FLAGS_1(clz64, TCG_CALL_NO_RWG_SE, i64, i64)
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
index 208d06b..db55389 100644
--- a/target-arm/translate-a64.c
+++ b/target-arm/translate-a64.c
@@ -1602,6 +1602,35 @@ static void handle_rev(DisasContext *s, uint32_t insn)
}
}
+static void handle_clz(DisasContext *s, uint32_t insn)
+{
+ int rd = get_reg(insn);
+ int rn = get_bits(insn, 5, 5);
+ int opc = get_bits(insn, 10, 2);
+ bool is_32bit = !get_bits(insn, 31, 1);
+ TCGv_i64 tcg_val = tcg_temp_new_i64();
+
+ if (is_32bit) {
+ tcg_gen_ext32u_i64(tcg_val, cpu_reg(rn));
+ } else {
+ tcg_gen_mov_i64(tcg_val, cpu_reg(rn));
+ }
+
+ switch (opc) {
+ case 0x0: /* CLZ */
+ gen_helper_clz64(cpu_reg(rd), tcg_val);
+ if (is_32bit) {
+ tcg_gen_subi_i64(cpu_reg(rd), cpu_reg(rd), 32);
+ }
+ break;
+ case 0x1: /* CLS */
+ unallocated_encoding(s);
+ break;
+ }
+
+ tcg_temp_free_i64(tcg_val);
+}
+
/* SIMD ORR */
static void handle_simdorr(DisasContext *s, uint32_t insn)
{
@@ -2170,6 +2199,8 @@ void disas_a64_insn(CPUARMState *env, DisasContext *s)
handle_shift_reg(s, insn);
} else if ((insn & 0x7ffff000) == 0x5ac00000) {
handle_rev(s, insn);
+ } else if ((insn & 0x7ffff800) == 0x5ac01000) {
+ handle_clz(s, insn);
} else {
unallocated_encoding(s);
}
--
1.7.12.4
- [Qemu-devel] [PATCH 33/60] AArch64: Add bc instruction emulation, (continued)
- [Qemu-devel] [PATCH 33/60] AArch64: Add bc instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 38/60] AArch64: Add stub barrier instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 21/60] AArch64: Convert SIMD load/store to common function, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 36/60] AArch64: Add msr instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 37/60] AArch64: Add hint instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 39/60] AArch64: Add stub sys instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 34/60] AArch64: Add b.cond instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 43/60] AArch64: Add cinc instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 45/60] AArch64: Add shift instruction family emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 47/60] AArch64: Add clz instruction emulation,
Alexander Graf <=
- [Qemu-devel] [PATCH 40/60] AArch64: Add tbz instruction emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 46/60] AArch64: Add rev instruction family emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 48/60] AArch64: Add 0x1a encoding of add instructions, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 44/60] AArch64: Add division instruction family emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 41/60] AArch64: Add ldr/str instruction family emulation, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 49/60] AArch64: Add "Data-processing (3 source)" instruction, Alexander Graf, 2013/09/26
- [Qemu-devel] [PATCH 51/60] AArch64: Add fmov (scalar, immediate) instruction, Alexander Graf, 2013/09/26