1 | /*
|
---|
2 | * MMX/3DNow!/SSE/SSE2/SSE3/SSSE3/SSE4/PNI support
|
---|
3 | *
|
---|
4 | * Copyright (c) 2005 Fabrice Bellard
|
---|
5 | * Copyright (c) 2008 Intel Corporation <[email protected]>
|
---|
6 | *
|
---|
7 | * This library is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU Lesser General Public
|
---|
9 | * License as published by the Free Software Foundation; either
|
---|
10 | * version 2 of the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This library is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | * Lesser General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU Lesser General Public
|
---|
18 | * License along with this library; if not, write to the Free Software
|
---|
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
20 | */
|
---|
21 | /*
|
---|
22 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
23 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
24 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
25 | * a choice of LGPL license versions is made available with the language indicating
|
---|
26 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
27 | * of the LGPL is applied is otherwise unspecified.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #if SHIFT == 0
|
---|
31 | #define Reg MMXReg
|
---|
32 | #ifndef VBOX
|
---|
33 | #define XMM_ONLY(x...)
|
---|
34 | #else
|
---|
35 | #define XMM_ONLY(x)
|
---|
36 | #endif
|
---|
37 | #define B(n) MMX_B(n)
|
---|
38 | #define W(n) MMX_W(n)
|
---|
39 | #define L(n) MMX_L(n)
|
---|
40 | #define Q(n) q
|
---|
41 | #define SUFFIX _mmx
|
---|
42 | #else
|
---|
43 | #define Reg XMMReg
|
---|
44 | #ifndef VBOX
|
---|
45 | #define XMM_ONLY(x...) x
|
---|
46 | #else
|
---|
47 | #define XMM_ONLY(x) x
|
---|
48 | #endif
|
---|
49 | #define B(n) XMM_B(n)
|
---|
50 | #define W(n) XMM_W(n)
|
---|
51 | #define L(n) XMM_L(n)
|
---|
52 | #define Q(n) XMM_Q(n)
|
---|
53 | #define SUFFIX _xmm
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | void glue(helper_psrlw, SUFFIX)(Reg *d, Reg *s)
|
---|
57 | {
|
---|
58 | int shift;
|
---|
59 |
|
---|
60 | if (s->Q(0) > 15) {
|
---|
61 | d->Q(0) = 0;
|
---|
62 | #if SHIFT == 1
|
---|
63 | d->Q(1) = 0;
|
---|
64 | #endif
|
---|
65 | } else {
|
---|
66 | shift = s->B(0);
|
---|
67 | d->W(0) >>= shift;
|
---|
68 | d->W(1) >>= shift;
|
---|
69 | d->W(2) >>= shift;
|
---|
70 | d->W(3) >>= shift;
|
---|
71 | #if SHIFT == 1
|
---|
72 | d->W(4) >>= shift;
|
---|
73 | d->W(5) >>= shift;
|
---|
74 | d->W(6) >>= shift;
|
---|
75 | d->W(7) >>= shift;
|
---|
76 | #endif
|
---|
77 | }
|
---|
78 | FORCE_RET();
|
---|
79 | }
|
---|
80 |
|
---|
81 | void glue(helper_psraw, SUFFIX)(Reg *d, Reg *s)
|
---|
82 | {
|
---|
83 | int shift;
|
---|
84 |
|
---|
85 | if (s->Q(0) > 15) {
|
---|
86 | shift = 15;
|
---|
87 | } else {
|
---|
88 | shift = s->B(0);
|
---|
89 | }
|
---|
90 | d->W(0) = (int16_t)d->W(0) >> shift;
|
---|
91 | d->W(1) = (int16_t)d->W(1) >> shift;
|
---|
92 | d->W(2) = (int16_t)d->W(2) >> shift;
|
---|
93 | d->W(3) = (int16_t)d->W(3) >> shift;
|
---|
94 | #if SHIFT == 1
|
---|
95 | d->W(4) = (int16_t)d->W(4) >> shift;
|
---|
96 | d->W(5) = (int16_t)d->W(5) >> shift;
|
---|
97 | d->W(6) = (int16_t)d->W(6) >> shift;
|
---|
98 | d->W(7) = (int16_t)d->W(7) >> shift;
|
---|
99 | #endif
|
---|
100 | }
|
---|
101 |
|
---|
102 | void glue(helper_psllw, SUFFIX)(Reg *d, Reg *s)
|
---|
103 | {
|
---|
104 | int shift;
|
---|
105 |
|
---|
106 | if (s->Q(0) > 15) {
|
---|
107 | d->Q(0) = 0;
|
---|
108 | #if SHIFT == 1
|
---|
109 | d->Q(1) = 0;
|
---|
110 | #endif
|
---|
111 | } else {
|
---|
112 | shift = s->B(0);
|
---|
113 | d->W(0) <<= shift;
|
---|
114 | d->W(1) <<= shift;
|
---|
115 | d->W(2) <<= shift;
|
---|
116 | d->W(3) <<= shift;
|
---|
117 | #if SHIFT == 1
|
---|
118 | d->W(4) <<= shift;
|
---|
119 | d->W(5) <<= shift;
|
---|
120 | d->W(6) <<= shift;
|
---|
121 | d->W(7) <<= shift;
|
---|
122 | #endif
|
---|
123 | }
|
---|
124 | FORCE_RET();
|
---|
125 | }
|
---|
126 |
|
---|
127 | void glue(helper_psrld, SUFFIX)(Reg *d, Reg *s)
|
---|
128 | {
|
---|
129 | int shift;
|
---|
130 |
|
---|
131 | if (s->Q(0) > 31) {
|
---|
132 | d->Q(0) = 0;
|
---|
133 | #if SHIFT == 1
|
---|
134 | d->Q(1) = 0;
|
---|
135 | #endif
|
---|
136 | } else {
|
---|
137 | shift = s->B(0);
|
---|
138 | d->L(0) >>= shift;
|
---|
139 | d->L(1) >>= shift;
|
---|
140 | #if SHIFT == 1
|
---|
141 | d->L(2) >>= shift;
|
---|
142 | d->L(3) >>= shift;
|
---|
143 | #endif
|
---|
144 | }
|
---|
145 | FORCE_RET();
|
---|
146 | }
|
---|
147 |
|
---|
148 | void glue(helper_psrad, SUFFIX)(Reg *d, Reg *s)
|
---|
149 | {
|
---|
150 | int shift;
|
---|
151 |
|
---|
152 | if (s->Q(0) > 31) {
|
---|
153 | shift = 31;
|
---|
154 | } else {
|
---|
155 | shift = s->B(0);
|
---|
156 | }
|
---|
157 | d->L(0) = (int32_t)d->L(0) >> shift;
|
---|
158 | d->L(1) = (int32_t)d->L(1) >> shift;
|
---|
159 | #if SHIFT == 1
|
---|
160 | d->L(2) = (int32_t)d->L(2) >> shift;
|
---|
161 | d->L(3) = (int32_t)d->L(3) >> shift;
|
---|
162 | #endif
|
---|
163 | }
|
---|
164 |
|
---|
165 | void glue(helper_pslld, SUFFIX)(Reg *d, Reg *s)
|
---|
166 | {
|
---|
167 | int shift;
|
---|
168 |
|
---|
169 | if (s->Q(0) > 31) {
|
---|
170 | d->Q(0) = 0;
|
---|
171 | #if SHIFT == 1
|
---|
172 | d->Q(1) = 0;
|
---|
173 | #endif
|
---|
174 | } else {
|
---|
175 | shift = s->B(0);
|
---|
176 | d->L(0) <<= shift;
|
---|
177 | d->L(1) <<= shift;
|
---|
178 | #if SHIFT == 1
|
---|
179 | d->L(2) <<= shift;
|
---|
180 | d->L(3) <<= shift;
|
---|
181 | #endif
|
---|
182 | }
|
---|
183 | FORCE_RET();
|
---|
184 | }
|
---|
185 |
|
---|
186 | void glue(helper_psrlq, SUFFIX)(Reg *d, Reg *s)
|
---|
187 | {
|
---|
188 | int shift;
|
---|
189 |
|
---|
190 | if (s->Q(0) > 63) {
|
---|
191 | d->Q(0) = 0;
|
---|
192 | #if SHIFT == 1
|
---|
193 | d->Q(1) = 0;
|
---|
194 | #endif
|
---|
195 | } else {
|
---|
196 | shift = s->B(0);
|
---|
197 | d->Q(0) >>= shift;
|
---|
198 | #if SHIFT == 1
|
---|
199 | d->Q(1) >>= shift;
|
---|
200 | #endif
|
---|
201 | }
|
---|
202 | FORCE_RET();
|
---|
203 | }
|
---|
204 |
|
---|
205 | void glue(helper_psllq, SUFFIX)(Reg *d, Reg *s)
|
---|
206 | {
|
---|
207 | int shift;
|
---|
208 |
|
---|
209 | if (s->Q(0) > 63) {
|
---|
210 | d->Q(0) = 0;
|
---|
211 | #if SHIFT == 1
|
---|
212 | d->Q(1) = 0;
|
---|
213 | #endif
|
---|
214 | } else {
|
---|
215 | shift = s->B(0);
|
---|
216 | d->Q(0) <<= shift;
|
---|
217 | #if SHIFT == 1
|
---|
218 | d->Q(1) <<= shift;
|
---|
219 | #endif
|
---|
220 | }
|
---|
221 | FORCE_RET();
|
---|
222 | }
|
---|
223 |
|
---|
224 | #if SHIFT == 1
|
---|
225 | void glue(helper_psrldq, SUFFIX)(Reg *d, Reg *s)
|
---|
226 | {
|
---|
227 | int shift, i;
|
---|
228 |
|
---|
229 | shift = s->L(0);
|
---|
230 | if (shift > 16)
|
---|
231 | shift = 16;
|
---|
232 | for(i = 0; i < 16 - shift; i++)
|
---|
233 | d->B(i) = d->B(i + shift);
|
---|
234 | for(i = 16 - shift; i < 16; i++)
|
---|
235 | d->B(i) = 0;
|
---|
236 | FORCE_RET();
|
---|
237 | }
|
---|
238 |
|
---|
239 | void glue(helper_pslldq, SUFFIX)(Reg *d, Reg *s)
|
---|
240 | {
|
---|
241 | int shift, i;
|
---|
242 |
|
---|
243 | shift = s->L(0);
|
---|
244 | if (shift > 16)
|
---|
245 | shift = 16;
|
---|
246 | for(i = 15; i >= shift; i--)
|
---|
247 | d->B(i) = d->B(i - shift);
|
---|
248 | for(i = 0; i < shift; i++)
|
---|
249 | d->B(i) = 0;
|
---|
250 | FORCE_RET();
|
---|
251 | }
|
---|
252 | #endif
|
---|
253 |
|
---|
254 | #define SSE_HELPER_B(name, F)\
|
---|
255 | void glue(name, SUFFIX) (Reg *d, Reg *s)\
|
---|
256 | {\
|
---|
257 | d->B(0) = F(d->B(0), s->B(0));\
|
---|
258 | d->B(1) = F(d->B(1), s->B(1));\
|
---|
259 | d->B(2) = F(d->B(2), s->B(2));\
|
---|
260 | d->B(3) = F(d->B(3), s->B(3));\
|
---|
261 | d->B(4) = F(d->B(4), s->B(4));\
|
---|
262 | d->B(5) = F(d->B(5), s->B(5));\
|
---|
263 | d->B(6) = F(d->B(6), s->B(6));\
|
---|
264 | d->B(7) = F(d->B(7), s->B(7));\
|
---|
265 | XMM_ONLY(\
|
---|
266 | d->B(8) = F(d->B(8), s->B(8));\
|
---|
267 | d->B(9) = F(d->B(9), s->B(9));\
|
---|
268 | d->B(10) = F(d->B(10), s->B(10));\
|
---|
269 | d->B(11) = F(d->B(11), s->B(11));\
|
---|
270 | d->B(12) = F(d->B(12), s->B(12));\
|
---|
271 | d->B(13) = F(d->B(13), s->B(13));\
|
---|
272 | d->B(14) = F(d->B(14), s->B(14));\
|
---|
273 | d->B(15) = F(d->B(15), s->B(15));\
|
---|
274 | )\
|
---|
275 | }
|
---|
276 |
|
---|
277 | #define SSE_HELPER_W(name, F)\
|
---|
278 | void glue(name, SUFFIX) (Reg *d, Reg *s)\
|
---|
279 | {\
|
---|
280 | d->W(0) = F(d->W(0), s->W(0));\
|
---|
281 | d->W(1) = F(d->W(1), s->W(1));\
|
---|
282 | d->W(2) = F(d->W(2), s->W(2));\
|
---|
283 | d->W(3) = F(d->W(3), s->W(3));\
|
---|
284 | XMM_ONLY(\
|
---|
285 | d->W(4) = F(d->W(4), s->W(4));\
|
---|
286 | d->W(5) = F(d->W(5), s->W(5));\
|
---|
287 | d->W(6) = F(d->W(6), s->W(6));\
|
---|
288 | d->W(7) = F(d->W(7), s->W(7));\
|
---|
289 | )\
|
---|
290 | }
|
---|
291 |
|
---|
292 | #define SSE_HELPER_L(name, F)\
|
---|
293 | void glue(name, SUFFIX) (Reg *d, Reg *s)\
|
---|
294 | {\
|
---|
295 | d->L(0) = F(d->L(0), s->L(0));\
|
---|
296 | d->L(1) = F(d->L(1), s->L(1));\
|
---|
297 | XMM_ONLY(\
|
---|
298 | d->L(2) = F(d->L(2), s->L(2));\
|
---|
299 | d->L(3) = F(d->L(3), s->L(3));\
|
---|
300 | )\
|
---|
301 | }
|
---|
302 |
|
---|
303 | #define SSE_HELPER_Q(name, F)\
|
---|
304 | void glue(name, SUFFIX) (Reg *d, Reg *s)\
|
---|
305 | {\
|
---|
306 | d->Q(0) = F(d->Q(0), s->Q(0));\
|
---|
307 | XMM_ONLY(\
|
---|
308 | d->Q(1) = F(d->Q(1), s->Q(1));\
|
---|
309 | )\
|
---|
310 | }
|
---|
311 |
|
---|
312 | #if SHIFT == 0
|
---|
313 | #ifndef VBOX
|
---|
314 | static inline int satub(int x)
|
---|
315 | #else /* VBOX */
|
---|
316 | DECLINLINE(int) satub(int x)
|
---|
317 | #endif /* VBOX */
|
---|
318 | {
|
---|
319 | if (x < 0)
|
---|
320 | return 0;
|
---|
321 | else if (x > 255)
|
---|
322 | return 255;
|
---|
323 | else
|
---|
324 | return x;
|
---|
325 | }
|
---|
326 |
|
---|
327 | #ifndef VBOX
|
---|
328 | static inline int satuw(int x)
|
---|
329 | #else /* VBOX */
|
---|
330 | DECLINLINE(int) satuw(int x)
|
---|
331 | #endif /* VBOX */
|
---|
332 | {
|
---|
333 | if (x < 0)
|
---|
334 | return 0;
|
---|
335 | else if (x > 65535)
|
---|
336 | return 65535;
|
---|
337 | else
|
---|
338 | return x;
|
---|
339 | }
|
---|
340 |
|
---|
341 | #ifndef VBOX
|
---|
342 | static inline int satsb(int x)
|
---|
343 | #else /* VBOX */
|
---|
344 | DECLINLINE(int) satsb(int x)
|
---|
345 | #endif /* VBOX */
|
---|
346 | {
|
---|
347 | if (x < -128)
|
---|
348 | return -128;
|
---|
349 | else if (x > 127)
|
---|
350 | return 127;
|
---|
351 | else
|
---|
352 | return x;
|
---|
353 | }
|
---|
354 |
|
---|
355 | #ifndef VBOX
|
---|
356 | static inline int satsw(int x)
|
---|
357 | #else /* VBOX */
|
---|
358 | DECLINLINE(int) satsw(int x)
|
---|
359 | #endif /* VBOX */
|
---|
360 | {
|
---|
361 | if (x < -32768)
|
---|
362 | return -32768;
|
---|
363 | else if (x > 32767)
|
---|
364 | return 32767;
|
---|
365 | else
|
---|
366 | return x;
|
---|
367 | }
|
---|
368 |
|
---|
369 | #define FADD(a, b) ((a) + (b))
|
---|
370 | #define FADDUB(a, b) satub((a) + (b))
|
---|
371 | #define FADDUW(a, b) satuw((a) + (b))
|
---|
372 | #define FADDSB(a, b) satsb((int8_t)(a) + (int8_t)(b))
|
---|
373 | #define FADDSW(a, b) satsw((int16_t)(a) + (int16_t)(b))
|
---|
374 |
|
---|
375 | #define FSUB(a, b) ((a) - (b))
|
---|
376 | #define FSUBUB(a, b) satub((a) - (b))
|
---|
377 | #define FSUBUW(a, b) satuw((a) - (b))
|
---|
378 | #define FSUBSB(a, b) satsb((int8_t)(a) - (int8_t)(b))
|
---|
379 | #define FSUBSW(a, b) satsw((int16_t)(a) - (int16_t)(b))
|
---|
380 | #define FMINUB(a, b) ((a) < (b)) ? (a) : (b)
|
---|
381 | #define FMINSW(a, b) ((int16_t)(a) < (int16_t)(b)) ? (a) : (b)
|
---|
382 | #define FMAXUB(a, b) ((a) > (b)) ? (a) : (b)
|
---|
383 | #define FMAXSW(a, b) ((int16_t)(a) > (int16_t)(b)) ? (a) : (b)
|
---|
384 |
|
---|
385 | #define FAND(a, b) (a) & (b)
|
---|
386 | #define FANDN(a, b) ((~(a)) & (b))
|
---|
387 | #define FOR(a, b) (a) | (b)
|
---|
388 | #define FXOR(a, b) (a) ^ (b)
|
---|
389 |
|
---|
390 | #define FCMPGTB(a, b) (int8_t)(a) > (int8_t)(b) ? -1 : 0
|
---|
391 | #define FCMPGTW(a, b) (int16_t)(a) > (int16_t)(b) ? -1 : 0
|
---|
392 | #define FCMPGTL(a, b) (int32_t)(a) > (int32_t)(b) ? -1 : 0
|
---|
393 | #define FCMPEQ(a, b) (a) == (b) ? -1 : 0
|
---|
394 |
|
---|
395 | #define FMULLW(a, b) (a) * (b)
|
---|
396 | #define FMULHRW(a, b) ((int16_t)(a) * (int16_t)(b) + 0x8000) >> 16
|
---|
397 | #define FMULHUW(a, b) (a) * (b) >> 16
|
---|
398 | #define FMULHW(a, b) (int16_t)(a) * (int16_t)(b) >> 16
|
---|
399 |
|
---|
400 | #define FAVG(a, b) ((a) + (b) + 1) >> 1
|
---|
401 | #endif
|
---|
402 |
|
---|
403 | SSE_HELPER_B(helper_paddb, FADD)
|
---|
404 | SSE_HELPER_W(helper_paddw, FADD)
|
---|
405 | SSE_HELPER_L(helper_paddl, FADD)
|
---|
406 | SSE_HELPER_Q(helper_paddq, FADD)
|
---|
407 |
|
---|
408 | SSE_HELPER_B(helper_psubb, FSUB)
|
---|
409 | SSE_HELPER_W(helper_psubw, FSUB)
|
---|
410 | SSE_HELPER_L(helper_psubl, FSUB)
|
---|
411 | SSE_HELPER_Q(helper_psubq, FSUB)
|
---|
412 |
|
---|
413 | SSE_HELPER_B(helper_paddusb, FADDUB)
|
---|
414 | SSE_HELPER_B(helper_paddsb, FADDSB)
|
---|
415 | SSE_HELPER_B(helper_psubusb, FSUBUB)
|
---|
416 | SSE_HELPER_B(helper_psubsb, FSUBSB)
|
---|
417 |
|
---|
418 | SSE_HELPER_W(helper_paddusw, FADDUW)
|
---|
419 | SSE_HELPER_W(helper_paddsw, FADDSW)
|
---|
420 | SSE_HELPER_W(helper_psubusw, FSUBUW)
|
---|
421 | SSE_HELPER_W(helper_psubsw, FSUBSW)
|
---|
422 |
|
---|
423 | SSE_HELPER_B(helper_pminub, FMINUB)
|
---|
424 | SSE_HELPER_B(helper_pmaxub, FMAXUB)
|
---|
425 |
|
---|
426 | SSE_HELPER_W(helper_pminsw, FMINSW)
|
---|
427 | SSE_HELPER_W(helper_pmaxsw, FMAXSW)
|
---|
428 |
|
---|
429 | SSE_HELPER_Q(helper_pand, FAND)
|
---|
430 | SSE_HELPER_Q(helper_pandn, FANDN)
|
---|
431 | SSE_HELPER_Q(helper_por, FOR)
|
---|
432 | SSE_HELPER_Q(helper_pxor, FXOR)
|
---|
433 |
|
---|
434 | SSE_HELPER_B(helper_pcmpgtb, FCMPGTB)
|
---|
435 | SSE_HELPER_W(helper_pcmpgtw, FCMPGTW)
|
---|
436 | SSE_HELPER_L(helper_pcmpgtl, FCMPGTL)
|
---|
437 |
|
---|
438 | SSE_HELPER_B(helper_pcmpeqb, FCMPEQ)
|
---|
439 | SSE_HELPER_W(helper_pcmpeqw, FCMPEQ)
|
---|
440 | SSE_HELPER_L(helper_pcmpeql, FCMPEQ)
|
---|
441 |
|
---|
442 | SSE_HELPER_W(helper_pmullw, FMULLW)
|
---|
443 | #if SHIFT == 0
|
---|
444 | SSE_HELPER_W(helper_pmulhrw, FMULHRW)
|
---|
445 | #endif
|
---|
446 | SSE_HELPER_W(helper_pmulhuw, FMULHUW)
|
---|
447 | SSE_HELPER_W(helper_pmulhw, FMULHW)
|
---|
448 |
|
---|
449 | SSE_HELPER_B(helper_pavgb, FAVG)
|
---|
450 | SSE_HELPER_W(helper_pavgw, FAVG)
|
---|
451 |
|
---|
452 | void glue(helper_pmuludq, SUFFIX) (Reg *d, Reg *s)
|
---|
453 | {
|
---|
454 | d->Q(0) = (uint64_t)s->L(0) * (uint64_t)d->L(0);
|
---|
455 | #if SHIFT == 1
|
---|
456 | d->Q(1) = (uint64_t)s->L(2) * (uint64_t)d->L(2);
|
---|
457 | #endif
|
---|
458 | }
|
---|
459 |
|
---|
460 | void glue(helper_pmaddwd, SUFFIX) (Reg *d, Reg *s)
|
---|
461 | {
|
---|
462 | int i;
|
---|
463 |
|
---|
464 | for(i = 0; i < (2 << SHIFT); i++) {
|
---|
465 | d->L(i) = (int16_t)s->W(2*i) * (int16_t)d->W(2*i) +
|
---|
466 | (int16_t)s->W(2*i+1) * (int16_t)d->W(2*i+1);
|
---|
467 | }
|
---|
468 | FORCE_RET();
|
---|
469 | }
|
---|
470 |
|
---|
471 | #if SHIFT == 0
|
---|
472 | #ifndef VBOX
|
---|
473 | static inline int abs1(int a)
|
---|
474 | #else /* VBOX */
|
---|
475 | DECLINLINE(int) abs1(int a)
|
---|
476 | #endif /* VBOX */
|
---|
477 | {
|
---|
478 | if (a < 0)
|
---|
479 | return -a;
|
---|
480 | else
|
---|
481 | return a;
|
---|
482 | }
|
---|
483 | #endif
|
---|
484 | void glue(helper_psadbw, SUFFIX) (Reg *d, Reg *s)
|
---|
485 | {
|
---|
486 | unsigned int val;
|
---|
487 |
|
---|
488 | val = 0;
|
---|
489 | val += abs1(d->B(0) - s->B(0));
|
---|
490 | val += abs1(d->B(1) - s->B(1));
|
---|
491 | val += abs1(d->B(2) - s->B(2));
|
---|
492 | val += abs1(d->B(3) - s->B(3));
|
---|
493 | val += abs1(d->B(4) - s->B(4));
|
---|
494 | val += abs1(d->B(5) - s->B(5));
|
---|
495 | val += abs1(d->B(6) - s->B(6));
|
---|
496 | val += abs1(d->B(7) - s->B(7));
|
---|
497 | d->Q(0) = val;
|
---|
498 | #if SHIFT == 1
|
---|
499 | val = 0;
|
---|
500 | val += abs1(d->B(8) - s->B(8));
|
---|
501 | val += abs1(d->B(9) - s->B(9));
|
---|
502 | val += abs1(d->B(10) - s->B(10));
|
---|
503 | val += abs1(d->B(11) - s->B(11));
|
---|
504 | val += abs1(d->B(12) - s->B(12));
|
---|
505 | val += abs1(d->B(13) - s->B(13));
|
---|
506 | val += abs1(d->B(14) - s->B(14));
|
---|
507 | val += abs1(d->B(15) - s->B(15));
|
---|
508 | d->Q(1) = val;
|
---|
509 | #endif
|
---|
510 | }
|
---|
511 |
|
---|
512 | void glue(helper_maskmov, SUFFIX) (Reg *d, Reg *s, target_ulong a0)
|
---|
513 | {
|
---|
514 | int i;
|
---|
515 | for(i = 0; i < (8 << SHIFT); i++) {
|
---|
516 | if (s->B(i) & 0x80)
|
---|
517 | stb(a0 + i, d->B(i));
|
---|
518 | }
|
---|
519 | FORCE_RET();
|
---|
520 | }
|
---|
521 |
|
---|
522 | void glue(helper_movl_mm_T0, SUFFIX) (Reg *d, uint32_t val)
|
---|
523 | {
|
---|
524 | d->L(0) = val;
|
---|
525 | d->L(1) = 0;
|
---|
526 | #if SHIFT == 1
|
---|
527 | d->Q(1) = 0;
|
---|
528 | #endif
|
---|
529 | }
|
---|
530 |
|
---|
531 | #ifdef TARGET_X86_64
|
---|
532 | void glue(helper_movq_mm_T0, SUFFIX) (Reg *d, uint64_t val)
|
---|
533 | {
|
---|
534 | d->Q(0) = val;
|
---|
535 | #if SHIFT == 1
|
---|
536 | d->Q(1) = 0;
|
---|
537 | #endif
|
---|
538 | }
|
---|
539 | #endif
|
---|
540 |
|
---|
541 | #if SHIFT == 0
|
---|
542 | void glue(helper_pshufw, SUFFIX) (Reg *d, Reg *s, int order)
|
---|
543 | {
|
---|
544 | Reg r;
|
---|
545 | r.W(0) = s->W(order & 3);
|
---|
546 | r.W(1) = s->W((order >> 2) & 3);
|
---|
547 | r.W(2) = s->W((order >> 4) & 3);
|
---|
548 | r.W(3) = s->W((order >> 6) & 3);
|
---|
549 | *d = r;
|
---|
550 | }
|
---|
551 | #else
|
---|
552 | void helper_shufps(Reg *d, Reg *s, int order)
|
---|
553 | {
|
---|
554 | Reg r;
|
---|
555 | r.L(0) = d->L(order & 3);
|
---|
556 | r.L(1) = d->L((order >> 2) & 3);
|
---|
557 | r.L(2) = s->L((order >> 4) & 3);
|
---|
558 | r.L(3) = s->L((order >> 6) & 3);
|
---|
559 | *d = r;
|
---|
560 | }
|
---|
561 |
|
---|
562 | void helper_shufpd(Reg *d, Reg *s, int order)
|
---|
563 | {
|
---|
564 | Reg r;
|
---|
565 | r.Q(0) = d->Q(order & 1);
|
---|
566 | r.Q(1) = s->Q((order >> 1) & 1);
|
---|
567 | *d = r;
|
---|
568 | }
|
---|
569 |
|
---|
570 | void glue(helper_pshufd, SUFFIX) (Reg *d, Reg *s, int order)
|
---|
571 | {
|
---|
572 | Reg r;
|
---|
573 | r.L(0) = s->L(order & 3);
|
---|
574 | r.L(1) = s->L((order >> 2) & 3);
|
---|
575 | r.L(2) = s->L((order >> 4) & 3);
|
---|
576 | r.L(3) = s->L((order >> 6) & 3);
|
---|
577 | *d = r;
|
---|
578 | }
|
---|
579 |
|
---|
580 | void glue(helper_pshuflw, SUFFIX) (Reg *d, Reg *s, int order)
|
---|
581 | {
|
---|
582 | Reg r;
|
---|
583 | r.W(0) = s->W(order & 3);
|
---|
584 | r.W(1) = s->W((order >> 2) & 3);
|
---|
585 | r.W(2) = s->W((order >> 4) & 3);
|
---|
586 | r.W(3) = s->W((order >> 6) & 3);
|
---|
587 | r.Q(1) = s->Q(1);
|
---|
588 | *d = r;
|
---|
589 | }
|
---|
590 |
|
---|
591 | void glue(helper_pshufhw, SUFFIX) (Reg *d, Reg *s, int order)
|
---|
592 | {
|
---|
593 | Reg r;
|
---|
594 | r.Q(0) = s->Q(0);
|
---|
595 | r.W(4) = s->W(4 + (order & 3));
|
---|
596 | r.W(5) = s->W(4 + ((order >> 2) & 3));
|
---|
597 | r.W(6) = s->W(4 + ((order >> 4) & 3));
|
---|
598 | r.W(7) = s->W(4 + ((order >> 6) & 3));
|
---|
599 | *d = r;
|
---|
600 | }
|
---|
601 | #endif
|
---|
602 |
|
---|
603 | #if SHIFT == 1
|
---|
604 | /* FPU ops */
|
---|
605 | /* XXX: not accurate */
|
---|
606 |
|
---|
607 | #define SSE_HELPER_S(name, F)\
|
---|
608 | void helper_ ## name ## ps (Reg *d, Reg *s)\
|
---|
609 | {\
|
---|
610 | d->XMM_S(0) = F(32, d->XMM_S(0), s->XMM_S(0));\
|
---|
611 | d->XMM_S(1) = F(32, d->XMM_S(1), s->XMM_S(1));\
|
---|
612 | d->XMM_S(2) = F(32, d->XMM_S(2), s->XMM_S(2));\
|
---|
613 | d->XMM_S(3) = F(32, d->XMM_S(3), s->XMM_S(3));\
|
---|
614 | }\
|
---|
615 | \
|
---|
616 | void helper_ ## name ## ss (Reg *d, Reg *s)\
|
---|
617 | {\
|
---|
618 | d->XMM_S(0) = F(32, d->XMM_S(0), s->XMM_S(0));\
|
---|
619 | }\
|
---|
620 | void helper_ ## name ## pd (Reg *d, Reg *s)\
|
---|
621 | {\
|
---|
622 | d->XMM_D(0) = F(64, d->XMM_D(0), s->XMM_D(0));\
|
---|
623 | d->XMM_D(1) = F(64, d->XMM_D(1), s->XMM_D(1));\
|
---|
624 | }\
|
---|
625 | \
|
---|
626 | void helper_ ## name ## sd (Reg *d, Reg *s)\
|
---|
627 | {\
|
---|
628 | d->XMM_D(0) = F(64, d->XMM_D(0), s->XMM_D(0));\
|
---|
629 | }
|
---|
630 |
|
---|
631 | #define FPU_ADD(size, a, b) float ## size ## _add(a, b, &env->sse_status)
|
---|
632 | #define FPU_SUB(size, a, b) float ## size ## _sub(a, b, &env->sse_status)
|
---|
633 | #define FPU_MUL(size, a, b) float ## size ## _mul(a, b, &env->sse_status)
|
---|
634 | #define FPU_DIV(size, a, b) float ## size ## _div(a, b, &env->sse_status)
|
---|
635 | #define FPU_MIN(size, a, b) (a) < (b) ? (a) : (b)
|
---|
636 | #define FPU_MAX(size, a, b) (a) > (b) ? (a) : (b)
|
---|
637 | #define FPU_SQRT(size, a, b) float ## size ## _sqrt(b, &env->sse_status)
|
---|
638 |
|
---|
639 | SSE_HELPER_S(add, FPU_ADD)
|
---|
640 | SSE_HELPER_S(sub, FPU_SUB)
|
---|
641 | SSE_HELPER_S(mul, FPU_MUL)
|
---|
642 | SSE_HELPER_S(div, FPU_DIV)
|
---|
643 | SSE_HELPER_S(min, FPU_MIN)
|
---|
644 | SSE_HELPER_S(max, FPU_MAX)
|
---|
645 | SSE_HELPER_S(sqrt, FPU_SQRT)
|
---|
646 |
|
---|
647 |
|
---|
648 | /* float to float conversions */
|
---|
649 | void helper_cvtps2pd(Reg *d, Reg *s)
|
---|
650 | {
|
---|
651 | float32 s0, s1;
|
---|
652 | s0 = s->XMM_S(0);
|
---|
653 | s1 = s->XMM_S(1);
|
---|
654 | d->XMM_D(0) = float32_to_float64(s0, &env->sse_status);
|
---|
655 | d->XMM_D(1) = float32_to_float64(s1, &env->sse_status);
|
---|
656 | }
|
---|
657 |
|
---|
658 | void helper_cvtpd2ps(Reg *d, Reg *s)
|
---|
659 | {
|
---|
660 | d->XMM_S(0) = float64_to_float32(s->XMM_D(0), &env->sse_status);
|
---|
661 | d->XMM_S(1) = float64_to_float32(s->XMM_D(1), &env->sse_status);
|
---|
662 | d->Q(1) = 0;
|
---|
663 | }
|
---|
664 |
|
---|
665 | void helper_cvtss2sd(Reg *d, Reg *s)
|
---|
666 | {
|
---|
667 | d->XMM_D(0) = float32_to_float64(s->XMM_S(0), &env->sse_status);
|
---|
668 | }
|
---|
669 |
|
---|
670 | void helper_cvtsd2ss(Reg *d, Reg *s)
|
---|
671 | {
|
---|
672 | d->XMM_S(0) = float64_to_float32(s->XMM_D(0), &env->sse_status);
|
---|
673 | }
|
---|
674 |
|
---|
675 | /* integer to float */
|
---|
676 | void helper_cvtdq2ps(Reg *d, Reg *s)
|
---|
677 | {
|
---|
678 | d->XMM_S(0) = int32_to_float32(s->XMM_L(0), &env->sse_status);
|
---|
679 | d->XMM_S(1) = int32_to_float32(s->XMM_L(1), &env->sse_status);
|
---|
680 | d->XMM_S(2) = int32_to_float32(s->XMM_L(2), &env->sse_status);
|
---|
681 | d->XMM_S(3) = int32_to_float32(s->XMM_L(3), &env->sse_status);
|
---|
682 | }
|
---|
683 |
|
---|
684 | void helper_cvtdq2pd(Reg *d, Reg *s)
|
---|
685 | {
|
---|
686 | int32_t l0, l1;
|
---|
687 | l0 = (int32_t)s->XMM_L(0);
|
---|
688 | l1 = (int32_t)s->XMM_L(1);
|
---|
689 | d->XMM_D(0) = int32_to_float64(l0, &env->sse_status);
|
---|
690 | d->XMM_D(1) = int32_to_float64(l1, &env->sse_status);
|
---|
691 | }
|
---|
692 |
|
---|
693 | void helper_cvtpi2ps(XMMReg *d, MMXReg *s)
|
---|
694 | {
|
---|
695 | d->XMM_S(0) = int32_to_float32(s->MMX_L(0), &env->sse_status);
|
---|
696 | d->XMM_S(1) = int32_to_float32(s->MMX_L(1), &env->sse_status);
|
---|
697 | }
|
---|
698 |
|
---|
699 | void helper_cvtpi2pd(XMMReg *d, MMXReg *s)
|
---|
700 | {
|
---|
701 | d->XMM_D(0) = int32_to_float64(s->MMX_L(0), &env->sse_status);
|
---|
702 | d->XMM_D(1) = int32_to_float64(s->MMX_L(1), &env->sse_status);
|
---|
703 | }
|
---|
704 |
|
---|
705 | void helper_cvtsi2ss(XMMReg *d, uint32_t val)
|
---|
706 | {
|
---|
707 | d->XMM_S(0) = int32_to_float32(val, &env->sse_status);
|
---|
708 | }
|
---|
709 |
|
---|
710 | void helper_cvtsi2sd(XMMReg *d, uint32_t val)
|
---|
711 | {
|
---|
712 | d->XMM_D(0) = int32_to_float64(val, &env->sse_status);
|
---|
713 | }
|
---|
714 |
|
---|
715 | #ifdef TARGET_X86_64
|
---|
716 | void helper_cvtsq2ss(XMMReg *d, uint64_t val)
|
---|
717 | {
|
---|
718 | d->XMM_S(0) = int64_to_float32(val, &env->sse_status);
|
---|
719 | }
|
---|
720 |
|
---|
721 | void helper_cvtsq2sd(XMMReg *d, uint64_t val)
|
---|
722 | {
|
---|
723 | d->XMM_D(0) = int64_to_float64(val, &env->sse_status);
|
---|
724 | }
|
---|
725 | #endif
|
---|
726 |
|
---|
727 | /* float to integer */
|
---|
728 | void helper_cvtps2dq(XMMReg *d, XMMReg *s)
|
---|
729 | {
|
---|
730 | d->XMM_L(0) = float32_to_int32(s->XMM_S(0), &env->sse_status);
|
---|
731 | d->XMM_L(1) = float32_to_int32(s->XMM_S(1), &env->sse_status);
|
---|
732 | d->XMM_L(2) = float32_to_int32(s->XMM_S(2), &env->sse_status);
|
---|
733 | d->XMM_L(3) = float32_to_int32(s->XMM_S(3), &env->sse_status);
|
---|
734 | }
|
---|
735 |
|
---|
736 | void helper_cvtpd2dq(XMMReg *d, XMMReg *s)
|
---|
737 | {
|
---|
738 | d->XMM_L(0) = float64_to_int32(s->XMM_D(0), &env->sse_status);
|
---|
739 | d->XMM_L(1) = float64_to_int32(s->XMM_D(1), &env->sse_status);
|
---|
740 | d->XMM_Q(1) = 0;
|
---|
741 | }
|
---|
742 |
|
---|
743 | void helper_cvtps2pi(MMXReg *d, XMMReg *s)
|
---|
744 | {
|
---|
745 | d->MMX_L(0) = float32_to_int32(s->XMM_S(0), &env->sse_status);
|
---|
746 | d->MMX_L(1) = float32_to_int32(s->XMM_S(1), &env->sse_status);
|
---|
747 | }
|
---|
748 |
|
---|
749 | void helper_cvtpd2pi(MMXReg *d, XMMReg *s)
|
---|
750 | {
|
---|
751 | d->MMX_L(0) = float64_to_int32(s->XMM_D(0), &env->sse_status);
|
---|
752 | d->MMX_L(1) = float64_to_int32(s->XMM_D(1), &env->sse_status);
|
---|
753 | }
|
---|
754 |
|
---|
755 | int32_t helper_cvtss2si(XMMReg *s)
|
---|
756 | {
|
---|
757 | return float32_to_int32(s->XMM_S(0), &env->sse_status);
|
---|
758 | }
|
---|
759 |
|
---|
760 | int32_t helper_cvtsd2si(XMMReg *s)
|
---|
761 | {
|
---|
762 | return float64_to_int32(s->XMM_D(0), &env->sse_status);
|
---|
763 | }
|
---|
764 |
|
---|
765 | #ifdef TARGET_X86_64
|
---|
766 | int64_t helper_cvtss2sq(XMMReg *s)
|
---|
767 | {
|
---|
768 | return float32_to_int64(s->XMM_S(0), &env->sse_status);
|
---|
769 | }
|
---|
770 |
|
---|
771 | int64_t helper_cvtsd2sq(XMMReg *s)
|
---|
772 | {
|
---|
773 | return float64_to_int64(s->XMM_D(0), &env->sse_status);
|
---|
774 | }
|
---|
775 | #endif
|
---|
776 |
|
---|
777 | /* float to integer truncated */
|
---|
778 | void helper_cvttps2dq(XMMReg *d, XMMReg *s)
|
---|
779 | {
|
---|
780 | d->XMM_L(0) = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status);
|
---|
781 | d->XMM_L(1) = float32_to_int32_round_to_zero(s->XMM_S(1), &env->sse_status);
|
---|
782 | d->XMM_L(2) = float32_to_int32_round_to_zero(s->XMM_S(2), &env->sse_status);
|
---|
783 | d->XMM_L(3) = float32_to_int32_round_to_zero(s->XMM_S(3), &env->sse_status);
|
---|
784 | }
|
---|
785 |
|
---|
786 | void helper_cvttpd2dq(XMMReg *d, XMMReg *s)
|
---|
787 | {
|
---|
788 | d->XMM_L(0) = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status);
|
---|
789 | d->XMM_L(1) = float64_to_int32_round_to_zero(s->XMM_D(1), &env->sse_status);
|
---|
790 | d->XMM_Q(1) = 0;
|
---|
791 | }
|
---|
792 |
|
---|
793 | void helper_cvttps2pi(MMXReg *d, XMMReg *s)
|
---|
794 | {
|
---|
795 | d->MMX_L(0) = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status);
|
---|
796 | d->MMX_L(1) = float32_to_int32_round_to_zero(s->XMM_S(1), &env->sse_status);
|
---|
797 | }
|
---|
798 |
|
---|
799 | void helper_cvttpd2pi(MMXReg *d, XMMReg *s)
|
---|
800 | {
|
---|
801 | d->MMX_L(0) = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status);
|
---|
802 | d->MMX_L(1) = float64_to_int32_round_to_zero(s->XMM_D(1), &env->sse_status);
|
---|
803 | }
|
---|
804 |
|
---|
805 | int32_t helper_cvttss2si(XMMReg *s)
|
---|
806 | {
|
---|
807 | return float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status);
|
---|
808 | }
|
---|
809 |
|
---|
810 | int32_t helper_cvttsd2si(XMMReg *s)
|
---|
811 | {
|
---|
812 | return float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status);
|
---|
813 | }
|
---|
814 |
|
---|
815 | #ifdef TARGET_X86_64
|
---|
816 | int64_t helper_cvttss2sq(XMMReg *s)
|
---|
817 | {
|
---|
818 | return float32_to_int64_round_to_zero(s->XMM_S(0), &env->sse_status);
|
---|
819 | }
|
---|
820 |
|
---|
821 | int64_t helper_cvttsd2sq(XMMReg *s)
|
---|
822 | {
|
---|
823 | return float64_to_int64_round_to_zero(s->XMM_D(0), &env->sse_status);
|
---|
824 | }
|
---|
825 | #endif
|
---|
826 |
|
---|
827 | void helper_rsqrtps(XMMReg *d, XMMReg *s)
|
---|
828 | {
|
---|
829 | d->XMM_S(0) = approx_rsqrt(s->XMM_S(0));
|
---|
830 | d->XMM_S(1) = approx_rsqrt(s->XMM_S(1));
|
---|
831 | d->XMM_S(2) = approx_rsqrt(s->XMM_S(2));
|
---|
832 | d->XMM_S(3) = approx_rsqrt(s->XMM_S(3));
|
---|
833 | }
|
---|
834 |
|
---|
835 | void helper_rsqrtss(XMMReg *d, XMMReg *s)
|
---|
836 | {
|
---|
837 | d->XMM_S(0) = approx_rsqrt(s->XMM_S(0));
|
---|
838 | }
|
---|
839 |
|
---|
840 | void helper_rcpps(XMMReg *d, XMMReg *s)
|
---|
841 | {
|
---|
842 | d->XMM_S(0) = approx_rcp(s->XMM_S(0));
|
---|
843 | d->XMM_S(1) = approx_rcp(s->XMM_S(1));
|
---|
844 | d->XMM_S(2) = approx_rcp(s->XMM_S(2));
|
---|
845 | d->XMM_S(3) = approx_rcp(s->XMM_S(3));
|
---|
846 | }
|
---|
847 |
|
---|
848 | void helper_rcpss(XMMReg *d, XMMReg *s)
|
---|
849 | {
|
---|
850 | d->XMM_S(0) = approx_rcp(s->XMM_S(0));
|
---|
851 | }
|
---|
852 |
|
---|
853 | void helper_haddps(XMMReg *d, XMMReg *s)
|
---|
854 | {
|
---|
855 | XMMReg r;
|
---|
856 | r.XMM_S(0) = d->XMM_S(0) + d->XMM_S(1);
|
---|
857 | r.XMM_S(1) = d->XMM_S(2) + d->XMM_S(3);
|
---|
858 | r.XMM_S(2) = s->XMM_S(0) + s->XMM_S(1);
|
---|
859 | r.XMM_S(3) = s->XMM_S(2) + s->XMM_S(3);
|
---|
860 | *d = r;
|
---|
861 | }
|
---|
862 |
|
---|
863 | void helper_haddpd(XMMReg *d, XMMReg *s)
|
---|
864 | {
|
---|
865 | XMMReg r;
|
---|
866 | r.XMM_D(0) = d->XMM_D(0) + d->XMM_D(1);
|
---|
867 | r.XMM_D(1) = s->XMM_D(0) + s->XMM_D(1);
|
---|
868 | *d = r;
|
---|
869 | }
|
---|
870 |
|
---|
871 | void helper_hsubps(XMMReg *d, XMMReg *s)
|
---|
872 | {
|
---|
873 | XMMReg r;
|
---|
874 | r.XMM_S(0) = d->XMM_S(0) - d->XMM_S(1);
|
---|
875 | r.XMM_S(1) = d->XMM_S(2) - d->XMM_S(3);
|
---|
876 | r.XMM_S(2) = s->XMM_S(0) - s->XMM_S(1);
|
---|
877 | r.XMM_S(3) = s->XMM_S(2) - s->XMM_S(3);
|
---|
878 | *d = r;
|
---|
879 | }
|
---|
880 |
|
---|
881 | void helper_hsubpd(XMMReg *d, XMMReg *s)
|
---|
882 | {
|
---|
883 | XMMReg r;
|
---|
884 | r.XMM_D(0) = d->XMM_D(0) - d->XMM_D(1);
|
---|
885 | r.XMM_D(1) = s->XMM_D(0) - s->XMM_D(1);
|
---|
886 | *d = r;
|
---|
887 | }
|
---|
888 |
|
---|
889 | void helper_addsubps(XMMReg *d, XMMReg *s)
|
---|
890 | {
|
---|
891 | d->XMM_S(0) = d->XMM_S(0) - s->XMM_S(0);
|
---|
892 | d->XMM_S(1) = d->XMM_S(1) + s->XMM_S(1);
|
---|
893 | d->XMM_S(2) = d->XMM_S(2) - s->XMM_S(2);
|
---|
894 | d->XMM_S(3) = d->XMM_S(3) + s->XMM_S(3);
|
---|
895 | }
|
---|
896 |
|
---|
897 | void helper_addsubpd(XMMReg *d, XMMReg *s)
|
---|
898 | {
|
---|
899 | d->XMM_D(0) = d->XMM_D(0) - s->XMM_D(0);
|
---|
900 | d->XMM_D(1) = d->XMM_D(1) + s->XMM_D(1);
|
---|
901 | }
|
---|
902 |
|
---|
903 | /* XXX: unordered */
|
---|
904 | #define SSE_HELPER_CMP(name, F)\
|
---|
905 | void helper_ ## name ## ps (Reg *d, Reg *s)\
|
---|
906 | {\
|
---|
907 | d->XMM_L(0) = F(32, d->XMM_S(0), s->XMM_S(0));\
|
---|
908 | d->XMM_L(1) = F(32, d->XMM_S(1), s->XMM_S(1));\
|
---|
909 | d->XMM_L(2) = F(32, d->XMM_S(2), s->XMM_S(2));\
|
---|
910 | d->XMM_L(3) = F(32, d->XMM_S(3), s->XMM_S(3));\
|
---|
911 | }\
|
---|
912 | \
|
---|
913 | void helper_ ## name ## ss (Reg *d, Reg *s)\
|
---|
914 | {\
|
---|
915 | d->XMM_L(0) = F(32, d->XMM_S(0), s->XMM_S(0));\
|
---|
916 | }\
|
---|
917 | void helper_ ## name ## pd (Reg *d, Reg *s)\
|
---|
918 | {\
|
---|
919 | d->XMM_Q(0) = F(64, d->XMM_D(0), s->XMM_D(0));\
|
---|
920 | d->XMM_Q(1) = F(64, d->XMM_D(1), s->XMM_D(1));\
|
---|
921 | }\
|
---|
922 | \
|
---|
923 | void helper_ ## name ## sd (Reg *d, Reg *s)\
|
---|
924 | {\
|
---|
925 | d->XMM_Q(0) = F(64, d->XMM_D(0), s->XMM_D(0));\
|
---|
926 | }
|
---|
927 |
|
---|
928 | #define FPU_CMPEQ(size, a, b) float ## size ## _eq(a, b, &env->sse_status) ? -1 : 0
|
---|
929 | #define FPU_CMPLT(size, a, b) float ## size ## _lt(a, b, &env->sse_status) ? -1 : 0
|
---|
930 | #define FPU_CMPLE(size, a, b) float ## size ## _le(a, b, &env->sse_status) ? -1 : 0
|
---|
931 | #define FPU_CMPUNORD(size, a, b) float ## size ## _unordered(a, b, &env->sse_status) ? - 1 : 0
|
---|
932 | #define FPU_CMPNEQ(size, a, b) float ## size ## _eq(a, b, &env->sse_status) ? 0 : -1
|
---|
933 | #define FPU_CMPNLT(size, a, b) float ## size ## _lt(a, b, &env->sse_status) ? 0 : -1
|
---|
934 | #define FPU_CMPNLE(size, a, b) float ## size ## _le(a, b, &env->sse_status) ? 0 : -1
|
---|
935 | #define FPU_CMPORD(size, a, b) float ## size ## _unordered(a, b, &env->sse_status) ? 0 : -1
|
---|
936 |
|
---|
937 | SSE_HELPER_CMP(cmpeq, FPU_CMPEQ)
|
---|
938 | SSE_HELPER_CMP(cmplt, FPU_CMPLT)
|
---|
939 | SSE_HELPER_CMP(cmple, FPU_CMPLE)
|
---|
940 | SSE_HELPER_CMP(cmpunord, FPU_CMPUNORD)
|
---|
941 | SSE_HELPER_CMP(cmpneq, FPU_CMPNEQ)
|
---|
942 | SSE_HELPER_CMP(cmpnlt, FPU_CMPNLT)
|
---|
943 | SSE_HELPER_CMP(cmpnle, FPU_CMPNLE)
|
---|
944 | SSE_HELPER_CMP(cmpord, FPU_CMPORD)
|
---|
945 |
|
---|
946 | const int comis_eflags[4] = {CC_C, CC_Z, 0, CC_Z | CC_P | CC_C};
|
---|
947 |
|
---|
948 | void helper_ucomiss(Reg *d, Reg *s)
|
---|
949 | {
|
---|
950 | int ret;
|
---|
951 | float32 s0, s1;
|
---|
952 |
|
---|
953 | s0 = d->XMM_S(0);
|
---|
954 | s1 = s->XMM_S(0);
|
---|
955 | ret = float32_compare_quiet(s0, s1, &env->sse_status);
|
---|
956 | CC_SRC = comis_eflags[ret + 1];
|
---|
957 | FORCE_RET();
|
---|
958 | }
|
---|
959 |
|
---|
960 | void helper_comiss(Reg *d, Reg *s)
|
---|
961 | {
|
---|
962 | int ret;
|
---|
963 | float32 s0, s1;
|
---|
964 |
|
---|
965 | s0 = d->XMM_S(0);
|
---|
966 | s1 = s->XMM_S(0);
|
---|
967 | ret = float32_compare(s0, s1, &env->sse_status);
|
---|
968 | CC_SRC = comis_eflags[ret + 1];
|
---|
969 | FORCE_RET();
|
---|
970 | }
|
---|
971 |
|
---|
972 | void helper_ucomisd(Reg *d, Reg *s)
|
---|
973 | {
|
---|
974 | int ret;
|
---|
975 | float64 d0, d1;
|
---|
976 |
|
---|
977 | d0 = d->XMM_D(0);
|
---|
978 | d1 = s->XMM_D(0);
|
---|
979 | ret = float64_compare_quiet(d0, d1, &env->sse_status);
|
---|
980 | CC_SRC = comis_eflags[ret + 1];
|
---|
981 | FORCE_RET();
|
---|
982 | }
|
---|
983 |
|
---|
984 | void helper_comisd(Reg *d, Reg *s)
|
---|
985 | {
|
---|
986 | int ret;
|
---|
987 | float64 d0, d1;
|
---|
988 |
|
---|
989 | d0 = d->XMM_D(0);
|
---|
990 | d1 = s->XMM_D(0);
|
---|
991 | ret = float64_compare(d0, d1, &env->sse_status);
|
---|
992 | CC_SRC = comis_eflags[ret + 1];
|
---|
993 | FORCE_RET();
|
---|
994 | }
|
---|
995 |
|
---|
996 | uint32_t helper_movmskps(Reg *s)
|
---|
997 | {
|
---|
998 | int b0, b1, b2, b3;
|
---|
999 | b0 = s->XMM_L(0) >> 31;
|
---|
1000 | b1 = s->XMM_L(1) >> 31;
|
---|
1001 | b2 = s->XMM_L(2) >> 31;
|
---|
1002 | b3 = s->XMM_L(3) >> 31;
|
---|
1003 | return b0 | (b1 << 1) | (b2 << 2) | (b3 << 3);
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | uint32_t helper_movmskpd(Reg *s)
|
---|
1007 | {
|
---|
1008 | int b0, b1;
|
---|
1009 | b0 = s->XMM_L(1) >> 31;
|
---|
1010 | b1 = s->XMM_L(3) >> 31;
|
---|
1011 | return b0 | (b1 << 1);
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | #endif
|
---|
1015 |
|
---|
1016 | uint32_t glue(helper_pmovmskb, SUFFIX)(Reg *s)
|
---|
1017 | {
|
---|
1018 | uint32_t val;
|
---|
1019 | val = 0;
|
---|
1020 | val |= (s->XMM_B(0) >> 7);
|
---|
1021 | val |= (s->XMM_B(1) >> 6) & 0x02;
|
---|
1022 | val |= (s->XMM_B(2) >> 5) & 0x04;
|
---|
1023 | val |= (s->XMM_B(3) >> 4) & 0x08;
|
---|
1024 | val |= (s->XMM_B(4) >> 3) & 0x10;
|
---|
1025 | val |= (s->XMM_B(5) >> 2) & 0x20;
|
---|
1026 | val |= (s->XMM_B(6) >> 1) & 0x40;
|
---|
1027 | val |= (s->XMM_B(7)) & 0x80;
|
---|
1028 | #if SHIFT == 1
|
---|
1029 | val |= (s->XMM_B(8) << 1) & 0x0100;
|
---|
1030 | val |= (s->XMM_B(9) << 2) & 0x0200;
|
---|
1031 | val |= (s->XMM_B(10) << 3) & 0x0400;
|
---|
1032 | val |= (s->XMM_B(11) << 4) & 0x0800;
|
---|
1033 | val |= (s->XMM_B(12) << 5) & 0x1000;
|
---|
1034 | val |= (s->XMM_B(13) << 6) & 0x2000;
|
---|
1035 | val |= (s->XMM_B(14) << 7) & 0x4000;
|
---|
1036 | val |= (s->XMM_B(15) << 8) & 0x8000;
|
---|
1037 | #endif
|
---|
1038 | return val;
|
---|
1039 | }
|
---|
1040 |
|
---|
1041 | void glue(helper_packsswb, SUFFIX) (Reg *d, Reg *s)
|
---|
1042 | {
|
---|
1043 | Reg r;
|
---|
1044 |
|
---|
1045 | r.B(0) = satsb((int16_t)d->W(0));
|
---|
1046 | r.B(1) = satsb((int16_t)d->W(1));
|
---|
1047 | r.B(2) = satsb((int16_t)d->W(2));
|
---|
1048 | r.B(3) = satsb((int16_t)d->W(3));
|
---|
1049 | #if SHIFT == 1
|
---|
1050 | r.B(4) = satsb((int16_t)d->W(4));
|
---|
1051 | r.B(5) = satsb((int16_t)d->W(5));
|
---|
1052 | r.B(6) = satsb((int16_t)d->W(6));
|
---|
1053 | r.B(7) = satsb((int16_t)d->W(7));
|
---|
1054 | #endif
|
---|
1055 | r.B((4 << SHIFT) + 0) = satsb((int16_t)s->W(0));
|
---|
1056 | r.B((4 << SHIFT) + 1) = satsb((int16_t)s->W(1));
|
---|
1057 | r.B((4 << SHIFT) + 2) = satsb((int16_t)s->W(2));
|
---|
1058 | r.B((4 << SHIFT) + 3) = satsb((int16_t)s->W(3));
|
---|
1059 | #if SHIFT == 1
|
---|
1060 | r.B(12) = satsb((int16_t)s->W(4));
|
---|
1061 | r.B(13) = satsb((int16_t)s->W(5));
|
---|
1062 | r.B(14) = satsb((int16_t)s->W(6));
|
---|
1063 | r.B(15) = satsb((int16_t)s->W(7));
|
---|
1064 | #endif
|
---|
1065 | *d = r;
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | void glue(helper_packuswb, SUFFIX) (Reg *d, Reg *s)
|
---|
1069 | {
|
---|
1070 | Reg r;
|
---|
1071 |
|
---|
1072 | r.B(0) = satub((int16_t)d->W(0));
|
---|
1073 | r.B(1) = satub((int16_t)d->W(1));
|
---|
1074 | r.B(2) = satub((int16_t)d->W(2));
|
---|
1075 | r.B(3) = satub((int16_t)d->W(3));
|
---|
1076 | #if SHIFT == 1
|
---|
1077 | r.B(4) = satub((int16_t)d->W(4));
|
---|
1078 | r.B(5) = satub((int16_t)d->W(5));
|
---|
1079 | r.B(6) = satub((int16_t)d->W(6));
|
---|
1080 | r.B(7) = satub((int16_t)d->W(7));
|
---|
1081 | #endif
|
---|
1082 | r.B((4 << SHIFT) + 0) = satub((int16_t)s->W(0));
|
---|
1083 | r.B((4 << SHIFT) + 1) = satub((int16_t)s->W(1));
|
---|
1084 | r.B((4 << SHIFT) + 2) = satub((int16_t)s->W(2));
|
---|
1085 | r.B((4 << SHIFT) + 3) = satub((int16_t)s->W(3));
|
---|
1086 | #if SHIFT == 1
|
---|
1087 | r.B(12) = satub((int16_t)s->W(4));
|
---|
1088 | r.B(13) = satub((int16_t)s->W(5));
|
---|
1089 | r.B(14) = satub((int16_t)s->W(6));
|
---|
1090 | r.B(15) = satub((int16_t)s->W(7));
|
---|
1091 | #endif
|
---|
1092 | *d = r;
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | void glue(helper_packssdw, SUFFIX) (Reg *d, Reg *s)
|
---|
1096 | {
|
---|
1097 | Reg r;
|
---|
1098 |
|
---|
1099 | r.W(0) = satsw(d->L(0));
|
---|
1100 | r.W(1) = satsw(d->L(1));
|
---|
1101 | #if SHIFT == 1
|
---|
1102 | r.W(2) = satsw(d->L(2));
|
---|
1103 | r.W(3) = satsw(d->L(3));
|
---|
1104 | #endif
|
---|
1105 | r.W((2 << SHIFT) + 0) = satsw(s->L(0));
|
---|
1106 | r.W((2 << SHIFT) + 1) = satsw(s->L(1));
|
---|
1107 | #if SHIFT == 1
|
---|
1108 | r.W(6) = satsw(s->L(2));
|
---|
1109 | r.W(7) = satsw(s->L(3));
|
---|
1110 | #endif
|
---|
1111 | *d = r;
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | #define UNPCK_OP(base_name, base) \
|
---|
1115 | \
|
---|
1116 | void glue(helper_punpck ## base_name ## bw, SUFFIX) (Reg *d, Reg *s) \
|
---|
1117 | { \
|
---|
1118 | Reg r; \
|
---|
1119 | \
|
---|
1120 | r.B(0) = d->B((base << (SHIFT + 2)) + 0); \
|
---|
1121 | r.B(1) = s->B((base << (SHIFT + 2)) + 0); \
|
---|
1122 | r.B(2) = d->B((base << (SHIFT + 2)) + 1); \
|
---|
1123 | r.B(3) = s->B((base << (SHIFT + 2)) + 1); \
|
---|
1124 | r.B(4) = d->B((base << (SHIFT + 2)) + 2); \
|
---|
1125 | r.B(5) = s->B((base << (SHIFT + 2)) + 2); \
|
---|
1126 | r.B(6) = d->B((base << (SHIFT + 2)) + 3); \
|
---|
1127 | r.B(7) = s->B((base << (SHIFT + 2)) + 3); \
|
---|
1128 | XMM_ONLY( \
|
---|
1129 | r.B(8) = d->B((base << (SHIFT + 2)) + 4); \
|
---|
1130 | r.B(9) = s->B((base << (SHIFT + 2)) + 4); \
|
---|
1131 | r.B(10) = d->B((base << (SHIFT + 2)) + 5); \
|
---|
1132 | r.B(11) = s->B((base << (SHIFT + 2)) + 5); \
|
---|
1133 | r.B(12) = d->B((base << (SHIFT + 2)) + 6); \
|
---|
1134 | r.B(13) = s->B((base << (SHIFT + 2)) + 6); \
|
---|
1135 | r.B(14) = d->B((base << (SHIFT + 2)) + 7); \
|
---|
1136 | r.B(15) = s->B((base << (SHIFT + 2)) + 7); \
|
---|
1137 | ) \
|
---|
1138 | *d = r; \
|
---|
1139 | } \
|
---|
1140 | \
|
---|
1141 | void glue(helper_punpck ## base_name ## wd, SUFFIX) (Reg *d, Reg *s) \
|
---|
1142 | { \
|
---|
1143 | Reg r; \
|
---|
1144 | \
|
---|
1145 | r.W(0) = d->W((base << (SHIFT + 1)) + 0); \
|
---|
1146 | r.W(1) = s->W((base << (SHIFT + 1)) + 0); \
|
---|
1147 | r.W(2) = d->W((base << (SHIFT + 1)) + 1); \
|
---|
1148 | r.W(3) = s->W((base << (SHIFT + 1)) + 1); \
|
---|
1149 | XMM_ONLY( \
|
---|
1150 | r.W(4) = d->W((base << (SHIFT + 1)) + 2); \
|
---|
1151 | r.W(5) = s->W((base << (SHIFT + 1)) + 2); \
|
---|
1152 | r.W(6) = d->W((base << (SHIFT + 1)) + 3); \
|
---|
1153 | r.W(7) = s->W((base << (SHIFT + 1)) + 3); \
|
---|
1154 | ) \
|
---|
1155 | *d = r; \
|
---|
1156 | } \
|
---|
1157 | \
|
---|
1158 | void glue(helper_punpck ## base_name ## dq, SUFFIX) (Reg *d, Reg *s) \
|
---|
1159 | { \
|
---|
1160 | Reg r; \
|
---|
1161 | \
|
---|
1162 | r.L(0) = d->L((base << SHIFT) + 0); \
|
---|
1163 | r.L(1) = s->L((base << SHIFT) + 0); \
|
---|
1164 | XMM_ONLY( \
|
---|
1165 | r.L(2) = d->L((base << SHIFT) + 1); \
|
---|
1166 | r.L(3) = s->L((base << SHIFT) + 1); \
|
---|
1167 | ) \
|
---|
1168 | *d = r; \
|
---|
1169 | } \
|
---|
1170 | \
|
---|
1171 | XMM_ONLY( \
|
---|
1172 | void glue(helper_punpck ## base_name ## qdq, SUFFIX) (Reg *d, Reg *s) \
|
---|
1173 | { \
|
---|
1174 | Reg r; \
|
---|
1175 | \
|
---|
1176 | r.Q(0) = d->Q(base); \
|
---|
1177 | r.Q(1) = s->Q(base); \
|
---|
1178 | *d = r; \
|
---|
1179 | } \
|
---|
1180 | )
|
---|
1181 |
|
---|
1182 | UNPCK_OP(l, 0)
|
---|
1183 | UNPCK_OP(h, 1)
|
---|
1184 |
|
---|
1185 | /* 3DNow! float ops */
|
---|
1186 | #if SHIFT == 0
|
---|
1187 | void helper_pi2fd(MMXReg *d, MMXReg *s)
|
---|
1188 | {
|
---|
1189 | d->MMX_S(0) = int32_to_float32(s->MMX_L(0), &env->mmx_status);
|
---|
1190 | d->MMX_S(1) = int32_to_float32(s->MMX_L(1), &env->mmx_status);
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | void helper_pi2fw(MMXReg *d, MMXReg *s)
|
---|
1194 | {
|
---|
1195 | d->MMX_S(0) = int32_to_float32((int16_t)s->MMX_W(0), &env->mmx_status);
|
---|
1196 | d->MMX_S(1) = int32_to_float32((int16_t)s->MMX_W(2), &env->mmx_status);
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | void helper_pf2id(MMXReg *d, MMXReg *s)
|
---|
1200 | {
|
---|
1201 | d->MMX_L(0) = float32_to_int32_round_to_zero(s->MMX_S(0), &env->mmx_status);
|
---|
1202 | d->MMX_L(1) = float32_to_int32_round_to_zero(s->MMX_S(1), &env->mmx_status);
|
---|
1203 | }
|
---|
1204 |
|
---|
1205 | void helper_pf2iw(MMXReg *d, MMXReg *s)
|
---|
1206 | {
|
---|
1207 | d->MMX_L(0) = satsw(float32_to_int32_round_to_zero(s->MMX_S(0), &env->mmx_status));
|
---|
1208 | d->MMX_L(1) = satsw(float32_to_int32_round_to_zero(s->MMX_S(1), &env->mmx_status));
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 | void helper_pfacc(MMXReg *d, MMXReg *s)
|
---|
1212 | {
|
---|
1213 | MMXReg r;
|
---|
1214 | r.MMX_S(0) = float32_add(d->MMX_S(0), d->MMX_S(1), &env->mmx_status);
|
---|
1215 | r.MMX_S(1) = float32_add(s->MMX_S(0), s->MMX_S(1), &env->mmx_status);
|
---|
1216 | *d = r;
|
---|
1217 | }
|
---|
1218 |
|
---|
1219 | void helper_pfadd(MMXReg *d, MMXReg *s)
|
---|
1220 | {
|
---|
1221 | d->MMX_S(0) = float32_add(d->MMX_S(0), s->MMX_S(0), &env->mmx_status);
|
---|
1222 | d->MMX_S(1) = float32_add(d->MMX_S(1), s->MMX_S(1), &env->mmx_status);
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | void helper_pfcmpeq(MMXReg *d, MMXReg *s)
|
---|
1226 | {
|
---|
1227 | d->MMX_L(0) = float32_eq(d->MMX_S(0), s->MMX_S(0), &env->mmx_status) ? -1 : 0;
|
---|
1228 | d->MMX_L(1) = float32_eq(d->MMX_S(1), s->MMX_S(1), &env->mmx_status) ? -1 : 0;
|
---|
1229 | }
|
---|
1230 |
|
---|
1231 | void helper_pfcmpge(MMXReg *d, MMXReg *s)
|
---|
1232 | {
|
---|
1233 | d->MMX_L(0) = float32_le(s->MMX_S(0), d->MMX_S(0), &env->mmx_status) ? -1 : 0;
|
---|
1234 | d->MMX_L(1) = float32_le(s->MMX_S(1), d->MMX_S(1), &env->mmx_status) ? -1 : 0;
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | void helper_pfcmpgt(MMXReg *d, MMXReg *s)
|
---|
1238 | {
|
---|
1239 | d->MMX_L(0) = float32_lt(s->MMX_S(0), d->MMX_S(0), &env->mmx_status) ? -1 : 0;
|
---|
1240 | d->MMX_L(1) = float32_lt(s->MMX_S(1), d->MMX_S(1), &env->mmx_status) ? -1 : 0;
|
---|
1241 | }
|
---|
1242 |
|
---|
1243 | void helper_pfmax(MMXReg *d, MMXReg *s)
|
---|
1244 | {
|
---|
1245 | if (float32_lt(d->MMX_S(0), s->MMX_S(0), &env->mmx_status))
|
---|
1246 | d->MMX_S(0) = s->MMX_S(0);
|
---|
1247 | if (float32_lt(d->MMX_S(1), s->MMX_S(1), &env->mmx_status))
|
---|
1248 | d->MMX_S(1) = s->MMX_S(1);
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | void helper_pfmin(MMXReg *d, MMXReg *s)
|
---|
1252 | {
|
---|
1253 | if (float32_lt(s->MMX_S(0), d->MMX_S(0), &env->mmx_status))
|
---|
1254 | d->MMX_S(0) = s->MMX_S(0);
|
---|
1255 | if (float32_lt(s->MMX_S(1), d->MMX_S(1), &env->mmx_status))
|
---|
1256 | d->MMX_S(1) = s->MMX_S(1);
|
---|
1257 | }
|
---|
1258 |
|
---|
1259 | void helper_pfmul(MMXReg *d, MMXReg *s)
|
---|
1260 | {
|
---|
1261 | d->MMX_S(0) = float32_mul(d->MMX_S(0), s->MMX_S(0), &env->mmx_status);
|
---|
1262 | d->MMX_S(1) = float32_mul(d->MMX_S(1), s->MMX_S(1), &env->mmx_status);
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | void helper_pfnacc(MMXReg *d, MMXReg *s)
|
---|
1266 | {
|
---|
1267 | MMXReg r;
|
---|
1268 | r.MMX_S(0) = float32_sub(d->MMX_S(0), d->MMX_S(1), &env->mmx_status);
|
---|
1269 | r.MMX_S(1) = float32_sub(s->MMX_S(0), s->MMX_S(1), &env->mmx_status);
|
---|
1270 | *d = r;
|
---|
1271 | }
|
---|
1272 |
|
---|
1273 | void helper_pfpnacc(MMXReg *d, MMXReg *s)
|
---|
1274 | {
|
---|
1275 | MMXReg r;
|
---|
1276 | r.MMX_S(0) = float32_sub(d->MMX_S(0), d->MMX_S(1), &env->mmx_status);
|
---|
1277 | r.MMX_S(1) = float32_add(s->MMX_S(0), s->MMX_S(1), &env->mmx_status);
|
---|
1278 | *d = r;
|
---|
1279 | }
|
---|
1280 |
|
---|
1281 | void helper_pfrcp(MMXReg *d, MMXReg *s)
|
---|
1282 | {
|
---|
1283 | d->MMX_S(0) = approx_rcp(s->MMX_S(0));
|
---|
1284 | d->MMX_S(1) = d->MMX_S(0);
|
---|
1285 | }
|
---|
1286 |
|
---|
1287 | void helper_pfrsqrt(MMXReg *d, MMXReg *s)
|
---|
1288 | {
|
---|
1289 | d->MMX_L(1) = s->MMX_L(0) & 0x7fffffff;
|
---|
1290 | d->MMX_S(1) = approx_rsqrt(d->MMX_S(1));
|
---|
1291 | d->MMX_L(1) |= s->MMX_L(0) & 0x80000000;
|
---|
1292 | d->MMX_L(0) = d->MMX_L(1);
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | void helper_pfsub(MMXReg *d, MMXReg *s)
|
---|
1296 | {
|
---|
1297 | d->MMX_S(0) = float32_sub(d->MMX_S(0), s->MMX_S(0), &env->mmx_status);
|
---|
1298 | d->MMX_S(1) = float32_sub(d->MMX_S(1), s->MMX_S(1), &env->mmx_status);
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | void helper_pfsubr(MMXReg *d, MMXReg *s)
|
---|
1302 | {
|
---|
1303 | d->MMX_S(0) = float32_sub(s->MMX_S(0), d->MMX_S(0), &env->mmx_status);
|
---|
1304 | d->MMX_S(1) = float32_sub(s->MMX_S(1), d->MMX_S(1), &env->mmx_status);
|
---|
1305 | }
|
---|
1306 |
|
---|
1307 | void helper_pswapd(MMXReg *d, MMXReg *s)
|
---|
1308 | {
|
---|
1309 | MMXReg r;
|
---|
1310 | r.MMX_L(0) = s->MMX_L(1);
|
---|
1311 | r.MMX_L(1) = s->MMX_L(0);
|
---|
1312 | *d = r;
|
---|
1313 | }
|
---|
1314 | #endif
|
---|
1315 |
|
---|
1316 | /* SSSE3 op helpers */
|
---|
1317 | void glue(helper_pshufb, SUFFIX) (Reg *d, Reg *s)
|
---|
1318 | {
|
---|
1319 | int i;
|
---|
1320 | Reg r;
|
---|
1321 |
|
---|
1322 | for (i = 0; i < (8 << SHIFT); i++)
|
---|
1323 | r.B(i) = (s->B(i) & 0x80) ? 0 : (d->B(s->B(i) & ((8 << SHIFT) - 1)));
|
---|
1324 |
|
---|
1325 | *d = r;
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | void glue(helper_phaddw, SUFFIX) (Reg *d, Reg *s)
|
---|
1329 | {
|
---|
1330 | d->W(0) = (int16_t)d->W(0) + (int16_t)d->W(1);
|
---|
1331 | d->W(1) = (int16_t)d->W(2) + (int16_t)d->W(3);
|
---|
1332 | XMM_ONLY(d->W(2) = (int16_t)d->W(4) + (int16_t)d->W(5));
|
---|
1333 | XMM_ONLY(d->W(3) = (int16_t)d->W(6) + (int16_t)d->W(7));
|
---|
1334 | d->W((2 << SHIFT) + 0) = (int16_t)s->W(0) + (int16_t)s->W(1);
|
---|
1335 | d->W((2 << SHIFT) + 1) = (int16_t)s->W(2) + (int16_t)s->W(3);
|
---|
1336 | XMM_ONLY(d->W(6) = (int16_t)s->W(4) + (int16_t)s->W(5));
|
---|
1337 | XMM_ONLY(d->W(7) = (int16_t)s->W(6) + (int16_t)s->W(7));
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | void glue(helper_phaddd, SUFFIX) (Reg *d, Reg *s)
|
---|
1341 | {
|
---|
1342 | d->L(0) = (int32_t)d->L(0) + (int32_t)d->L(1);
|
---|
1343 | XMM_ONLY(d->L(1) = (int32_t)d->L(2) + (int32_t)d->L(3));
|
---|
1344 | d->L((1 << SHIFT) + 0) = (int32_t)s->L(0) + (int32_t)s->L(1);
|
---|
1345 | XMM_ONLY(d->L(3) = (int32_t)s->L(2) + (int32_t)s->L(3));
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | void glue(helper_phaddsw, SUFFIX) (Reg *d, Reg *s)
|
---|
1349 | {
|
---|
1350 | d->W(0) = satsw((int16_t)d->W(0) + (int16_t)d->W(1));
|
---|
1351 | d->W(1) = satsw((int16_t)d->W(2) + (int16_t)d->W(3));
|
---|
1352 | XMM_ONLY(d->W(2) = satsw((int16_t)d->W(4) + (int16_t)d->W(5)));
|
---|
1353 | XMM_ONLY(d->W(3) = satsw((int16_t)d->W(6) + (int16_t)d->W(7)));
|
---|
1354 | d->W((2 << SHIFT) + 0) = satsw((int16_t)s->W(0) + (int16_t)s->W(1));
|
---|
1355 | d->W((2 << SHIFT) + 1) = satsw((int16_t)s->W(2) + (int16_t)s->W(3));
|
---|
1356 | XMM_ONLY(d->W(6) = satsw((int16_t)s->W(4) + (int16_t)s->W(5)));
|
---|
1357 | XMM_ONLY(d->W(7) = satsw((int16_t)s->W(6) + (int16_t)s->W(7)));
|
---|
1358 | }
|
---|
1359 |
|
---|
1360 | void glue(helper_pmaddubsw, SUFFIX) (Reg *d, Reg *s)
|
---|
1361 | {
|
---|
1362 | d->W(0) = satsw((int8_t)s->B( 0) * (uint8_t)d->B( 0) +
|
---|
1363 | (int8_t)s->B( 1) * (uint8_t)d->B( 1));
|
---|
1364 | d->W(1) = satsw((int8_t)s->B( 2) * (uint8_t)d->B( 2) +
|
---|
1365 | (int8_t)s->B( 3) * (uint8_t)d->B( 3));
|
---|
1366 | d->W(2) = satsw((int8_t)s->B( 4) * (uint8_t)d->B( 4) +
|
---|
1367 | (int8_t)s->B( 5) * (uint8_t)d->B( 5));
|
---|
1368 | d->W(3) = satsw((int8_t)s->B( 6) * (uint8_t)d->B( 6) +
|
---|
1369 | (int8_t)s->B( 7) * (uint8_t)d->B( 7));
|
---|
1370 | #if SHIFT == 1
|
---|
1371 | d->W(4) = satsw((int8_t)s->B( 8) * (uint8_t)d->B( 8) +
|
---|
1372 | (int8_t)s->B( 9) * (uint8_t)d->B( 9));
|
---|
1373 | d->W(5) = satsw((int8_t)s->B(10) * (uint8_t)d->B(10) +
|
---|
1374 | (int8_t)s->B(11) * (uint8_t)d->B(11));
|
---|
1375 | d->W(6) = satsw((int8_t)s->B(12) * (uint8_t)d->B(12) +
|
---|
1376 | (int8_t)s->B(13) * (uint8_t)d->B(13));
|
---|
1377 | d->W(7) = satsw((int8_t)s->B(14) * (uint8_t)d->B(14) +
|
---|
1378 | (int8_t)s->B(15) * (uint8_t)d->B(15));
|
---|
1379 | #endif
|
---|
1380 | }
|
---|
1381 |
|
---|
1382 | void glue(helper_phsubw, SUFFIX) (Reg *d, Reg *s)
|
---|
1383 | {
|
---|
1384 | d->W(0) = (int16_t)d->W(0) - (int16_t)d->W(1);
|
---|
1385 | d->W(1) = (int16_t)d->W(2) - (int16_t)d->W(3);
|
---|
1386 | XMM_ONLY(d->W(2) = (int16_t)d->W(4) - (int16_t)d->W(5));
|
---|
1387 | XMM_ONLY(d->W(3) = (int16_t)d->W(6) - (int16_t)d->W(7));
|
---|
1388 | d->W((2 << SHIFT) + 0) = (int16_t)s->W(0) - (int16_t)s->W(1);
|
---|
1389 | d->W((2 << SHIFT) + 1) = (int16_t)s->W(2) - (int16_t)s->W(3);
|
---|
1390 | XMM_ONLY(d->W(6) = (int16_t)s->W(4) - (int16_t)s->W(5));
|
---|
1391 | XMM_ONLY(d->W(7) = (int16_t)s->W(6) - (int16_t)s->W(7));
|
---|
1392 | }
|
---|
1393 |
|
---|
1394 | void glue(helper_phsubd, SUFFIX) (Reg *d, Reg *s)
|
---|
1395 | {
|
---|
1396 | d->L(0) = (int32_t)d->L(0) - (int32_t)d->L(1);
|
---|
1397 | XMM_ONLY(d->L(1) = (int32_t)d->L(2) - (int32_t)d->L(3));
|
---|
1398 | d->L((1 << SHIFT) + 0) = (int32_t)s->L(0) - (int32_t)s->L(1);
|
---|
1399 | XMM_ONLY(d->L(3) = (int32_t)s->L(2) - (int32_t)s->L(3));
|
---|
1400 | }
|
---|
1401 |
|
---|
1402 | void glue(helper_phsubsw, SUFFIX) (Reg *d, Reg *s)
|
---|
1403 | {
|
---|
1404 | d->W(0) = satsw((int16_t)d->W(0) - (int16_t)d->W(1));
|
---|
1405 | d->W(1) = satsw((int16_t)d->W(2) - (int16_t)d->W(3));
|
---|
1406 | XMM_ONLY(d->W(2) = satsw((int16_t)d->W(4) - (int16_t)d->W(5)));
|
---|
1407 | XMM_ONLY(d->W(3) = satsw((int16_t)d->W(6) - (int16_t)d->W(7)));
|
---|
1408 | d->W((2 << SHIFT) + 0) = satsw((int16_t)s->W(0) - (int16_t)s->W(1));
|
---|
1409 | d->W((2 << SHIFT) + 1) = satsw((int16_t)s->W(2) - (int16_t)s->W(3));
|
---|
1410 | XMM_ONLY(d->W(6) = satsw((int16_t)s->W(4) - (int16_t)s->W(5)));
|
---|
1411 | XMM_ONLY(d->W(7) = satsw((int16_t)s->W(6) - (int16_t)s->W(7)));
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 | #define FABSB(_, x) x > INT8_MAX ? -(int8_t ) x : x
|
---|
1415 | #define FABSW(_, x) x > INT16_MAX ? -(int16_t) x : x
|
---|
1416 | #define FABSL(_, x) x > INT32_MAX ? -(int32_t) x : x
|
---|
1417 | SSE_HELPER_B(helper_pabsb, FABSB)
|
---|
1418 | SSE_HELPER_W(helper_pabsw, FABSW)
|
---|
1419 | SSE_HELPER_L(helper_pabsd, FABSL)
|
---|
1420 |
|
---|
1421 | #define FMULHRSW(d, s) ((int16_t) d * (int16_t) s + 0x4000) >> 15
|
---|
1422 | SSE_HELPER_W(helper_pmulhrsw, FMULHRSW)
|
---|
1423 |
|
---|
1424 | #define FSIGNB(d, s) s <= INT8_MAX ? s ? d : 0 : -(int8_t ) d
|
---|
1425 | #define FSIGNW(d, s) s <= INT16_MAX ? s ? d : 0 : -(int16_t) d
|
---|
1426 | #define FSIGNL(d, s) s <= INT32_MAX ? s ? d : 0 : -(int32_t) d
|
---|
1427 | SSE_HELPER_B(helper_psignb, FSIGNB)
|
---|
1428 | SSE_HELPER_W(helper_psignw, FSIGNW)
|
---|
1429 | SSE_HELPER_L(helper_psignd, FSIGNL)
|
---|
1430 |
|
---|
1431 | void glue(helper_palignr, SUFFIX) (Reg *d, Reg *s, int32_t shift)
|
---|
1432 | {
|
---|
1433 | Reg r;
|
---|
1434 |
|
---|
1435 | /* XXX could be checked during translation */
|
---|
1436 | if (shift >= (16 << SHIFT)) {
|
---|
1437 | r.Q(0) = 0;
|
---|
1438 | XMM_ONLY(r.Q(1) = 0);
|
---|
1439 | } else {
|
---|
1440 | shift <<= 3;
|
---|
1441 | #define SHR(v, i) (i < 64 && i > -64 ? i > 0 ? v >> (i) : (v << -(i)) : 0)
|
---|
1442 | #if SHIFT == 0
|
---|
1443 | r.Q(0) = SHR(s->Q(0), shift - 0) |
|
---|
1444 | SHR(d->Q(0), shift - 64);
|
---|
1445 | #else
|
---|
1446 | r.Q(0) = SHR(s->Q(0), shift - 0) |
|
---|
1447 | SHR(s->Q(1), shift - 64) |
|
---|
1448 | SHR(d->Q(0), shift - 128) |
|
---|
1449 | SHR(d->Q(1), shift - 192);
|
---|
1450 | r.Q(1) = SHR(s->Q(0), shift + 64) |
|
---|
1451 | SHR(s->Q(1), shift - 0) |
|
---|
1452 | SHR(d->Q(0), shift - 64) |
|
---|
1453 | SHR(d->Q(1), shift - 128);
|
---|
1454 | #endif
|
---|
1455 | #undef SHR
|
---|
1456 | }
|
---|
1457 |
|
---|
1458 | *d = r;
|
---|
1459 | }
|
---|
1460 |
|
---|
1461 | #define XMM0 env->xmm_regs[0]
|
---|
1462 |
|
---|
1463 | #if SHIFT == 1
|
---|
1464 | #define SSE_HELPER_V(name, elem, num, F)\
|
---|
1465 | void glue(name, SUFFIX) (Reg *d, Reg *s)\
|
---|
1466 | {\
|
---|
1467 | d->elem(0) = F(d->elem(0), s->elem(0), XMM0.elem(0));\
|
---|
1468 | d->elem(1) = F(d->elem(1), s->elem(1), XMM0.elem(1));\
|
---|
1469 | if (num > 2) {\
|
---|
1470 | d->elem(2) = F(d->elem(2), s->elem(2), XMM0.elem(2));\
|
---|
1471 | d->elem(3) = F(d->elem(3), s->elem(3), XMM0.elem(3));\
|
---|
1472 | if (num > 4) {\
|
---|
1473 | d->elem(4) = F(d->elem(4), s->elem(4), XMM0.elem(4));\
|
---|
1474 | d->elem(5) = F(d->elem(5), s->elem(5), XMM0.elem(5));\
|
---|
1475 | d->elem(6) = F(d->elem(6), s->elem(6), XMM0.elem(6));\
|
---|
1476 | d->elem(7) = F(d->elem(7), s->elem(7), XMM0.elem(7));\
|
---|
1477 | if (num > 8) {\
|
---|
1478 | d->elem(8) = F(d->elem(8), s->elem(8), XMM0.elem(8));\
|
---|
1479 | d->elem(9) = F(d->elem(9), s->elem(9), XMM0.elem(9));\
|
---|
1480 | d->elem(10) = F(d->elem(10), s->elem(10), XMM0.elem(10));\
|
---|
1481 | d->elem(11) = F(d->elem(11), s->elem(11), XMM0.elem(11));\
|
---|
1482 | d->elem(12) = F(d->elem(12), s->elem(12), XMM0.elem(12));\
|
---|
1483 | d->elem(13) = F(d->elem(13), s->elem(13), XMM0.elem(13));\
|
---|
1484 | d->elem(14) = F(d->elem(14), s->elem(14), XMM0.elem(14));\
|
---|
1485 | d->elem(15) = F(d->elem(15), s->elem(15), XMM0.elem(15));\
|
---|
1486 | }\
|
---|
1487 | }\
|
---|
1488 | }\
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | #define SSE_HELPER_I(name, elem, num, F)\
|
---|
1492 | void glue(name, SUFFIX) (Reg *d, Reg *s, uint32_t imm)\
|
---|
1493 | {\
|
---|
1494 | d->elem(0) = F(d->elem(0), s->elem(0), ((imm >> 0) & 1));\
|
---|
1495 | d->elem(1) = F(d->elem(1), s->elem(1), ((imm >> 1) & 1));\
|
---|
1496 | if (num > 2) {\
|
---|
1497 | d->elem(2) = F(d->elem(2), s->elem(2), ((imm >> 2) & 1));\
|
---|
1498 | d->elem(3) = F(d->elem(3), s->elem(3), ((imm >> 3) & 1));\
|
---|
1499 | if (num > 4) {\
|
---|
1500 | d->elem(4) = F(d->elem(4), s->elem(4), ((imm >> 4) & 1));\
|
---|
1501 | d->elem(5) = F(d->elem(5), s->elem(5), ((imm >> 5) & 1));\
|
---|
1502 | d->elem(6) = F(d->elem(6), s->elem(6), ((imm >> 6) & 1));\
|
---|
1503 | d->elem(7) = F(d->elem(7), s->elem(7), ((imm >> 7) & 1));\
|
---|
1504 | if (num > 8) {\
|
---|
1505 | d->elem(8) = F(d->elem(8), s->elem(8), ((imm >> 8) & 1));\
|
---|
1506 | d->elem(9) = F(d->elem(9), s->elem(9), ((imm >> 9) & 1));\
|
---|
1507 | d->elem(10) = F(d->elem(10), s->elem(10), ((imm >> 10) & 1));\
|
---|
1508 | d->elem(11) = F(d->elem(11), s->elem(11), ((imm >> 11) & 1));\
|
---|
1509 | d->elem(12) = F(d->elem(12), s->elem(12), ((imm >> 12) & 1));\
|
---|
1510 | d->elem(13) = F(d->elem(13), s->elem(13), ((imm >> 13) & 1));\
|
---|
1511 | d->elem(14) = F(d->elem(14), s->elem(14), ((imm >> 14) & 1));\
|
---|
1512 | d->elem(15) = F(d->elem(15), s->elem(15), ((imm >> 15) & 1));\
|
---|
1513 | }\
|
---|
1514 | }\
|
---|
1515 | }\
|
---|
1516 | }
|
---|
1517 |
|
---|
1518 | /* SSE4.1 op helpers */
|
---|
1519 | #define FBLENDVB(d, s, m) (m & 0x80) ? s : d
|
---|
1520 | #define FBLENDVPS(d, s, m) (m & 0x80000000) ? s : d
|
---|
1521 | #define FBLENDVPD(d, s, m) (m & 0x8000000000000000LL) ? s : d
|
---|
1522 | SSE_HELPER_V(helper_pblendvb, B, 16, FBLENDVB)
|
---|
1523 | SSE_HELPER_V(helper_blendvps, L, 4, FBLENDVPS)
|
---|
1524 | SSE_HELPER_V(helper_blendvpd, Q, 2, FBLENDVPD)
|
---|
1525 |
|
---|
1526 | void glue(helper_ptest, SUFFIX) (Reg *d, Reg *s)
|
---|
1527 | {
|
---|
1528 | uint64_t zf = (s->Q(0) & d->Q(0)) | (s->Q(1) & d->Q(1));
|
---|
1529 | uint64_t cf = (s->Q(0) & ~d->Q(0)) | (s->Q(1) & ~d->Q(1));
|
---|
1530 |
|
---|
1531 | CC_SRC = (zf ? 0 : CC_Z) | (cf ? 0 : CC_C);
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | #define SSE_HELPER_F(name, elem, num, F)\
|
---|
1535 | void glue(name, SUFFIX) (Reg *d, Reg *s)\
|
---|
1536 | {\
|
---|
1537 | d->elem(0) = F(0);\
|
---|
1538 | d->elem(1) = F(1);\
|
---|
1539 | if (num > 2) {\
|
---|
1540 | d->elem(2) = F(2);\
|
---|
1541 | d->elem(3) = F(3);\
|
---|
1542 | if (num > 4) {\
|
---|
1543 | d->elem(4) = F(4);\
|
---|
1544 | d->elem(5) = F(5);\
|
---|
1545 | d->elem(6) = F(6);\
|
---|
1546 | d->elem(7) = F(7);\
|
---|
1547 | }\
|
---|
1548 | }\
|
---|
1549 | }
|
---|
1550 |
|
---|
1551 | SSE_HELPER_F(helper_pmovsxbw, W, 8, (int8_t) s->B)
|
---|
1552 | SSE_HELPER_F(helper_pmovsxbd, L, 4, (int8_t) s->B)
|
---|
1553 | SSE_HELPER_F(helper_pmovsxbq, Q, 2, (int8_t) s->B)
|
---|
1554 | SSE_HELPER_F(helper_pmovsxwd, L, 4, (int16_t) s->W)
|
---|
1555 | SSE_HELPER_F(helper_pmovsxwq, Q, 2, (int16_t) s->W)
|
---|
1556 | SSE_HELPER_F(helper_pmovsxdq, Q, 2, (int32_t) s->L)
|
---|
1557 | SSE_HELPER_F(helper_pmovzxbw, W, 8, s->B)
|
---|
1558 | SSE_HELPER_F(helper_pmovzxbd, L, 4, s->B)
|
---|
1559 | SSE_HELPER_F(helper_pmovzxbq, Q, 2, s->B)
|
---|
1560 | SSE_HELPER_F(helper_pmovzxwd, L, 4, s->W)
|
---|
1561 | SSE_HELPER_F(helper_pmovzxwq, Q, 2, s->W)
|
---|
1562 | SSE_HELPER_F(helper_pmovzxdq, Q, 2, s->L)
|
---|
1563 |
|
---|
1564 | void glue(helper_pmuldq, SUFFIX) (Reg *d, Reg *s)
|
---|
1565 | {
|
---|
1566 | d->Q(0) = (int64_t) (int32_t) d->L(0) * (int32_t) s->L(0);
|
---|
1567 | d->Q(1) = (int64_t) (int32_t) d->L(2) * (int32_t) s->L(2);
|
---|
1568 | }
|
---|
1569 |
|
---|
1570 | #define FCMPEQQ(d, s) d == s ? -1 : 0
|
---|
1571 | SSE_HELPER_Q(helper_pcmpeqq, FCMPEQQ)
|
---|
1572 |
|
---|
1573 | void glue(helper_packusdw, SUFFIX) (Reg *d, Reg *s)
|
---|
1574 | {
|
---|
1575 | d->W(0) = satuw((int32_t) d->L(0));
|
---|
1576 | d->W(1) = satuw((int32_t) d->L(1));
|
---|
1577 | d->W(2) = satuw((int32_t) d->L(2));
|
---|
1578 | d->W(3) = satuw((int32_t) d->L(3));
|
---|
1579 | d->W(4) = satuw((int32_t) s->L(0));
|
---|
1580 | d->W(5) = satuw((int32_t) s->L(1));
|
---|
1581 | d->W(6) = satuw((int32_t) s->L(2));
|
---|
1582 | d->W(7) = satuw((int32_t) s->L(3));
|
---|
1583 | }
|
---|
1584 |
|
---|
1585 | #define FMINSB(d, s) MIN((int8_t) d, (int8_t) s)
|
---|
1586 | #define FMINSD(d, s) MIN((int32_t) d, (int32_t) s)
|
---|
1587 | #define FMAXSB(d, s) MAX((int8_t) d, (int8_t) s)
|
---|
1588 | #define FMAXSD(d, s) MAX((int32_t) d, (int32_t) s)
|
---|
1589 | SSE_HELPER_B(helper_pminsb, FMINSB)
|
---|
1590 | SSE_HELPER_L(helper_pminsd, FMINSD)
|
---|
1591 | SSE_HELPER_W(helper_pminuw, MIN)
|
---|
1592 | SSE_HELPER_L(helper_pminud, MIN)
|
---|
1593 | SSE_HELPER_B(helper_pmaxsb, FMAXSB)
|
---|
1594 | SSE_HELPER_L(helper_pmaxsd, FMAXSD)
|
---|
1595 | SSE_HELPER_W(helper_pmaxuw, MAX)
|
---|
1596 | SSE_HELPER_L(helper_pmaxud, MAX)
|
---|
1597 |
|
---|
1598 | #define FMULLD(d, s) (int32_t) d * (int32_t) s
|
---|
1599 | SSE_HELPER_L(helper_pmulld, FMULLD)
|
---|
1600 |
|
---|
1601 | void glue(helper_phminposuw, SUFFIX) (Reg *d, Reg *s)
|
---|
1602 | {
|
---|
1603 | int idx = 0;
|
---|
1604 |
|
---|
1605 | if (s->W(1) < s->W(idx))
|
---|
1606 | idx = 1;
|
---|
1607 | if (s->W(2) < s->W(idx))
|
---|
1608 | idx = 2;
|
---|
1609 | if (s->W(3) < s->W(idx))
|
---|
1610 | idx = 3;
|
---|
1611 | if (s->W(4) < s->W(idx))
|
---|
1612 | idx = 4;
|
---|
1613 | if (s->W(5) < s->W(idx))
|
---|
1614 | idx = 5;
|
---|
1615 | if (s->W(6) < s->W(idx))
|
---|
1616 | idx = 6;
|
---|
1617 | if (s->W(7) < s->W(idx))
|
---|
1618 | idx = 7;
|
---|
1619 |
|
---|
1620 | d->Q(1) = 0;
|
---|
1621 | d->L(1) = 0;
|
---|
1622 | d->W(1) = idx;
|
---|
1623 | d->W(0) = s->W(idx);
|
---|
1624 | }
|
---|
1625 |
|
---|
1626 | void glue(helper_roundps, SUFFIX) (Reg *d, Reg *s, uint32_t mode)
|
---|
1627 | {
|
---|
1628 | signed char prev_rounding_mode;
|
---|
1629 |
|
---|
1630 | prev_rounding_mode = env->sse_status.float_rounding_mode;
|
---|
1631 | if (!(mode & (1 << 2)))
|
---|
1632 | switch (mode & 3) {
|
---|
1633 | case 0:
|
---|
1634 | set_float_rounding_mode(float_round_nearest_even, &env->sse_status);
|
---|
1635 | break;
|
---|
1636 | case 1:
|
---|
1637 | set_float_rounding_mode(float_round_down, &env->sse_status);
|
---|
1638 | break;
|
---|
1639 | case 2:
|
---|
1640 | set_float_rounding_mode(float_round_up, &env->sse_status);
|
---|
1641 | break;
|
---|
1642 | case 3:
|
---|
1643 | set_float_rounding_mode(float_round_to_zero, &env->sse_status);
|
---|
1644 | break;
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 | d->L(0) = float64_round_to_int(s->L(0), &env->sse_status);
|
---|
1648 | d->L(1) = float64_round_to_int(s->L(1), &env->sse_status);
|
---|
1649 | d->L(2) = float64_round_to_int(s->L(2), &env->sse_status);
|
---|
1650 | d->L(3) = float64_round_to_int(s->L(3), &env->sse_status);
|
---|
1651 |
|
---|
1652 | #if 0 /* TODO */
|
---|
1653 | if (mode & (1 << 3))
|
---|
1654 | set_float_exception_flags(
|
---|
1655 | get_float_exception_flags(&env->sse_status) &
|
---|
1656 | ~float_flag_inexact,
|
---|
1657 | &env->sse_status);
|
---|
1658 | #endif
|
---|
1659 | env->sse_status.float_rounding_mode = prev_rounding_mode;
|
---|
1660 | }
|
---|
1661 |
|
---|
1662 | void glue(helper_roundpd, SUFFIX) (Reg *d, Reg *s, uint32_t mode)
|
---|
1663 | {
|
---|
1664 | signed char prev_rounding_mode;
|
---|
1665 |
|
---|
1666 | prev_rounding_mode = env->sse_status.float_rounding_mode;
|
---|
1667 | if (!(mode & (1 << 2)))
|
---|
1668 | switch (mode & 3) {
|
---|
1669 | case 0:
|
---|
1670 | set_float_rounding_mode(float_round_nearest_even, &env->sse_status);
|
---|
1671 | break;
|
---|
1672 | case 1:
|
---|
1673 | set_float_rounding_mode(float_round_down, &env->sse_status);
|
---|
1674 | break;
|
---|
1675 | case 2:
|
---|
1676 | set_float_rounding_mode(float_round_up, &env->sse_status);
|
---|
1677 | break;
|
---|
1678 | case 3:
|
---|
1679 | set_float_rounding_mode(float_round_to_zero, &env->sse_status);
|
---|
1680 | break;
|
---|
1681 | }
|
---|
1682 |
|
---|
1683 | d->Q(0) = float64_round_to_int(s->Q(0), &env->sse_status);
|
---|
1684 | d->Q(1) = float64_round_to_int(s->Q(1), &env->sse_status);
|
---|
1685 |
|
---|
1686 | #if 0 /* TODO */
|
---|
1687 | if (mode & (1 << 3))
|
---|
1688 | set_float_exception_flags(
|
---|
1689 | get_float_exception_flags(&env->sse_status) &
|
---|
1690 | ~float_flag_inexact,
|
---|
1691 | &env->sse_status);
|
---|
1692 | #endif
|
---|
1693 | env->sse_status.float_rounding_mode = prev_rounding_mode;
|
---|
1694 | }
|
---|
1695 |
|
---|
1696 | void glue(helper_roundss, SUFFIX) (Reg *d, Reg *s, uint32_t mode)
|
---|
1697 | {
|
---|
1698 | signed char prev_rounding_mode;
|
---|
1699 |
|
---|
1700 | prev_rounding_mode = env->sse_status.float_rounding_mode;
|
---|
1701 | if (!(mode & (1 << 2)))
|
---|
1702 | switch (mode & 3) {
|
---|
1703 | case 0:
|
---|
1704 | set_float_rounding_mode(float_round_nearest_even, &env->sse_status);
|
---|
1705 | break;
|
---|
1706 | case 1:
|
---|
1707 | set_float_rounding_mode(float_round_down, &env->sse_status);
|
---|
1708 | break;
|
---|
1709 | case 2:
|
---|
1710 | set_float_rounding_mode(float_round_up, &env->sse_status);
|
---|
1711 | break;
|
---|
1712 | case 3:
|
---|
1713 | set_float_rounding_mode(float_round_to_zero, &env->sse_status);
|
---|
1714 | break;
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 | d->L(0) = float64_round_to_int(s->L(0), &env->sse_status);
|
---|
1718 |
|
---|
1719 | #if 0 /* TODO */
|
---|
1720 | if (mode & (1 << 3))
|
---|
1721 | set_float_exception_flags(
|
---|
1722 | get_float_exception_flags(&env->sse_status) &
|
---|
1723 | ~float_flag_inexact,
|
---|
1724 | &env->sse_status);
|
---|
1725 | #endif
|
---|
1726 | env->sse_status.float_rounding_mode = prev_rounding_mode;
|
---|
1727 | }
|
---|
1728 |
|
---|
1729 | void glue(helper_roundsd, SUFFIX) (Reg *d, Reg *s, uint32_t mode)
|
---|
1730 | {
|
---|
1731 | signed char prev_rounding_mode;
|
---|
1732 |
|
---|
1733 | prev_rounding_mode = env->sse_status.float_rounding_mode;
|
---|
1734 | if (!(mode & (1 << 2)))
|
---|
1735 | switch (mode & 3) {
|
---|
1736 | case 0:
|
---|
1737 | set_float_rounding_mode(float_round_nearest_even, &env->sse_status);
|
---|
1738 | break;
|
---|
1739 | case 1:
|
---|
1740 | set_float_rounding_mode(float_round_down, &env->sse_status);
|
---|
1741 | break;
|
---|
1742 | case 2:
|
---|
1743 | set_float_rounding_mode(float_round_up, &env->sse_status);
|
---|
1744 | break;
|
---|
1745 | case 3:
|
---|
1746 | set_float_rounding_mode(float_round_to_zero, &env->sse_status);
|
---|
1747 | break;
|
---|
1748 | }
|
---|
1749 |
|
---|
1750 | d->Q(0) = float64_round_to_int(s->Q(0), &env->sse_status);
|
---|
1751 |
|
---|
1752 | #if 0 /* TODO */
|
---|
1753 | if (mode & (1 << 3))
|
---|
1754 | set_float_exception_flags(
|
---|
1755 | get_float_exception_flags(&env->sse_status) &
|
---|
1756 | ~float_flag_inexact,
|
---|
1757 | &env->sse_status);
|
---|
1758 | #endif
|
---|
1759 | env->sse_status.float_rounding_mode = prev_rounding_mode;
|
---|
1760 | }
|
---|
1761 |
|
---|
1762 | #define FBLENDP(d, s, m) m ? s : d
|
---|
1763 | SSE_HELPER_I(helper_blendps, L, 4, FBLENDP)
|
---|
1764 | SSE_HELPER_I(helper_blendpd, Q, 2, FBLENDP)
|
---|
1765 | SSE_HELPER_I(helper_pblendw, W, 8, FBLENDP)
|
---|
1766 |
|
---|
1767 | void glue(helper_dpps, SUFFIX) (Reg *d, Reg *s, uint32_t mask)
|
---|
1768 | {
|
---|
1769 | float32 iresult = 0 /*float32_zero*/;
|
---|
1770 |
|
---|
1771 | if (mask & (1 << 4))
|
---|
1772 | iresult = float32_add(iresult,
|
---|
1773 | float32_mul(d->L(0), s->L(0), &env->sse_status),
|
---|
1774 | &env->sse_status);
|
---|
1775 | if (mask & (1 << 5))
|
---|
1776 | iresult = float32_add(iresult,
|
---|
1777 | float32_mul(d->L(1), s->L(1), &env->sse_status),
|
---|
1778 | &env->sse_status);
|
---|
1779 | if (mask & (1 << 6))
|
---|
1780 | iresult = float32_add(iresult,
|
---|
1781 | float32_mul(d->L(2), s->L(2), &env->sse_status),
|
---|
1782 | &env->sse_status);
|
---|
1783 | if (mask & (1 << 7))
|
---|
1784 | iresult = float32_add(iresult,
|
---|
1785 | float32_mul(d->L(3), s->L(3), &env->sse_status),
|
---|
1786 | &env->sse_status);
|
---|
1787 | d->L(0) = (mask & (1 << 0)) ? iresult : 0 /*float32_zero*/;
|
---|
1788 | d->L(1) = (mask & (1 << 1)) ? iresult : 0 /*float32_zero*/;
|
---|
1789 | d->L(2) = (mask & (1 << 2)) ? iresult : 0 /*float32_zero*/;
|
---|
1790 | d->L(3) = (mask & (1 << 3)) ? iresult : 0 /*float32_zero*/;
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | void glue(helper_dppd, SUFFIX) (Reg *d, Reg *s, uint32_t mask)
|
---|
1794 | {
|
---|
1795 | float64 iresult = 0 /*float64_zero*/;
|
---|
1796 |
|
---|
1797 | if (mask & (1 << 4))
|
---|
1798 | iresult = float64_add(iresult,
|
---|
1799 | float64_mul(d->Q(0), s->Q(0), &env->sse_status),
|
---|
1800 | &env->sse_status);
|
---|
1801 | if (mask & (1 << 5))
|
---|
1802 | iresult = float64_add(iresult,
|
---|
1803 | float64_mul(d->Q(1), s->Q(1), &env->sse_status),
|
---|
1804 | &env->sse_status);
|
---|
1805 | d->Q(0) = (mask & (1 << 0)) ? iresult : 0 /*float64_zero*/;
|
---|
1806 | d->Q(1) = (mask & (1 << 1)) ? iresult : 0 /*float64_zero*/;
|
---|
1807 | }
|
---|
1808 |
|
---|
1809 | void glue(helper_mpsadbw, SUFFIX) (Reg *d, Reg *s, uint32_t offset)
|
---|
1810 | {
|
---|
1811 | int s0 = (offset & 3) << 2;
|
---|
1812 | int d0 = (offset & 4) << 0;
|
---|
1813 | int i;
|
---|
1814 | Reg r;
|
---|
1815 |
|
---|
1816 | for (i = 0; i < 8; i++, d0++) {
|
---|
1817 | r.W(i) = 0;
|
---|
1818 | r.W(i) += abs1(d->B(d0 + 0) - s->B(s0 + 0));
|
---|
1819 | r.W(i) += abs1(d->B(d0 + 1) - s->B(s0 + 1));
|
---|
1820 | r.W(i) += abs1(d->B(d0 + 2) - s->B(s0 + 2));
|
---|
1821 | r.W(i) += abs1(d->B(d0 + 3) - s->B(s0 + 3));
|
---|
1822 | }
|
---|
1823 |
|
---|
1824 | *d = r;
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 | /* SSE4.2 op helpers */
|
---|
1828 | /* it's unclear whether signed or unsigned */
|
---|
1829 | #define FCMPGTQ(d, s) d > s ? -1 : 0
|
---|
1830 | SSE_HELPER_Q(helper_pcmpgtq, FCMPGTQ)
|
---|
1831 |
|
---|
1832 | #ifndef VBOX
|
---|
1833 | static inline int pcmp_elen(int reg, uint32_t ctrl)
|
---|
1834 | #else /* VBOX */
|
---|
1835 | DECLINLINE(int) pcmp_elen(int reg, uint32_t ctrl)
|
---|
1836 | #endif /* VBOX */
|
---|
1837 | {
|
---|
1838 | int val;
|
---|
1839 |
|
---|
1840 | /* Presence of REX.W is indicated by a bit higher than 7 set */
|
---|
1841 | if (ctrl >> 8)
|
---|
1842 | val = abs1((int64_t) env->regs[reg]);
|
---|
1843 | else
|
---|
1844 | val = abs1((int32_t) env->regs[reg]);
|
---|
1845 |
|
---|
1846 | if (ctrl & 1) {
|
---|
1847 | if (val > 8)
|
---|
1848 | return 8;
|
---|
1849 | } else
|
---|
1850 | if (val > 16)
|
---|
1851 | return 16;
|
---|
1852 |
|
---|
1853 | return val;
|
---|
1854 | }
|
---|
1855 |
|
---|
1856 | #ifndef VBOX
|
---|
1857 | static inline int pcmp_ilen(Reg *r, uint8_t ctrl)
|
---|
1858 | #else /* VBOX */
|
---|
1859 | DECLINLINE(int) pcmp_ilen(Reg *r, uint8_t ctrl)
|
---|
1860 | #endif /* VBOX */
|
---|
1861 | {
|
---|
1862 | int val = 0;
|
---|
1863 |
|
---|
1864 | if (ctrl & 1) {
|
---|
1865 | while (val < 8 && r->W(val))
|
---|
1866 | val++;
|
---|
1867 | } else
|
---|
1868 | while (val < 16 && r->B(val))
|
---|
1869 | val++;
|
---|
1870 |
|
---|
1871 | return val;
|
---|
1872 | }
|
---|
1873 |
|
---|
1874 | #ifndef VBOX
|
---|
1875 | static inline int pcmp_val(Reg *r, uint8_t ctrl, int i)
|
---|
1876 | #else /* VBOX */
|
---|
1877 | DECLINLINE(int) pcmp_val(Reg *r, uint8_t ctrl, int i)
|
---|
1878 | #endif /* VBOX */
|
---|
1879 | {
|
---|
1880 | switch ((ctrl >> 0) & 3) {
|
---|
1881 | case 0:
|
---|
1882 | return r->B(i);
|
---|
1883 | case 1:
|
---|
1884 | return r->W(i);
|
---|
1885 | case 2:
|
---|
1886 | return (int8_t) r->B(i);
|
---|
1887 | case 3:
|
---|
1888 | default:
|
---|
1889 | return (int16_t) r->W(i);
|
---|
1890 | }
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 | #ifndef VBOX
|
---|
1894 | static inline unsigned pcmpxstrx(Reg *d, Reg *s,
|
---|
1895 | #else /* VBOX */
|
---|
1896 | DECLINLINE(unsigned) pcmpxstrx(Reg *d, Reg *s,
|
---|
1897 | #endif /* VBOX */
|
---|
1898 | int8_t ctrl, int valids, int validd)
|
---|
1899 | {
|
---|
1900 | unsigned int res = 0;
|
---|
1901 | int v;
|
---|
1902 | int j, i;
|
---|
1903 | int upper = (ctrl & 1) ? 7 : 15;
|
---|
1904 |
|
---|
1905 | valids--;
|
---|
1906 | validd--;
|
---|
1907 |
|
---|
1908 | CC_SRC = (valids < upper ? CC_Z : 0) | (validd < upper ? CC_S : 0);
|
---|
1909 |
|
---|
1910 | switch ((ctrl >> 2) & 3) {
|
---|
1911 | case 0:
|
---|
1912 | for (j = valids; j >= 0; j--) {
|
---|
1913 | res <<= 1;
|
---|
1914 | v = pcmp_val(s, ctrl, j);
|
---|
1915 | for (i = validd; i >= 0; i--)
|
---|
1916 | res |= (v == pcmp_val(d, ctrl, i));
|
---|
1917 | }
|
---|
1918 | break;
|
---|
1919 | case 1:
|
---|
1920 | for (j = valids; j >= 0; j--) {
|
---|
1921 | res <<= 1;
|
---|
1922 | v = pcmp_val(s, ctrl, j);
|
---|
1923 | for (i = ((validd - 1) | 1); i >= 0; i -= 2)
|
---|
1924 | res |= (pcmp_val(d, ctrl, i - 0) <= v &&
|
---|
1925 | pcmp_val(d, ctrl, i - 1) >= v);
|
---|
1926 | }
|
---|
1927 | break;
|
---|
1928 | case 2:
|
---|
1929 | res = (2 << (upper - MAX(valids, validd))) - 1;
|
---|
1930 | res <<= MAX(valids, validd) - MIN(valids, validd);
|
---|
1931 | for (i = MIN(valids, validd); i >= 0; i--) {
|
---|
1932 | res <<= 1;
|
---|
1933 | v = pcmp_val(s, ctrl, i);
|
---|
1934 | res |= (v == pcmp_val(d, ctrl, i));
|
---|
1935 | }
|
---|
1936 | break;
|
---|
1937 | case 3:
|
---|
1938 | for (j = valids - validd; j >= 0; j--) {
|
---|
1939 | res <<= 1;
|
---|
1940 | res |= 1;
|
---|
1941 | for (i = MIN(upper - j, validd); i >= 0; i--)
|
---|
1942 | res &= (pcmp_val(s, ctrl, i + j) == pcmp_val(d, ctrl, i));
|
---|
1943 | }
|
---|
1944 | break;
|
---|
1945 | }
|
---|
1946 |
|
---|
1947 | switch ((ctrl >> 4) & 3) {
|
---|
1948 | case 1:
|
---|
1949 | res ^= (2 << upper) - 1;
|
---|
1950 | break;
|
---|
1951 | case 3:
|
---|
1952 | res ^= (2 << valids) - 1;
|
---|
1953 | break;
|
---|
1954 | }
|
---|
1955 |
|
---|
1956 | if (res)
|
---|
1957 | CC_SRC |= CC_C;
|
---|
1958 | if (res & 1)
|
---|
1959 | CC_SRC |= CC_O;
|
---|
1960 |
|
---|
1961 | return res;
|
---|
1962 | }
|
---|
1963 |
|
---|
1964 | #ifndef VBOX
|
---|
1965 | static inline int rffs1(unsigned int val)
|
---|
1966 | #else /* VBOX */
|
---|
1967 | DECLINLINE(int) rffs1(unsigned int val)
|
---|
1968 | #endif /* VBOX */
|
---|
1969 | {
|
---|
1970 | int ret = 1, hi;
|
---|
1971 |
|
---|
1972 | for (hi = sizeof(val) * 4; hi; hi /= 2)
|
---|
1973 | if (val >> hi) {
|
---|
1974 | val >>= hi;
|
---|
1975 | ret += hi;
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | return ret;
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | #ifndef VBOX
|
---|
1982 | static inline int ffs1(unsigned int val)
|
---|
1983 | #else /* VBOX */
|
---|
1984 | DECLINLINE(int) ffs1(unsigned int val)
|
---|
1985 | #endif /* VBOX */
|
---|
1986 | {
|
---|
1987 | int ret = 1, hi;
|
---|
1988 |
|
---|
1989 | for (hi = sizeof(val) * 4; hi; hi /= 2)
|
---|
1990 | if (val << hi) {
|
---|
1991 | val <<= hi;
|
---|
1992 | ret += hi;
|
---|
1993 | }
|
---|
1994 |
|
---|
1995 | return ret;
|
---|
1996 | }
|
---|
1997 |
|
---|
1998 | void glue(helper_pcmpestri, SUFFIX) (Reg *d, Reg *s, uint32_t ctrl)
|
---|
1999 | {
|
---|
2000 | unsigned int res = pcmpxstrx(d, s, ctrl,
|
---|
2001 | pcmp_elen(R_EDX, ctrl),
|
---|
2002 | pcmp_elen(R_EAX, ctrl));
|
---|
2003 |
|
---|
2004 | if (res)
|
---|
2005 | #ifndef VBOX
|
---|
2006 | env->regs[R_ECX] = ((ctrl & (1 << 6)) ? rffs1 : ffs1)(res) - 1;
|
---|
2007 | #else
|
---|
2008 | env->regs[R_ECX] = ((ctrl & (1 << 6)) ? rffs1(res) : ffs1(res)) - 1;
|
---|
2009 | #endif
|
---|
2010 | else
|
---|
2011 | env->regs[R_ECX] = 16 >> (ctrl & (1 << 0));
|
---|
2012 | }
|
---|
2013 |
|
---|
2014 | void glue(helper_pcmpestrm, SUFFIX) (Reg *d, Reg *s, uint32_t ctrl)
|
---|
2015 | {
|
---|
2016 | int i;
|
---|
2017 | unsigned int res = pcmpxstrx(d, s, ctrl,
|
---|
2018 | pcmp_elen(R_EDX, ctrl),
|
---|
2019 | pcmp_elen(R_EAX, ctrl));
|
---|
2020 |
|
---|
2021 | if ((ctrl >> 6) & 1) {
|
---|
2022 | if (ctrl & 1)
|
---|
2023 | for (i = 0; i <= 8; i--, res >>= 1)
|
---|
2024 | d->W(i) = (res & 1) ? ~0 : 0;
|
---|
2025 | else
|
---|
2026 | for (i = 0; i <= 16; i--, res >>= 1)
|
---|
2027 | d->B(i) = (res & 1) ? ~0 : 0;
|
---|
2028 | } else {
|
---|
2029 | d->Q(1) = 0;
|
---|
2030 | d->Q(0) = res;
|
---|
2031 | }
|
---|
2032 | }
|
---|
2033 |
|
---|
2034 | void glue(helper_pcmpistri, SUFFIX) (Reg *d, Reg *s, uint32_t ctrl)
|
---|
2035 | {
|
---|
2036 | unsigned int res = pcmpxstrx(d, s, ctrl,
|
---|
2037 | pcmp_ilen(s, ctrl),
|
---|
2038 | pcmp_ilen(d, ctrl));
|
---|
2039 |
|
---|
2040 | if (res)
|
---|
2041 | env->regs[R_ECX] = ((ctrl & (1 << 6)) ? rffs1 : ffs1)(res) - 1;
|
---|
2042 | else
|
---|
2043 | env->regs[R_ECX] = 16 >> (ctrl & (1 << 0));
|
---|
2044 | }
|
---|
2045 |
|
---|
2046 | void glue(helper_pcmpistrm, SUFFIX) (Reg *d, Reg *s, uint32_t ctrl)
|
---|
2047 | {
|
---|
2048 | int i;
|
---|
2049 | unsigned int res = pcmpxstrx(d, s, ctrl,
|
---|
2050 | pcmp_ilen(s, ctrl),
|
---|
2051 | pcmp_ilen(d, ctrl));
|
---|
2052 |
|
---|
2053 | if ((ctrl >> 6) & 1) {
|
---|
2054 | if (ctrl & 1)
|
---|
2055 | for (i = 0; i <= 8; i--, res >>= 1)
|
---|
2056 | d->W(i) = (res & 1) ? ~0 : 0;
|
---|
2057 | else
|
---|
2058 | for (i = 0; i <= 16; i--, res >>= 1)
|
---|
2059 | d->B(i) = (res & 1) ? ~0 : 0;
|
---|
2060 | } else {
|
---|
2061 | d->Q(1) = 0;
|
---|
2062 | d->Q(0) = res;
|
---|
2063 | }
|
---|
2064 | }
|
---|
2065 |
|
---|
2066 | #define CRCPOLY 0x1edc6f41
|
---|
2067 | #define CRCPOLY_BITREV 0x82f63b78
|
---|
2068 | target_ulong helper_crc32(uint32_t crc1, target_ulong msg, uint32_t len)
|
---|
2069 | {
|
---|
2070 | target_ulong crc = (msg & ((target_ulong) -1 >>
|
---|
2071 | (TARGET_LONG_BITS - len))) ^ crc1;
|
---|
2072 |
|
---|
2073 | while (len--)
|
---|
2074 | crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_BITREV : 0);
|
---|
2075 |
|
---|
2076 | return crc;
|
---|
2077 | }
|
---|
2078 |
|
---|
2079 | #define POPMASK(i) ((target_ulong) -1 / ((1LL << (1 << i)) + 1))
|
---|
2080 | #define POPCOUNT(n, i) (n & POPMASK(i)) + ((n >> (1 << i)) & POPMASK(i))
|
---|
2081 | target_ulong helper_popcnt(target_ulong n, uint32_t type)
|
---|
2082 | {
|
---|
2083 | CC_SRC = n ? 0 : CC_Z;
|
---|
2084 |
|
---|
2085 | n = POPCOUNT(n, 0);
|
---|
2086 | n = POPCOUNT(n, 1);
|
---|
2087 | n = POPCOUNT(n, 2);
|
---|
2088 | n = POPCOUNT(n, 3);
|
---|
2089 | if (type == 1)
|
---|
2090 | return n & 0xff;
|
---|
2091 |
|
---|
2092 | n = POPCOUNT(n, 4);
|
---|
2093 | #ifndef TARGET_X86_64
|
---|
2094 | return n;
|
---|
2095 | #else
|
---|
2096 | if (type == 2)
|
---|
2097 | return n & 0xff;
|
---|
2098 |
|
---|
2099 | return POPCOUNT(n, 5);
|
---|
2100 | #endif
|
---|
2101 | }
|
---|
2102 | #endif
|
---|
2103 |
|
---|
2104 | #undef SHIFT
|
---|
2105 | #undef XMM_ONLY
|
---|
2106 | #undef Reg
|
---|
2107 | #undef B
|
---|
2108 | #undef W
|
---|
2109 | #undef L
|
---|
2110 | #undef Q
|
---|
2111 | #undef SUFFIX
|
---|