root / target-arm / iwmmxt_helper.c @ 64e58fe5
History | View | Annotate | Download (24.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 | e677137d | pbrook | #include "exec-all.h" |
27 | e677137d | pbrook | #include "helpers.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 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, b)))(CPUState *env, \ |
166 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
167 | e677137d | pbrook | { \ |
168 | e677137d | pbrook | a = \ |
169 | e677137d | pbrook | (((a >> SH0) & 0xff) << 0) | (((b >> SH0) & 0xff) << 8) | \ |
170 | e677137d | pbrook | (((a >> SH1) & 0xff) << 16) | (((b >> SH1) & 0xff) << 24) | \ |
171 | e677137d | pbrook | (((a >> SH2) & 0xff) << 32) | (((b >> SH2) & 0xff) << 40) | \ |
172 | e677137d | pbrook | (((a >> SH3) & 0xff) << 48) | (((b >> SH3) & 0xff) << 56); \ |
173 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
174 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \ |
175 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \ |
176 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \ |
177 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \ |
178 | e677137d | pbrook | return a; \
|
179 | e677137d | pbrook | } \ |
180 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, w)))(CPUState *env, \ |
181 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
182 | e677137d | pbrook | { \ |
183 | e677137d | pbrook | a = \ |
184 | e677137d | pbrook | (((a >> SH0) & 0xffff) << 0) | \ |
185 | e677137d | pbrook | (((b >> SH0) & 0xffff) << 16) | \ |
186 | e677137d | pbrook | (((a >> SH2) & 0xffff) << 32) | \ |
187 | e677137d | pbrook | (((b >> SH2) & 0xffff) << 48); \ |
188 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
189 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 16, 1) | \ |
190 | e677137d | pbrook | NZBIT8(a >> 32, 2) | NZBIT8(a >> 48, 3); \ |
191 | e677137d | pbrook | return a; \
|
192 | e677137d | pbrook | } \ |
193 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, l)))(CPUState *env, \ |
194 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
195 | e677137d | pbrook | { \ |
196 | e677137d | pbrook | a = \ |
197 | e677137d | pbrook | (((a >> SH0) & 0xffffffff) << 0) | \ |
198 | e677137d | pbrook | (((b >> SH0) & 0xffffffff) << 32); \ |
199 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
200 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \ |
201 | e677137d | pbrook | return a; \
|
202 | e677137d | pbrook | } \ |
203 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ub)))(CPUState *env, \ |
204 | e677137d | pbrook | uint64_t x) \ |
205 | e677137d | pbrook | { \ |
206 | e677137d | pbrook | x = \ |
207 | e677137d | pbrook | (((x >> SH0) & 0xff) << 0) | \ |
208 | e677137d | pbrook | (((x >> SH1) & 0xff) << 16) | \ |
209 | e677137d | pbrook | (((x >> SH2) & 0xff) << 32) | \ |
210 | e677137d | pbrook | (((x >> SH3) & 0xff) << 48); \ |
211 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
212 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \ |
213 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \ |
214 | e677137d | pbrook | return x; \
|
215 | e677137d | pbrook | } \ |
216 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, uw)))(CPUState *env, \ |
217 | e677137d | pbrook | uint64_t x) \ |
218 | e677137d | pbrook | { \ |
219 | e677137d | pbrook | x = \ |
220 | e677137d | pbrook | (((x >> SH0) & 0xffff) << 0) | \ |
221 | e677137d | pbrook | (((x >> SH2) & 0xffff) << 32); \ |
222 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
223 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \ |
224 | e677137d | pbrook | return x; \
|
225 | e677137d | pbrook | } \ |
226 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ul)))(CPUState *env, \ |
227 | e677137d | pbrook | uint64_t x) \ |
228 | e677137d | pbrook | { \ |
229 | e677137d | pbrook | x = (((x >> SH0) & 0xffffffff) << 0); \ |
230 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
|
231 | e677137d | pbrook | return x; \
|
232 | e677137d | pbrook | } \ |
233 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sb)))(CPUState *env, \ |
234 | e677137d | pbrook | uint64_t x) \ |
235 | e677137d | pbrook | { \ |
236 | e677137d | pbrook | x = \ |
237 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH0) & 0xff) << 0) | \ |
238 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH1) & 0xff) << 16) | \ |
239 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH2) & 0xff) << 32) | \ |
240 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH3) & 0xff) << 48); \ |
241 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
242 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \ |
243 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \ |
244 | e677137d | pbrook | return x; \
|
245 | e677137d | pbrook | } \ |
246 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sw)))(CPUState *env, \ |
247 | e677137d | pbrook | uint64_t x) \ |
248 | e677137d | pbrook | { \ |
249 | e677137d | pbrook | x = \ |
250 | e677137d | pbrook | ((uint64_t) EXTEND16((x >> SH0) & 0xffff) << 0) | \ |
251 | e677137d | pbrook | ((uint64_t) EXTEND16((x >> SH2) & 0xffff) << 32); \ |
252 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
253 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \ |
254 | e677137d | pbrook | return x; \
|
255 | e677137d | pbrook | } \ |
256 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sl)))(CPUState *env, \ |
257 | e677137d | pbrook | uint64_t x) \ |
258 | e677137d | pbrook | { \ |
259 | e677137d | pbrook | x = EXTEND32((x >> SH0) & 0xffffffff); \
|
260 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
|
261 | e677137d | pbrook | return x; \
|
262 | e677137d | pbrook | } |
263 | e677137d | pbrook | IWMMXT_OP_UNPACK(l, 0, 8, 16, 24) |
264 | e677137d | pbrook | IWMMXT_OP_UNPACK(h, 32, 40, 48, 56) |
265 | e677137d | pbrook | |
266 | e677137d | pbrook | #define IWMMXT_OP_CMP(SUFF, Tb, Tw, Tl, O) \
|
267 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, b)))(CPUState *env, \ |
268 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
269 | e677137d | pbrook | { \ |
270 | e677137d | pbrook | a = \ |
271 | e677137d | pbrook | CMP(0, Tb, O, 0xff) | CMP(8, Tb, O, 0xff) | \ |
272 | e677137d | pbrook | CMP(16, Tb, O, 0xff) | CMP(24, Tb, O, 0xff) | \ |
273 | e677137d | pbrook | CMP(32, Tb, O, 0xff) | CMP(40, Tb, O, 0xff) | \ |
274 | e677137d | pbrook | CMP(48, Tb, O, 0xff) | CMP(56, Tb, O, 0xff); \ |
275 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
276 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \ |
277 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \ |
278 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \ |
279 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \ |
280 | e677137d | pbrook | return a; \
|
281 | e677137d | pbrook | } \ |
282 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, w)))(CPUState *env, \ |
283 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
284 | e677137d | pbrook | { \ |
285 | e677137d | pbrook | a = CMP(0, Tw, O, 0xffff) | CMP(16, Tw, O, 0xffff) | \ |
286 | e677137d | pbrook | CMP(32, Tw, O, 0xffff) | CMP(48, Tw, O, 0xffff); \ |
287 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
288 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | \ |
289 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); \ |
290 | e677137d | pbrook | return a; \
|
291 | e677137d | pbrook | } \ |
292 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, l)))(CPUState *env, \ |
293 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
294 | e677137d | pbrook | { \ |
295 | e677137d | pbrook | a = CMP(0, Tl, O, 0xffffffff) | \ |
296 | e677137d | pbrook | CMP(32, Tl, O, 0xffffffff); \ |
297 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
298 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \ |
299 | e677137d | pbrook | return a; \
|
300 | e677137d | pbrook | } |
301 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((((TYPE) ((a >> SHR) & MASK) OPER \
|
302 | e677137d | pbrook | (TYPE) ((b >> SHR) & MASK)) ? (uint64_t) MASK : 0) << SHR)
|
303 | e677137d | pbrook | IWMMXT_OP_CMP(cmpeq, uint8_t, uint16_t, uint32_t, ==) |
304 | e677137d | pbrook | IWMMXT_OP_CMP(cmpgts, int8_t, int16_t, int32_t, >) |
305 | e677137d | pbrook | IWMMXT_OP_CMP(cmpgtu, uint8_t, uint16_t, uint32_t, >) |
306 | e677137d | pbrook | #undef CMP
|
307 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((((TYPE) ((a >> SHR) & MASK) OPER \
|
308 | e677137d | pbrook | (TYPE) ((b >> SHR) & MASK)) ? a : b) & ((uint64_t) MASK << SHR)) |
309 | e677137d | pbrook | IWMMXT_OP_CMP(mins, int8_t, int16_t, int32_t, <) |
310 | e677137d | pbrook | IWMMXT_OP_CMP(minu, uint8_t, uint16_t, uint32_t, <) |
311 | e677137d | pbrook | IWMMXT_OP_CMP(maxs, int8_t, int16_t, int32_t, >) |
312 | e677137d | pbrook | IWMMXT_OP_CMP(maxu, uint8_t, uint16_t, uint32_t, >) |
313 | e677137d | pbrook | #undef CMP
|
314 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((uint64_t) (((TYPE) ((a >> SHR) & MASK) \
|
315 | e677137d | pbrook | OPER (TYPE) ((b >> SHR) & MASK)) & MASK) << SHR) |
316 | e677137d | pbrook | IWMMXT_OP_CMP(subn, uint8_t, uint16_t, uint32_t, -) |
317 | e677137d | pbrook | IWMMXT_OP_CMP(addn, uint8_t, uint16_t, uint32_t, +) |
318 | e677137d | pbrook | #undef CMP
|
319 | e677137d | pbrook | /* TODO Signed- and Unsigned-Saturation */
|
320 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((uint64_t) (((TYPE) ((a >> SHR) & MASK) \
|
321 | e677137d | pbrook | OPER (TYPE) ((b >> SHR) & MASK)) & MASK) << SHR) |
322 | e677137d | pbrook | IWMMXT_OP_CMP(subu, uint8_t, uint16_t, uint32_t, -) |
323 | e677137d | pbrook | IWMMXT_OP_CMP(addu, uint8_t, uint16_t, uint32_t, +) |
324 | e677137d | pbrook | IWMMXT_OP_CMP(subs, int8_t, int16_t, int32_t, -) |
325 | e677137d | pbrook | IWMMXT_OP_CMP(adds, int8_t, int16_t, int32_t, +) |
326 | e677137d | pbrook | #undef CMP
|
327 | e677137d | pbrook | #undef IWMMXT_OP_CMP
|
328 | e677137d | pbrook | |
329 | e677137d | pbrook | #define AVGB(SHR) ((( \
|
330 | e677137d | pbrook | ((a >> SHR) & 0xff) + ((b >> SHR) & 0xff) + round) >> 1) << SHR) |
331 | e677137d | pbrook | #define IWMMXT_OP_AVGB(r) \
|
332 | e677137d | pbrook | uint64_t HELPER(iwmmxt_avgb##r)(CPUState *env, uint64_t a, uint64_t b) \ |
333 | e677137d | pbrook | { \ |
334 | e677137d | pbrook | const int round = r; \ |
335 | e677137d | pbrook | a = AVGB(0) | AVGB(8) | AVGB(16) | AVGB(24) | \ |
336 | e677137d | pbrook | AVGB(32) | AVGB(40) | AVGB(48) | AVGB(56); \ |
337 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
338 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 0) & 0xff), SIMD_ZBIT, 0) | \ |
339 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 8) & 0xff), SIMD_ZBIT, 1) | \ |
340 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 16) & 0xff), SIMD_ZBIT, 2) | \ |
341 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 24) & 0xff), SIMD_ZBIT, 3) | \ |
342 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 32) & 0xff), SIMD_ZBIT, 4) | \ |
343 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 40) & 0xff), SIMD_ZBIT, 5) | \ |
344 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 48) & 0xff), SIMD_ZBIT, 6) | \ |
345 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 56) & 0xff), SIMD_ZBIT, 7); \ |
346 | e677137d | pbrook | return a; \
|
347 | e677137d | pbrook | } |
348 | e677137d | pbrook | IWMMXT_OP_AVGB(0)
|
349 | e677137d | pbrook | IWMMXT_OP_AVGB(1)
|
350 | e677137d | pbrook | #undef IWMMXT_OP_AVGB
|
351 | e677137d | pbrook | #undef AVGB
|
352 | e677137d | pbrook | |
353 | e677137d | pbrook | #define AVGW(SHR) ((( \
|
354 | e677137d | pbrook | ((a >> SHR) & 0xffff) + ((b >> SHR) & 0xffff) + round) >> 1) << SHR) |
355 | e677137d | pbrook | #define IWMMXT_OP_AVGW(r) \
|
356 | e677137d | pbrook | uint64_t HELPER(iwmmxt_avgw##r)(CPUState *env, uint64_t a, uint64_t b) \ |
357 | e677137d | pbrook | { \ |
358 | e677137d | pbrook | const int round = r; \ |
359 | e677137d | pbrook | a = AVGW(0) | AVGW(16) | AVGW(32) | AVGW(48); \ |
360 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
361 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 0) & 0xffff), SIMD_ZBIT, 0) | \ |
362 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 16) & 0xffff), SIMD_ZBIT, 1) | \ |
363 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 32) & 0xffff), SIMD_ZBIT, 2) | \ |
364 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 48) & 0xffff), SIMD_ZBIT, 3); \ |
365 | e677137d | pbrook | return a; \
|
366 | e677137d | pbrook | } |
367 | e677137d | pbrook | IWMMXT_OP_AVGW(0)
|
368 | e677137d | pbrook | IWMMXT_OP_AVGW(1)
|
369 | e677137d | pbrook | #undef IWMMXT_OP_AVGW
|
370 | e677137d | pbrook | #undef AVGW
|
371 | e677137d | pbrook | |
372 | e677137d | pbrook | uint64_t HELPER(iwmmxt_msadb)(uint64_t a, uint64_t b) |
373 | e677137d | pbrook | { |
374 | e677137d | pbrook | a = ((((a >> 0 ) & 0xffff) * ((b >> 0) & 0xffff) + |
375 | e677137d | pbrook | ((a >> 16) & 0xffff) * ((b >> 16) & 0xffff)) & 0xffffffff) | |
376 | e677137d | pbrook | ((((a >> 32) & 0xffff) * ((b >> 32) & 0xffff) + |
377 | e677137d | pbrook | ((a >> 48) & 0xffff) * ((b >> 48) & 0xffff)) << 32); |
378 | e677137d | pbrook | return a;
|
379 | e677137d | pbrook | } |
380 | e677137d | pbrook | |
381 | e677137d | pbrook | uint64_t HELPER(iwmmxt_align)(uint64_t a, uint64_t b, uint32_t n) |
382 | e677137d | pbrook | { |
383 | e677137d | pbrook | a >>= n << 3;
|
384 | e677137d | pbrook | a |= b << (64 - (n << 3)); |
385 | e677137d | pbrook | return a;
|
386 | e677137d | pbrook | } |
387 | e677137d | pbrook | |
388 | e677137d | pbrook | uint64_t HELPER(iwmmxt_insr)(uint64_t x, uint32_t a, uint32_t b, uint32_t n) |
389 | e677137d | pbrook | { |
390 | e677137d | pbrook | x &= ~((uint64_t) b << n); |
391 | e677137d | pbrook | x |= (uint64_t) (a & b) << n; |
392 | e677137d | pbrook | return x;
|
393 | e677137d | pbrook | } |
394 | e677137d | pbrook | |
395 | e677137d | pbrook | uint32_t HELPER(iwmmxt_setpsr_nz)(uint64_t x) |
396 | e677137d | pbrook | { |
397 | e677137d | pbrook | return SIMD64_SET((x == 0), SIMD_ZBIT) | |
398 | e677137d | pbrook | SIMD64_SET((x & (1ULL << 63)), SIMD_NBIT); |
399 | e677137d | pbrook | } |
400 | e677137d | pbrook | |
401 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstb)(uint32_t arg) |
402 | e677137d | pbrook | { |
403 | e677137d | pbrook | arg &= 0xff;
|
404 | e677137d | pbrook | return
|
405 | e677137d | pbrook | ((uint64_t) arg << 0 ) | ((uint64_t) arg << 8 ) | |
406 | e677137d | pbrook | ((uint64_t) arg << 16) | ((uint64_t) arg << 24) | |
407 | e677137d | pbrook | ((uint64_t) arg << 32) | ((uint64_t) arg << 40) | |
408 | e677137d | pbrook | ((uint64_t) arg << 48) | ((uint64_t) arg << 56); |
409 | e677137d | pbrook | } |
410 | e677137d | pbrook | |
411 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstw)(uint32_t arg) |
412 | e677137d | pbrook | { |
413 | e677137d | pbrook | arg &= 0xffff;
|
414 | e677137d | pbrook | return
|
415 | e677137d | pbrook | ((uint64_t) arg << 0 ) | ((uint64_t) arg << 16) | |
416 | e677137d | pbrook | ((uint64_t) arg << 32) | ((uint64_t) arg << 48); |
417 | e677137d | pbrook | } |
418 | e677137d | pbrook | |
419 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstl)(uint32_t arg) |
420 | e677137d | pbrook | { |
421 | e677137d | pbrook | return arg | ((uint64_t) arg << 32); |
422 | e677137d | pbrook | } |
423 | e677137d | pbrook | |
424 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcb)(uint64_t x) |
425 | e677137d | pbrook | { |
426 | e677137d | pbrook | return
|
427 | e677137d | pbrook | ((x >> 0) & 0xff) + ((x >> 8) & 0xff) + |
428 | e677137d | pbrook | ((x >> 16) & 0xff) + ((x >> 24) & 0xff) + |
429 | e677137d | pbrook | ((x >> 32) & 0xff) + ((x >> 40) & 0xff) + |
430 | e677137d | pbrook | ((x >> 48) & 0xff) + ((x >> 56) & 0xff); |
431 | e677137d | pbrook | } |
432 | e677137d | pbrook | |
433 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcw)(uint64_t x) |
434 | e677137d | pbrook | { |
435 | e677137d | pbrook | return
|
436 | e677137d | pbrook | ((x >> 0) & 0xffff) + ((x >> 16) & 0xffff) + |
437 | e677137d | pbrook | ((x >> 32) & 0xffff) + ((x >> 48) & 0xffff); |
438 | e677137d | pbrook | } |
439 | e677137d | pbrook | |
440 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcl)(uint64_t x) |
441 | e677137d | pbrook | { |
442 | e677137d | pbrook | return (x & 0xffffffff) + (x >> 32); |
443 | e677137d | pbrook | } |
444 | e677137d | pbrook | |
445 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbb)(uint64_t x) |
446 | e677137d | pbrook | { |
447 | e677137d | pbrook | return
|
448 | e677137d | pbrook | ((x >> 7) & 0x01) | ((x >> 14) & 0x02) | |
449 | e677137d | pbrook | ((x >> 21) & 0x04) | ((x >> 28) & 0x08) | |
450 | e677137d | pbrook | ((x >> 35) & 0x10) | ((x >> 42) & 0x20) | |
451 | e677137d | pbrook | ((x >> 49) & 0x40) | ((x >> 56) & 0x80); |
452 | e677137d | pbrook | } |
453 | e677137d | pbrook | |
454 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbw)(uint64_t x) |
455 | e677137d | pbrook | { |
456 | e677137d | pbrook | return
|
457 | e677137d | pbrook | ((x >> 15) & 0x01) | ((x >> 30) & 0x02) | |
458 | e677137d | pbrook | ((x >> 45) & 0x04) | ((x >> 52) & 0x08); |
459 | e677137d | pbrook | } |
460 | e677137d | pbrook | |
461 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbl)(uint64_t x) |
462 | e677137d | pbrook | { |
463 | e677137d | pbrook | return ((x >> 31) & 0x01) | ((x >> 62) & 0x02); |
464 | e677137d | pbrook | } |
465 | e677137d | pbrook | |
466 | e677137d | pbrook | /* FIXME: Split wCASF setting into a separate op to avoid env use. */
|
467 | e677137d | pbrook | uint64_t HELPER(iwmmxt_srlw)(CPUState *env, uint64_t x, uint32_t n) |
468 | e677137d | pbrook | { |
469 | e677137d | pbrook | x = (((x & (0xffffll << 0)) >> n) & (0xffffll << 0)) | |
470 | e677137d | pbrook | (((x & (0xffffll << 16)) >> n) & (0xffffll << 16)) | |
471 | e677137d | pbrook | (((x & (0xffffll << 32)) >> n) & (0xffffll << 32)) | |
472 | e677137d | pbrook | (((x & (0xffffll << 48)) >> n) & (0xffffll << 48)); |
473 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
474 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
475 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
476 | e677137d | pbrook | return x;
|
477 | e677137d | pbrook | } |
478 | e677137d | pbrook | |
479 | e677137d | pbrook | uint64_t HELPER(iwmmxt_srll)(CPUState *env, uint64_t x, uint32_t n) |
480 | e677137d | pbrook | { |
481 | e677137d | pbrook | x = ((x & (0xffffffffll << 0)) >> n) | |
482 | e677137d | pbrook | ((x >> n) & (0xffffffffll << 32)); |
483 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
484 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
485 | e677137d | pbrook | return x;
|
486 | e677137d | pbrook | } |
487 | e677137d | pbrook | |
488 | e677137d | pbrook | uint64_t HELPER(iwmmxt_srlq)(CPUState *env, uint64_t x, uint32_t n) |
489 | e677137d | pbrook | { |
490 | e677137d | pbrook | x >>= n; |
491 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
492 | e677137d | pbrook | return x;
|
493 | e677137d | pbrook | } |
494 | e677137d | pbrook | |
495 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sllw)(CPUState *env, uint64_t x, uint32_t n) |
496 | e677137d | pbrook | { |
497 | e677137d | pbrook | x = (((x & (0xffffll << 0)) << n) & (0xffffll << 0)) | |
498 | e677137d | pbrook | (((x & (0xffffll << 16)) << n) & (0xffffll << 16)) | |
499 | e677137d | pbrook | (((x & (0xffffll << 32)) << n) & (0xffffll << 32)) | |
500 | e677137d | pbrook | (((x & (0xffffll << 48)) << n) & (0xffffll << 48)); |
501 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
502 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
503 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
504 | e677137d | pbrook | return x;
|
505 | e677137d | pbrook | } |
506 | e677137d | pbrook | |
507 | e677137d | pbrook | uint64_t HELPER(iwmmxt_slll)(CPUState *env, uint64_t x, uint32_t n) |
508 | e677137d | pbrook | { |
509 | e677137d | pbrook | x = ((x << n) & (0xffffffffll << 0)) | |
510 | e677137d | pbrook | ((x & (0xffffffffll << 32)) << n); |
511 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
512 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
513 | e677137d | pbrook | return x;
|
514 | e677137d | pbrook | } |
515 | e677137d | pbrook | |
516 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sllq)(CPUState *env, uint64_t x, uint32_t n) |
517 | e677137d | pbrook | { |
518 | e677137d | pbrook | x <<= n; |
519 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
520 | e677137d | pbrook | return x;
|
521 | e677137d | pbrook | } |
522 | e677137d | pbrook | |
523 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sraw)(CPUState *env, uint64_t x, uint32_t n) |
524 | e677137d | pbrook | { |
525 | e677137d | pbrook | x = ((uint64_t) ((EXTEND16(x >> 0) >> n) & 0xffff) << 0) | |
526 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 16) >> n) & 0xffff) << 16) | |
527 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 32) >> n) & 0xffff) << 32) | |
528 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 48) >> n) & 0xffff) << 48); |
529 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
530 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
531 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
532 | e677137d | pbrook | return x;
|
533 | e677137d | pbrook | } |
534 | e677137d | pbrook | |
535 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sral)(CPUState *env, uint64_t x, uint32_t n) |
536 | e677137d | pbrook | { |
537 | e677137d | pbrook | x = (((EXTEND32(x >> 0) >> n) & 0xffffffff) << 0) | |
538 | e677137d | pbrook | (((EXTEND32(x >> 32) >> n) & 0xffffffff) << 32); |
539 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
540 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
541 | e677137d | pbrook | return x;
|
542 | e677137d | pbrook | } |
543 | e677137d | pbrook | |
544 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sraq)(CPUState *env, uint64_t x, uint32_t n) |
545 | e677137d | pbrook | { |
546 | e677137d | pbrook | x = (int64_t) x >> n; |
547 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
548 | e677137d | pbrook | return x;
|
549 | e677137d | pbrook | } |
550 | e677137d | pbrook | |
551 | e677137d | pbrook | uint64_t HELPER(iwmmxt_rorw)(CPUState *env, uint64_t x, uint32_t n) |
552 | e677137d | pbrook | { |
553 | e677137d | pbrook | x = ((((x & (0xffffll << 0)) >> n) | |
554 | e677137d | pbrook | ((x & (0xffffll << 0)) << (16 - n))) & (0xffffll << 0)) | |
555 | e677137d | pbrook | ((((x & (0xffffll << 16)) >> n) | |
556 | e677137d | pbrook | ((x & (0xffffll << 16)) << (16 - n))) & (0xffffll << 16)) | |
557 | e677137d | pbrook | ((((x & (0xffffll << 32)) >> n) | |
558 | e677137d | pbrook | ((x & (0xffffll << 32)) << (16 - n))) & (0xffffll << 32)) | |
559 | e677137d | pbrook | ((((x & (0xffffll << 48)) >> n) | |
560 | e677137d | pbrook | ((x & (0xffffll << 48)) << (16 - n))) & (0xffffll << 48)); |
561 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
562 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
563 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
564 | e677137d | pbrook | return x;
|
565 | e677137d | pbrook | } |
566 | e677137d | pbrook | |
567 | e677137d | pbrook | uint64_t HELPER(iwmmxt_rorl)(CPUState *env, uint64_t x, uint32_t n) |
568 | e677137d | pbrook | { |
569 | e677137d | pbrook | x = ((x & (0xffffffffll << 0)) >> n) | |
570 | e677137d | pbrook | ((x >> n) & (0xffffffffll << 32)) | |
571 | e677137d | pbrook | ((x << (32 - n)) & (0xffffffffll << 0)) | |
572 | e677137d | pbrook | ((x & (0xffffffffll << 32)) << (32 - n)); |
573 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
574 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
575 | e677137d | pbrook | return x;
|
576 | e677137d | pbrook | } |
577 | e677137d | pbrook | |
578 | e677137d | pbrook | uint64_t HELPER(iwmmxt_rorq)(CPUState *env, uint64_t x, uint32_t n) |
579 | e677137d | pbrook | { |
580 | e677137d | pbrook | x = (x >> n) | (x << (64 - n));
|
581 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
582 | e677137d | pbrook | return x;
|
583 | e677137d | pbrook | } |
584 | e677137d | pbrook | |
585 | e677137d | pbrook | uint64_t HELPER(iwmmxt_shufh)(CPUState *env, uint64_t x, uint32_t n) |
586 | e677137d | pbrook | { |
587 | e677137d | pbrook | x = (((x >> ((n << 4) & 0x30)) & 0xffff) << 0) | |
588 | e677137d | pbrook | (((x >> ((n << 2) & 0x30)) & 0xffff) << 16) | |
589 | e677137d | pbrook | (((x >> ((n << 0) & 0x30)) & 0xffff) << 32) | |
590 | e677137d | pbrook | (((x >> ((n >> 2) & 0x30)) & 0xffff) << 48); |
591 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
592 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
593 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
594 | e677137d | pbrook | return x;
|
595 | e677137d | pbrook | } |
596 | e677137d | pbrook | |
597 | e677137d | pbrook | /* TODO: Unsigned-Saturation */
|
598 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packuw)(CPUState *env, uint64_t a, uint64_t b) |
599 | e677137d | pbrook | { |
600 | e677137d | pbrook | a = (((a >> 0) & 0xff) << 0) | (((a >> 16) & 0xff) << 8) | |
601 | e677137d | pbrook | (((a >> 32) & 0xff) << 16) | (((a >> 48) & 0xff) << 24) | |
602 | e677137d | pbrook | (((b >> 0) & 0xff) << 32) | (((b >> 16) & 0xff) << 40) | |
603 | e677137d | pbrook | (((b >> 32) & 0xff) << 48) | (((b >> 48) & 0xff) << 56); |
604 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
605 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | |
606 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | |
607 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | |
608 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); |
609 | e677137d | pbrook | return a;
|
610 | e677137d | pbrook | } |
611 | e677137d | pbrook | |
612 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packul)(CPUState *env, uint64_t a, uint64_t b) |
613 | e677137d | pbrook | { |
614 | e677137d | pbrook | a = (((a >> 0) & 0xffff) << 0) | (((a >> 32) & 0xffff) << 16) | |
615 | e677137d | pbrook | (((b >> 0) & 0xffff) << 32) | (((b >> 32) & 0xffff) << 48); |
616 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
617 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | |
618 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); |
619 | e677137d | pbrook | return a;
|
620 | e677137d | pbrook | } |
621 | e677137d | pbrook | |
622 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packuq)(CPUState *env, uint64_t a, uint64_t b) |
623 | e677137d | pbrook | { |
624 | e677137d | pbrook | a = (a & 0xffffffff) | ((b & 0xffffffff) << 32); |
625 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
626 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); |
627 | e677137d | pbrook | return a;
|
628 | e677137d | pbrook | } |
629 | e677137d | pbrook | |
630 | e677137d | pbrook | /* TODO: Signed-Saturation */
|
631 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packsw)(CPUState *env, uint64_t a, uint64_t b) |
632 | e677137d | pbrook | { |
633 | e677137d | pbrook | a = (((a >> 0) & 0xff) << 0) | (((a >> 16) & 0xff) << 8) | |
634 | e677137d | pbrook | (((a >> 32) & 0xff) << 16) | (((a >> 48) & 0xff) << 24) | |
635 | e677137d | pbrook | (((b >> 0) & 0xff) << 32) | (((b >> 16) & 0xff) << 40) | |
636 | e677137d | pbrook | (((b >> 32) & 0xff) << 48) | (((b >> 48) & 0xff) << 56); |
637 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
638 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | |
639 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | |
640 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | |
641 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); |
642 | e677137d | pbrook | return a;
|
643 | e677137d | pbrook | } |
644 | e677137d | pbrook | |
645 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packsl)(CPUState *env, uint64_t a, uint64_t b) |
646 | e677137d | pbrook | { |
647 | e677137d | pbrook | a = (((a >> 0) & 0xffff) << 0) | (((a >> 32) & 0xffff) << 16) | |
648 | e677137d | pbrook | (((b >> 0) & 0xffff) << 32) | (((b >> 32) & 0xffff) << 48); |
649 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
650 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | |
651 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); |
652 | e677137d | pbrook | return a;
|
653 | e677137d | pbrook | } |
654 | e677137d | pbrook | |
655 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packsq)(CPUState *env, uint64_t a, uint64_t b) |
656 | e677137d | pbrook | { |
657 | e677137d | pbrook | a = (a & 0xffffffff) | ((b & 0xffffffff) << 32); |
658 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
659 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); |
660 | e677137d | pbrook | return a;
|
661 | e677137d | pbrook | } |
662 | e677137d | pbrook | |
663 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdsl)(uint64_t c, uint32_t a, uint32_t b) |
664 | e677137d | pbrook | { |
665 | e677137d | pbrook | return c + ((int32_t) EXTEND32(a) * (int32_t) EXTEND32(b));
|
666 | e677137d | pbrook | } |
667 | e677137d | pbrook | |
668 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdsw)(uint64_t c, uint32_t a, uint32_t b) |
669 | e677137d | pbrook | { |
670 | e677137d | pbrook | c += EXTEND32(EXTEND16S((a >> 0) & 0xffff) * |
671 | e677137d | pbrook | EXTEND16S((b >> 0) & 0xffff)); |
672 | e677137d | pbrook | c += EXTEND32(EXTEND16S((a >> 16) & 0xffff) * |
673 | e677137d | pbrook | EXTEND16S((b >> 16) & 0xffff)); |
674 | e677137d | pbrook | return c;
|
675 | e677137d | pbrook | } |
676 | e677137d | pbrook | |
677 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdswl)(uint64_t c, uint32_t a, uint32_t b) |
678 | e677137d | pbrook | { |
679 | e677137d | pbrook | return c + (EXTEND32(EXTEND16S(a & 0xffff) * |
680 | e677137d | pbrook | EXTEND16S(b & 0xffff)));
|
681 | e677137d | pbrook | } |