1
From ebce42385269c9cd63c1f9471aa825ef2b911165 Mon Sep 17 00:00:00 2001
2
From: Peter Maydell <peter.maydell@linaro.org>
3
Date: Mon, 3 Feb 2014 23:31:52 +0000
4
Subject: [PATCH 150/158] target-arm: A64: Add narrowing 2-reg-misc
7
Add the narrowing integer instructions in the 2-reg-misc class.
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <rth@twiddle.net>
12
target-arm/translate-a64.c | 85 ++++++++++++++++++++++++++++++++++++++++++++--
13
1 file changed, 83 insertions(+), 2 deletions(-)
15
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
16
index dd1bbeb..42457e4 100644
17
--- a/target-arm/translate-a64.c
18
+++ b/target-arm/translate-a64.c
19
@@ -75,6 +75,8 @@ typedef struct AArch64DecodeTable {
20
/* Function prototype for gen_ functions for calling Neon helpers */
21
typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32);
22
typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32);
23
+typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64);
24
+typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64);
26
/* initialize TCG globals. */
27
void a64_translate_init(void)
28
@@ -7371,6 +7373,79 @@ static void disas_simd_three_reg_same(DisasContext *s, uint32_t insn)
32
+static void handle_2misc_narrow(DisasContext *s, int opcode, bool u, bool is_q,
33
+ int size, int rn, int rd)
35
+ /* Handle 2-reg-misc ops which are narrowing (so each 2*size element
36
+ * in the source becomes a size element in the destination).
39
+ TCGv_i32 tcg_res[2];
40
+ int destelt = is_q ? 2 : 0;
42
+ for (pass = 0; pass < 2; pass++) {
43
+ TCGv_i64 tcg_op = tcg_temp_new_i64();
44
+ NeonGenNarrowFn *genfn = NULL;
45
+ NeonGenNarrowEnvFn *genenvfn = NULL;
47
+ read_vec_element(s, tcg_op, rn, pass, MO_64);
48
+ tcg_res[pass] = tcg_temp_new_i32();
51
+ case 0x12: /* XTN, SQXTUN */
53
+ static NeonGenNarrowFn * const xtnfns[3] = {
54
+ gen_helper_neon_narrow_u8,
55
+ gen_helper_neon_narrow_u16,
56
+ tcg_gen_trunc_i64_i32,
58
+ static NeonGenNarrowEnvFn * const sqxtunfns[3] = {
59
+ gen_helper_neon_unarrow_sat8,
60
+ gen_helper_neon_unarrow_sat16,
61
+ gen_helper_neon_unarrow_sat32,
64
+ genenvfn = sqxtunfns[size];
66
+ genfn = xtnfns[size];
70
+ case 0x14: /* SQXTN, UQXTN */
72
+ static NeonGenNarrowEnvFn * const fns[3][2] = {
73
+ { gen_helper_neon_narrow_sat_s8,
74
+ gen_helper_neon_narrow_sat_u8 },
75
+ { gen_helper_neon_narrow_sat_s16,
76
+ gen_helper_neon_narrow_sat_u16 },
77
+ { gen_helper_neon_narrow_sat_s32,
78
+ gen_helper_neon_narrow_sat_u32 },
80
+ genenvfn = fns[size][u];
84
+ g_assert_not_reached();
88
+ genfn(tcg_res[pass], tcg_op);
90
+ genenvfn(tcg_res[pass], cpu_env, tcg_op);
93
+ tcg_temp_free_i64(tcg_op);
96
+ for (pass = 0; pass < 2; pass++) {
97
+ write_vec_element_i32(s, tcg_res[pass], rd, destelt + pass, MO_32);
98
+ tcg_temp_free_i32(tcg_res[pass]);
101
+ clear_vec_high(s, rd);
105
/* C3.6.17 AdvSIMD two reg misc
106
* 31 30 29 28 24 23 22 21 17 16 12 11 10 9 5 4 0
107
* +---+---+---+-----------+------+-----------+--------+-----+------+------+
108
@@ -7405,11 +7480,17 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
110
unallocated_encoding(s);
112
+ case 0x12: /* XTN, XTN2, SQXTUN, SQXTUN2 */
113
+ case 0x14: /* SQXTN, SQXTN2, UQXTN, UQXTN2 */
115
+ unallocated_encoding(s);
118
+ handle_2misc_narrow(s, opcode, u, is_q, size, rn, rd);
120
case 0x2: /* SADDLP, UADDLP */
121
case 0x4: /* CLS, CLZ */
122
case 0x6: /* SADALP, UADALP */
123
- case 0x12: /* XTN, XTN2, SQXTUN, SQXTUN2 */
124
- case 0x14: /* SQXTN, SQXTN2, UQXTN, UQXTN2 */
126
unallocated_encoding(s);