2 * MMX/3DNow!/SSE/SSE2/SSE3/PNI support
4 * Copyright (c) 2005 Fabrice Bellard
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.
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.
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
28 DEF_HELPER(void, glue(helper_psrlw
, SUFFIX
), (Reg
*d
, Reg
*s
))
29 DEF_HELPER(void, glue(helper_psraw
, SUFFIX
), (Reg
*d
, Reg
*s
))
30 DEF_HELPER(void, glue(helper_psllw
, SUFFIX
), (Reg
*d
, Reg
*s
))
31 DEF_HELPER(void, glue(helper_psrld
, SUFFIX
), (Reg
*d
, Reg
*s
))
32 DEF_HELPER(void, glue(helper_psrad
, SUFFIX
), (Reg
*d
, Reg
*s
))
33 DEF_HELPER(void, glue(helper_pslld
, SUFFIX
), (Reg
*d
, Reg
*s
))
34 DEF_HELPER(void, glue(helper_psrlq
, SUFFIX
), (Reg
*d
, Reg
*s
))
35 DEF_HELPER(void, glue(helper_psllq
, SUFFIX
), (Reg
*d
, Reg
*s
))
38 DEF_HELPER(void, glue(helper_psrldq
, SUFFIX
), (Reg
*d
, Reg
*s
))
39 DEF_HELPER(void, glue(helper_pslldq
, SUFFIX
), (Reg
*d
, Reg
*s
))
42 #define SSE_HELPER_B(name, F)\
43 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
45 #define SSE_HELPER_W(name, F)\
46 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
48 #define SSE_HELPER_L(name, F)\
49 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
51 #define SSE_HELPER_Q(name, F)\
52 DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
54 SSE_HELPER_B(helper_paddb
, FADD
)
55 SSE_HELPER_W(helper_paddw
, FADD
)
56 SSE_HELPER_L(helper_paddl
, FADD
)
57 SSE_HELPER_Q(helper_paddq
, FADD
)
59 SSE_HELPER_B(helper_psubb
, FSUB
)
60 SSE_HELPER_W(helper_psubw
, FSUB
)
61 SSE_HELPER_L(helper_psubl
, FSUB
)
62 SSE_HELPER_Q(helper_psubq
, FSUB
)
64 SSE_HELPER_B(helper_paddusb
, FADDUB
)
65 SSE_HELPER_B(helper_paddsb
, FADDSB
)
66 SSE_HELPER_B(helper_psubusb
, FSUBUB
)
67 SSE_HELPER_B(helper_psubsb
, FSUBSB
)
69 SSE_HELPER_W(helper_paddusw
, FADDUW
)
70 SSE_HELPER_W(helper_paddsw
, FADDSW
)
71 SSE_HELPER_W(helper_psubusw
, FSUBUW
)
72 SSE_HELPER_W(helper_psubsw
, FSUBSW
)
74 SSE_HELPER_B(helper_pminub
, FMINUB
)
75 SSE_HELPER_B(helper_pmaxub
, FMAXUB
)
77 SSE_HELPER_W(helper_pminsw
, FMINSW
)
78 SSE_HELPER_W(helper_pmaxsw
, FMAXSW
)
80 SSE_HELPER_Q(helper_pand
, FAND
)
81 SSE_HELPER_Q(helper_pandn
, FANDN
)
82 SSE_HELPER_Q(helper_por
, FOR
)
83 SSE_HELPER_Q(helper_pxor
, FXOR
)
85 SSE_HELPER_B(helper_pcmpgtb
, FCMPGTB
)
86 SSE_HELPER_W(helper_pcmpgtw
, FCMPGTW
)
87 SSE_HELPER_L(helper_pcmpgtl
, FCMPGTL
)
89 SSE_HELPER_B(helper_pcmpeqb
, FCMPEQ
)
90 SSE_HELPER_W(helper_pcmpeqw
, FCMPEQ
)
91 SSE_HELPER_L(helper_pcmpeql
, FCMPEQ
)
93 SSE_HELPER_W(helper_pmullw
, FMULLW
)
95 SSE_HELPER_W(helper_pmulhrw
, FMULHRW
)
97 SSE_HELPER_W(helper_pmulhuw
, FMULHUW
)
98 SSE_HELPER_W(helper_pmulhw
, FMULHW
)
100 SSE_HELPER_B(helper_pavgb
, FAVG
)
101 SSE_HELPER_W(helper_pavgw
, FAVG
)
103 DEF_HELPER(void, glue(helper_pmuludq
, SUFFIX
) , (Reg
*d
, Reg
*s
))
104 DEF_HELPER(void, glue(helper_pmaddwd
, SUFFIX
) , (Reg
*d
, Reg
*s
))
106 DEF_HELPER(void, glue(helper_psadbw
, SUFFIX
) , (Reg
*d
, Reg
*s
))
107 DEF_HELPER(void, glue(helper_maskmov
, SUFFIX
) , (Reg
*d
, Reg
*s
, target_ulong a0
))
108 DEF_HELPER(void, glue(helper_movl_mm_T0
, SUFFIX
) , (Reg
*d
, uint32_t val
))
110 DEF_HELPER(void, glue(helper_movq_mm_T0
, SUFFIX
) , (Reg
*d
, uint64_t val
))
114 DEF_HELPER(void, glue(helper_pshufw
, SUFFIX
) , (Reg
*d
, Reg
*s
, int order
))
116 DEF_HELPER(void, helper_shufps
, (Reg
*d
, Reg
*s
, int order
))
117 DEF_HELPER(void, helper_shufpd
, (Reg
*d
, Reg
*s
, int order
))
118 DEF_HELPER(void, glue(helper_pshufd
, SUFFIX
) , (Reg
*d
, Reg
*s
, int order
))
119 DEF_HELPER(void, glue(helper_pshuflw
, SUFFIX
) , (Reg
*d
, Reg
*s
, int order
))
120 DEF_HELPER(void, glue(helper_pshufhw
, SUFFIX
) , (Reg
*d
, Reg
*s
, int order
))
125 /* XXX: not accurate */
127 #define SSE_HELPER_S(name, F)\
128 DEF_HELPER(void, helper_ ## name ## ps , (Reg *d, Reg *s)) \
129 DEF_HELPER(void, helper_ ## name ## ss , (Reg *d, Reg *s)) \
130 DEF_HELPER(void, helper_ ## name ## pd , (Reg *d, Reg *s)) \
131 DEF_HELPER(void, helper_ ## name ## sd , (Reg *d, Reg *s))
133 SSE_HELPER_S(add
, FPU_ADD
)
134 SSE_HELPER_S(sub
, FPU_SUB
)
135 SSE_HELPER_S(mul
, FPU_MUL
)
136 SSE_HELPER_S(div
, FPU_DIV
)
137 SSE_HELPER_S(min
, FPU_MIN
)
138 SSE_HELPER_S(max
, FPU_MAX
)
139 SSE_HELPER_S(sqrt
, FPU_SQRT
)
142 DEF_HELPER(void, helper_cvtps2pd
, (Reg
*d
, Reg
*s
))
143 DEF_HELPER(void, helper_cvtpd2ps
, (Reg
*d
, Reg
*s
))
144 DEF_HELPER(void, helper_cvtss2sd
, (Reg
*d
, Reg
*s
))
145 DEF_HELPER(void, helper_cvtsd2ss
, (Reg
*d
, Reg
*s
))
146 DEF_HELPER(void, helper_cvtdq2ps
, (Reg
*d
, Reg
*s
))
147 DEF_HELPER(void, helper_cvtdq2pd
, (Reg
*d
, Reg
*s
))
148 DEF_HELPER(void, helper_cvtpi2ps
, (XMMReg
*d
, MMXReg
*s
))
149 DEF_HELPER(void, helper_cvtpi2pd
, (XMMReg
*d
, MMXReg
*s
))
150 DEF_HELPER(void, helper_cvtsi2ss
, (XMMReg
*d
, uint32_t val
))
151 DEF_HELPER(void, helper_cvtsi2sd
, (XMMReg
*d
, uint32_t val
))
154 DEF_HELPER(void, helper_cvtsq2ss
, (XMMReg
*d
, uint64_t val
))
155 DEF_HELPER(void, helper_cvtsq2sd
, (XMMReg
*d
, uint64_t val
))
158 DEF_HELPER(void, helper_cvtps2dq
, (XMMReg
*d
, XMMReg
*s
))
159 DEF_HELPER(void, helper_cvtpd2dq
, (XMMReg
*d
, XMMReg
*s
))
160 DEF_HELPER(void, helper_cvtps2pi
, (MMXReg
*d
, XMMReg
*s
))
161 DEF_HELPER(void, helper_cvtpd2pi
, (MMXReg
*d
, XMMReg
*s
))
162 DEF_HELPER(int32_t, helper_cvtss2si
, (XMMReg
*s
))
163 DEF_HELPER(int32_t, helper_cvtsd2si
, (XMMReg
*s
))
165 DEF_HELPER(int64_t, helper_cvtss2sq
, (XMMReg
*s
))
166 DEF_HELPER(int64_t, helper_cvtsd2sq
, (XMMReg
*s
))
169 DEF_HELPER(void, helper_cvttps2dq
, (XMMReg
*d
, XMMReg
*s
))
170 DEF_HELPER(void, helper_cvttpd2dq
, (XMMReg
*d
, XMMReg
*s
))
171 DEF_HELPER(void, helper_cvttps2pi
, (MMXReg
*d
, XMMReg
*s
))
172 DEF_HELPER(void, helper_cvttpd2pi
, (MMXReg
*d
, XMMReg
*s
))
173 DEF_HELPER(int32_t, helper_cvttss2si
, (XMMReg
*s
))
174 DEF_HELPER(int32_t, helper_cvttsd2si
, (XMMReg
*s
))
176 DEF_HELPER(int64_t, helper_cvttss2sq
, (XMMReg
*s
))
177 DEF_HELPER(int64_t, helper_cvttsd2sq
, (XMMReg
*s
))
180 DEF_HELPER(void, helper_rsqrtps
, (XMMReg
*d
, XMMReg
*s
))
181 DEF_HELPER(void, helper_rsqrtss
, (XMMReg
*d
, XMMReg
*s
))
182 DEF_HELPER(void, helper_rcpps
, (XMMReg
*d
, XMMReg
*s
))
183 DEF_HELPER(void, helper_rcpss
, (XMMReg
*d
, XMMReg
*s
))
184 DEF_HELPER(void, helper_haddps
, (XMMReg
*d
, XMMReg
*s
))
185 DEF_HELPER(void, helper_haddpd
, (XMMReg
*d
, XMMReg
*s
))
186 DEF_HELPER(void, helper_hsubps
, (XMMReg
*d
, XMMReg
*s
))
187 DEF_HELPER(void, helper_hsubpd
, (XMMReg
*d
, XMMReg
*s
))
188 DEF_HELPER(void, helper_addsubps
, (XMMReg
*d
, XMMReg
*s
))
189 DEF_HELPER(void, helper_addsubpd
, (XMMReg
*d
, XMMReg
*s
))
191 #define SSE_HELPER_CMP(name, F)\
192 DEF_HELPER(void, helper_ ## name ## ps , (Reg *d, Reg *s)) \
193 DEF_HELPER(void, helper_ ## name ## ss , (Reg *d, Reg *s)) \
194 DEF_HELPER(void, helper_ ## name ## pd , (Reg *d, Reg *s)) \
195 DEF_HELPER(void, helper_ ## name ## sd , (Reg *d, Reg *s))
197 SSE_HELPER_CMP(cmpeq
, FPU_CMPEQ
)
198 SSE_HELPER_CMP(cmplt
, FPU_CMPLT
)
199 SSE_HELPER_CMP(cmple
, FPU_CMPLE
)
200 SSE_HELPER_CMP(cmpunord
, FPU_CMPUNORD
)
201 SSE_HELPER_CMP(cmpneq
, FPU_CMPNEQ
)
202 SSE_HELPER_CMP(cmpnlt
, FPU_CMPNLT
)
203 SSE_HELPER_CMP(cmpnle
, FPU_CMPNLE
)
204 SSE_HELPER_CMP(cmpord
, FPU_CMPORD
)
206 DEF_HELPER(void, helper_ucomiss
, (Reg
*d
, Reg
*s
))
207 DEF_HELPER(void, helper_comiss
, (Reg
*d
, Reg
*s
))
208 DEF_HELPER(void, helper_ucomisd
, (Reg
*d
, Reg
*s
))
209 DEF_HELPER(void, helper_comisd
, (Reg
*d
, Reg
*s
))
210 DEF_HELPER(uint32_t, helper_movmskps
, (Reg
*s
))
211 DEF_HELPER(uint32_t, helper_movmskpd
, (Reg
*s
))
214 DEF_HELPER(uint32_t, glue(helper_pmovmskb
, SUFFIX
), (Reg
*s
))
215 DEF_HELPER(void, glue(helper_packsswb
, SUFFIX
) , (Reg
*d
, Reg
*s
))
216 DEF_HELPER(void, glue(helper_packuswb
, SUFFIX
) , (Reg
*d
, Reg
*s
))
217 DEF_HELPER(void, glue(helper_packssdw
, SUFFIX
) , (Reg
*d
, Reg
*s
))
218 #define UNPCK_OP(base_name, base) \
219 DEF_HELPER(void, glue(helper_punpck ## base_name ## bw, SUFFIX) , (Reg *d, Reg *s)) \
220 DEF_HELPER(void, glue(helper_punpck ## base_name ## wd, SUFFIX) , (Reg *d, Reg *s)) \
221 DEF_HELPER(void, glue(helper_punpck ## base_name ## dq, SUFFIX) , (Reg *d, Reg *s))
227 DEF_HELPER(void, glue(helper_punpcklqdq
, SUFFIX
) , (Reg
*d
, Reg
*s
))
228 DEF_HELPER(void, glue(helper_punpckhqdq
, SUFFIX
) , (Reg
*d
, Reg
*s
))
231 /* 3DNow! float ops */
233 DEF_HELPER(void, helper_pi2fd
, (MMXReg
*d
, MMXReg
*s
))
234 DEF_HELPER(void, helper_pi2fw
, (MMXReg
*d
, MMXReg
*s
))
235 DEF_HELPER(void, helper_pf2id
, (MMXReg
*d
, MMXReg
*s
))
236 DEF_HELPER(void, helper_pf2iw
, (MMXReg
*d
, MMXReg
*s
))
237 DEF_HELPER(void, helper_pfacc
, (MMXReg
*d
, MMXReg
*s
))
238 DEF_HELPER(void, helper_pfadd
, (MMXReg
*d
, MMXReg
*s
))
239 DEF_HELPER(void, helper_pfcmpeq
, (MMXReg
*d
, MMXReg
*s
))
240 DEF_HELPER(void, helper_pfcmpge
, (MMXReg
*d
, MMXReg
*s
))
241 DEF_HELPER(void, helper_pfcmpgt
, (MMXReg
*d
, MMXReg
*s
))
242 DEF_HELPER(void, helper_pfmax
, (MMXReg
*d
, MMXReg
*s
))
243 DEF_HELPER(void, helper_pfmin
, (MMXReg
*d
, MMXReg
*s
))
244 DEF_HELPER(void, helper_pfmul
, (MMXReg
*d
, MMXReg
*s
))
245 DEF_HELPER(void, helper_pfnacc
, (MMXReg
*d
, MMXReg
*s
))
246 DEF_HELPER(void, helper_pfpnacc
, (MMXReg
*d
, MMXReg
*s
))
247 DEF_HELPER(void, helper_pfrcp
, (MMXReg
*d
, MMXReg
*s
))
248 DEF_HELPER(void, helper_pfrsqrt
, (MMXReg
*d
, MMXReg
*s
))
249 DEF_HELPER(void, helper_pfsub
, (MMXReg
*d
, MMXReg
*s
))
250 DEF_HELPER(void, helper_pfsubr
, (MMXReg
*d
, MMXReg
*s
))
251 DEF_HELPER(void, helper_pswapd
, (MMXReg
*d
, MMXReg
*s
))
263 #undef SSE_HELPER_CMP