6#if defined(TARGET_ARCH_IA32)
15#define EXPECT_DISASSEMBLY(expected)
17#define EXPECT_DISASSEMBLY(expected) \
18 EXPECT_STREQ(expected, test->RelativeDisassembly())
27 __ movl(
EAX, Immediate(42));
32 typedef int (*SimpleCode)();
33 EXPECT_EQ(42,
reinterpret_cast<SimpleCode
>(
test->entry())());
45 typedef int (*ReadArgumentCode)(
int n);
46 EXPECT_EQ(42,
reinterpret_cast<ReadArgumentCode
>(
test->entry())(42));
47 EXPECT_EQ(87,
reinterpret_cast<ReadArgumentCode
>(
test->entry())(87));
116 "mov eax,[esp+0x4]\n"
117 "mov eax,[ebp+0x4]\n"
118 "mov eax,[eax+0x4]\n"
119 "mov eax,[esp-0x4]\n"
120 "mov eax,[ebp-0x4]\n"
121 "mov eax,[eax-0x4]\n"
122 "mov eax,[esp+0x400]\n"
123 "mov eax,[ebp+0x400]\n"
124 "mov eax,[eax+0x400]\n"
125 "mov eax,[esp-0x400]\n"
126 "mov eax,[ebp-0x400]\n"
127 "mov eax,[eax-0x400]\n"
129 "mov eax,[eax+0x1]\n"
130 "mov eax,[eax+0x2]\n"
131 "mov eax,[eax+0x3]\n"
132 "mov eax,[ebp+0x1]\n"
133 "mov eax,[eax+0x1]\n"
134 "mov eax,[ebp*2+0x4]\n"
135 "mov eax,[eax*2+0x4]\n"
136 "mov eax,[ebp*2+0x400]\n"
137 "mov eax,[eax*2+0x400]\n"
138 "mov eax,[eax+ebp*2]\n"
139 "mov eax,[eax+eax*2]\n"
140 "mov eax,[ebp+ebp*2+0]\n"
141 "mov eax,[ebp+eax*2+0]\n"
142 "mov eax,[esp+ebp*2]\n"
143 "mov eax,[esp+eax*2]\n"
144 "mov eax,[eax+ebp*2+0x4]\n"
145 "mov eax,[eax+eax*2+0x4]\n"
146 "mov eax,[ebp+ebp*2+0x4]\n"
147 "mov eax,[ebp+eax*2+0x4]\n"
148 "mov eax,[esp+ebp*2+0x4]\n"
149 "mov eax,[esp+eax*2+0x4]\n"
150 "mov eax,[eax+ebp*2+0x400]\n"
151 "mov eax,[eax+eax*2+0x400]\n"
152 "mov eax,[ebp+ebp*2+0x400]\n"
153 "mov eax,[ebp+eax*2+0x400]\n"
154 "mov eax,[esp+ebp*2+0x400]\n"
155 "mov eax,[esp+eax*2+0x400]\n");
162 condition =
static_cast<Condition>(condition + 1)) {
170 __ movl(
EAX, Immediate(0));
179 EXPECT(!instr->IsBreakPoint());
180 typedef void (*JumpAroundCrashCode)();
181 reinterpret_cast<JumpAroundCrashCode
>(
test->entry())();
209 condition =
static_cast<Condition>(condition + 1)) {
217 __ movl(
EAX, Immediate(0));
225 typedef void (*NearJumpAroundCrashCode)();
226 reinterpret_cast<NearJumpAroundCrashCode
>(
test->entry())();
251 __ movl(
EAX, Immediate(0));
252 __ movl(
ECX, Immediate(0));
255 __ addl(
EAX, Immediate(2));
257 __ cmpl(
ECX, Immediate(87));
263 typedef int (*SimpleLoopCode)();
264 EXPECT_EQ(2 * 87,
reinterpret_cast<SimpleLoopCode
>(
test->entry())());
277 __ movl(
EAX, Immediate(1));
278 __ pushl(Immediate(0xffffff11));
279 __ cmpb(Address(
ESP, 0), Immediate(0x11));
281 __ movl(
EAX, Immediate(0));
288 typedef int (*CmpbCode)();
289 EXPECT_EQ(1,
reinterpret_cast<CmpbCode
>(
test->entry())());
301 __ movl(
EAX, Immediate(1));
302 __ movl(
ECX, Immediate(0));
303 __ pushl(Immediate(0xffffff11));
304 __ testb(Address(
ESP, 0), Immediate(0x10));
307 __ testb(Address(
ESP, 0), Immediate(0x20));
315 typedef int (*TestbCode)();
316 EXPECT_EQ(1,
reinterpret_cast<TestbCode
>(
test->entry())());
330 __ movl(
ECX, Immediate(12));
336 typedef int (*BsfCode)();
337 EXPECT_EQ(2,
reinterpret_cast<BsfCode
>(
test->entry())());
345 __ movl(
ECX, Immediate(12));
351 typedef int (*BsrCode)();
352 EXPECT_EQ(3,
reinterpret_cast<BsrCode
>(
test->entry())());
360 __ movl(
ECX, Immediate(-1));
362 __ movl(
ECX, Immediate(0xf));
372 typedef int (*PopcntCode)();
373 EXPECT_EQ(36,
reinterpret_cast<PopcntCode
>(
test->entry())());
375 "mov ecx,0xffffffff\n"
384 __ movl(
ECX, Immediate(0x0f00));
386 __ movl(
ECX, Immediate(0x00f0));
396 typedef int (*LzcntCode)();
397 EXPECT_EQ(44,
reinterpret_cast<LzcntCode
>(
test->entry())());
418static JumpAddress jump_address;
419static uword jump_address_offset;
429 jump_address_offset =
__ CodeSize();
430 __ movl(
EAX, Immediate(42));
435 memset(&jump_address, 0,
sizeof(jump_address));
436 jump_address.target =
test->entry() + jump_address_offset;
438 typedef int (*TestCode)(
void*);
439 EXPECT_EQ(42,
reinterpret_cast<TestCode
>(
test->entry())(&jump_address));
441 "mov eax,[esp+0x4]\n"
453 __ movl(
EAX, Immediate(0));
455 __ incl(Address(
ESP, 0));
464 typedef int (*IncrementCode)();
465 EXPECT_EQ(2,
reinterpret_cast<IncrementCode
>(
test->entry())());
478 __ movl(
EAX, Immediate(2));
480 __ decl(Address(
ESP, 0));
489 typedef int (*DecrementCode)();
490 EXPECT_EQ(0,
reinterpret_cast<DecrementCode
>(
test->entry())());
512 typedef int (*AddressBinOpCode)(
int a);
513 EXPECT_EQ((2 + 2 + 1 - 2) * 2,
514 reinterpret_cast<AddressBinOpCode
>(
test->entry())(2));
516 "mov eax,[esp+0x4]\n"
517 "add eax,[esp+0x4]\n"
519 "sub eax,[esp+0x4]\n"
520 "imul eax,[esp+0x4]\n"
525 __ movl(
EAX, Immediate(2));
526 __ movl(
ECX, Immediate(4));
528 __ imull(
EAX, Immediate(1000));
533 typedef int (*SignedMultiply)();
534 EXPECT_EQ(8000,
reinterpret_cast<SignedMultiply
>(
test->entry())());
539 "imul eax,eax,0x3e8\n"
544 __ movl(
EDX, Immediate(0));
545 __ movl(
EAX, Immediate(0x0fffffff));
546 __ movl(
ECX, Immediate(0x0fffffff));
553 typedef int (*OverflowSignedMultiply)();
554 EXPECT_EQ(0,
reinterpret_cast<OverflowSignedMultiply
>(
test->entry())());
557 "mov eax,0x0fffffff\n"
558 "mov ecx,0x0fffffff\n"
566 __ movl(
EBX, Immediate(2));
567 __ movl(
ECX, Immediate(4));
569 __ imull(
EBX, Immediate(1000));
576 typedef int (*SignedMultiply1)();
577 EXPECT_EQ(8000,
reinterpret_cast<SignedMultiply1
>(
test->entry())());
583 "imul ebx,ebx,0x3e8\n"
590 __ movl(
ECX, Immediate(42));
597 typedef int (*Negate)();
598 EXPECT_EQ(-42,
reinterpret_cast<Negate
>(
test->entry())());
608 __ movl(
EAX, Immediate(666));
614 typedef int (*Bsr)(
int input);
615 Bsr
call =
reinterpret_cast<Bsr
>(
test->entry());
616 EXPECT_EQ(666,
call(0));
617 EXPECT_EQ(0,
call(1));
618 EXPECT_EQ(1,
call(2));
619 EXPECT_EQ(1,
call(3));
620 EXPECT_EQ(2,
call(4));
621 EXPECT_EQ(5,
call(42));
622 EXPECT_EQ(31,
call(-1));
624 "mov ecx,[esp+0x4]\n"
632 __ movl(
EDX, Immediate(0x1234ffff));
643 typedef int (*MoveExtend)();
644 EXPECT_EQ(0xff - 1 + 0xffff,
reinterpret_cast<MoveExtend
>(
test->entry())());
647 "mov edx,0x1234ffff\n"
659 __ movl(
EDX, Immediate(0x1234ffff));
674 typedef int (*MoveExtendMemory)();
675 EXPECT_EQ(0xff - 1 + 0xffff,
676 reinterpret_cast<MoveExtendMemory
>(
test->entry())());
679 "mov edx,0x1234ffff\n"
692 __ movl(
ECX, Immediate(42));
694 __ orl(
ECX, Immediate(0x100));
695 __ movl(
EAX, Immediate(0x648));
697 __ movl(
EAX, Immediate(0xfff0));
699 __ pushl(Immediate(0xF6FF));
702 __ movl(
EAX, Immediate(1));
704 __ pushl(Immediate(0x7));
707 __ xorl(
ECX, Immediate(0));
708 __ pushl(Immediate(0x1C));
712 __ movl(
EDX, Immediate(0xB0));
723 EXPECT_EQ(0xBA,
value);
744 "mov eax,[esp+0x4]\n"
753 __ movl(
EAX, Immediate(4));
754 __ andl(
EAX, Immediate(2));
755 __ cmpl(
EAX, Immediate(0));
758 __ movl(
EAX, Immediate(0));
763 __ movl(
ECX, Immediate(4));
764 __ andl(
ECX, Immediate(4));
765 __ cmpl(
ECX, Immediate(0));
768 __ movl(
EAX, Immediate(0));
773 __ movl(
EAX, Immediate(0));
774 __ orl(
EAX, Immediate(0));
775 __ cmpl(
EAX, Immediate(0));
778 __ movl(
EAX, Immediate(0));
783 __ movl(
EAX, Immediate(4));
784 __ orl(
EAX, Immediate(0));
785 __ cmpl(
EAX, Immediate(0));
788 __ movl(
EAX, Immediate(0));
793 __ movl(
EAX, Immediate(1));
794 __ shll(
EAX, Immediate(1));
795 __ cmpl(
EAX, Immediate(2));
798 __ movl(
EAX, Immediate(0));
803 __ movl(
EAX, Immediate(1));
804 __ shll(
EAX, Immediate(3));
805 __ cmpl(
EAX, Immediate(8));
808 __ movl(
EAX, Immediate(0));
813 __ movl(
EAX, Immediate(2));
814 __ shrl(
EAX, Immediate(1));
815 __ cmpl(
EAX, Immediate(1));
818 __ movl(
EAX, Immediate(0));
823 __ movl(
EAX, Immediate(8));
824 __ shrl(
EAX, Immediate(3));
825 __ cmpl(
EAX, Immediate(1));
828 __ movl(
EAX, Immediate(0));
833 __ movl(
EAX, Immediate(1));
834 __ movl(
ECX, Immediate(3));
836 __ cmpl(
EAX, Immediate(8));
839 __ movl(
EAX, Immediate(0));
844 __ movl(
EAX, Immediate(8));
845 __ movl(
ECX, Immediate(3));
847 __ cmpl(
EAX, Immediate(1));
850 __ movl(
EAX, Immediate(0));
855 __ movl(
EAX, Immediate(1));
856 __ shll(
EAX, Immediate(31));
857 __ shrl(
EAX, Immediate(3));
858 __ cmpl(
EAX, Immediate(0x10000000));
861 __ movl(
EAX, Immediate(0));
866 __ movl(
EAX, Immediate(1));
867 __ shll(
EAX, Immediate(31));
868 __ sarl(
EAX, Immediate(3));
869 __ cmpl(
EAX, Immediate(0xf0000000));
872 __ movl(
EAX, Immediate(0));
877 __ movl(
EAX, Immediate(1));
878 __ movl(
ECX, Immediate(3));
879 __ shll(
EAX, Immediate(31));
881 __ cmpl(
EAX, Immediate(0xf0000000));
884 __ movl(
EAX, Immediate(0));
890 __ movl(Address(
ESP, 0), Immediate(0x80000000));
891 __ movl(
EAX, Immediate(0));
892 __ movl(
ECX, Immediate(3));
895 __ cmpl(Address(
ESP, 0), Immediate(0x1e000000));
903 __ movl(Address(
ESP, 0), Immediate(0xFF000000));
904 __ movl(
EAX, Immediate(-1));
905 __ movl(
ECX, Immediate(2));
908 __ cmpl(Address(
ESP, 0), Immediate(0xF0000003));
915 __ movl(
EDX, Immediate(0x80000000));
916 __ movl(
EAX, Immediate(0));
917 __ movl(
ECX, Immediate(3));
918 __ sarl(
EDX, Immediate(3));
920 __ cmpl(
EDX, Immediate(0x1e000000));
926 __ movl(
EDX, Immediate(0xFF000000));
927 __ movl(
EAX, Immediate(-1));
928 __ shll(
EDX, Immediate(2));
930 __ cmpl(
EDX, Immediate(0xF0000003));
935 __ movl(
EAX, Immediate(0));
940 typedef int (*LogicalOpsCode)();
941 EXPECT_EQ(0,
reinterpret_cast<LogicalOpsCode
>(
test->entry())());
1008 "cmp eax,0x10000000\n"
1015 "cmp eax,0xf0000000\n"
1023 "cmp eax,0xf0000000\n"
1028 "mov [esp],-0x80000000\n"
1032 "shrd [esp],eax,cl\n"
1033 "cmp [esp],0x1e000000\n"
1038 "mov [esp],-0x01000000\n"
1039 "mov eax,0xffffffff\n"
1042 "shld [esp],eax,cl\n"
1043 "cmp [esp],0xf0000003\n"
1047 "mov edx,0x80000000\n"
1052 "cmp edx,0x1e000000\n"
1055 "mov edx,0xff000000\n"
1056 "mov eax,0xffffffff\n"
1059 "cmp edx,0xf0000003\n"
1069 __ movl(
EAX, Immediate(4));
1070 __ movl(
ECX, Immediate(2));
1074 __ movl(
EAX, Immediate(0));
1079 __ movl(
EDX, Immediate(4));
1080 __ movl(
ECX, Immediate(4));
1084 __ movl(
EAX, Immediate(0));
1089 __ movl(
EAX, Immediate(0));
1090 __ testl(
EAX, Immediate(0));
1093 __ movl(
EAX, Immediate(0));
1098 __ movl(
EBX, Immediate(4));
1099 __ testl(
EBX, Immediate(4));
1102 __ movl(
EAX, Immediate(0));
1107 __ movl(
EBX, Immediate(0xff));
1108 __ testl(
EBX, Immediate(0xff));
1111 __ movl(
EAX, Immediate(0));
1115 __ movl(
EAX, Immediate(0));
1121 typedef int (*LogicalTestCode)();
1122 EXPECT_EQ(0,
reinterpret_cast<LogicalTestCode
>(
test->entry())());
1158 __ movl(
EAX, Immediate(0));
1160 __ movl(
EAX, Immediate(4));
1161 __ movl(
ECX, Immediate(0));
1163 __ LockCmpxchgl(Address(
ESP, 0),
ECX);
1169 typedef int (*CompareSwapEQCode)();
1170 EXPECT_EQ(0,
reinterpret_cast<CompareSwapEQCode
>(
test->entry())());
1177 "lock cmpxchg ecx,[esp]\n"
1183 __ movl(
EAX, Immediate(0));
1185 __ movl(
EAX, Immediate(2));
1186 __ movl(
ECX, Immediate(4));
1188 __ LockCmpxchgl(Address(
ESP, 0),
ECX);
1194 typedef int (*CompareSwapNEQCode)();
1195 EXPECT_EQ(4,
reinterpret_cast<CompareSwapNEQCode
>(
test->entry())());
1202 "lock cmpxchg ecx,[esp]\n"
1208 __ movl(
EAX, Immediate(-87));
1209 __ movl(
EDX, Immediate(123));
1211 __ movl(
ECX, Immediate(42));
1217 typedef int (*SignedDivide)();
1218 EXPECT_EQ(-87 / 42,
reinterpret_cast<SignedDivide
>(
test->entry())());
1220 "mov eax,0xffffffa9\n"
1224 "idiv (eax,edx),ecx\n"
1229 __ movl(
EAX, Immediate(0xffffffbe));
1230 __ movl(
EDX, Immediate(0x41));
1231 __ movl(
ECX, Immediate(-1));
1237 typedef int (*UnsignedDivide)();
1238 EXPECT_EQ(0x42,
reinterpret_cast<UnsignedDivide
>(
test->entry())());
1240 "mov eax,0xffffffbe\n"
1242 "mov ecx,0xffffffff\n"
1243 "div (eax,edx),ecx\n"
1248 __ movl(
EAX, Immediate(123456789));
1249 __ movl(
EDX, Immediate(987654321));
1256 typedef int (*Exchange)();
1257 EXPECT_EQ(987654321 - 123456789,
reinterpret_cast<Exchange
>(
test->entry())());
1259 "mov eax,0x075bcd15\n"
1260 "mov edx,0x3ade68b1\n"
1266static int ComputeStackSpaceReservation(
int needed,
int fixed) {
1273static int LeafReturn42() {
1277static int LeafReturnArgument(
int x) {
1282 ExternalLabel call1(
reinterpret_cast<uword>(LeafReturn42));
1283 ExternalLabel call2(
reinterpret_cast<uword>(LeafReturnArgument));
1284 int space = ComputeStackSpaceReservation(0, 4);
1285 __ AddImmediate(
ESP, Immediate(-space));
1287 __ AddImmediate(
ESP, Immediate(space));
1288 space = ComputeStackSpaceReservation(4, 4);
1289 __ AddImmediate(
ESP, Immediate(-space));
1292 __ AddImmediate(
ESP, Immediate(space));
1297 typedef int (*CallSimpleLeafCode)();
1298 EXPECT_EQ(42 + 87,
reinterpret_cast<CallSimpleLeafCode
>(
test->entry())());
1302 ExternalLabel call1(
reinterpret_cast<uword>(LeafReturn42));
1304 int space = ComputeStackSpaceReservation(0, 4);
1305 __ AddImmediate(
ESP, Immediate(-space));
1307 __ AddImmediate(
ESP, Immediate(space));
1314 typedef int (*JumpSimpleLeafCode)();
1315 EXPECT_EQ(42,
reinterpret_cast<JumpSimpleLeafCode
>(
test->entry())());
1319 ExternalLabel call1(
reinterpret_cast<uword>(LeafReturn42));
1321 int space = ComputeStackSpaceReservation(0, 4);
1322 __ AddImmediate(
ESP, Immediate(-space));
1324 __ AddImmediate(
ESP, Immediate(space));
1333 typedef int (*JumpConditionalSimpleLeafCode)();
1335 reinterpret_cast<JumpConditionalSimpleLeafCode
>(
test->entry())());
1339 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(234.0f)));
1349 __ movl(Address(
ESP, 0), Immediate(0));
1351 __ flds(Address(
ESP, 0));
1357 typedef float (*SingleFPMovesCode)();
1358 float res =
reinterpret_cast<SingleFPMovesCode
>(
test->entry())();
1359 EXPECT_EQ(234.0f, res);
1361 "mov eax,0x436a0000\n"
1372 "movss [esp],xmm7\n"
1381 __ movl(
EBX, Immediate(bit_cast<int32_t, float>(234.0f)));
1386 __ flds(Address(
ESP, 0));
1394 typedef float (*SingleFPMoves2Code)();
1395 float res =
reinterpret_cast<SingleFPMoves2Code
>(
test->entry())();
1396 EXPECT_EQ(234.0f, res);
1400 "mov ebx,0x436a0000\n"
1413 __ movl(
EAX, Immediate(1131020288));
1415 __ flds(Address(
ESP, 0));
1418 __ fstps(Address(
ESP, 0));
1425 typedef int (*SingleFPUStackMovesCode)();
1426 int res =
reinterpret_cast<SingleFPUStackMovesCode
>(
test->entry())();
1427 EXPECT_EQ(234.0f, (bit_cast<float, int>(res)));
1429 "mov eax,0x436a0000\n"
1441 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1443 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(3.4f)));
1451 __ flds(Address(
ESP, 0));
1457 typedef float (*SingleFPOperationsCode)();
1458 float res =
reinterpret_cast<SingleFPOperationsCode
>(
test->entry())();
1459 EXPECT_FLOAT_EQ(14.7f, res, 0.001f);
1461 "mov eax,0x4144cccd\n"
1463 "mov eax,0x4059999a\n"
1470 "movss [esp],xmm0\n"
1477 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1480 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(3.4f)));
1491 __ flds(Address(
ESP, 0));
1497 typedef float (*PackedFPOperationsCode)();
1498 float res =
reinterpret_cast<PackedFPOperationsCode
>(
test->entry())();
1499 EXPECT_FLOAT_EQ(14.7f, res, 0.001f);
1501 "mov eax,0x4144cccd\n"
1503 "shufps xmm0,xmm0 [0]\n"
1504 "mov eax,0x4059999a\n"
1506 "shufps xmm1,xmm1 [0]\n"
1511 "shufps xmm0,xmm0 [55]\n"
1513 "movss [esp],xmm0\n"
1520 __ movl(
EAX, Immediate(0x2));
1523 __ movl(
EAX, Immediate(0x1));
1537 typedef uint32_t (*PackedIntOperationsCode)();
1538 uint32_t res =
reinterpret_cast<PackedIntOperationsCode
>(
test->entry())();
1539 EXPECT_EQ(
static_cast<uword>(0x5), res);
1543 "shufps xmm0,xmm0 [0]\n"
1546 "shufps xmm1,xmm1 [0]\n"
1551 "movss [esp],xmm0\n"
1557 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1570 __ flds(Address(
ESP, 0));
1576 typedef float (*PackedFPOperations2Code)();
1577 float res =
reinterpret_cast<PackedFPOperations2Code
>(
test->entry())();
1578 EXPECT_FLOAT_EQ(0.0f, res, 0.001f);
1580 "mov eax,0x40800000\n"
1582 "shufps xmm0,xmm0 [0]\n"
1583 "movaps xmm1,xmm0\n"
1585 "sqrtps xmm1,xmm1\n"
1586 "rsqrtps xmm0,xmm0\n"
1588 "shufps xmm0,xmm0 [0]\n"
1590 "movss [esp],xmm0\n"
1597 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1598 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1603 __ flds(Address(
ESP, 0));
1609 typedef uint32_t (*PackedCompareEQCode)();
1610 uint32_t res =
reinterpret_cast<PackedCompareEQCode
>(
test->entry())();
1611 EXPECT_EQ(
static_cast<uword>(0x0), res);
1613 "mov eax,0x40000000\n"
1615 "shufps xmm0,xmm0 [0]\n"
1616 "mov eax,0x40800000\n"
1618 "shufps xmm1,xmm1 [0]\n"
1619 "cmpps xmm0,xmm1 [eq]\n"
1621 "movss [esp],xmm0\n"
1628 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1629 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1634 __ flds(Address(
ESP, 0));
1640 typedef uint32_t (*PackedCompareNEQCode)();
1641 uint32_t res =
reinterpret_cast<PackedCompareNEQCode
>(
test->entry())();
1642 EXPECT_EQ(
static_cast<uword>(0xFFFFFFFF), res);
1644 "mov eax,0x40000000\n"
1646 "shufps xmm0,xmm0 [0]\n"
1647 "mov eax,0x40800000\n"
1649 "shufps xmm1,xmm1 [0]\n"
1650 "cmpps xmm0,xmm1 [neq]\n"
1652 "movss [esp],xmm0\n"
1659 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1660 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1665 __ flds(Address(
ESP, 0));
1671 typedef uint32_t (*PackedCompareLTCode)();
1672 uint32_t res =
reinterpret_cast<PackedCompareLTCode
>(
test->entry())();
1673 EXPECT_EQ(
static_cast<uword>(0xFFFFFFFF), res);
1675 "mov eax,0x40000000\n"
1677 "shufps xmm0,xmm0 [0]\n"
1678 "mov eax,0x40800000\n"
1680 "shufps xmm1,xmm1 [0]\n"
1681 "cmpps xmm0,xmm1 [lt]\n"
1683 "movss [esp],xmm0\n"
1690 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1691 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1696 __ flds(Address(
ESP, 0));
1702 typedef uint32_t (*PackedCompareLECode)();
1703 uint32_t res =
reinterpret_cast<PackedCompareLECode
>(
test->entry())();
1704 EXPECT_EQ(
static_cast<uword>(0xFFFFFFFF), res);
1706 "mov eax,0x40000000\n"
1708 "shufps xmm0,xmm0 [0]\n"
1709 "mov eax,0x40800000\n"
1711 "shufps xmm1,xmm1 [0]\n"
1712 "cmpps xmm0,xmm1 [le]\n"
1714 "movss [esp],xmm0\n"
1721 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1722 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1727 __ flds(Address(
ESP, 0));
1733 typedef uint32_t (*PackedCompareNLTCode)();
1734 uint32_t res =
reinterpret_cast<PackedCompareNLTCode
>(
test->entry())();
1735 EXPECT_EQ(
static_cast<uword>(0x0), res);
1737 "mov eax,0x40000000\n"
1739 "shufps xmm0,xmm0 [0]\n"
1740 "mov eax,0x40800000\n"
1742 "shufps xmm1,xmm1 [0]\n"
1743 "cmpps xmm0,xmm1 [nlt]\n"
1745 "movss [esp],xmm0\n"
1752 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1753 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1758 __ flds(Address(
ESP, 0));
1764 typedef uint32_t (*PackedCompareNLECode)();
1765 uint32_t res =
reinterpret_cast<PackedCompareNLECode
>(
test->entry())();
1766 EXPECT_EQ(
static_cast<uword>(0x0), res);
1768 "mov eax,0x40000000\n"
1770 "shufps xmm0,xmm0 [0]\n"
1771 "mov eax,0x40800000\n"
1773 "shufps xmm1,xmm1 [0]\n"
1774 "cmpps xmm0,xmm1 [nle]\n"
1776 "movss [esp],xmm0\n"
1783 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1791 __ flds(Address(
ESP, 0));
1797 typedef float (*PackedNegateCode)();
1798 float res =
reinterpret_cast<PackedNegateCode
>(
test->entry())();
1799 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f);
1801 "mov eax,0x4144cccd\n"
1803 "shufps xmm0,xmm0 [0]\n"
1804 "xorps xmm0,[0x........]\n"
1805 "shufps xmm0,xmm0 [aa]\n"
1807 "movss [esp],xmm0\n"
1814 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(-15.3f)));
1822 __ flds(Address(
ESP, 0));
1828 typedef float (*PackedAbsoluteCode)();
1829 float res =
reinterpret_cast<PackedAbsoluteCode
>(
test->entry())();
1830 EXPECT_FLOAT_EQ(15.3f, res, 0.001f);
1832 "mov eax,0xc174cccd\n"
1834 "shufps xmm0,xmm0 [0]\n"
1835 "andps xmm0,[0x........]\n"
1836 "shufps xmm0,xmm0 [aa]\n"
1838 "movss [esp],xmm0\n"
1845 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1851 __ flds(Address(
ESP, 0));
1857 typedef float (*PackedSetWZeroCode)();
1858 float res =
reinterpret_cast<PackedSetWZeroCode
>(
test->entry())();
1859 EXPECT_FLOAT_EQ(0.0f, res, 0.001f);
1861 "mov eax,0x4144cccd\n"
1863 "shufps xmm0,xmm0 [0]\n"
1864 "andps xmm0,[0x........]\n"
1865 "shufps xmm0,xmm0 [ff]\n"
1867 "movss [esp],xmm0\n"
1874 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1875 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1880 __ flds(Address(
ESP, 0));
1886 typedef float (*PackedMinCode)();
1887 float res =
reinterpret_cast<PackedMinCode
>(
test->entry())();
1888 EXPECT_FLOAT_EQ(2.0f, res, 0.001f);
1890 "mov eax,0x40000000\n"
1892 "shufps xmm0,xmm0 [0]\n"
1893 "mov eax,0x40800000\n"
1895 "shufps xmm1,xmm1 [0]\n"
1898 "movss [esp],xmm0\n"
1905 __ set1ps(
XMM0,
EAX, Immediate(bit_cast<int32_t, float>(2.0f)));
1906 __ set1ps(
XMM1,
EAX, Immediate(bit_cast<int32_t, float>(4.0f)));
1911 __ flds(Address(
ESP, 0));
1917 typedef float (*PackedMaxCode)();
1918 float res =
reinterpret_cast<PackedMaxCode
>(
test->entry())();
1919 EXPECT_FLOAT_EQ(4.0f, res, 0.001f);
1921 "mov eax,0x40000000\n"
1923 "shufps xmm0,xmm0 [0]\n"
1924 "mov eax,0x40800000\n"
1926 "shufps xmm1,xmm1 [0]\n"
1929 "movss [esp],xmm0\n"
1941 } constant1 = {0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0};
1947 } constant2 = {0x0F0F0F0F, 0x0F0F0F0F, 0x0F0F0F0F, 0x0F0F0F0F};
1954 __ flds(Address(
ESP, 0));
1960 typedef uint32_t (*PackedLogicalOrCode)();
1961 uint32_t res =
reinterpret_cast<PackedLogicalOrCode
>(
test->entry())();
1962 EXPECT_EQ(0xFFFFFFFF, res);
1964 "movups xmm0,[0x........]\n"
1965 "movups xmm1,[0x........]\n"
1968 "movss [esp],xmm0\n"
1980 } constant1 = {0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0, 0xF0F0F0F0};
1986 } constant2 = {0x0F0FFF0F, 0x0F0F0F0F, 0x0F0F0F0F, 0x0F0F0F0F};
1992 __ flds(Address(
ESP, 0));
1998 typedef uint32_t (*PackedLogicalAndCode)();
1999 uint32_t res =
reinterpret_cast<PackedLogicalAndCode
>(
test->entry())();
2000 EXPECT_EQ(
static_cast<uword>(0x0000F000), res);
2002 "movups xmm0,[0x........]\n"
2003 "andps xmm0,[0x........]\n"
2005 "movss [esp],xmm0\n"
2017 } constant1 = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
2023 __ flds(Address(
ESP, 0));
2029 typedef uint32_t (*PackedLogicalNotCode)();
2030 uint32_t res =
reinterpret_cast<PackedLogicalNotCode
>(
test->entry())();
2031 EXPECT_EQ(
static_cast<uword>(0x0), res);
2033 "movups xmm0,[0x........]\n"
2034 "xorps xmm0,[0x........]\n"
2036 "movss [esp],xmm0\n"
2048 } constant0 = {1.0, 2.0, 3.0, 4.0};
2054 } constant1 = {5.0, 6.0, 7.0, 8.0};
2069 __ flds(Address(
ESP, 0));
2075 typedef float (*PackedMoveHighLow)();
2076 float res =
reinterpret_cast<PackedMoveHighLow
>(
test->entry())();
2077 EXPECT_FLOAT_EQ(15.0f, res, 0.001f);
2079 "movups xmm0,[0x........]\n"
2080 "movups xmm1,[0x........]\n"
2081 "movhlps xmm0,xmm1\n"
2083 "movaps xmm1,xmm0\n"
2084 "shufps xmm0,xmm0 [0]\n"
2085 "shufps xmm1,xmm1 [55]\n"
2088 "movss [esp],xmm0\n"
2100 } constant0 = {1.0, 2.0, 3.0, 4.0};
2106 } constant1 = {5.0, 6.0, 7.0, 8.0};
2121 __ flds(Address(
ESP, 0));
2127 typedef float (*PackedMoveLowHigh)();
2128 float res =
reinterpret_cast<PackedMoveLowHigh
>(
test->entry())();
2129 EXPECT_FLOAT_EQ(11.0f, res, 0.001f);
2131 "movups xmm0,[0x........]\n"
2132 "movups xmm1,[0x........]\n"
2133 "movlhps xmm0,xmm1\n"
2135 "movaps xmm1,xmm0\n"
2136 "shufps xmm0,xmm0 [aa]\n"
2137 "shufps xmm1,xmm1 [ff]\n"
2140 "movss [esp],xmm0\n"
2152 } constant0 = {1.0, 2.0, 3.0, 4.0};
2158 } constant1 = {5.0, 6.0, 7.0, 8.0};
2172 __ flds(Address(
ESP, 0));
2178 typedef float (*PackedUnpackLow)();
2179 float res =
reinterpret_cast<PackedUnpackLow
>(
test->entry())();
2180 EXPECT_FLOAT_EQ(11.0f, res, 0.001f);
2182 "movups xmm0,[0x........]\n"
2183 "movups xmm1,[0x........]\n"
2184 "unpcklps xmm0,xmm1\n"
2185 "movaps xmm1,xmm0\n"
2186 "shufps xmm0,xmm0 [55]\n"
2187 "shufps xmm1,xmm1 [ff]\n"
2190 "movss [esp],xmm0\n"
2202 } constant0 = {1.0, 2.0, 3.0, 4.0};
2208 } constant1 = {5.0, 6.0, 7.0, 8.0};
2222 __ flds(Address(
ESP, 0));
2228 typedef float (*PackedUnpackHigh)();
2229 float res =
reinterpret_cast<PackedUnpackHigh
>(
test->entry())();
2230 EXPECT_FLOAT_EQ(7.0f, res, 0.001f);
2232 "movups xmm0,[0x........]\n"
2233 "movups xmm1,[0x........]\n"
2234 "unpckhps xmm0,xmm1\n"
2235 "movaps xmm1,xmm0\n"
2236 "shufps xmm0,xmm0 [0]\n"
2237 "shufps xmm1,xmm1 [aa]\n"
2240 "movss [esp],xmm0\n"
2252 } constant0 = {1.0, 2.0, 3.0, 4.0};
2258 } constant1 = {5.0, 6.0, 7.0, 8.0};
2272 __ flds(Address(
ESP, 0));
2278 typedef float (*PackedUnpackLowPair)();
2279 float res =
reinterpret_cast<PackedUnpackLowPair
>(
test->entry())();
2280 EXPECT_FLOAT_EQ(6.0f, res, 0.001f);
2282 "movups xmm0,[0x........]\n"
2283 "movups xmm1,[0x........]\n"
2284 "unpcklpd xmm0,xmm1\n"
2285 "movaps xmm1,xmm0\n"
2286 "shufps xmm0,xmm0 [0]\n"
2287 "shufps xmm1,xmm1 [aa]\n"
2290 "movss [esp],xmm0\n"
2302 } constant0 = {1.0, 2.0, 3.0, 4.0};
2308 } constant1 = {5.0, 6.0, 7.0, 8.0};
2322 __ flds(Address(
ESP, 0));
2328 typedef float (*PackedUnpackHighPair)();
2329 float res =
reinterpret_cast<PackedUnpackHighPair
>(
test->entry())();
2330 EXPECT_FLOAT_EQ(12.0f, res, 0.001f);
2332 "movups xmm0,[0x........]\n"
2333 "movups xmm1,[0x........]\n"
2334 "unpckhpd xmm0,xmm1\n"
2335 "movaps xmm1,xmm0\n"
2336 "shufps xmm0,xmm0 [55]\n"
2337 "shufps xmm1,xmm1 [ff]\n"
2340 "movss [esp],xmm0\n"
2350 } constant0 = {1.0, 2.0};
2354 } constant1 = {3.0, 4.0};
2361 __ fldl(Address(
ESP, 0));
2368 typedef double (*PackedDoubleAdd)();
2369 double res =
reinterpret_cast<PackedDoubleAdd
>(
test->entry())();
2370 EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
2372 "movups xmm0,[0x........]\n"
2373 "movups xmm1,[0x........]\n"
2377 "movsd [esp],xmm0\n"
2388 } constant0 = {1.0, 2.0};
2392 } constant1 = {3.0, 4.0};
2399 __ fldl(Address(
ESP, 0));
2406 typedef double (*PackedDoubleSub)();
2407 double res =
reinterpret_cast<PackedDoubleSub
>(
test->entry())();
2408 EXPECT_FLOAT_EQ(-2.0, res, 0.000001f);
2410 "movups xmm0,[0x........]\n"
2411 "movups xmm1,[0x........]\n"
2415 "movsd [esp],xmm0\n"
2426 } constant0 = {1.0, 2.0};
2432 __ fldl(Address(
ESP, 0));
2439 typedef double (*PackedDoubleNegate)();
2440 double res =
reinterpret_cast<PackedDoubleNegate
>(
test->entry())();
2441 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f);
2443 "movups xmm0,[0x........]\n"
2444 "xorpd xmm0,[0x........]\n"
2447 "movsd [esp],xmm0\n"
2458 } constant0 = {-1.0, 2.0};
2464 __ fldl(Address(
ESP, 0));
2471 typedef double (*PackedDoubleAbsolute)();
2472 double res =
reinterpret_cast<PackedDoubleAbsolute
>(
test->entry())();
2473 EXPECT_FLOAT_EQ(1.0, res, 0.000001f);
2475 "movups xmm0,[0x........]\n"
2476 "andpd xmm0,[0x........]\n"
2479 "movsd [esp],xmm0\n"
2490 } constant0 = {3.0, 2.0};
2494 } constant1 = {3.0, 4.0};
2501 __ fldl(Address(
ESP, 0));
2508 typedef double (*PackedDoubleMul)();
2509 double res =
reinterpret_cast<PackedDoubleMul
>(
test->entry())();
2510 EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
2512 "movups xmm0,[0x........]\n"
2513 "movups xmm1,[0x........]\n"
2517 "movsd [esp],xmm0\n"
2528 } constant0 = {9.0, 2.0};
2532 } constant1 = {3.0, 4.0};
2539 __ fldl(Address(
ESP, 0));
2546 typedef double (*PackedDoubleDiv)();
2547 double res =
reinterpret_cast<PackedDoubleDiv
>(
test->entry())();
2548 EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
2550 "movups xmm0,[0x........]\n"
2551 "movups xmm1,[0x........]\n"
2555 "movsd [esp],xmm0\n"
2566 } constant0 = {16.0, 2.0};
2572 __ fldl(Address(
ESP, 0));
2579 typedef double (*PackedDoubleSqrt)();
2580 double res =
reinterpret_cast<PackedDoubleSqrt
>(
test->entry())();
2581 EXPECT_FLOAT_EQ(4.0, res, 0.000001f);
2583 "movups xmm0,[0x........]\n"
2584 "sqrtpd xmm0,xmm0\n"
2587 "movsd [esp],xmm0\n"
2598 } constant0 = {9.0, 2.0};
2602 } constant1 = {3.0, 4.0};
2609 __ fldl(Address(
ESP, 0));
2616 typedef double (*PackedDoubleMin)();
2617 double res =
reinterpret_cast<PackedDoubleMin
>(
test->entry())();
2618 EXPECT_FLOAT_EQ(3.0, res, 0.000001f);
2620 "movups xmm0,[0x........]\n"
2621 "movups xmm1,[0x........]\n"
2625 "movsd [esp],xmm0\n"
2636 } constant0 = {9.0, 2.0};
2640 } constant1 = {3.0, 4.0};
2647 __ fldl(Address(
ESP, 0));
2654 typedef double (*PackedDoubleMax)();
2655 double res =
reinterpret_cast<PackedDoubleMax
>(
test->entry())();
2656 EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
2658 "movups xmm0,[0x........]\n"
2659 "movups xmm1,[0x........]\n"
2663 "movsd [esp],xmm0\n"
2674 } constant0 = {2.0, 9.0};
2684 __ fldl(Address(
ESP, 0));
2691 typedef double (*PackedDoubleShuffle)();
2692 double res =
reinterpret_cast<PackedDoubleShuffle
>(
test->entry())();
2693 EXPECT_FLOAT_EQ(9.0, res, 0.000001f);
2695 "movups xmm0,[0x........]\n"
2696 "shufpd xmm0, xmm0 [33]\n"
2697 "shufpd xmm0, xmm0 [0]\n"
2700 "movsd [esp],xmm0\n"
2711 } constant0 = {9.0, 2.0};
2716 __ flds(Address(
ESP, 0));
2722 typedef float (*PackedDoubleToSingle)();
2723 float res =
reinterpret_cast<PackedDoubleToSingle
>(
test->entry())();
2724 EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
2726 "movups xmm1,[0x........]\n"
2727 "cvtpd2ps xmm0,xmm1\n"
2729 "movss [esp],xmm0\n"
2741 } constant0 = {9.0f, 2.0f, 3.0f, 4.0f};
2747 __ fldl(Address(
ESP, 0));
2754 typedef double (*PackedSingleToDouble)();
2755 double res =
reinterpret_cast<PackedSingleToDouble
>(
test->entry())();
2756 EXPECT_FLOAT_EQ(9.0f, res, 0.000001f);
2758 "movups xmm1,[0x........]\n"
2759 "cvtps2pd xmm0,xmm1\n"
2762 "movsd [esp],xmm0\n"
2770 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
2778 __ flds(Address(
ESP, 0));
2784 typedef float (*SingleFPOperationsStackCode)(
float f);
2785 float res =
reinterpret_cast<SingleFPOperationsStackCode
>(
test->entry())(3.4);
2786 EXPECT_FLOAT_EQ(14.7f, res, 0.001f);
2788 "mov eax,0x4144cccd\n"
2790 "addss xmm0,[esp+0x4]\n"
2791 "mulss xmm0,[esp+0x4]\n"
2792 "subss xmm0,[esp+0x4]\n"
2793 "divss xmm0,[esp+0x4]\n"
2795 "movss [esp],xmm0\n"
2802 int64_t l = bit_cast<int64_t, double>(1024.67);
2815 __ movl(Address(
ESP, 0), Immediate(0));
2827 __ movl(Address(
ESP, 0), Immediate(0));
2830 __ fldl(Address(
ESP, 0));
2837 typedef double (*DoubleFPMovesCode)();
2838 double res =
reinterpret_cast<DoubleFPMovesCode
>(
test->entry())();
2839 EXPECT_FLOAT_EQ(1024.67, res, 0.0001);
2841 "mov eax,0x409002ae\n"
2843 "mov eax,0x147ae148\n"
2845 "movsd xmm0,[esp]\n"
2855 "movsd xmm0,[esp]\n"
2856 "movsd [esp],xmm7\n"
2857 "movsd xmm7,[esp]\n"
2858 "movaps xmm6,xmm7\n"
2859 "movaps xmm5,xmm6\n"
2860 "movaps xmm4,xmm5\n"
2861 "movaps xmm3,xmm4\n"
2862 "movaps xmm2,xmm3\n"
2863 "movaps xmm1,xmm2\n"
2864 "movaps xmm0,xmm1\n"
2867 "movsd [esp],xmm0\n"
2875 int64_t l = bit_cast<int64_t, double>(1024.67);
2880 __ fldl(Address(
ESP, 0));
2881 __ movl(Address(
ESP, 0), Immediate(0));
2883 __ fstpl(Address(
ESP, 0));
2890 typedef int64_t (*DoubleFPUStackMovesCode)();
2891 int64_t res =
reinterpret_cast<DoubleFPUStackMovesCode
>(
test->entry())();
2892 EXPECT_FLOAT_EQ(1024.67, (bit_cast<double, int64_t>(res)), 0.001);
2894 "mov eax,0x409002ae\n"
2896 "mov eax,0x147ae148\n"
2908 int64_t l = bit_cast<int64_t, double>(12.3);
2916 l = bit_cast<int64_t, double>(3.4);
2927 __ fldl(Address(
ESP, 0));
2934 typedef double (*DoubleFPOperationsCode)();
2935 double res =
reinterpret_cast<DoubleFPOperationsCode
>(
test->entry())();
2936 EXPECT_FLOAT_EQ(14.7, res, 0.001);
2938 "mov eax,0x40289999\n"
2940 "mov eax,0x9999999a\n"
2942 "movsd xmm0,[esp]\n"
2945 "mov eax,0x400b3333\n"
2947 "mov eax,0x33333333\n"
2949 "movsd xmm1,[esp]\n"
2954 "movsd [esp],xmm0\n"
2962 int64_t l = bit_cast<int64_t, double>(12.3);
2979 __ fldl(Address(
ESP, 0));
2986 typedef double (*DoubleFPOperationsStackCode)(
double d);
2988 reinterpret_cast<DoubleFPOperationsStackCode
>(
test->entry())(3.4);
2989 EXPECT_FLOAT_EQ(14.7, res, 0.001);
2991 "mov eax,0x40289999\n"
2993 "mov eax,0x9999999a\n"
2995 "movsd xmm0,[esp]\n"
2998 "addsd xmm0,[esp+0x4]\n"
2999 "mulsd xmm0,[esp+0x4]\n"
3000 "subsd xmm0,[esp+0x4]\n"
3001 "divsd xmm0,[esp+0x4]\n"
3004 "movsd [esp],xmm0\n"
3012 __ movl(
EDX, Immediate(6));
3017 __ fldl(Address(
ESP, 0));
3024 typedef double (*IntToDoubleConversionCode)();
3025 double res =
reinterpret_cast<IntToDoubleConversionCode
>(
test->entry())();
3026 EXPECT_FLOAT_EQ(6.0, res, 0.001);
3029 "cvtsi2sd xmm1,edx\n"
3032 "movsd [esp],xmm1\n"
3045 typedef double (*IntToDoubleConversion2Code)(
int i);
3046 double res =
reinterpret_cast<IntToDoubleConversion2Code
>(
test->entry())(3);
3047 EXPECT_FLOAT_EQ(3.0, res, 0.001);
3049 "fild_s [esp+0x4]\n"
3054 __ movl(
EAX, Immediate(0));
3055 __ movl(
EDX, Immediate(6));
3058 __ fildl(Address(
ESP, 0));
3065 typedef double (*Int64ToDoubleConversionCode)();
3066 double res =
reinterpret_cast<Int64ToDoubleConversionCode
>(
test->entry())();
3067 EXPECT_EQ(6.0, res);
3080 __ movl(
EAX, Immediate(0xFFFFFFFF));
3081 __ movl(
EDX, Immediate(0xFFFFFFFA));
3084 __ fildl(Address(
ESP, 0));
3091 typedef double (*NegativeInt64ToDoubleConversionCode)();
3093 reinterpret_cast<NegativeInt64ToDoubleConversionCode
>(
test->entry())();
3094 EXPECT_EQ(-6.0, res);
3096 "mov eax,0xffffffff\n"
3097 "mov edx,0xfffffffa\n"
3107 __ movl(
EDX, Immediate(6));
3111 __ flds(Address(
ESP, 0));
3117 typedef float (*IntToFloatConversionCode)();
3118 float res =
reinterpret_cast<IntToFloatConversionCode
>(
test->entry())();
3119 EXPECT_FLOAT_EQ(6.0, res, 0.001);
3122 "cvtsi2ss xmm1,edx\n"
3124 "movss [esp],xmm1\n"
3138 typedef int (*FloatToIntConversionRoundCode)(
float f);
3140 reinterpret_cast<FloatToIntConversionRoundCode
>(
test->entry())(12.3);
3142 res =
reinterpret_cast<FloatToIntConversionRoundCode
>(
test->entry())(12.8);
3145 "movsd xmm1,[esp+0x4]\n"
3146 "cvtss2si edx,xmm1\n"
3159 typedef int (*FloatToIntConversionTruncCode)(
float f);
3161 reinterpret_cast<FloatToIntConversionTruncCode
>(
test->entry())(12.3);
3163 res =
reinterpret_cast<FloatToIntConversionTruncCode
>(
test->entry())(12.8);
3166 "movsd xmm1,[esp+0x4]\n"
3167 "cvttss2si edx,xmm1\n"
3173 __ movl(
EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
3180 __ fldl(Address(
ESP, 0));
3187 typedef double (*FloatToDoubleConversionCode)();
3188 double res =
reinterpret_cast<FloatToDoubleConversionCode
>(
test->entry())();
3189 EXPECT_FLOAT_EQ(12.3, res, 0.001);
3191 "mov eax,0x4144cccd\n"
3194 "cvtss2sd xmm2,xmm1\n"
3197 "movsd [esp],xmm2\n"
3206 Label is_nan, is_above, is_ok, cont_1, cont_2;
3209 __ movl(
EDX, Immediate(bit_cast<int32_t, float>(12.3f)));
3211 __ movl(
EDX, Immediate(bit_cast<int32_t, float>(12.5f)));
3225 __ movl(
EDX, Immediate(bit_cast<int32_t, float>(0.0f)));
3246 typedef int (*FloatCompareCode)();
3247 int res =
reinterpret_cast<FloatCompareCode
>(
test->entry())();
3251 "mov edx,0x4144cccd\n"
3253 "mov edx,0x41480000\n"
3255 "comiss xmm0,xmm1\n"
3263 "comiss xmm1,xmm1\n"
3274 int64_t
a = bit_cast<int64_t, double>(12.3);
3275 int64_t
b = bit_cast<int64_t, double>(12.5);
3294 Label is_nan, is_above, is_ok, cont_1, cont_2;
3309 int64_t zero = bit_cast<int64_t, double>(0.0);
3337 typedef int (*DoubleCompareCode)();
3338 int res =
reinterpret_cast<DoubleCompareCode
>(
test->entry())();
3341 "mov edx,0x40289999\n"
3343 "mov edx,0x9999999a\n"
3345 "movsd xmm0,[esp]\n"
3348 "mov edx,0x40290000\n"
3352 "movsd xmm1,[esp]\n"
3356 "comisd xmm0,xmm1\n"
3365 "movsd xmm1,[esp]\n"
3369 "comisd xmm1,xmm1\n"
3380 int64_t l = bit_cast<int64_t, double>(12.3);
3388 __ flds(Address(
ESP, 0));
3395 typedef float (*DoubleToFloatConversionCode)();
3396 float res =
reinterpret_cast<DoubleToFloatConversionCode
>(
test->entry())();
3397 EXPECT_FLOAT_EQ(12.3f, res, 0.001);
3399 "mov eax,0x40289999\n"
3401 "mov eax,0x9999999a\n"
3403 "movsd xmm0,[esp]\n"
3404 "cvtsd2ss xmm1,xmm0\n"
3405 "movss [esp],xmm1\n"
3419 typedef int (*DoubleToIntConversionRoundCode)(
double d);
3421 reinterpret_cast<DoubleToIntConversionRoundCode
>(
test->entry())(12.3);
3423 res =
reinterpret_cast<DoubleToIntConversionRoundCode
>(
test->entry())(12.8);
3426 "movsd xmm3,[esp+0x4]\n"
3427 "cvtsd2si eax,xmm3\n"
3438 typedef int (*DoubleToIntConversionTruncCode)(
double d);
3440 reinterpret_cast<DoubleToIntConversionTruncCode
>(
test->entry())(12.3);
3442 res =
reinterpret_cast<DoubleToIntConversionTruncCode
>(
test->entry())(12.8);
3445 "movsd xmm3,[esp+0x4]\n"
3446 "cvttsd2si eax,xmm3\n"
3456 __ fldl(Address(
ESP, 0));
3463 typedef double (*DoubleToDoubleTruncCode)(
double d);
3464 double res =
reinterpret_cast<DoubleToDoubleTruncCode
>(
test->entry())(12.3);
3465 EXPECT_EQ(12.0, res);
3466 res =
reinterpret_cast<DoubleToDoubleTruncCode
>(
test->entry())(12.8);
3467 EXPECT_EQ(12.0, res);
3468 res =
reinterpret_cast<DoubleToDoubleTruncCode
>(
test->entry())(-12.3);
3469 EXPECT_EQ(-12.0, res);
3470 res =
reinterpret_cast<DoubleToDoubleTruncCode
>(
test->entry())(-12.8);
3471 EXPECT_EQ(-12.0, res);
3473 "movsd xmm3,[esp+0x4]\n"
3474 "roundsd edx, ebx, 3\n"
3477 "movsd [esp],xmm2\n"
3484static const double kDoubleConst = 3.226;
3491 __ fldl(Address(
ESP, 0));
3498 typedef double (*GlobalAddressCode)();
3499 double res =
reinterpret_cast<GlobalAddressCode
>(
test->entry())();
3500 EXPECT_FLOAT_EQ(kDoubleConst, res, 0.000001);
3502 "movsd xmm0,[0x........]\n"
3505 "movsd [esp],xmm0\n"
3519 typedef float (*SineCode)(
float f);
3520 const float kFloatConst = 0.7;
3521 float res =
reinterpret_cast<SineCode
>(
test->entry())(kFloatConst);
3522 EXPECT_FLOAT_EQ(sin(kFloatConst), res, 0.0001);
3536 typedef float (*CosineCode)(
float f);
3537 const float kFloatConst = 0.7;
3538 float res =
reinterpret_cast<CosineCode
>(
test->entry())(kFloatConst);
3539 EXPECT_FLOAT_EQ(cos(kFloatConst), res, 0.0001);
3550 __ fstpl(Address(
ESP, 0));
3552 __ fstpl(Address(
ESP, 0));
3556 __ fldl(Address(
ESP, 0));
3562 typedef double (*SinCosCode)(
double d);
3563 const double arg = 1.2345;
3564 const double expected = sin(arg) - cos(arg);
3565 double res =
reinterpret_cast<SinCosCode
>(
test->entry())(arg);
3566 EXPECT_FLOAT_EQ(expected, res, 0.000001);
3572 "movsd xmm0,[esp]\n"
3574 "movsd xmm1,[esp]\n"
3576 "movsd [esp],xmm1\n"
3591 typedef double (*TangentCode)(
double d);
3592 const double kDoubleConst = 0.6108652375000001;
3593 double res =
reinterpret_cast<TangentCode
>(
test->entry())(kDoubleConst);
3594 EXPECT_FLOAT_EQ(tan(kDoubleConst), res, 0.0001);
3608 __ flds(Address(
ESP, 0));
3614 typedef float (*SquareRootFloatCode)(
float f);
3615 const float kFloatConst = 0.7;
3616 float res =
reinterpret_cast<SquareRootFloatCode
>(
test->entry())(kFloatConst);
3617 EXPECT_FLOAT_EQ(
sqrt(kFloatConst), res, 0.0001);
3619 "movss xmm0,[esp+0x4]\n"
3620 "sqrtss xmm1,xmm0\n"
3622 "movss [esp],xmm1\n"
3634 __ fldl(Address(
ESP, 0));
3641 typedef double (*SquareRootDoubleCode)(
double d);
3642 const double kDoubleConst = .7;
3644 reinterpret_cast<SquareRootDoubleCode
>(
test->entry())(kDoubleConst);
3645 EXPECT_FLOAT_EQ(
sqrt(kDoubleConst), res, 0.0001);
3647 "movsd xmm0,[esp+0x4]\n"
3648 "sqrtsd xmm1,xmm0\n"
3651 "movsd [esp],xmm1\n"
3668 __ movl(
EAX, Immediate(0));
3673 typedef intptr_t (*XmmAluTest)();
3674 intptr_t res =
reinterpret_cast<XmmAluTest
>(
test->entry())();
3681 "cvtss2sd xmm0,xmm0\n"
3682 "cvtsd2ss xmm0,xmm0\n"
3683 "cvtps2pd xmm0,xmm0\n"
3684 "cvtpd2ps xmm0,xmm0\n"
3694 __ flds(Address(
ESP, 0));
3700 typedef float (*FloatNegateCode)(
float f);
3701 const float kFloatConst = 12.345;
3702 float res =
reinterpret_cast<FloatNegateCode
>(
test->entry())(kFloatConst);
3703 EXPECT_FLOAT_EQ(-kFloatConst, res, 0.0001);
3705 "movss xmm0,[esp+0x4]\n"
3706 "xorps xmm0,[0x........]\n"
3708 "movss [esp],xmm0\n"
3720 __ fldl(Address(
ESP, 0));
3727 typedef double (*DoubleNegateCode)(
double f);
3728 const double kDoubleConst = 12.345;
3729 double res =
reinterpret_cast<DoubleNegateCode
>(
test->entry())(kDoubleConst);
3730 EXPECT_FLOAT_EQ(-kDoubleConst, res, 0.0001);
3732 "movsd xmm0,[esp+0x4]\n"
3733 "xorpd xmm0,[0x........]\n"
3736 "movsd [esp],xmm0\n"
3751 typedef int64_t (*LongMulRegCode)(
int a,
int b);
3754 const int64_t mul_res =
a *
b;
3755 int64_t res =
reinterpret_cast<LongMulRegCode
>(
test->entry())(
a,
b);
3756 EXPECT_EQ(mul_res, res);
3758 "mov ecx,[esp+0x4]\n"
3759 "mov eax,[esp+0x8]\n"
3760 "imul (eax,edx),ecx\n"
3771 typedef int64_t (*LongMulAddressCode)(
int a,
int b);
3774 const int64_t mul_res =
a *
b;
3775 int64_t res =
reinterpret_cast<LongMulAddressCode
>(
test->entry())(
a,
b);
3776 EXPECT_EQ(mul_res, res);
3778 "mov eax,[esp+0x8]\n"
3779 "imul (eax,edx),[esp+0x4]\n"
3791 typedef uint64_t (*LongUnsignedMulRegCode)(uint32_t
a, uint32_t
b);
3794 uint64_t mul_res =
a *
b;
3795 uint64_t res =
reinterpret_cast<LongUnsignedMulRegCode
>(
test->entry())(
a,
b);
3796 EXPECT_EQ(mul_res, res);
3799 res =
reinterpret_cast<LongUnsignedMulRegCode
>(
test->entry())(
a,
b);
3800 mul_res =
static_cast<uint64_t
>(
a) *
static_cast<uint64_t
>(
b);
3801 EXPECT_EQ(mul_res, res);
3803 "mov ecx,[esp+0x4]\n"
3804 "mov eax,[esp+0x8]\n"
3805 "mul (eax,edx),ecx\n"
3816 typedef uint64_t (*LongUnsignedMulAddressCode)(uint32_t
a, uint32_t
b);
3819 uint64_t mul_res =
a *
b;
3821 reinterpret_cast<LongUnsignedMulAddressCode
>(
test->entry())(
a,
b);
3822 EXPECT_EQ(mul_res, res);
3825 res =
reinterpret_cast<LongUnsignedMulAddressCode
>(
test->entry())(
a,
b);
3826 mul_res =
static_cast<uint64_t
>(
a) *
static_cast<uint64_t
>(
b);
3827 EXPECT_EQ(mul_res, res);
3829 "mov eax,[esp+0x8]\n"
3830 "mul (eax,edx),[esp+0x4]\n"
3849 typedef int64_t (*LongAddRegCode)(int64_t
a, int64_t
b);
3852 int64_t res =
reinterpret_cast<LongAddRegCode
>(
test->entry())(
a,
b);
3853 EXPECT_EQ((
a +
b), res);
3856 res =
reinterpret_cast<LongAddRegCode
>(
test->entry())(
a,
b);
3857 EXPECT_EQ((
a +
b), res);
3860 "mov eax,[esp+0x8]\n"
3861 "mov edx,[esp+0xc]\n"
3862 "mov ecx,[esp+0x10]\n"
3863 "mov ebx,[esp+0x14]\n"
3880 typedef int64_t (*LongAddAddressCode)(int64_t
a, int64_t
b);
3883 int64_t res =
reinterpret_cast<LongAddAddressCode
>(
test->entry())(
a,
b);
3884 EXPECT_EQ((
a +
b), res);
3887 res =
reinterpret_cast<LongAddAddressCode
>(
test->entry())(
a,
b);
3888 EXPECT_EQ((
a +
b), res);
3890 "mov eax,[esp+0x4]\n"
3891 "mov edx,[esp+0x8]\n"
3892 "add eax,[esp+0xc]\n"
3893 "adc edx,[esp+0x10]\n"
3912 typedef int64_t (*LongSubRegCode)(int64_t
a, int64_t
b);
3915 int64_t res =
reinterpret_cast<LongSubRegCode
>(
test->entry())(
a,
b);
3916 EXPECT_EQ((
a -
b), res);
3919 res =
reinterpret_cast<LongSubRegCode
>(
test->entry())(
a,
b);
3920 EXPECT_EQ((
a -
b), res);
3923 "mov eax,[esp+0x8]\n"
3924 "mov edx,[esp+0xc]\n"
3925 "mov ecx,[esp+0x10]\n"
3926 "mov ebx,[esp+0x14]\n"
3943 typedef int64_t (*LongSubAddressCode)(int64_t
a, int64_t
b);
3946 int64_t res =
reinterpret_cast<LongSubAddressCode
>(
test->entry())(
a,
b);
3947 EXPECT_EQ((
a -
b), res);
3950 res =
reinterpret_cast<LongSubAddressCode
>(
test->entry())(
a,
b);
3951 EXPECT_EQ((
a -
b), res);
3953 "mov eax,[esp+0x4]\n"
3954 "mov edx,[esp+0x8]\n"
3955 "sub eax,[esp+0xc]\n"
3956 "sbb edx,[esp+0x10]\n"
3981 typedef int64_t (*LongSubAddress2Code)(int64_t
a, int64_t
b);
3984 int64_t res =
reinterpret_cast<LongSubAddress2Code
>(
test->entry())(
a,
b);
3985 EXPECT_EQ((
a -
b), res);
3988 res =
reinterpret_cast<LongSubAddress2Code
>(
test->entry())(
a,
b);
3989 EXPECT_EQ((
a -
b), res);
3992 "mov eax,[esp+0x8]\n"
3993 "mov edx,[esp+0xc]\n"
3994 "mov ecx,[esp+0x10]\n"
3995 "mov ebx,[esp+0x14]\n"
3998 "mov [esp+0x4],edx\n"
4000 "sbb [esp+0x4],ebx\n"
4002 "mov edx,[esp+0x4]\n"
4029 typedef int64_t (*LongAddAddress2Code)(int64_t
a, int64_t
b);
4032 int64_t res =
reinterpret_cast<LongAddAddress2Code
>(
test->entry())(
a,
b);
4033 EXPECT_EQ((
a +
b), res);
4036 res =
reinterpret_cast<LongAddAddress2Code
>(
test->entry())(
a,
b);
4037 EXPECT_EQ((
a +
b), res);
4040 "mov eax,[esp+0x8]\n"
4041 "mov edx,[esp+0xc]\n"
4042 "mov ecx,[esp+0x10]\n"
4043 "mov ebx,[esp+0x14]\n"
4046 "mov [esp+0x4],edx\n"
4048 "adc [esp+0x4],ebx\n"
4050 "mov edx,[esp+0x4]\n"
4063 __ fldl(Address(
ESP, 0));
4070 typedef double (*IntegerToDoubleConversionCode)(int32_t);
4071 const int32_t val = -12;
4073 reinterpret_cast<IntegerToDoubleConversionCode
>(
test->entry())(val);
4074 EXPECT_FLOAT_EQ(
static_cast<double>(val), res, 0.001);
4076 "movsd xmm1,[esp+0x4]\n"
4077 "cvtdq2pd xmm2,xmm1\n"
4080 "movsd [esp],xmm2\n"
4092 __ fnstcw(Address(
ESP, 0));
4094 __ orl(
EAX, Immediate(0x0c00));
4099 __ fistpl(Address(
ESP, 0));
4102 __ fldcw(Address(
ESP, 0));
4108 typedef int64_t (*FPUStoreLongCode)(
double d);
4110 int64_t res =
reinterpret_cast<FPUStoreLongCode
>(
test->entry())(val);
4111 EXPECT_EQ(
static_cast<int64_t
>(val), res);
4113 res =
reinterpret_cast<FPUStoreLongCode
>(
test->entry())(val);
4114 EXPECT_EQ(
static_cast<int64_t
>(val), res);
4116 res =
reinterpret_cast<FPUStoreLongCode
>(
test->entry())(val);
4117 EXPECT_EQ(
static_cast<int64_t
>(val), res);
4119 res =
reinterpret_cast<FPUStoreLongCode
>(
test->entry())(val);
4120 EXPECT_EQ(
static_cast<int64_t
>(val), res);
4126 "movzxw eax,[esp]\n"
4128 "movw [esp+0x4],eax\n"
4146 __ fldl(Address(
ESP, 0));
4153 typedef double (*XorpdZeroingCode)(
double d);
4154 double res =
reinterpret_cast<XorpdZeroingCode
>(
test->entry())(12.56e3);
4155 EXPECT_FLOAT_EQ(0.0, res, 0.0001);
4157 "movsd xmm0,[esp+0x4]\n"
4161 "movsd [esp],xmm0\n"
4174 __ fldl(Address(
ESP, 0));
4181 typedef double (*PxorCode)(
double d);
4182 double res =
reinterpret_cast<PxorCode
>(
test->entry())(12.3456e3);
4183 EXPECT_FLOAT_EQ(0.0, res, 0.0);
4185 "movsd xmm0,[esp+0x4]\n"
4189 "movsd [esp],xmm0\n"
4204 __ fldl(Address(
ESP, 0));
4211 typedef double (*OrpdCode)(
double d);
4212 double res =
reinterpret_cast<OrpdCode
>(
test->entry())(12.56e3);
4213 EXPECT_FLOAT_EQ(-12.56e3, res, 0.0);
4215 "movsd xmm0,[esp+0x4]\n"
4217 "xorpd xmm1,[0x........]\n"
4221 "movsd [esp],xmm0\n"
4238 typedef int32_t (*PextrdCode0)(
double d);
4239 int32_t res =
reinterpret_cast<PextrdCode0
>(
test->entry())(123456789);
4240 EXPECT_EQ(0x54000000, res);
4243 "movsd xmm0,[esp+0x4]\n"
4244 "pextrd eax,xmm0,0\n"
4258 typedef int32_t (*PextrdCode1)(
double d);
4259 int32_t res =
reinterpret_cast<PextrdCode1
>(
test->entry())(123456789);
4260 EXPECT_EQ(0x419d6f34, res);
4263 "movsd xmm0,[esp+0x4]\n"
4264 "pextrd eax,xmm0,1\n"
4279 typedef int32_t (*PmovsxdqCode)(
double d);
4280 int32_t res =
reinterpret_cast<PmovsxdqCode
>(
test->entry())(123456789);
4284 "movsd xmm0,[esp+0x4]\n"
4285 "pmovsxdq xmm0,xmm0\n"
4286 "pextrd eax,xmm0,1\n"
4302 typedef int32_t (*PcmpeqqCode)(
double d);
4303 int32_t res =
reinterpret_cast<PcmpeqqCode
>(
test->entry())(0);
4307 "movsd xmm0,[esp+0x4]\n"
4309 "pcmpeqq xmm0,xmm1\n"
4320 __ fldl(Address(
ESP, 0));
4327 typedef double (*AndpdCode)(
double d);
4328 double res =
reinterpret_cast<AndpdCode
>(
test->entry())(12.56e3);
4329 EXPECT_FLOAT_EQ(12.56e3, res, 0.0);
4331 "movsd xmm0,[esp+0x4]\n"
4335 "movsd [esp],xmm0\n"
4346 __ fldl(Address(
ESP, 0));
4352 typedef double (*MovqCode)(
double d);
4353 double res =
reinterpret_cast<MovqCode
>(
test->entry())(12.34e5);
4354 EXPECT_FLOAT_EQ(12.34e5, res, 0.0);
4356 "movq xmm0, [esp+0x4]\n"
4370 __ fldl(Address(
ESP, 0));
4377 typedef double (*DoubleAbsCode)(
double d);
4378 double val = -12.45;
4379 double res =
reinterpret_cast<DoubleAbsCode
>(
test->entry())(val);
4380 EXPECT_FLOAT_EQ(-val, res, 0.001);
4382 res =
reinterpret_cast<DoubleAbsCode
>(
test->entry())(val);
4383 EXPECT_FLOAT_EQ(val, res, 0.001);
4385 "movsd xmm0,[esp+0x4]\n"
4386 "andpd xmm0,[0x........]\n"
4389 "movsd [esp],xmm0\n"
4399 __ andl(
EAX, Immediate(0x1));
4404 typedef int (*ExtractSignBits)(
double d);
4405 int res =
reinterpret_cast<ExtractSignBits
>(
test->entry())(1.0);
4407 res =
reinterpret_cast<ExtractSignBits
>(
test->entry())(-1.0);
4409 res =
reinterpret_cast<ExtractSignBits
>(
test->entry())(-0.0);
4412 "movsd xmm0,[esp+0x4]\n"
4413 "movmskpd eax,xmm0\n"
4425 __ movl(
EBX, Immediate(1));
4426 __ movl(
ECX, Immediate(-1));
4438 typedef int (*ConditionalMovesSignCode)(
int i);
4439 int res =
reinterpret_cast<ConditionalMovesSignCode
>(
test->entry())(785);
4441 res =
reinterpret_cast<ConditionalMovesSignCode
>(
test->entry())(-12);
4445 "mov edx,[esp+0x8]\n"
4448 "mov ecx,0xffffffff\n"
4461 __ movl(
EAX, Immediate(1));
4462 __ movl(
ECX, Immediate(0));
4468 typedef int (*ConditionalMovesNoOverflowCode)(
int i,
int j);
4469 int res =
reinterpret_cast<ConditionalMovesNoOverflowCode
>(
test->entry())(
4472 res =
reinterpret_cast<ConditionalMovesNoOverflowCode
>(
test->entry())(1, 1);
4475 "mov edx,[esp+0x4]\n"
4476 "add edx,[esp+0x8]\n"
4486 __ movl(
ECX, Immediate(1));
4488 __ cmpl(
EDX, Immediate(785));
4494 typedef int (*ConditionalMovesEqualCode)(
int i);
4495 int res =
reinterpret_cast<ConditionalMovesEqualCode
>(
test->entry())(785);
4497 res =
reinterpret_cast<ConditionalMovesEqualCode
>(
test->entry())(-12);
4502 "mov edx,[esp+0x4]\n"
4511 __ movl(
ECX, Immediate(1));
4513 __ cmpl(
EDX, Immediate(785));
4519 typedef int (*ConditionalMovesNotEqualCode)(
int i);
4520 int res =
reinterpret_cast<ConditionalMovesNotEqualCode
>(
test->entry())(785);
4522 res =
reinterpret_cast<ConditionalMovesNotEqualCode
>(
test->entry())(-12);
4527 "mov edx,[esp+0x4]\n"
4534 __ movl(
EDX, Immediate(1));
4535 __ movl(
ECX, Immediate(-1));
4544 typedef int (*ConditionalMovesCompareCode)(
int i,
int j);
4545 int res =
reinterpret_cast<ConditionalMovesCompareCode
>(
test->entry())(10, 5);
4547 res =
reinterpret_cast<ConditionalMovesCompareCode
>(
test->entry())(5, 5);
4549 res =
reinterpret_cast<ConditionalMovesCompareCode
>(
test->entry())(2, 5);
4553 "mov ecx,0xffffffff\n"
4554 "mov eax,[esp+0x4]\n"
4555 "cmp eax,[esp+0x8]\n"
4562 __ LoadDImmediate(
XMM3, -12.34);
4566 __ fldl(Address(
ESP, 0));
4573 typedef double (*TestLoadDImmediateCode)();
4574 double res =
reinterpret_cast<TestLoadDImmediateCode
>(
test->entry())();
4575 EXPECT_FLOAT_EQ(-12.34, res, 0.0001);
4579 "movsd xmm3,[esp]\n"
4583 "movsd [esp],xmm3\n"
4594 __ LoadObject(
EAX, obj);
4595 __ CompareObject(
EAX, obj);
4597 __ LoadObject(
ECX, obj);
4598 __ CompareObject(
ECX, obj);
4600 __ movl(
EAX, Immediate(1));
4603 __ movl(
EAX, Immediate(0));
4608 typedef bool (*TestObjectCompare)();
4609 bool res =
reinterpret_cast<TestObjectCompare
>(
test->entry())();
4610 EXPECT_EQ(
true, res);
4615 __ movl(
EAX, Immediate(0xFFFFFFFF));
4622 typedef uword (*TestSetCC)();
4623 uword res =
reinterpret_cast<TestSetCC
>(
test->entry())();
4624 EXPECT_EQ(0xFFFFFF00, res);
4626 "mov eax,0xffffffff\n"
4641 __ movl(
EAX, Immediate(assembler->CodeSize()));
4646 typedef int (*TestNop)();
4647 int res =
reinterpret_cast<TestNop
>(
test->entry())();
4664 __ movl(
EAX, Immediate(assembler->CodeSize()));
4669 typedef int (*TestAlign0)();
4670 int res =
reinterpret_cast<TestAlign0
>(
test->entry())();
4680 __ movl(
EAX, Immediate(assembler->CodeSize()));
4685 typedef int (*TestAlign1)();
4686 int res =
reinterpret_cast<TestAlign1
>(
test->entry())();
4698 __ movl(
EAX, Immediate(assembler->CodeSize()));
4703 typedef int (*TestAlign1Offset1)();
4704 int res =
reinterpret_cast<TestAlign1Offset1
>(
test->entry())();
4716 __ movl(
EAX, Immediate(assembler->CodeSize()));
4721 typedef int (*TestAlignLarge)();
4722 int res =
reinterpret_cast<TestAlignLarge
>(
test->entry())();
4748 const char* from =
"0123456789x";
4749 char* to =
new char[11]{0};
4751 typedef void (*TestRepMovsBytes)(
const char* from,
char* to,
int count);
4752 reinterpret_cast<TestRepMovsBytes
>(
test->entry())(from, to, 10);
4753 EXPECT_EQ(to[0],
'0');
4754 for (
int i = 0;
i < 10;
i++) {
4755 EXPECT_EQ(from[
i], to[
i]);
4757 EXPECT_EQ(to[10],
'y');
4763 "mov esi,[esp+0x10]\n"
4764 "mov edi,[esp+0x14]\n"
4765 "mov ecx,[esp+0x18]\n"
4789 const uint16_t from[11] = {0x0123, 0x1234, 0x2345, 0x3456, 0x4567, 0x5678,
4790 0x6789, 0x789A, 0x89AB, 0x9ABC, 0xABCD};
4791 uint16_t* to =
new uint16_t[11]{0};
4793 typedef void (*TestRepMovsWords)(
const uint16_t* from, uint16_t* to,
4795 reinterpret_cast<TestRepMovsWords
>(
test->entry())(from, to, 10);
4796 EXPECT_EQ(to[0], 0x0123u);
4797 for (
int i = 0;
i < 10;
i++) {
4798 EXPECT_EQ(from[
i], to[
i]);
4800 EXPECT_EQ(to[10], 0xFEFEu);
4806 "mov esi,[esp+0x10]\n"
4807 "mov edi,[esp+0x14]\n"
4808 "mov ecx,[esp+0x18]\n"
4832 const uint32_t from[11] = {0x01234567, 0x12345678, 0x23456789, 0x3456789A,
4833 0x456789AB, 0x56789ABC, 0x6789ABCD, 0x789ABCDE,
4834 0x89ABCDEF, 0x9ABCDEF0, 0xABCDEF01};
4835 uint32_t* to =
new uint32_t[11]{0};
4836 to[10] = 0xFEFEFEFE;
4837 typedef void (*TestRepMovsDwords)(
const uint32_t* from, uint32_t* to,
4839 reinterpret_cast<TestRepMovsDwords
>(
test->entry())(from, to, 10);
4840 EXPECT_EQ(to[0], 0x01234567u);
4841 for (
int i = 0;
i < 10;
i++) {
4842 EXPECT_EQ(from[
i], to[
i]);
4844 EXPECT_EQ(to[10], 0xFEFEFEFEu);
4850 "mov esi,[esp+0x10]\n"
4851 "mov edi,[esp+0x14]\n"
4852 "mov ecx,[esp+0x18]\n"
4875 __ movl(
EAX, Immediate(4));
4876 __ movl(
ECX, Immediate(2));
4882 __ movl(
EAX, Immediate(1));
4887 typedef int (*BitTest)();
4888 EXPECT_EQ(1,
reinterpret_cast<BitTest
>(
test->entry())());
4900 __ movl(
ECX, Immediate(32));
4906 __ movl(
EAX, Immediate(1));
4911 typedef int (*BitTestImmediate)();
4912 EXPECT_EQ(1,
reinterpret_cast<BitTestImmediate
>(
test->entry())());
4923#define ALU_TEST(NAME, WIDTH, INTRO, LHS, RHS, OUTRO) \
4924 ASSEMBLER_TEST_GENERATE(NAME, assembler) { \
4925 __ movl(EAX, Immediate(0x87654321)); \
4926 __ movl(ECX, Immediate(0x12345678)); \
4930 __ and##WIDTH(LHS, RHS); \
4931 __ or##WIDTH(RHS, LHS); \
4932 __ xor##WIDTH(LHS, RHS); \
4933 __ add##WIDTH(RHS, LHS); \
4934 __ cmp##WIDTH(LHS, RHS); \
4935 __ adc##WIDTH(LHS, RHS); \
4936 __ sub##WIDTH(RHS, LHS); \
4937 __ sbb##WIDTH(LHS, RHS); \
4941 __ xorl(ECX, ECX); \
4942 __ add##WIDTH(ECX, EAX); \
4943 __ andl(EAX, ECX); \
4947 ASSEMBLER_TEST_RUN(NAME, test) { \
4948 typedef uint32_t (*NAME)(); \
4949 uint32_t expectation_l = 0x42649381; \
4950 uint16_t expectation_w = expectation_l; \
4951 uint32_t expectation = expectation_##WIDTH | expectation_w; \
4952 EXPECT_EQ(expectation, reinterpret_cast<NAME>(test->entry())()); \
4956ALU_TEST(RegRegW,
w, ,
EAX,
ECX, )
4959ALU_TEST(RegRegL, l, ,
EAX,
ECX, )
4963#define IMMEDIATE_TEST(NAME, REG, MASK, INTRO, VALUE, OUTRO) \
4964 ASSEMBLER_TEST_GENERATE(NAME, assembler) { \
4965 __ movl(REG, Immediate(0x87654321)); \
4969 __ andl(VALUE, Immediate(0xa8df51d3 & MASK)); \
4970 __ orl(VALUE, Immediate(0x1582a681 & MASK)); \
4971 __ xorl(VALUE, Immediate(0xa5a5a5a5 & MASK)); \
4972 __ addl(VALUE, Immediate(0x7fffffff & MASK)); \
4973 __ cmpl(VALUE, Immediate(0x40404040 & MASK)); \
4974 __ adcl(VALUE, Immediate(0x6eeeeeee & MASK)); \
4975 __ subl(VALUE, Immediate(0x7eeeeeee & MASK)); \
4976 __ sbbl(VALUE, Immediate(0x6fffffff & MASK)); \
4980 __ movl(EAX, REG); \
4984 ASSEMBLER_TEST_RUN(NAME, test) { \
4985 typedef uint32_t (*NAME)(); \
4986 uint32_t expectation = MASK < 0x100 ? 0x24 : 0x30624223; \
4987 EXPECT_EQ(expectation, reinterpret_cast<NAME>(test->entry())()); \
4993IMMEDIATE_TEST(RegImmEAX,
EAX, 0xffffffff, ,
EAX, )
4994IMMEDIATE_TEST(RegImmECX,
ECX, 0xffffffff, ,
ECX, )
4995IMMEDIATE_TEST(RegImmEAXByte,
EAX, 0x7f, ,
EAX, )
4996IMMEDIATE_TEST(RegImmECXByte,
ECX, 0x7f, ,
ECX, )
4997IMMEDIATE_TEST(AddrImmEAX,
5003IMMEDIATE_TEST(AddrImmEAXByte,
5015 __ movl(return_reg, Immediate(0));
5018 __ movl(return_reg, Immediate(1));
5026 RangeCheck(assembler,
value, temp);
5031 result =
test->Invoke<intptr_t, intptr_t>(kErrorCid);
5033 result =
test->Invoke<intptr_t, intptr_t>(kUnwindErrorCid);
5035 result =
test->Invoke<intptr_t, intptr_t>(kFunctionCid);
5037 result =
test->Invoke<intptr_t, intptr_t>(kMintCid);
5045 RangeCheck(assembler,
value, temp);
5050 result =
test->Invoke<intptr_t, intptr_t>(kErrorCid);
5052 result =
test->Invoke<intptr_t, intptr_t>(kUnwindErrorCid);
5054 result =
test->Invoke<intptr_t, intptr_t>(kFunctionCid);
5056 result =
test->Invoke<intptr_t, intptr_t>(kMintCid);
5075 result =
test->Invoke<intptr_t, intptr_t>(kErrorCid);
5076 EXPECT_EQ(kErrorCid,
result);
5077 result =
test->Invoke<intptr_t, intptr_t>(kUnwindErrorCid);
5078 EXPECT_EQ(kUnwindErrorCid,
result);
5079 result =
test->Invoke<intptr_t, intptr_t>(kFunctionCid);
5080 EXPECT_EQ(kFunctionCid,
result);
5081 result =
test->Invoke<intptr_t, intptr_t>(kMintCid);
5082 EXPECT_EQ(kMintCid,
result);
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
static void fail(const SkString &err)
static bool ok(int result)
static constexpr Register kFirstNonArgumentRegister
static constexpr Register kReturnReg
static constexpr Register kSecondNonArgumentRegister
static intptr_t data_offset()
static bool popcnt_supported()
static bool abm_supported()
static Instr * At(uword pc)
ObjectStore * object_store() const
static IsolateGroup * Current()
static intptr_t ActivationFrameAlignment()
static Object & ZoneHandle()
static bool sse4_1_supported()
static int32_t Low32Bits(int64_t value)
static int32_t High32Bits(int64_t value)
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
static Address Absolute(const uword addr)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static constexpr intptr_t kWordSize
void LeaveTestFrame(Assembler *assembler)
ASSEMBLER_TEST_GENERATE(InstantiateTypeArgumentsHashKeys, assembler)
void EnterTestFrame(Assembler *assembler)
static const ClassId kLastErrorCid
static const ClassId kFirstErrorCid
ASSEMBLER_TEST_RUN(StoreIntoObject, test)
constexpr intptr_t kDoubleSize
static bool Bind(PassBindingsCacheMTL &pass, ShaderStage stage, size_t bind_index, const BufferView &view)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
SIN Vec< N, uint16_t > mull(const Vec< N, uint8_t > &x, const Vec< N, uint8_t > &y)
#define OFFSET_OF(type, field)