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