1
From 3716264c13b3ce89232862da1a86ae2d313cccce Mon Sep 17 00:00:00 2001
2
From: Claudio Fontana <claudio.fontana@linaro.org>
3
Date: Tue, 17 Dec 2013 19:42:35 +0000
4
Subject: [PATCH 47/49] target-arm: A64: add support for 1-src CLS insn
6
this patch adds support for the CLS instruction.
8
Signed-off-by: Claudio Fontana <claudio.fontana@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <rth@twiddle.net>
12
target-arm/helper-a64.c | 10 ++++++++++
13
target-arm/helper-a64.h | 2 ++
14
target-arm/translate-a64.c | 20 +++++++++++++++++++-
15
3 files changed, 31 insertions(+), 1 deletion(-)
17
diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
18
index cccaac6..d3f7067 100644
19
--- a/target-arm/helper-a64.c
20
+++ b/target-arm/helper-a64.c
21
@@ -50,6 +50,16 @@ uint64_t HELPER(clz64)(uint64_t x)
25
+uint64_t HELPER(cls64)(uint64_t x)
30
+uint32_t HELPER(cls32)(uint32_t x)
35
uint64_t HELPER(rbit64)(uint64_t x)
37
/* assign the correct byte position */
38
diff --git a/target-arm/helper-a64.h b/target-arm/helper-a64.h
39
index 9959139..a163a94 100644
40
--- a/target-arm/helper-a64.h
41
+++ b/target-arm/helper-a64.h
43
DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
44
DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
45
DEF_HELPER_FLAGS_1(clz64, TCG_CALL_NO_RWG_SE, i64, i64)
46
+DEF_HELPER_FLAGS_1(cls64, TCG_CALL_NO_RWG_SE, i64, i64)
47
+DEF_HELPER_FLAGS_1(cls32, TCG_CALL_NO_RWG_SE, i32, i32)
48
DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64)
49
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
50
index 2111bcd..2bb1795 100644
51
--- a/target-arm/translate-a64.c
52
+++ b/target-arm/translate-a64.c
53
@@ -1114,6 +1114,24 @@ static void handle_clz(DisasContext *s, unsigned int sf,
57
+static void handle_cls(DisasContext *s, unsigned int sf,
58
+ unsigned int rn, unsigned int rd)
60
+ TCGv_i64 tcg_rd, tcg_rn;
61
+ tcg_rd = cpu_reg(s, rd);
62
+ tcg_rn = cpu_reg(s, rn);
65
+ gen_helper_cls64(tcg_rd, tcg_rn);
67
+ TCGv_i32 tcg_tmp32 = tcg_temp_new_i32();
68
+ tcg_gen_trunc_i64_i32(tcg_tmp32, tcg_rn);
69
+ gen_helper_cls32(tcg_tmp32, tcg_tmp32);
70
+ tcg_gen_extu_i32_i64(tcg_rd, tcg_tmp32);
71
+ tcg_temp_free_i32(tcg_tmp32);
75
static void handle_rbit(DisasContext *s, unsigned int sf,
76
unsigned int rn, unsigned int rd)
78
@@ -1236,7 +1254,7 @@ static void disas_data_proc_1src(DisasContext *s, uint32_t insn)
79
handle_clz(s, sf, rn, rd);
82
- unsupported_encoding(s, insn);
83
+ handle_cls(s, sf, rn, rd);