VirtualBox

source: vbox/trunk/src/recompiler/target-i386/ops_sse_header.h@ 43902

最後變更 在這個檔案從43902是 37689,由 vboxsync 提交於 13 年 前

recompiler: Merged in changes from 0.13.0.

  • 屬性 svn:eol-style 設為 native
檔案大小: 12.2 KB
 
1/*
2 * MMX/3DNow!/SSE/SSE2/SSE3/SSSE3/SSE4/PNI support
3 *
4 * Copyright (c) 2005 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
22 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
23 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
24 * a choice of LGPL license versions is made available with the language indicating
25 * that LGPLv2 or any later version may be used, or where a choice of which version
26 * of the LGPL is applied is otherwise unspecified.
27 */
28
29#if SHIFT == 0
30#define Reg MMXReg
31#define SUFFIX _mmx
32#else
33#define Reg XMMReg
34#define SUFFIX _xmm
35#endif
36
37#define dh_alias_Reg ptr
38#define dh_alias_XMMReg ptr
39#define dh_alias_MMXReg ptr
40#define dh_ctype_Reg Reg *
41#define dh_ctype_XMMReg XMMReg *
42#define dh_ctype_MMXReg MMXReg *
43#define dh_is_signed_Reg dh_is_signed_ptr
44#define dh_is_signed_XMMReg dh_is_signed_ptr
45#define dh_is_signed_MMXReg dh_is_signed_ptr
46
47DEF_HELPER_2(glue(psrlw, SUFFIX), void, Reg, Reg)
48DEF_HELPER_2(glue(psraw, SUFFIX), void, Reg, Reg)
49DEF_HELPER_2(glue(psllw, SUFFIX), void, Reg, Reg)
50DEF_HELPER_2(glue(psrld, SUFFIX), void, Reg, Reg)
51DEF_HELPER_2(glue(psrad, SUFFIX), void, Reg, Reg)
52DEF_HELPER_2(glue(pslld, SUFFIX), void, Reg, Reg)
53DEF_HELPER_2(glue(psrlq, SUFFIX), void, Reg, Reg)
54DEF_HELPER_2(glue(psllq, SUFFIX), void, Reg, Reg)
55
56#if SHIFT == 1
57DEF_HELPER_2(glue(psrldq, SUFFIX), void, Reg, Reg)
58DEF_HELPER_2(glue(pslldq, SUFFIX), void, Reg, Reg)
59#endif
60
61#define SSE_HELPER_B(name, F)\
62 DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
63
64#define SSE_HELPER_W(name, F)\
65 DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
66
67#define SSE_HELPER_L(name, F)\
68 DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
69
70#define SSE_HELPER_Q(name, F)\
71 DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
72
73SSE_HELPER_B(paddb, FADD)
74SSE_HELPER_W(paddw, FADD)
75SSE_HELPER_L(paddl, FADD)
76SSE_HELPER_Q(paddq, FADD)
77
78SSE_HELPER_B(psubb, FSUB)
79SSE_HELPER_W(psubw, FSUB)
80SSE_HELPER_L(psubl, FSUB)
81SSE_HELPER_Q(psubq, FSUB)
82
83SSE_HELPER_B(paddusb, FADDUB)
84SSE_HELPER_B(paddsb, FADDSB)
85SSE_HELPER_B(psubusb, FSUBUB)
86SSE_HELPER_B(psubsb, FSUBSB)
87
88SSE_HELPER_W(paddusw, FADDUW)
89SSE_HELPER_W(paddsw, FADDSW)
90SSE_HELPER_W(psubusw, FSUBUW)
91SSE_HELPER_W(psubsw, FSUBSW)
92
93SSE_HELPER_B(pminub, FMINUB)
94SSE_HELPER_B(pmaxub, FMAXUB)
95
96SSE_HELPER_W(pminsw, FMINSW)
97SSE_HELPER_W(pmaxsw, FMAXSW)
98
99SSE_HELPER_Q(pand, FAND)
100SSE_HELPER_Q(pandn, FANDN)
101SSE_HELPER_Q(por, FOR)
102SSE_HELPER_Q(pxor, FXOR)
103
104SSE_HELPER_B(pcmpgtb, FCMPGTB)
105SSE_HELPER_W(pcmpgtw, FCMPGTW)
106SSE_HELPER_L(pcmpgtl, FCMPGTL)
107
108SSE_HELPER_B(pcmpeqb, FCMPEQ)
109SSE_HELPER_W(pcmpeqw, FCMPEQ)
110SSE_HELPER_L(pcmpeql, FCMPEQ)
111
112SSE_HELPER_W(pmullw, FMULLW)
113#if SHIFT == 0
114SSE_HELPER_W(pmulhrw, FMULHRW)
115#endif
116SSE_HELPER_W(pmulhuw, FMULHUW)
117SSE_HELPER_W(pmulhw, FMULHW)
118
119SSE_HELPER_B(pavgb, FAVG)
120SSE_HELPER_W(pavgw, FAVG)
121
122DEF_HELPER_2(glue(pmuludq, SUFFIX), void, Reg, Reg)
123DEF_HELPER_2(glue(pmaddwd, SUFFIX), void, Reg, Reg)
124
125DEF_HELPER_2(glue(psadbw, SUFFIX), void, Reg, Reg)
126DEF_HELPER_3(glue(maskmov, SUFFIX), void, Reg, Reg, tl)
127DEF_HELPER_2(glue(movl_mm_T0, SUFFIX), void, Reg, i32)
128#ifdef TARGET_X86_64
129DEF_HELPER_2(glue(movq_mm_T0, SUFFIX), void, Reg, i64)
130#endif
131
132#if SHIFT == 0
133DEF_HELPER_3(glue(pshufw, SUFFIX), void, Reg, Reg, int)
134#else
135DEF_HELPER_3(shufps, void, Reg, Reg, int)
136DEF_HELPER_3(shufpd, void, Reg, Reg, int)
137DEF_HELPER_3(glue(pshufd, SUFFIX), void, Reg, Reg, int)
138DEF_HELPER_3(glue(pshuflw, SUFFIX), void, Reg, Reg, int)
139DEF_HELPER_3(glue(pshufhw, SUFFIX), void, Reg, Reg, int)
140#endif
141
142#if SHIFT == 1
143/* FPU ops */
144/* XXX: not accurate */
145
146#define SSE_HELPER_S(name, F)\
147 DEF_HELPER_2(name ## ps , void, Reg, Reg) \
148 DEF_HELPER_2(name ## ss , void, Reg, Reg) \
149 DEF_HELPER_2(name ## pd , void, Reg, Reg) \
150 DEF_HELPER_2(name ## sd , void, Reg, Reg)
151
152SSE_HELPER_S(add, FPU_ADD)
153SSE_HELPER_S(sub, FPU_SUB)
154SSE_HELPER_S(mul, FPU_MUL)
155SSE_HELPER_S(div, FPU_DIV)
156SSE_HELPER_S(min, FPU_MIN)
157SSE_HELPER_S(max, FPU_MAX)
158SSE_HELPER_S(sqrt, FPU_SQRT)
159
160
161DEF_HELPER_2(cvtps2pd, void, Reg, Reg)
162DEF_HELPER_2(cvtpd2ps, void, Reg, Reg)
163DEF_HELPER_2(cvtss2sd, void, Reg, Reg)
164DEF_HELPER_2(cvtsd2ss, void, Reg, Reg)
165DEF_HELPER_2(cvtdq2ps, void, Reg, Reg)
166DEF_HELPER_2(cvtdq2pd, void, Reg, Reg)
167DEF_HELPER_2(cvtpi2ps, void, XMMReg, MMXReg)
168DEF_HELPER_2(cvtpi2pd, void, XMMReg, MMXReg)
169DEF_HELPER_2(cvtsi2ss, void, XMMReg, i32)
170DEF_HELPER_2(cvtsi2sd, void, XMMReg, i32)
171
172#ifdef TARGET_X86_64
173DEF_HELPER_2(cvtsq2ss, void, XMMReg, i64)
174DEF_HELPER_2(cvtsq2sd, void, XMMReg, i64)
175#endif
176
177DEF_HELPER_2(cvtps2dq, void, XMMReg, XMMReg)
178DEF_HELPER_2(cvtpd2dq, void, XMMReg, XMMReg)
179DEF_HELPER_2(cvtps2pi, void, MMXReg, XMMReg)
180DEF_HELPER_2(cvtpd2pi, void, MMXReg, XMMReg)
181DEF_HELPER_1(cvtss2si, s32, XMMReg)
182DEF_HELPER_1(cvtsd2si, s32, XMMReg)
183#ifdef TARGET_X86_64
184DEF_HELPER_1(cvtss2sq, s64, XMMReg)
185DEF_HELPER_1(cvtsd2sq, s64, XMMReg)
186#endif
187
188DEF_HELPER_2(cvttps2dq, void, XMMReg, XMMReg)
189DEF_HELPER_2(cvttpd2dq, void, XMMReg, XMMReg)
190DEF_HELPER_2(cvttps2pi, void, MMXReg, XMMReg)
191DEF_HELPER_2(cvttpd2pi, void, MMXReg, XMMReg)
192DEF_HELPER_1(cvttss2si, s32, XMMReg)
193DEF_HELPER_1(cvttsd2si, s32, XMMReg)
194#ifdef TARGET_X86_64
195DEF_HELPER_1(cvttss2sq, s64, XMMReg)
196DEF_HELPER_1(cvttsd2sq, s64, XMMReg)
197#endif
198
199DEF_HELPER_2(rsqrtps, void, XMMReg, XMMReg)
200DEF_HELPER_2(rsqrtss, void, XMMReg, XMMReg)
201DEF_HELPER_2(rcpps, void, XMMReg, XMMReg)
202DEF_HELPER_2(rcpss, void, XMMReg, XMMReg)
203DEF_HELPER_2(extrq_r, void, XMMReg, XMMReg)
204DEF_HELPER_3(extrq_i, void, XMMReg, int, int)
205DEF_HELPER_2(insertq_r, void, XMMReg, XMMReg)
206DEF_HELPER_3(insertq_i, void, XMMReg, int, int)
207DEF_HELPER_2(haddps, void, XMMReg, XMMReg)
208DEF_HELPER_2(haddpd, void, XMMReg, XMMReg)
209DEF_HELPER_2(hsubps, void, XMMReg, XMMReg)
210DEF_HELPER_2(hsubpd, void, XMMReg, XMMReg)
211DEF_HELPER_2(addsubps, void, XMMReg, XMMReg)
212DEF_HELPER_2(addsubpd, void, XMMReg, XMMReg)
213
214#define SSE_HELPER_CMP(name, F)\
215 DEF_HELPER_2( name ## ps , void, Reg, Reg) \
216 DEF_HELPER_2( name ## ss , void, Reg, Reg) \
217 DEF_HELPER_2( name ## pd , void, Reg, Reg) \
218 DEF_HELPER_2( name ## sd , void, Reg, Reg)
219
220SSE_HELPER_CMP(cmpeq, FPU_CMPEQ)
221SSE_HELPER_CMP(cmplt, FPU_CMPLT)
222SSE_HELPER_CMP(cmple, FPU_CMPLE)
223SSE_HELPER_CMP(cmpunord, FPU_CMPUNORD)
224SSE_HELPER_CMP(cmpneq, FPU_CMPNEQ)
225SSE_HELPER_CMP(cmpnlt, FPU_CMPNLT)
226SSE_HELPER_CMP(cmpnle, FPU_CMPNLE)
227SSE_HELPER_CMP(cmpord, FPU_CMPORD)
228
229DEF_HELPER_2(ucomiss, void, Reg, Reg)
230DEF_HELPER_2(comiss, void, Reg, Reg)
231DEF_HELPER_2(ucomisd, void, Reg, Reg)
232DEF_HELPER_2(comisd, void, Reg, Reg)
233DEF_HELPER_1(movmskps, i32, Reg)
234DEF_HELPER_1(movmskpd, i32, Reg)
235#endif
236
237DEF_HELPER_1(glue(pmovmskb, SUFFIX), i32, Reg)
238DEF_HELPER_2(glue(packsswb, SUFFIX), void, Reg, Reg)
239DEF_HELPER_2(glue(packuswb, SUFFIX), void, Reg, Reg)
240DEF_HELPER_2(glue(packssdw, SUFFIX), void, Reg, Reg)
241#define UNPCK_OP(base_name, base) \
242 DEF_HELPER_2(glue(punpck ## base_name ## bw, SUFFIX) , void, Reg, Reg) \
243 DEF_HELPER_2(glue(punpck ## base_name ## wd, SUFFIX) , void, Reg, Reg) \
244 DEF_HELPER_2(glue(punpck ## base_name ## dq, SUFFIX) , void, Reg, Reg)
245
246UNPCK_OP(l, 0)
247UNPCK_OP(h, 1)
248
249#if SHIFT == 1
250DEF_HELPER_2(glue(punpcklqdq, SUFFIX), void, Reg, Reg)
251DEF_HELPER_2(glue(punpckhqdq, SUFFIX), void, Reg, Reg)
252#endif
253
254/* 3DNow! float ops */
255#if SHIFT == 0
256DEF_HELPER_2(pi2fd, void, MMXReg, MMXReg)
257DEF_HELPER_2(pi2fw, void, MMXReg, MMXReg)
258DEF_HELPER_2(pf2id, void, MMXReg, MMXReg)
259DEF_HELPER_2(pf2iw, void, MMXReg, MMXReg)
260DEF_HELPER_2(pfacc, void, MMXReg, MMXReg)
261DEF_HELPER_2(pfadd, void, MMXReg, MMXReg)
262DEF_HELPER_2(pfcmpeq, void, MMXReg, MMXReg)
263DEF_HELPER_2(pfcmpge, void, MMXReg, MMXReg)
264DEF_HELPER_2(pfcmpgt, void, MMXReg, MMXReg)
265DEF_HELPER_2(pfmax, void, MMXReg, MMXReg)
266DEF_HELPER_2(pfmin, void, MMXReg, MMXReg)
267DEF_HELPER_2(pfmul, void, MMXReg, MMXReg)
268DEF_HELPER_2(pfnacc, void, MMXReg, MMXReg)
269DEF_HELPER_2(pfpnacc, void, MMXReg, MMXReg)
270DEF_HELPER_2(pfrcp, void, MMXReg, MMXReg)
271DEF_HELPER_2(pfrsqrt, void, MMXReg, MMXReg)
272DEF_HELPER_2(pfsub, void, MMXReg, MMXReg)
273DEF_HELPER_2(pfsubr, void, MMXReg, MMXReg)
274DEF_HELPER_2(pswapd, void, MMXReg, MMXReg)
275#endif
276
277/* SSSE3 op helpers */
278DEF_HELPER_2(glue(phaddw, SUFFIX), void, Reg, Reg)
279DEF_HELPER_2(glue(phaddd, SUFFIX), void, Reg, Reg)
280DEF_HELPER_2(glue(phaddsw, SUFFIX), void, Reg, Reg)
281DEF_HELPER_2(glue(phsubw, SUFFIX), void, Reg, Reg)
282DEF_HELPER_2(glue(phsubd, SUFFIX), void, Reg, Reg)
283DEF_HELPER_2(glue(phsubsw, SUFFIX), void, Reg, Reg)
284DEF_HELPER_2(glue(pabsb, SUFFIX), void, Reg, Reg)
285DEF_HELPER_2(glue(pabsw, SUFFIX), void, Reg, Reg)
286DEF_HELPER_2(glue(pabsd, SUFFIX), void, Reg, Reg)
287DEF_HELPER_2(glue(pmaddubsw, SUFFIX), void, Reg, Reg)
288DEF_HELPER_2(glue(pmulhrsw, SUFFIX), void, Reg, Reg)
289DEF_HELPER_2(glue(pshufb, SUFFIX), void, Reg, Reg)
290DEF_HELPER_2(glue(psignb, SUFFIX), void, Reg, Reg)
291DEF_HELPER_2(glue(psignw, SUFFIX), void, Reg, Reg)
292DEF_HELPER_2(glue(psignd, SUFFIX), void, Reg, Reg)
293DEF_HELPER_3(glue(palignr, SUFFIX), void, Reg, Reg, s32)
294
295/* SSE4.1 op helpers */
296#if SHIFT == 1
297DEF_HELPER_2(glue(pblendvb, SUFFIX), void, Reg, Reg)
298DEF_HELPER_2(glue(blendvps, SUFFIX), void, Reg, Reg)
299DEF_HELPER_2(glue(blendvpd, SUFFIX), void, Reg, Reg)
300DEF_HELPER_2(glue(ptest, SUFFIX), void, Reg, Reg)
301DEF_HELPER_2(glue(pmovsxbw, SUFFIX), void, Reg, Reg)
302DEF_HELPER_2(glue(pmovsxbd, SUFFIX), void, Reg, Reg)
303DEF_HELPER_2(glue(pmovsxbq, SUFFIX), void, Reg, Reg)
304DEF_HELPER_2(glue(pmovsxwd, SUFFIX), void, Reg, Reg)
305DEF_HELPER_2(glue(pmovsxwq, SUFFIX), void, Reg, Reg)
306DEF_HELPER_2(glue(pmovsxdq, SUFFIX), void, Reg, Reg)
307DEF_HELPER_2(glue(pmovzxbw, SUFFIX), void, Reg, Reg)
308DEF_HELPER_2(glue(pmovzxbd, SUFFIX), void, Reg, Reg)
309DEF_HELPER_2(glue(pmovzxbq, SUFFIX), void, Reg, Reg)
310DEF_HELPER_2(glue(pmovzxwd, SUFFIX), void, Reg, Reg)
311DEF_HELPER_2(glue(pmovzxwq, SUFFIX), void, Reg, Reg)
312DEF_HELPER_2(glue(pmovzxdq, SUFFIX), void, Reg, Reg)
313DEF_HELPER_2(glue(pmuldq, SUFFIX), void, Reg, Reg)
314DEF_HELPER_2(glue(pcmpeqq, SUFFIX), void, Reg, Reg)
315DEF_HELPER_2(glue(packusdw, SUFFIX), void, Reg, Reg)
316DEF_HELPER_2(glue(pminsb, SUFFIX), void, Reg, Reg)
317DEF_HELPER_2(glue(pminsd, SUFFIX), void, Reg, Reg)
318DEF_HELPER_2(glue(pminuw, SUFFIX), void, Reg, Reg)
319DEF_HELPER_2(glue(pminud, SUFFIX), void, Reg, Reg)
320DEF_HELPER_2(glue(pmaxsb, SUFFIX), void, Reg, Reg)
321DEF_HELPER_2(glue(pmaxsd, SUFFIX), void, Reg, Reg)
322DEF_HELPER_2(glue(pmaxuw, SUFFIX), void, Reg, Reg)
323DEF_HELPER_2(glue(pmaxud, SUFFIX), void, Reg, Reg)
324DEF_HELPER_2(glue(pmulld, SUFFIX), void, Reg, Reg)
325DEF_HELPER_2(glue(phminposuw, SUFFIX), void, Reg, Reg)
326DEF_HELPER_3(glue(roundps, SUFFIX), void, Reg, Reg, i32)
327DEF_HELPER_3(glue(roundpd, SUFFIX), void, Reg, Reg, i32)
328DEF_HELPER_3(glue(roundss, SUFFIX), void, Reg, Reg, i32)
329DEF_HELPER_3(glue(roundsd, SUFFIX), void, Reg, Reg, i32)
330DEF_HELPER_3(glue(blendps, SUFFIX), void, Reg, Reg, i32)
331DEF_HELPER_3(glue(blendpd, SUFFIX), void, Reg, Reg, i32)
332DEF_HELPER_3(glue(pblendw, SUFFIX), void, Reg, Reg, i32)
333DEF_HELPER_3(glue(dpps, SUFFIX), void, Reg, Reg, i32)
334DEF_HELPER_3(glue(dppd, SUFFIX), void, Reg, Reg, i32)
335DEF_HELPER_3(glue(mpsadbw, SUFFIX), void, Reg, Reg, i32)
336#endif
337
338/* SSE4.2 op helpers */
339#if SHIFT == 1
340DEF_HELPER_2(glue(pcmpgtq, SUFFIX), void, Reg, Reg)
341DEF_HELPER_3(glue(pcmpestri, SUFFIX), void, Reg, Reg, i32)
342DEF_HELPER_3(glue(pcmpestrm, SUFFIX), void, Reg, Reg, i32)
343DEF_HELPER_3(glue(pcmpistri, SUFFIX), void, Reg, Reg, i32)
344DEF_HELPER_3(glue(pcmpistrm, SUFFIX), void, Reg, Reg, i32)
345DEF_HELPER_3(crc32, tl, i32, tl, i32)
346DEF_HELPER_2(popcnt, tl, tl, i32)
347#endif
348
349#undef SHIFT
350#undef Reg
351#undef SUFFIX
352
353#undef SSE_HELPER_B
354#undef SSE_HELPER_W
355#undef SSE_HELPER_L
356#undef SSE_HELPER_Q
357#undef SSE_HELPER_S
358#undef SSE_HELPER_CMP
359#undef UNPCK_OP
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette