1
From d2d8369d25ced8ee94327b4feb3c97dc7d9c973f Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <alex.bennee@linaro.org>
3
Date: Fri, 31 Jan 2014 14:47:32 +0000
4
Subject: [PATCH 120/158] target-arm: A64: Add SIMD modified immediate group
6
Content-Type: text/plain; charset=UTF-8
7
Content-Transfer-Encoding: 8bit
9
This patch adds support for the AdvSIMD modified immediate group
10
(C3.6.6) with all its suboperations (movi, orr, fmov, mvni, bic).
12
Signed-off-by: Alexander Graf <agraf@suse.de>
13
[AJB: new decode struct, minor bug fixes, optimisation]
14
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <rth@twiddle.net>
18
target-arm/translate-a64.c | 120 ++++++++++++++++++++++++++++++++++++++++++++-
19
1 file changed, 119 insertions(+), 1 deletion(-)
21
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
22
index 6521f73..69c75c0 100644
23
--- a/target-arm/translate-a64.c
24
+++ b/target-arm/translate-a64.c
25
@@ -5293,10 +5293,128 @@ static void disas_simd_copy(DisasContext *s, uint32_t insn)
26
* +---+---+----+---------------------+-----+-------+----+---+-------+------+
27
* | 0 | Q | op | 0 1 1 1 1 0 0 0 0 0 | abc | cmode | o2 | 1 | defgh | Rd |
28
* +---+---+----+---------------------+-----+-------+----+---+-------+------+
30
+ * There are a number of operations that can be carried out here:
31
+ * MOVI - move (shifted) imm into register
32
+ * MVNI - move inverted (shifted) imm into register
33
+ * ORR - bitwise OR of (shifted) imm with register
34
+ * BIC - bitwise clear of (shifted) imm with register
36
static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
38
- unsupported_encoding(s, insn);
39
+ int rd = extract32(insn, 0, 5);
40
+ int cmode = extract32(insn, 12, 4);
41
+ int cmode_3_1 = extract32(cmode, 1, 3);
42
+ int cmode_0 = extract32(cmode, 0, 1);
43
+ int o2 = extract32(insn, 11, 1);
44
+ uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5);
45
+ bool is_neg = extract32(insn, 29, 1);
46
+ bool is_q = extract32(insn, 30, 1);
48
+ TCGv_i64 tcg_rd, tcg_imm;
51
+ if (o2 != 0 || ((cmode == 0xf) && is_neg && !is_q)) {
52
+ unallocated_encoding(s);
56
+ /* See AdvSIMDExpandImm() in ARM ARM */
57
+ switch (cmode_3_1) {
58
+ case 0: /* Replicate(Zeros(24):imm8, 2) */
59
+ case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */
60
+ case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */
61
+ case 3: /* Replicate(imm8:Zeros(24), 2) */
63
+ int shift = cmode_3_1 * 8;
64
+ imm = bitfield_replicate(abcdefgh << shift, 32);
67
+ case 4: /* Replicate(Zeros(8):imm8, 4) */
68
+ case 5: /* Replicate(imm8:Zeros(8), 4) */
70
+ int shift = (cmode_3_1 & 0x1) * 8;
71
+ imm = bitfield_replicate(abcdefgh << shift, 16);
76
+ /* Replicate(Zeros(8):imm8:Ones(16), 2) */
77
+ imm = (abcdefgh << 16) | 0xffff;
79
+ /* Replicate(Zeros(16):imm8:Ones(8), 2) */
80
+ imm = (abcdefgh << 8) | 0xff;
82
+ imm = bitfield_replicate(imm, 32);
85
+ if (!cmode_0 && !is_neg) {
86
+ imm = bitfield_replicate(abcdefgh, 8);
87
+ } else if (!cmode_0 && is_neg) {
90
+ for (i = 0; i < 8; i++) {
91
+ if ((abcdefgh) & (1 << i)) {
92
+ imm |= 0xffULL << (i * 8);
95
+ } else if (cmode_0) {
97
+ imm = (abcdefgh & 0x3f) << 48;
98
+ if (abcdefgh & 0x80) {
99
+ imm |= 0x8000000000000000ULL;
101
+ if (abcdefgh & 0x40) {
102
+ imm |= 0x3fc0000000000000ULL;
104
+ imm |= 0x4000000000000000ULL;
107
+ imm = (abcdefgh & 0x3f) << 19;
108
+ if (abcdefgh & 0x80) {
111
+ if (abcdefgh & 0x40) {
116
+ imm |= (imm << 32);
122
+ if (cmode_3_1 != 7 && is_neg) {
126
+ tcg_imm = tcg_const_i64(imm);
127
+ tcg_rd = new_tmp_a64(s);
129
+ for (i = 0; i < 2; i++) {
130
+ int foffs = i ? fp_reg_hi_offset(rd) : fp_reg_offset(rd, MO_64);
132
+ if (i == 1 && !is_q) {
133
+ /* non-quad ops clear high half of vector */
134
+ tcg_gen_movi_i64(tcg_rd, 0);
135
+ } else if ((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9) {
136
+ tcg_gen_ld_i64(tcg_rd, cpu_env, foffs);
139
+ tcg_gen_and_i64(tcg_rd, tcg_rd, tcg_imm);
142
+ tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_imm);
146
+ tcg_gen_mov_i64(tcg_rd, tcg_imm);
148
+ tcg_gen_st_i64(tcg_rd, cpu_env, foffs);
151
+ tcg_temp_free_i64(tcg_imm);
154
/* C3.6.7 AdvSIMD scalar copy