VirtualBox

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

最後變更 在這個檔案從33656是 33656,由 vboxsync 提交於 14 年 前

*: rebrand Sun (L)GPL disclaimers

  • 屬性 svn:eol-style 設為 native
檔案大小: 14.5 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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * Oracle 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, Oracle 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#define SUFFIX _mmx
33#else
34#define Reg XMMReg
35#define SUFFIX _xmm
36#endif
37
38DEF_HELPER(void, glue(helper_psrlw, SUFFIX), (Reg *d, Reg *s))
39DEF_HELPER(void, glue(helper_psraw, SUFFIX), (Reg *d, Reg *s))
40DEF_HELPER(void, glue(helper_psllw, SUFFIX), (Reg *d, Reg *s))
41DEF_HELPER(void, glue(helper_psrld, SUFFIX), (Reg *d, Reg *s))
42DEF_HELPER(void, glue(helper_psrad, SUFFIX), (Reg *d, Reg *s))
43DEF_HELPER(void, glue(helper_pslld, SUFFIX), (Reg *d, Reg *s))
44DEF_HELPER(void, glue(helper_psrlq, SUFFIX), (Reg *d, Reg *s))
45DEF_HELPER(void, glue(helper_psllq, SUFFIX), (Reg *d, Reg *s))
46
47#if SHIFT == 1
48DEF_HELPER(void, glue(helper_psrldq, SUFFIX), (Reg *d, Reg *s))
49DEF_HELPER(void, glue(helper_pslldq, SUFFIX), (Reg *d, Reg *s))
50#endif
51
52#define SSE_HELPER_B(name, F)\
53 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
54
55#define SSE_HELPER_W(name, F)\
56 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
57
58#define SSE_HELPER_L(name, F)\
59 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
60
61#define SSE_HELPER_Q(name, F)\
62 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
63
64SSE_HELPER_B(helper_paddb, FADD)
65SSE_HELPER_W(helper_paddw, FADD)
66SSE_HELPER_L(helper_paddl, FADD)
67SSE_HELPER_Q(helper_paddq, FADD)
68
69SSE_HELPER_B(helper_psubb, FSUB)
70SSE_HELPER_W(helper_psubw, FSUB)
71SSE_HELPER_L(helper_psubl, FSUB)
72SSE_HELPER_Q(helper_psubq, FSUB)
73
74SSE_HELPER_B(helper_paddusb, FADDUB)
75SSE_HELPER_B(helper_paddsb, FADDSB)
76SSE_HELPER_B(helper_psubusb, FSUBUB)
77SSE_HELPER_B(helper_psubsb, FSUBSB)
78
79SSE_HELPER_W(helper_paddusw, FADDUW)
80SSE_HELPER_W(helper_paddsw, FADDSW)
81SSE_HELPER_W(helper_psubusw, FSUBUW)
82SSE_HELPER_W(helper_psubsw, FSUBSW)
83
84SSE_HELPER_B(helper_pminub, FMINUB)
85SSE_HELPER_B(helper_pmaxub, FMAXUB)
86
87SSE_HELPER_W(helper_pminsw, FMINSW)
88SSE_HELPER_W(helper_pmaxsw, FMAXSW)
89
90SSE_HELPER_Q(helper_pand, FAND)
91SSE_HELPER_Q(helper_pandn, FANDN)
92SSE_HELPER_Q(helper_por, FOR)
93SSE_HELPER_Q(helper_pxor, FXOR)
94
95SSE_HELPER_B(helper_pcmpgtb, FCMPGTB)
96SSE_HELPER_W(helper_pcmpgtw, FCMPGTW)
97SSE_HELPER_L(helper_pcmpgtl, FCMPGTL)
98
99SSE_HELPER_B(helper_pcmpeqb, FCMPEQ)
100SSE_HELPER_W(helper_pcmpeqw, FCMPEQ)
101SSE_HELPER_L(helper_pcmpeql, FCMPEQ)
102
103SSE_HELPER_W(helper_pmullw, FMULLW)
104#if SHIFT == 0
105SSE_HELPER_W(helper_pmulhrw, FMULHRW)
106#endif
107SSE_HELPER_W(helper_pmulhuw, FMULHUW)
108SSE_HELPER_W(helper_pmulhw, FMULHW)
109
110SSE_HELPER_B(helper_pavgb, FAVG)
111SSE_HELPER_W(helper_pavgw, FAVG)
112
113DEF_HELPER(void, glue(helper_pmuludq, SUFFIX) , (Reg *d, Reg *s))
114DEF_HELPER(void, glue(helper_pmaddwd, SUFFIX) , (Reg *d, Reg *s))
115
116DEF_HELPER(void, glue(helper_psadbw, SUFFIX) , (Reg *d, Reg *s))
117DEF_HELPER(void, glue(helper_maskmov, SUFFIX) , (Reg *d, Reg *s, target_ulong a0))
118DEF_HELPER(void, glue(helper_movl_mm_T0, SUFFIX) , (Reg *d, uint32_t val))
119#ifdef TARGET_X86_64
120DEF_HELPER(void, glue(helper_movq_mm_T0, SUFFIX) , (Reg *d, uint64_t val))
121#endif
122
123#if SHIFT == 0
124DEF_HELPER(void, glue(helper_pshufw, SUFFIX) , (Reg *d, Reg *s, int order))
125#else
126DEF_HELPER(void, helper_shufps, (Reg *d, Reg *s, int order))
127DEF_HELPER(void, helper_shufpd, (Reg *d, Reg *s, int order))
128DEF_HELPER(void, glue(helper_pshufd, SUFFIX) , (Reg *d, Reg *s, int order))
129DEF_HELPER(void, glue(helper_pshuflw, SUFFIX) , (Reg *d, Reg *s, int order))
130DEF_HELPER(void, glue(helper_pshufhw, SUFFIX) , (Reg *d, Reg *s, int order))
131#endif
132
133#if SHIFT == 1
134/* FPU ops */
135/* XXX: not accurate */
136
137#define SSE_HELPER_S(name, F)\
138 DEF_HELPER(void, helper_ ## name ## ps , (Reg *d, Reg *s)) \
139 DEF_HELPER(void, helper_ ## name ## ss , (Reg *d, Reg *s)) \
140 DEF_HELPER(void, helper_ ## name ## pd , (Reg *d, Reg *s)) \
141 DEF_HELPER(void, helper_ ## name ## sd , (Reg *d, Reg *s))
142
143SSE_HELPER_S(add, FPU_ADD)
144SSE_HELPER_S(sub, FPU_SUB)
145SSE_HELPER_S(mul, FPU_MUL)
146SSE_HELPER_S(div, FPU_DIV)
147SSE_HELPER_S(min, FPU_MIN)
148SSE_HELPER_S(max, FPU_MAX)
149SSE_HELPER_S(sqrt, FPU_SQRT)
150
151
152DEF_HELPER(void, helper_cvtps2pd, (Reg *d, Reg *s))
153DEF_HELPER(void, helper_cvtpd2ps, (Reg *d, Reg *s))
154DEF_HELPER(void, helper_cvtss2sd, (Reg *d, Reg *s))
155DEF_HELPER(void, helper_cvtsd2ss, (Reg *d, Reg *s))
156DEF_HELPER(void, helper_cvtdq2ps, (Reg *d, Reg *s))
157DEF_HELPER(void, helper_cvtdq2pd, (Reg *d, Reg *s))
158DEF_HELPER(void, helper_cvtpi2ps, (XMMReg *d, MMXReg *s))
159DEF_HELPER(void, helper_cvtpi2pd, (XMMReg *d, MMXReg *s))
160DEF_HELPER(void, helper_cvtsi2ss, (XMMReg *d, uint32_t val))
161DEF_HELPER(void, helper_cvtsi2sd, (XMMReg *d, uint32_t val))
162
163#ifdef TARGET_X86_64
164DEF_HELPER(void, helper_cvtsq2ss, (XMMReg *d, uint64_t val))
165DEF_HELPER(void, helper_cvtsq2sd, (XMMReg *d, uint64_t val))
166#endif
167
168DEF_HELPER(void, helper_cvtps2dq, (XMMReg *d, XMMReg *s))
169DEF_HELPER(void, helper_cvtpd2dq, (XMMReg *d, XMMReg *s))
170DEF_HELPER(void, helper_cvtps2pi, (MMXReg *d, XMMReg *s))
171DEF_HELPER(void, helper_cvtpd2pi, (MMXReg *d, XMMReg *s))
172DEF_HELPER(int32_t, helper_cvtss2si, (XMMReg *s))
173DEF_HELPER(int32_t, helper_cvtsd2si, (XMMReg *s))
174#ifdef TARGET_X86_64
175DEF_HELPER(int64_t, helper_cvtss2sq, (XMMReg *s))
176DEF_HELPER(int64_t, helper_cvtsd2sq, (XMMReg *s))
177#endif
178
179DEF_HELPER(void, helper_cvttps2dq, (XMMReg *d, XMMReg *s))
180DEF_HELPER(void, helper_cvttpd2dq, (XMMReg *d, XMMReg *s))
181DEF_HELPER(void, helper_cvttps2pi, (MMXReg *d, XMMReg *s))
182DEF_HELPER(void, helper_cvttpd2pi, (MMXReg *d, XMMReg *s))
183DEF_HELPER(int32_t, helper_cvttss2si, (XMMReg *s))
184DEF_HELPER(int32_t, helper_cvttsd2si, (XMMReg *s))
185#ifdef TARGET_X86_64
186DEF_HELPER(int64_t, helper_cvttss2sq, (XMMReg *s))
187DEF_HELPER(int64_t, helper_cvttsd2sq, (XMMReg *s))
188#endif
189
190DEF_HELPER(void, helper_rsqrtps, (XMMReg *d, XMMReg *s))
191DEF_HELPER(void, helper_rsqrtss, (XMMReg *d, XMMReg *s))
192DEF_HELPER(void, helper_rcpps, (XMMReg *d, XMMReg *s))
193DEF_HELPER(void, helper_rcpss, (XMMReg *d, XMMReg *s))
194DEF_HELPER(void, helper_haddps, (XMMReg *d, XMMReg *s))
195DEF_HELPER(void, helper_haddpd, (XMMReg *d, XMMReg *s))
196DEF_HELPER(void, helper_hsubps, (XMMReg *d, XMMReg *s))
197DEF_HELPER(void, helper_hsubpd, (XMMReg *d, XMMReg *s))
198DEF_HELPER(void, helper_addsubps, (XMMReg *d, XMMReg *s))
199DEF_HELPER(void, helper_addsubpd, (XMMReg *d, XMMReg *s))
200
201#define SSE_HELPER_CMP(name, F)\
202 DEF_HELPER(void, helper_ ## name ## ps , (Reg *d, Reg *s)) \
203 DEF_HELPER(void, helper_ ## name ## ss , (Reg *d, Reg *s)) \
204 DEF_HELPER(void, helper_ ## name ## pd , (Reg *d, Reg *s)) \
205 DEF_HELPER(void, helper_ ## name ## sd , (Reg *d, Reg *s))
206
207SSE_HELPER_CMP(cmpeq, FPU_CMPEQ)
208SSE_HELPER_CMP(cmplt, FPU_CMPLT)
209SSE_HELPER_CMP(cmple, FPU_CMPLE)
210SSE_HELPER_CMP(cmpunord, FPU_CMPUNORD)
211SSE_HELPER_CMP(cmpneq, FPU_CMPNEQ)
212SSE_HELPER_CMP(cmpnlt, FPU_CMPNLT)
213SSE_HELPER_CMP(cmpnle, FPU_CMPNLE)
214SSE_HELPER_CMP(cmpord, FPU_CMPORD)
215
216DEF_HELPER(void, helper_ucomiss, (Reg *d, Reg *s))
217DEF_HELPER(void, helper_comiss, (Reg *d, Reg *s))
218DEF_HELPER(void, helper_ucomisd, (Reg *d, Reg *s))
219DEF_HELPER(void, helper_comisd, (Reg *d, Reg *s))
220DEF_HELPER(uint32_t, helper_movmskps, (Reg *s))
221DEF_HELPER(uint32_t, helper_movmskpd, (Reg *s))
222#endif
223
224DEF_HELPER(uint32_t, glue(helper_pmovmskb, SUFFIX), (Reg *s))
225DEF_HELPER(void, glue(helper_packsswb, SUFFIX) , (Reg *d, Reg *s))
226DEF_HELPER(void, glue(helper_packuswb, SUFFIX) , (Reg *d, Reg *s))
227DEF_HELPER(void, glue(helper_packssdw, SUFFIX) , (Reg *d, Reg *s))
228#define UNPCK_OP(base_name, base) \
229 DEF_HELPER(void, glue(helper_punpck ## base_name ## bw, SUFFIX) , (Reg *d, Reg *s)) \
230 DEF_HELPER(void, glue(helper_punpck ## base_name ## wd, SUFFIX) , (Reg *d, Reg *s)) \
231 DEF_HELPER(void, glue(helper_punpck ## base_name ## dq, SUFFIX) , (Reg *d, Reg *s))
232
233UNPCK_OP(l, 0)
234UNPCK_OP(h, 1)
235
236#if SHIFT == 1
237DEF_HELPER(void, glue(helper_punpcklqdq, SUFFIX) , (Reg *d, Reg *s))
238DEF_HELPER(void, glue(helper_punpckhqdq, SUFFIX) , (Reg *d, Reg *s))
239#endif
240
241/* 3DNow! float ops */
242#if SHIFT == 0
243DEF_HELPER(void, helper_pi2fd, (MMXReg *d, MMXReg *s))
244DEF_HELPER(void, helper_pi2fw, (MMXReg *d, MMXReg *s))
245DEF_HELPER(void, helper_pf2id, (MMXReg *d, MMXReg *s))
246DEF_HELPER(void, helper_pf2iw, (MMXReg *d, MMXReg *s))
247DEF_HELPER(void, helper_pfacc, (MMXReg *d, MMXReg *s))
248DEF_HELPER(void, helper_pfadd, (MMXReg *d, MMXReg *s))
249DEF_HELPER(void, helper_pfcmpeq, (MMXReg *d, MMXReg *s))
250DEF_HELPER(void, helper_pfcmpge, (MMXReg *d, MMXReg *s))
251DEF_HELPER(void, helper_pfcmpgt, (MMXReg *d, MMXReg *s))
252DEF_HELPER(void, helper_pfmax, (MMXReg *d, MMXReg *s))
253DEF_HELPER(void, helper_pfmin, (MMXReg *d, MMXReg *s))
254DEF_HELPER(void, helper_pfmul, (MMXReg *d, MMXReg *s))
255DEF_HELPER(void, helper_pfnacc, (MMXReg *d, MMXReg *s))
256DEF_HELPER(void, helper_pfpnacc, (MMXReg *d, MMXReg *s))
257DEF_HELPER(void, helper_pfrcp, (MMXReg *d, MMXReg *s))
258DEF_HELPER(void, helper_pfrsqrt, (MMXReg *d, MMXReg *s))
259DEF_HELPER(void, helper_pfsub, (MMXReg *d, MMXReg *s))
260DEF_HELPER(void, helper_pfsubr, (MMXReg *d, MMXReg *s))
261DEF_HELPER(void, helper_pswapd, (MMXReg *d, MMXReg *s))
262#endif
263
264/* SSSE3 op helpers */
265DEF_HELPER(void, glue(helper_phaddw, SUFFIX), (Reg *d, Reg *s))
266DEF_HELPER(void, glue(helper_phaddd, SUFFIX), (Reg *d, Reg *s))
267DEF_HELPER(void, glue(helper_phaddsw, SUFFIX), (Reg *d, Reg *s))
268DEF_HELPER(void, glue(helper_phsubw, SUFFIX), (Reg *d, Reg *s))
269DEF_HELPER(void, glue(helper_phsubd, SUFFIX), (Reg *d, Reg *s))
270DEF_HELPER(void, glue(helper_phsubsw, SUFFIX), (Reg *d, Reg *s))
271DEF_HELPER(void, glue(helper_pabsb, SUFFIX), (Reg *d, Reg *s))
272DEF_HELPER(void, glue(helper_pabsw, SUFFIX), (Reg *d, Reg *s))
273DEF_HELPER(void, glue(helper_pabsd, SUFFIX), (Reg *d, Reg *s))
274DEF_HELPER(void, glue(helper_pmaddubsw, SUFFIX), (Reg *d, Reg *s))
275DEF_HELPER(void, glue(helper_pmulhrsw, SUFFIX), (Reg *d, Reg *s))
276DEF_HELPER(void, glue(helper_pshufb, SUFFIX), (Reg *d, Reg *s))
277DEF_HELPER(void, glue(helper_psignb, SUFFIX), (Reg *d, Reg *s))
278DEF_HELPER(void, glue(helper_psignw, SUFFIX), (Reg *d, Reg *s))
279DEF_HELPER(void, glue(helper_psignd, SUFFIX), (Reg *d, Reg *s))
280DEF_HELPER(void, glue(helper_palignr, SUFFIX), (Reg *d, Reg *s, int32_t shift))
281
282/* SSE4.1 op helpers */
283#if SHIFT == 1
284DEF_HELPER(void, glue(helper_pblendvb, SUFFIX), (Reg *d, Reg *s))
285DEF_HELPER(void, glue(helper_blendvps, SUFFIX), (Reg *d, Reg *s))
286DEF_HELPER(void, glue(helper_blendvpd, SUFFIX), (Reg *d, Reg *s))
287DEF_HELPER(void, glue(helper_ptest, SUFFIX), (Reg *d, Reg *s))
288DEF_HELPER(void, glue(helper_pmovsxbw, SUFFIX), (Reg *d, Reg *s))
289DEF_HELPER(void, glue(helper_pmovsxbd, SUFFIX), (Reg *d, Reg *s))
290DEF_HELPER(void, glue(helper_pmovsxbq, SUFFIX), (Reg *d, Reg *s))
291DEF_HELPER(void, glue(helper_pmovsxwd, SUFFIX), (Reg *d, Reg *s))
292DEF_HELPER(void, glue(helper_pmovsxwq, SUFFIX), (Reg *d, Reg *s))
293DEF_HELPER(void, glue(helper_pmovsxdq, SUFFIX), (Reg *d, Reg *s))
294DEF_HELPER(void, glue(helper_pmovzxbw, SUFFIX), (Reg *d, Reg *s))
295DEF_HELPER(void, glue(helper_pmovzxbd, SUFFIX), (Reg *d, Reg *s))
296DEF_HELPER(void, glue(helper_pmovzxbq, SUFFIX), (Reg *d, Reg *s))
297DEF_HELPER(void, glue(helper_pmovzxwd, SUFFIX), (Reg *d, Reg *s))
298DEF_HELPER(void, glue(helper_pmovzxwq, SUFFIX), (Reg *d, Reg *s))
299DEF_HELPER(void, glue(helper_pmovzxdq, SUFFIX), (Reg *d, Reg *s))
300DEF_HELPER(void, glue(helper_pmuldq, SUFFIX), (Reg *d, Reg *s))
301DEF_HELPER(void, glue(helper_pcmpeqq, SUFFIX), (Reg *d, Reg *s))
302DEF_HELPER(void, glue(helper_packusdw, SUFFIX), (Reg *d, Reg *s))
303DEF_HELPER(void, glue(helper_pminsb, SUFFIX), (Reg *d, Reg *s))
304DEF_HELPER(void, glue(helper_pminsd, SUFFIX), (Reg *d, Reg *s))
305DEF_HELPER(void, glue(helper_pminuw, SUFFIX), (Reg *d, Reg *s))
306DEF_HELPER(void, glue(helper_pminud, SUFFIX), (Reg *d, Reg *s))
307DEF_HELPER(void, glue(helper_pmaxsb, SUFFIX), (Reg *d, Reg *s))
308DEF_HELPER(void, glue(helper_pmaxsd, SUFFIX), (Reg *d, Reg *s))
309DEF_HELPER(void, glue(helper_pmaxuw, SUFFIX), (Reg *d, Reg *s))
310DEF_HELPER(void, glue(helper_pmaxud, SUFFIX), (Reg *d, Reg *s))
311DEF_HELPER(void, glue(helper_pmulld, SUFFIX), (Reg *d, Reg *s))
312DEF_HELPER(void, glue(helper_phminposuw, SUFFIX), (Reg *d, Reg *s))
313DEF_HELPER(void, glue(helper_roundps, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
314DEF_HELPER(void, glue(helper_roundpd, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
315DEF_HELPER(void, glue(helper_roundss, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
316DEF_HELPER(void, glue(helper_roundsd, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
317DEF_HELPER(void, glue(helper_blendps, SUFFIX), (Reg *d, Reg *s, uint32_t imm))
318DEF_HELPER(void, glue(helper_blendpd, SUFFIX), (Reg *d, Reg *s, uint32_t imm))
319DEF_HELPER(void, glue(helper_pblendw, SUFFIX), (Reg *d, Reg *s, uint32_t imm))
320DEF_HELPER(void, glue(helper_dpps, SUFFIX), (Reg *d, Reg *s, uint32_t mask))
321DEF_HELPER(void, glue(helper_dppd, SUFFIX), (Reg *d, Reg *s, uint32_t mask))
322DEF_HELPER(void, glue(helper_mpsadbw, SUFFIX), (Reg *d, Reg *s, uint32_t off))
323#endif
324
325/* SSE4.2 op helpers */
326#if SHIFT == 1
327DEF_HELPER(void, glue(helper_pcmpgtq, SUFFIX), (Reg *d, Reg *s))
328DEF_HELPER(void, glue(helper_pcmpestri, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
329DEF_HELPER(void, glue(helper_pcmpestrm, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
330DEF_HELPER(void, glue(helper_pcmpistri, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
331DEF_HELPER(void, glue(helper_pcmpistrm, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
332DEF_HELPER(target_ulong, helper_crc32,
333 (uint32_t crc1, target_ulong msg, uint32_t len))
334DEF_HELPER(target_ulong, helper_popcnt, (target_ulong n, uint32_t type))
335#endif
336
337#undef SHIFT
338#undef Reg
339#undef SUFFIX
340
341#undef SSE_HELPER_B
342#undef SSE_HELPER_W
343#undef SSE_HELPER_L
344#undef SSE_HELPER_Q
345#undef SSE_HELPER_S
346#undef SSE_HELPER_CMP
347#undef UNPCK_OP
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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