root / target-i386 / ops_sse.h @ 2157fa06
History | View | Annotate | Download (36.8 kB)
1 | 664e0f19 | bellard | /*
|
---|---|---|---|
2 | 664e0f19 | bellard | * MMX/SSE/SSE2/PNI support
|
3 | 664e0f19 | bellard | *
|
4 | 664e0f19 | bellard | * Copyright (c) 2005 Fabrice Bellard
|
5 | 664e0f19 | bellard | *
|
6 | 664e0f19 | bellard | * This library is free software; you can redistribute it and/or
|
7 | 664e0f19 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 664e0f19 | bellard | * License as published by the Free Software Foundation; either
|
9 | 664e0f19 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 664e0f19 | bellard | *
|
11 | 664e0f19 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 664e0f19 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 664e0f19 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 664e0f19 | bellard | * Lesser General Public License for more details.
|
15 | 664e0f19 | bellard | *
|
16 | 664e0f19 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 664e0f19 | bellard | * License along with this library; if not, write to the Free Software
|
18 | 664e0f19 | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 664e0f19 | bellard | */
|
20 | 664e0f19 | bellard | #if SHIFT == 0 |
21 | 664e0f19 | bellard | #define Reg MMXReg
|
22 | 664e0f19 | bellard | #define XMM_ONLY(x...)
|
23 | 664e0f19 | bellard | #define B(n) MMX_B(n)
|
24 | 664e0f19 | bellard | #define W(n) MMX_W(n)
|
25 | 664e0f19 | bellard | #define L(n) MMX_L(n)
|
26 | 664e0f19 | bellard | #define Q(n) q
|
27 | 664e0f19 | bellard | #define SUFFIX _mmx
|
28 | 664e0f19 | bellard | #else
|
29 | 664e0f19 | bellard | #define Reg XMMReg
|
30 | 664e0f19 | bellard | #define XMM_ONLY(x...) x
|
31 | 664e0f19 | bellard | #define B(n) XMM_B(n)
|
32 | 664e0f19 | bellard | #define W(n) XMM_W(n)
|
33 | 664e0f19 | bellard | #define L(n) XMM_L(n)
|
34 | 664e0f19 | bellard | #define Q(n) XMM_Q(n)
|
35 | 664e0f19 | bellard | #define SUFFIX _xmm
|
36 | 664e0f19 | bellard | #endif
|
37 | 664e0f19 | bellard | |
38 | 664e0f19 | bellard | void OPPROTO glue(op_psrlw, SUFFIX)(void) |
39 | 664e0f19 | bellard | { |
40 | 664e0f19 | bellard | Reg *d, *s; |
41 | 664e0f19 | bellard | int shift;
|
42 | 664e0f19 | bellard | |
43 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
44 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
45 | 664e0f19 | bellard | |
46 | 664e0f19 | bellard | if (s->Q(0) > 15) { |
47 | 664e0f19 | bellard | d->Q(0) = 0; |
48 | 664e0f19 | bellard | #if SHIFT == 1 |
49 | 664e0f19 | bellard | d->Q(1) = 0; |
50 | 664e0f19 | bellard | #endif
|
51 | 664e0f19 | bellard | } else {
|
52 | 664e0f19 | bellard | shift = s->B(0);
|
53 | 664e0f19 | bellard | d->W(0) >>= shift;
|
54 | 664e0f19 | bellard | d->W(1) >>= shift;
|
55 | 664e0f19 | bellard | d->W(2) >>= shift;
|
56 | 664e0f19 | bellard | d->W(3) >>= shift;
|
57 | 664e0f19 | bellard | #if SHIFT == 1 |
58 | 664e0f19 | bellard | d->W(4) >>= shift;
|
59 | 664e0f19 | bellard | d->W(5) >>= shift;
|
60 | 664e0f19 | bellard | d->W(6) >>= shift;
|
61 | 664e0f19 | bellard | d->W(7) >>= shift;
|
62 | 664e0f19 | bellard | #endif
|
63 | 664e0f19 | bellard | } |
64 | 0523c6b7 | bellard | FORCE_RET(); |
65 | 664e0f19 | bellard | } |
66 | 664e0f19 | bellard | |
67 | 664e0f19 | bellard | void OPPROTO glue(op_psraw, SUFFIX)(void) |
68 | 664e0f19 | bellard | { |
69 | 664e0f19 | bellard | Reg *d, *s; |
70 | 664e0f19 | bellard | int shift;
|
71 | 664e0f19 | bellard | |
72 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
73 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
74 | 664e0f19 | bellard | |
75 | 664e0f19 | bellard | if (s->Q(0) > 15) { |
76 | 664e0f19 | bellard | shift = 15;
|
77 | 664e0f19 | bellard | } else {
|
78 | 664e0f19 | bellard | shift = s->B(0);
|
79 | 664e0f19 | bellard | } |
80 | 664e0f19 | bellard | d->W(0) = (int16_t)d->W(0) >> shift; |
81 | 664e0f19 | bellard | d->W(1) = (int16_t)d->W(1) >> shift; |
82 | 664e0f19 | bellard | d->W(2) = (int16_t)d->W(2) >> shift; |
83 | 664e0f19 | bellard | d->W(3) = (int16_t)d->W(3) >> shift; |
84 | 664e0f19 | bellard | #if SHIFT == 1 |
85 | 664e0f19 | bellard | d->W(4) = (int16_t)d->W(4) >> shift; |
86 | 664e0f19 | bellard | d->W(5) = (int16_t)d->W(5) >> shift; |
87 | 664e0f19 | bellard | d->W(6) = (int16_t)d->W(6) >> shift; |
88 | 664e0f19 | bellard | d->W(7) = (int16_t)d->W(7) >> shift; |
89 | 664e0f19 | bellard | #endif
|
90 | 664e0f19 | bellard | } |
91 | 664e0f19 | bellard | |
92 | 664e0f19 | bellard | void OPPROTO glue(op_psllw, SUFFIX)(void) |
93 | 664e0f19 | bellard | { |
94 | 664e0f19 | bellard | Reg *d, *s; |
95 | 664e0f19 | bellard | int shift;
|
96 | 664e0f19 | bellard | |
97 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
98 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
99 | 664e0f19 | bellard | |
100 | 664e0f19 | bellard | if (s->Q(0) > 15) { |
101 | 664e0f19 | bellard | d->Q(0) = 0; |
102 | 664e0f19 | bellard | #if SHIFT == 1 |
103 | 664e0f19 | bellard | d->Q(1) = 0; |
104 | 664e0f19 | bellard | #endif
|
105 | 664e0f19 | bellard | } else {
|
106 | 664e0f19 | bellard | shift = s->B(0);
|
107 | 664e0f19 | bellard | d->W(0) <<= shift;
|
108 | 664e0f19 | bellard | d->W(1) <<= shift;
|
109 | 664e0f19 | bellard | d->W(2) <<= shift;
|
110 | 664e0f19 | bellard | d->W(3) <<= shift;
|
111 | 664e0f19 | bellard | #if SHIFT == 1 |
112 | 664e0f19 | bellard | d->W(4) <<= shift;
|
113 | 664e0f19 | bellard | d->W(5) <<= shift;
|
114 | 664e0f19 | bellard | d->W(6) <<= shift;
|
115 | 664e0f19 | bellard | d->W(7) <<= shift;
|
116 | 664e0f19 | bellard | #endif
|
117 | 664e0f19 | bellard | } |
118 | 0523c6b7 | bellard | FORCE_RET(); |
119 | 664e0f19 | bellard | } |
120 | 664e0f19 | bellard | |
121 | 664e0f19 | bellard | void OPPROTO glue(op_psrld, SUFFIX)(void) |
122 | 664e0f19 | bellard | { |
123 | 664e0f19 | bellard | Reg *d, *s; |
124 | 664e0f19 | bellard | int shift;
|
125 | 664e0f19 | bellard | |
126 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
127 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
128 | 664e0f19 | bellard | |
129 | 664e0f19 | bellard | if (s->Q(0) > 31) { |
130 | 664e0f19 | bellard | d->Q(0) = 0; |
131 | 664e0f19 | bellard | #if SHIFT == 1 |
132 | 664e0f19 | bellard | d->Q(1) = 0; |
133 | 664e0f19 | bellard | #endif
|
134 | 664e0f19 | bellard | } else {
|
135 | 664e0f19 | bellard | shift = s->B(0);
|
136 | 664e0f19 | bellard | d->L(0) >>= shift;
|
137 | 664e0f19 | bellard | d->L(1) >>= shift;
|
138 | 664e0f19 | bellard | #if SHIFT == 1 |
139 | 664e0f19 | bellard | d->L(2) >>= shift;
|
140 | 664e0f19 | bellard | d->L(3) >>= shift;
|
141 | 664e0f19 | bellard | #endif
|
142 | 664e0f19 | bellard | } |
143 | 0523c6b7 | bellard | FORCE_RET(); |
144 | 664e0f19 | bellard | } |
145 | 664e0f19 | bellard | |
146 | 664e0f19 | bellard | void OPPROTO glue(op_psrad, SUFFIX)(void) |
147 | 664e0f19 | bellard | { |
148 | 664e0f19 | bellard | Reg *d, *s; |
149 | 664e0f19 | bellard | int shift;
|
150 | 664e0f19 | bellard | |
151 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
152 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
153 | 664e0f19 | bellard | |
154 | 664e0f19 | bellard | if (s->Q(0) > 31) { |
155 | 664e0f19 | bellard | shift = 31;
|
156 | 664e0f19 | bellard | } else {
|
157 | 664e0f19 | bellard | shift = s->B(0);
|
158 | 664e0f19 | bellard | } |
159 | 664e0f19 | bellard | d->L(0) = (int32_t)d->L(0) >> shift; |
160 | 664e0f19 | bellard | d->L(1) = (int32_t)d->L(1) >> shift; |
161 | 664e0f19 | bellard | #if SHIFT == 1 |
162 | 664e0f19 | bellard | d->L(2) = (int32_t)d->L(2) >> shift; |
163 | 664e0f19 | bellard | d->L(3) = (int32_t)d->L(3) >> shift; |
164 | 664e0f19 | bellard | #endif
|
165 | 664e0f19 | bellard | } |
166 | 664e0f19 | bellard | |
167 | 664e0f19 | bellard | void OPPROTO glue(op_pslld, SUFFIX)(void) |
168 | 664e0f19 | bellard | { |
169 | 664e0f19 | bellard | Reg *d, *s; |
170 | 664e0f19 | bellard | int shift;
|
171 | 664e0f19 | bellard | |
172 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
173 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
174 | 664e0f19 | bellard | |
175 | 664e0f19 | bellard | if (s->Q(0) > 31) { |
176 | 664e0f19 | bellard | d->Q(0) = 0; |
177 | 664e0f19 | bellard | #if SHIFT == 1 |
178 | 664e0f19 | bellard | d->Q(1) = 0; |
179 | 664e0f19 | bellard | #endif
|
180 | 664e0f19 | bellard | } else {
|
181 | 664e0f19 | bellard | shift = s->B(0);
|
182 | 664e0f19 | bellard | d->L(0) <<= shift;
|
183 | 664e0f19 | bellard | d->L(1) <<= shift;
|
184 | 664e0f19 | bellard | #if SHIFT == 1 |
185 | 664e0f19 | bellard | d->L(2) <<= shift;
|
186 | 664e0f19 | bellard | d->L(3) <<= shift;
|
187 | 664e0f19 | bellard | #endif
|
188 | 664e0f19 | bellard | } |
189 | 0523c6b7 | bellard | FORCE_RET(); |
190 | 664e0f19 | bellard | } |
191 | 664e0f19 | bellard | |
192 | 664e0f19 | bellard | void OPPROTO glue(op_psrlq, SUFFIX)(void) |
193 | 664e0f19 | bellard | { |
194 | 664e0f19 | bellard | Reg *d, *s; |
195 | 664e0f19 | bellard | int shift;
|
196 | 664e0f19 | bellard | |
197 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
198 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
199 | 664e0f19 | bellard | |
200 | 664e0f19 | bellard | if (s->Q(0) > 63) { |
201 | 664e0f19 | bellard | d->Q(0) = 0; |
202 | 664e0f19 | bellard | #if SHIFT == 1 |
203 | 664e0f19 | bellard | d->Q(1) = 0; |
204 | 664e0f19 | bellard | #endif
|
205 | 664e0f19 | bellard | } else {
|
206 | 664e0f19 | bellard | shift = s->B(0);
|
207 | 664e0f19 | bellard | d->Q(0) >>= shift;
|
208 | 664e0f19 | bellard | #if SHIFT == 1 |
209 | 664e0f19 | bellard | d->Q(1) >>= shift;
|
210 | 664e0f19 | bellard | #endif
|
211 | 664e0f19 | bellard | } |
212 | 0523c6b7 | bellard | FORCE_RET(); |
213 | 664e0f19 | bellard | } |
214 | 664e0f19 | bellard | |
215 | 664e0f19 | bellard | void OPPROTO glue(op_psllq, SUFFIX)(void) |
216 | 664e0f19 | bellard | { |
217 | 664e0f19 | bellard | Reg *d, *s; |
218 | 664e0f19 | bellard | int shift;
|
219 | 664e0f19 | bellard | |
220 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
221 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
222 | 664e0f19 | bellard | |
223 | 664e0f19 | bellard | if (s->Q(0) > 63) { |
224 | 664e0f19 | bellard | d->Q(0) = 0; |
225 | 664e0f19 | bellard | #if SHIFT == 1 |
226 | 664e0f19 | bellard | d->Q(1) = 0; |
227 | 664e0f19 | bellard | #endif
|
228 | 664e0f19 | bellard | } else {
|
229 | 664e0f19 | bellard | shift = s->B(0);
|
230 | 664e0f19 | bellard | d->Q(0) <<= shift;
|
231 | 664e0f19 | bellard | #if SHIFT == 1 |
232 | 664e0f19 | bellard | d->Q(1) <<= shift;
|
233 | 664e0f19 | bellard | #endif
|
234 | 664e0f19 | bellard | } |
235 | 0523c6b7 | bellard | FORCE_RET(); |
236 | 664e0f19 | bellard | } |
237 | 664e0f19 | bellard | |
238 | 664e0f19 | bellard | #if SHIFT == 1 |
239 | 664e0f19 | bellard | void OPPROTO glue(op_psrldq, SUFFIX)(void) |
240 | 664e0f19 | bellard | { |
241 | 664e0f19 | bellard | Reg *d, *s; |
242 | 664e0f19 | bellard | int shift, i;
|
243 | 664e0f19 | bellard | |
244 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
245 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
246 | 664e0f19 | bellard | shift = s->L(0);
|
247 | 664e0f19 | bellard | if (shift > 16) |
248 | 664e0f19 | bellard | shift = 16;
|
249 | 664e0f19 | bellard | for(i = 0; i < 16 - shift; i++) |
250 | 664e0f19 | bellard | d->B(i) = d->B(i + shift); |
251 | 664e0f19 | bellard | for(i = 16 - shift; i < 16; i++) |
252 | 664e0f19 | bellard | d->B(i) = 0;
|
253 | 664e0f19 | bellard | FORCE_RET(); |
254 | 664e0f19 | bellard | } |
255 | 664e0f19 | bellard | |
256 | 664e0f19 | bellard | void OPPROTO glue(op_pslldq, SUFFIX)(void) |
257 | 664e0f19 | bellard | { |
258 | 664e0f19 | bellard | Reg *d, *s; |
259 | 664e0f19 | bellard | int shift, i;
|
260 | 664e0f19 | bellard | |
261 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
262 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
263 | 664e0f19 | bellard | shift = s->L(0);
|
264 | 664e0f19 | bellard | if (shift > 16) |
265 | 664e0f19 | bellard | shift = 16;
|
266 | 664e0f19 | bellard | for(i = 15; i >= shift; i--) |
267 | 664e0f19 | bellard | d->B(i) = d->B(i - shift); |
268 | 664e0f19 | bellard | for(i = 0; i < shift; i++) |
269 | 664e0f19 | bellard | d->B(i) = 0;
|
270 | 664e0f19 | bellard | FORCE_RET(); |
271 | 664e0f19 | bellard | } |
272 | 664e0f19 | bellard | #endif
|
273 | 664e0f19 | bellard | |
274 | 664e0f19 | bellard | #define SSE_OP_B(name, F)\
|
275 | 664e0f19 | bellard | void OPPROTO glue(name, SUFFIX) (void)\ |
276 | 664e0f19 | bellard | {\ |
277 | 664e0f19 | bellard | Reg *d, *s;\ |
278 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
279 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
280 | 664e0f19 | bellard | d->B(0) = F(d->B(0), s->B(0));\ |
281 | 664e0f19 | bellard | d->B(1) = F(d->B(1), s->B(1));\ |
282 | 664e0f19 | bellard | d->B(2) = F(d->B(2), s->B(2));\ |
283 | 664e0f19 | bellard | d->B(3) = F(d->B(3), s->B(3));\ |
284 | 664e0f19 | bellard | d->B(4) = F(d->B(4), s->B(4));\ |
285 | 664e0f19 | bellard | d->B(5) = F(d->B(5), s->B(5));\ |
286 | 664e0f19 | bellard | d->B(6) = F(d->B(6), s->B(6));\ |
287 | 664e0f19 | bellard | d->B(7) = F(d->B(7), s->B(7));\ |
288 | 664e0f19 | bellard | XMM_ONLY(\ |
289 | 664e0f19 | bellard | d->B(8) = F(d->B(8), s->B(8));\ |
290 | 664e0f19 | bellard | d->B(9) = F(d->B(9), s->B(9));\ |
291 | 664e0f19 | bellard | d->B(10) = F(d->B(10), s->B(10));\ |
292 | 664e0f19 | bellard | d->B(11) = F(d->B(11), s->B(11));\ |
293 | 664e0f19 | bellard | d->B(12) = F(d->B(12), s->B(12));\ |
294 | 664e0f19 | bellard | d->B(13) = F(d->B(13), s->B(13));\ |
295 | 664e0f19 | bellard | d->B(14) = F(d->B(14), s->B(14));\ |
296 | 664e0f19 | bellard | d->B(15) = F(d->B(15), s->B(15));\ |
297 | 664e0f19 | bellard | )\ |
298 | 664e0f19 | bellard | } |
299 | 664e0f19 | bellard | |
300 | 664e0f19 | bellard | #define SSE_OP_W(name, F)\
|
301 | 664e0f19 | bellard | void OPPROTO glue(name, SUFFIX) (void)\ |
302 | 664e0f19 | bellard | {\ |
303 | 664e0f19 | bellard | Reg *d, *s;\ |
304 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
305 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
306 | 664e0f19 | bellard | d->W(0) = F(d->W(0), s->W(0));\ |
307 | 664e0f19 | bellard | d->W(1) = F(d->W(1), s->W(1));\ |
308 | 664e0f19 | bellard | d->W(2) = F(d->W(2), s->W(2));\ |
309 | 664e0f19 | bellard | d->W(3) = F(d->W(3), s->W(3));\ |
310 | 664e0f19 | bellard | XMM_ONLY(\ |
311 | 664e0f19 | bellard | d->W(4) = F(d->W(4), s->W(4));\ |
312 | 664e0f19 | bellard | d->W(5) = F(d->W(5), s->W(5));\ |
313 | 664e0f19 | bellard | d->W(6) = F(d->W(6), s->W(6));\ |
314 | 664e0f19 | bellard | d->W(7) = F(d->W(7), s->W(7));\ |
315 | 664e0f19 | bellard | )\ |
316 | 664e0f19 | bellard | } |
317 | 664e0f19 | bellard | |
318 | 664e0f19 | bellard | #define SSE_OP_L(name, F)\
|
319 | 664e0f19 | bellard | void OPPROTO glue(name, SUFFIX) (void)\ |
320 | 664e0f19 | bellard | {\ |
321 | 664e0f19 | bellard | Reg *d, *s;\ |
322 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
323 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
324 | 664e0f19 | bellard | d->L(0) = F(d->L(0), s->L(0));\ |
325 | 664e0f19 | bellard | d->L(1) = F(d->L(1), s->L(1));\ |
326 | 664e0f19 | bellard | XMM_ONLY(\ |
327 | 664e0f19 | bellard | d->L(2) = F(d->L(2), s->L(2));\ |
328 | 664e0f19 | bellard | d->L(3) = F(d->L(3), s->L(3));\ |
329 | 664e0f19 | bellard | )\ |
330 | 664e0f19 | bellard | } |
331 | 664e0f19 | bellard | |
332 | 664e0f19 | bellard | #define SSE_OP_Q(name, F)\
|
333 | 664e0f19 | bellard | void OPPROTO glue(name, SUFFIX) (void)\ |
334 | 664e0f19 | bellard | {\ |
335 | 664e0f19 | bellard | Reg *d, *s;\ |
336 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
337 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
338 | 664e0f19 | bellard | d->Q(0) = F(d->Q(0), s->Q(0));\ |
339 | 664e0f19 | bellard | XMM_ONLY(\ |
340 | 664e0f19 | bellard | d->Q(1) = F(d->Q(1), s->Q(1));\ |
341 | 664e0f19 | bellard | )\ |
342 | 664e0f19 | bellard | } |
343 | 664e0f19 | bellard | |
344 | 664e0f19 | bellard | #if SHIFT == 0 |
345 | 664e0f19 | bellard | static inline int satub(int x) |
346 | 664e0f19 | bellard | { |
347 | 664e0f19 | bellard | if (x < 0) |
348 | 664e0f19 | bellard | return 0; |
349 | 664e0f19 | bellard | else if (x > 255) |
350 | 664e0f19 | bellard | return 255; |
351 | 664e0f19 | bellard | else
|
352 | 664e0f19 | bellard | return x;
|
353 | 664e0f19 | bellard | } |
354 | 664e0f19 | bellard | |
355 | 664e0f19 | bellard | static inline int satuw(int x) |
356 | 664e0f19 | bellard | { |
357 | 664e0f19 | bellard | if (x < 0) |
358 | 664e0f19 | bellard | return 0; |
359 | 664e0f19 | bellard | else if (x > 65535) |
360 | 664e0f19 | bellard | return 65535; |
361 | 664e0f19 | bellard | else
|
362 | 664e0f19 | bellard | return x;
|
363 | 664e0f19 | bellard | } |
364 | 664e0f19 | bellard | |
365 | 664e0f19 | bellard | static inline int satsb(int x) |
366 | 664e0f19 | bellard | { |
367 | 664e0f19 | bellard | if (x < -128) |
368 | 664e0f19 | bellard | return -128; |
369 | 664e0f19 | bellard | else if (x > 127) |
370 | 664e0f19 | bellard | return 127; |
371 | 664e0f19 | bellard | else
|
372 | 664e0f19 | bellard | return x;
|
373 | 664e0f19 | bellard | } |
374 | 664e0f19 | bellard | |
375 | 664e0f19 | bellard | static inline int satsw(int x) |
376 | 664e0f19 | bellard | { |
377 | 664e0f19 | bellard | if (x < -32768) |
378 | 664e0f19 | bellard | return -32768; |
379 | 664e0f19 | bellard | else if (x > 32767) |
380 | 664e0f19 | bellard | return 32767; |
381 | 664e0f19 | bellard | else
|
382 | 664e0f19 | bellard | return x;
|
383 | 664e0f19 | bellard | } |
384 | 664e0f19 | bellard | |
385 | 664e0f19 | bellard | #define FADD(a, b) ((a) + (b))
|
386 | 664e0f19 | bellard | #define FADDUB(a, b) satub((a) + (b))
|
387 | 664e0f19 | bellard | #define FADDUW(a, b) satuw((a) + (b))
|
388 | 664e0f19 | bellard | #define FADDSB(a, b) satsb((int8_t)(a) + (int8_t)(b))
|
389 | 664e0f19 | bellard | #define FADDSW(a, b) satsw((int16_t)(a) + (int16_t)(b))
|
390 | 664e0f19 | bellard | |
391 | 664e0f19 | bellard | #define FSUB(a, b) ((a) - (b))
|
392 | 664e0f19 | bellard | #define FSUBUB(a, b) satub((a) - (b))
|
393 | 664e0f19 | bellard | #define FSUBUW(a, b) satuw((a) - (b))
|
394 | 664e0f19 | bellard | #define FSUBSB(a, b) satsb((int8_t)(a) - (int8_t)(b))
|
395 | 664e0f19 | bellard | #define FSUBSW(a, b) satsw((int16_t)(a) - (int16_t)(b))
|
396 | 664e0f19 | bellard | #define FMINUB(a, b) ((a) < (b)) ? (a) : (b)
|
397 | 664e0f19 | bellard | #define FMINSW(a, b) ((int16_t)(a) < (int16_t)(b)) ? (a) : (b)
|
398 | 664e0f19 | bellard | #define FMAXUB(a, b) ((a) > (b)) ? (a) : (b)
|
399 | 664e0f19 | bellard | #define FMAXSW(a, b) ((int16_t)(a) > (int16_t)(b)) ? (a) : (b)
|
400 | 664e0f19 | bellard | |
401 | 664e0f19 | bellard | #define FAND(a, b) (a) & (b)
|
402 | 664e0f19 | bellard | #define FANDN(a, b) ((~(a)) & (b))
|
403 | 664e0f19 | bellard | #define FOR(a, b) (a) | (b)
|
404 | 664e0f19 | bellard | #define FXOR(a, b) (a) ^ (b)
|
405 | 664e0f19 | bellard | |
406 | 664e0f19 | bellard | #define FCMPGTB(a, b) (int8_t)(a) > (int8_t)(b) ? -1 : 0 |
407 | 664e0f19 | bellard | #define FCMPGTW(a, b) (int16_t)(a) > (int16_t)(b) ? -1 : 0 |
408 | 664e0f19 | bellard | #define FCMPGTL(a, b) (int32_t)(a) > (int32_t)(b) ? -1 : 0 |
409 | 664e0f19 | bellard | #define FCMPEQ(a, b) (a) == (b) ? -1 : 0 |
410 | 664e0f19 | bellard | |
411 | 664e0f19 | bellard | #define FMULLW(a, b) (a) * (b)
|
412 | 664e0f19 | bellard | #define FMULHUW(a, b) (a) * (b) >> 16 |
413 | 664e0f19 | bellard | #define FMULHW(a, b) (int16_t)(a) * (int16_t)(b) >> 16 |
414 | 664e0f19 | bellard | |
415 | 664e0f19 | bellard | #define FAVG(a, b) ((a) + (b) + 1) >> 1 |
416 | 664e0f19 | bellard | #endif
|
417 | 664e0f19 | bellard | |
418 | 664e0f19 | bellard | SSE_OP_B(op_paddb, FADD) |
419 | 664e0f19 | bellard | SSE_OP_W(op_paddw, FADD) |
420 | 664e0f19 | bellard | SSE_OP_L(op_paddl, FADD) |
421 | 664e0f19 | bellard | SSE_OP_Q(op_paddq, FADD) |
422 | 664e0f19 | bellard | |
423 | 664e0f19 | bellard | SSE_OP_B(op_psubb, FSUB) |
424 | 664e0f19 | bellard | SSE_OP_W(op_psubw, FSUB) |
425 | 664e0f19 | bellard | SSE_OP_L(op_psubl, FSUB) |
426 | 664e0f19 | bellard | SSE_OP_Q(op_psubq, FSUB) |
427 | 664e0f19 | bellard | |
428 | 664e0f19 | bellard | SSE_OP_B(op_paddusb, FADDUB) |
429 | 664e0f19 | bellard | SSE_OP_B(op_paddsb, FADDSB) |
430 | 664e0f19 | bellard | SSE_OP_B(op_psubusb, FSUBUB) |
431 | 664e0f19 | bellard | SSE_OP_B(op_psubsb, FSUBSB) |
432 | 664e0f19 | bellard | |
433 | 664e0f19 | bellard | SSE_OP_W(op_paddusw, FADDUW) |
434 | 664e0f19 | bellard | SSE_OP_W(op_paddsw, FADDSW) |
435 | 664e0f19 | bellard | SSE_OP_W(op_psubusw, FSUBUW) |
436 | 664e0f19 | bellard | SSE_OP_W(op_psubsw, FSUBSW) |
437 | 664e0f19 | bellard | |
438 | 664e0f19 | bellard | SSE_OP_B(op_pminub, FMINUB) |
439 | 664e0f19 | bellard | SSE_OP_B(op_pmaxub, FMAXUB) |
440 | 664e0f19 | bellard | |
441 | 664e0f19 | bellard | SSE_OP_W(op_pminsw, FMINSW) |
442 | 664e0f19 | bellard | SSE_OP_W(op_pmaxsw, FMAXSW) |
443 | 664e0f19 | bellard | |
444 | 664e0f19 | bellard | SSE_OP_Q(op_pand, FAND) |
445 | 664e0f19 | bellard | SSE_OP_Q(op_pandn, FANDN) |
446 | 664e0f19 | bellard | SSE_OP_Q(op_por, FOR) |
447 | 664e0f19 | bellard | SSE_OP_Q(op_pxor, FXOR) |
448 | 664e0f19 | bellard | |
449 | 664e0f19 | bellard | SSE_OP_B(op_pcmpgtb, FCMPGTB) |
450 | 664e0f19 | bellard | SSE_OP_W(op_pcmpgtw, FCMPGTW) |
451 | 664e0f19 | bellard | SSE_OP_L(op_pcmpgtl, FCMPGTL) |
452 | 664e0f19 | bellard | |
453 | 664e0f19 | bellard | SSE_OP_B(op_pcmpeqb, FCMPEQ) |
454 | 664e0f19 | bellard | SSE_OP_W(op_pcmpeqw, FCMPEQ) |
455 | 664e0f19 | bellard | SSE_OP_L(op_pcmpeql, FCMPEQ) |
456 | 664e0f19 | bellard | |
457 | 664e0f19 | bellard | SSE_OP_W(op_pmullw, FMULLW) |
458 | 664e0f19 | bellard | SSE_OP_W(op_pmulhuw, FMULHUW) |
459 | 664e0f19 | bellard | SSE_OP_W(op_pmulhw, FMULHW) |
460 | 664e0f19 | bellard | |
461 | 664e0f19 | bellard | SSE_OP_B(op_pavgb, FAVG) |
462 | 664e0f19 | bellard | SSE_OP_W(op_pavgw, FAVG) |
463 | 664e0f19 | bellard | |
464 | 664e0f19 | bellard | void OPPROTO glue(op_pmuludq, SUFFIX) (void) |
465 | 664e0f19 | bellard | { |
466 | 664e0f19 | bellard | Reg *d, *s; |
467 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
468 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
469 | 664e0f19 | bellard | |
470 | 664e0f19 | bellard | d->Q(0) = (uint64_t)s->L(0) * (uint64_t)d->L(0); |
471 | 664e0f19 | bellard | #if SHIFT == 1 |
472 | 664e0f19 | bellard | d->Q(1) = (uint64_t)s->L(2) * (uint64_t)d->L(2); |
473 | 664e0f19 | bellard | #endif
|
474 | 664e0f19 | bellard | } |
475 | 664e0f19 | bellard | |
476 | 664e0f19 | bellard | void OPPROTO glue(op_pmaddwd, SUFFIX) (void) |
477 | 664e0f19 | bellard | { |
478 | 664e0f19 | bellard | int i;
|
479 | 664e0f19 | bellard | Reg *d, *s; |
480 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
481 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
482 | 664e0f19 | bellard | |
483 | 664e0f19 | bellard | for(i = 0; i < (2 << SHIFT); i++) { |
484 | 664e0f19 | bellard | d->L(i) = (int16_t)s->W(2*i) * (int16_t)d->W(2*i) + |
485 | 664e0f19 | bellard | (int16_t)s->W(2*i+1) * (int16_t)d->W(2*i+1); |
486 | 664e0f19 | bellard | } |
487 | 0523c6b7 | bellard | FORCE_RET(); |
488 | 664e0f19 | bellard | } |
489 | 664e0f19 | bellard | |
490 | 664e0f19 | bellard | #if SHIFT == 0 |
491 | 664e0f19 | bellard | static inline int abs1(int a) |
492 | 664e0f19 | bellard | { |
493 | 664e0f19 | bellard | if (a < 0) |
494 | 664e0f19 | bellard | return -a;
|
495 | 664e0f19 | bellard | else
|
496 | 664e0f19 | bellard | return a;
|
497 | 664e0f19 | bellard | } |
498 | 664e0f19 | bellard | #endif
|
499 | 664e0f19 | bellard | void OPPROTO glue(op_psadbw, SUFFIX) (void) |
500 | 664e0f19 | bellard | { |
501 | 664e0f19 | bellard | unsigned int val; |
502 | 664e0f19 | bellard | Reg *d, *s; |
503 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
504 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
505 | 664e0f19 | bellard | |
506 | 664e0f19 | bellard | val = 0;
|
507 | 664e0f19 | bellard | val += abs1(d->B(0) - s->B(0)); |
508 | 664e0f19 | bellard | val += abs1(d->B(1) - s->B(1)); |
509 | 664e0f19 | bellard | val += abs1(d->B(2) - s->B(2)); |
510 | 664e0f19 | bellard | val += abs1(d->B(3) - s->B(3)); |
511 | 664e0f19 | bellard | val += abs1(d->B(4) - s->B(4)); |
512 | 664e0f19 | bellard | val += abs1(d->B(5) - s->B(5)); |
513 | 664e0f19 | bellard | val += abs1(d->B(6) - s->B(6)); |
514 | 664e0f19 | bellard | val += abs1(d->B(7) - s->B(7)); |
515 | 664e0f19 | bellard | d->Q(0) = val;
|
516 | 664e0f19 | bellard | #if SHIFT == 1 |
517 | 664e0f19 | bellard | val = 0;
|
518 | 664e0f19 | bellard | val += abs1(d->B(8) - s->B(8)); |
519 | 664e0f19 | bellard | val += abs1(d->B(9) - s->B(9)); |
520 | 664e0f19 | bellard | val += abs1(d->B(10) - s->B(10)); |
521 | 664e0f19 | bellard | val += abs1(d->B(11) - s->B(11)); |
522 | 664e0f19 | bellard | val += abs1(d->B(12) - s->B(12)); |
523 | 664e0f19 | bellard | val += abs1(d->B(13) - s->B(13)); |
524 | 664e0f19 | bellard | val += abs1(d->B(14) - s->B(14)); |
525 | 664e0f19 | bellard | val += abs1(d->B(15) - s->B(15)); |
526 | 664e0f19 | bellard | d->Q(1) = val;
|
527 | 664e0f19 | bellard | #endif
|
528 | 664e0f19 | bellard | } |
529 | 664e0f19 | bellard | |
530 | 664e0f19 | bellard | void OPPROTO glue(op_maskmov, SUFFIX) (void) |
531 | 664e0f19 | bellard | { |
532 | 664e0f19 | bellard | int i;
|
533 | 664e0f19 | bellard | Reg *d, *s; |
534 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
535 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
536 | 664e0f19 | bellard | for(i = 0; i < (8 << SHIFT); i++) { |
537 | 664e0f19 | bellard | if (s->B(i) & 0x80) |
538 | d52cf7a6 | bellard | stb(A0 + i, d->B(i)); |
539 | 664e0f19 | bellard | } |
540 | 0523c6b7 | bellard | FORCE_RET(); |
541 | 664e0f19 | bellard | } |
542 | 664e0f19 | bellard | |
543 | 664e0f19 | bellard | void OPPROTO glue(op_movl_mm_T0, SUFFIX) (void) |
544 | 664e0f19 | bellard | { |
545 | 664e0f19 | bellard | Reg *d; |
546 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
547 | 664e0f19 | bellard | d->L(0) = T0;
|
548 | 664e0f19 | bellard | d->L(1) = 0; |
549 | 664e0f19 | bellard | #if SHIFT == 1 |
550 | 664e0f19 | bellard | d->Q(1) = 0; |
551 | 664e0f19 | bellard | #endif
|
552 | 664e0f19 | bellard | } |
553 | 664e0f19 | bellard | |
554 | 664e0f19 | bellard | void OPPROTO glue(op_movl_T0_mm, SUFFIX) (void) |
555 | 664e0f19 | bellard | { |
556 | 664e0f19 | bellard | Reg *s; |
557 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM1);
|
558 | 664e0f19 | bellard | T0 = s->L(0);
|
559 | 664e0f19 | bellard | } |
560 | 664e0f19 | bellard | |
561 | 664e0f19 | bellard | #if SHIFT == 0 |
562 | 664e0f19 | bellard | void OPPROTO glue(op_pshufw, SUFFIX) (void) |
563 | 664e0f19 | bellard | { |
564 | 664e0f19 | bellard | Reg r, *d, *s; |
565 | 664e0f19 | bellard | int order;
|
566 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
567 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
568 | 664e0f19 | bellard | order = PARAM3; |
569 | 664e0f19 | bellard | r.W(0) = s->W(order & 3); |
570 | 664e0f19 | bellard | r.W(1) = s->W((order >> 2) & 3); |
571 | 664e0f19 | bellard | r.W(2) = s->W((order >> 4) & 3); |
572 | 664e0f19 | bellard | r.W(3) = s->W((order >> 6) & 3); |
573 | 664e0f19 | bellard | *d = r; |
574 | 664e0f19 | bellard | } |
575 | 664e0f19 | bellard | #else
|
576 | d52cf7a6 | bellard | void OPPROTO op_shufps(void) |
577 | d52cf7a6 | bellard | { |
578 | d52cf7a6 | bellard | Reg r, *d, *s; |
579 | d52cf7a6 | bellard | int order;
|
580 | d52cf7a6 | bellard | d = (Reg *)((char *)env + PARAM1);
|
581 | d52cf7a6 | bellard | s = (Reg *)((char *)env + PARAM2);
|
582 | d52cf7a6 | bellard | order = PARAM3; |
583 | d52cf7a6 | bellard | r.L(0) = d->L(order & 3); |
584 | d52cf7a6 | bellard | r.L(1) = d->L((order >> 2) & 3); |
585 | d52cf7a6 | bellard | r.L(2) = s->L((order >> 4) & 3); |
586 | d52cf7a6 | bellard | r.L(3) = s->L((order >> 6) & 3); |
587 | d52cf7a6 | bellard | *d = r; |
588 | d52cf7a6 | bellard | } |
589 | d52cf7a6 | bellard | |
590 | 664e0f19 | bellard | void OPPROTO op_shufpd(void) |
591 | 664e0f19 | bellard | { |
592 | 664e0f19 | bellard | Reg r, *d, *s; |
593 | 664e0f19 | bellard | int order;
|
594 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
595 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
596 | 664e0f19 | bellard | order = PARAM3; |
597 | d52cf7a6 | bellard | r.Q(0) = d->Q(order & 1); |
598 | 664e0f19 | bellard | r.Q(1) = s->Q((order >> 1) & 1); |
599 | 664e0f19 | bellard | *d = r; |
600 | 664e0f19 | bellard | } |
601 | 664e0f19 | bellard | |
602 | 664e0f19 | bellard | void OPPROTO glue(op_pshufd, SUFFIX) (void) |
603 | 664e0f19 | bellard | { |
604 | 664e0f19 | bellard | Reg r, *d, *s; |
605 | 664e0f19 | bellard | int order;
|
606 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
607 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
608 | 664e0f19 | bellard | order = PARAM3; |
609 | 664e0f19 | bellard | r.L(0) = s->L(order & 3); |
610 | 664e0f19 | bellard | r.L(1) = s->L((order >> 2) & 3); |
611 | 664e0f19 | bellard | r.L(2) = s->L((order >> 4) & 3); |
612 | 664e0f19 | bellard | r.L(3) = s->L((order >> 6) & 3); |
613 | 664e0f19 | bellard | *d = r; |
614 | 664e0f19 | bellard | } |
615 | 664e0f19 | bellard | |
616 | 664e0f19 | bellard | void OPPROTO glue(op_pshuflw, SUFFIX) (void) |
617 | 664e0f19 | bellard | { |
618 | 664e0f19 | bellard | Reg r, *d, *s; |
619 | 664e0f19 | bellard | int order;
|
620 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
621 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
622 | 664e0f19 | bellard | order = PARAM3; |
623 | 664e0f19 | bellard | r.W(0) = s->W(order & 3); |
624 | 664e0f19 | bellard | r.W(1) = s->W((order >> 2) & 3); |
625 | 664e0f19 | bellard | r.W(2) = s->W((order >> 4) & 3); |
626 | 664e0f19 | bellard | r.W(3) = s->W((order >> 6) & 3); |
627 | 664e0f19 | bellard | r.Q(1) = s->Q(1); |
628 | 664e0f19 | bellard | *d = r; |
629 | 664e0f19 | bellard | } |
630 | 664e0f19 | bellard | |
631 | 664e0f19 | bellard | void OPPROTO glue(op_pshufhw, SUFFIX) (void) |
632 | 664e0f19 | bellard | { |
633 | 664e0f19 | bellard | Reg r, *d, *s; |
634 | 664e0f19 | bellard | int order;
|
635 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
636 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
637 | 664e0f19 | bellard | order = PARAM3; |
638 | 664e0f19 | bellard | r.Q(0) = s->Q(0); |
639 | 664e0f19 | bellard | r.W(4) = s->W(4 + (order & 3)); |
640 | 664e0f19 | bellard | r.W(5) = s->W(4 + ((order >> 2) & 3)); |
641 | 664e0f19 | bellard | r.W(6) = s->W(4 + ((order >> 4) & 3)); |
642 | 664e0f19 | bellard | r.W(7) = s->W(4 + ((order >> 6) & 3)); |
643 | 664e0f19 | bellard | *d = r; |
644 | 664e0f19 | bellard | } |
645 | 664e0f19 | bellard | #endif
|
646 | 664e0f19 | bellard | |
647 | 664e0f19 | bellard | #if SHIFT == 1 |
648 | 664e0f19 | bellard | /* FPU ops */
|
649 | 664e0f19 | bellard | /* XXX: not accurate */
|
650 | 664e0f19 | bellard | |
651 | 664e0f19 | bellard | #define SSE_OP_S(name, F)\
|
652 | 664e0f19 | bellard | void OPPROTO op_ ## name ## ps (void)\ |
653 | 664e0f19 | bellard | {\ |
654 | 664e0f19 | bellard | Reg *d, *s;\ |
655 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
656 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
657 | 7a0e1f41 | bellard | d->XMM_S(0) = F(32, d->XMM_S(0), s->XMM_S(0));\ |
658 | 7a0e1f41 | bellard | d->XMM_S(1) = F(32, d->XMM_S(1), s->XMM_S(1));\ |
659 | 7a0e1f41 | bellard | d->XMM_S(2) = F(32, d->XMM_S(2), s->XMM_S(2));\ |
660 | 7a0e1f41 | bellard | d->XMM_S(3) = F(32, d->XMM_S(3), s->XMM_S(3));\ |
661 | 664e0f19 | bellard | }\ |
662 | 664e0f19 | bellard | \ |
663 | 664e0f19 | bellard | void OPPROTO op_ ## name ## ss (void)\ |
664 | 664e0f19 | bellard | {\ |
665 | 664e0f19 | bellard | Reg *d, *s;\ |
666 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
667 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
668 | 7a0e1f41 | bellard | d->XMM_S(0) = F(32, d->XMM_S(0), s->XMM_S(0));\ |
669 | 664e0f19 | bellard | }\ |
670 | 664e0f19 | bellard | void OPPROTO op_ ## name ## pd (void)\ |
671 | 664e0f19 | bellard | {\ |
672 | 664e0f19 | bellard | Reg *d, *s;\ |
673 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
674 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
675 | 7a0e1f41 | bellard | d->XMM_D(0) = F(64, d->XMM_D(0), s->XMM_D(0));\ |
676 | 7a0e1f41 | bellard | d->XMM_D(1) = F(64, d->XMM_D(1), s->XMM_D(1));\ |
677 | 664e0f19 | bellard | }\ |
678 | 664e0f19 | bellard | \ |
679 | 664e0f19 | bellard | void OPPROTO op_ ## name ## sd (void)\ |
680 | 664e0f19 | bellard | {\ |
681 | 664e0f19 | bellard | Reg *d, *s;\ |
682 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
683 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
684 | 7a0e1f41 | bellard | d->XMM_D(0) = F(64, d->XMM_D(0), s->XMM_D(0));\ |
685 | 664e0f19 | bellard | } |
686 | 664e0f19 | bellard | |
687 | 7a0e1f41 | bellard | #define FPU_ADD(size, a, b) float ## size ## _add(a, b, &env->sse_status) |
688 | 7a0e1f41 | bellard | #define FPU_SUB(size, a, b) float ## size ## _sub(a, b, &env->sse_status) |
689 | 7a0e1f41 | bellard | #define FPU_MUL(size, a, b) float ## size ## _mul(a, b, &env->sse_status) |
690 | 7a0e1f41 | bellard | #define FPU_DIV(size, a, b) float ## size ## _div(a, b, &env->sse_status) |
691 | 7a0e1f41 | bellard | #define FPU_MIN(size, a, b) (a) < (b) ? (a) : (b)
|
692 | 7a0e1f41 | bellard | #define FPU_MAX(size, a, b) (a) > (b) ? (a) : (b)
|
693 | 7a0e1f41 | bellard | #define FPU_SQRT(size, a, b) float ## size ## _sqrt(b, &env->sse_status) |
694 | 664e0f19 | bellard | |
695 | 664e0f19 | bellard | SSE_OP_S(add, FPU_ADD) |
696 | 664e0f19 | bellard | SSE_OP_S(sub, FPU_SUB) |
697 | 664e0f19 | bellard | SSE_OP_S(mul, FPU_MUL) |
698 | 664e0f19 | bellard | SSE_OP_S(div, FPU_DIV) |
699 | 664e0f19 | bellard | SSE_OP_S(min, FPU_MIN) |
700 | 664e0f19 | bellard | SSE_OP_S(max, FPU_MAX) |
701 | 664e0f19 | bellard | SSE_OP_S(sqrt, FPU_SQRT) |
702 | 664e0f19 | bellard | |
703 | 664e0f19 | bellard | |
704 | 664e0f19 | bellard | /* float to float conversions */
|
705 | 664e0f19 | bellard | void OPPROTO op_cvtps2pd(void) |
706 | 664e0f19 | bellard | { |
707 | 8422b113 | bellard | float32 s0, s1; |
708 | 664e0f19 | bellard | Reg *d, *s; |
709 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
710 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
711 | 664e0f19 | bellard | s0 = s->XMM_S(0);
|
712 | 664e0f19 | bellard | s1 = s->XMM_S(1);
|
713 | 7a0e1f41 | bellard | d->XMM_D(0) = float32_to_float64(s0, &env->sse_status);
|
714 | 7a0e1f41 | bellard | d->XMM_D(1) = float32_to_float64(s1, &env->sse_status);
|
715 | 664e0f19 | bellard | } |
716 | 664e0f19 | bellard | |
717 | 664e0f19 | bellard | void OPPROTO op_cvtpd2ps(void) |
718 | 664e0f19 | bellard | { |
719 | 664e0f19 | bellard | Reg *d, *s; |
720 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
721 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
722 | 7a0e1f41 | bellard | d->XMM_S(0) = float64_to_float32(s->XMM_D(0), &env->sse_status); |
723 | 7a0e1f41 | bellard | d->XMM_S(1) = float64_to_float32(s->XMM_D(1), &env->sse_status); |
724 | 664e0f19 | bellard | d->Q(1) = 0; |
725 | 664e0f19 | bellard | } |
726 | 664e0f19 | bellard | |
727 | 664e0f19 | bellard | void OPPROTO op_cvtss2sd(void) |
728 | 664e0f19 | bellard | { |
729 | 664e0f19 | bellard | Reg *d, *s; |
730 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
731 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
732 | 7a0e1f41 | bellard | d->XMM_D(0) = float32_to_float64(s->XMM_S(0), &env->sse_status); |
733 | 664e0f19 | bellard | } |
734 | 664e0f19 | bellard | |
735 | 664e0f19 | bellard | void OPPROTO op_cvtsd2ss(void) |
736 | 664e0f19 | bellard | { |
737 | 664e0f19 | bellard | Reg *d, *s; |
738 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
739 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
740 | 7a0e1f41 | bellard | d->XMM_S(0) = float64_to_float32(s->XMM_D(0), &env->sse_status); |
741 | 664e0f19 | bellard | } |
742 | 664e0f19 | bellard | |
743 | 664e0f19 | bellard | /* integer to float */
|
744 | 664e0f19 | bellard | void OPPROTO op_cvtdq2ps(void) |
745 | 664e0f19 | bellard | { |
746 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
747 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
748 | 7a0e1f41 | bellard | d->XMM_S(0) = int32_to_float32(s->XMM_L(0), &env->sse_status); |
749 | 7a0e1f41 | bellard | d->XMM_S(1) = int32_to_float32(s->XMM_L(1), &env->sse_status); |
750 | 7a0e1f41 | bellard | d->XMM_S(2) = int32_to_float32(s->XMM_L(2), &env->sse_status); |
751 | 7a0e1f41 | bellard | d->XMM_S(3) = int32_to_float32(s->XMM_L(3), &env->sse_status); |
752 | 664e0f19 | bellard | } |
753 | 664e0f19 | bellard | |
754 | 664e0f19 | bellard | void OPPROTO op_cvtdq2pd(void) |
755 | 664e0f19 | bellard | { |
756 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
757 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
758 | 664e0f19 | bellard | int32_t l0, l1; |
759 | 664e0f19 | bellard | l0 = (int32_t)s->XMM_L(0);
|
760 | 664e0f19 | bellard | l1 = (int32_t)s->XMM_L(1);
|
761 | 7a0e1f41 | bellard | d->XMM_D(0) = int32_to_float64(l0, &env->sse_status);
|
762 | 7a0e1f41 | bellard | d->XMM_D(1) = int32_to_float64(l1, &env->sse_status);
|
763 | 664e0f19 | bellard | } |
764 | 664e0f19 | bellard | |
765 | 664e0f19 | bellard | void OPPROTO op_cvtpi2ps(void) |
766 | 664e0f19 | bellard | { |
767 | 664e0f19 | bellard | XMMReg *d = (Reg *)((char *)env + PARAM1);
|
768 | 664e0f19 | bellard | MMXReg *s = (MMXReg *)((char *)env + PARAM2);
|
769 | 7a0e1f41 | bellard | d->XMM_S(0) = int32_to_float32(s->MMX_L(0), &env->sse_status); |
770 | 7a0e1f41 | bellard | d->XMM_S(1) = int32_to_float32(s->MMX_L(1), &env->sse_status); |
771 | 664e0f19 | bellard | } |
772 | 664e0f19 | bellard | |
773 | 664e0f19 | bellard | void OPPROTO op_cvtpi2pd(void) |
774 | 664e0f19 | bellard | { |
775 | 664e0f19 | bellard | XMMReg *d = (Reg *)((char *)env + PARAM1);
|
776 | 664e0f19 | bellard | MMXReg *s = (MMXReg *)((char *)env + PARAM2);
|
777 | 7a0e1f41 | bellard | d->XMM_D(0) = int32_to_float64(s->MMX_L(0), &env->sse_status); |
778 | 7a0e1f41 | bellard | d->XMM_D(1) = int32_to_float64(s->MMX_L(1), &env->sse_status); |
779 | 664e0f19 | bellard | } |
780 | 664e0f19 | bellard | |
781 | 664e0f19 | bellard | void OPPROTO op_cvtsi2ss(void) |
782 | 664e0f19 | bellard | { |
783 | 664e0f19 | bellard | XMMReg *d = (Reg *)((char *)env + PARAM1);
|
784 | 7a0e1f41 | bellard | d->XMM_S(0) = int32_to_float32(T0, &env->sse_status);
|
785 | 664e0f19 | bellard | } |
786 | 664e0f19 | bellard | |
787 | 664e0f19 | bellard | void OPPROTO op_cvtsi2sd(void) |
788 | 664e0f19 | bellard | { |
789 | 664e0f19 | bellard | XMMReg *d = (Reg *)((char *)env + PARAM1);
|
790 | 7a0e1f41 | bellard | d->XMM_D(0) = int32_to_float64(T0, &env->sse_status);
|
791 | 664e0f19 | bellard | } |
792 | 664e0f19 | bellard | |
793 | 664e0f19 | bellard | #ifdef TARGET_X86_64
|
794 | 664e0f19 | bellard | void OPPROTO op_cvtsq2ss(void) |
795 | 664e0f19 | bellard | { |
796 | 664e0f19 | bellard | XMMReg *d = (Reg *)((char *)env + PARAM1);
|
797 | 7a0e1f41 | bellard | d->XMM_S(0) = int64_to_float32(T0, &env->sse_status);
|
798 | 664e0f19 | bellard | } |
799 | 664e0f19 | bellard | |
800 | 664e0f19 | bellard | void OPPROTO op_cvtsq2sd(void) |
801 | 664e0f19 | bellard | { |
802 | 664e0f19 | bellard | XMMReg *d = (Reg *)((char *)env + PARAM1);
|
803 | 7a0e1f41 | bellard | d->XMM_D(0) = int64_to_float64(T0, &env->sse_status);
|
804 | 664e0f19 | bellard | } |
805 | 664e0f19 | bellard | #endif
|
806 | 664e0f19 | bellard | |
807 | 664e0f19 | bellard | /* float to integer */
|
808 | 664e0f19 | bellard | void OPPROTO op_cvtps2dq(void) |
809 | 664e0f19 | bellard | { |
810 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
811 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
812 | 7a0e1f41 | bellard | d->XMM_L(0) = float32_to_int32(s->XMM_S(0), &env->sse_status); |
813 | 7a0e1f41 | bellard | d->XMM_L(1) = float32_to_int32(s->XMM_S(1), &env->sse_status); |
814 | 7a0e1f41 | bellard | d->XMM_L(2) = float32_to_int32(s->XMM_S(2), &env->sse_status); |
815 | 7a0e1f41 | bellard | d->XMM_L(3) = float32_to_int32(s->XMM_S(3), &env->sse_status); |
816 | 664e0f19 | bellard | } |
817 | 664e0f19 | bellard | |
818 | 664e0f19 | bellard | void OPPROTO op_cvtpd2dq(void) |
819 | 664e0f19 | bellard | { |
820 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
821 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
822 | 7a0e1f41 | bellard | d->XMM_L(0) = float64_to_int32(s->XMM_D(0), &env->sse_status); |
823 | 7a0e1f41 | bellard | d->XMM_L(1) = float64_to_int32(s->XMM_D(1), &env->sse_status); |
824 | 664e0f19 | bellard | d->XMM_Q(1) = 0; |
825 | 664e0f19 | bellard | } |
826 | 664e0f19 | bellard | |
827 | 664e0f19 | bellard | void OPPROTO op_cvtps2pi(void) |
828 | 664e0f19 | bellard | { |
829 | 664e0f19 | bellard | MMXReg *d = (MMXReg *)((char *)env + PARAM1);
|
830 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
831 | 7a0e1f41 | bellard | d->MMX_L(0) = float32_to_int32(s->XMM_S(0), &env->sse_status); |
832 | 7a0e1f41 | bellard | d->MMX_L(1) = float32_to_int32(s->XMM_S(1), &env->sse_status); |
833 | 664e0f19 | bellard | } |
834 | 664e0f19 | bellard | |
835 | 664e0f19 | bellard | void OPPROTO op_cvtpd2pi(void) |
836 | 664e0f19 | bellard | { |
837 | 664e0f19 | bellard | MMXReg *d = (MMXReg *)((char *)env + PARAM1);
|
838 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
839 | 7a0e1f41 | bellard | d->MMX_L(0) = float64_to_int32(s->XMM_D(0), &env->sse_status); |
840 | 7a0e1f41 | bellard | d->MMX_L(1) = float64_to_int32(s->XMM_D(1), &env->sse_status); |
841 | 664e0f19 | bellard | } |
842 | 664e0f19 | bellard | |
843 | 664e0f19 | bellard | void OPPROTO op_cvtss2si(void) |
844 | 664e0f19 | bellard | { |
845 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
846 | 7a0e1f41 | bellard | T0 = float32_to_int32(s->XMM_S(0), &env->sse_status);
|
847 | 664e0f19 | bellard | } |
848 | 664e0f19 | bellard | |
849 | 664e0f19 | bellard | void OPPROTO op_cvtsd2si(void) |
850 | 664e0f19 | bellard | { |
851 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
852 | 7a0e1f41 | bellard | T0 = float64_to_int32(s->XMM_D(0), &env->sse_status);
|
853 | 664e0f19 | bellard | } |
854 | 664e0f19 | bellard | |
855 | 664e0f19 | bellard | #ifdef TARGET_X86_64
|
856 | 664e0f19 | bellard | void OPPROTO op_cvtss2sq(void) |
857 | 664e0f19 | bellard | { |
858 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
859 | 7a0e1f41 | bellard | T0 = float32_to_int64(s->XMM_S(0), &env->sse_status);
|
860 | 664e0f19 | bellard | } |
861 | 664e0f19 | bellard | |
862 | 664e0f19 | bellard | void OPPROTO op_cvtsd2sq(void) |
863 | 664e0f19 | bellard | { |
864 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
865 | 7a0e1f41 | bellard | T0 = float64_to_int64(s->XMM_D(0), &env->sse_status);
|
866 | 664e0f19 | bellard | } |
867 | 664e0f19 | bellard | #endif
|
868 | 664e0f19 | bellard | |
869 | 664e0f19 | bellard | /* float to integer truncated */
|
870 | 664e0f19 | bellard | void OPPROTO op_cvttps2dq(void) |
871 | 664e0f19 | bellard | { |
872 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
873 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
874 | 7a0e1f41 | bellard | d->XMM_L(0) = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status); |
875 | 7a0e1f41 | bellard | d->XMM_L(1) = float32_to_int32_round_to_zero(s->XMM_S(1), &env->sse_status); |
876 | 7a0e1f41 | bellard | d->XMM_L(2) = float32_to_int32_round_to_zero(s->XMM_S(2), &env->sse_status); |
877 | 7a0e1f41 | bellard | d->XMM_L(3) = float32_to_int32_round_to_zero(s->XMM_S(3), &env->sse_status); |
878 | 664e0f19 | bellard | } |
879 | 664e0f19 | bellard | |
880 | 664e0f19 | bellard | void OPPROTO op_cvttpd2dq(void) |
881 | 664e0f19 | bellard | { |
882 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
883 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
884 | 7a0e1f41 | bellard | d->XMM_L(0) = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status); |
885 | 7a0e1f41 | bellard | d->XMM_L(1) = float64_to_int32_round_to_zero(s->XMM_D(1), &env->sse_status); |
886 | 664e0f19 | bellard | d->XMM_Q(1) = 0; |
887 | 664e0f19 | bellard | } |
888 | 664e0f19 | bellard | |
889 | 664e0f19 | bellard | void OPPROTO op_cvttps2pi(void) |
890 | 664e0f19 | bellard | { |
891 | 664e0f19 | bellard | MMXReg *d = (MMXReg *)((char *)env + PARAM1);
|
892 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
893 | 7a0e1f41 | bellard | d->MMX_L(0) = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status); |
894 | 7a0e1f41 | bellard | d->MMX_L(1) = float32_to_int32_round_to_zero(s->XMM_S(1), &env->sse_status); |
895 | 664e0f19 | bellard | } |
896 | 664e0f19 | bellard | |
897 | 664e0f19 | bellard | void OPPROTO op_cvttpd2pi(void) |
898 | 664e0f19 | bellard | { |
899 | 664e0f19 | bellard | MMXReg *d = (MMXReg *)((char *)env + PARAM1);
|
900 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
901 | 7a0e1f41 | bellard | d->MMX_L(0) = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status); |
902 | 7a0e1f41 | bellard | d->MMX_L(1) = float64_to_int32_round_to_zero(s->XMM_D(1), &env->sse_status); |
903 | 664e0f19 | bellard | } |
904 | 664e0f19 | bellard | |
905 | 664e0f19 | bellard | void OPPROTO op_cvttss2si(void) |
906 | 664e0f19 | bellard | { |
907 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
908 | 7a0e1f41 | bellard | T0 = float32_to_int32_round_to_zero(s->XMM_S(0), &env->sse_status);
|
909 | 664e0f19 | bellard | } |
910 | 664e0f19 | bellard | |
911 | 664e0f19 | bellard | void OPPROTO op_cvttsd2si(void) |
912 | 664e0f19 | bellard | { |
913 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
914 | 7a0e1f41 | bellard | T0 = float64_to_int32_round_to_zero(s->XMM_D(0), &env->sse_status);
|
915 | 664e0f19 | bellard | } |
916 | 664e0f19 | bellard | |
917 | 664e0f19 | bellard | #ifdef TARGET_X86_64
|
918 | 664e0f19 | bellard | void OPPROTO op_cvttss2sq(void) |
919 | 664e0f19 | bellard | { |
920 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
921 | 7a0e1f41 | bellard | T0 = float32_to_int64_round_to_zero(s->XMM_S(0), &env->sse_status);
|
922 | 664e0f19 | bellard | } |
923 | 664e0f19 | bellard | |
924 | 664e0f19 | bellard | void OPPROTO op_cvttsd2sq(void) |
925 | 664e0f19 | bellard | { |
926 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM1);
|
927 | 7a0e1f41 | bellard | T0 = float64_to_int64_round_to_zero(s->XMM_D(0), &env->sse_status);
|
928 | 664e0f19 | bellard | } |
929 | 664e0f19 | bellard | #endif
|
930 | 664e0f19 | bellard | |
931 | 664e0f19 | bellard | void OPPROTO op_rsqrtps(void) |
932 | 664e0f19 | bellard | { |
933 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
934 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
935 | 664e0f19 | bellard | d->XMM_S(0) = approx_rsqrt(s->XMM_S(0)); |
936 | 664e0f19 | bellard | d->XMM_S(1) = approx_rsqrt(s->XMM_S(1)); |
937 | 664e0f19 | bellard | d->XMM_S(2) = approx_rsqrt(s->XMM_S(2)); |
938 | 664e0f19 | bellard | d->XMM_S(3) = approx_rsqrt(s->XMM_S(3)); |
939 | 664e0f19 | bellard | } |
940 | 664e0f19 | bellard | |
941 | 664e0f19 | bellard | void OPPROTO op_rsqrtss(void) |
942 | 664e0f19 | bellard | { |
943 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
944 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
945 | 664e0f19 | bellard | d->XMM_S(0) = approx_rsqrt(s->XMM_S(0)); |
946 | 664e0f19 | bellard | } |
947 | 664e0f19 | bellard | |
948 | 664e0f19 | bellard | void OPPROTO op_rcpps(void) |
949 | 664e0f19 | bellard | { |
950 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
951 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
952 | 664e0f19 | bellard | d->XMM_S(0) = approx_rcp(s->XMM_S(0)); |
953 | 664e0f19 | bellard | d->XMM_S(1) = approx_rcp(s->XMM_S(1)); |
954 | 664e0f19 | bellard | d->XMM_S(2) = approx_rcp(s->XMM_S(2)); |
955 | 664e0f19 | bellard | d->XMM_S(3) = approx_rcp(s->XMM_S(3)); |
956 | 664e0f19 | bellard | } |
957 | 664e0f19 | bellard | |
958 | 664e0f19 | bellard | void OPPROTO op_rcpss(void) |
959 | 664e0f19 | bellard | { |
960 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
961 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
962 | 664e0f19 | bellard | d->XMM_S(0) = approx_rcp(s->XMM_S(0)); |
963 | 664e0f19 | bellard | } |
964 | 664e0f19 | bellard | |
965 | 664e0f19 | bellard | void OPPROTO op_haddps(void) |
966 | 664e0f19 | bellard | { |
967 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
968 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
969 | 664e0f19 | bellard | XMMReg r; |
970 | 664e0f19 | bellard | r.XMM_S(0) = d->XMM_S(0) + d->XMM_S(1); |
971 | 664e0f19 | bellard | r.XMM_S(1) = d->XMM_S(2) + d->XMM_S(3); |
972 | 664e0f19 | bellard | r.XMM_S(2) = s->XMM_S(0) + s->XMM_S(1); |
973 | 664e0f19 | bellard | r.XMM_S(3) = s->XMM_S(2) + s->XMM_S(3); |
974 | 664e0f19 | bellard | *d = r; |
975 | 664e0f19 | bellard | } |
976 | 664e0f19 | bellard | |
977 | 664e0f19 | bellard | void OPPROTO op_haddpd(void) |
978 | 664e0f19 | bellard | { |
979 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
980 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
981 | 664e0f19 | bellard | XMMReg r; |
982 | 664e0f19 | bellard | r.XMM_D(0) = d->XMM_D(0) + d->XMM_D(1); |
983 | 664e0f19 | bellard | r.XMM_D(1) = s->XMM_D(0) + s->XMM_D(1); |
984 | 664e0f19 | bellard | *d = r; |
985 | 664e0f19 | bellard | } |
986 | 664e0f19 | bellard | |
987 | 664e0f19 | bellard | void OPPROTO op_hsubps(void) |
988 | 664e0f19 | bellard | { |
989 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
990 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
991 | 664e0f19 | bellard | XMMReg r; |
992 | 664e0f19 | bellard | r.XMM_S(0) = d->XMM_S(0) - d->XMM_S(1); |
993 | 664e0f19 | bellard | r.XMM_S(1) = d->XMM_S(2) - d->XMM_S(3); |
994 | 664e0f19 | bellard | r.XMM_S(2) = s->XMM_S(0) - s->XMM_S(1); |
995 | 664e0f19 | bellard | r.XMM_S(3) = s->XMM_S(2) - s->XMM_S(3); |
996 | 664e0f19 | bellard | *d = r; |
997 | 664e0f19 | bellard | } |
998 | 664e0f19 | bellard | |
999 | 664e0f19 | bellard | void OPPROTO op_hsubpd(void) |
1000 | 664e0f19 | bellard | { |
1001 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
1002 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
1003 | 664e0f19 | bellard | XMMReg r; |
1004 | 664e0f19 | bellard | r.XMM_D(0) = d->XMM_D(0) - d->XMM_D(1); |
1005 | 664e0f19 | bellard | r.XMM_D(1) = s->XMM_D(0) - s->XMM_D(1); |
1006 | 664e0f19 | bellard | *d = r; |
1007 | 664e0f19 | bellard | } |
1008 | 664e0f19 | bellard | |
1009 | 664e0f19 | bellard | void OPPROTO op_addsubps(void) |
1010 | 664e0f19 | bellard | { |
1011 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
1012 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
1013 | 664e0f19 | bellard | d->XMM_S(0) = d->XMM_S(0) - s->XMM_S(0); |
1014 | 664e0f19 | bellard | d->XMM_S(1) = d->XMM_S(1) + s->XMM_S(1); |
1015 | 664e0f19 | bellard | d->XMM_S(2) = d->XMM_S(2) - s->XMM_S(2); |
1016 | 664e0f19 | bellard | d->XMM_S(3) = d->XMM_S(3) + s->XMM_S(3); |
1017 | 664e0f19 | bellard | } |
1018 | 664e0f19 | bellard | |
1019 | 664e0f19 | bellard | void OPPROTO op_addsubpd(void) |
1020 | 664e0f19 | bellard | { |
1021 | 664e0f19 | bellard | XMMReg *d = (XMMReg *)((char *)env + PARAM1);
|
1022 | 664e0f19 | bellard | XMMReg *s = (XMMReg *)((char *)env + PARAM2);
|
1023 | 664e0f19 | bellard | d->XMM_D(0) = d->XMM_D(0) - s->XMM_D(0); |
1024 | 664e0f19 | bellard | d->XMM_D(1) = d->XMM_D(1) + s->XMM_D(1); |
1025 | 664e0f19 | bellard | } |
1026 | 664e0f19 | bellard | |
1027 | 664e0f19 | bellard | /* XXX: unordered */
|
1028 | 664e0f19 | bellard | #define SSE_OP_CMP(name, F)\
|
1029 | 664e0f19 | bellard | void OPPROTO op_ ## name ## ps (void)\ |
1030 | 664e0f19 | bellard | {\ |
1031 | 664e0f19 | bellard | Reg *d, *s;\ |
1032 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
1033 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
1034 | 8422b113 | bellard | d->XMM_L(0) = F(32, d->XMM_S(0), s->XMM_S(0));\ |
1035 | 8422b113 | bellard | d->XMM_L(1) = F(32, d->XMM_S(1), s->XMM_S(1));\ |
1036 | 8422b113 | bellard | d->XMM_L(2) = F(32, d->XMM_S(2), s->XMM_S(2));\ |
1037 | 8422b113 | bellard | d->XMM_L(3) = F(32, d->XMM_S(3), s->XMM_S(3));\ |
1038 | 664e0f19 | bellard | }\ |
1039 | 664e0f19 | bellard | \ |
1040 | 664e0f19 | bellard | void OPPROTO op_ ## name ## ss (void)\ |
1041 | 664e0f19 | bellard | {\ |
1042 | 664e0f19 | bellard | Reg *d, *s;\ |
1043 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
1044 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
1045 | 8422b113 | bellard | d->XMM_L(0) = F(32, d->XMM_S(0), s->XMM_S(0));\ |
1046 | 664e0f19 | bellard | }\ |
1047 | 664e0f19 | bellard | void OPPROTO op_ ## name ## pd (void)\ |
1048 | 664e0f19 | bellard | {\ |
1049 | 664e0f19 | bellard | Reg *d, *s;\ |
1050 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
1051 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
1052 | 8422b113 | bellard | d->XMM_Q(0) = F(64, d->XMM_D(0), s->XMM_D(0));\ |
1053 | 8422b113 | bellard | d->XMM_Q(1) = F(64, d->XMM_D(1), s->XMM_D(1));\ |
1054 | 664e0f19 | bellard | }\ |
1055 | 664e0f19 | bellard | \ |
1056 | 664e0f19 | bellard | void OPPROTO op_ ## name ## sd (void)\ |
1057 | 664e0f19 | bellard | {\ |
1058 | 664e0f19 | bellard | Reg *d, *s;\ |
1059 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);\
|
1060 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);\
|
1061 | 8422b113 | bellard | d->XMM_Q(0) = F(64, d->XMM_D(0), s->XMM_D(0));\ |
1062 | 664e0f19 | bellard | } |
1063 | 664e0f19 | bellard | |
1064 | 8422b113 | bellard | #define FPU_CMPEQ(size, a, b) float ## size ## _eq(a, b, &env->sse_status) ? -1 : 0 |
1065 | 8422b113 | bellard | #define FPU_CMPLT(size, a, b) float ## size ## _lt(a, b, &env->sse_status) ? -1 : 0 |
1066 | 8422b113 | bellard | #define FPU_CMPLE(size, a, b) float ## size ## _le(a, b, &env->sse_status) ? -1 : 0 |
1067 | 8422b113 | bellard | #define FPU_CMPUNORD(size, a, b) float ## size ## _unordered(a, b, &env->sse_status) ? - 1 : 0 |
1068 | 8422b113 | bellard | #define FPU_CMPNEQ(size, a, b) float ## size ## _eq(a, b, &env->sse_status) ? 0 : -1 |
1069 | 8422b113 | bellard | #define FPU_CMPNLT(size, a, b) float ## size ## _lt(a, b, &env->sse_status) ? 0 : -1 |
1070 | 8422b113 | bellard | #define FPU_CMPNLE(size, a, b) float ## size ## _le(a, b, &env->sse_status) ? 0 : -1 |
1071 | 8422b113 | bellard | #define FPU_CMPORD(size, a, b) float ## size ## _unordered(a, b, &env->sse_status) ? 0 : -1 |
1072 | 664e0f19 | bellard | |
1073 | 664e0f19 | bellard | SSE_OP_CMP(cmpeq, FPU_CMPEQ) |
1074 | 664e0f19 | bellard | SSE_OP_CMP(cmplt, FPU_CMPLT) |
1075 | 664e0f19 | bellard | SSE_OP_CMP(cmple, FPU_CMPLE) |
1076 | 664e0f19 | bellard | SSE_OP_CMP(cmpunord, FPU_CMPUNORD) |
1077 | 664e0f19 | bellard | SSE_OP_CMP(cmpneq, FPU_CMPNEQ) |
1078 | 664e0f19 | bellard | SSE_OP_CMP(cmpnlt, FPU_CMPNLT) |
1079 | 664e0f19 | bellard | SSE_OP_CMP(cmpnle, FPU_CMPNLE) |
1080 | 664e0f19 | bellard | SSE_OP_CMP(cmpord, FPU_CMPORD) |
1081 | 664e0f19 | bellard | |
1082 | 43fb823b | bellard | const int comis_eflags[4] = {CC_C, CC_Z, 0, CC_Z | CC_P | CC_C}; |
1083 | 43fb823b | bellard | |
1084 | 664e0f19 | bellard | void OPPROTO op_ucomiss(void) |
1085 | 664e0f19 | bellard | { |
1086 | 43fb823b | bellard | int ret;
|
1087 | 8422b113 | bellard | float32 s0, s1; |
1088 | 664e0f19 | bellard | Reg *d, *s; |
1089 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
1090 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
1091 | 664e0f19 | bellard | |
1092 | 664e0f19 | bellard | s0 = d->XMM_S(0);
|
1093 | 664e0f19 | bellard | s1 = s->XMM_S(0);
|
1094 | 43fb823b | bellard | ret = float32_compare_quiet(s0, s1, &env->sse_status); |
1095 | 43fb823b | bellard | CC_SRC = comis_eflags[ret + 1];
|
1096 | 664e0f19 | bellard | FORCE_RET(); |
1097 | 664e0f19 | bellard | } |
1098 | 664e0f19 | bellard | |
1099 | 664e0f19 | bellard | void OPPROTO op_comiss(void) |
1100 | 664e0f19 | bellard | { |
1101 | 43fb823b | bellard | int ret;
|
1102 | 8422b113 | bellard | float32 s0, s1; |
1103 | 664e0f19 | bellard | Reg *d, *s; |
1104 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
1105 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
1106 | 664e0f19 | bellard | |
1107 | 664e0f19 | bellard | s0 = d->XMM_S(0);
|
1108 | 664e0f19 | bellard | s1 = s->XMM_S(0);
|
1109 | 43fb823b | bellard | ret = float32_compare(s0, s1, &env->sse_status); |
1110 | 43fb823b | bellard | CC_SRC = comis_eflags[ret + 1];
|
1111 | 664e0f19 | bellard | FORCE_RET(); |
1112 | 664e0f19 | bellard | } |
1113 | 664e0f19 | bellard | |
1114 | 664e0f19 | bellard | void OPPROTO op_ucomisd(void) |
1115 | 664e0f19 | bellard | { |
1116 | 43fb823b | bellard | int ret;
|
1117 | 8422b113 | bellard | float64 d0, d1; |
1118 | 664e0f19 | bellard | Reg *d, *s; |
1119 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
1120 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
1121 | 664e0f19 | bellard | |
1122 | 664e0f19 | bellard | d0 = d->XMM_D(0);
|
1123 | 664e0f19 | bellard | d1 = s->XMM_D(0);
|
1124 | 43fb823b | bellard | ret = float64_compare_quiet(d0, d1, &env->sse_status); |
1125 | 43fb823b | bellard | CC_SRC = comis_eflags[ret + 1];
|
1126 | 664e0f19 | bellard | FORCE_RET(); |
1127 | 664e0f19 | bellard | } |
1128 | 664e0f19 | bellard | |
1129 | 664e0f19 | bellard | void OPPROTO op_comisd(void) |
1130 | 664e0f19 | bellard | { |
1131 | 43fb823b | bellard | int ret;
|
1132 | 8422b113 | bellard | float64 d0, d1; |
1133 | 664e0f19 | bellard | Reg *d, *s; |
1134 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
1135 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
1136 | 664e0f19 | bellard | |
1137 | 664e0f19 | bellard | d0 = d->XMM_D(0);
|
1138 | 664e0f19 | bellard | d1 = s->XMM_D(0);
|
1139 | 43fb823b | bellard | ret = float64_compare(d0, d1, &env->sse_status); |
1140 | 43fb823b | bellard | CC_SRC = comis_eflags[ret + 1];
|
1141 | 664e0f19 | bellard | FORCE_RET(); |
1142 | 664e0f19 | bellard | } |
1143 | 664e0f19 | bellard | |
1144 | 664e0f19 | bellard | void OPPROTO op_movmskps(void) |
1145 | 664e0f19 | bellard | { |
1146 | 664e0f19 | bellard | int b0, b1, b2, b3;
|
1147 | 664e0f19 | bellard | Reg *s; |
1148 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM1);
|
1149 | 664e0f19 | bellard | b0 = s->XMM_L(0) >> 31; |
1150 | 664e0f19 | bellard | b1 = s->XMM_L(1) >> 31; |
1151 | 664e0f19 | bellard | b2 = s->XMM_L(2) >> 31; |
1152 | 664e0f19 | bellard | b3 = s->XMM_L(3) >> 31; |
1153 | 664e0f19 | bellard | T0 = b0 | (b1 << 1) | (b2 << 2) | (b3 << 3); |
1154 | 664e0f19 | bellard | } |
1155 | 664e0f19 | bellard | |
1156 | 664e0f19 | bellard | void OPPROTO op_movmskpd(void) |
1157 | 664e0f19 | bellard | { |
1158 | 664e0f19 | bellard | int b0, b1;
|
1159 | 664e0f19 | bellard | Reg *s; |
1160 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM1);
|
1161 | 664e0f19 | bellard | b0 = s->XMM_L(1) >> 31; |
1162 | 664e0f19 | bellard | b1 = s->XMM_L(3) >> 31; |
1163 | 664e0f19 | bellard | T0 = b0 | (b1 << 1);
|
1164 | 664e0f19 | bellard | } |
1165 | 664e0f19 | bellard | |
1166 | 664e0f19 | bellard | #endif
|
1167 | 664e0f19 | bellard | |
1168 | 664e0f19 | bellard | void OPPROTO glue(op_pmovmskb, SUFFIX)(void) |
1169 | 664e0f19 | bellard | { |
1170 | 664e0f19 | bellard | Reg *s; |
1171 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM1);
|
1172 | 664e0f19 | bellard | T0 = 0;
|
1173 | 664e0f19 | bellard | T0 |= (s->XMM_B(0) >> 7); |
1174 | 664e0f19 | bellard | T0 |= (s->XMM_B(1) >> 6) & 0x02; |
1175 | 664e0f19 | bellard | T0 |= (s->XMM_B(2) >> 5) & 0x04; |
1176 | 664e0f19 | bellard | T0 |= (s->XMM_B(3) >> 4) & 0x08; |
1177 | 664e0f19 | bellard | T0 |= (s->XMM_B(4) >> 3) & 0x10; |
1178 | 664e0f19 | bellard | T0 |= (s->XMM_B(5) >> 2) & 0x20; |
1179 | 664e0f19 | bellard | T0 |= (s->XMM_B(6) >> 1) & 0x40; |
1180 | 664e0f19 | bellard | T0 |= (s->XMM_B(7)) & 0x80; |
1181 | 664e0f19 | bellard | #if SHIFT == 1 |
1182 | 664e0f19 | bellard | T0 |= (s->XMM_B(8) << 1) & 0x0100; |
1183 | 664e0f19 | bellard | T0 |= (s->XMM_B(9) << 2) & 0x0200; |
1184 | 664e0f19 | bellard | T0 |= (s->XMM_B(10) << 3) & 0x0400; |
1185 | 664e0f19 | bellard | T0 |= (s->XMM_B(11) << 4) & 0x0800; |
1186 | 664e0f19 | bellard | T0 |= (s->XMM_B(12) << 5) & 0x1000; |
1187 | 664e0f19 | bellard | T0 |= (s->XMM_B(13) << 6) & 0x2000; |
1188 | 664e0f19 | bellard | T0 |= (s->XMM_B(14) << 7) & 0x4000; |
1189 | 664e0f19 | bellard | T0 |= (s->XMM_B(15) << 8) & 0x8000; |
1190 | 664e0f19 | bellard | #endif
|
1191 | 664e0f19 | bellard | } |
1192 | 664e0f19 | bellard | |
1193 | 664e0f19 | bellard | void OPPROTO glue(op_pinsrw, SUFFIX) (void) |
1194 | 664e0f19 | bellard | { |
1195 | 664e0f19 | bellard | Reg *d = (Reg *)((char *)env + PARAM1);
|
1196 | 664e0f19 | bellard | int pos = PARAM2;
|
1197 | 664e0f19 | bellard | |
1198 | 664e0f19 | bellard | d->W(pos) = T0; |
1199 | 664e0f19 | bellard | } |
1200 | 664e0f19 | bellard | |
1201 | 664e0f19 | bellard | void OPPROTO glue(op_pextrw, SUFFIX) (void) |
1202 | 664e0f19 | bellard | { |
1203 | 664e0f19 | bellard | Reg *s = (Reg *)((char *)env + PARAM1);
|
1204 | 664e0f19 | bellard | int pos = PARAM2;
|
1205 | 664e0f19 | bellard | |
1206 | 664e0f19 | bellard | T0 = s->W(pos); |
1207 | 664e0f19 | bellard | } |
1208 | 664e0f19 | bellard | |
1209 | 664e0f19 | bellard | void OPPROTO glue(op_packsswb, SUFFIX) (void) |
1210 | 664e0f19 | bellard | { |
1211 | 664e0f19 | bellard | Reg r, *d, *s; |
1212 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
1213 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
1214 | 664e0f19 | bellard | |
1215 | 664e0f19 | bellard | r.B(0) = satsb((int16_t)d->W(0)); |
1216 | 664e0f19 | bellard | r.B(1) = satsb((int16_t)d->W(1)); |
1217 | 664e0f19 | bellard | r.B(2) = satsb((int16_t)d->W(2)); |
1218 | 664e0f19 | bellard | r.B(3) = satsb((int16_t)d->W(3)); |
1219 | 664e0f19 | bellard | #if SHIFT == 1 |
1220 | 664e0f19 | bellard | r.B(4) = satsb((int16_t)d->W(4)); |
1221 | 664e0f19 | bellard | r.B(5) = satsb((int16_t)d->W(5)); |
1222 | 664e0f19 | bellard | r.B(6) = satsb((int16_t)d->W(6)); |
1223 | 664e0f19 | bellard | r.B(7) = satsb((int16_t)d->W(7)); |
1224 | 664e0f19 | bellard | #endif
|
1225 | 664e0f19 | bellard | r.B((4 << SHIFT) + 0) = satsb((int16_t)s->W(0)); |
1226 | 664e0f19 | bellard | r.B((4 << SHIFT) + 1) = satsb((int16_t)s->W(1)); |
1227 | 664e0f19 | bellard | r.B((4 << SHIFT) + 2) = satsb((int16_t)s->W(2)); |
1228 | 664e0f19 | bellard | r.B((4 << SHIFT) + 3) = satsb((int16_t)s->W(3)); |
1229 | 664e0f19 | bellard | #if SHIFT == 1 |
1230 | 664e0f19 | bellard | r.B(12) = satsb((int16_t)s->W(4)); |
1231 | 664e0f19 | bellard | r.B(13) = satsb((int16_t)s->W(5)); |
1232 | 664e0f19 | bellard | r.B(14) = satsb((int16_t)s->W(6)); |
1233 | 664e0f19 | bellard | r.B(15) = satsb((int16_t)s->W(7)); |
1234 | 664e0f19 | bellard | #endif
|
1235 | 664e0f19 | bellard | *d = r; |
1236 | 664e0f19 | bellard | } |
1237 | 664e0f19 | bellard | |
1238 | 664e0f19 | bellard | void OPPROTO glue(op_packuswb, SUFFIX) (void) |
1239 | 664e0f19 | bellard | { |
1240 | 664e0f19 | bellard | Reg r, *d, *s; |
1241 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
1242 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
1243 | 664e0f19 | bellard | |
1244 | 664e0f19 | bellard | r.B(0) = satub((int16_t)d->W(0)); |
1245 | 664e0f19 | bellard | r.B(1) = satub((int16_t)d->W(1)); |
1246 | 664e0f19 | bellard | r.B(2) = satub((int16_t)d->W(2)); |
1247 | 664e0f19 | bellard | r.B(3) = satub((int16_t)d->W(3)); |
1248 | 664e0f19 | bellard | #if SHIFT == 1 |
1249 | 664e0f19 | bellard | r.B(4) = satub((int16_t)d->W(4)); |
1250 | 664e0f19 | bellard | r.B(5) = satub((int16_t)d->W(5)); |
1251 | 664e0f19 | bellard | r.B(6) = satub((int16_t)d->W(6)); |
1252 | 664e0f19 | bellard | r.B(7) = satub((int16_t)d->W(7)); |
1253 | 664e0f19 | bellard | #endif
|
1254 | 664e0f19 | bellard | r.B((4 << SHIFT) + 0) = satub((int16_t)s->W(0)); |
1255 | 664e0f19 | bellard | r.B((4 << SHIFT) + 1) = satub((int16_t)s->W(1)); |
1256 | 664e0f19 | bellard | r.B((4 << SHIFT) + 2) = satub((int16_t)s->W(2)); |
1257 | 664e0f19 | bellard | r.B((4 << SHIFT) + 3) = satub((int16_t)s->W(3)); |
1258 | 664e0f19 | bellard | #if SHIFT == 1 |
1259 | 664e0f19 | bellard | r.B(12) = satub((int16_t)s->W(4)); |
1260 | 664e0f19 | bellard | r.B(13) = satub((int16_t)s->W(5)); |
1261 | 664e0f19 | bellard | r.B(14) = satub((int16_t)s->W(6)); |
1262 | 664e0f19 | bellard | r.B(15) = satub((int16_t)s->W(7)); |
1263 | 664e0f19 | bellard | #endif
|
1264 | 664e0f19 | bellard | *d = r; |
1265 | 664e0f19 | bellard | } |
1266 | 664e0f19 | bellard | |
1267 | 664e0f19 | bellard | void OPPROTO glue(op_packssdw, SUFFIX) (void) |
1268 | 664e0f19 | bellard | { |
1269 | 664e0f19 | bellard | Reg r, *d, *s; |
1270 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1);
|
1271 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2);
|
1272 | 664e0f19 | bellard | |
1273 | 664e0f19 | bellard | r.W(0) = satsw(d->L(0)); |
1274 | 664e0f19 | bellard | r.W(1) = satsw(d->L(1)); |
1275 | 664e0f19 | bellard | #if SHIFT == 1 |
1276 | 664e0f19 | bellard | r.W(2) = satsw(d->L(2)); |
1277 | 664e0f19 | bellard | r.W(3) = satsw(d->L(3)); |
1278 | 664e0f19 | bellard | #endif
|
1279 | 664e0f19 | bellard | r.W((2 << SHIFT) + 0) = satsw(s->L(0)); |
1280 | 664e0f19 | bellard | r.W((2 << SHIFT) + 1) = satsw(s->L(1)); |
1281 | 664e0f19 | bellard | #if SHIFT == 1 |
1282 | 664e0f19 | bellard | r.W(6) = satsw(s->L(2)); |
1283 | 664e0f19 | bellard | r.W(7) = satsw(s->L(3)); |
1284 | 664e0f19 | bellard | #endif
|
1285 | 664e0f19 | bellard | *d = r; |
1286 | 664e0f19 | bellard | } |
1287 | 664e0f19 | bellard | |
1288 | 664e0f19 | bellard | #define UNPCK_OP(base_name, base) \
|
1289 | 664e0f19 | bellard | \ |
1290 | 664e0f19 | bellard | void OPPROTO glue(op_punpck ## base_name ## bw, SUFFIX) (void) \ |
1291 | 664e0f19 | bellard | { \ |
1292 | 664e0f19 | bellard | Reg r, *d, *s; \ |
1293 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1); \
|
1294 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2); \
|
1295 | 664e0f19 | bellard | \ |
1296 | 664e0f19 | bellard | r.B(0) = d->B((base << (SHIFT + 2)) + 0); \ |
1297 | 664e0f19 | bellard | r.B(1) = s->B((base << (SHIFT + 2)) + 0); \ |
1298 | 664e0f19 | bellard | r.B(2) = d->B((base << (SHIFT + 2)) + 1); \ |
1299 | 664e0f19 | bellard | r.B(3) = s->B((base << (SHIFT + 2)) + 1); \ |
1300 | 664e0f19 | bellard | r.B(4) = d->B((base << (SHIFT + 2)) + 2); \ |
1301 | 664e0f19 | bellard | r.B(5) = s->B((base << (SHIFT + 2)) + 2); \ |
1302 | 664e0f19 | bellard | r.B(6) = d->B((base << (SHIFT + 2)) + 3); \ |
1303 | 664e0f19 | bellard | r.B(7) = s->B((base << (SHIFT + 2)) + 3); \ |
1304 | 664e0f19 | bellard | XMM_ONLY( \ |
1305 | 664e0f19 | bellard | r.B(8) = d->B((base << (SHIFT + 2)) + 4); \ |
1306 | 664e0f19 | bellard | r.B(9) = s->B((base << (SHIFT + 2)) + 4); \ |
1307 | 664e0f19 | bellard | r.B(10) = d->B((base << (SHIFT + 2)) + 5); \ |
1308 | 664e0f19 | bellard | r.B(11) = s->B((base << (SHIFT + 2)) + 5); \ |
1309 | 664e0f19 | bellard | r.B(12) = d->B((base << (SHIFT + 2)) + 6); \ |
1310 | 664e0f19 | bellard | r.B(13) = s->B((base << (SHIFT + 2)) + 6); \ |
1311 | 664e0f19 | bellard | r.B(14) = d->B((base << (SHIFT + 2)) + 7); \ |
1312 | 664e0f19 | bellard | r.B(15) = s->B((base << (SHIFT + 2)) + 7); \ |
1313 | 664e0f19 | bellard | ) \ |
1314 | 664e0f19 | bellard | *d = r; \ |
1315 | 664e0f19 | bellard | } \ |
1316 | 664e0f19 | bellard | \ |
1317 | 664e0f19 | bellard | void OPPROTO glue(op_punpck ## base_name ## wd, SUFFIX) (void) \ |
1318 | 664e0f19 | bellard | { \ |
1319 | 664e0f19 | bellard | Reg r, *d, *s; \ |
1320 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1); \
|
1321 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2); \
|
1322 | 664e0f19 | bellard | \ |
1323 | 664e0f19 | bellard | r.W(0) = d->W((base << (SHIFT + 1)) + 0); \ |
1324 | 664e0f19 | bellard | r.W(1) = s->W((base << (SHIFT + 1)) + 0); \ |
1325 | 664e0f19 | bellard | r.W(2) = d->W((base << (SHIFT + 1)) + 1); \ |
1326 | 664e0f19 | bellard | r.W(3) = s->W((base << (SHIFT + 1)) + 1); \ |
1327 | 664e0f19 | bellard | XMM_ONLY( \ |
1328 | 664e0f19 | bellard | r.W(4) = d->W((base << (SHIFT + 1)) + 2); \ |
1329 | 664e0f19 | bellard | r.W(5) = s->W((base << (SHIFT + 1)) + 2); \ |
1330 | 664e0f19 | bellard | r.W(6) = d->W((base << (SHIFT + 1)) + 3); \ |
1331 | 664e0f19 | bellard | r.W(7) = s->W((base << (SHIFT + 1)) + 3); \ |
1332 | 664e0f19 | bellard | ) \ |
1333 | 664e0f19 | bellard | *d = r; \ |
1334 | 664e0f19 | bellard | } \ |
1335 | 664e0f19 | bellard | \ |
1336 | 664e0f19 | bellard | void OPPROTO glue(op_punpck ## base_name ## dq, SUFFIX) (void) \ |
1337 | 664e0f19 | bellard | { \ |
1338 | 664e0f19 | bellard | Reg r, *d, *s; \ |
1339 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1); \
|
1340 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2); \
|
1341 | 664e0f19 | bellard | \ |
1342 | 664e0f19 | bellard | r.L(0) = d->L((base << SHIFT) + 0); \ |
1343 | 664e0f19 | bellard | r.L(1) = s->L((base << SHIFT) + 0); \ |
1344 | 664e0f19 | bellard | XMM_ONLY( \ |
1345 | 664e0f19 | bellard | r.L(2) = d->L((base << SHIFT) + 1); \ |
1346 | 664e0f19 | bellard | r.L(3) = s->L((base << SHIFT) + 1); \ |
1347 | 664e0f19 | bellard | ) \ |
1348 | 664e0f19 | bellard | *d = r; \ |
1349 | 664e0f19 | bellard | } \ |
1350 | 664e0f19 | bellard | \ |
1351 | 664e0f19 | bellard | XMM_ONLY( \ |
1352 | 664e0f19 | bellard | void OPPROTO glue(op_punpck ## base_name ## qdq, SUFFIX) (void) \ |
1353 | 664e0f19 | bellard | { \ |
1354 | 664e0f19 | bellard | Reg r, *d, *s; \ |
1355 | 664e0f19 | bellard | d = (Reg *)((char *)env + PARAM1); \
|
1356 | 664e0f19 | bellard | s = (Reg *)((char *)env + PARAM2); \
|
1357 | 664e0f19 | bellard | \ |
1358 | 664e0f19 | bellard | r.Q(0) = d->Q(base); \
|
1359 | 664e0f19 | bellard | r.Q(1) = s->Q(base); \
|
1360 | 664e0f19 | bellard | *d = r; \ |
1361 | 664e0f19 | bellard | } \ |
1362 | 664e0f19 | bellard | ) |
1363 | 664e0f19 | bellard | |
1364 | 664e0f19 | bellard | UNPCK_OP(l, 0)
|
1365 | 664e0f19 | bellard | UNPCK_OP(h, 1)
|
1366 | 664e0f19 | bellard | |
1367 | 664e0f19 | bellard | #undef SHIFT
|
1368 | 664e0f19 | bellard | #undef XMM_ONLY
|
1369 | 664e0f19 | bellard | #undef Reg
|
1370 | 664e0f19 | bellard | #undef B
|
1371 | 664e0f19 | bellard | #undef W
|
1372 | 664e0f19 | bellard | #undef L
|
1373 | 664e0f19 | bellard | #undef Q
|
1374 | 664e0f19 | bellard | #undef SUFFIX |