~ubuntu-branches/ubuntu/vivid/qemu/vivid

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu/arm64/0120-target-arm-A64-Add-SIMD-modified-immediate-group.patch

  • Committer: Package Import Robot
  • Author(s): dann frazier
  • Date: 2014-02-11 15:41:53 UTC
  • Revision ID: package-import@ubuntu.com-20140211154153-2d001tf0ium08u81
Tags: 1.7.0+dfsg-3ubuntu2
* Backport changes to enable qemu-user-static support for aarch64
* debian/control: add ppc64el to Architectures
* debian/rules: only install qemu-system-aarch64 on arm64.
  Fixes a FTBFS  when built twice in a row on non-arm64 due to a stale
  debian/qemu-system-aarch64 directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
MIME-Version: 1.0
 
6
Content-Type: text/plain; charset=UTF-8
 
7
Content-Transfer-Encoding: 8bit
 
8
 
 
9
This patch adds support for the AdvSIMD modified immediate group
 
10
(C3.6.6) with all its suboperations (movi, orr, fmov, mvni, bic).
 
11
 
 
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>
 
17
---
 
18
 target-arm/translate-a64.c | 120 ++++++++++++++++++++++++++++++++++++++++++++-
 
19
 1 file changed, 119 insertions(+), 1 deletion(-)
 
20
 
 
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
  * +---+---+----+---------------------+-----+-------+----+---+-------+------+
 
29
+ *
 
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
 
35
  */
 
36
 static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
 
37
 {
 
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);
 
47
+    uint64_t imm = 0;
 
48
+    TCGv_i64 tcg_rd, tcg_imm;
 
49
+    int i;
 
50
+
 
51
+    if (o2 != 0 || ((cmode == 0xf) && is_neg && !is_q)) {
 
52
+        unallocated_encoding(s);
 
53
+        return;
 
54
+    }
 
55
+
 
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) */
 
62
+    {
 
63
+        int shift = cmode_3_1 * 8;
 
64
+        imm = bitfield_replicate(abcdefgh << shift, 32);
 
65
+        break;
 
66
+    }
 
67
+    case 4: /* Replicate(Zeros(8):imm8, 4) */
 
68
+    case 5: /* Replicate(imm8:Zeros(8), 4) */
 
69
+    {
 
70
+        int shift = (cmode_3_1 & 0x1) * 8;
 
71
+        imm = bitfield_replicate(abcdefgh << shift, 16);
 
72
+        break;
 
73
+    }
 
74
+    case 6:
 
75
+        if (cmode_0) {
 
76
+            /* Replicate(Zeros(8):imm8:Ones(16), 2) */
 
77
+            imm = (abcdefgh << 16) | 0xffff;
 
78
+        } else {
 
79
+            /* Replicate(Zeros(16):imm8:Ones(8), 2) */
 
80
+            imm = (abcdefgh << 8) | 0xff;
 
81
+        }
 
82
+        imm = bitfield_replicate(imm, 32);
 
83
+        break;
 
84
+    case 7:
 
85
+        if (!cmode_0 && !is_neg) {
 
86
+            imm = bitfield_replicate(abcdefgh, 8);
 
87
+        } else if (!cmode_0 && is_neg) {
 
88
+            int i;
 
89
+            imm = 0;
 
90
+            for (i = 0; i < 8; i++) {
 
91
+                if ((abcdefgh) & (1 << i)) {
 
92
+                    imm |= 0xffULL << (i * 8);
 
93
+                }
 
94
+            }
 
95
+        } else if (cmode_0) {
 
96
+            if (is_neg) {
 
97
+                imm = (abcdefgh & 0x3f) << 48;
 
98
+                if (abcdefgh & 0x80) {
 
99
+                    imm |= 0x8000000000000000ULL;
 
100
+                }
 
101
+                if (abcdefgh & 0x40) {
 
102
+                    imm |= 0x3fc0000000000000ULL;
 
103
+                } else {
 
104
+                    imm |= 0x4000000000000000ULL;
 
105
+                }
 
106
+            } else {
 
107
+                imm = (abcdefgh & 0x3f) << 19;
 
108
+                if (abcdefgh & 0x80) {
 
109
+                    imm |= 0x80000000;
 
110
+                }
 
111
+                if (abcdefgh & 0x40) {
 
112
+                    imm |= 0x3e000000;
 
113
+                } else {
 
114
+                    imm |= 0x40000000;
 
115
+                }
 
116
+                imm |= (imm << 32);
 
117
+            }
 
118
+        }
 
119
+        break;
 
120
+    }
 
121
+
 
122
+    if (cmode_3_1 != 7 && is_neg) {
 
123
+        imm = ~imm;
 
124
+    }
 
125
+
 
126
+    tcg_imm = tcg_const_i64(imm);
 
127
+    tcg_rd = new_tmp_a64(s);
 
128
+
 
129
+    for (i = 0; i < 2; i++) {
 
130
+        int foffs = i ? fp_reg_hi_offset(rd) : fp_reg_offset(rd, MO_64);
 
131
+
 
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);
 
137
+            if (is_neg) {
 
138
+                /* AND (BIC) */
 
139
+                tcg_gen_and_i64(tcg_rd, tcg_rd, tcg_imm);
 
140
+            } else {
 
141
+                /* ORR */
 
142
+                tcg_gen_or_i64(tcg_rd, tcg_rd, tcg_imm);
 
143
+            }
 
144
+        } else {
 
145
+            /* MOVI */
 
146
+            tcg_gen_mov_i64(tcg_rd, tcg_imm);
 
147
+        }
 
148
+        tcg_gen_st_i64(tcg_rd, cpu_env, foffs);
 
149
+    }
 
150
+
 
151
+    tcg_temp_free_i64(tcg_imm);
 
152
 }
 
153
 
 
154
 /* C3.6.7 AdvSIMD scalar copy
 
155
-- 
 
156
1.9.rc1
 
157