root / target-arm / iwmmxt_helper.c @ 36802b6b
History | View | Annotate | Download (23.7 kB)
1 | e677137d | pbrook | /*
|
---|---|---|---|
2 | e677137d | pbrook | * iwMMXt micro operations for XScale.
|
3 | e677137d | pbrook | *
|
4 | e677137d | pbrook | * Copyright (c) 2007 OpenedHand, Ltd.
|
5 | e677137d | pbrook | * Written by Andrzej Zaborowski <andrew@openedhand.com>
|
6 | e677137d | pbrook | * Copyright (c) 2008 CodeSourcery
|
7 | e677137d | pbrook | *
|
8 | e677137d | pbrook | * This library is free software; you can redistribute it and/or
|
9 | e677137d | pbrook | * modify it under the terms of the GNU Lesser General Public
|
10 | e677137d | pbrook | * License as published by the Free Software Foundation; either
|
11 | e677137d | pbrook | * version 2 of the License, or (at your option) any later version.
|
12 | e677137d | pbrook | *
|
13 | e677137d | pbrook | * This library is distributed in the hope that it will be useful,
|
14 | e677137d | pbrook | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 | e677137d | pbrook | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16 | e677137d | pbrook | * Lesser General Public License for more details.
|
17 | e677137d | pbrook | *
|
18 | e677137d | pbrook | * You should have received a copy of the GNU Lesser General Public
|
19 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
20 | e677137d | pbrook | */
|
21 | e677137d | pbrook | |
22 | e677137d | pbrook | #include <stdlib.h> |
23 | e677137d | pbrook | #include <stdio.h> |
24 | e677137d | pbrook | |
25 | e677137d | pbrook | #include "cpu.h" |
26 | 947a2fa2 | Peter Maydell | #include "exec.h" |
27 | 7b59220e | Lluís | #include "helper.h" |
28 | e677137d | pbrook | |
29 | e677137d | pbrook | /* iwMMXt macros extracted from GNU gdb. */
|
30 | e677137d | pbrook | |
31 | e677137d | pbrook | /* Set the SIMD wCASF flags for 8, 16, 32 or 64-bit operations. */
|
32 | e677137d | pbrook | #define SIMD8_SET( v, n, b) ((v != 0) << ((((b) + 1) * 4) + (n))) |
33 | e677137d | pbrook | #define SIMD16_SET(v, n, h) ((v != 0) << ((((h) + 1) * 8) + (n))) |
34 | e677137d | pbrook | #define SIMD32_SET(v, n, w) ((v != 0) << ((((w) + 1) * 16) + (n))) |
35 | e677137d | pbrook | #define SIMD64_SET(v, n) ((v != 0) << (32 + (n))) |
36 | e677137d | pbrook | /* Flags to pass as "n" above. */
|
37 | e677137d | pbrook | #define SIMD_NBIT -1 |
38 | e677137d | pbrook | #define SIMD_ZBIT -2 |
39 | e677137d | pbrook | #define SIMD_CBIT -3 |
40 | e677137d | pbrook | #define SIMD_VBIT -4 |
41 | e677137d | pbrook | /* Various status bit macros. */
|
42 | e677137d | pbrook | #define NBIT8(x) ((x) & 0x80) |
43 | e677137d | pbrook | #define NBIT16(x) ((x) & 0x8000) |
44 | e677137d | pbrook | #define NBIT32(x) ((x) & 0x80000000) |
45 | e677137d | pbrook | #define NBIT64(x) ((x) & 0x8000000000000000ULL) |
46 | e677137d | pbrook | #define ZBIT8(x) (((x) & 0xff) == 0) |
47 | e677137d | pbrook | #define ZBIT16(x) (((x) & 0xffff) == 0) |
48 | e677137d | pbrook | #define ZBIT32(x) (((x) & 0xffffffff) == 0) |
49 | e677137d | pbrook | #define ZBIT64(x) (x == 0) |
50 | e677137d | pbrook | /* Sign extension macros. */
|
51 | e677137d | pbrook | #define EXTEND8H(a) ((uint16_t) (int8_t) (a))
|
52 | e677137d | pbrook | #define EXTEND8(a) ((uint32_t) (int8_t) (a))
|
53 | e677137d | pbrook | #define EXTEND16(a) ((uint32_t) (int16_t) (a))
|
54 | e677137d | pbrook | #define EXTEND16S(a) ((int32_t) (int16_t) (a))
|
55 | e677137d | pbrook | #define EXTEND32(a) ((uint64_t) (int32_t) (a))
|
56 | e677137d | pbrook | |
57 | e677137d | pbrook | uint64_t HELPER(iwmmxt_maddsq)(uint64_t a, uint64_t b) |
58 | e677137d | pbrook | { |
59 | e677137d | pbrook | a = (( |
60 | e677137d | pbrook | EXTEND16S((a >> 0) & 0xffff) * EXTEND16S((b >> 0) & 0xffff) + |
61 | e677137d | pbrook | EXTEND16S((a >> 16) & 0xffff) * EXTEND16S((b >> 16) & 0xffff) |
62 | e677137d | pbrook | ) & 0xffffffff) | ((uint64_t) (
|
63 | e677137d | pbrook | EXTEND16S((a >> 32) & 0xffff) * EXTEND16S((b >> 32) & 0xffff) + |
64 | e677137d | pbrook | EXTEND16S((a >> 48) & 0xffff) * EXTEND16S((b >> 48) & 0xffff) |
65 | e677137d | pbrook | ) << 32);
|
66 | e677137d | pbrook | return a;
|
67 | e677137d | pbrook | } |
68 | e677137d | pbrook | |
69 | e677137d | pbrook | uint64_t HELPER(iwmmxt_madduq)(uint64_t a, uint64_t b) |
70 | e677137d | pbrook | { |
71 | e677137d | pbrook | a = (( |
72 | e677137d | pbrook | ((a >> 0) & 0xffff) * ((b >> 0) & 0xffff) + |
73 | e677137d | pbrook | ((a >> 16) & 0xffff) * ((b >> 16) & 0xffff) |
74 | e677137d | pbrook | ) & 0xffffffff) | ((
|
75 | e677137d | pbrook | ((a >> 32) & 0xffff) * ((b >> 32) & 0xffff) + |
76 | e677137d | pbrook | ((a >> 48) & 0xffff) * ((b >> 48) & 0xffff) |
77 | e677137d | pbrook | ) << 32);
|
78 | e677137d | pbrook | return a;
|
79 | e677137d | pbrook | } |
80 | e677137d | pbrook | |
81 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sadb)(uint64_t a, uint64_t b) |
82 | e677137d | pbrook | { |
83 | e677137d | pbrook | #define abs(x) (((x) >= 0) ? x : -x) |
84 | e677137d | pbrook | #define SADB(SHR) abs((int) ((a >> SHR) & 0xff) - (int) ((b >> SHR) & 0xff)) |
85 | e677137d | pbrook | return
|
86 | e677137d | pbrook | SADB(0) + SADB(8) + SADB(16) + SADB(24) + |
87 | e677137d | pbrook | SADB(32) + SADB(40) + SADB(48) + SADB(56); |
88 | e677137d | pbrook | #undef SADB
|
89 | e677137d | pbrook | } |
90 | e677137d | pbrook | |
91 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sadw)(uint64_t a, uint64_t b) |
92 | e677137d | pbrook | { |
93 | e677137d | pbrook | #define SADW(SHR) \
|
94 | e677137d | pbrook | abs((int) ((a >> SHR) & 0xffff) - (int) ((b >> SHR) & 0xffff)) |
95 | e677137d | pbrook | return SADW(0) + SADW(16) + SADW(32) + SADW(48); |
96 | e677137d | pbrook | #undef SADW
|
97 | e677137d | pbrook | } |
98 | e677137d | pbrook | |
99 | e677137d | pbrook | uint64_t HELPER(iwmmxt_mulslw)(uint64_t a, uint64_t b) |
100 | e677137d | pbrook | { |
101 | e677137d | pbrook | #define MULS(SHR) ((uint64_t) ((( \
|
102 | e677137d | pbrook | EXTEND16S((a >> SHR) & 0xffff) * EXTEND16S((b >> SHR) & 0xffff) \ |
103 | e677137d | pbrook | ) >> 0) & 0xffff) << SHR) |
104 | e677137d | pbrook | return MULS(0) | MULS(16) | MULS(32) | MULS(48); |
105 | e677137d | pbrook | #undef MULS
|
106 | e677137d | pbrook | } |
107 | e677137d | pbrook | |
108 | e677137d | pbrook | uint64_t HELPER(iwmmxt_mulshw)(uint64_t a, uint64_t b) |
109 | e677137d | pbrook | { |
110 | e677137d | pbrook | #define MULS(SHR) ((uint64_t) ((( \
|
111 | e677137d | pbrook | EXTEND16S((a >> SHR) & 0xffff) * EXTEND16S((b >> SHR) & 0xffff) \ |
112 | e677137d | pbrook | ) >> 16) & 0xffff) << SHR) |
113 | e677137d | pbrook | return MULS(0) | MULS(16) | MULS(32) | MULS(48); |
114 | e677137d | pbrook | #undef MULS
|
115 | e677137d | pbrook | } |
116 | e677137d | pbrook | |
117 | e677137d | pbrook | uint64_t HELPER(iwmmxt_mululw)(uint64_t a, uint64_t b) |
118 | e677137d | pbrook | { |
119 | e677137d | pbrook | #define MULU(SHR) ((uint64_t) ((( \
|
120 | e677137d | pbrook | ((a >> SHR) & 0xffff) * ((b >> SHR) & 0xffff) \ |
121 | e677137d | pbrook | ) >> 0) & 0xffff) << SHR) |
122 | e677137d | pbrook | return MULU(0) | MULU(16) | MULU(32) | MULU(48); |
123 | e677137d | pbrook | #undef MULU
|
124 | e677137d | pbrook | } |
125 | e677137d | pbrook | |
126 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muluhw)(uint64_t a, uint64_t b) |
127 | e677137d | pbrook | { |
128 | e677137d | pbrook | #define MULU(SHR) ((uint64_t) ((( \
|
129 | e677137d | pbrook | ((a >> SHR) & 0xffff) * ((b >> SHR) & 0xffff) \ |
130 | e677137d | pbrook | ) >> 16) & 0xffff) << SHR) |
131 | e677137d | pbrook | return MULU(0) | MULU(16) | MULU(32) | MULU(48); |
132 | e677137d | pbrook | #undef MULU
|
133 | e677137d | pbrook | } |
134 | e677137d | pbrook | |
135 | e677137d | pbrook | uint64_t HELPER(iwmmxt_macsw)(uint64_t a, uint64_t b) |
136 | e677137d | pbrook | { |
137 | e677137d | pbrook | #define MACS(SHR) ( \
|
138 | e677137d | pbrook | EXTEND16((a >> SHR) & 0xffff) * EXTEND16S((b >> SHR) & 0xffff)) |
139 | e677137d | pbrook | return (int64_t) (MACS(0) + MACS(16) + MACS(32) + MACS(48)); |
140 | e677137d | pbrook | #undef MACS
|
141 | e677137d | pbrook | } |
142 | e677137d | pbrook | |
143 | e677137d | pbrook | uint64_t HELPER(iwmmxt_macuw)(uint64_t a, uint64_t b) |
144 | e677137d | pbrook | { |
145 | e677137d | pbrook | #define MACU(SHR) ( \
|
146 | e677137d | pbrook | (uint32_t) ((a >> SHR) & 0xffff) * \
|
147 | e677137d | pbrook | (uint32_t) ((b >> SHR) & 0xffff))
|
148 | e677137d | pbrook | return MACU(0) + MACU(16) + MACU(32) + MACU(48); |
149 | e677137d | pbrook | #undef MACU
|
150 | e677137d | pbrook | } |
151 | e677137d | pbrook | |
152 | e677137d | pbrook | #define NZBIT8(x, i) \
|
153 | e677137d | pbrook | SIMD8_SET(NBIT8((x) & 0xff), SIMD_NBIT, i) | \
|
154 | e677137d | pbrook | SIMD8_SET(ZBIT8((x) & 0xff), SIMD_ZBIT, i)
|
155 | e677137d | pbrook | #define NZBIT16(x, i) \
|
156 | e677137d | pbrook | SIMD16_SET(NBIT16((x) & 0xffff), SIMD_NBIT, i) | \
|
157 | e677137d | pbrook | SIMD16_SET(ZBIT16((x) & 0xffff), SIMD_ZBIT, i)
|
158 | e677137d | pbrook | #define NZBIT32(x, i) \
|
159 | e677137d | pbrook | SIMD32_SET(NBIT32((x) & 0xffffffff), SIMD_NBIT, i) | \
|
160 | e677137d | pbrook | SIMD32_SET(ZBIT32((x) & 0xffffffff), SIMD_ZBIT, i)
|
161 | e677137d | pbrook | #define NZBIT64(x) \
|
162 | e677137d | pbrook | SIMD64_SET(NBIT64(x), SIMD_NBIT) | \ |
163 | e677137d | pbrook | SIMD64_SET(ZBIT64(x), SIMD_ZBIT) |
164 | e677137d | pbrook | #define IWMMXT_OP_UNPACK(S, SH0, SH1, SH2, SH3) \
|
165 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, b)))(uint64_t a, uint64_t b) \ |
166 | e677137d | pbrook | { \ |
167 | e677137d | pbrook | a = \ |
168 | e677137d | pbrook | (((a >> SH0) & 0xff) << 0) | (((b >> SH0) & 0xff) << 8) | \ |
169 | e677137d | pbrook | (((a >> SH1) & 0xff) << 16) | (((b >> SH1) & 0xff) << 24) | \ |
170 | e677137d | pbrook | (((a >> SH2) & 0xff) << 32) | (((b >> SH2) & 0xff) << 40) | \ |
171 | e677137d | pbrook | (((a >> SH3) & 0xff) << 48) | (((b >> SH3) & 0xff) << 56); \ |
172 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
173 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \ |
174 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \ |
175 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \ |
176 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \ |
177 | e677137d | pbrook | return a; \
|
178 | e677137d | pbrook | } \ |
179 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, w)))(uint64_t a, uint64_t b) \ |
180 | e677137d | pbrook | { \ |
181 | e677137d | pbrook | a = \ |
182 | e677137d | pbrook | (((a >> SH0) & 0xffff) << 0) | \ |
183 | e677137d | pbrook | (((b >> SH0) & 0xffff) << 16) | \ |
184 | e677137d | pbrook | (((a >> SH2) & 0xffff) << 32) | \ |
185 | e677137d | pbrook | (((b >> SH2) & 0xffff) << 48); \ |
186 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
187 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 16, 1) | \ |
188 | e677137d | pbrook | NZBIT8(a >> 32, 2) | NZBIT8(a >> 48, 3); \ |
189 | e677137d | pbrook | return a; \
|
190 | e677137d | pbrook | } \ |
191 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, l)))(uint64_t a, uint64_t b) \ |
192 | e677137d | pbrook | { \ |
193 | e677137d | pbrook | a = \ |
194 | e677137d | pbrook | (((a >> SH0) & 0xffffffff) << 0) | \ |
195 | e677137d | pbrook | (((b >> SH0) & 0xffffffff) << 32); \ |
196 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
197 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \ |
198 | e677137d | pbrook | return a; \
|
199 | e677137d | pbrook | } \ |
200 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ub)))(uint64_t x) \ |
201 | e677137d | pbrook | { \ |
202 | e677137d | pbrook | x = \ |
203 | e677137d | pbrook | (((x >> SH0) & 0xff) << 0) | \ |
204 | e677137d | pbrook | (((x >> SH1) & 0xff) << 16) | \ |
205 | e677137d | pbrook | (((x >> SH2) & 0xff) << 32) | \ |
206 | e677137d | pbrook | (((x >> SH3) & 0xff) << 48); \ |
207 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
208 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \ |
209 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \ |
210 | e677137d | pbrook | return x; \
|
211 | e677137d | pbrook | } \ |
212 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, uw)))(uint64_t x) \ |
213 | e677137d | pbrook | { \ |
214 | e677137d | pbrook | x = \ |
215 | e677137d | pbrook | (((x >> SH0) & 0xffff) << 0) | \ |
216 | e677137d | pbrook | (((x >> SH2) & 0xffff) << 32); \ |
217 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
218 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \ |
219 | e677137d | pbrook | return x; \
|
220 | e677137d | pbrook | } \ |
221 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ul)))(uint64_t x) \ |
222 | e677137d | pbrook | { \ |
223 | e677137d | pbrook | x = (((x >> SH0) & 0xffffffff) << 0); \ |
224 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
|
225 | e677137d | pbrook | return x; \
|
226 | e677137d | pbrook | } \ |
227 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sb)))(uint64_t x) \ |
228 | e677137d | pbrook | { \ |
229 | e677137d | pbrook | x = \ |
230 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH0) & 0xff) << 0) | \ |
231 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH1) & 0xff) << 16) | \ |
232 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH2) & 0xff) << 32) | \ |
233 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH3) & 0xff) << 48); \ |
234 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
235 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \ |
236 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \ |
237 | e677137d | pbrook | return x; \
|
238 | e677137d | pbrook | } \ |
239 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sw)))(uint64_t x) \ |
240 | e677137d | pbrook | { \ |
241 | e677137d | pbrook | x = \ |
242 | e677137d | pbrook | ((uint64_t) EXTEND16((x >> SH0) & 0xffff) << 0) | \ |
243 | e677137d | pbrook | ((uint64_t) EXTEND16((x >> SH2) & 0xffff) << 32); \ |
244 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
245 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \ |
246 | e677137d | pbrook | return x; \
|
247 | e677137d | pbrook | } \ |
248 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sl)))(uint64_t x) \ |
249 | e677137d | pbrook | { \ |
250 | e677137d | pbrook | x = EXTEND32((x >> SH0) & 0xffffffff); \
|
251 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
|
252 | e677137d | pbrook | return x; \
|
253 | e677137d | pbrook | } |
254 | e677137d | pbrook | IWMMXT_OP_UNPACK(l, 0, 8, 16, 24) |
255 | e677137d | pbrook | IWMMXT_OP_UNPACK(h, 32, 40, 48, 56) |
256 | e677137d | pbrook | |
257 | e677137d | pbrook | #define IWMMXT_OP_CMP(SUFF, Tb, Tw, Tl, O) \
|
258 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, b)))(uint64_t a, uint64_t b) \ |
259 | e677137d | pbrook | { \ |
260 | e677137d | pbrook | a = \ |
261 | e677137d | pbrook | CMP(0, Tb, O, 0xff) | CMP(8, Tb, O, 0xff) | \ |
262 | e677137d | pbrook | CMP(16, Tb, O, 0xff) | CMP(24, Tb, O, 0xff) | \ |
263 | e677137d | pbrook | CMP(32, Tb, O, 0xff) | CMP(40, Tb, O, 0xff) | \ |
264 | e677137d | pbrook | CMP(48, Tb, O, 0xff) | CMP(56, Tb, O, 0xff); \ |
265 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
266 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \ |
267 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \ |
268 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \ |
269 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \ |
270 | e677137d | pbrook | return a; \
|
271 | e677137d | pbrook | } \ |
272 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, w)))(uint64_t a, uint64_t b) \ |
273 | e677137d | pbrook | { \ |
274 | e677137d | pbrook | a = CMP(0, Tw, O, 0xffff) | CMP(16, Tw, O, 0xffff) | \ |
275 | e677137d | pbrook | CMP(32, Tw, O, 0xffff) | CMP(48, Tw, O, 0xffff); \ |
276 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
277 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | \ |
278 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); \ |
279 | e677137d | pbrook | return a; \
|
280 | e677137d | pbrook | } \ |
281 | 947a2fa2 | Peter Maydell | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, l)))(uint64_t a, uint64_t b) \ |
282 | e677137d | pbrook | { \ |
283 | e677137d | pbrook | a = CMP(0, Tl, O, 0xffffffff) | \ |
284 | e677137d | pbrook | CMP(32, Tl, O, 0xffffffff); \ |
285 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
286 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \ |
287 | e677137d | pbrook | return a; \
|
288 | e677137d | pbrook | } |
289 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((((TYPE) ((a >> SHR) & MASK) OPER \
|
290 | e677137d | pbrook | (TYPE) ((b >> SHR) & MASK)) ? (uint64_t) MASK : 0) << SHR)
|
291 | e677137d | pbrook | IWMMXT_OP_CMP(cmpeq, uint8_t, uint16_t, uint32_t, ==) |
292 | e677137d | pbrook | IWMMXT_OP_CMP(cmpgts, int8_t, int16_t, int32_t, >) |
293 | e677137d | pbrook | IWMMXT_OP_CMP(cmpgtu, uint8_t, uint16_t, uint32_t, >) |
294 | e677137d | pbrook | #undef CMP
|
295 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((((TYPE) ((a >> SHR) & MASK) OPER \
|
296 | e677137d | pbrook | (TYPE) ((b >> SHR) & MASK)) ? a : b) & ((uint64_t) MASK << SHR)) |
297 | e677137d | pbrook | IWMMXT_OP_CMP(mins, int8_t, int16_t, int32_t, <) |
298 | e677137d | pbrook | IWMMXT_OP_CMP(minu, uint8_t, uint16_t, uint32_t, <) |
299 | e677137d | pbrook | IWMMXT_OP_CMP(maxs, int8_t, int16_t, int32_t, >) |
300 | e677137d | pbrook | IWMMXT_OP_CMP(maxu, uint8_t, uint16_t, uint32_t, >) |
301 | e677137d | pbrook | #undef CMP
|
302 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((uint64_t) (((TYPE) ((a >> SHR) & MASK) \
|
303 | e677137d | pbrook | OPER (TYPE) ((b >> SHR) & MASK)) & MASK) << SHR) |
304 | e677137d | pbrook | IWMMXT_OP_CMP(subn, uint8_t, uint16_t, uint32_t, -) |
305 | e677137d | pbrook | IWMMXT_OP_CMP(addn, uint8_t, uint16_t, uint32_t, +) |
306 | e677137d | pbrook | #undef CMP
|
307 | e677137d | pbrook | /* TODO Signed- and Unsigned-Saturation */
|
308 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((uint64_t) (((TYPE) ((a >> SHR) & MASK) \
|
309 | e677137d | pbrook | OPER (TYPE) ((b >> SHR) & MASK)) & MASK) << SHR) |
310 | e677137d | pbrook | IWMMXT_OP_CMP(subu, uint8_t, uint16_t, uint32_t, -) |
311 | e677137d | pbrook | IWMMXT_OP_CMP(addu, uint8_t, uint16_t, uint32_t, +) |
312 | e677137d | pbrook | IWMMXT_OP_CMP(subs, int8_t, int16_t, int32_t, -) |
313 | e677137d | pbrook | IWMMXT_OP_CMP(adds, int8_t, int16_t, int32_t, +) |
314 | e677137d | pbrook | #undef CMP
|
315 | e677137d | pbrook | #undef IWMMXT_OP_CMP
|
316 | e677137d | pbrook | |
317 | e677137d | pbrook | #define AVGB(SHR) ((( \
|
318 | e677137d | pbrook | ((a >> SHR) & 0xff) + ((b >> SHR) & 0xff) + round) >> 1) << SHR) |
319 | e677137d | pbrook | #define IWMMXT_OP_AVGB(r) \
|
320 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_avgb##r)(uint64_t a, uint64_t b) \ |
321 | e677137d | pbrook | { \ |
322 | e677137d | pbrook | const int round = r; \ |
323 | e677137d | pbrook | a = AVGB(0) | AVGB(8) | AVGB(16) | AVGB(24) | \ |
324 | e677137d | pbrook | AVGB(32) | AVGB(40) | AVGB(48) | AVGB(56); \ |
325 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
326 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 0) & 0xff), SIMD_ZBIT, 0) | \ |
327 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 8) & 0xff), SIMD_ZBIT, 1) | \ |
328 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 16) & 0xff), SIMD_ZBIT, 2) | \ |
329 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 24) & 0xff), SIMD_ZBIT, 3) | \ |
330 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 32) & 0xff), SIMD_ZBIT, 4) | \ |
331 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 40) & 0xff), SIMD_ZBIT, 5) | \ |
332 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 48) & 0xff), SIMD_ZBIT, 6) | \ |
333 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 56) & 0xff), SIMD_ZBIT, 7); \ |
334 | e677137d | pbrook | return a; \
|
335 | e677137d | pbrook | } |
336 | e677137d | pbrook | IWMMXT_OP_AVGB(0)
|
337 | e677137d | pbrook | IWMMXT_OP_AVGB(1)
|
338 | e677137d | pbrook | #undef IWMMXT_OP_AVGB
|
339 | e677137d | pbrook | #undef AVGB
|
340 | e677137d | pbrook | |
341 | e677137d | pbrook | #define AVGW(SHR) ((( \
|
342 | e677137d | pbrook | ((a >> SHR) & 0xffff) + ((b >> SHR) & 0xffff) + round) >> 1) << SHR) |
343 | e677137d | pbrook | #define IWMMXT_OP_AVGW(r) \
|
344 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_avgw##r)(uint64_t a, uint64_t b) \ |
345 | e677137d | pbrook | { \ |
346 | e677137d | pbrook | const int round = r; \ |
347 | e677137d | pbrook | a = AVGW(0) | AVGW(16) | AVGW(32) | AVGW(48); \ |
348 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
349 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 0) & 0xffff), SIMD_ZBIT, 0) | \ |
350 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 16) & 0xffff), SIMD_ZBIT, 1) | \ |
351 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 32) & 0xffff), SIMD_ZBIT, 2) | \ |
352 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 48) & 0xffff), SIMD_ZBIT, 3); \ |
353 | e677137d | pbrook | return a; \
|
354 | e677137d | pbrook | } |
355 | e677137d | pbrook | IWMMXT_OP_AVGW(0)
|
356 | e677137d | pbrook | IWMMXT_OP_AVGW(1)
|
357 | e677137d | pbrook | #undef IWMMXT_OP_AVGW
|
358 | e677137d | pbrook | #undef AVGW
|
359 | e677137d | pbrook | |
360 | e677137d | pbrook | uint64_t HELPER(iwmmxt_msadb)(uint64_t a, uint64_t b) |
361 | e677137d | pbrook | { |
362 | e677137d | pbrook | a = ((((a >> 0 ) & 0xffff) * ((b >> 0) & 0xffff) + |
363 | e677137d | pbrook | ((a >> 16) & 0xffff) * ((b >> 16) & 0xffff)) & 0xffffffff) | |
364 | e677137d | pbrook | ((((a >> 32) & 0xffff) * ((b >> 32) & 0xffff) + |
365 | e677137d | pbrook | ((a >> 48) & 0xffff) * ((b >> 48) & 0xffff)) << 32); |
366 | e677137d | pbrook | return a;
|
367 | e677137d | pbrook | } |
368 | e677137d | pbrook | |
369 | e677137d | pbrook | uint64_t HELPER(iwmmxt_align)(uint64_t a, uint64_t b, uint32_t n) |
370 | e677137d | pbrook | { |
371 | e677137d | pbrook | a >>= n << 3;
|
372 | e677137d | pbrook | a |= b << (64 - (n << 3)); |
373 | e677137d | pbrook | return a;
|
374 | e677137d | pbrook | } |
375 | e677137d | pbrook | |
376 | e677137d | pbrook | uint64_t HELPER(iwmmxt_insr)(uint64_t x, uint32_t a, uint32_t b, uint32_t n) |
377 | e677137d | pbrook | { |
378 | e677137d | pbrook | x &= ~((uint64_t) b << n); |
379 | e677137d | pbrook | x |= (uint64_t) (a & b) << n; |
380 | e677137d | pbrook | return x;
|
381 | e677137d | pbrook | } |
382 | e677137d | pbrook | |
383 | e677137d | pbrook | uint32_t HELPER(iwmmxt_setpsr_nz)(uint64_t x) |
384 | e677137d | pbrook | { |
385 | e677137d | pbrook | return SIMD64_SET((x == 0), SIMD_ZBIT) | |
386 | e677137d | pbrook | SIMD64_SET((x & (1ULL << 63)), SIMD_NBIT); |
387 | e677137d | pbrook | } |
388 | e677137d | pbrook | |
389 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstb)(uint32_t arg) |
390 | e677137d | pbrook | { |
391 | e677137d | pbrook | arg &= 0xff;
|
392 | e677137d | pbrook | return
|
393 | e677137d | pbrook | ((uint64_t) arg << 0 ) | ((uint64_t) arg << 8 ) | |
394 | e677137d | pbrook | ((uint64_t) arg << 16) | ((uint64_t) arg << 24) | |
395 | e677137d | pbrook | ((uint64_t) arg << 32) | ((uint64_t) arg << 40) | |
396 | e677137d | pbrook | ((uint64_t) arg << 48) | ((uint64_t) arg << 56); |
397 | e677137d | pbrook | } |
398 | e677137d | pbrook | |
399 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstw)(uint32_t arg) |
400 | e677137d | pbrook | { |
401 | e677137d | pbrook | arg &= 0xffff;
|
402 | e677137d | pbrook | return
|
403 | e677137d | pbrook | ((uint64_t) arg << 0 ) | ((uint64_t) arg << 16) | |
404 | e677137d | pbrook | ((uint64_t) arg << 32) | ((uint64_t) arg << 48); |
405 | e677137d | pbrook | } |
406 | e677137d | pbrook | |
407 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstl)(uint32_t arg) |
408 | e677137d | pbrook | { |
409 | e677137d | pbrook | return arg | ((uint64_t) arg << 32); |
410 | e677137d | pbrook | } |
411 | e677137d | pbrook | |
412 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcb)(uint64_t x) |
413 | e677137d | pbrook | { |
414 | e677137d | pbrook | return
|
415 | e677137d | pbrook | ((x >> 0) & 0xff) + ((x >> 8) & 0xff) + |
416 | e677137d | pbrook | ((x >> 16) & 0xff) + ((x >> 24) & 0xff) + |
417 | e677137d | pbrook | ((x >> 32) & 0xff) + ((x >> 40) & 0xff) + |
418 | e677137d | pbrook | ((x >> 48) & 0xff) + ((x >> 56) & 0xff); |
419 | e677137d | pbrook | } |
420 | e677137d | pbrook | |
421 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcw)(uint64_t x) |
422 | e677137d | pbrook | { |
423 | e677137d | pbrook | return
|
424 | e677137d | pbrook | ((x >> 0) & 0xffff) + ((x >> 16) & 0xffff) + |
425 | e677137d | pbrook | ((x >> 32) & 0xffff) + ((x >> 48) & 0xffff); |
426 | e677137d | pbrook | } |
427 | e677137d | pbrook | |
428 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcl)(uint64_t x) |
429 | e677137d | pbrook | { |
430 | e677137d | pbrook | return (x & 0xffffffff) + (x >> 32); |
431 | e677137d | pbrook | } |
432 | e677137d | pbrook | |
433 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbb)(uint64_t x) |
434 | e677137d | pbrook | { |
435 | e677137d | pbrook | return
|
436 | e677137d | pbrook | ((x >> 7) & 0x01) | ((x >> 14) & 0x02) | |
437 | e677137d | pbrook | ((x >> 21) & 0x04) | ((x >> 28) & 0x08) | |
438 | e677137d | pbrook | ((x >> 35) & 0x10) | ((x >> 42) & 0x20) | |
439 | e677137d | pbrook | ((x >> 49) & 0x40) | ((x >> 56) & 0x80); |
440 | e677137d | pbrook | } |
441 | e677137d | pbrook | |
442 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbw)(uint64_t x) |
443 | e677137d | pbrook | { |
444 | e677137d | pbrook | return
|
445 | e677137d | pbrook | ((x >> 15) & 0x01) | ((x >> 30) & 0x02) | |
446 | e677137d | pbrook | ((x >> 45) & 0x04) | ((x >> 52) & 0x08); |
447 | e677137d | pbrook | } |
448 | e677137d | pbrook | |
449 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbl)(uint64_t x) |
450 | e677137d | pbrook | { |
451 | e677137d | pbrook | return ((x >> 31) & 0x01) | ((x >> 62) & 0x02); |
452 | e677137d | pbrook | } |
453 | e677137d | pbrook | |
454 | e677137d | pbrook | /* FIXME: Split wCASF setting into a separate op to avoid env use. */
|
455 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_srlw)(uint64_t x, uint32_t n) |
456 | e677137d | pbrook | { |
457 | e677137d | pbrook | x = (((x & (0xffffll << 0)) >> n) & (0xffffll << 0)) | |
458 | e677137d | pbrook | (((x & (0xffffll << 16)) >> n) & (0xffffll << 16)) | |
459 | e677137d | pbrook | (((x & (0xffffll << 32)) >> n) & (0xffffll << 32)) | |
460 | e677137d | pbrook | (((x & (0xffffll << 48)) >> n) & (0xffffll << 48)); |
461 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
462 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
463 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
464 | e677137d | pbrook | return x;
|
465 | e677137d | pbrook | } |
466 | e677137d | pbrook | |
467 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_srll)(uint64_t x, uint32_t n) |
468 | e677137d | pbrook | { |
469 | e677137d | pbrook | x = ((x & (0xffffffffll << 0)) >> n) | |
470 | e677137d | pbrook | ((x >> n) & (0xffffffffll << 32)); |
471 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
472 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
473 | e677137d | pbrook | return x;
|
474 | e677137d | pbrook | } |
475 | e677137d | pbrook | |
476 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_srlq)(uint64_t x, uint32_t n) |
477 | e677137d | pbrook | { |
478 | e677137d | pbrook | x >>= n; |
479 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
480 | e677137d | pbrook | return x;
|
481 | e677137d | pbrook | } |
482 | e677137d | pbrook | |
483 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_sllw)(uint64_t x, uint32_t n) |
484 | e677137d | pbrook | { |
485 | e677137d | pbrook | x = (((x & (0xffffll << 0)) << n) & (0xffffll << 0)) | |
486 | e677137d | pbrook | (((x & (0xffffll << 16)) << n) & (0xffffll << 16)) | |
487 | e677137d | pbrook | (((x & (0xffffll << 32)) << n) & (0xffffll << 32)) | |
488 | e677137d | pbrook | (((x & (0xffffll << 48)) << n) & (0xffffll << 48)); |
489 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
490 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
491 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
492 | e677137d | pbrook | return x;
|
493 | e677137d | pbrook | } |
494 | e677137d | pbrook | |
495 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_slll)(uint64_t x, uint32_t n) |
496 | e677137d | pbrook | { |
497 | e677137d | pbrook | x = ((x << n) & (0xffffffffll << 0)) | |
498 | e677137d | pbrook | ((x & (0xffffffffll << 32)) << n); |
499 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
500 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
501 | e677137d | pbrook | return x;
|
502 | e677137d | pbrook | } |
503 | e677137d | pbrook | |
504 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_sllq)(uint64_t x, uint32_t n) |
505 | e677137d | pbrook | { |
506 | e677137d | pbrook | x <<= n; |
507 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
508 | e677137d | pbrook | return x;
|
509 | e677137d | pbrook | } |
510 | e677137d | pbrook | |
511 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_sraw)(uint64_t x, uint32_t n) |
512 | e677137d | pbrook | { |
513 | e677137d | pbrook | x = ((uint64_t) ((EXTEND16(x >> 0) >> n) & 0xffff) << 0) | |
514 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 16) >> n) & 0xffff) << 16) | |
515 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 32) >> n) & 0xffff) << 32) | |
516 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 48) >> n) & 0xffff) << 48); |
517 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
518 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
519 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
520 | e677137d | pbrook | return x;
|
521 | e677137d | pbrook | } |
522 | e677137d | pbrook | |
523 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_sral)(uint64_t x, uint32_t n) |
524 | e677137d | pbrook | { |
525 | e677137d | pbrook | x = (((EXTEND32(x >> 0) >> n) & 0xffffffff) << 0) | |
526 | e677137d | pbrook | (((EXTEND32(x >> 32) >> n) & 0xffffffff) << 32); |
527 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
528 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
529 | e677137d | pbrook | return x;
|
530 | e677137d | pbrook | } |
531 | e677137d | pbrook | |
532 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_sraq)(uint64_t x, uint32_t n) |
533 | e677137d | pbrook | { |
534 | e677137d | pbrook | x = (int64_t) x >> n; |
535 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
536 | e677137d | pbrook | return x;
|
537 | e677137d | pbrook | } |
538 | e677137d | pbrook | |
539 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_rorw)(uint64_t x, uint32_t n) |
540 | e677137d | pbrook | { |
541 | e677137d | pbrook | x = ((((x & (0xffffll << 0)) >> n) | |
542 | e677137d | pbrook | ((x & (0xffffll << 0)) << (16 - n))) & (0xffffll << 0)) | |
543 | e677137d | pbrook | ((((x & (0xffffll << 16)) >> n) | |
544 | e677137d | pbrook | ((x & (0xffffll << 16)) << (16 - n))) & (0xffffll << 16)) | |
545 | e677137d | pbrook | ((((x & (0xffffll << 32)) >> n) | |
546 | e677137d | pbrook | ((x & (0xffffll << 32)) << (16 - n))) & (0xffffll << 32)) | |
547 | e677137d | pbrook | ((((x & (0xffffll << 48)) >> n) | |
548 | e677137d | pbrook | ((x & (0xffffll << 48)) << (16 - n))) & (0xffffll << 48)); |
549 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
550 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
551 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
552 | e677137d | pbrook | return x;
|
553 | e677137d | pbrook | } |
554 | e677137d | pbrook | |
555 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_rorl)(uint64_t x, uint32_t n) |
556 | e677137d | pbrook | { |
557 | e677137d | pbrook | x = ((x & (0xffffffffll << 0)) >> n) | |
558 | e677137d | pbrook | ((x >> n) & (0xffffffffll << 32)) | |
559 | e677137d | pbrook | ((x << (32 - n)) & (0xffffffffll << 0)) | |
560 | e677137d | pbrook | ((x & (0xffffffffll << 32)) << (32 - n)); |
561 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
562 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
563 | e677137d | pbrook | return x;
|
564 | e677137d | pbrook | } |
565 | e677137d | pbrook | |
566 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_rorq)(uint64_t x, uint32_t n) |
567 | e677137d | pbrook | { |
568 | e677137d | pbrook | x = (x >> n) | (x << (64 - n));
|
569 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
570 | e677137d | pbrook | return x;
|
571 | e677137d | pbrook | } |
572 | e677137d | pbrook | |
573 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_shufh)(uint64_t x, uint32_t n) |
574 | e677137d | pbrook | { |
575 | e677137d | pbrook | x = (((x >> ((n << 4) & 0x30)) & 0xffff) << 0) | |
576 | e677137d | pbrook | (((x >> ((n << 2) & 0x30)) & 0xffff) << 16) | |
577 | e677137d | pbrook | (((x >> ((n << 0) & 0x30)) & 0xffff) << 32) | |
578 | e677137d | pbrook | (((x >> ((n >> 2) & 0x30)) & 0xffff) << 48); |
579 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
580 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
581 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
582 | e677137d | pbrook | return x;
|
583 | e677137d | pbrook | } |
584 | e677137d | pbrook | |
585 | e677137d | pbrook | /* TODO: Unsigned-Saturation */
|
586 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_packuw)(uint64_t a, uint64_t b) |
587 | e677137d | pbrook | { |
588 | e677137d | pbrook | a = (((a >> 0) & 0xff) << 0) | (((a >> 16) & 0xff) << 8) | |
589 | e677137d | pbrook | (((a >> 32) & 0xff) << 16) | (((a >> 48) & 0xff) << 24) | |
590 | e677137d | pbrook | (((b >> 0) & 0xff) << 32) | (((b >> 16) & 0xff) << 40) | |
591 | e677137d | pbrook | (((b >> 32) & 0xff) << 48) | (((b >> 48) & 0xff) << 56); |
592 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
593 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | |
594 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | |
595 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | |
596 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); |
597 | e677137d | pbrook | return a;
|
598 | e677137d | pbrook | } |
599 | e677137d | pbrook | |
600 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_packul)(uint64_t a, uint64_t b) |
601 | e677137d | pbrook | { |
602 | e677137d | pbrook | a = (((a >> 0) & 0xffff) << 0) | (((a >> 32) & 0xffff) << 16) | |
603 | e677137d | pbrook | (((b >> 0) & 0xffff) << 32) | (((b >> 32) & 0xffff) << 48); |
604 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
605 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | |
606 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); |
607 | e677137d | pbrook | return a;
|
608 | e677137d | pbrook | } |
609 | e677137d | pbrook | |
610 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_packuq)(uint64_t a, uint64_t b) |
611 | e677137d | pbrook | { |
612 | e677137d | pbrook | a = (a & 0xffffffff) | ((b & 0xffffffff) << 32); |
613 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
614 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); |
615 | e677137d | pbrook | return a;
|
616 | e677137d | pbrook | } |
617 | e677137d | pbrook | |
618 | e677137d | pbrook | /* TODO: Signed-Saturation */
|
619 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_packsw)(uint64_t a, uint64_t b) |
620 | e677137d | pbrook | { |
621 | e677137d | pbrook | a = (((a >> 0) & 0xff) << 0) | (((a >> 16) & 0xff) << 8) | |
622 | e677137d | pbrook | (((a >> 32) & 0xff) << 16) | (((a >> 48) & 0xff) << 24) | |
623 | e677137d | pbrook | (((b >> 0) & 0xff) << 32) | (((b >> 16) & 0xff) << 40) | |
624 | e677137d | pbrook | (((b >> 32) & 0xff) << 48) | (((b >> 48) & 0xff) << 56); |
625 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
626 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | |
627 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | |
628 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | |
629 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); |
630 | e677137d | pbrook | return a;
|
631 | e677137d | pbrook | } |
632 | e677137d | pbrook | |
633 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_packsl)(uint64_t a, uint64_t b) |
634 | e677137d | pbrook | { |
635 | e677137d | pbrook | a = (((a >> 0) & 0xffff) << 0) | (((a >> 32) & 0xffff) << 16) | |
636 | e677137d | pbrook | (((b >> 0) & 0xffff) << 32) | (((b >> 32) & 0xffff) << 48); |
637 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
638 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | |
639 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); |
640 | e677137d | pbrook | return a;
|
641 | e677137d | pbrook | } |
642 | e677137d | pbrook | |
643 | 947a2fa2 | Peter Maydell | uint64_t HELPER(iwmmxt_packsq)(uint64_t a, uint64_t b) |
644 | e677137d | pbrook | { |
645 | e677137d | pbrook | a = (a & 0xffffffff) | ((b & 0xffffffff) << 32); |
646 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
647 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); |
648 | e677137d | pbrook | return a;
|
649 | e677137d | pbrook | } |
650 | e677137d | pbrook | |
651 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdsl)(uint64_t c, uint32_t a, uint32_t b) |
652 | e677137d | pbrook | { |
653 | e677137d | pbrook | return c + ((int32_t) EXTEND32(a) * (int32_t) EXTEND32(b));
|
654 | e677137d | pbrook | } |
655 | e677137d | pbrook | |
656 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdsw)(uint64_t c, uint32_t a, uint32_t b) |
657 | e677137d | pbrook | { |
658 | e677137d | pbrook | c += EXTEND32(EXTEND16S((a >> 0) & 0xffff) * |
659 | e677137d | pbrook | EXTEND16S((b >> 0) & 0xffff)); |
660 | e677137d | pbrook | c += EXTEND32(EXTEND16S((a >> 16) & 0xffff) * |
661 | e677137d | pbrook | EXTEND16S((b >> 16) & 0xffff)); |
662 | e677137d | pbrook | return c;
|
663 | e677137d | pbrook | } |
664 | e677137d | pbrook | |
665 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdswl)(uint64_t c, uint32_t a, uint32_t b) |
666 | e677137d | pbrook | { |
667 | e677137d | pbrook | return c + (EXTEND32(EXTEND16S(a & 0xffff) * |
668 | e677137d | pbrook | EXTEND16S(b & 0xffff)));
|
669 | e677137d | pbrook | } |