ops_sse_header.h (13134B)
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.1 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#if SHIFT == 0 20#define Reg MMXReg 21#define SUFFIX _mmx 22#else 23#define Reg ZMMReg 24#define SUFFIX _xmm 25#endif 26 27#define dh_alias_Reg ptr 28#define dh_alias_ZMMReg ptr 29#define dh_alias_MMXReg ptr 30#define dh_ctype_Reg Reg * 31#define dh_ctype_ZMMReg ZMMReg * 32#define dh_ctype_MMXReg MMXReg * 33 34DEF_HELPER_3(glue(psrlw, SUFFIX), void, env, Reg, Reg) 35DEF_HELPER_3(glue(psraw, SUFFIX), void, env, Reg, Reg) 36DEF_HELPER_3(glue(psllw, SUFFIX), void, env, Reg, Reg) 37DEF_HELPER_3(glue(psrld, SUFFIX), void, env, Reg, Reg) 38DEF_HELPER_3(glue(psrad, SUFFIX), void, env, Reg, Reg) 39DEF_HELPER_3(glue(pslld, SUFFIX), void, env, Reg, Reg) 40DEF_HELPER_3(glue(psrlq, SUFFIX), void, env, Reg, Reg) 41DEF_HELPER_3(glue(psllq, SUFFIX), void, env, Reg, Reg) 42 43#if SHIFT == 1 44DEF_HELPER_3(glue(psrldq, SUFFIX), void, env, Reg, Reg) 45DEF_HELPER_3(glue(pslldq, SUFFIX), void, env, Reg, Reg) 46#endif 47 48#define SSE_HELPER_B(name, F)\ 49 DEF_HELPER_3(glue(name, SUFFIX), void, env, Reg, Reg) 50 51#define SSE_HELPER_W(name, F)\ 52 DEF_HELPER_3(glue(name, SUFFIX), void, env, Reg, Reg) 53 54#define SSE_HELPER_L(name, F)\ 55 DEF_HELPER_3(glue(name, SUFFIX), void, env, Reg, Reg) 56 57#define SSE_HELPER_Q(name, F)\ 58 DEF_HELPER_3(glue(name, SUFFIX), void, env, Reg, Reg) 59 60SSE_HELPER_B(paddb, FADD) 61SSE_HELPER_W(paddw, FADD) 62SSE_HELPER_L(paddl, FADD) 63SSE_HELPER_Q(paddq, FADD) 64 65SSE_HELPER_B(psubb, FSUB) 66SSE_HELPER_W(psubw, FSUB) 67SSE_HELPER_L(psubl, FSUB) 68SSE_HELPER_Q(psubq, FSUB) 69 70SSE_HELPER_B(paddusb, FADDUB) 71SSE_HELPER_B(paddsb, FADDSB) 72SSE_HELPER_B(psubusb, FSUBUB) 73SSE_HELPER_B(psubsb, FSUBSB) 74 75SSE_HELPER_W(paddusw, FADDUW) 76SSE_HELPER_W(paddsw, FADDSW) 77SSE_HELPER_W(psubusw, FSUBUW) 78SSE_HELPER_W(psubsw, FSUBSW) 79 80SSE_HELPER_B(pminub, FMINUB) 81SSE_HELPER_B(pmaxub, FMAXUB) 82 83SSE_HELPER_W(pminsw, FMINSW) 84SSE_HELPER_W(pmaxsw, FMAXSW) 85 86SSE_HELPER_Q(pand, FAND) 87SSE_HELPER_Q(pandn, FANDN) 88SSE_HELPER_Q(por, FOR) 89SSE_HELPER_Q(pxor, FXOR) 90 91SSE_HELPER_B(pcmpgtb, FCMPGTB) 92SSE_HELPER_W(pcmpgtw, FCMPGTW) 93SSE_HELPER_L(pcmpgtl, FCMPGTL) 94 95SSE_HELPER_B(pcmpeqb, FCMPEQ) 96SSE_HELPER_W(pcmpeqw, FCMPEQ) 97SSE_HELPER_L(pcmpeql, FCMPEQ) 98 99SSE_HELPER_W(pmullw, FMULLW) 100#if SHIFT == 0 101SSE_HELPER_W(pmulhrw, FMULHRW) 102#endif 103SSE_HELPER_W(pmulhuw, FMULHUW) 104SSE_HELPER_W(pmulhw, FMULHW) 105 106SSE_HELPER_B(pavgb, FAVG) 107SSE_HELPER_W(pavgw, FAVG) 108 109DEF_HELPER_3(glue(pmuludq, SUFFIX), void, env, Reg, Reg) 110DEF_HELPER_3(glue(pmaddwd, SUFFIX), void, env, Reg, Reg) 111 112DEF_HELPER_3(glue(psadbw, SUFFIX), void, env, Reg, Reg) 113DEF_HELPER_4(glue(maskmov, SUFFIX), void, env, Reg, Reg, tl) 114DEF_HELPER_2(glue(movl_mm_T0, SUFFIX), void, Reg, i32) 115#ifdef TARGET_X86_64 116DEF_HELPER_2(glue(movq_mm_T0, SUFFIX), void, Reg, i64) 117#endif 118 119#if SHIFT == 0 120DEF_HELPER_3(glue(pshufw, SUFFIX), void, Reg, Reg, int) 121#else 122DEF_HELPER_3(shufps, void, Reg, Reg, int) 123DEF_HELPER_3(shufpd, void, Reg, Reg, int) 124DEF_HELPER_3(glue(pshufd, SUFFIX), void, Reg, Reg, int) 125DEF_HELPER_3(glue(pshuflw, SUFFIX), void, Reg, Reg, int) 126DEF_HELPER_3(glue(pshufhw, SUFFIX), void, Reg, Reg, int) 127#endif 128 129#if SHIFT == 1 130/* FPU ops */ 131/* XXX: not accurate */ 132 133#define SSE_HELPER_S(name, F) \ 134 DEF_HELPER_3(name ## ps, void, env, Reg, Reg) \ 135 DEF_HELPER_3(name ## ss, void, env, Reg, Reg) \ 136 DEF_HELPER_3(name ## pd, void, env, Reg, Reg) \ 137 DEF_HELPER_3(name ## sd, void, env, Reg, Reg) 138 139SSE_HELPER_S(add, FPU_ADD) 140SSE_HELPER_S(sub, FPU_SUB) 141SSE_HELPER_S(mul, FPU_MUL) 142SSE_HELPER_S(div, FPU_DIV) 143SSE_HELPER_S(min, FPU_MIN) 144SSE_HELPER_S(max, FPU_MAX) 145SSE_HELPER_S(sqrt, FPU_SQRT) 146 147 148DEF_HELPER_3(cvtps2pd, void, env, Reg, Reg) 149DEF_HELPER_3(cvtpd2ps, void, env, Reg, Reg) 150DEF_HELPER_3(cvtss2sd, void, env, Reg, Reg) 151DEF_HELPER_3(cvtsd2ss, void, env, Reg, Reg) 152DEF_HELPER_3(cvtdq2ps, void, env, Reg, Reg) 153DEF_HELPER_3(cvtdq2pd, void, env, Reg, Reg) 154DEF_HELPER_3(cvtpi2ps, void, env, ZMMReg, MMXReg) 155DEF_HELPER_3(cvtpi2pd, void, env, ZMMReg, MMXReg) 156DEF_HELPER_3(cvtsi2ss, void, env, ZMMReg, i32) 157DEF_HELPER_3(cvtsi2sd, void, env, ZMMReg, i32) 158 159#ifdef TARGET_X86_64 160DEF_HELPER_3(cvtsq2ss, void, env, ZMMReg, i64) 161DEF_HELPER_3(cvtsq2sd, void, env, ZMMReg, i64) 162#endif 163 164DEF_HELPER_3(cvtps2dq, void, env, ZMMReg, ZMMReg) 165DEF_HELPER_3(cvtpd2dq, void, env, ZMMReg, ZMMReg) 166DEF_HELPER_3(cvtps2pi, void, env, MMXReg, ZMMReg) 167DEF_HELPER_3(cvtpd2pi, void, env, MMXReg, ZMMReg) 168DEF_HELPER_2(cvtss2si, s32, env, ZMMReg) 169DEF_HELPER_2(cvtsd2si, s32, env, ZMMReg) 170#ifdef TARGET_X86_64 171DEF_HELPER_2(cvtss2sq, s64, env, ZMMReg) 172DEF_HELPER_2(cvtsd2sq, s64, env, ZMMReg) 173#endif 174 175DEF_HELPER_3(cvttps2dq, void, env, ZMMReg, ZMMReg) 176DEF_HELPER_3(cvttpd2dq, void, env, ZMMReg, ZMMReg) 177DEF_HELPER_3(cvttps2pi, void, env, MMXReg, ZMMReg) 178DEF_HELPER_3(cvttpd2pi, void, env, MMXReg, ZMMReg) 179DEF_HELPER_2(cvttss2si, s32, env, ZMMReg) 180DEF_HELPER_2(cvttsd2si, s32, env, ZMMReg) 181#ifdef TARGET_X86_64 182DEF_HELPER_2(cvttss2sq, s64, env, ZMMReg) 183DEF_HELPER_2(cvttsd2sq, s64, env, ZMMReg) 184#endif 185 186DEF_HELPER_3(rsqrtps, void, env, ZMMReg, ZMMReg) 187DEF_HELPER_3(rsqrtss, void, env, ZMMReg, ZMMReg) 188DEF_HELPER_3(rcpps, void, env, ZMMReg, ZMMReg) 189DEF_HELPER_3(rcpss, void, env, ZMMReg, ZMMReg) 190DEF_HELPER_3(extrq_r, void, env, ZMMReg, ZMMReg) 191DEF_HELPER_4(extrq_i, void, env, ZMMReg, int, int) 192DEF_HELPER_3(insertq_r, void, env, ZMMReg, ZMMReg) 193DEF_HELPER_4(insertq_i, void, env, ZMMReg, int, int) 194DEF_HELPER_3(haddps, void, env, ZMMReg, ZMMReg) 195DEF_HELPER_3(haddpd, void, env, ZMMReg, ZMMReg) 196DEF_HELPER_3(hsubps, void, env, ZMMReg, ZMMReg) 197DEF_HELPER_3(hsubpd, void, env, ZMMReg, ZMMReg) 198DEF_HELPER_3(addsubps, void, env, ZMMReg, ZMMReg) 199DEF_HELPER_3(addsubpd, void, env, ZMMReg, ZMMReg) 200 201#define SSE_HELPER_CMP(name, F) \ 202 DEF_HELPER_3(name ## ps, void, env, Reg, Reg) \ 203 DEF_HELPER_3(name ## ss, void, env, Reg, Reg) \ 204 DEF_HELPER_3(name ## pd, void, env, Reg, Reg) \ 205 DEF_HELPER_3(name ## sd, void, env, Reg, Reg) 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_3(ucomiss, void, env, Reg, Reg) 217DEF_HELPER_3(comiss, void, env, Reg, Reg) 218DEF_HELPER_3(ucomisd, void, env, Reg, Reg) 219DEF_HELPER_3(comisd, void, env, Reg, Reg) 220DEF_HELPER_2(movmskps, i32, env, Reg) 221DEF_HELPER_2(movmskpd, i32, env, Reg) 222#endif 223 224DEF_HELPER_2(glue(pmovmskb, SUFFIX), i32, env, Reg) 225DEF_HELPER_3(glue(packsswb, SUFFIX), void, env, Reg, Reg) 226DEF_HELPER_3(glue(packuswb, SUFFIX), void, env, Reg, Reg) 227DEF_HELPER_3(glue(packssdw, SUFFIX), void, env, Reg, Reg) 228#define UNPCK_OP(base_name, base) \ 229 DEF_HELPER_3(glue(punpck ## base_name ## bw, SUFFIX), void, env, Reg, Reg) \ 230 DEF_HELPER_3(glue(punpck ## base_name ## wd, SUFFIX), void, env, Reg, Reg) \ 231 DEF_HELPER_3(glue(punpck ## base_name ## dq, SUFFIX), void, env, Reg, Reg) 232 233UNPCK_OP(l, 0) 234UNPCK_OP(h, 1) 235 236#if SHIFT == 1 237DEF_HELPER_3(glue(punpcklqdq, SUFFIX), void, env, Reg, Reg) 238DEF_HELPER_3(glue(punpckhqdq, SUFFIX), void, env, Reg, Reg) 239#endif 240 241/* 3DNow! float ops */ 242#if SHIFT == 0 243DEF_HELPER_3(pi2fd, void, env, MMXReg, MMXReg) 244DEF_HELPER_3(pi2fw, void, env, MMXReg, MMXReg) 245DEF_HELPER_3(pf2id, void, env, MMXReg, MMXReg) 246DEF_HELPER_3(pf2iw, void, env, MMXReg, MMXReg) 247DEF_HELPER_3(pfacc, void, env, MMXReg, MMXReg) 248DEF_HELPER_3(pfadd, void, env, MMXReg, MMXReg) 249DEF_HELPER_3(pfcmpeq, void, env, MMXReg, MMXReg) 250DEF_HELPER_3(pfcmpge, void, env, MMXReg, MMXReg) 251DEF_HELPER_3(pfcmpgt, void, env, MMXReg, MMXReg) 252DEF_HELPER_3(pfmax, void, env, MMXReg, MMXReg) 253DEF_HELPER_3(pfmin, void, env, MMXReg, MMXReg) 254DEF_HELPER_3(pfmul, void, env, MMXReg, MMXReg) 255DEF_HELPER_3(pfnacc, void, env, MMXReg, MMXReg) 256DEF_HELPER_3(pfpnacc, void, env, MMXReg, MMXReg) 257DEF_HELPER_3(pfrcp, void, env, MMXReg, MMXReg) 258DEF_HELPER_3(pfrsqrt, void, env, MMXReg, MMXReg) 259DEF_HELPER_3(pfsub, void, env, MMXReg, MMXReg) 260DEF_HELPER_3(pfsubr, void, env, MMXReg, MMXReg) 261DEF_HELPER_3(pswapd, void, env, MMXReg, MMXReg) 262#endif 263 264/* SSSE3 op helpers */ 265DEF_HELPER_3(glue(phaddw, SUFFIX), void, env, Reg, Reg) 266DEF_HELPER_3(glue(phaddd, SUFFIX), void, env, Reg, Reg) 267DEF_HELPER_3(glue(phaddsw, SUFFIX), void, env, Reg, Reg) 268DEF_HELPER_3(glue(phsubw, SUFFIX), void, env, Reg, Reg) 269DEF_HELPER_3(glue(phsubd, SUFFIX), void, env, Reg, Reg) 270DEF_HELPER_3(glue(phsubsw, SUFFIX), void, env, Reg, Reg) 271DEF_HELPER_3(glue(pabsb, SUFFIX), void, env, Reg, Reg) 272DEF_HELPER_3(glue(pabsw, SUFFIX), void, env, Reg, Reg) 273DEF_HELPER_3(glue(pabsd, SUFFIX), void, env, Reg, Reg) 274DEF_HELPER_3(glue(pmaddubsw, SUFFIX), void, env, Reg, Reg) 275DEF_HELPER_3(glue(pmulhrsw, SUFFIX), void, env, Reg, Reg) 276DEF_HELPER_3(glue(pshufb, SUFFIX), void, env, Reg, Reg) 277DEF_HELPER_3(glue(psignb, SUFFIX), void, env, Reg, Reg) 278DEF_HELPER_3(glue(psignw, SUFFIX), void, env, Reg, Reg) 279DEF_HELPER_3(glue(psignd, SUFFIX), void, env, Reg, Reg) 280DEF_HELPER_4(glue(palignr, SUFFIX), void, env, Reg, Reg, s32) 281 282/* SSE4.1 op helpers */ 283#if SHIFT == 1 284DEF_HELPER_3(glue(pblendvb, SUFFIX), void, env, Reg, Reg) 285DEF_HELPER_3(glue(blendvps, SUFFIX), void, env, Reg, Reg) 286DEF_HELPER_3(glue(blendvpd, SUFFIX), void, env, Reg, Reg) 287DEF_HELPER_3(glue(ptest, SUFFIX), void, env, Reg, Reg) 288DEF_HELPER_3(glue(pmovsxbw, SUFFIX), void, env, Reg, Reg) 289DEF_HELPER_3(glue(pmovsxbd, SUFFIX), void, env, Reg, Reg) 290DEF_HELPER_3(glue(pmovsxbq, SUFFIX), void, env, Reg, Reg) 291DEF_HELPER_3(glue(pmovsxwd, SUFFIX), void, env, Reg, Reg) 292DEF_HELPER_3(glue(pmovsxwq, SUFFIX), void, env, Reg, Reg) 293DEF_HELPER_3(glue(pmovsxdq, SUFFIX), void, env, Reg, Reg) 294DEF_HELPER_3(glue(pmovzxbw, SUFFIX), void, env, Reg, Reg) 295DEF_HELPER_3(glue(pmovzxbd, SUFFIX), void, env, Reg, Reg) 296DEF_HELPER_3(glue(pmovzxbq, SUFFIX), void, env, Reg, Reg) 297DEF_HELPER_3(glue(pmovzxwd, SUFFIX), void, env, Reg, Reg) 298DEF_HELPER_3(glue(pmovzxwq, SUFFIX), void, env, Reg, Reg) 299DEF_HELPER_3(glue(pmovzxdq, SUFFIX), void, env, Reg, Reg) 300DEF_HELPER_3(glue(pmuldq, SUFFIX), void, env, Reg, Reg) 301DEF_HELPER_3(glue(pcmpeqq, SUFFIX), void, env, Reg, Reg) 302DEF_HELPER_3(glue(packusdw, SUFFIX), void, env, Reg, Reg) 303DEF_HELPER_3(glue(pminsb, SUFFIX), void, env, Reg, Reg) 304DEF_HELPER_3(glue(pminsd, SUFFIX), void, env, Reg, Reg) 305DEF_HELPER_3(glue(pminuw, SUFFIX), void, env, Reg, Reg) 306DEF_HELPER_3(glue(pminud, SUFFIX), void, env, Reg, Reg) 307DEF_HELPER_3(glue(pmaxsb, SUFFIX), void, env, Reg, Reg) 308DEF_HELPER_3(glue(pmaxsd, SUFFIX), void, env, Reg, Reg) 309DEF_HELPER_3(glue(pmaxuw, SUFFIX), void, env, Reg, Reg) 310DEF_HELPER_3(glue(pmaxud, SUFFIX), void, env, Reg, Reg) 311DEF_HELPER_3(glue(pmulld, SUFFIX), void, env, Reg, Reg) 312DEF_HELPER_3(glue(phminposuw, SUFFIX), void, env, Reg, Reg) 313DEF_HELPER_4(glue(roundps, SUFFIX), void, env, Reg, Reg, i32) 314DEF_HELPER_4(glue(roundpd, SUFFIX), void, env, Reg, Reg, i32) 315DEF_HELPER_4(glue(roundss, SUFFIX), void, env, Reg, Reg, i32) 316DEF_HELPER_4(glue(roundsd, SUFFIX), void, env, Reg, Reg, i32) 317DEF_HELPER_4(glue(blendps, SUFFIX), void, env, Reg, Reg, i32) 318DEF_HELPER_4(glue(blendpd, SUFFIX), void, env, Reg, Reg, i32) 319DEF_HELPER_4(glue(pblendw, SUFFIX), void, env, Reg, Reg, i32) 320DEF_HELPER_4(glue(dpps, SUFFIX), void, env, Reg, Reg, i32) 321DEF_HELPER_4(glue(dppd, SUFFIX), void, env, Reg, Reg, i32) 322DEF_HELPER_4(glue(mpsadbw, SUFFIX), void, env, Reg, Reg, i32) 323#endif 324 325/* SSE4.2 op helpers */ 326#if SHIFT == 1 327DEF_HELPER_3(glue(pcmpgtq, SUFFIX), void, env, Reg, Reg) 328DEF_HELPER_4(glue(pcmpestri, SUFFIX), void, env, Reg, Reg, i32) 329DEF_HELPER_4(glue(pcmpestrm, SUFFIX), void, env, Reg, Reg, i32) 330DEF_HELPER_4(glue(pcmpistri, SUFFIX), void, env, Reg, Reg, i32) 331DEF_HELPER_4(glue(pcmpistrm, SUFFIX), void, env, Reg, Reg, i32) 332DEF_HELPER_3(crc32, tl, i32, tl, i32) 333#endif 334 335/* AES-NI op helpers */ 336#if SHIFT == 1 337DEF_HELPER_3(glue(aesdec, SUFFIX), void, env, Reg, Reg) 338DEF_HELPER_3(glue(aesdeclast, SUFFIX), void, env, Reg, Reg) 339DEF_HELPER_3(glue(aesenc, SUFFIX), void, env, Reg, Reg) 340DEF_HELPER_3(glue(aesenclast, SUFFIX), void, env, Reg, Reg) 341DEF_HELPER_3(glue(aesimc, SUFFIX), void, env, Reg, Reg) 342DEF_HELPER_4(glue(aeskeygenassist, SUFFIX), void, env, Reg, Reg, i32) 343DEF_HELPER_4(glue(pclmulqdq, SUFFIX), void, env, Reg, Reg, i32) 344#endif 345 346#undef SHIFT 347#undef Reg 348#undef SUFFIX 349 350#undef SSE_HELPER_B 351#undef SSE_HELPER_W 352#undef SSE_HELPER_L 353#undef SSE_HELPER_Q 354#undef SSE_HELPER_S 355#undef SSE_HELPER_CMP 356#undef UNPCK_OP