Lines Matching +full:3 +full:- +full:d
2 * MMX/3DNow!/SSE/SSE2/SSE3/SSSE3/SSE4/PNI support
22 #include "crypto/aes-round.h"
57 void glue(helper_psrlw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
60 if (c->Q(0) > 15) { in glue()
62 d->Q(i) = 0; in glue()
65 shift = c->B(0); in glue()
67 d->W(i) = FPSRL(s->W(i), shift); in glue()
72 void glue(helper_psllw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
75 if (c->Q(0) > 15) { in glue()
77 d->Q(i) = 0; in glue()
80 shift = c->B(0); in glue()
82 d->W(i) = FPSLL(s->W(i), shift); in glue()
87 void glue(helper_psraw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
90 if (c->Q(0) > 15) { in glue()
93 shift = c->B(0); in glue()
96 d->W(i) = FPSRAW(s->W(i), shift); in glue()
100 void glue(helper_psrld, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
103 if (c->Q(0) > 31) { in glue()
105 d->Q(i) = 0; in glue()
108 shift = c->B(0); in glue()
110 d->L(i) = FPSRL(s->L(i), shift); in glue()
115 void glue(helper_pslld, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
118 if (c->Q(0) > 31) { in glue()
120 d->Q(i) = 0; in glue()
123 shift = c->B(0); in glue()
125 d->L(i) = FPSLL(s->L(i), shift); in glue()
130 void glue(helper_psrad, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
133 if (c->Q(0) > 31) { in glue()
136 shift = c->B(0); in glue()
139 d->L(i) = FPSRAL(s->L(i), shift); in glue()
143 void glue(helper_psrlq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
146 if (c->Q(0) > 63) { in glue()
148 d->Q(i) = 0; in glue()
151 shift = c->B(0); in glue()
153 d->Q(i) = FPSRL(s->Q(i), shift); in glue()
158 void glue(helper_psllq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
161 if (c->Q(0) > 63) { in glue()
163 d->Q(i) = 0; in glue()
166 shift = c->B(0); in glue()
168 d->Q(i) = FPSLL(s->Q(i), shift); in glue()
174 void glue(helper_psrldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
178 shift = c->L(0); in glue()
183 for (i = 0; i < 16 - shift; i++) { in glue()
184 d->B(j + i) = s->B(j + i + shift); in glue()
186 for (i = 16 - shift; i < 16; i++) { in glue()
187 d->B(j + i) = 0; in glue()
192 void glue(helper_pslldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c) in glue()
196 shift = c->L(0); in glue()
201 for (i = 15; i >= shift; i--) { in glue()
202 d->B(j + i) = s->B(j + i - shift); in glue()
205 d->B(j + i) = 0; in glue()
212 void glue(name, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) \
216 d->elem(i) = F(s->elem(i)); \
221 void glue(name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
225 d->elem(i) = F(v->elem(i), s->elem(i)); \
266 if (x < -128) { in satsb()
267 return -128; in satsb()
277 if (x < -32768) { in satsw()
278 return -32768; in satsw()
292 #define FSUB(a, b) ((a) - (b))
293 #define FSUBUB(a, b) satub((a) - (b))
294 #define FSUBUW(a, b) satuw((a) - (b))
295 #define FSUBSB(a, b) satsb((int8_t)(a) - (int8_t)(b))
296 #define FSUBSW(a, b) satsw((int16_t)(a) - (int16_t)(b))
313 void glue(helper_pmulhrw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in SSE_HELPER_W()
315 d->W(0) = FMULHRW(d->W(0), s->W(0)); in SSE_HELPER_W()
316 d->W(1) = FMULHRW(d->W(1), s->W(1)); in SSE_HELPER_W()
317 d->W(2) = FMULHRW(d->W(2), s->W(2)); in SSE_HELPER_W()
318 d->W(3) = FMULHRW(d->W(3), s->W(3)); in SSE_HELPER_W()
325 void glue(helper_pmuludq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in SSE_HELPER_B()
330 d->Q(i) = (uint64_t)s->L(i * 2) * (uint64_t)v->L(i * 2); in SSE_HELPER_B()
334 void glue(helper_pmaddwd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
339 d->L(i) = (int16_t)s->W(2 * i) * (int16_t)v->W(2 * i) + in glue()
340 (int16_t)s->W(2 * i + 1) * (int16_t)v->W(2 * i + 1); in glue()
348 return -a; in abs1()
354 void glue(helper_psadbw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
360 val += abs1(v->B(8 * i + 0) - s->B(8 * i + 0)); in glue()
361 val += abs1(v->B(8 * i + 1) - s->B(8 * i + 1)); in glue()
362 val += abs1(v->B(8 * i + 2) - s->B(8 * i + 2)); in glue()
363 val += abs1(v->B(8 * i + 3) - s->B(8 * i + 3)); in glue()
364 val += abs1(v->B(8 * i + 4) - s->B(8 * i + 4)); in glue()
365 val += abs1(v->B(8 * i + 5) - s->B(8 * i + 5)); in glue()
366 val += abs1(v->B(8 * i + 6) - s->B(8 * i + 6)); in glue()
367 val += abs1(v->B(8 * i + 7) - s->B(8 * i + 7)); in glue()
368 d->Q(i) = val; in glue()
373 void glue(helper_maskmov, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
379 if (s->B(i) & 0x80) { in glue()
380 cpu_stb_data_ra(env, a0 + i, d->B(i), GETPC()); in glue()
387 r0 = a->F((order & 3) + offset); \
388 r1 = a->F(((order >> 2) & 3) + offset); \
389 r2 = b->F(((order >> 4) & 3) + offset); \
390 r3 = b->F(((order >> 6) & 3) + offset); \
391 d->F(offset) = r0; \
392 d->F(offset + 1) = r1; \
393 d->F(offset + 2) = r2; \
394 d->F(offset + 3) = r3; \
398 void glue(helper_pshufw, SUFFIX)(Reg *d, Reg *s, int order) in glue()
405 void glue(helper_shufps, SUFFIX)(Reg *d, Reg *v, Reg *s, int order) in glue()
415 void glue(helper_shufpd, SUFFIX)(Reg *d, Reg *v, Reg *s, int order) in glue()
421 r0 = v->Q(((order & 1) & 1) + i); in glue()
422 r1 = s->Q(((order >> 1) & 1) + i); in glue()
423 d->Q(i) = r0; in glue()
424 d->Q(i + 1) = r1; in glue()
429 void glue(helper_pshufd, SUFFIX)(Reg *d, Reg *s, int order) in glue()
439 void glue(helper_pshuflw, SUFFIX)(Reg *d, Reg *s, int order) in glue()
446 d->Q(j) = s->Q(j); in glue()
450 void glue(helper_pshufhw, SUFFIX)(Reg *d, Reg *s, int order) in glue()
456 d->Q(j) = s->Q(j); in glue()
468 Reg *d, Reg *v, Reg *s) \
472 d->ZMM_S(i) = F(32, v->ZMM_S(i), s->ZMM_S(i)); \
477 Reg *d, Reg *v, Reg *s) \
481 d->ZMM_D(i) = F(64, v->ZMM_D(i), s->ZMM_D(i)); \
490 void helper_ ## name ## ss(CPUX86State *env, Reg *d, Reg *v, Reg *s)\
493 d->ZMM_S(0) = F(32, v->ZMM_S(0), s->ZMM_S(0)); \
495 d->ZMM_L(i) = v->ZMM_L(i); \
499 void helper_ ## name ## sd(CPUX86State *env, Reg *d, Reg *v, Reg *s)\
502 d->ZMM_D(0) = F(64, v->ZMM_D(0), s->ZMM_D(0)); \
504 d->ZMM_Q(i) = v->ZMM_Q(i); \
514 #define FPU_ADD(size, a, b) float ## size ## _add(a, b, &env->sse_status)
515 #define FPU_SUB(size, a, b) float ## size ## _sub(a, b, &env->sse_status)
516 #define FPU_MUL(size, a, b) float ## size ## _mul(a, b, &env->sse_status)
517 #define FPU_DIV(size, a, b) float ## size ## _div(a, b, &env->sse_status)
520 * special cases right: for min and max Intel specifies that (-0,0),
524 (float ## size ## _lt(a, b, &env->sse_status) ? (a) : (b))
526 (float ## size ## _lt(b, a, &env->sse_status) ? (a) : (b))
535 void glue(helper_sqrtps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in SSE_HELPER_S()
539 d->ZMM_S(i) = float32_sqrt(s->ZMM_S(i), &env->sse_status); in SSE_HELPER_S()
543 void glue(helper_sqrtpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
547 d->ZMM_D(i) = float64_sqrt(s->ZMM_D(i), &env->sse_status); in glue()
552 void helper_sqrtss(CPUX86State *env, Reg *d, Reg *v, Reg *s) in helper_sqrtss() argument
555 d->ZMM_S(0) = float32_sqrt(s->ZMM_S(0), &env->sse_status); in helper_sqrtss()
557 d->ZMM_L(i) = v->ZMM_L(i); in helper_sqrtss()
561 void helper_sqrtsd(CPUX86State *env, Reg *d, Reg *v, Reg *s) in helper_sqrtsd() argument
564 d->ZMM_D(0) = float64_sqrt(s->ZMM_D(0), &env->sse_status); in helper_sqrtsd()
566 d->ZMM_Q(i) = v->ZMM_Q(i); in helper_sqrtsd()
572 void glue(helper_cvtps2pd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
575 for (i = 1 << SHIFT; --i >= 0; ) { in glue()
576 d->ZMM_D(i) = float32_to_float64(s->ZMM_S(i), &env->sse_status); in glue()
580 void glue(helper_cvtpd2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
584 d->ZMM_S(i) = float64_to_float32(s->ZMM_D(i), &env->sse_status); in glue()
587 d->Q(i) = 0; in glue()
592 void glue(helper_cvtph2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
596 for (i = 2 << SHIFT; --i >= 0; ) { in glue()
597 d->ZMM_S(i) = float16_to_float32(s->ZMM_H(i), true, &env->sse_status); in glue()
601 void glue(helper_cvtps2ph, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, int mode) in glue()
604 FloatRoundMode prev_rounding_mode = env->sse_status.float_rounding_mode; in glue()
606 set_x86_rounding_mode(mode & 3, &env->sse_status); in glue()
610 d->ZMM_H(i) = float32_to_float16(s->ZMM_S(i), true, &env->sse_status); in glue()
613 d->Q(i) = 0; in glue()
616 env->sse_status.float_rounding_mode = prev_rounding_mode; in glue()
621 void helper_cvtss2sd(CPUX86State *env, Reg *d, Reg *v, Reg *s) in helper_cvtss2sd() argument
624 d->ZMM_D(0) = float32_to_float64(s->ZMM_S(0), &env->sse_status); in helper_cvtss2sd()
626 d->ZMM_Q(i) = v->ZMM_Q(i); in helper_cvtss2sd()
630 void helper_cvtsd2ss(CPUX86State *env, Reg *d, Reg *v, Reg *s) in helper_cvtsd2ss() argument
633 d->ZMM_S(0) = float64_to_float32(s->ZMM_D(0), &env->sse_status); in helper_cvtsd2ss()
635 d->ZMM_L(i) = v->ZMM_L(i); in helper_cvtsd2ss()
641 void glue(helper_cvtdq2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
645 d->ZMM_S(i) = int32_to_float32(s->ZMM_L(i), &env->sse_status); in glue()
649 void glue(helper_cvtdq2pd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
652 for (i = 1 << SHIFT; --i >= 0; ) { in glue()
653 int32_t l = s->ZMM_L(i); in glue()
654 d->ZMM_D(i) = int32_to_float64(l, &env->sse_status); in glue()
659 void helper_cvtpi2ps(CPUX86State *env, ZMMReg *d, MMXReg *s) in helper_cvtpi2ps() argument
661 d->ZMM_S(0) = int32_to_float32(s->MMX_L(0), &env->sse_status); in helper_cvtpi2ps()
662 d->ZMM_S(1) = int32_to_float32(s->MMX_L(1), &env->sse_status); in helper_cvtpi2ps()
665 void helper_cvtpi2pd(CPUX86State *env, ZMMReg *d, MMXReg *s) in helper_cvtpi2pd() argument
667 d->ZMM_D(0) = int32_to_float64(s->MMX_L(0), &env->sse_status); in helper_cvtpi2pd()
668 d->ZMM_D(1) = int32_to_float64(s->MMX_L(1), &env->sse_status); in helper_cvtpi2pd()
671 void helper_cvtsi2ss(CPUX86State *env, ZMMReg *d, uint32_t val) in helper_cvtsi2ss() argument
673 d->ZMM_S(0) = int32_to_float32(val, &env->sse_status); in helper_cvtsi2ss()
676 void helper_cvtsi2sd(CPUX86State *env, ZMMReg *d, uint32_t val) in helper_cvtsi2sd() argument
678 d->ZMM_D(0) = int32_to_float64(val, &env->sse_status); in helper_cvtsi2sd()
682 void helper_cvtsq2ss(CPUX86State *env, ZMMReg *d, uint64_t val) in helper_cvtsq2ss() argument
684 d->ZMM_S(0) = int64_to_float32(val, &env->sse_status); in helper_cvtsq2ss()
687 void helper_cvtsq2sd(CPUX86State *env, ZMMReg *d, uint64_t val) in helper_cvtsq2sd() argument
689 d->ZMM_D(0) = int64_to_float64(val, &env->sse_status); in helper_cvtsq2sd()
700 * of any float-to-integer conversion that raises the 'invalid' exception.
730 void glue(helper_cvtps2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s) in WRAP_FLOATCONV()
734 d->ZMM_L(i) = x86_float32_to_int32(s->ZMM_S(i), &env->sse_status); in WRAP_FLOATCONV()
738 void glue(helper_cvtpd2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s) in glue()
742 d->ZMM_L(i) = x86_float64_to_int32(s->ZMM_D(i), &env->sse_status); in glue()
745 d->Q(i) = 0; in glue()
750 void helper_cvtps2pi(CPUX86State *env, MMXReg *d, ZMMReg *s) in helper_cvtps2pi() argument
752 d->MMX_L(0) = x86_float32_to_int32(s->ZMM_S(0), &env->sse_status); in helper_cvtps2pi()
753 d->MMX_L(1) = x86_float32_to_int32(s->ZMM_S(1), &env->sse_status); in helper_cvtps2pi()
756 void helper_cvtpd2pi(CPUX86State *env, MMXReg *d, ZMMReg *s) in helper_cvtpd2pi() argument
758 d->MMX_L(0) = x86_float64_to_int32(s->ZMM_D(0), &env->sse_status); in helper_cvtpd2pi()
759 d->MMX_L(1) = x86_float64_to_int32(s->ZMM_D(1), &env->sse_status); in helper_cvtpd2pi()
764 return x86_float32_to_int32(s->ZMM_S(0), &env->sse_status); in helper_cvtss2si()
769 return x86_float64_to_int32(s->ZMM_D(0), &env->sse_status); in helper_cvtsd2si()
775 return x86_float32_to_int64(s->ZMM_S(0), &env->sse_status); in helper_cvtss2sq()
780 return x86_float64_to_int64(s->ZMM_D(0), &env->sse_status); in helper_cvtsd2sq()
786 void glue(helper_cvttps2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s) in glue()
790 d->ZMM_L(i) = x86_float32_to_int32_round_to_zero(s->ZMM_S(i), in glue()
791 &env->sse_status); in glue()
795 void glue(helper_cvttpd2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s) in glue()
799 d->ZMM_L(i) = x86_float64_to_int32_round_to_zero(s->ZMM_D(i), in glue()
800 &env->sse_status); in glue()
803 d->Q(i) = 0; in glue()
808 void helper_cvttps2pi(CPUX86State *env, MMXReg *d, ZMMReg *s) in helper_cvttps2pi() argument
810 d->MMX_L(0) = x86_float32_to_int32_round_to_zero(s->ZMM_S(0), &env->sse_status); in helper_cvttps2pi()
811 d->MMX_L(1) = x86_float32_to_int32_round_to_zero(s->ZMM_S(1), &env->sse_status); in helper_cvttps2pi()
814 void helper_cvttpd2pi(CPUX86State *env, MMXReg *d, ZMMReg *s) in helper_cvttpd2pi() argument
816 d->MMX_L(0) = x86_float64_to_int32_round_to_zero(s->ZMM_D(0), &env->sse_status); in helper_cvttpd2pi()
817 d->MMX_L(1) = x86_float64_to_int32_round_to_zero(s->ZMM_D(1), &env->sse_status); in helper_cvttpd2pi()
822 return x86_float32_to_int32_round_to_zero(s->ZMM_S(0), &env->sse_status); in helper_cvttss2si()
827 return x86_float64_to_int32_round_to_zero(s->ZMM_D(0), &env->sse_status); in helper_cvttsd2si()
833 return x86_float32_to_int64_round_to_zero(s->ZMM_S(0), &env->sse_status); in helper_cvttss2sq()
838 return x86_float64_to_int64_round_to_zero(s->ZMM_D(0), &env->sse_status); in helper_cvttsd2sq()
843 void glue(helper_rsqrtps, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s) in glue()
845 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in glue()
848 d->ZMM_S(i) = float32_div(float32_one, in glue()
849 float32_sqrt(s->ZMM_S(i), &env->sse_status), in glue()
850 &env->sse_status); in glue()
852 set_float_exception_flags(old_flags, &env->sse_status); in glue()
856 void helper_rsqrtss(CPUX86State *env, ZMMReg *d, ZMMReg *v, ZMMReg *s) in helper_rsqrtss() argument
858 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in helper_rsqrtss()
860 d->ZMM_S(0) = float32_div(float32_one, in helper_rsqrtss()
861 float32_sqrt(s->ZMM_S(0), &env->sse_status), in helper_rsqrtss()
862 &env->sse_status); in helper_rsqrtss()
863 set_float_exception_flags(old_flags, &env->sse_status); in helper_rsqrtss()
865 d->ZMM_L(i) = v->ZMM_L(i); in helper_rsqrtss()
870 void glue(helper_rcpps, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s) in glue()
872 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in glue()
875 d->ZMM_S(i) = float32_div(float32_one, s->ZMM_S(i), &env->sse_status); in glue()
877 set_float_exception_flags(old_flags, &env->sse_status); in glue()
881 void helper_rcpss(CPUX86State *env, ZMMReg *d, ZMMReg *v, ZMMReg *s) in helper_rcpss() argument
883 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in helper_rcpss()
885 d->ZMM_S(0) = float32_div(float32_one, s->ZMM_S(0), &env->sse_status); in helper_rcpss()
887 d->ZMM_L(i) = v->ZMM_L(i); in helper_rcpss()
889 set_float_exception_flags(old_flags, &env->sse_status); in helper_rcpss()
901 mask = (1ULL << len) - 1; in helper_extrq()
906 void helper_extrq_r(CPUX86State *env, ZMMReg *d, ZMMReg *s) in helper_extrq_r() argument
908 d->ZMM_Q(0) = helper_extrq(d->ZMM_Q(0), s->ZMM_B(1) & 63, s->ZMM_B(0) & 63); in helper_extrq_r()
911 void helper_extrq_i(CPUX86State *env, ZMMReg *d, int index, int length) in helper_extrq_i() argument
913 d->ZMM_Q(0) = helper_extrq(d->ZMM_Q(0), index, length); in helper_extrq_i()
923 mask = (1ULL << len) - 1; in helper_insertq()
928 void helper_insertq_r(CPUX86State *env, ZMMReg *d, ZMMReg *s) in helper_insertq_r() argument
930 d->ZMM_Q(0) = helper_insertq(d->ZMM_Q(0), s->ZMM_Q(0), s->ZMM_B(9) & 63, s->ZMM_B(8) & 63); in helper_insertq_r()
933 void helper_insertq_i(CPUX86State *env, ZMMReg *d, ZMMReg *s, int index, int length) in helper_insertq_i() argument
935 d->ZMM_Q(0) = helper_insertq(d->ZMM_Q(0), s->ZMM_Q(0), index, length); in helper_insertq_i()
940 void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
946 r[i + k] = F(v->ZMM_S(j + k), v->ZMM_S(j + k + 1), &env->sse_status); \
949 r[i + k] = F(s->ZMM_S(j + k), s->ZMM_S(j + k + 1), &env->sse_status); \
953 d->ZMM_S(i) = r[i]; \
961 void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \ in SSE_HELPER_HPS()
967 r[i + k] = F(v->ZMM_D(j + k), v->ZMM_D(j + k + 1), &env->sse_status); \ in SSE_HELPER_HPS()
970 r[i + k] = F(s->ZMM_D(j + k), s->ZMM_D(j + k + 1), &env->sse_status); \ in SSE_HELPER_HPS()
974 d->ZMM_D(i) = r[i]; \ in SSE_HELPER_HPS()
981 void glue(helper_addsubps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
985 d->ZMM_S(i) = float32_sub(v->ZMM_S(i), s->ZMM_S(i), &env->sse_status);
986 d->ZMM_S(i+1) = float32_add(v->ZMM_S(i+1), s->ZMM_S(i+1), &env->sse_status);
990 void glue(helper_addsubpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
994 d->ZMM_D(i) = float64_sub(v->ZMM_D(i), s->ZMM_D(i), &env->sse_status); in glue()
995 d->ZMM_D(i+1) = float64_add(v->ZMM_D(i+1), s->ZMM_D(i+1), &env->sse_status); in glue()
1001 Reg *d, Reg *v, Reg *s) \
1005 d->ZMM_L(i) = C(F(32, v->ZMM_S(i), s->ZMM_S(i))) ? -1 : 0; \
1010 Reg *d, Reg *v, Reg *s) \
1014 d->ZMM_Q(i) = C(F(64, v->ZMM_D(i), s->ZMM_D(i))) ? -1 : 0; \
1021 void helper_ ## name ## ss(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
1024 d->ZMM_L(0) = C(F(32, v->ZMM_S(0), s->ZMM_S(0))) ? -1 : 0; \
1026 d->ZMM_L(i) = v->ZMM_L(i); \
1030 void helper_ ## name ## sd(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
1033 d->ZMM_Q(0) = C(F(64, v->ZMM_D(0), s->ZMM_D(0))) ? -1 : 0; \
1035 d->ZMM_Q(i) = v->ZMM_Q(i); \
1056 float ## size ## _compare_quiet(a, b, &env->sse_status)
1058 float ## size ## _compare(a, b, &env->sse_status)
1105 void helper_ucomiss(CPUX86State *env, Reg *d, Reg *s) in helper_ucomiss() argument
1110 s0 = d->ZMM_S(0); in helper_ucomiss()
1111 s1 = s->ZMM_S(0); in helper_ucomiss()
1112 ret = float32_compare_quiet(s0, s1, &env->sse_status); in helper_ucomiss()
1117 void helper_comiss(CPUX86State *env, Reg *d, Reg *s) in helper_comiss() argument
1122 s0 = d->ZMM_S(0); in helper_comiss()
1123 s1 = s->ZMM_S(0); in helper_comiss()
1124 ret = float32_compare(s0, s1, &env->sse_status); in helper_comiss()
1129 void helper_ucomisd(CPUX86State *env, Reg *d, Reg *s) in helper_ucomisd() argument
1134 d0 = d->ZMM_D(0); in helper_ucomisd()
1135 d1 = s->ZMM_D(0); in helper_ucomisd()
1136 ret = float64_compare_quiet(d0, d1, &env->sse_status); in helper_ucomisd()
1141 void helper_comisd(CPUX86State *env, Reg *d, Reg *s) in helper_comisd() argument
1146 d0 = d->ZMM_D(0); in helper_comisd()
1147 d1 = s->ZMM_D(0); in helper_comisd()
1148 ret = float64_compare(d0, d1, &env->sse_status); in helper_comisd()
1161 mask |= (s->ZMM_L(i) >> (31 - i)) & (1 << i); in glue()
1173 mask |= (s->ZMM_Q(i) >> (63 - i)) & (1 << i); in glue()
1182 Reg *d, Reg *v, Reg *s) \
1188 r[k] = F((int16_t)v->W(j + k)); \
1191 r[PACK_WIDTH + k] = F((int16_t)s->W(j + k)); \
1194 d->B(2 * j + k) = r[k]; \
1202 void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in PACK_HELPER_B()
1209 r[k] = satsw(v->L(j + k)); in PACK_HELPER_B()
1212 r[PACK_WIDTH / 2 + k] = satsw(s->L(j + k)); in PACK_HELPER_B()
1215 d->W(2 * j + k) = r[k]; in PACK_HELPER_B()
1223 Reg *d, Reg *v, Reg *s) \
1231 r[2 * i] = v->B(k + i); \
1232 r[2 * i + 1] = s->B(k + i); \
1235 d->B(j) = r[i]; \
1241 Reg *d, Reg *v, Reg *s) \
1249 r[2 * i] = v->W(k + i); \
1250 r[2 * i + 1] = s->W(k + i); \
1253 d->W(j) = r[i]; \
1259 Reg *d, Reg *v, Reg *s) \
1267 r[2 * i] = v->L(k + i); \
1268 r[2 * i + 1] = s->L(k + i); \
1271 d->L(j) = r[i]; \
1278 CPUX86State *env, Reg *d, Reg *v, Reg *s) \
1284 r[0] = v->Q(base + i); \
1285 r[1] = s->Q(base + i); \
1286 d->Q(i) = r[0]; \
1287 d->Q(i + 1) = r[1]; \
1300 /* 3DNow! float ops */
1302 void helper_pi2fd(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pi2fd() argument
1304 d->MMX_S(0) = int32_to_float32(s->MMX_L(0), &env->mmx_status); in helper_pi2fd()
1305 d->MMX_S(1) = int32_to_float32(s->MMX_L(1), &env->mmx_status); in helper_pi2fd()
1308 void helper_pi2fw(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pi2fw() argument
1310 d->MMX_S(0) = int32_to_float32((int16_t)s->MMX_W(0), &env->mmx_status); in helper_pi2fw()
1311 d->MMX_S(1) = int32_to_float32((int16_t)s->MMX_W(2), &env->mmx_status); in helper_pi2fw()
1314 void helper_pf2id(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pf2id() argument
1316 d->MMX_L(0) = float32_to_int32_round_to_zero(s->MMX_S(0), &env->mmx_status); in helper_pf2id()
1317 d->MMX_L(1) = float32_to_int32_round_to_zero(s->MMX_S(1), &env->mmx_status); in helper_pf2id()
1320 void helper_pf2iw(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pf2iw() argument
1322 d->MMX_L(0) = satsw(float32_to_int32_round_to_zero(s->MMX_S(0), in helper_pf2iw()
1323 &env->mmx_status)); in helper_pf2iw()
1324 d->MMX_L(1) = satsw(float32_to_int32_round_to_zero(s->MMX_S(1), in helper_pf2iw()
1325 &env->mmx_status)); in helper_pf2iw()
1328 void helper_pfacc(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfacc() argument
1332 r = float32_add(d->MMX_S(0), d->MMX_S(1), &env->mmx_status); in helper_pfacc()
1333 d->MMX_S(1) = float32_add(s->MMX_S(0), s->MMX_S(1), &env->mmx_status); in helper_pfacc()
1334 d->MMX_S(0) = r; in helper_pfacc()
1337 void helper_pfadd(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfadd() argument
1339 d->MMX_S(0) = float32_add(d->MMX_S(0), s->MMX_S(0), &env->mmx_status); in helper_pfadd()
1340 d->MMX_S(1) = float32_add(d->MMX_S(1), s->MMX_S(1), &env->mmx_status); in helper_pfadd()
1343 void helper_pfcmpeq(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfcmpeq() argument
1345 d->MMX_L(0) = float32_eq_quiet(d->MMX_S(0), s->MMX_S(0), in helper_pfcmpeq()
1346 &env->mmx_status) ? -1 : 0; in helper_pfcmpeq()
1347 d->MMX_L(1) = float32_eq_quiet(d->MMX_S(1), s->MMX_S(1), in helper_pfcmpeq()
1348 &env->mmx_status) ? -1 : 0; in helper_pfcmpeq()
1351 void helper_pfcmpge(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfcmpge() argument
1353 d->MMX_L(0) = float32_le(s->MMX_S(0), d->MMX_S(0), in helper_pfcmpge()
1354 &env->mmx_status) ? -1 : 0; in helper_pfcmpge()
1355 d->MMX_L(1) = float32_le(s->MMX_S(1), d->MMX_S(1), in helper_pfcmpge()
1356 &env->mmx_status) ? -1 : 0; in helper_pfcmpge()
1359 void helper_pfcmpgt(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfcmpgt() argument
1361 d->MMX_L(0) = float32_lt(s->MMX_S(0), d->MMX_S(0), in helper_pfcmpgt()
1362 &env->mmx_status) ? -1 : 0; in helper_pfcmpgt()
1363 d->MMX_L(1) = float32_lt(s->MMX_S(1), d->MMX_S(1), in helper_pfcmpgt()
1364 &env->mmx_status) ? -1 : 0; in helper_pfcmpgt()
1367 void helper_pfmax(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfmax() argument
1369 if (float32_lt(d->MMX_S(0), s->MMX_S(0), &env->mmx_status)) { in helper_pfmax()
1370 d->MMX_S(0) = s->MMX_S(0); in helper_pfmax()
1372 if (float32_lt(d->MMX_S(1), s->MMX_S(1), &env->mmx_status)) { in helper_pfmax()
1373 d->MMX_S(1) = s->MMX_S(1); in helper_pfmax()
1377 void helper_pfmin(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfmin() argument
1379 if (float32_lt(s->MMX_S(0), d->MMX_S(0), &env->mmx_status)) { in helper_pfmin()
1380 d->MMX_S(0) = s->MMX_S(0); in helper_pfmin()
1382 if (float32_lt(s->MMX_S(1), d->MMX_S(1), &env->mmx_status)) { in helper_pfmin()
1383 d->MMX_S(1) = s->MMX_S(1); in helper_pfmin()
1387 void helper_pfmul(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfmul() argument
1389 d->MMX_S(0) = float32_mul(d->MMX_S(0), s->MMX_S(0), &env->mmx_status); in helper_pfmul()
1390 d->MMX_S(1) = float32_mul(d->MMX_S(1), s->MMX_S(1), &env->mmx_status); in helper_pfmul()
1393 void helper_pfnacc(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfnacc() argument
1397 r = float32_sub(d->MMX_S(0), d->MMX_S(1), &env->mmx_status); in helper_pfnacc()
1398 d->MMX_S(1) = float32_sub(s->MMX_S(0), s->MMX_S(1), &env->mmx_status); in helper_pfnacc()
1399 d->MMX_S(0) = r; in helper_pfnacc()
1402 void helper_pfpnacc(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfpnacc() argument
1406 r = float32_sub(d->MMX_S(0), d->MMX_S(1), &env->mmx_status); in helper_pfpnacc()
1407 d->MMX_S(1) = float32_add(s->MMX_S(0), s->MMX_S(1), &env->mmx_status); in helper_pfpnacc()
1408 d->MMX_S(0) = r; in helper_pfpnacc()
1411 void helper_pfrcp(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfrcp() argument
1413 d->MMX_S(0) = float32_div(float32_one, s->MMX_S(0), &env->mmx_status); in helper_pfrcp()
1414 d->MMX_S(1) = d->MMX_S(0); in helper_pfrcp()
1417 void helper_pfrsqrt(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfrsqrt() argument
1419 d->MMX_L(1) = s->MMX_L(0) & 0x7fffffff; in helper_pfrsqrt()
1420 d->MMX_S(1) = float32_div(float32_one, in helper_pfrsqrt()
1421 float32_sqrt(d->MMX_S(1), &env->mmx_status), in helper_pfrsqrt()
1422 &env->mmx_status); in helper_pfrsqrt()
1423 d->MMX_L(1) |= s->MMX_L(0) & 0x80000000; in helper_pfrsqrt()
1424 d->MMX_L(0) = d->MMX_L(1); in helper_pfrsqrt()
1427 void helper_pfsub(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfsub() argument
1429 d->MMX_S(0) = float32_sub(d->MMX_S(0), s->MMX_S(0), &env->mmx_status); in helper_pfsub()
1430 d->MMX_S(1) = float32_sub(d->MMX_S(1), s->MMX_S(1), &env->mmx_status); in helper_pfsub()
1433 void helper_pfsubr(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pfsubr() argument
1435 d->MMX_S(0) = float32_sub(s->MMX_S(0), d->MMX_S(0), &env->mmx_status); in helper_pfsubr()
1436 d->MMX_S(1) = float32_sub(s->MMX_S(1), d->MMX_S(1), &env->mmx_status); in helper_pfsubr()
1439 void helper_pswapd(CPUX86State *env, MMXReg *d, MMXReg *s) in helper_pswapd() argument
1443 r = s->MMX_L(0); in helper_pswapd()
1444 d->MMX_L(0) = s->MMX_L(1); in helper_pswapd()
1445 d->MMX_L(1) = r; in helper_pswapd()
1450 void glue(helper_pshufb, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
1457 r[i] = (s->B(i) & 0x80) ? 0 : (v->B(s->B(i) & 7)); in glue()
1460 d->B(i) = r[i]; in glue()
1467 r[i] = (s->B(i) & 0x80) ? 0 : v->B(j | (s->B(i) & 0xf)); in glue()
1470 d->B(i) = r[i]; in glue()
1476 void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
1482 r[i + k] = F(v->W(j + k), v->W(j + k + 1)); \
1485 r[i + k] = F(s->W(j + k), s->W(j + k + 1)); \
1489 d->W(i) = r[i]; \
1494 void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
1500 r[i + k] = F(v->L(j + k), v->L(j + k + 1)); \
1503 r[i + k] = F(s->L(j + k), s->L(j + k + 1)); \
1507 d->L(i) = r[i]; \
1521 void glue(helper_pmaddubsw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in SSE_HELPER_HW()
1525 d->W(i) = satsw((int8_t)s->B(i * 2) * (uint8_t)v->B(i * 2) + in SSE_HELPER_HW()
1526 (int8_t)s->B(i * 2 + 1) * (uint8_t)v->B(i * 2 + 1)); in SSE_HELPER_HW()
1530 #define FMULHRSW(d, s) (((int16_t) d * (int16_t)s + 0x4000) >> 15) argument
1533 #define FSIGNB(d, s) (s <= INT8_MAX ? s ? d : 0 : -(int8_t)d) in SSE_HELPER_W() argument
1534 #define FSIGNW(d, s) (s <= INT16_MAX ? s ? d : 0 : -(int16_t)d) in SSE_HELPER_W() argument
1535 #define FSIGNL(d, s) (s <= INT32_MAX ? s ? d : 0 : -(int32_t)d) in SSE_HELPER_W() argument
1540 void glue(helper_palignr, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, in SSE_HELPER_W()
1548 d->Q(i) = 0; in SSE_HELPER_W()
1552 #define SHR(v, i) (i < 64 && i > -64 ? i > 0 ? v >> (i) : (v << -(i)) : 0) in SSE_HELPER_W()
1554 d->Q(0) = SHR(s->Q(0), shift - 0) | in SSE_HELPER_W()
1555 SHR(v->Q(0), shift - 64); in SSE_HELPER_W()
1560 r0 = SHR(s->Q(i), shift - 0) | in SSE_HELPER_W()
1561 SHR(s->Q(i + 1), shift - 64) | in SSE_HELPER_W()
1562 SHR(v->Q(i), shift - 128) | in SSE_HELPER_W()
1563 SHR(v->Q(i + 1), shift - 192); in SSE_HELPER_W()
1564 r1 = SHR(s->Q(i), shift + 64) | in SSE_HELPER_W()
1565 SHR(s->Q(i + 1), shift - 0) | in SSE_HELPER_W()
1566 SHR(v->Q(i), shift - 64) | in SSE_HELPER_W()
1567 SHR(v->Q(i + 1), shift - 128); in SSE_HELPER_W()
1568 d->Q(i) = r0; in SSE_HELPER_W()
1569 d->Q(i + 1) = r1; in SSE_HELPER_W()
1579 void glue(name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, \
1584 d->elem(i) = F(v->elem(i), s->elem(i), m->elem(i)); \
1589 void glue(name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, \
1595 d->elem(i) = F(v->elem(i), s->elem(i), (imm >> j) & 1); \
1607 void glue(helper_ptest, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
1613 zf |= (s->Q(i) & d->Q(i)); in glue()
1614 cf |= (s->Q(i) & ~d->Q(i)); in glue()
1620 #define FMOVSLDUP(i) s->L((i) & ~1)
1621 #define FMOVSHDUP(i) s->L((i) | 1)
1622 #define FMOVDLDUP(i) s->Q((i) & ~1)
1625 void glue(name, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) \
1628 for (int i = n; --i >= 0; ) { \
1629 d->elem(i) = F(i); \
1634 SSE_HELPER_F(helper_pmovsxbw, W, 4 << SHIFT, (int8_t) s->B)
1635 SSE_HELPER_F(helper_pmovsxbd, L, 2 << SHIFT, (int8_t) s->B)
1636 SSE_HELPER_F(helper_pmovsxbq, Q, 1 << SHIFT, (int8_t) s->B)
1637 SSE_HELPER_F(helper_pmovsxwd, L, 2 << SHIFT, (int16_t) s->W)
1638 SSE_HELPER_F(helper_pmovsxwq, Q, 1 << SHIFT, (int16_t) s->W)
1639 SSE_HELPER_F(helper_pmovsxdq, Q, 1 << SHIFT, (int32_t) s->L)
1640 SSE_HELPER_F(helper_pmovzxbw, W, 4 << SHIFT, s->B)
1641 SSE_HELPER_F(helper_pmovzxbd, L, 2 << SHIFT, s->B)
1642 SSE_HELPER_F(helper_pmovzxbq, Q, 1 << SHIFT, s->B)
1643 SSE_HELPER_F(helper_pmovzxwd, L, 2 << SHIFT, s->W)
1644 SSE_HELPER_F(helper_pmovzxwq, Q, 1 << SHIFT, s->W)
1645 SSE_HELPER_F(helper_pmovzxdq, Q, 1 << SHIFT, s->L)
1651 void glue(helper_pmuldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
1656 d->Q(i) = (int64_t)(int32_t) v->L(2 * i) * (int32_t) s->L(2 * i); in glue()
1660 void glue(helper_packusdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
1666 r[0] = satuw(v->L(j)); in glue()
1667 r[1] = satuw(v->L(j + 1)); in glue()
1668 r[2] = satuw(v->L(j + 2)); in glue()
1669 r[3] = satuw(v->L(j + 3)); in glue()
1670 r[4] = satuw(s->L(j)); in glue()
1671 r[5] = satuw(s->L(j + 1)); in glue()
1672 r[6] = satuw(s->L(j + 2)); in glue()
1673 r[7] = satuw(s->L(j + 3)); in glue()
1675 d->W(i + k) = r[k]; in glue()
1681 void glue(helper_phminposuw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
1685 if (s->W(1) < s->W(idx)) { in glue()
1688 if (s->W(2) < s->W(idx)) { in glue()
1691 if (s->W(3) < s->W(idx)) { in glue()
1692 idx = 3; in glue()
1694 if (s->W(4) < s->W(idx)) { in glue()
1697 if (s->W(5) < s->W(idx)) { in glue()
1700 if (s->W(6) < s->W(idx)) { in glue()
1703 if (s->W(7) < s->W(idx)) { in glue()
1707 d->W(0) = s->W(idx); in glue()
1708 d->W(1) = idx; in glue()
1709 d->L(1) = 0; in glue()
1710 d->Q(1) = 0; in glue()
1714 void glue(helper_roundps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
1717 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in glue()
1721 prev_rounding_mode = env->sse_status.float_rounding_mode; in glue()
1723 set_x86_rounding_mode(mode & 3, &env->sse_status); in glue()
1727 d->ZMM_S(i) = float32_round_to_int(s->ZMM_S(i), &env->sse_status); in glue()
1730 if (mode & (1 << 3) && !(old_flags & float_flag_inexact)) { in glue()
1731 set_float_exception_flags(get_float_exception_flags(&env->sse_status) & in glue()
1733 &env->sse_status); in glue()
1735 env->sse_status.float_rounding_mode = prev_rounding_mode; in glue()
1738 void glue(helper_roundpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
1741 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in glue()
1745 prev_rounding_mode = env->sse_status.float_rounding_mode; in glue()
1747 set_x86_rounding_mode(mode & 3, &env->sse_status); in glue()
1751 d->ZMM_D(i) = float64_round_to_int(s->ZMM_D(i), &env->sse_status); in glue()
1754 if (mode & (1 << 3) && !(old_flags & float_flag_inexact)) { in glue()
1755 set_float_exception_flags(get_float_exception_flags(&env->sse_status) & in glue()
1757 &env->sse_status); in glue()
1759 env->sse_status.float_rounding_mode = prev_rounding_mode; in glue()
1763 void glue(helper_roundss, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, in glue()
1766 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in glue()
1770 prev_rounding_mode = env->sse_status.float_rounding_mode; in glue()
1772 set_x86_rounding_mode(mode & 3, &env->sse_status); in glue()
1775 d->ZMM_S(0) = float32_round_to_int(s->ZMM_S(0), &env->sse_status); in glue()
1777 d->ZMM_L(i) = v->ZMM_L(i); in glue()
1780 if (mode & (1 << 3) && !(old_flags & float_flag_inexact)) { in glue()
1781 set_float_exception_flags(get_float_exception_flags(&env->sse_status) & in glue()
1783 &env->sse_status); in glue()
1785 env->sse_status.float_rounding_mode = prev_rounding_mode; in glue()
1788 void glue(helper_roundsd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, in glue()
1791 uint8_t old_flags = get_float_exception_flags(&env->sse_status); in glue()
1795 prev_rounding_mode = env->sse_status.float_rounding_mode; in glue()
1797 set_x86_rounding_mode(mode & 3, &env->sse_status); in glue()
1800 d->ZMM_D(0) = float64_round_to_int(s->ZMM_D(0), &env->sse_status); in glue()
1802 d->ZMM_Q(i) = v->ZMM_Q(i); in glue()
1805 if (mode & (1 << 3) && !(old_flags & float_flag_inexact)) { in glue()
1806 set_float_exception_flags(get_float_exception_flags(&env->sse_status) & in glue()
1808 &env->sse_status); in glue()
1810 env->sse_status.float_rounding_mode = prev_rounding_mode; in glue()
1819 void glue(helper_dpps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, in glue()
1827 * We must evaluate (A+B)+(C+D), not ((A+B)+C)+D in glue()
1831 prod1 = float32_mul(v->ZMM_S(i), s->ZMM_S(i), &env->sse_status); in glue()
1836 prod2 = float32_mul(v->ZMM_S(i+1), s->ZMM_S(i+1), &env->sse_status); in glue()
1840 temp2 = float32_add(prod1, prod2, &env->sse_status); in glue()
1842 prod1 = float32_mul(v->ZMM_S(i+2), s->ZMM_S(i+2), &env->sse_status); in glue()
1847 prod2 = float32_mul(v->ZMM_S(i+3), s->ZMM_S(i+3), &env->sse_status); in glue()
1851 temp3 = float32_add(prod1, prod2, &env->sse_status); in glue()
1852 temp4 = float32_add(temp2, temp3, &env->sse_status); in glue()
1854 d->ZMM_S(i) = (mask & (1 << 0)) ? temp4 : float32_zero; in glue()
1855 d->ZMM_S(i+1) = (mask & (1 << 1)) ? temp4 : float32_zero; in glue()
1856 d->ZMM_S(i+2) = (mask & (1 << 2)) ? temp4 : float32_zero; in glue()
1857 d->ZMM_S(i+3) = (mask & (1 << 3)) ? temp4 : float32_zero; in glue()
1864 Reg *d, Reg *v, Reg *s, uint32_t mask) in glue()
1869 prod1 = float64_mul(v->ZMM_D(0), s->ZMM_D(0), &env->sse_status); in glue()
1874 prod2 = float64_mul(v->ZMM_D(1), s->ZMM_D(1), &env->sse_status); in glue()
1878 temp2 = float64_add(prod1, prod2, &env->sse_status); in glue()
1879 d->ZMM_D(0) = (mask & (1 << 0)) ? temp2 : float64_zero; in glue()
1880 d->ZMM_D(1) = (mask & (1 << 1)) ? temp2 : float64_zero; in glue()
1884 void glue(helper_mpsadbw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, in glue()
1891 int s0 = (j * 2) + ((offset & 3) << 2); in glue()
1895 r[i] += abs1(v->B(d0 + 0) - s->B(s0 + 0)); in glue()
1896 r[i] += abs1(v->B(d0 + 1) - s->B(s0 + 1)); in glue()
1897 r[i] += abs1(v->B(d0 + 2) - s->B(s0 + 2)); in glue()
1898 r[i] += abs1(v->B(d0 + 3) - s->B(s0 + 3)); in glue()
1901 d->W(j) = r[i]; in glue()
1903 offset >>= 3; in glue()
1915 val = (target_long)env->regs[reg]; in pcmp_elen()
1917 val = (int32_t)env->regs[reg]; in pcmp_elen()
1924 if ((val > limit) || (val < -limit)) { in pcmp_elen()
1935 while (val < 8 && r->W(val)) { in pcmp_ilen()
1939 while (val < 16 && r->B(val)) { in pcmp_ilen()
1949 switch ((ctrl >> 0) & 3) { in pcmp_val()
1951 return r->B(i); in pcmp_val()
1953 return r->W(i); in pcmp_val()
1955 return (int8_t)r->B(i); in pcmp_val()
1956 case 3: in pcmp_val()
1958 return (int16_t)r->W(i); in pcmp_val()
1962 static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s, in pcmpxstrx() argument
1970 valids--; in pcmpxstrx()
1971 validd--; in pcmpxstrx()
1976 switch ((ctrl >> 2) & 3) { in pcmpxstrx()
1978 for (j = valids; j >= 0; j--) { in pcmpxstrx()
1981 for (i = validd; i >= 0; i--) { in pcmpxstrx()
1982 res |= (v == pcmp_val(d, ctrl, i)); in pcmpxstrx()
1987 for (j = valids; j >= 0; j--) { in pcmpxstrx()
1990 for (i = ((validd - 1) | 1); i >= 0; i -= 2) { in pcmpxstrx()
1991 res |= (pcmp_val(d, ctrl, i - 0) >= v && in pcmpxstrx()
1992 pcmp_val(d, ctrl, i - 1) <= v); in pcmpxstrx()
1997 res = (1 << (upper - MAX(valids, validd))) - 1; in pcmpxstrx()
1998 res <<= MAX(valids, validd) - MIN(valids, validd); in pcmpxstrx()
1999 for (i = MIN(valids, validd); i >= 0; i--) { in pcmpxstrx()
2002 res |= (v == pcmp_val(d, ctrl, i)); in pcmpxstrx()
2005 case 3: in pcmpxstrx()
2006 if (validd == -1) { in pcmpxstrx()
2007 res = (2 << upper) - 1; in pcmpxstrx()
2010 for (j = valids == upper ? valids : valids - validd; j >= 0; j--) { in pcmpxstrx()
2013 for (i = MIN(valids - j, validd); i >= 0; i--) { in pcmpxstrx()
2014 v &= (pcmp_val(s, ctrl, i + j) == pcmp_val(d, ctrl, i)); in pcmpxstrx()
2021 switch ((ctrl >> 4) & 3) { in pcmpxstrx()
2023 res ^= (2 << upper) - 1; in pcmpxstrx()
2025 case 3: in pcmpxstrx()
2026 res ^= (1 << (valids + 1)) - 1; in pcmpxstrx()
2040 void glue(helper_pcmpestri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
2043 unsigned int res = pcmpxstrx(env, d, s, ctrl, in glue()
2048 env->regs[R_ECX] = (ctrl & (1 << 6)) ? 31 - clz32(res) : ctz32(res); in glue()
2050 env->regs[R_ECX] = 16 >> (ctrl & (1 << 0)); in glue()
2054 void glue(helper_pcmpestrm, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
2058 unsigned int res = pcmpxstrx(env, d, s, ctrl, in glue()
2065 env->xmm_regs[0].W(i) = (res & 1) ? ~0 : 0; in glue()
2069 env->xmm_regs[0].B(i) = (res & 1) ? ~0 : 0; in glue()
2073 env->xmm_regs[0].Q(1) = 0; in glue()
2074 env->xmm_regs[0].Q(0) = res; in glue()
2078 void glue(helper_pcmpistri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
2081 unsigned int res = pcmpxstrx(env, d, s, ctrl, in glue()
2083 pcmp_ilen(d, ctrl)); in glue()
2086 env->regs[R_ECX] = (ctrl & (1 << 6)) ? 31 - clz32(res) : ctz32(res); in glue()
2088 env->regs[R_ECX] = 16 >> (ctrl & (1 << 0)); in glue()
2092 void glue(helper_pcmpistrm, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
2096 unsigned int res = pcmpxstrx(env, d, s, ctrl, in glue()
2098 pcmp_ilen(d, ctrl)); in glue()
2103 env->xmm_regs[0].W(i) = (res & 1) ? ~0 : 0; in glue()
2107 env->xmm_regs[0].B(i) = (res & 1) ? ~0 : 0; in glue()
2111 env->xmm_regs[0].Q(1) = 0; in glue()
2112 env->xmm_regs[0].Q(0) = res; in glue()
2120 target_ulong crc = (msg & ((target_ulong) -1 >> in helper_crc32()
2121 (TARGET_LONG_BITS - len))) ^ crc1; in helper_crc32()
2123 while (len--) { in helper_crc32()
2132 void glue(helper_pclmulqdq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s, in glue()
2139 uint64_t a = v->Q(2 * i + a_idx); in glue()
2140 uint64_t b = s->Q(2 * i + b_idx); in glue()
2141 Int128 *r = (Int128 *)&d->ZMM_X(i); in glue()
2147 void glue(helper_aesdec, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2150 AESState *ad = (AESState *)&d->ZMM_X(i); in glue()
2151 AESState *st = (AESState *)&v->ZMM_X(i); in glue()
2152 AESState *rk = (AESState *)&s->ZMM_X(i); in glue()
2158 void glue(helper_aesdeclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2161 AESState *ad = (AESState *)&d->ZMM_X(i); in glue()
2162 AESState *st = (AESState *)&v->ZMM_X(i); in glue()
2163 AESState *rk = (AESState *)&s->ZMM_X(i); in glue()
2169 void glue(helper_aesenc, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2172 AESState *ad = (AESState *)&d->ZMM_X(i); in glue()
2173 AESState *st = (AESState *)&v->ZMM_X(i); in glue()
2174 AESState *rk = (AESState *)&s->ZMM_X(i); in glue()
2180 void glue(helper_aesenclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2183 AESState *ad = (AESState *)&d->ZMM_X(i); in glue()
2184 AESState *st = (AESState *)&v->ZMM_X(i); in glue()
2185 AESState *rk = (AESState *)&s->ZMM_X(i); in glue()
2192 void glue(helper_aesimc, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
2194 AESState *ad = (AESState *)&d->ZMM_X(0); in glue()
2195 AESState *st = (AESState *)&s->ZMM_X(0); in glue()
2200 void glue(helper_aeskeygenassist, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, in glue()
2207 d->B(i) = AES_sbox[tmp.B(i + 4)]; in glue()
2208 d->B(i + 8) = AES_sbox[tmp.B(i + 12)]; in glue()
2210 d->L(1) = (d->L(0) << 24 | d->L(0) >> 8) ^ ctrl; in glue()
2211 d->L(3) = (d->L(2) << 24 | d->L(2) >> 8) ^ ctrl; in glue()
2217 void glue(helper_vpermilpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2223 r0 = v->Q(i + ((s->Q(i) >> 1) & 1)); in glue()
2224 r1 = v->Q(i + ((s->Q(i+1) >> 1) & 1)); in glue()
2225 d->Q(i) = r0; in glue()
2226 d->Q(i+1) = r1; in glue()
2230 void glue(helper_vpermilps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2236 r0 = v->L(i + (s->L(i) & 3)); in glue()
2237 r1 = v->L(i + (s->L(i+1) & 3)); in glue()
2238 r2 = v->L(i + (s->L(i+2) & 3)); in glue()
2239 r3 = v->L(i + (s->L(i+3) & 3)); in glue()
2240 d->L(i) = r0; in glue()
2241 d->L(i+1) = r1; in glue()
2242 d->L(i+2) = r2; in glue()
2243 d->L(i+3) = r3; in glue()
2247 void glue(helper_vpermilpd_imm, SUFFIX)(Reg *d, Reg *s, uint32_t order) in glue()
2253 r0 = s->Q(i + ((order >> 0) & 1)); in glue()
2254 r1 = s->Q(i + ((order >> 1) & 1)); in glue()
2255 d->Q(i) = r0; in glue()
2256 d->Q(i+1) = r1; in glue()
2262 void glue(helper_vpermilps_imm, SUFFIX)(Reg *d, Reg *s, uint32_t order) in glue()
2268 r0 = s->L(i + ((order >> 0) & 3)); in glue()
2269 r1 = s->L(i + ((order >> 2) & 3)); in glue()
2270 r2 = s->L(i + ((order >> 4) & 3)); in glue()
2271 r3 = s->L(i + ((order >> 6) & 3)); in glue()
2272 d->L(i) = r0; in glue()
2273 d->L(i+1) = r1; in glue()
2274 d->L(i+2) = r2; in glue()
2275 d->L(i+3) = r3; in glue()
2296 void glue(helper_vtestps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in SSE_HELPER_L()
2302 zf |= (s->L(i) & d->L(i)); in SSE_HELPER_L()
2303 cf |= (s->L(i) & ~d->L(i)); in SSE_HELPER_L()
2309 void glue(helper_vtestpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) in glue()
2315 zf |= (s->Q(i) & d->Q(i)); in glue()
2316 cf |= (s->Q(i) & ~d->Q(i)); in glue()
2328 if (v->L(i) >> 31) { in glue()
2329 cpu_stl_data_ra(env, a0 + i * 4, s->L(i), GETPC()); in glue()
2340 if (v->Q(i) >> 63) { in glue()
2341 cpu_stq_data_ra(env, a0 + i * 8, s->Q(i), GETPC()); in glue()
2346 void glue(helper_vpmaskmovd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2351 d->L(i) = (v->L(i) >> 31) ? s->L(i) : 0; in glue()
2355 void glue(helper_vpmaskmovq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) in glue()
2360 d->Q(i) = (v->Q(i) >> 63) ? s->Q(i) : 0; in glue()
2365 Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale) in glue()
2369 if (v->L(i) >> 31) { in glue()
2371 + ((target_ulong)(int32_t)s->L(i) << scale); in glue()
2372 d->L(i) = cpu_ldl_data_ra(env, addr, GETPC()); in glue()
2374 v->L(i) = 0; in glue()
2379 Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale) in glue()
2383 if (v->Q(i) >> 63) { in glue()
2385 + ((target_ulong)(int32_t)s->L(i) << scale); in glue()
2386 d->Q(i) = cpu_ldq_data_ra(env, addr, GETPC()); in glue()
2388 v->Q(i) = 0; in glue()
2393 Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale) in glue()
2397 if (v->L(i) >> 31) { in glue()
2399 + ((target_ulong)(int64_t)s->Q(i) << scale); in glue()
2400 d->L(i) = cpu_ldl_data_ra(env, addr, GETPC()); in glue()
2402 v->L(i) = 0; in glue()
2405 d->Q(i) = 0; in glue()
2406 v->Q(i) = 0; in glue()
2411 Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale) in glue()
2415 if (v->Q(i) >> 63) { in glue()
2417 + ((target_ulong)(int64_t)s->Q(i) << scale); in glue()
2418 d->Q(i) = cpu_ldq_data_ra(env, addr, GETPC()); in glue()
2420 v->Q(i) = 0; in glue()
2426 void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order) in helper_vpermdq_ymm() argument
2430 switch (order & 3) { in helper_vpermdq_ymm()
2432 r0 = v->Q(0); in helper_vpermdq_ymm()
2433 r1 = v->Q(1); in helper_vpermdq_ymm()
2436 r0 = v->Q(2); in helper_vpermdq_ymm()
2437 r1 = v->Q(3); in helper_vpermdq_ymm()
2440 r0 = s->Q(0); in helper_vpermdq_ymm()
2441 r1 = s->Q(1); in helper_vpermdq_ymm()
2443 case 3: in helper_vpermdq_ymm()
2444 r0 = s->Q(2); in helper_vpermdq_ymm()
2445 r1 = s->Q(3); in helper_vpermdq_ymm()
2450 switch ((order >> 4) & 3) { in helper_vpermdq_ymm()
2452 r2 = v->Q(0); in helper_vpermdq_ymm()
2453 r3 = v->Q(1); in helper_vpermdq_ymm()
2456 r2 = v->Q(2); in helper_vpermdq_ymm()
2457 r3 = v->Q(3); in helper_vpermdq_ymm()
2460 r2 = s->Q(0); in helper_vpermdq_ymm()
2461 r3 = s->Q(1); in helper_vpermdq_ymm()
2463 case 3: in helper_vpermdq_ymm()
2464 r2 = s->Q(2); in helper_vpermdq_ymm()
2465 r3 = s->Q(3); in helper_vpermdq_ymm()
2470 d->Q(0) = r0; in helper_vpermdq_ymm()
2471 d->Q(1) = r1; in helper_vpermdq_ymm()
2472 d->Q(2) = r2; in helper_vpermdq_ymm()
2473 d->Q(3) = r3; in helper_vpermdq_ymm()
2475 d->Q(0) = 0; in helper_vpermdq_ymm()
2476 d->Q(1) = 0; in helper_vpermdq_ymm()
2479 d->Q(2) = 0; in helper_vpermdq_ymm()
2480 d->Q(3) = 0; in helper_vpermdq_ymm()
2484 void helper_vpermq_ymm(Reg *d, Reg *s, uint32_t order) in helper_vpermq_ymm() argument
2487 r0 = s->Q(order & 3); in helper_vpermq_ymm()
2488 r1 = s->Q((order >> 2) & 3); in helper_vpermq_ymm()
2489 r2 = s->Q((order >> 4) & 3); in helper_vpermq_ymm()
2490 r3 = s->Q((order >> 6) & 3); in helper_vpermq_ymm()
2491 d->Q(0) = r0; in helper_vpermq_ymm()
2492 d->Q(1) = r1; in helper_vpermq_ymm()
2493 d->Q(2) = r2; in helper_vpermq_ymm()
2494 d->Q(3) = r3; in helper_vpermq_ymm()
2497 void helper_vpermd_ymm(Reg *d, Reg *v, Reg *s) in helper_vpermd_ymm() argument
2503 r[i] = s->L(v->L(i) & 7); in helper_vpermd_ymm()
2506 d->L(i) = r[i]; in helper_vpermd_ymm()
2514 void name(CPUX86State *env, Reg *d, Reg *a, Reg *b, Reg *c, int flags) \
2516 d->elem(0) = F(a->elem(0), b->elem(0), c->elem(0), flags, &env->sse_status); \
2519 void glue(name, SUFFIX)(CPUX86State *env, Reg *d, Reg *a, Reg *b, Reg *c, \
2524 d->elem(i) = F(a->elem(i), b->elem(i), c->elem(i), flags, &env->sse_status); \
2540 void name(Reg *d, Reg *a, Reg *b) \ in SSE_HELPER_FMAS()
2542 uint32_t A, B, C, D, E, t, i; \ in SSE_HELPER_FMAS()
2544 A = a->L(3); \ in SSE_HELPER_FMAS()
2545 B = a->L(2); \ in SSE_HELPER_FMAS()
2546 C = a->L(1); \ in SSE_HELPER_FMAS()
2547 D = a->L(0); \ in SSE_HELPER_FMAS()
2550 for (i = 0; i <= 3; i++) { \ in SSE_HELPER_FMAS()
2551 t = F(B, C, D) + rol32(A, 5) + b->L(3 - i) + E + K; \ in SSE_HELPER_FMAS()
2552 E = D; \ in SSE_HELPER_FMAS()
2553 D = C; \ in SSE_HELPER_FMAS()
2559 d->L(3) = A; \ in SSE_HELPER_FMAS()
2560 d->L(2) = B; \ in SSE_HELPER_FMAS()
2561 d->L(1) = C; \ in SSE_HELPER_FMAS()
2562 d->L(0) = D; \ in SSE_HELPER_FMAS()
2565 #define SHA1_F0(b, c, d) (((b) & (c)) ^ (~(b) & (d))) argument
2566 #define SHA1_F1(b, c, d) ((b) ^ (c) ^ (d)) argument
2567 #define SHA1_F2(b, c, d) (((b) & (c)) ^ ((b) & (d)) ^ ((c) & (d))) argument
2574 void helper_sha1nexte(Reg *d, Reg *a, Reg *b)
2576 d->L(3) = b->L(3) + rol32(a->L(3), 30);
2577 d->L(2) = b->L(2);
2578 d->L(1) = b->L(1);
2579 d->L(0) = b->L(0);
2582 void helper_sha1msg1(Reg *d, Reg *a, Reg *b) in helper_sha1msg1() argument
2585 uint32_t b3 = b->L(3); in helper_sha1msg1()
2586 uint32_t b2 = b->L(2); in helper_sha1msg1()
2588 d->L(3) = a->L(3) ^ a->L(1); in helper_sha1msg1()
2589 d->L(2) = a->L(2) ^ a->L(0); in helper_sha1msg1()
2590 d->L(1) = a->L(1) ^ b3; in helper_sha1msg1()
2591 d->L(0) = a->L(0) ^ b2; in helper_sha1msg1()
2594 void helper_sha1msg2(Reg *d, Reg *a, Reg *b) in helper_sha1msg2() argument
2596 d->L(3) = rol32(a->L(3) ^ b->L(2), 1); in helper_sha1msg2()
2597 d->L(2) = rol32(a->L(2) ^ b->L(1), 1); in helper_sha1msg2()
2598 d->L(1) = rol32(a->L(1) ^ b->L(0), 1); in helper_sha1msg2()
2599 d->L(0) = rol32(a->L(0) ^ d->L(3), 1); in helper_sha1msg2()
2607 #define SHA256_MSGS0(w) (ror32((w), 7) ^ ror32((w), 18) ^ ((w) >> 3))
2610 void helper_sha256rnds2(Reg *d, Reg *a, Reg *b, uint32_t wk0, uint32_t wk1) in helper_sha256rnds2() argument
2614 uint32_t A = b->L(3); in helper_sha256rnds2()
2615 uint32_t B = b->L(2); in helper_sha256rnds2()
2616 uint32_t C = a->L(3); in helper_sha256rnds2()
2617 uint32_t D = a->L(2); in helper_sha256rnds2() local
2618 uint32_t E = b->L(1); in helper_sha256rnds2()
2619 uint32_t F = b->L(0); in helper_sha256rnds2()
2620 uint32_t G = a->L(1); in helper_sha256rnds2()
2621 uint32_t H = a->L(0); in helper_sha256rnds2()
2626 EE = t + D; in helper_sha256rnds2()
2629 d->L(2) = AA; in helper_sha256rnds2()
2630 d->L(0) = EE; in helper_sha256rnds2()
2632 D = C, C = B, B = A, A = AA; in helper_sha256rnds2()
2638 EE = t + D; in helper_sha256rnds2()
2640 d->L(3) = AA; in helper_sha256rnds2()
2641 d->L(1) = EE; in helper_sha256rnds2()
2644 void helper_sha256msg1(Reg *d, Reg *a, Reg *b) in helper_sha256msg1() argument
2646 /* b->L(0) could be overwritten by the first assignment, save it. */ in helper_sha256msg1()
2647 uint32_t b0 = b->L(0); in helper_sha256msg1()
2649 d->L(0) = a->L(0) + SHA256_MSGS0(a->L(1)); in helper_sha256msg1()
2650 d->L(1) = a->L(1) + SHA256_MSGS0(a->L(2)); in helper_sha256msg1()
2651 d->L(2) = a->L(2) + SHA256_MSGS0(a->L(3)); in helper_sha256msg1()
2652 d->L(3) = a->L(3) + SHA256_MSGS0(b0); in helper_sha256msg1()
2655 void helper_sha256msg2(Reg *d, Reg *a, Reg *b) in helper_sha256msg2() argument
2658 d->L(0) = a->L(0) + SHA256_MSGS1(b->L(2)); in helper_sha256msg2()
2659 d->L(1) = a->L(1) + SHA256_MSGS1(b->L(3)); in helper_sha256msg2()
2661 d->L(2) = a->L(2) + SHA256_MSGS1(d->L(0)); in helper_sha256msg2()
2662 d->L(3) = a->L(3) + SHA256_MSGS1(d->L(1)); in helper_sha256msg2()