6#if defined(TARGET_ARCH_RISCV32) || defined(TARGET_ARCH_RISCV64)
20#define EXPECT_DISASSEMBLY(expected)
22#define EXPECT_DISASSEMBLY(expected) \
23 EXPECT_STREQ(expected, test->RelativeDisassembly())
33 __ PushNativeCalleeSavedRegisters();
36 __ RestorePinnedRegisters();
41 __ PopNativeCalleeSavedRegisters();
46static intx_t Call(intx_t entry,
51#if defined(USING_SIMULATOR)
54 typedef intx_t (*
F)(intx_t, intx_t, intx_t, intx_t);
55 return reinterpret_cast<F>(entry)(arg0, arg1, arg2, arg3);
58static float CallF(intx_t entry, intx_t arg0) {
59#if defined(USING_SIMULATOR)
62 typedef float (*
F)(intx_t);
63 return reinterpret_cast<F>(entry)(arg0);
66static float CallF(intx_t entry, intx_t arg0,
float arg1) {
67#if defined(USING_SIMULATOR)
71 return reinterpret_cast<F>(entry)(arg0, arg1);
74static float CallF(intx_t entry,
double arg0) {
75#if defined(USING_SIMULATOR)
78 typedef float (*
F)(double);
79 return reinterpret_cast<F>(entry)(arg0);
82static float CallF(intx_t entry,
float arg0) {
83#if defined(USING_SIMULATOR)
87 return reinterpret_cast<F>(entry)(arg0);
90static float CallF(intx_t entry,
float arg0,
float arg1) {
91#if defined(USING_SIMULATOR)
95 return reinterpret_cast<F>(entry)(arg0, arg1);
98static float CallF(intx_t entry,
float arg0,
float arg1,
float arg2) {
99#if defined(USING_SIMULATOR)
103 return reinterpret_cast<F>(entry)(arg0, arg1, arg2);
106static intx_t CallI(intx_t entry,
float arg0) {
107#if defined(USING_SIMULATOR)
110 typedef intx_t (*
F)(
float);
111 return reinterpret_cast<F>(entry)(arg0);
114static intx_t CallI(intx_t entry,
float arg0,
float arg1) {
115#if defined(USING_SIMULATOR)
119 return reinterpret_cast<F>(entry)(arg0, arg1);
122static double CallD(intx_t entry, intx_t arg0) {
123#if defined(USING_SIMULATOR)
126 typedef double (*
F)(intx_t);
127 return reinterpret_cast<F>(entry)(arg0);
130static double CallD(intx_t entry, intx_t arg0,
double arg1) {
131#if defined(USING_SIMULATOR)
134 typedef double (*
F)(intx_t, double);
135 return reinterpret_cast<F>(entry)(arg0, arg1);
138static double CallD(intx_t entry,
float arg0) {
139#if defined(USING_SIMULATOR)
142 typedef double (*
F)(
float);
143 return reinterpret_cast<F>(entry)(arg0);
146static double CallD(intx_t entry,
double arg0) {
147#if defined(USING_SIMULATOR)
150 typedef double (*
F)(double);
151 return reinterpret_cast<F>(entry)(arg0);
154static double CallD(intx_t entry,
double arg0,
double arg1) {
155#if defined(USING_SIMULATOR)
158 typedef double (*
F)(double, double);
159 return reinterpret_cast<F>(entry)(arg0, arg1);
162static double CallD(intx_t entry,
double arg0,
double arg1,
double arg2) {
163#if defined(USING_SIMULATOR)
166 typedef double (*
F)(double, double, double);
167 return reinterpret_cast<F>(entry)(arg0, arg1, arg2);
170static intx_t CallI(intx_t entry,
double arg0) {
171#if defined(USING_SIMULATOR)
174 typedef intx_t (*
F)(double);
175 return reinterpret_cast<F>(entry)(arg0);
178static intx_t CallI(intx_t entry,
double arg0,
double arg1) {
179#if defined(USING_SIMULATOR)
182 typedef intx_t (*
F)(double, double);
183 return reinterpret_cast<F>(entry)(arg0, arg1);
188 FLAG_use_compressed_instructions =
false;
191 __ lui(
A0, 42 << 16);
196 "002a0537 lui a0, 2752512\n"
198 EXPECT_EQ(42 << 16, Call(
test->entry()));
202 FLAG_use_compressed_instructions =
false;
210 "00000517 auipc a0, 0\n"
212 EXPECT_EQ(
test->entry(),
static_cast<uintx_t
>(Call(
test->entry())));
216 FLAG_use_compressed_instructions =
false;
219 Label label1, label2;
238 "01c00eef jal t4, +28\n"
239 "40628533 sub a0, t0, t1\n"
242 "00700313 li t1, 7\n"
245 "00400293 li t0, 4\n"
246 "ff1fff6f jal t5, -16\n"
249 EXPECT_EQ(-3, Call(
test->entry()));
253 FLAG_use_compressed_instructions =
false;
256 Label label1, label2;
272 "00700313 li t1, 7\n"
273 "40628533 sub a0, t0, t1\n"
275 "00400293 li t0, 4\n"
278 EXPECT_EQ(-3, Call(
test->entry()));
282 FLAG_use_compressed_instructions =
false;
301 "01c58ee7 jalr t4, 28(a1)\n"
302 "40628533 sub a0, t0, t1\n"
305 "00700313 li t1, 7\n"
308 "00400293 li t0, 4\n"
309 "01058f67 jalr t5, 16(a1)\n"
312 EXPECT_EQ(-3, Call(
test->entry(), 0,
test->entry()));
316 FLAG_use_compressed_instructions =
false;
330 "01458067 jr 20(a1)\n"
332 "00700313 li t1, 7\n"
333 "40628533 sub a0, t0, t1\n"
335 "00400293 li t0, 4\n"
336 "00858067 jr 8(a1)\n"
338 EXPECT_EQ(-3, Call(
test->entry(), 0,
test->entry()));
342 FLAG_use_compressed_instructions =
false;
355 "00b50663 beq a0, a1, +12\n"
356 "00300513 li a0, 3\n"
358 "00400513 li a0, 4\n"
360 EXPECT_EQ(4, Call(
test->entry(), 1, 1));
361 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
362 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
363 EXPECT_EQ(3, Call(
test->entry(), 0, 1));
364 EXPECT_EQ(4, Call(
test->entry(), 0, 0));
365 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
366 EXPECT_EQ(3, Call(
test->entry(), -1, 1));
367 EXPECT_EQ(3, Call(
test->entry(), -1, 0));
368 EXPECT_EQ(4, Call(
test->entry(), -1, -1));
372 FLAG_use_compressed_instructions =
false;
379 for (intptr_t
i = 0;
i < (1 << 13);
i++) {
388 EXPECT_EQ(4, Call(
test->entry(), 1, 1));
389 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
390 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
391 EXPECT_EQ(3, Call(
test->entry(), 0, 1));
392 EXPECT_EQ(4, Call(
test->entry(), 0, 0));
393 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
394 EXPECT_EQ(3, Call(
test->entry(), -1, 1));
395 EXPECT_EQ(3, Call(
test->entry(), -1, 0));
396 EXPECT_EQ(4, Call(
test->entry(), -1, -1));
400 FLAG_use_compressed_instructions =
false;
413 "00b51663 bne a0, a1, +12\n"
414 "00300513 li a0, 3\n"
416 "00400513 li a0, 4\n"
418 EXPECT_EQ(3, Call(
test->entry(), 1, 1));
419 EXPECT_EQ(4, Call(
test->entry(), 1, 0));
420 EXPECT_EQ(4, Call(
test->entry(), 1, -1));
421 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
422 EXPECT_EQ(3, Call(
test->entry(), 0, 0));
423 EXPECT_EQ(4, Call(
test->entry(), 0, -1));
424 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
425 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
426 EXPECT_EQ(3, Call(
test->entry(), -1, -1));
430 FLAG_use_compressed_instructions =
false;
437 for (intptr_t
i = 0;
i < (1 << 13);
i++) {
446 EXPECT_EQ(3, Call(
test->entry(), 1, 1));
447 EXPECT_EQ(4, Call(
test->entry(), 1, 0));
448 EXPECT_EQ(4, Call(
test->entry(), 1, -1));
449 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
450 EXPECT_EQ(3, Call(
test->entry(), 0, 0));
451 EXPECT_EQ(4, Call(
test->entry(), 0, -1));
452 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
453 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
454 EXPECT_EQ(3, Call(
test->entry(), -1, -1));
458 FLAG_use_compressed_instructions =
false;
471 "00b54663 blt a0, a1, +12\n"
472 "00300513 li a0, 3\n"
474 "00400513 li a0, 4\n"
476 EXPECT_EQ(3, Call(
test->entry(), 1, 1));
477 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
478 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
479 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
480 EXPECT_EQ(3, Call(
test->entry(), 0, 0));
481 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
482 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
483 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
484 EXPECT_EQ(3, Call(
test->entry(), -1, -1));
488 FLAG_use_compressed_instructions =
false;
495 for (intptr_t
i = 0;
i < (1 << 13);
i++) {
504 EXPECT_EQ(3, Call(
test->entry(), 1, 1));
505 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
506 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
507 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
508 EXPECT_EQ(3, Call(
test->entry(), 0, 0));
509 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
510 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
511 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
512 EXPECT_EQ(3, Call(
test->entry(), -1, -1));
516 FLAG_use_compressed_instructions =
false;
529 "00a5d663 ble a0, a1, +12\n"
530 "00300513 li a0, 3\n"
532 "00400513 li a0, 4\n"
534 EXPECT_EQ(4, Call(
test->entry(), 1, 1));
535 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
536 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
537 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
538 EXPECT_EQ(4, Call(
test->entry(), 0, 0));
539 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
540 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
541 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
542 EXPECT_EQ(4, Call(
test->entry(), -1, -1));
546 FLAG_use_compressed_instructions =
false;
553 for (intptr_t
i = 0;
i < (1 << 13);
i++) {
562 EXPECT_EQ(4, Call(
test->entry(), 1, 1));
563 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
564 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
565 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
566 EXPECT_EQ(4, Call(
test->entry(), 0, 0));
567 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
568 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
569 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
570 EXPECT_EQ(4, Call(
test->entry(), -1, -1));
574 FLAG_use_compressed_instructions =
false;
587 "00a5c663 blt a1, a0, +12\n"
588 "00300513 li a0, 3\n"
590 "00400513 li a0, 4\n"
592 EXPECT_EQ(3, Call(
test->entry(), 1, 1));
593 EXPECT_EQ(4, Call(
test->entry(), 1, 0));
594 EXPECT_EQ(4, Call(
test->entry(), 1, -1));
595 EXPECT_EQ(3, Call(
test->entry(), 0, 1));
596 EXPECT_EQ(3, Call(
test->entry(), 0, 0));
597 EXPECT_EQ(4, Call(
test->entry(), 0, -1));
598 EXPECT_EQ(3, Call(
test->entry(), -1, 1));
599 EXPECT_EQ(3, Call(
test->entry(), -1, 0));
600 EXPECT_EQ(3, Call(
test->entry(), -1, -1));
604 FLAG_use_compressed_instructions =
false;
617 "00b55663 ble a1, a0, +12\n"
618 "00300513 li a0, 3\n"
620 "00400513 li a0, 4\n"
622 EXPECT_EQ(4, Call(
test->entry(), 1, 1));
623 EXPECT_EQ(4, Call(
test->entry(), 1, 0));
624 EXPECT_EQ(4, Call(
test->entry(), 1, -1));
625 EXPECT_EQ(3, Call(
test->entry(), 0, 1));
626 EXPECT_EQ(4, Call(
test->entry(), 0, 0));
627 EXPECT_EQ(4, Call(
test->entry(), 0, -1));
628 EXPECT_EQ(3, Call(
test->entry(), -1, 1));
629 EXPECT_EQ(3, Call(
test->entry(), -1, 0));
630 EXPECT_EQ(4, Call(
test->entry(), -1, -1));
634 FLAG_use_compressed_instructions =
false;
647 "00b56663 bltu a0, a1, +12\n"
648 "00300513 li a0, 3\n"
650 "00400513 li a0, 4\n"
652 EXPECT_EQ(3, Call(
test->entry(), 1, 1));
653 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
654 EXPECT_EQ(4, Call(
test->entry(), 1, -1));
655 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
656 EXPECT_EQ(3, Call(
test->entry(), 0, 0));
657 EXPECT_EQ(4, Call(
test->entry(), 0, -1));
658 EXPECT_EQ(3, Call(
test->entry(), -1, 1));
659 EXPECT_EQ(3, Call(
test->entry(), -1, 0));
660 EXPECT_EQ(3, Call(
test->entry(), -1, -1));
664 FLAG_use_compressed_instructions =
false;
677 "00a5f663 bleu a0, a1, +12\n"
678 "00300513 li a0, 3\n"
680 "00400513 li a0, 4\n"
682 EXPECT_EQ(4, Call(
test->entry(), 1, 1));
683 EXPECT_EQ(3, Call(
test->entry(), 1, 0));
684 EXPECT_EQ(4, Call(
test->entry(), 1, -1));
685 EXPECT_EQ(4, Call(
test->entry(), 0, 1));
686 EXPECT_EQ(4, Call(
test->entry(), 0, 0));
687 EXPECT_EQ(4, Call(
test->entry(), 0, -1));
688 EXPECT_EQ(3, Call(
test->entry(), -1, 1));
689 EXPECT_EQ(3, Call(
test->entry(), -1, 0));
690 EXPECT_EQ(4, Call(
test->entry(), -1, -1));
694 FLAG_use_compressed_instructions =
false;
707 "00a5e663 bltu a1, a0, +12\n"
708 "00300513 li a0, 3\n"
710 "00400513 li a0, 4\n"
712 EXPECT_EQ(3, Call(
test->entry(), 1, 1));
713 EXPECT_EQ(4, Call(
test->entry(), 1, 0));
714 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
715 EXPECT_EQ(3, Call(
test->entry(), 0, 1));
716 EXPECT_EQ(3, Call(
test->entry(), 0, 0));
717 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
718 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
719 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
720 EXPECT_EQ(3, Call(
test->entry(), -1, -1));
724 FLAG_use_compressed_instructions =
false;
737 "00b57663 bleu a1, a0, +12\n"
738 "00300513 li a0, 3\n"
740 "00400513 li a0, 4\n"
742 EXPECT_EQ(4, Call(
test->entry(), 1, 1));
743 EXPECT_EQ(4, Call(
test->entry(), 1, 0));
744 EXPECT_EQ(3, Call(
test->entry(), 1, -1));
745 EXPECT_EQ(3, Call(
test->entry(), 0, 1));
746 EXPECT_EQ(4, Call(
test->entry(), 0, 0));
747 EXPECT_EQ(3, Call(
test->entry(), 0, -1));
748 EXPECT_EQ(4, Call(
test->entry(), -1, 1));
749 EXPECT_EQ(4, Call(
test->entry(), -1, 0));
750 EXPECT_EQ(4, Call(
test->entry(), -1, -1));
754 FLAG_use_compressed_instructions =
false;
756 __ lb(
A0, Address(
A0, 0));
761 "00050503 lb a0, 0(a0)\n"
764 uint8_t*
values =
reinterpret_cast<uint8_t*
>(
malloc(3 *
sizeof(uint8_t)));
768 EXPECT_EQ(-51, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
773 FLAG_use_compressed_instructions =
false;
775 __ lb(
A0, Address(
A0, 1));
780 "00150503 lb a0, 1(a0)\n"
783 uint8_t*
values =
reinterpret_cast<uint8_t*
>(
malloc(3 *
sizeof(uint8_t)));
788 EXPECT_EQ(-17, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
793 FLAG_use_compressed_instructions =
false;
795 __ lb(
A0, Address(
A0, -1));
800 "fff50503 lb a0, -1(a0)\n"
803 uint8_t*
values =
reinterpret_cast<uint8_t*
>(
malloc(3 *
sizeof(uint8_t)));
808 EXPECT_EQ(-85, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
813 FLAG_use_compressed_instructions =
false;
815 __ lbu(
A0, Address(
A0, 0));
820 "00054503 lbu a0, 0(a0)\n"
823 uint8_t*
values =
reinterpret_cast<uint8_t*
>(
malloc(3 *
sizeof(uint8_t)));
828 EXPECT_EQ(0xCD, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
833 FLAG_use_compressed_instructions =
false;
835 __ lbu(
A0, Address(
A0, 1));
840 "00154503 lbu a0, 1(a0)\n"
843 uint8_t*
values =
reinterpret_cast<uint8_t*
>(
malloc(3 *
sizeof(uint8_t)));
848 EXPECT_EQ(0xEF, Call(
test->entry(),
reinterpret_cast<intx_t
>((&
values[1]))));
853 FLAG_use_compressed_instructions =
false;
855 __ lbu(
A0, Address(
A0, -1));
860 "fff54503 lbu a0, -1(a0)\n"
863 uint8_t*
values =
reinterpret_cast<uint8_t*
>(
malloc(3 *
sizeof(uint8_t)));
868 EXPECT_EQ(0xAB, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
872 FLAG_use_compressed_instructions =
false;
874 __ lh(
A0, Address(
A0, 0));
879 "00051503 lh a0, 0(a0)\n"
882 uint16_t*
values =
reinterpret_cast<uint16_t*
>(
malloc(3 *
sizeof(uint16_t)));
887 EXPECT_EQ(-13054, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
890 FLAG_use_compressed_instructions =
false;
892 __ lh(
A0, Address(
A0, 2));
897 "00251503 lh a0, 2(a0)\n"
900 uint16_t*
values =
reinterpret_cast<uint16_t*
>(
malloc(3 *
sizeof(uint16_t)));
905 EXPECT_EQ(-4349, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
908 FLAG_use_compressed_instructions =
false;
910 __ lh(
A0, Address(
A0, -2));
915 "ffe51503 lh a0, -2(a0)\n"
918 uint16_t*
values =
reinterpret_cast<uint16_t*
>(
malloc(3 *
sizeof(uint16_t)));
923 EXPECT_EQ(-21759, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
927 FLAG_use_compressed_instructions =
false;
929 __ lhu(
A0, Address(
A0, 0));
934 "00055503 lhu a0, 0(a0)\n"
937 uint16_t*
values =
reinterpret_cast<uint16_t*
>(
malloc(3 *
sizeof(uint16_t)));
942 EXPECT_EQ(0xCD02, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
946 FLAG_use_compressed_instructions =
false;
948 __ lhu(
A0, Address(
A0, 2));
953 "00255503 lhu a0, 2(a0)\n"
956 uint16_t*
values =
reinterpret_cast<uint16_t*
>(
malloc(3 *
sizeof(uint16_t)));
961 EXPECT_EQ(0xEF03, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
964 FLAG_use_compressed_instructions =
false;
966 __ lhu(
A0, Address(
A0, -2));
971 "ffe55503 lhu a0, -2(a0)\n"
974 uint16_t*
values =
reinterpret_cast<uint16_t*
>(
malloc(3 *
sizeof(uint16_t)));
979 EXPECT_EQ(0xAB01, Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
983 FLAG_use_compressed_instructions =
false;
985 __ lw(
A0, Address(
A0, 0));
990 "00052503 lw a0, 0(a0)\n"
993 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
998 EXPECT_EQ(-855505915,
999 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1002 FLAG_use_compressed_instructions =
false;
1004 __ lw(
A0, Address(
A0, 4));
1009 "00452503 lw a0, 4(a0)\n"
1012 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1017 EXPECT_EQ(-285014521,
1018 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1021 FLAG_use_compressed_instructions =
false;
1023 __ lw(
A0, Address(
A0, -4));
1028 "ffc52503 lw a0, -4(a0)\n"
1031 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1036 EXPECT_EQ(-1425997309,
1037 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1041 FLAG_use_compressed_instructions =
false;
1043 __ sw(
A1, Address(
A0, 0));
1048 "00b52023 sw a1, 0(a0)\n"
1051 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1056 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xCD020405);
1057 EXPECT_EQ(0u,
values[0]);
1058 EXPECT_EQ(0xCD020405,
values[1]);
1059 EXPECT_EQ(0u,
values[2]);
1062 FLAG_use_compressed_instructions =
false;
1064 __ sw(
A1, Address(
A0, 4));
1069 "00b52223 sw a1, 4(a0)\n"
1072 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1077 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xEF030607);
1078 EXPECT_EQ(0u,
values[0]);
1079 EXPECT_EQ(0u,
values[1]);
1080 EXPECT_EQ(0xEF030607,
values[2]);
1083 FLAG_use_compressed_instructions =
false;
1085 __ sw(
A1, Address(
A0, -4));
1090 "feb52e23 sw a1, -4(a0)\n"
1093 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1098 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xAB010203);
1099 EXPECT_EQ(0xAB010203,
values[0]);
1100 EXPECT_EQ(0u,
values[1]);
1101 EXPECT_EQ(0u,
values[2]);
1106 FLAG_use_compressed_instructions =
false;
1108 __ lwu(
A0, Address(
A0, 0));
1113 "00056503 lwu a0, 0(a0)\n"
1116 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1121 EXPECT_EQ(0xCD020405,
1122 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1125 FLAG_use_compressed_instructions =
false;
1127 __ lwu(
A0, Address(
A0, 4));
1132 "00456503 lwu a0, 4(a0)\n"
1135 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1140 EXPECT_EQ(0xEF030607,
1141 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1144 FLAG_use_compressed_instructions =
false;
1146 __ lwu(
A0, Address(
A0, -4));
1151 "ffc56503 lwu a0, -4(a0)\n"
1154 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
1159 EXPECT_EQ(0xAB010203,
1160 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1164 FLAG_use_compressed_instructions =
false;
1166 __ ld(
A0, Address(
A0, 0));
1171 "00053503 ld a0, 0(a0)\n"
1174 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
1175 values[0] = 0xAB01020304050607;
1176 values[1] = 0xCD02040505060708;
1177 values[2] = 0xEF03060708090A0B;
1179 EXPECT_EQ(-3674369926375274744,
1180 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1183 FLAG_use_compressed_instructions =
false;
1185 __ ld(
A0, Address(
A0, 8));
1190 "00853503 ld a0, 8(a0)\n"
1193 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
1194 values[0] = 0xAB01020304050607;
1195 values[1] = 0xCD02040505060708;
1196 values[2] = 0xEF03060708090A0B;
1198 EXPECT_EQ(-1224128046445295093,
1199 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1202 FLAG_use_compressed_instructions =
false;
1204 __ ld(
A0, Address(
A0, -8));
1209 "ff853503 ld a0, -8(a0)\n"
1212 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
1213 values[0] = 0xAB01020304050607;
1214 values[1] = 0xCD02040505060708;
1215 values[2] = 0xEF03060708090A0B;
1217 EXPECT_EQ(-6124611806271568377,
1218 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
1222 FLAG_use_compressed_instructions =
false;
1224 __ sd(
A1, Address(
A0, 0));
1229 "00b53023 sd a1, 0(a0)\n"
1232 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
1237 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xCD02040505060708);
1238 EXPECT_EQ(0u,
values[0]);
1239 EXPECT_EQ(0xCD02040505060708,
values[1]);
1240 EXPECT_EQ(0u,
values[2]);
1243 FLAG_use_compressed_instructions =
false;
1245 __ sd(
A1, Address(
A0, 8));
1250 "00b53423 sd a1, 8(a0)\n"
1253 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
1258 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xEF03060708090A0B);
1259 EXPECT_EQ(0u,
values[0]);
1260 EXPECT_EQ(0u,
values[1]);
1261 EXPECT_EQ(0xEF03060708090A0B,
values[2]);
1264 FLAG_use_compressed_instructions =
false;
1266 __ sd(
A1, Address(
A0, -8));
1271 "feb53c23 sd a1, -8(a0)\n"
1274 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
1279 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xAB01020304050607);
1280 EXPECT_EQ(0xAB01020304050607,
values[0]);
1281 EXPECT_EQ(0u,
values[1]);
1282 EXPECT_EQ(0u,
values[2]);
1287 FLAG_use_compressed_instructions =
false;
1294 "02a50513 addi a0, a0, 42\n"
1296 EXPECT_EQ(42, Call(
test->entry(), 0));
1297 EXPECT_EQ(40, Call(
test->entry(), -2));
1298 EXPECT_EQ(0, Call(
test->entry(), -42));
1302 FLAG_use_compressed_instructions =
false;
1309 "fd650513 addi a0, a0, -42\n"
1311 EXPECT_EQ(-42, Call(
test->entry(), 0));
1312 EXPECT_EQ(-44, Call(
test->entry(), -2));
1313 EXPECT_EQ(38, Call(
test->entry(), 80));
1317 FLAG_use_compressed_instructions =
false;
1324 "00752513 slti a0, a0, 7\n"
1326 EXPECT_EQ(1, Call(
test->entry(), 6));
1327 EXPECT_EQ(0, Call(
test->entry(), 7));
1328 EXPECT_EQ(0, Call(
test->entry(), 8));
1329 EXPECT_EQ(1, Call(
test->entry(), -6));
1330 EXPECT_EQ(1, Call(
test->entry(), -7));
1331 EXPECT_EQ(1, Call(
test->entry(), -8));
1335 FLAG_use_compressed_instructions =
false;
1342 "ff952513 slti a0, a0, -7\n"
1344 EXPECT_EQ(0, Call(
test->entry(), 6));
1345 EXPECT_EQ(0, Call(
test->entry(), 7));
1346 EXPECT_EQ(0, Call(
test->entry(), 8));
1347 EXPECT_EQ(0, Call(
test->entry(), -6));
1348 EXPECT_EQ(0, Call(
test->entry(), -7));
1349 EXPECT_EQ(1, Call(
test->entry(), -8));
1353 FLAG_use_compressed_instructions =
false;
1360 "00753513 sltiu a0, a0, 7\n"
1362 EXPECT_EQ(1, Call(
test->entry(), 6));
1363 EXPECT_EQ(0, Call(
test->entry(), 7));
1364 EXPECT_EQ(0, Call(
test->entry(), 8));
1365 EXPECT_EQ(0, Call(
test->entry(), -6));
1366 EXPECT_EQ(0, Call(
test->entry(), -7));
1367 EXPECT_EQ(0, Call(
test->entry(), -8));
1371 FLAG_use_compressed_instructions =
false;
1378 "ff953513 sltiu a0, a0, -7\n"
1380 EXPECT_EQ(1, Call(
test->entry(), 6));
1381 EXPECT_EQ(1, Call(
test->entry(), 7));
1382 EXPECT_EQ(1, Call(
test->entry(), 8));
1383 EXPECT_EQ(0, Call(
test->entry(), -6));
1384 EXPECT_EQ(0, Call(
test->entry(), -7));
1385 EXPECT_EQ(1, Call(
test->entry(), -8));
1389 FLAG_use_compressed_instructions =
false;
1396 "02a54513 xori a0, a0, 42\n"
1398 EXPECT_EQ(42, Call(
test->entry(), 0));
1399 EXPECT_EQ(43, Call(
test->entry(), 1));
1400 EXPECT_EQ(32, Call(
test->entry(), 10));
1401 EXPECT_EQ(-43, Call(
test->entry(), -1));
1402 EXPECT_EQ(-36, Call(
test->entry(), -10));
1406 FLAG_use_compressed_instructions =
false;
1413 "fd654513 xori a0, a0, -42\n"
1415 EXPECT_EQ(-42, Call(
test->entry(), 0));
1416 EXPECT_EQ(-41, Call(
test->entry(), 1));
1417 EXPECT_EQ(-36, Call(
test->entry(), 10));
1418 EXPECT_EQ(41, Call(
test->entry(), -1));
1419 EXPECT_EQ(32, Call(
test->entry(), -10));
1423 FLAG_use_compressed_instructions =
false;
1430 "ffa56513 ori a0, a0, -6\n"
1432 EXPECT_EQ(-6, Call(
test->entry(), 0));
1433 EXPECT_EQ(-5, Call(
test->entry(), 1));
1434 EXPECT_EQ(-5, Call(
test->entry(), 11));
1435 EXPECT_EQ(-1, Call(
test->entry(), -1));
1436 EXPECT_EQ(-1, Call(
test->entry(), -11));
1440 FLAG_use_compressed_instructions =
false;
1447 "00656513 ori a0, a0, 6\n"
1449 EXPECT_EQ(6, Call(
test->entry(), 0));
1450 EXPECT_EQ(7, Call(
test->entry(), 1));
1451 EXPECT_EQ(15, Call(
test->entry(), 11));
1452 EXPECT_EQ(-1, Call(
test->entry(), -1));
1453 EXPECT_EQ(-9, Call(
test->entry(), -11));
1457 FLAG_use_compressed_instructions =
false;
1464 "ffa57513 andi a0, a0, -6\n"
1466 EXPECT_EQ(0, Call(
test->entry(), 0));
1467 EXPECT_EQ(0, Call(
test->entry(), 1));
1468 EXPECT_EQ(10, Call(
test->entry(), 11));
1469 EXPECT_EQ(-6, Call(
test->entry(), -1));
1470 EXPECT_EQ(-16, Call(
test->entry(), -11));
1474 FLAG_use_compressed_instructions =
false;
1481 "00657513 andi a0, a0, 6\n"
1483 EXPECT_EQ(0, Call(
test->entry(), 0));
1484 EXPECT_EQ(0, Call(
test->entry(), 1));
1485 EXPECT_EQ(2, Call(
test->entry(), 11));
1486 EXPECT_EQ(6, Call(
test->entry(), -1));
1487 EXPECT_EQ(4, Call(
test->entry(), -11));
1491 FLAG_use_compressed_instructions =
false;
1498 "00251513 slli a0, a0, 0x2\n"
1500 EXPECT_EQ(84, Call(
test->entry(), 21));
1501 EXPECT_EQ(4, Call(
test->entry(), 1));
1502 EXPECT_EQ(0, Call(
test->entry(), 0));
1503 EXPECT_EQ(-4, Call(
test->entry(), -1));
1504 EXPECT_EQ(-84, Call(
test->entry(), -21));
1508 FLAG_use_compressed_instructions =
false;
1510 __ slli(
A0,
A0, XLEN - 1);
1516 "01f51513 slli a0, a0, 0x1f\n"
1520 "03f51513 slli a0, a0, 0x3f\n"
1523 EXPECT_EQ(0, Call(
test->entry(), 2));
1524 EXPECT_EQ(kMinIntX, Call(
test->entry(), 1));
1525 EXPECT_EQ(0, Call(
test->entry(), 0));
1526 EXPECT_EQ(kMinIntX, Call(
test->entry(), -1));
1527 EXPECT_EQ(0, Call(
test->entry(), -2));
1531 FLAG_use_compressed_instructions =
false;
1538 "00255513 srli a0, a0, 0x2\n"
1540 EXPECT_EQ(5, Call(
test->entry(), 21));
1541 EXPECT_EQ(0, Call(
test->entry(), 1));
1542 EXPECT_EQ(0, Call(
test->entry(), 0));
1543 EXPECT_EQ(
static_cast<intx_t
>(
static_cast<uintx_t
>(-1) >> 2),
1544 Call(
test->entry(), -1));
1545 EXPECT_EQ(
static_cast<intx_t
>(
static_cast<uintx_t
>(-21) >> 2),
1546 Call(
test->entry(), -21));
1550 FLAG_use_compressed_instructions =
false;
1552 __ srli(
A0,
A0, XLEN - 1);
1558 "01f55513 srli a0, a0, 0x1f\n"
1562 "03f55513 srli a0, a0, 0x3f\n"
1565 EXPECT_EQ(0, Call(
test->entry(), 21));
1566 EXPECT_EQ(0, Call(
test->entry(), 1));
1567 EXPECT_EQ(0, Call(
test->entry(), 0));
1568 EXPECT_EQ(1, Call(
test->entry(), -1));
1569 EXPECT_EQ(1, Call(
test->entry(), -21));
1573 FLAG_use_compressed_instructions =
false;
1580 "40255513 srai a0, a0, 0x2\n"
1582 EXPECT_EQ(5, Call(
test->entry(), 21));
1583 EXPECT_EQ(0, Call(
test->entry(), 1));
1584 EXPECT_EQ(0, Call(
test->entry(), 0));
1585 EXPECT_EQ(-1, Call(
test->entry(), -1));
1586 EXPECT_EQ(-6, Call(
test->entry(), -21));
1590 FLAG_use_compressed_instructions =
false;
1592 __ srai(
A0,
A0, XLEN - 1);
1598 "41f55513 srai a0, a0, 0x1f\n"
1602 "43f55513 srai a0, a0, 0x3f\n"
1605 EXPECT_EQ(0, Call(
test->entry(), 21));
1606 EXPECT_EQ(0, Call(
test->entry(), 1));
1607 EXPECT_EQ(0, Call(
test->entry(), 0));
1608 EXPECT_EQ(-1, Call(
test->entry(), -1));
1609 EXPECT_EQ(-1, Call(
test->entry(), -21));
1613 FLAG_use_compressed_instructions =
false;
1620 "00b50533 add a0, a0, a1\n"
1622 EXPECT_EQ(24, Call(
test->entry(), 7, 17));
1623 EXPECT_EQ(-10, Call(
test->entry(), 7, -17));
1624 EXPECT_EQ(10, Call(
test->entry(), -7, 17));
1625 EXPECT_EQ(-24, Call(
test->entry(), -7, -17));
1626 EXPECT_EQ(24, Call(
test->entry(), 17, 7));
1627 EXPECT_EQ(10, Call(
test->entry(), 17, -7));
1628 EXPECT_EQ(-10, Call(
test->entry(), -17, 7));
1629 EXPECT_EQ(-24, Call(
test->entry(), -17, -7));
1633 FLAG_use_compressed_instructions =
false;
1640 "40b50533 sub a0, a0, a1\n"
1642 EXPECT_EQ(-10, Call(
test->entry(), 7, 17));
1643 EXPECT_EQ(24, Call(
test->entry(), 7, -17));
1644 EXPECT_EQ(-24, Call(
test->entry(), -7, 17));
1645 EXPECT_EQ(10, Call(
test->entry(), -7, -17));
1646 EXPECT_EQ(10, Call(
test->entry(), 17, 7));
1647 EXPECT_EQ(24, Call(
test->entry(), 17, -7));
1648 EXPECT_EQ(-24, Call(
test->entry(), -17, 7));
1649 EXPECT_EQ(-10, Call(
test->entry(), -17, -7));
1653 FLAG_use_compressed_instructions =
false;
1660 "00b51533 sll a0, a0, a1\n"
1662 EXPECT_EQ(2176, Call(
test->entry(), 17, 7));
1663 EXPECT_EQ(-2176, Call(
test->entry(), -17, 7));
1664 EXPECT_EQ(34, Call(
test->entry(), 17, 1));
1665 EXPECT_EQ(-34, Call(
test->entry(), -17, 1));
1666 EXPECT_EQ(17, Call(
test->entry(), 17, 0));
1667 EXPECT_EQ(-17, Call(
test->entry(), -17, 0));
1671 FLAG_use_compressed_instructions =
false;
1678 "00b52533 slt a0, a0, a1\n"
1680 EXPECT_EQ(0, Call(
test->entry(), 7, 7));
1681 EXPECT_EQ(0, Call(
test->entry(), -7, -7));
1682 EXPECT_EQ(1, Call(
test->entry(), 7, 17));
1683 EXPECT_EQ(0, Call(
test->entry(), 7, -17));
1684 EXPECT_EQ(1, Call(
test->entry(), -7, 17));
1685 EXPECT_EQ(0, Call(
test->entry(), -7, -17));
1686 EXPECT_EQ(0, Call(
test->entry(), 17, 7));
1687 EXPECT_EQ(0, Call(
test->entry(), 17, -7));
1688 EXPECT_EQ(1, Call(
test->entry(), -17, 7));
1689 EXPECT_EQ(1, Call(
test->entry(), -17, -7));
1693 FLAG_use_compressed_instructions =
false;
1700 "00b53533 sltu a0, a0, a1\n"
1702 EXPECT_EQ(0, Call(
test->entry(), 7, 7));
1703 EXPECT_EQ(0, Call(
test->entry(), -7, -7));
1704 EXPECT_EQ(1, Call(
test->entry(), 7, 17));
1705 EXPECT_EQ(1, Call(
test->entry(), 7, -17));
1706 EXPECT_EQ(0, Call(
test->entry(), -7, 17));
1707 EXPECT_EQ(0, Call(
test->entry(), -7, -17));
1708 EXPECT_EQ(0, Call(
test->entry(), 17, 7));
1709 EXPECT_EQ(1, Call(
test->entry(), 17, -7));
1710 EXPECT_EQ(0, Call(
test->entry(), -17, 7));
1711 EXPECT_EQ(1, Call(
test->entry(), -17, -7));
1715 FLAG_use_compressed_instructions =
false;
1722 "00b54533 xor a0, a0, a1\n"
1724 EXPECT_EQ(22, Call(
test->entry(), 7, 17));
1725 EXPECT_EQ(-24, Call(
test->entry(), 7, -17));
1726 EXPECT_EQ(-24, Call(
test->entry(), -7, 17));
1727 EXPECT_EQ(22, Call(
test->entry(), -7, -17));
1728 EXPECT_EQ(22, Call(
test->entry(), 17, 7));
1729 EXPECT_EQ(-24, Call(
test->entry(), 17, -7));
1730 EXPECT_EQ(-24, Call(
test->entry(), -17, 7));
1731 EXPECT_EQ(22, Call(
test->entry(), -17, -7));
1735 FLAG_use_compressed_instructions =
false;
1742 "00b55533 srl a0, a0, a1\n"
1744 EXPECT_EQ(0, Call(
test->entry(), 17, 7));
1745 EXPECT_EQ(
static_cast<intx_t
>(
static_cast<uintx_t
>(-17) >> 7),
1746 Call(
test->entry(), -17, 7));
1747 EXPECT_EQ(8, Call(
test->entry(), 17, 1));
1748 EXPECT_EQ(
static_cast<intx_t
>(
static_cast<uintx_t
>(-17) >> 1),
1749 Call(
test->entry(), -17, 1));
1750 EXPECT_EQ(17, Call(
test->entry(), 17, 0));
1751 EXPECT_EQ(-17, Call(
test->entry(), -17, 0));
1755 FLAG_use_compressed_instructions =
false;
1762 "40b55533 sra a0, a0, a1\n"
1764 EXPECT_EQ(0, Call(
test->entry(), 17, 7));
1765 EXPECT_EQ(-1, Call(
test->entry(), -17, 7));
1766 EXPECT_EQ(8, Call(
test->entry(), 17, 1));
1767 EXPECT_EQ(-9, Call(
test->entry(), -17, 1));
1768 EXPECT_EQ(17, Call(
test->entry(), 17, 0));
1769 EXPECT_EQ(-17, Call(
test->entry(), -17, 0));
1773 FLAG_use_compressed_instructions =
false;
1780 "00b56533 or a0, a0, a1\n"
1782 EXPECT_EQ(23, Call(
test->entry(), 7, 17));
1783 EXPECT_EQ(-17, Call(
test->entry(), 7, -17));
1784 EXPECT_EQ(-7, Call(
test->entry(), -7, 17));
1785 EXPECT_EQ(-1, Call(
test->entry(), -7, -17));
1786 EXPECT_EQ(23, Call(
test->entry(), 17, 7));
1787 EXPECT_EQ(-7, Call(
test->entry(), 17, -7));
1788 EXPECT_EQ(-17, Call(
test->entry(), -17, 7));
1789 EXPECT_EQ(-1, Call(
test->entry(), -17, -7));
1793 FLAG_use_compressed_instructions =
false;
1800 "00b57533 and a0, a0, a1\n"
1802 EXPECT_EQ(1, Call(
test->entry(), 7, 17));
1803 EXPECT_EQ(7, Call(
test->entry(), 7, -17));
1804 EXPECT_EQ(17, Call(
test->entry(), -7, 17));
1805 EXPECT_EQ(-23, Call(
test->entry(), -7, -17));
1806 EXPECT_EQ(1, Call(
test->entry(), 17, 7));
1807 EXPECT_EQ(17, Call(
test->entry(), 17, -7));
1808 EXPECT_EQ(7, Call(
test->entry(), -17, 7));
1809 EXPECT_EQ(-23, Call(
test->entry(), -17, -7));
1813 FLAG_use_compressed_instructions =
false;
1816 __ fence(kRead, kWrite);
1819 __ fence(kAll, kAll);
1825 "0210000f fence r,w\n"
1826 "0840000f fence i,o\n"
1827 "0330000f fence rw,rw\n"
1830 Call(
test->entry());
1834 FLAG_use_compressed_instructions =
false;
1841 "0000100f fence.i\n"
1843 Call(
test->entry());
1847 FLAG_use_compressed_instructions =
false;
1861 FLAG_use_compressed_instructions =
false;
1875 FLAG_use_compressed_instructions =
false;
1884 __ csrrwi(
T1, 0x123, 1);
1885 __ csrrsi(
T2, 0x123, 2);
1886 __ csrrci(
T3, 0x123, 3);
1894 "123492f3 csrrw t0, 0x123, thr\n"
1895 "12392373 csrrs t1, 0x123, s2\n"
1896 "1239b3f3 csrrc t2, 0x123, s3\n"
1897 "12302e73 csrr t3, 0x123\n"
1898 "123a1073 csrw 0x123, s4\n"
1899 "123aa073 csrs 0x123, s5\n"
1900 "123b3073 csrc 0x123, s6\n"
1901 "1230d373 csrrwi t1, 0x123, 1\n"
1902 "123163f3 csrrsi t2, 0x123, 2\n"
1903 "1231fe73 csrrci t3, 0x123, 3\n"
1904 "12325073 csrwi 0x123, 4\n"
1905 "1232e073 csrsi 0x123, 5\n"
1906 "12337073 csrci 0x123, 6\n"
1913 FLAG_use_compressed_instructions =
false;
1922 EXPECT_EQ(123, Call(
test->entry(), 123));
1926 FLAG_use_compressed_instructions =
false;
1933 "00058513 mv a0, a1\n"
1935 EXPECT_EQ(36, Call(
test->entry(), 42, 36));
1939 FLAG_use_compressed_instructions =
false;
1946 "fff54513 not a0, a0\n"
1948 EXPECT_EQ(~42, Call(
test->entry(), 42));
1949 EXPECT_EQ(~-42, Call(
test->entry(), -42));
1953 FLAG_use_compressed_instructions =
false;
1960 "40a00533 neg a0, a0\n"
1962 EXPECT_EQ(-42, Call(
test->entry(), 42));
1963 EXPECT_EQ(42, Call(
test->entry(), -42));
1967 FLAG_use_compressed_instructions =
false;
1974 "00a03533 snez a0, a0\n"
1976 EXPECT_EQ(1, Call(
test->entry(), -42));
1977 EXPECT_EQ(0, Call(
test->entry(), 0));
1978 EXPECT_EQ(1, Call(
test->entry(), 42));
1982 FLAG_use_compressed_instructions =
false;
1989 "00153513 seqz a0, a0\n"
1991 EXPECT_EQ(0, Call(
test->entry(), -42));
1992 EXPECT_EQ(1, Call(
test->entry(), 0));
1993 EXPECT_EQ(0, Call(
test->entry(), 42));
1997 FLAG_use_compressed_instructions =
false;
2004 "00052533 sltz a0, a0\n"
2006 EXPECT_EQ(1, Call(
test->entry(), -42));
2007 EXPECT_EQ(0, Call(
test->entry(), 0));
2008 EXPECT_EQ(0, Call(
test->entry(), 42));
2012 FLAG_use_compressed_instructions =
false;
2019 "00a02533 sgtz a0, a0\n"
2021 EXPECT_EQ(0, Call(
test->entry(), -42));
2022 EXPECT_EQ(0, Call(
test->entry(), 0));
2023 EXPECT_EQ(1, Call(
test->entry(), 42));
2027 FLAG_use_compressed_instructions =
false;
2030 __ beqz(
A0, &label);
2039 "00050663 beqz a0, +12\n"
2040 "00300513 li a0, 3\n"
2042 "00400513 li a0, 4\n"
2044 EXPECT_EQ(3, Call(
test->entry(), -42));
2045 EXPECT_EQ(4, Call(
test->entry(), 0));
2046 EXPECT_EQ(3, Call(
test->entry(), 42));
2050 FLAG_use_compressed_instructions =
false;
2053 __ bnez(
A0, &label);
2062 "00051663 bnez a0, +12\n"
2063 "00300513 li a0, 3\n"
2065 "00400513 li a0, 4\n"
2067 EXPECT_EQ(4, Call(
test->entry(), -42));
2068 EXPECT_EQ(3, Call(
test->entry(), 0));
2069 EXPECT_EQ(4, Call(
test->entry(), 42));
2073 FLAG_use_compressed_instructions =
false;
2076 __ blez(
A0, &label);
2085 "00a05663 blez a0, +12\n"
2086 "00300513 li a0, 3\n"
2088 "00400513 li a0, 4\n"
2090 EXPECT_EQ(4, Call(
test->entry(), -42));
2091 EXPECT_EQ(4, Call(
test->entry(), 0));
2092 EXPECT_EQ(3, Call(
test->entry(), 42));
2096 FLAG_use_compressed_instructions =
false;
2099 __ bgez(
A0, &label);
2108 "00055663 bgez a0, +12\n"
2109 "00300513 li a0, 3\n"
2111 "00400513 li a0, 4\n"
2113 EXPECT_EQ(3, Call(
test->entry(), -42));
2114 EXPECT_EQ(4, Call(
test->entry(), 0));
2115 EXPECT_EQ(4, Call(
test->entry(), 42));
2119 FLAG_use_compressed_instructions =
false;
2122 __ bltz(
A0, &label);
2131 "00054663 bltz a0, +12\n"
2132 "00300513 li a0, 3\n"
2134 "00400513 li a0, 4\n"
2136 EXPECT_EQ(4, Call(
test->entry(), -42));
2137 EXPECT_EQ(3, Call(
test->entry(), 0));
2138 EXPECT_EQ(3, Call(
test->entry(), 42));
2142 FLAG_use_compressed_instructions =
false;
2145 __ bgtz(
A0, &label);
2154 "00a04663 bgtz a0, +12\n"
2155 "00300513 li a0, 3\n"
2157 "00400513 li a0, 4\n"
2159 EXPECT_EQ(3, Call(
test->entry(), -42));
2160 EXPECT_EQ(3, Call(
test->entry(), 0));
2161 EXPECT_EQ(4, Call(
test->entry(), 42));
2166 FLAG_use_compressed_instructions =
false;
2173 "02a5051b addiw a0, a0, 42\n"
2175 EXPECT_EQ(42, Call(
test->entry(), 0));
2176 EXPECT_EQ(40, Call(
test->entry(), -2));
2177 EXPECT_EQ(0, Call(
test->entry(), -42));
2181 FLAG_use_compressed_instructions =
false;
2188 "fd65051b addiw a0, a0, -42\n"
2190 EXPECT_EQ(-42, Call(
test->entry(), 0));
2191 EXPECT_EQ(-44, Call(
test->entry(), -2));
2192 EXPECT_EQ(38, Call(
test->entry(), 80));
2196 FLAG_use_compressed_instructions =
false;
2203 "0025151b slliw a0, a0, 0x2\n"
2205 EXPECT_EQ(84, Call(
test->entry(), 21));
2206 EXPECT_EQ(4, Call(
test->entry(), 1));
2207 EXPECT_EQ(0, Call(
test->entry(), 0));
2208 EXPECT_EQ(-4, Call(
test->entry(), -1));
2209 EXPECT_EQ(-84, Call(
test->entry(), -21));
2213 FLAG_use_compressed_instructions =
false;
2220 "0025551b srliw a0, a0, 0x2\n"
2222 EXPECT_EQ(5, Call(
test->entry(), 21));
2223 EXPECT_EQ(0, Call(
test->entry(), 1));
2224 EXPECT_EQ(0, Call(
test->entry(), 0));
2225 EXPECT_EQ(
sign_extend(
static_cast<uint32_t
>(-1) >> 2),
2226 Call(
test->entry(), -1));
2227 EXPECT_EQ(
sign_extend(
static_cast<uint32_t
>(-21) >> 2),
2228 Call(
test->entry(), -21));
2232 FLAG_use_compressed_instructions =
false;
2239 "4025551b sraiw a0, a0, 0x2\n"
2241 EXPECT_EQ(5, Call(
test->entry(), 21));
2242 EXPECT_EQ(0, Call(
test->entry(), 1));
2243 EXPECT_EQ(0, Call(
test->entry(), 0));
2244 EXPECT_EQ(-1, Call(
test->entry(), -1));
2245 EXPECT_EQ(-6, Call(
test->entry(), -21));
2249 FLAG_use_compressed_instructions =
false;
2256 "00b5053b addw a0, a0, a1\n"
2258 EXPECT_EQ(24, Call(
test->entry(), 7, 17));
2259 EXPECT_EQ(-10, Call(
test->entry(), 7, -17));
2260 EXPECT_EQ(10, Call(
test->entry(), -7, 17));
2261 EXPECT_EQ(-24, Call(
test->entry(), -7, -17));
2262 EXPECT_EQ(24, Call(
test->entry(), 17, 7));
2263 EXPECT_EQ(10, Call(
test->entry(), 17, -7));
2264 EXPECT_EQ(-10, Call(
test->entry(), -17, 7));
2265 EXPECT_EQ(-24, Call(
test->entry(), -17, -7));
2266 EXPECT_EQ(3, Call(
test->entry(), 0x200000002, 0x100000001));
2270 FLAG_use_compressed_instructions =
false;
2277 "40b5053b subw a0, a0, a1\n"
2279 EXPECT_EQ(-10, Call(
test->entry(), 7, 17));
2280 EXPECT_EQ(24, Call(
test->entry(), 7, -17));
2281 EXPECT_EQ(-24, Call(
test->entry(), -7, 17));
2282 EXPECT_EQ(10, Call(
test->entry(), -7, -17));
2283 EXPECT_EQ(10, Call(
test->entry(), 17, 7));
2284 EXPECT_EQ(24, Call(
test->entry(), 17, -7));
2285 EXPECT_EQ(-24, Call(
test->entry(), -17, 7));
2286 EXPECT_EQ(-10, Call(
test->entry(), -17, -7));
2287 EXPECT_EQ(1, Call(
test->entry(), 0x200000002, 0x100000001));
2291 FLAG_use_compressed_instructions =
false;
2298 "00b5153b sllw a0, a0, a1\n"
2300 EXPECT_EQ(2176, Call(
test->entry(), 17, 7));
2301 EXPECT_EQ(-2176, Call(
test->entry(), -17, 7));
2302 EXPECT_EQ(34, Call(
test->entry(), 17, 1));
2303 EXPECT_EQ(-34, Call(
test->entry(), -17, 1));
2304 EXPECT_EQ(17, Call(
test->entry(), 17, 0));
2305 EXPECT_EQ(-17, Call(
test->entry(), -17, 0));
2306 EXPECT_EQ(0x10, Call(
test->entry(), 0x10000001, 4));
2310 FLAG_use_compressed_instructions =
false;
2317 "00b5553b srlw a0, a0, a1\n"
2319 EXPECT_EQ(0, Call(
test->entry(), 17, 7));
2320 EXPECT_EQ(
sign_extend(
static_cast<uint32_t
>(-17) >> 7),
2321 Call(
test->entry(), -17, 7));
2322 EXPECT_EQ(8, Call(
test->entry(), 17, 1));
2323 EXPECT_EQ(
sign_extend(
static_cast<uint32_t
>(-17) >> 1),
2324 Call(
test->entry(), -17, 1));
2325 EXPECT_EQ(17, Call(
test->entry(), 17, 0));
2326 EXPECT_EQ(-17, Call(
test->entry(), -17, 0));
2330 FLAG_use_compressed_instructions =
false;
2337 "40b5553b sraw a0, a0, a1\n"
2339 EXPECT_EQ(0, Call(
test->entry(), 17, 7));
2340 EXPECT_EQ(-1, Call(
test->entry(), -17, 7));
2341 EXPECT_EQ(8, Call(
test->entry(), 17, 1));
2342 EXPECT_EQ(-9, Call(
test->entry(), -17, 1));
2343 EXPECT_EQ(17, Call(
test->entry(), 17, 0));
2344 EXPECT_EQ(-17, Call(
test->entry(), -17, 0));
2348 FLAG_use_compressed_instructions =
false;
2355 "40a0053b negw a0, a0\n"
2357 EXPECT_EQ(0, Call(
test->entry(), 0));
2358 EXPECT_EQ(-42, Call(
test->entry(), 42));
2359 EXPECT_EQ(42, Call(
test->entry(), -42));
2360 EXPECT_EQ(1, Call(
test->entry(), 0x10FFFFFFFF));
2364 FLAG_use_compressed_instructions =
false;
2371 "0005051b sext.w a0, a0\n"
2373 EXPECT_EQ(0, Call(
test->entry(), 0));
2374 EXPECT_EQ(42, Call(
test->entry(), 42));
2375 EXPECT_EQ(-42, Call(
test->entry(), -42));
2376 EXPECT_EQ(-1, Call(
test->entry(), 0x10FFFFFFFF));
2381 FLAG_use_compressed_instructions =
false;
2388 "02b50533 mul a0, a0, a1\n"
2390 EXPECT_EQ(68, Call(
test->entry(), 4, 17));
2391 EXPECT_EQ(-68, Call(
test->entry(), -4, 17));
2392 EXPECT_EQ(-68, Call(
test->entry(), 4, -17));
2393 EXPECT_EQ(68, Call(
test->entry(), -4, -17));
2394 EXPECT_EQ(68, Call(
test->entry(), 17, 4));
2395 EXPECT_EQ(-68, Call(
test->entry(), -17, 4));
2396 EXPECT_EQ(-68, Call(
test->entry(), 17, -4));
2397 EXPECT_EQ(68, Call(
test->entry(), -17, -4));
2401 FLAG_use_compressed_instructions =
false;
2408 "02b51533 mulh a0, a0, a1\n"
2410 EXPECT_EQ(0, Call(
test->entry(), 4, 17));
2411 EXPECT_EQ(-1, Call(
test->entry(), -4, 17));
2412 EXPECT_EQ(-1, Call(
test->entry(), 4, -17));
2413 EXPECT_EQ(0, Call(
test->entry(), -4, -17));
2414 EXPECT_EQ(0, Call(
test->entry(), 17, 4));
2415 EXPECT_EQ(-1, Call(
test->entry(), -17, 4));
2416 EXPECT_EQ(-1, Call(
test->entry(), 17, -4));
2417 EXPECT_EQ(0, Call(
test->entry(), -17, -4));
2421 FLAG_use_compressed_instructions =
false;
2428 "02b52533 mulhsu a0, a0, a1\n"
2430 EXPECT_EQ(0, Call(
test->entry(), 4, 17));
2431 EXPECT_EQ(-1, Call(
test->entry(), -4, 17));
2432 EXPECT_EQ(3, Call(
test->entry(), 4, -17));
2433 EXPECT_EQ(-4, Call(
test->entry(), -4, -17));
2434 EXPECT_EQ(0, Call(
test->entry(), 17, 4));
2435 EXPECT_EQ(-1, Call(
test->entry(), -17, 4));
2436 EXPECT_EQ(16, Call(
test->entry(), 17, -4));
2437 EXPECT_EQ(-17, Call(
test->entry(), -17, -4));
2441 FLAG_use_compressed_instructions =
false;
2448 "02b53533 mulhu a0, a0, a1\n"
2450 EXPECT_EQ(0, Call(
test->entry(), 4, 17));
2451 EXPECT_EQ(16, Call(
test->entry(), -4, 17));
2452 EXPECT_EQ(3, Call(
test->entry(), 4, -17));
2453 EXPECT_EQ(-21, Call(
test->entry(), -4, -17));
2454 EXPECT_EQ(0, Call(
test->entry(), 17, 4));
2455 EXPECT_EQ(3, Call(
test->entry(), -17, 4));
2456 EXPECT_EQ(16, Call(
test->entry(), 17, -4));
2457 EXPECT_EQ(-21, Call(
test->entry(), -17, -4));
2461 FLAG_use_compressed_instructions =
false;
2468 "02b54533 div a0, a0, a1\n"
2470 EXPECT_EQ(0, Call(
test->entry(), 4, 17));
2471 EXPECT_EQ(0, Call(
test->entry(), -4, 17));
2472 EXPECT_EQ(0, Call(
test->entry(), 4, -17));
2473 EXPECT_EQ(0, Call(
test->entry(), -4, -17));
2474 EXPECT_EQ(4, Call(
test->entry(), 17, 4));
2475 EXPECT_EQ(-4, Call(
test->entry(), -17, 4));
2476 EXPECT_EQ(-4, Call(
test->entry(), 17, -4));
2477 EXPECT_EQ(4, Call(
test->entry(), -17, -4));
2481 FLAG_use_compressed_instructions =
false;
2488 "02b55533 divu a0, a0, a1\n"
2490 EXPECT_EQ(0, Call(
test->entry(), 4, 17));
2492 EXPECT_EQ(252645134, Call(
test->entry(), -4, 17));
2494 EXPECT_EQ(1085102592571150094, Call(
test->entry(), -4, 17));
2496 EXPECT_EQ(0, Call(
test->entry(), 4, -17));
2497 EXPECT_EQ(1, Call(
test->entry(), -4, -17));
2498 EXPECT_EQ(4, Call(
test->entry(), 17, 4));
2500 EXPECT_EQ(1073741819, Call(
test->entry(), -17, 4));
2502 EXPECT_EQ(4611686018427387899, Call(
test->entry(), -17, 4));
2504 EXPECT_EQ(0, Call(
test->entry(), 17, -4));
2505 EXPECT_EQ(0, Call(
test->entry(), -17, -4));
2509 FLAG_use_compressed_instructions =
false;
2516 "02b56533 rem a0, a0, a1\n"
2518 EXPECT_EQ(4, Call(
test->entry(), 4, 17));
2519 EXPECT_EQ(-4, Call(
test->entry(), -4, 17));
2520 EXPECT_EQ(4, Call(
test->entry(), 4, -17));
2521 EXPECT_EQ(-4, Call(
test->entry(), -4, -17));
2522 EXPECT_EQ(1, Call(
test->entry(), 17, 4));
2523 EXPECT_EQ(-1, Call(
test->entry(), -17, 4));
2524 EXPECT_EQ(1, Call(
test->entry(), 17, -4));
2525 EXPECT_EQ(-1, Call(
test->entry(), -17, -4));
2529 FLAG_use_compressed_instructions =
false;
2536 "02b57533 remu a0, a0, a1\n"
2538 EXPECT_EQ(4, Call(
test->entry(), 4, 17));
2539 EXPECT_EQ(14, Call(
test->entry(), -4, 17));
2540 EXPECT_EQ(4, Call(
test->entry(), 4, -17));
2541 EXPECT_EQ(13, Call(
test->entry(), -4, -17));
2542 EXPECT_EQ(1, Call(
test->entry(), 17, 4));
2543 EXPECT_EQ(3, Call(
test->entry(), -17, 4));
2544 EXPECT_EQ(17, Call(
test->entry(), 17, -4));
2545 EXPECT_EQ(-17, Call(
test->entry(), -17, -4));
2550 FLAG_use_compressed_instructions =
false;
2557 "02b5053b mulw a0, a0, a1\n"
2559 EXPECT_EQ(68, Call(
test->entry(), 4, 17));
2560 EXPECT_EQ(-68, Call(
test->entry(), -4, 17));
2561 EXPECT_EQ(-68, Call(
test->entry(), 4, -17));
2562 EXPECT_EQ(68, Call(
test->entry(), -4, -17));
2563 EXPECT_EQ(68, Call(
test->entry(), 17, 4));
2564 EXPECT_EQ(-68, Call(
test->entry(), -17, 4));
2565 EXPECT_EQ(-68, Call(
test->entry(), 17, -4));
2566 EXPECT_EQ(68, Call(
test->entry(), -17, -4));
2570 FLAG_use_compressed_instructions =
false;
2577 "02b5453b divw a0, a0, a1\n"
2579 EXPECT_EQ(0, Call(
test->entry(), 4, 17));
2580 EXPECT_EQ(0, Call(
test->entry(), -4, 17));
2581 EXPECT_EQ(0, Call(
test->entry(), 4, -17));
2582 EXPECT_EQ(0, Call(
test->entry(), -4, -17));
2583 EXPECT_EQ(4, Call(
test->entry(), 17, 4));
2584 EXPECT_EQ(-4, Call(
test->entry(), -17, 4));
2585 EXPECT_EQ(-4, Call(
test->entry(), 17, -4));
2586 EXPECT_EQ(4, Call(
test->entry(), -17, -4));
2590 FLAG_use_compressed_instructions =
false;
2597 "02b5553b divuw a0, a0, a1\n"
2599 EXPECT_EQ(0, Call(
test->entry(), 4, 17));
2600 EXPECT_EQ(252645134, Call(
test->entry(), -4, 17));
2601 EXPECT_EQ(0, Call(
test->entry(), 4, -17));
2602 EXPECT_EQ(1, Call(
test->entry(), -4, -17));
2603 EXPECT_EQ(4, Call(
test->entry(), 17, 4));
2604 EXPECT_EQ(1073741819, Call(
test->entry(), -17, 4));
2605 EXPECT_EQ(0, Call(
test->entry(), 17, -4));
2606 EXPECT_EQ(0, Call(
test->entry(), -17, -4));
2610 FLAG_use_compressed_instructions =
false;
2617 "02b5653b remw a0, a0, a1\n"
2619 EXPECT_EQ(4, Call(
test->entry(), 4, 17));
2620 EXPECT_EQ(-4, Call(
test->entry(), -4, 17));
2621 EXPECT_EQ(4, Call(
test->entry(), 4, -17));
2622 EXPECT_EQ(-4, Call(
test->entry(), -4, -17));
2623 EXPECT_EQ(1, Call(
test->entry(), 17, 4));
2624 EXPECT_EQ(-1, Call(
test->entry(), -17, 4));
2625 EXPECT_EQ(1, Call(
test->entry(), 17, -4));
2626 EXPECT_EQ(-1, Call(
test->entry(), -17, -4));
2630 FLAG_use_compressed_instructions =
false;
2637 "02b5753b remuw a0, a0, a1\n"
2639 EXPECT_EQ(4, Call(
test->entry(), 4, 17));
2640 EXPECT_EQ(14, Call(
test->entry(), -4, 17));
2641 EXPECT_EQ(4, Call(
test->entry(), 4, -17));
2642 EXPECT_EQ(13, Call(
test->entry(), -4, -17));
2643 EXPECT_EQ(1, Call(
test->entry(), 17, 4));
2644 EXPECT_EQ(3, Call(
test->entry(), -17, 4));
2645 EXPECT_EQ(17, Call(
test->entry(), 17, -4));
2646 EXPECT_EQ(-17, Call(
test->entry(), -17, -4));
2651 FLAG_use_compressed_instructions =
false;
2660 "100522af lr.w t0, (a0)\n"
2661 "00128293 addi t0, t0, 1\n"
2662 "1855252f sc.w a0, t0, (a0)\n"
2665 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2667 EXPECT_EQ(0, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value)));
2668 EXPECT_EQ(0b1101, *
value);
2672 FLAG_use_compressed_instructions =
false;
2680 "02a00293 li t0, 42\n"
2681 "1855252f sc.w a0, t0, (a0)\n"
2684 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2686 EXPECT_EQ(
false, 0 == Call(
test->entry(),
reinterpret_cast<intx_t
>(
value)));
2687 EXPECT_EQ(0b1100, *
value);
2691 FLAG_use_compressed_instructions =
false;
2698 "08b5252f amoswap.w a0, a1, (a0)\n"
2701 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2704 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2705 EXPECT_EQ(0b1010, *
value);
2709 FLAG_use_compressed_instructions =
false;
2716 "00b5252f amoadd.w a0, a1, (a0)\n"
2719 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2721 EXPECT_EQ(42, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 10));
2722 EXPECT_EQ(52, *
value);
2726 FLAG_use_compressed_instructions =
false;
2733 "20b5252f amoxor.w a0, a1, (a0)\n"
2736 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2739 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2740 EXPECT_EQ(0b0110, *
value);
2744 FLAG_use_compressed_instructions =
false;
2751 "60b5252f amoand.w a0, a1, (a0)\n"
2754 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2757 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2758 EXPECT_EQ(0b1000, *
value);
2762 FLAG_use_compressed_instructions =
false;
2769 "40b5252f amoor.w a0, a1, (a0)\n"
2772 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2775 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2776 EXPECT_EQ(0b1110, *
value);
2780 FLAG_use_compressed_instructions =
false;
2787 "80b5252f amomin.w a0, a1, (a0)\n"
2790 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2792 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
2793 EXPECT_EQ(-7, *
value);
2794 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
2795 EXPECT_EQ(-7, *
value);
2796 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
2797 EXPECT_EQ(-11, *
value);
2801 FLAG_use_compressed_instructions =
false;
2808 "a0b5252f amomax.w a0, a1, (a0)\n"
2811 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2813 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
2814 EXPECT_EQ(-7, *
value);
2815 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
2816 EXPECT_EQ(-7, *
value);
2817 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
2818 EXPECT_EQ(-4, *
value);
2822 FLAG_use_compressed_instructions =
false;
2829 "c0b5252f amominu.w a0, a1, (a0)\n"
2832 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2835 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
2836 EXPECT_EQ(-7, *
value);
2838 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
2839 EXPECT_EQ(-7, *
value);
2841 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
2842 EXPECT_EQ(-11, *
value);
2846 FLAG_use_compressed_instructions =
false;
2853 "e0b5252f amomaxu.w a0, a1, (a0)\n"
2856 int32_t*
value =
reinterpret_cast<int32_t*
>(
malloc(
sizeof(int32_t)));
2859 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
2860 EXPECT_EQ(-7, *
value);
2862 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
2863 EXPECT_EQ(-7, *
value);
2865 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
2866 EXPECT_EQ(-4, *
value);
2872 FLAG_use_compressed_instructions =
false;
2881 "100532af lr.d t0, (a0)\n"
2882 "00128293 addi t0, t0, 1\n"
2883 "1855352f sc.d a0, t0, (a0)\n"
2886 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
2888 EXPECT_EQ(0, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value)));
2889 EXPECT_EQ(0b1101, *
value);
2894 FLAG_use_compressed_instructions =
false;
2902 "02a00293 li t0, 42\n"
2903 "1855352f sc.d a0, t0, (a0)\n"
2906 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
2908 EXPECT_EQ(
false, 0 == Call(
test->entry(),
reinterpret_cast<intx_t
>(
value)));
2909 EXPECT_EQ(0b1100, *
value);
2913 FLAG_use_compressed_instructions =
false;
2920 "08b5352f amoswap.d a0, a1, (a0)\n"
2923 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
2926 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2927 EXPECT_EQ(0b1010, *
value);
2931 FLAG_use_compressed_instructions =
false;
2938 "00b5352f amoadd.d a0, a1, (a0)\n"
2941 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
2943 EXPECT_EQ(42, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 10));
2944 EXPECT_EQ(52, *
value);
2948 FLAG_use_compressed_instructions =
false;
2955 "20b5352f amoxor.d a0, a1, (a0)\n"
2958 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
2961 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2962 EXPECT_EQ(0b0110, *
value);
2966 FLAG_use_compressed_instructions =
false;
2973 "60b5352f amoand.d a0, a1, (a0)\n"
2976 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
2979 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2980 EXPECT_EQ(0b1000, *
value);
2984 FLAG_use_compressed_instructions =
false;
2991 "40b5352f amoor.d a0, a1, (a0)\n"
2994 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
2997 Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), 0b1010));
2998 EXPECT_EQ(0b1110, *
value);
3002 FLAG_use_compressed_instructions =
false;
3009 "80b5352f amomin.d a0, a1, (a0)\n"
3012 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
3014 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
3015 EXPECT_EQ(-7, *
value);
3016 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
3017 EXPECT_EQ(-7, *
value);
3018 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
3019 EXPECT_EQ(-11, *
value);
3023 FLAG_use_compressed_instructions =
false;
3030 "a0b5352f amomax.d a0, a1, (a0)\n"
3033 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
3035 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
3036 EXPECT_EQ(-7, *
value);
3037 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
3038 EXPECT_EQ(-7, *
value);
3039 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
3040 EXPECT_EQ(-4, *
value);
3044 FLAG_use_compressed_instructions =
false;
3051 "c0b5352f amominu.d a0, a1, (a0)\n"
3054 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
3056 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
3057 EXPECT_EQ(-7, *
value);
3058 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
3059 EXPECT_EQ(-7, *
value);
3060 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
3061 EXPECT_EQ(-11, *
value);
3065 FLAG_use_compressed_instructions =
false;
3072 "e0b5352f amomaxu.d a0, a1, (a0)\n"
3075 int64_t*
value =
reinterpret_cast<int64_t*
>(
malloc(
sizeof(int64_t)));
3077 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -11));
3078 EXPECT_EQ(-7, *
value);
3079 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -7));
3080 EXPECT_EQ(-7, *
value);
3081 EXPECT_EQ(-7, Call(
test->entry(),
reinterpret_cast<intx_t
>(
value), -4));
3082 EXPECT_EQ(-4, *
value);
3087 FLAG_use_compressed_instructions =
false;
3089 __ flw(
FA0, Address(
A0, 1 *
sizeof(
float)));
3094 "00452507 flw fa0, 4(a0)\n"
3097 float*
data =
reinterpret_cast<float*
>(
malloc(3 *
sizeof(
float)));
3101 EXPECT_EQ(
data[1], CallF(
test->entry(),
reinterpret_cast<intx_t
>(
data)));
3105 FLAG_use_compressed_instructions =
false;
3107 __ fsw(
FA0, Address(
A0, 1 *
sizeof(
float)));
3112 "00a52227 fsw fa0, 4(a0)\n"
3115 float*
data =
reinterpret_cast<float*
>(
malloc(3 *
sizeof(
float)));
3119 CallF(
test->entry(),
reinterpret_cast<intx_t
>(
data), 4.2f);
3120 EXPECT_EQ(4.2f,
data[1]);
3124 FLAG_use_compressed_instructions =
false;
3131 "60b50543 fmadd.s fa0, fa0, fa1, fa2\n"
3133 EXPECT_EQ(22.0, CallF(
test->entry(), 3.0, 5.0, 7.0));
3134 EXPECT_EQ(-8.0, CallF(
test->entry(), -3.0, 5.0, 7.0));
3135 EXPECT_EQ(-8.0, CallF(
test->entry(), 3.0, -5.0, 7.0));
3136 EXPECT_EQ(8.0, CallF(
test->entry(), 3.0, 5.0, -7.0));
3138 EXPECT_EQ(26.0, CallF(
test->entry(), 7.0, 3.0, 5.0));
3139 EXPECT_EQ(-16.0, CallF(
test->entry(), -7.0, 3.0, 5.0));
3140 EXPECT_EQ(-16.0, CallF(
test->entry(), 7.0, -3.0, 5.0));
3141 EXPECT_EQ(16.0, CallF(
test->entry(), 7.0, 3.0, -5.0));
3145 FLAG_use_compressed_instructions =
false;
3152 "60b50547 fmsub.s fa0, fa0, fa1, fa2\n"
3154 EXPECT_EQ(8.0, CallF(
test->entry(), 3.0, 5.0, 7.0));
3155 EXPECT_EQ(-22.0, CallF(
test->entry(), -3.0, 5.0, 7.0));
3156 EXPECT_EQ(-22.0, CallF(
test->entry(), 3.0, -5.0, 7.0));
3157 EXPECT_EQ(22.0, CallF(
test->entry(), 3.0, 5.0, -7.0));
3159 EXPECT_EQ(16.0, CallF(
test->entry(), 7.0, 3.0, 5.0));
3160 EXPECT_EQ(-26.0, CallF(
test->entry(), -7.0, 3.0, 5.0));
3161 EXPECT_EQ(-26.0, CallF(
test->entry(), 7.0, -3.0, 5.0));
3162 EXPECT_EQ(26.0, CallF(
test->entry(), 7.0, 3.0, -5.0));
3166 FLAG_use_compressed_instructions =
false;
3173 "60b5054b fnmsub.s fa0, fa0, fa1, fa2\n"
3175 EXPECT_EQ(-8.0, CallF(
test->entry(), 3.0, 5.0, 7.0));
3176 EXPECT_EQ(22.0, CallF(
test->entry(), -3.0, 5.0, 7.0));
3177 EXPECT_EQ(22.0, CallF(
test->entry(), 3.0, -5.0, 7.0));
3178 EXPECT_EQ(-22.0, CallF(
test->entry(), 3.0, 5.0, -7.0));
3180 EXPECT_EQ(-16.0, CallF(
test->entry(), 7.0, 3.0, 5.0));
3181 EXPECT_EQ(26.0, CallF(
test->entry(), -7.0, 3.0, 5.0));
3182 EXPECT_EQ(26.0, CallF(
test->entry(), 7.0, -3.0, 5.0));
3183 EXPECT_EQ(-26.0, CallF(
test->entry(), 7.0, 3.0, -5.0));
3187 FLAG_use_compressed_instructions =
false;
3194 "60b5054f fnmadd.s fa0, fa0, fa1, fa2\n"
3196 EXPECT_EQ(-22.0, CallF(
test->entry(), 3.0, 5.0, 7.0));
3197 EXPECT_EQ(8.0, CallF(
test->entry(), -3.0, 5.0, 7.0));
3198 EXPECT_EQ(8.0, CallF(
test->entry(), 3.0, -5.0, 7.0));
3199 EXPECT_EQ(-8.0, CallF(
test->entry(), 3.0, 5.0, -7.0));
3201 EXPECT_EQ(-26.0, CallF(
test->entry(), 7.0, 3.0, 5.0));
3202 EXPECT_EQ(16.0, CallF(
test->entry(), -7.0, 3.0, 5.0));
3203 EXPECT_EQ(16.0, CallF(
test->entry(), 7.0, -3.0, 5.0));
3204 EXPECT_EQ(-16.0, CallF(
test->entry(), 7.0, 3.0, -5.0));
3208 FLAG_use_compressed_instructions =
false;
3215 "00b50553 fadd.s fa0, fa0, fa1\n"
3217 EXPECT_EQ(8.0f, CallF(
test->entry(), 3.0f, 5.0f));
3218 EXPECT_EQ(2.0f, CallF(
test->entry(), -3.0f, 5.0f));
3219 EXPECT_EQ(-2.0f, CallF(
test->entry(), 3.0f, -5.0f));
3220 EXPECT_EQ(-8.0f, CallF(
test->entry(), -3.0f, -5.0f));
3222 EXPECT_EQ(10.0f, CallF(
test->entry(), 7.0f, 3.0f));
3223 EXPECT_EQ(-4.0f, CallF(
test->entry(), -7.0f, 3.0f));
3224 EXPECT_EQ(4.0f, CallF(
test->entry(), 7.0f, -3.0f));
3225 EXPECT_EQ(-10.0f, CallF(
test->entry(), -7.0f, -3.0f));
3229 FLAG_use_compressed_instructions =
false;
3236 "08b50553 fsub.s fa0, fa0, fa1\n"
3238 EXPECT_EQ(-2.0f, CallF(
test->entry(), 3.0f, 5.0f));
3239 EXPECT_EQ(-8.0f, CallF(
test->entry(), -3.0f, 5.0f));
3240 EXPECT_EQ(8.0f, CallF(
test->entry(), 3.0f, -5.0f));
3241 EXPECT_EQ(2.0f, CallF(
test->entry(), -3.0f, -5.0f));
3243 EXPECT_EQ(4.0f, CallF(
test->entry(), 7.0f, 3.0f));
3244 EXPECT_EQ(-10.0f, CallF(
test->entry(), -7.0f, 3.0f));
3245 EXPECT_EQ(10.0f, CallF(
test->entry(), 7.0f, -3.0f));
3246 EXPECT_EQ(-4.0f, CallF(
test->entry(), -7.0f, -3.0f));
3250 FLAG_use_compressed_instructions =
false;
3257 "10b50553 fmul.s fa0, fa0, fa1\n"
3259 EXPECT_EQ(15.0f, CallF(
test->entry(), 3.0f, 5.0f));
3260 EXPECT_EQ(-15.0f, CallF(
test->entry(), -3.0f, 5.0f));
3261 EXPECT_EQ(-15.0f, CallF(
test->entry(), 3.0f, -5.0f));
3262 EXPECT_EQ(15.0f, CallF(
test->entry(), -3.0f, -5.0f));
3264 EXPECT_EQ(21.0f, CallF(
test->entry(), 7.0f, 3.0f));
3265 EXPECT_EQ(-21.0f, CallF(
test->entry(), -7.0f, 3.0f));
3266 EXPECT_EQ(-21.0f, CallF(
test->entry(), 7.0f, -3.0f));
3267 EXPECT_EQ(21.0f, CallF(
test->entry(), -7.0f, -3.0f));
3271 FLAG_use_compressed_instructions =
false;
3278 "18b50553 fdiv.s fa0, fa0, fa1\n"
3280 EXPECT_EQ(2.0f, CallF(
test->entry(), 10.0f, 5.0f));
3281 EXPECT_EQ(-2.0f, CallF(
test->entry(), -10.0f, 5.0f));
3282 EXPECT_EQ(-2.0f, CallF(
test->entry(), 10.0f, -5.0f));
3283 EXPECT_EQ(2.0f, CallF(
test->entry(), -10.0f, -5.0f));
3287 FLAG_use_compressed_instructions =
false;
3294 "58050553 fsqrt.s fa0, fa0\n"
3296 EXPECT_EQ(0.0f, CallF(
test->entry(), 0.0f));
3297 EXPECT_EQ(1.0f, CallF(
test->entry(), 1.0f));
3298 EXPECT_EQ(2.0f, CallF(
test->entry(), 4.0f));
3299 EXPECT_EQ(3.0f, CallF(
test->entry(), 9.0f));
3303 FLAG_use_compressed_instructions =
false;
3310 "20b50553 fsgnj.s fa0, fa0, fa1\n"
3312 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, 5.0f));
3313 EXPECT_EQ(3.0f, CallF(
test->entry(), -3.0f, 5.0f));
3314 EXPECT_EQ(-3.0f, CallF(
test->entry(), 3.0f, -5.0f));
3315 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, -5.0f));
3319 FLAG_use_compressed_instructions =
false;
3326 "20b51553 fsgnjn.s fa0, fa0, fa1\n"
3328 EXPECT_EQ(-3.0f, CallF(
test->entry(), 3.0f, 5.0f));
3329 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, 5.0f));
3330 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, -5.0f));
3331 EXPECT_EQ(3.0f, CallF(
test->entry(), -3.0f, -5.0f));
3335 FLAG_use_compressed_instructions =
false;
3342 "20b52553 fsgnjx.s fa0, fa0, fa1\n"
3344 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, 5.0f));
3345 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, 5.0f));
3346 EXPECT_EQ(-3.0f, CallF(
test->entry(), 3.0f, -5.0f));
3347 EXPECT_EQ(3.0f, CallF(
test->entry(), -3.0f, -5.0f));
3351 FLAG_use_compressed_instructions =
false;
3358 "28b50553 fmin.s fa0, fa0, fa1\n"
3360 EXPECT_EQ(1.0f, CallF(
test->entry(), 3.0f, 1.0f));
3361 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, 3.0f));
3362 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, 5.0f));
3363 EXPECT_EQ(-1.0f, CallF(
test->entry(), 3.0f, -1.0f));
3364 EXPECT_EQ(-3.0f, CallF(
test->entry(), 3.0f, -3.0f));
3365 EXPECT_EQ(-5.0f, CallF(
test->entry(), 3.0f, -5.0f));
3366 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, 1.0f));
3367 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, 3.0f));
3368 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, 5.0f));
3369 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, -1.0f));
3370 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, -3.0f));
3371 EXPECT_EQ(-5.0f, CallF(
test->entry(), -3.0f, -5.0f));
3373 EXPECT_EQ(bit_cast<uint32_t>(-0.0f),
3374 bit_cast<uint32_t>(CallF(
test->entry(), 0.0f, -0.0f)));
3375 EXPECT_EQ(bit_cast<uint32_t>(-0.0f),
3376 bit_cast<uint32_t>(CallF(
test->entry(), -0.0f, 0.0f)));
3378 float qNAN = std::numeric_limits<float>::quiet_NaN();
3379 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, qNAN));
3380 EXPECT_EQ(3.0f, CallF(
test->entry(), qNAN, 3.0f));
3381 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, qNAN));
3382 EXPECT_EQ(-3.0f, CallF(
test->entry(), qNAN, -3.0f));
3384 float sNAN = std::numeric_limits<float>::signaling_NaN();
3385 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, sNAN));
3386 EXPECT_EQ(3.0f, CallF(
test->entry(), sNAN, 3.0f));
3387 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, sNAN));
3388 EXPECT_EQ(-3.0f, CallF(
test->entry(), sNAN, -3.0f));
3390 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3391 bit_cast<uint32_t>(CallF(
test->entry(), qNAN, qNAN)));
3392 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3393 bit_cast<uint32_t>(CallF(
test->entry(), sNAN, sNAN)));
3394 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3395 bit_cast<uint32_t>(CallF(
test->entry(), qNAN, sNAN)));
3396 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3397 bit_cast<uint32_t>(CallF(
test->entry(), sNAN, qNAN)));
3401 FLAG_use_compressed_instructions =
false;
3408 "28b51553 fmax.s fa0, fa0, fa1\n"
3410 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, 1.0f));
3411 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, 3.0f));
3412 EXPECT_EQ(5.0f, CallF(
test->entry(), 3.0f, 5.0f));
3413 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, -1.0f));
3414 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, -3.0f));
3415 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, -5.0f));
3416 EXPECT_EQ(1.0f, CallF(
test->entry(), -3.0f, 1.0f));
3417 EXPECT_EQ(3.0f, CallF(
test->entry(), -3.0f, 3.0f));
3418 EXPECT_EQ(5.0f, CallF(
test->entry(), -3.0f, 5.0f));
3419 EXPECT_EQ(-1.0f, CallF(
test->entry(), -3.0f, -1.0f));
3420 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, -3.0f));
3421 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, -5.0f));
3423 EXPECT_EQ(bit_cast<uint32_t>(0.0f),
3424 bit_cast<uint32_t>(CallF(
test->entry(), 0.0f, -0.0f)));
3425 EXPECT_EQ(bit_cast<uint32_t>(0.0f),
3426 bit_cast<uint32_t>(CallF(
test->entry(), -0.0f, 0.0f)));
3428 float qNAN = std::numeric_limits<float>::quiet_NaN();
3429 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, qNAN));
3430 EXPECT_EQ(3.0f, CallF(
test->entry(), qNAN, 3.0f));
3431 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, qNAN));
3432 EXPECT_EQ(-3.0f, CallF(
test->entry(), qNAN, -3.0f));
3434 float sNAN = std::numeric_limits<float>::signaling_NaN();
3435 EXPECT_EQ(3.0f, CallF(
test->entry(), 3.0f, sNAN));
3436 EXPECT_EQ(3.0f, CallF(
test->entry(), sNAN, 3.0f));
3437 EXPECT_EQ(-3.0f, CallF(
test->entry(), -3.0f, sNAN));
3438 EXPECT_EQ(-3.0f, CallF(
test->entry(), sNAN, -3.0f));
3440 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3441 bit_cast<uint32_t>(CallF(
test->entry(), qNAN, qNAN)));
3442 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3443 bit_cast<uint32_t>(CallF(
test->entry(), sNAN, sNAN)));
3444 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3445 bit_cast<uint32_t>(CallF(
test->entry(), qNAN, sNAN)));
3446 EXPECT_EQ(bit_cast<uint32_t>(qNAN),
3447 bit_cast<uint32_t>(CallF(
test->entry(), sNAN, qNAN)));
3451 FLAG_use_compressed_instructions =
false;
3458 "a0b52553 feq.s a0, fa0, fa1\n"
3460 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, 1.0f));
3461 EXPECT_EQ(1, CallI(
test->entry(), 3.0f, 3.0f));
3462 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, 5.0f));
3463 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -1.0f));
3464 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -3.0f));
3465 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -5.0f));
3466 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, 1.0f));
3467 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, 3.0f));
3468 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, 5.0f));
3469 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, -1.0f));
3470 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, -3.0f));
3471 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, -5.0f));
3473 float qNAN = std::numeric_limits<float>::quiet_NaN();
3474 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, qNAN));
3475 EXPECT_EQ(0, CallI(
test->entry(), qNAN, 3.0f));
3476 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, qNAN));
3477 EXPECT_EQ(0, CallI(
test->entry(), qNAN, -3.0f));
3481 FLAG_use_compressed_instructions =
false;
3488 "a0b51553 flt.s a0, fa0, fa1\n"
3490 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, 1.0f));
3491 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, 3.0f));
3492 EXPECT_EQ(1, CallI(
test->entry(), 3.0f, 5.0f));
3493 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -1.0f));
3494 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -3.0f));
3495 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -5.0f));
3496 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, 1.0f));
3497 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, 3.0f));
3498 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, 5.0f));
3499 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, -1.0f));
3500 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, -3.0f));
3501 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, -5.0f));
3503 float qNAN = std::numeric_limits<float>::quiet_NaN();
3504 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, qNAN));
3505 EXPECT_EQ(0, CallI(
test->entry(), qNAN, 3.0f));
3506 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, qNAN));
3507 EXPECT_EQ(0, CallI(
test->entry(), qNAN, -3.0f));
3511 FLAG_use_compressed_instructions =
false;
3518 "a0b50553 fle.s a0, fa0, fa1\n"
3520 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, 1.0f));
3521 EXPECT_EQ(1, CallI(
test->entry(), 3.0f, 3.0f));
3522 EXPECT_EQ(1, CallI(
test->entry(), 3.0f, 5.0f));
3523 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -1.0f));
3524 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -3.0f));
3525 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, -5.0f));
3526 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, 1.0f));
3527 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, 3.0f));
3528 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, 5.0f));
3529 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, -1.0f));
3530 EXPECT_EQ(1, CallI(
test->entry(), -3.0f, -3.0f));
3531 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, -5.0f));
3533 float qNAN = std::numeric_limits<float>::quiet_NaN();
3534 EXPECT_EQ(0, CallI(
test->entry(), 3.0f, qNAN));
3535 EXPECT_EQ(0, CallI(
test->entry(), qNAN, 3.0f));
3536 EXPECT_EQ(0, CallI(
test->entry(), -3.0f, qNAN));
3537 EXPECT_EQ(0, CallI(
test->entry(), qNAN, -3.0f));
3541 FLAG_use_compressed_instructions =
false;
3548 "e0051553 fclass.s a0, fa0\n"
3552 CallI(
test->entry(), -std::numeric_limits<float>::infinity()));
3554 EXPECT_EQ(1 << 1, CallI(
test->entry(), -1.0f));
3559 EXPECT_EQ(1 << 3, CallI(
test->entry(), -0.0f));
3561 EXPECT_EQ(1 << 4, CallI(
test->entry(), 0.0f));
3566 EXPECT_EQ(1 << 6, CallI(
test->entry(), 1.0f));
3569 CallI(
test->entry(), std::numeric_limits<float>::infinity()));
3572 CallI(
test->entry(), std::numeric_limits<float>::signaling_NaN()));
3575 CallI(
test->entry(), std::numeric_limits<float>::quiet_NaN()));
3579 FLAG_use_compressed_instructions =
false;
3586 "c0050553 fcvt.w.s a0, fa0\n"
3588 EXPECT_EQ(-42, CallI(
test->entry(),
static_cast<float>(-42)));
3589 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<float>(0)));
3590 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<float>(42)));
3604 CallI(
test->entry(), -std::numeric_limits<float>::infinity()));
3606 CallI(
test->entry(), std::numeric_limits<float>::infinity()));
3608 CallI(
test->entry(), std::numeric_limits<float>::signaling_NaN()));
3612 FLAG_use_compressed_instructions =
false;
3619 "c0050553 fcvt.w.s a0, fa0\n"
3621 EXPECT_EQ(-44, CallI(
test->entry(), -43.6f));
3622 EXPECT_EQ(-44, CallI(
test->entry(), -43.5f));
3623 EXPECT_EQ(-43, CallI(
test->entry(), -43.4f));
3624 EXPECT_EQ(-43, CallI(
test->entry(), -43.0f));
3625 EXPECT_EQ(-43, CallI(
test->entry(), -42.6f));
3626 EXPECT_EQ(-42, CallI(
test->entry(), -42.5f));
3627 EXPECT_EQ(-42, CallI(
test->entry(), -42.4f));
3628 EXPECT_EQ(-42, CallI(
test->entry(), -42.0f));
3629 EXPECT_EQ(0, CallI(
test->entry(), -0.0f));
3630 EXPECT_EQ(0, CallI(
test->entry(), +0.0f));
3631 EXPECT_EQ(42, CallI(
test->entry(), 42.0f));
3632 EXPECT_EQ(42, CallI(
test->entry(), 42.4f));
3633 EXPECT_EQ(42, CallI(
test->entry(), 42.5f));
3634 EXPECT_EQ(43, CallI(
test->entry(), 42.6f));
3635 EXPECT_EQ(43, CallI(
test->entry(), 43.0f));
3636 EXPECT_EQ(43, CallI(
test->entry(), 43.4f));
3637 EXPECT_EQ(44, CallI(
test->entry(), 43.5f));
3638 EXPECT_EQ(44, CallI(
test->entry(), 43.6f));
3642 FLAG_use_compressed_instructions =
false;
3649 "c0051553 fcvt.w.s a0, fa0, rtz\n"
3651 EXPECT_EQ(-43, CallI(
test->entry(), -43.6f));
3652 EXPECT_EQ(-43, CallI(
test->entry(), -43.5f));
3653 EXPECT_EQ(-43, CallI(
test->entry(), -43.4f));
3654 EXPECT_EQ(-43, CallI(
test->entry(), -43.0f));
3655 EXPECT_EQ(-42, CallI(
test->entry(), -42.6f));
3656 EXPECT_EQ(-42, CallI(
test->entry(), -42.5f));
3657 EXPECT_EQ(-42, CallI(
test->entry(), -42.4f));
3658 EXPECT_EQ(-42, CallI(
test->entry(), -42.0f));
3659 EXPECT_EQ(0, CallI(
test->entry(), -0.0f));
3660 EXPECT_EQ(0, CallI(
test->entry(), +0.0f));
3661 EXPECT_EQ(42, CallI(
test->entry(), 42.0f));
3662 EXPECT_EQ(42, CallI(
test->entry(), 42.4f));
3663 EXPECT_EQ(42, CallI(
test->entry(), 42.5f));
3664 EXPECT_EQ(42, CallI(
test->entry(), 42.6f));
3665 EXPECT_EQ(43, CallI(
test->entry(), 43.0f));
3666 EXPECT_EQ(43, CallI(
test->entry(), 43.4f));
3667 EXPECT_EQ(43, CallI(
test->entry(), 43.5f));
3668 EXPECT_EQ(43, CallI(
test->entry(), 43.6f));
3672 FLAG_use_compressed_instructions =
false;
3679 "c0052553 fcvt.w.s a0, fa0, rdn\n"
3681 EXPECT_EQ(-44, CallI(
test->entry(), -43.6f));
3682 EXPECT_EQ(-44, CallI(
test->entry(), -43.5f));
3683 EXPECT_EQ(-44, CallI(
test->entry(), -43.4f));
3684 EXPECT_EQ(-43, CallI(
test->entry(), -43.0f));
3685 EXPECT_EQ(-43, CallI(
test->entry(), -42.6f));
3686 EXPECT_EQ(-43, CallI(
test->entry(), -42.5f));
3687 EXPECT_EQ(-43, CallI(
test->entry(), -42.4f));
3688 EXPECT_EQ(-42, CallI(
test->entry(), -42.0f));
3689 EXPECT_EQ(0, CallI(
test->entry(), -0.0f));
3690 EXPECT_EQ(0, CallI(
test->entry(), +0.0f));
3691 EXPECT_EQ(42, CallI(
test->entry(), 42.0f));
3692 EXPECT_EQ(42, CallI(
test->entry(), 42.4f));
3693 EXPECT_EQ(42, CallI(
test->entry(), 42.5f));
3694 EXPECT_EQ(42, CallI(
test->entry(), 42.6f));
3695 EXPECT_EQ(43, CallI(
test->entry(), 43.0f));
3696 EXPECT_EQ(43, CallI(
test->entry(), 43.4f));
3697 EXPECT_EQ(43, CallI(
test->entry(), 43.5f));
3698 EXPECT_EQ(43, CallI(
test->entry(), 43.6f));
3702 FLAG_use_compressed_instructions =
false;
3709 "c0053553 fcvt.w.s a0, fa0, rup\n"
3711 EXPECT_EQ(-43, CallI(
test->entry(), -43.6f));
3712 EXPECT_EQ(-43, CallI(
test->entry(), -43.5f));
3713 EXPECT_EQ(-43, CallI(
test->entry(), -43.4f));
3714 EXPECT_EQ(-43, CallI(
test->entry(), -43.0f));
3715 EXPECT_EQ(-42, CallI(
test->entry(), -42.6f));
3716 EXPECT_EQ(-42, CallI(
test->entry(), -42.5f));
3717 EXPECT_EQ(-42, CallI(
test->entry(), -42.4f));
3718 EXPECT_EQ(-42, CallI(
test->entry(), -42.0f));
3719 EXPECT_EQ(0, CallI(
test->entry(), -0.0f));
3720 EXPECT_EQ(0, CallI(
test->entry(), +0.0f));
3721 EXPECT_EQ(42, CallI(
test->entry(), 42.0f));
3722 EXPECT_EQ(43, CallI(
test->entry(), 42.4f));
3723 EXPECT_EQ(43, CallI(
test->entry(), 42.5f));
3724 EXPECT_EQ(43, CallI(
test->entry(), 42.6f));
3725 EXPECT_EQ(43, CallI(
test->entry(), 43.0f));
3726 EXPECT_EQ(44, CallI(
test->entry(), 43.5f));
3727 EXPECT_EQ(44, CallI(
test->entry(), 43.5f));
3728 EXPECT_EQ(44, CallI(
test->entry(), 43.6f));
3732 FLAG_use_compressed_instructions =
false;
3739 "c0054553 fcvt.w.s a0, fa0, rmm\n"
3741 EXPECT_EQ(-44, CallI(
test->entry(), -43.6f));
3742 EXPECT_EQ(-44, CallI(
test->entry(), -43.5f));
3743 EXPECT_EQ(-43, CallI(
test->entry(), -43.4f));
3744 EXPECT_EQ(-43, CallI(
test->entry(), -43.0f));
3745 EXPECT_EQ(-43, CallI(
test->entry(), -42.6f));
3746 EXPECT_EQ(-43, CallI(
test->entry(), -42.5f));
3747 EXPECT_EQ(-42, CallI(
test->entry(), -42.4f));
3748 EXPECT_EQ(-42, CallI(
test->entry(), -42.0f));
3749 EXPECT_EQ(0, CallI(
test->entry(), -0.0f));
3750 EXPECT_EQ(0, CallI(
test->entry(), +0.0f));
3751 EXPECT_EQ(42, CallI(
test->entry(), 42.0f));
3752 EXPECT_EQ(42, CallI(
test->entry(), 42.4f));
3753 EXPECT_EQ(43, CallI(
test->entry(), 42.5f));
3754 EXPECT_EQ(43, CallI(
test->entry(), 42.6f));
3755 EXPECT_EQ(43, CallI(
test->entry(), 43.0f));
3756 EXPECT_EQ(43, CallI(
test->entry(), 43.4f));
3757 EXPECT_EQ(44, CallI(
test->entry(), 43.5f));
3758 EXPECT_EQ(44, CallI(
test->entry(), 43.6f));
3762 FLAG_use_compressed_instructions =
false;
3769 "c0150553 fcvt.wu.s a0, fa0\n"
3771 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<float>(-42)));
3772 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<float>(0)));
3773 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<float>(42)));
3777 EXPECT_EQ(-2147483648, CallI(
test->entry(),
static_cast<float>(
kMaxInt32)));
3787 CallI(
test->entry(), -std::numeric_limits<float>::infinity()));
3789 CallI(
test->entry(), std::numeric_limits<float>::infinity()));
3791 CallI(
test->entry(), std::numeric_limits<float>::signaling_NaN()));
3795 FLAG_use_compressed_instructions =
false;
3802 "d0050553 fcvt.s.w fa0, a0\n"
3807 EXPECT_EQ(
static_cast<float>(
kMinInt32),
3809 EXPECT_EQ(
static_cast<float>(
kMaxInt32),
3815 FLAG_use_compressed_instructions =
false;
3822 "d0150553 fcvt.s.wu fa0, a0\n"
3825 static_cast<float>(
static_cast<uint32_t
>(
static_cast<int32_t
>(-42))),
3829 EXPECT_EQ(
static_cast<float>(
static_cast<uint32_t
>(
kMinInt32)),
3831 EXPECT_EQ(
static_cast<float>(
kMaxInt32),
3838 FLAG_use_compressed_instructions =
false;
3845 "20b58553 fmv.s fa0, fa1\n"
3847 EXPECT_EQ(36.0f, CallF(
test->entry(), 42.0f, 36.0f));
3848 EXPECT_EQ(std::numeric_limits<float>::infinity(),
3849 CallF(
test->entry(), -std::numeric_limits<float>::infinity(),
3850 std::numeric_limits<float>::infinity()));
3854 FLAG_use_compressed_instructions =
false;
3861 "20a52553 fabs.s fa0, fa0\n"
3863 EXPECT_EQ(0.0f, CallF(
test->entry(), 0.0f));
3864 EXPECT_EQ(0.0f, CallF(
test->entry(), -0.0f));
3865 EXPECT_EQ(42.0f, CallF(
test->entry(), 42.0f));
3866 EXPECT_EQ(42.0f, CallF(
test->entry(), -42.0f));
3867 EXPECT_EQ(std::numeric_limits<float>::infinity(),
3868 CallF(
test->entry(), std::numeric_limits<float>::infinity()));
3869 EXPECT_EQ(std::numeric_limits<float>::infinity(),
3870 CallF(
test->entry(), -std::numeric_limits<float>::infinity()));
3874 FLAG_use_compressed_instructions =
false;
3881 "20a51553 fneg.s fa0, fa0\n"
3883 EXPECT_EQ(-0.0f, CallF(
test->entry(), 0.0f));
3884 EXPECT_EQ(0.0f, CallF(
test->entry(), -0.0f));
3885 EXPECT_EQ(-42.0f, CallF(
test->entry(), 42.0f));
3886 EXPECT_EQ(42.0f, CallF(
test->entry(), -42.0f));
3887 EXPECT_EQ(-std::numeric_limits<float>::infinity(),
3888 CallF(
test->entry(), std::numeric_limits<float>::infinity()));
3889 EXPECT_EQ(std::numeric_limits<float>::infinity(),
3890 CallF(
test->entry(), -std::numeric_limits<float>::infinity()));
3894 FLAG_use_compressed_instructions =
false;
3901 "e0050553 fmv.x.w a0, fa0\n"
3903 EXPECT_EQ(bit_cast<int32_t>(0.0f), CallI(
test->entry(), 0.0f));
3904 EXPECT_EQ(bit_cast<int32_t>(-0.0f), CallI(
test->entry(), -0.0f));
3905 EXPECT_EQ(bit_cast<int32_t>(42.0f), CallI(
test->entry(), 42.0f));
3906 EXPECT_EQ(bit_cast<int32_t>(-42.0f), CallI(
test->entry(), -42.0f));
3907 EXPECT_EQ(bit_cast<int32_t>(std::numeric_limits<float>::quiet_NaN()),
3908 CallI(
test->entry(), std::numeric_limits<float>::quiet_NaN()));
3909 EXPECT_EQ(bit_cast<int32_t>(std::numeric_limits<float>::signaling_NaN()),
3910 CallI(
test->entry(), std::numeric_limits<float>::signaling_NaN()));
3911 EXPECT_EQ(bit_cast<int32_t>(std::numeric_limits<float>::infinity()),
3912 CallI(
test->entry(), std::numeric_limits<float>::infinity()));
3913 EXPECT_EQ(bit_cast<int32_t>(-std::numeric_limits<float>::infinity()),
3914 CallI(
test->entry(), -std::numeric_limits<float>::infinity()));
3918 FLAG_use_compressed_instructions =
false;
3925 "f0050553 fmv.w.x fa0, a0\n"
3927 EXPECT_EQ(0.0f, CallF(
test->entry(),
sign_extend(bit_cast<int32_t>(0.0f))));
3928 EXPECT_EQ(-0.0f, CallF(
test->entry(),
sign_extend(bit_cast<int32_t>(-0.0f))));
3929 EXPECT_EQ(42.0f, CallF(
test->entry(),
sign_extend(bit_cast<int32_t>(42.0f))));
3932 EXPECT_EQ(
true, isnan(CallF(
test->entry(),
3934 std::numeric_limits<float>::quiet_NaN())))));
3936 isnan(CallF(
test->entry(),
3938 std::numeric_limits<float>::signaling_NaN())))));
3939 EXPECT_EQ(std::numeric_limits<float>::infinity(),
3941 std::numeric_limits<float>::infinity()))));
3943 -std::numeric_limits<float>::infinity(),
3945 -std::numeric_limits<float>::infinity()))));
3950 FLAG_use_compressed_instructions =
false;
3957 "c0250553 fcvt.l.s a0, fa0\n"
3959 EXPECT_EQ(-42, CallI(
test->entry(),
static_cast<float>(-42)));
3960 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<float>(0)));
3961 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<float>(42)));
3962 EXPECT_EQ(
static_cast<int64_t
>(
kMinInt32),
3965 EXPECT_EQ(
static_cast<int64_t
>(
kMaxInt32) + 1,
3967 EXPECT_EQ(
static_cast<int64_t
>(
kMaxUint32) + 1,
3973 CallI(
test->entry(), -std::numeric_limits<float>::infinity()));
3975 CallI(
test->entry(), std::numeric_limits<float>::infinity()));
3977 CallI(
test->entry(), std::numeric_limits<float>::signaling_NaN()));
3981 FLAG_use_compressed_instructions =
false;
3988 "c0350553 fcvt.lu.s a0, fa0\n"
3990 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<float>(-42)));
3991 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<float>(0)));
3992 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<float>(42)));
3993 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(0)),
3995 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxInt32) + 1),
3997 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint32) + 1),
3999 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(0)),
4001 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxInt64) + 1),
4003 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint64)),
4005 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(0)),
4006 CallI(
test->entry(), -std::numeric_limits<float>::infinity()));
4007 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint64)),
4008 CallI(
test->entry(), std::numeric_limits<float>::infinity()));
4009 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint64)),
4010 CallI(
test->entry(), std::numeric_limits<float>::signaling_NaN()));
4014 FLAG_use_compressed_instructions =
false;
4021 "d0250553 fcvt.s.l fa0, a0\n"
4026 EXPECT_EQ(
static_cast<float>(
kMinInt32),
4028 EXPECT_EQ(
static_cast<float>(
kMaxInt32),
4032 EXPECT_EQ(
static_cast<float>(
kMinInt64),
4034 EXPECT_EQ(
static_cast<float>(
kMaxInt64),
4041 FLAG_use_compressed_instructions =
false;
4048 "d0350553 fcvt.s.lu fa0, a0\n"
4052 EXPECT_EQ(
static_cast<float>(
static_cast<uint64_t
>(
sign_extend(-42))),
4070 FLAG_use_compressed_instructions =
false;
4072 __ fld(
FA0, Address(
A0, 1 *
sizeof(
double)));
4077 "00853507 fld fa0, 8(a0)\n"
4080 double*
data =
reinterpret_cast<double*
>(
malloc(3 *
sizeof(
double)));
4084 EXPECT_EQ(
data[1], CallD(
test->entry(),
reinterpret_cast<intx_t
>(
data)));
4088 FLAG_use_compressed_instructions =
false;
4090 __ fsd(
FA0, Address(
A0, 1 *
sizeof(
double)));
4095 "00a53427 fsd fa0, 8(a0)\n"
4098 double*
data =
reinterpret_cast<double*
>(
malloc(3 *
sizeof(
double)));
4102 CallD(
test->entry(),
reinterpret_cast<intx_t
>(
data), 4.2);
4103 EXPECT_EQ(4.2,
data[1]);
4107 FLAG_use_compressed_instructions =
false;
4114 "62b50543 fmadd.d fa0, fa0, fa1, fa2\n"
4116 EXPECT_EQ(22.0, CallD(
test->entry(), 3.0, 5.0, 7.0));
4117 EXPECT_EQ(-8.0, CallD(
test->entry(), -3.0, 5.0, 7.0));
4118 EXPECT_EQ(-8.0, CallD(
test->entry(), 3.0, -5.0, 7.0));
4119 EXPECT_EQ(8.0, CallD(
test->entry(), 3.0, 5.0, -7.0));
4121 EXPECT_EQ(26.0, CallD(
test->entry(), 7.0, 3.0, 5.0));
4122 EXPECT_EQ(-16.0, CallD(
test->entry(), -7.0, 3.0, 5.0));
4123 EXPECT_EQ(-16.0, CallD(
test->entry(), 7.0, -3.0, 5.0));
4124 EXPECT_EQ(16.0, CallD(
test->entry(), 7.0, 3.0, -5.0));
4128 FLAG_use_compressed_instructions =
false;
4135 "62b50547 fmsub.d fa0, fa0, fa1, fa2\n"
4137 EXPECT_EQ(8.0, CallD(
test->entry(), 3.0, 5.0, 7.0));
4138 EXPECT_EQ(-22.0, CallD(
test->entry(), -3.0, 5.0, 7.0));
4139 EXPECT_EQ(-22.0, CallD(
test->entry(), 3.0, -5.0, 7.0));
4140 EXPECT_EQ(22.0, CallD(
test->entry(), 3.0, 5.0, -7.0));
4142 EXPECT_EQ(16.0, CallD(
test->entry(), 7.0, 3.0, 5.0));
4143 EXPECT_EQ(-26.0, CallD(
test->entry(), -7.0, 3.0, 5.0));
4144 EXPECT_EQ(-26.0, CallD(
test->entry(), 7.0, -3.0, 5.0));
4145 EXPECT_EQ(26.0, CallD(
test->entry(), 7.0, 3.0, -5.0));
4149 FLAG_use_compressed_instructions =
false;
4156 "62b5054b fnmsub.d fa0, fa0, fa1, fa2\n"
4158 EXPECT_EQ(-8.0, CallD(
test->entry(), 3.0, 5.0, 7.0));
4159 EXPECT_EQ(22.0, CallD(
test->entry(), -3.0, 5.0, 7.0));
4160 EXPECT_EQ(22.0, CallD(
test->entry(), 3.0, -5.0, 7.0));
4161 EXPECT_EQ(-22.0, CallD(
test->entry(), 3.0, 5.0, -7.0));
4163 EXPECT_EQ(-16.0, CallD(
test->entry(), 7.0, 3.0, 5.0));
4164 EXPECT_EQ(26.0, CallD(
test->entry(), -7.0, 3.0, 5.0));
4165 EXPECT_EQ(26.0, CallD(
test->entry(), 7.0, -3.0, 5.0));
4166 EXPECT_EQ(-26.0, CallD(
test->entry(), 7.0, 3.0, -5.0));
4170 FLAG_use_compressed_instructions =
false;
4177 "62b5054f fnmadd.d fa0, fa0, fa1, fa2\n"
4179 EXPECT_EQ(-22.0, CallD(
test->entry(), 3.0, 5.0, 7.0));
4180 EXPECT_EQ(8.0, CallD(
test->entry(), -3.0, 5.0, 7.0));
4181 EXPECT_EQ(8.0, CallD(
test->entry(), 3.0, -5.0, 7.0));
4182 EXPECT_EQ(-8.0, CallD(
test->entry(), 3.0, 5.0, -7.0));
4184 EXPECT_EQ(-26.0, CallD(
test->entry(), 7.0, 3.0, 5.0));
4185 EXPECT_EQ(16.0, CallD(
test->entry(), -7.0, 3.0, 5.0));
4186 EXPECT_EQ(16.0, CallD(
test->entry(), 7.0, -3.0, 5.0));
4187 EXPECT_EQ(-16.0, CallD(
test->entry(), 7.0, 3.0, -5.0));
4191 FLAG_use_compressed_instructions =
false;
4198 "02b50553 fadd.d fa0, fa0, fa1\n"
4200 EXPECT_EQ(8.0, CallD(
test->entry(), 3.0, 5.0));
4201 EXPECT_EQ(2.0, CallD(
test->entry(), -3.0, 5.0));
4202 EXPECT_EQ(-2.0, CallD(
test->entry(), 3.0, -5.0));
4203 EXPECT_EQ(-8.0, CallD(
test->entry(), -3.0, -5.0));
4205 EXPECT_EQ(10.0, CallD(
test->entry(), 7.0, 3.0));
4206 EXPECT_EQ(-4.0, CallD(
test->entry(), -7.0, 3.0));
4207 EXPECT_EQ(4.0, CallD(
test->entry(), 7.0, -3.0));
4208 EXPECT_EQ(-10.0, CallD(
test->entry(), -7.0, -3.0));
4212 FLAG_use_compressed_instructions =
false;
4219 "0ab50553 fsub.d fa0, fa0, fa1\n"
4221 EXPECT_EQ(-2.0, CallD(
test->entry(), 3.0, 5.0));
4222 EXPECT_EQ(-8.0, CallD(
test->entry(), -3.0, 5.0));
4223 EXPECT_EQ(8.0, CallD(
test->entry(), 3.0, -5.0));
4224 EXPECT_EQ(2.0, CallD(
test->entry(), -3.0, -5.0));
4226 EXPECT_EQ(4.0, CallD(
test->entry(), 7.0, 3.0));
4227 EXPECT_EQ(-10.0, CallD(
test->entry(), -7.0, 3.0));
4228 EXPECT_EQ(10.0, CallD(
test->entry(), 7.0, -3.0));
4229 EXPECT_EQ(-4.0, CallD(
test->entry(), -7.0, -3.0));
4233 FLAG_use_compressed_instructions =
false;
4240 "12b50553 fmul.d fa0, fa0, fa1\n"
4242 EXPECT_EQ(15.0, CallD(
test->entry(), 3.0, 5.0));
4243 EXPECT_EQ(-15.0, CallD(
test->entry(), -3.0, 5.0));
4244 EXPECT_EQ(-15.0, CallD(
test->entry(), 3.0, -5.0));
4245 EXPECT_EQ(15.0, CallD(
test->entry(), -3.0, -5.0));
4247 EXPECT_EQ(21.0, CallD(
test->entry(), 7.0, 3.0));
4248 EXPECT_EQ(-21.0, CallD(
test->entry(), -7.0, 3.0));
4249 EXPECT_EQ(-21.0, CallD(
test->entry(), 7.0, -3.0));
4250 EXPECT_EQ(21.0, CallD(
test->entry(), -7.0, -3.0));
4254 FLAG_use_compressed_instructions =
false;
4261 "1ab50553 fdiv.d fa0, fa0, fa1\n"
4263 EXPECT_EQ(2.0, CallD(
test->entry(), 10.0, 5.0));
4264 EXPECT_EQ(-2.0, CallD(
test->entry(), -10.0, 5.0));
4265 EXPECT_EQ(-2.0, CallD(
test->entry(), 10.0, -5.0));
4266 EXPECT_EQ(2.0, CallD(
test->entry(), -10.0, -5.0));
4270 FLAG_use_compressed_instructions =
false;
4277 "5a050553 fsqrt.d fa0, fa0\n"
4279 EXPECT_EQ(0.0, CallD(
test->entry(), 0.0));
4280 EXPECT_EQ(1.0, CallD(
test->entry(), 1.0));
4281 EXPECT_EQ(2.0, CallD(
test->entry(), 4.0));
4282 EXPECT_EQ(3.0, CallD(
test->entry(), 9.0));
4286 FLAG_use_compressed_instructions =
false;
4293 "22b50553 fsgnj.d fa0, fa0, fa1\n"
4295 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, 5.0));
4296 EXPECT_EQ(3.0, CallD(
test->entry(), -3.0, 5.0));
4297 EXPECT_EQ(-3.0, CallD(
test->entry(), 3.0, -5.0));
4298 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, -5.0));
4302 FLAG_use_compressed_instructions =
false;
4309 "22b51553 fsgnjn.d fa0, fa0, fa1\n"
4311 EXPECT_EQ(-3.0, CallD(
test->entry(), 3.0, 5.0));
4312 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, 5.0));
4313 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, -5.0));
4314 EXPECT_EQ(3.0, CallD(
test->entry(), -3.0, -5.0));
4318 FLAG_use_compressed_instructions =
false;
4325 "22b52553 fsgnjx.d fa0, fa0, fa1\n"
4327 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, 5.0));
4328 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, 5.0));
4329 EXPECT_EQ(-3.0, CallD(
test->entry(), 3.0, -5.0));
4330 EXPECT_EQ(3.0, CallD(
test->entry(), -3.0, -5.0));
4334 FLAG_use_compressed_instructions =
false;
4341 "2ab50553 fmin.d fa0, fa0, fa1\n"
4343 EXPECT_EQ(1.0, CallD(
test->entry(), 3.0, 1.0));
4344 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, 3.0));
4345 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, 5.0));
4346 EXPECT_EQ(-1.0, CallD(
test->entry(), 3.0, -1.0));
4347 EXPECT_EQ(-3.0, CallD(
test->entry(), 3.0, -3.0));
4348 EXPECT_EQ(-5.0, CallD(
test->entry(), 3.0, -5.0));
4349 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, 1.0));
4350 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, 3.0));
4351 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, 5.0));
4352 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, -1.0));
4353 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, -3.0));
4354 EXPECT_EQ(-5.0, CallD(
test->entry(), -3.0, -5.0));
4356 EXPECT_EQ(bit_cast<uint64_t>(-0.0),
4357 bit_cast<uint64_t>(CallD(
test->entry(), 0.0, -0.0)));
4358 EXPECT_EQ(bit_cast<uint64_t>(-0.0),
4359 bit_cast<uint64_t>(CallD(
test->entry(), -0.0, 0.0)));
4361 double qNAN = std::numeric_limits<double>::quiet_NaN();
4362 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, qNAN));
4363 EXPECT_EQ(3.0, CallD(
test->entry(), qNAN, 3.0));
4364 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, qNAN));
4365 EXPECT_EQ(-3.0, CallD(
test->entry(), qNAN, -3.0));
4367 double sNAN = std::numeric_limits<double>::signaling_NaN();
4368 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, sNAN));
4369 EXPECT_EQ(3.0, CallD(
test->entry(), sNAN, 3.0));
4370 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, sNAN));
4371 EXPECT_EQ(-3.0, CallD(
test->entry(), sNAN, -3.0));
4373 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4374 bit_cast<uint64_t>(CallD(
test->entry(), sNAN, sNAN)));
4375 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4376 bit_cast<uint64_t>(CallD(
test->entry(), qNAN, qNAN)));
4377 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4378 bit_cast<uint64_t>(CallD(
test->entry(), qNAN, sNAN)));
4379 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4380 bit_cast<uint64_t>(CallD(
test->entry(), sNAN, qNAN)));
4384 FLAG_use_compressed_instructions =
false;
4391 "2ab51553 fmax.d fa0, fa0, fa1\n"
4393 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, 1.0));
4394 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, 3.0));
4395 EXPECT_EQ(5.0, CallD(
test->entry(), 3.0, 5.0));
4396 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, -1.0));
4397 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, -3.0));
4398 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, -5.0));
4399 EXPECT_EQ(1.0, CallD(
test->entry(), -3.0, 1.0));
4400 EXPECT_EQ(3.0, CallD(
test->entry(), -3.0, 3.0));
4401 EXPECT_EQ(5.0, CallD(
test->entry(), -3.0, 5.0));
4402 EXPECT_EQ(-1.0, CallD(
test->entry(), -3.0, -1.0));
4403 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, -3.0));
4404 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, -5.0));
4406 EXPECT_EQ(bit_cast<uint64_t>(0.0),
4407 bit_cast<uint64_t>(CallD(
test->entry(), 0.0, -0.0)));
4408 EXPECT_EQ(bit_cast<uint64_t>(0.0),
4409 bit_cast<uint64_t>(CallD(
test->entry(), -0.0, 0.0)));
4411 double qNAN = std::numeric_limits<double>::quiet_NaN();
4412 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, qNAN));
4413 EXPECT_EQ(3.0, CallD(
test->entry(), qNAN, 3.0));
4414 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, qNAN));
4415 EXPECT_EQ(-3.0, CallD(
test->entry(), qNAN, -3.0));
4417 double sNAN = std::numeric_limits<double>::signaling_NaN();
4418 EXPECT_EQ(3.0, CallD(
test->entry(), 3.0, sNAN));
4419 EXPECT_EQ(3.0, CallD(
test->entry(), sNAN, 3.0));
4420 EXPECT_EQ(-3.0, CallD(
test->entry(), -3.0, sNAN));
4421 EXPECT_EQ(-3.0, CallD(
test->entry(), sNAN, -3.0));
4423 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4424 bit_cast<uint64_t>(CallD(
test->entry(), sNAN, sNAN)));
4425 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4426 bit_cast<uint64_t>(CallD(
test->entry(), qNAN, qNAN)));
4427 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4428 bit_cast<uint64_t>(CallD(
test->entry(), qNAN, sNAN)));
4429 EXPECT_EQ(bit_cast<uint64_t>(qNAN),
4430 bit_cast<uint64_t>(CallD(
test->entry(), sNAN, qNAN)));
4434 FLAG_use_compressed_instructions =
false;
4441 "40150553 fcvt.s.d fa0, fa0\n"
4443 EXPECT_EQ(0.0f, CallF(
test->entry(), 0.0));
4444 EXPECT_EQ(42.0f, CallF(
test->entry(), 42.0));
4445 EXPECT_EQ(-42.0f, CallF(
test->entry(), -42.0));
4446 EXPECT_EQ(
true, isnan(CallF(
test->entry(),
4447 std::numeric_limits<double>::quiet_NaN())));
4448 EXPECT_EQ(
true, isnan(CallF(
test->entry(),
4449 std::numeric_limits<double>::signaling_NaN())));
4450 EXPECT_EQ(std::numeric_limits<float>::infinity(),
4451 CallF(
test->entry(), std::numeric_limits<double>::infinity()));
4452 EXPECT_EQ(-std::numeric_limits<float>::infinity(),
4453 CallF(
test->entry(), -std::numeric_limits<double>::infinity()));
4457 FLAG_use_compressed_instructions =
false;
4464 "42050553 fcvt.d.s fa0, fa0\n"
4466 EXPECT_EQ(0.0, CallD(
test->entry(), 0.0f));
4467 EXPECT_EQ(42.0, CallD(
test->entry(), 42.0f));
4468 EXPECT_EQ(-42.0, CallD(
test->entry(), -42.0f));
4469 EXPECT_EQ(
true, isnan(CallD(
test->entry(),
4470 std::numeric_limits<float>::quiet_NaN())));
4471 EXPECT_EQ(
true, isnan(CallD(
test->entry(),
4472 std::numeric_limits<float>::signaling_NaN())));
4473 EXPECT_EQ(std::numeric_limits<double>::infinity(),
4474 CallD(
test->entry(), std::numeric_limits<float>::infinity()));
4475 EXPECT_EQ(-std::numeric_limits<double>::infinity(),
4476 CallD(
test->entry(), -std::numeric_limits<float>::infinity()));
4480 FLAG_use_compressed_instructions =
false;
4485 EXPECT_DISASSEMBLY(
"00008067 ret\n");
4486 EXPECT_EQ(
true, isnan(CallD(
test->entry(), 42.0f)));
4490 FLAG_use_compressed_instructions =
false;
4497 "a2b52553 feq.d a0, fa0, fa1\n"
4499 EXPECT_EQ(0, CallI(
test->entry(), 3.0, 1.0));
4500 EXPECT_EQ(1, CallI(
test->entry(), 3.0, 3.0));
4501 EXPECT_EQ(0, CallI(
test->entry(), 3.0, 5.0));
4502 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -1.0));
4503 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -3.0));
4504 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -5.0));
4505 EXPECT_EQ(0, CallI(
test->entry(), -3.0, 1.0));
4506 EXPECT_EQ(0, CallI(
test->entry(), -3.0, 3.0));
4507 EXPECT_EQ(0, CallI(
test->entry(), -3.0, 5.0));
4508 EXPECT_EQ(0, CallI(
test->entry(), -3.0, -1.0));
4509 EXPECT_EQ(1, CallI(
test->entry(), -3.0, -3.0));
4510 EXPECT_EQ(0, CallI(
test->entry(), -3.0, -5.0));
4512 double qNAN = std::numeric_limits<double>::quiet_NaN();
4513 EXPECT_EQ(0, CallI(
test->entry(), 3.0, qNAN));
4514 EXPECT_EQ(0, CallI(
test->entry(), qNAN, 3.0));
4515 EXPECT_EQ(0, CallI(
test->entry(), -3.0, qNAN));
4516 EXPECT_EQ(0, CallI(
test->entry(), qNAN, -3.0));
4520 FLAG_use_compressed_instructions =
false;
4527 "a2b51553 flt.d a0, fa0, fa1\n"
4529 EXPECT_EQ(0, CallI(
test->entry(), 3.0, 1.0));
4530 EXPECT_EQ(0, CallI(
test->entry(), 3.0, 3.0));
4531 EXPECT_EQ(1, CallI(
test->entry(), 3.0, 5.0));
4532 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -1.0));
4533 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -3.0));
4534 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -5.0));
4535 EXPECT_EQ(1, CallI(
test->entry(), -3.0, 1.0));
4536 EXPECT_EQ(1, CallI(
test->entry(), -3.0, 3.0));
4537 EXPECT_EQ(1, CallI(
test->entry(), -3.0, 5.0));
4538 EXPECT_EQ(1, CallI(
test->entry(), -3.0, -1.0));
4539 EXPECT_EQ(0, CallI(
test->entry(), -3.0, -3.0));
4540 EXPECT_EQ(0, CallI(
test->entry(), -3.0, -5.0));
4542 double qNAN = std::numeric_limits<double>::quiet_NaN();
4543 EXPECT_EQ(0, CallI(
test->entry(), 3.0, qNAN));
4544 EXPECT_EQ(0, CallI(
test->entry(), qNAN, 3.0));
4545 EXPECT_EQ(0, CallI(
test->entry(), -3.0, qNAN));
4546 EXPECT_EQ(0, CallI(
test->entry(), qNAN, -3.0));
4550 FLAG_use_compressed_instructions =
false;
4557 "a2b50553 fle.d a0, fa0, fa1\n"
4559 EXPECT_EQ(0, CallI(
test->entry(), 3.0, 1.0));
4560 EXPECT_EQ(1, CallI(
test->entry(), 3.0, 3.0));
4561 EXPECT_EQ(1, CallI(
test->entry(), 3.0, 5.0));
4562 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -1.0));
4563 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -3.0));
4564 EXPECT_EQ(0, CallI(
test->entry(), 3.0, -5.0));
4565 EXPECT_EQ(1, CallI(
test->entry(), -3.0, 1.0));
4566 EXPECT_EQ(1, CallI(
test->entry(), -3.0, 3.0));
4567 EXPECT_EQ(1, CallI(
test->entry(), -3.0, 5.0));
4568 EXPECT_EQ(1, CallI(
test->entry(), -3.0, -1.0));
4569 EXPECT_EQ(1, CallI(
test->entry(), -3.0, -3.0));
4570 EXPECT_EQ(0, CallI(
test->entry(), -3.0, -5.0));
4572 double qNAN = std::numeric_limits<double>::quiet_NaN();
4573 EXPECT_EQ(0, CallI(
test->entry(), 3.0, qNAN));
4574 EXPECT_EQ(0, CallI(
test->entry(), qNAN, 3.0));
4575 EXPECT_EQ(0, CallI(
test->entry(), -3.0, qNAN));
4576 EXPECT_EQ(0, CallI(
test->entry(), qNAN, -3.0));
4580 FLAG_use_compressed_instructions =
false;
4587 "e2051553 fclass.d a0, fa0\n"
4591 CallI(
test->entry(), -std::numeric_limits<double>::infinity()));
4593 EXPECT_EQ(1 << 1, CallI(
test->entry(), -1.0));
4598 EXPECT_EQ(1 << 3, CallI(
test->entry(), -0.0));
4600 EXPECT_EQ(1 << 4, CallI(
test->entry(), 0.0));
4605 EXPECT_EQ(1 << 6, CallI(
test->entry(), 1.0));
4608 CallI(
test->entry(), std::numeric_limits<double>::infinity()));
4611 CallI(
test->entry(), std::numeric_limits<double>::signaling_NaN()));
4614 CallI(
test->entry(), std::numeric_limits<double>::quiet_NaN()));
4618 FLAG_use_compressed_instructions =
false;
4625 "c2050553 fcvt.w.d a0, fa0\n"
4627 EXPECT_EQ(-42, CallI(
test->entry(),
static_cast<double>(-42)));
4628 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<double>(0)));
4629 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<double>(42)));
4643 CallI(
test->entry(), -std::numeric_limits<double>::infinity()));
4645 CallI(
test->entry(), std::numeric_limits<double>::infinity()));
4647 CallI(
test->entry(), std::numeric_limits<double>::signaling_NaN()));
4651 FLAG_use_compressed_instructions =
false;
4658 "c2150553 fcvt.wu.d a0, fa0\n"
4660 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<double>(-42)));
4661 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<double>(0)));
4662 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<double>(42)));
4676 CallI(
test->entry(), -std::numeric_limits<double>::infinity()));
4678 CallI(
test->entry(), std::numeric_limits<double>::infinity()));
4680 CallI(
test->entry(), std::numeric_limits<double>::signaling_NaN()));
4684 FLAG_use_compressed_instructions =
false;
4691 "d2050553 fcvt.d.w fa0, a0\n"
4696 EXPECT_EQ(
static_cast<double>(
kMinInt32),
4698 EXPECT_EQ(
static_cast<double>(
kMaxInt32),
4704 FLAG_use_compressed_instructions =
false;
4711 "d2150553 fcvt.d.wu fa0, a0\n"
4714 static_cast<double>(
static_cast<uint32_t
>(
static_cast<int32_t
>(-42))),
4718 EXPECT_EQ(
static_cast<double>(
static_cast<uint32_t
>(
kMinInt32)),
4720 EXPECT_EQ(
static_cast<double>(
kMaxInt32),
4727 FLAG_use_compressed_instructions =
false;
4734 "22b58553 fmv.d fa0, fa1\n"
4736 EXPECT_EQ(36.0, CallD(
test->entry(), 42.0, 36.0));
4737 EXPECT_EQ(std::numeric_limits<double>::infinity(),
4738 CallD(
test->entry(), -std::numeric_limits<double>::infinity(),
4739 std::numeric_limits<double>::infinity()));
4743 FLAG_use_compressed_instructions =
false;
4750 "22a52553 fabs.d fa0, fa0\n"
4752 EXPECT_EQ(0.0, CallD(
test->entry(), 0.0));
4753 EXPECT_EQ(0.0, CallD(
test->entry(), -0.0));
4754 EXPECT_EQ(42.0, CallD(
test->entry(), 42.0));
4755 EXPECT_EQ(42.0, CallD(
test->entry(), -42.0));
4756 EXPECT_EQ(std::numeric_limits<double>::infinity(),
4757 CallD(
test->entry(), std::numeric_limits<double>::infinity()));
4758 EXPECT_EQ(std::numeric_limits<double>::infinity(),
4759 CallD(
test->entry(), -std::numeric_limits<double>::infinity()));
4763 FLAG_use_compressed_instructions =
false;
4770 "22a51553 fneg.d fa0, fa0\n"
4772 EXPECT_EQ(-0.0, CallD(
test->entry(), 0.0));
4773 EXPECT_EQ(0.0, CallD(
test->entry(), -0.0));
4774 EXPECT_EQ(-42.0, CallD(
test->entry(), 42.0));
4775 EXPECT_EQ(42.0, CallD(
test->entry(), -42.0));
4776 EXPECT_EQ(-std::numeric_limits<double>::infinity(),
4777 CallD(
test->entry(), std::numeric_limits<double>::infinity()));
4778 EXPECT_EQ(std::numeric_limits<double>::infinity(),
4779 CallD(
test->entry(), -std::numeric_limits<double>::infinity()));
4784 FLAG_use_compressed_instructions =
false;
4791 "c2250553 fcvt.l.d a0, fa0\n"
4793 EXPECT_EQ(-42, CallI(
test->entry(),
static_cast<double>(-42)));
4794 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<double>(0)));
4795 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<double>(42)));
4796 EXPECT_EQ(
static_cast<int64_t
>(
kMinInt32),
4798 EXPECT_EQ(
static_cast<int64_t
>(
kMaxInt32),
4806 CallI(
test->entry(), -std::numeric_limits<double>::infinity()));
4808 CallI(
test->entry(), std::numeric_limits<double>::infinity()));
4810 CallI(
test->entry(), std::numeric_limits<double>::signaling_NaN()));
4814 FLAG_use_compressed_instructions =
false;
4821 "c2250553 fcvt.l.d a0, fa0\n"
4823 EXPECT_EQ(-44, CallI(
test->entry(), -43.6));
4824 EXPECT_EQ(-44, CallI(
test->entry(), -43.5));
4825 EXPECT_EQ(-43, CallI(
test->entry(), -43.4));
4826 EXPECT_EQ(-43, CallI(
test->entry(), -43.0));
4827 EXPECT_EQ(-43, CallI(
test->entry(), -42.6));
4828 EXPECT_EQ(-42, CallI(
test->entry(), -42.5));
4829 EXPECT_EQ(-42, CallI(
test->entry(), -42.4));
4830 EXPECT_EQ(-42, CallI(
test->entry(), -42.0));
4831 EXPECT_EQ(0, CallI(
test->entry(), -0.0));
4832 EXPECT_EQ(0, CallI(
test->entry(), +0.0));
4833 EXPECT_EQ(42, CallI(
test->entry(), 42.0));
4834 EXPECT_EQ(42, CallI(
test->entry(), 42.4));
4835 EXPECT_EQ(42, CallI(
test->entry(), 42.5));
4836 EXPECT_EQ(43, CallI(
test->entry(), 42.6));
4837 EXPECT_EQ(43, CallI(
test->entry(), 43.0));
4838 EXPECT_EQ(43, CallI(
test->entry(), 43.4));
4839 EXPECT_EQ(44, CallI(
test->entry(), 43.5));
4840 EXPECT_EQ(44, CallI(
test->entry(), 43.6));
4844 FLAG_use_compressed_instructions =
false;
4851 "c2251553 fcvt.l.d a0, fa0, rtz\n"
4853 EXPECT_EQ(-43, CallI(
test->entry(), -43.6));
4854 EXPECT_EQ(-43, CallI(
test->entry(), -43.5));
4855 EXPECT_EQ(-43, CallI(
test->entry(), -43.4));
4856 EXPECT_EQ(-43, CallI(
test->entry(), -43.0));
4857 EXPECT_EQ(-42, CallI(
test->entry(), -42.6));
4858 EXPECT_EQ(-42, CallI(
test->entry(), -42.5));
4859 EXPECT_EQ(-42, CallI(
test->entry(), -42.4));
4860 EXPECT_EQ(-42, CallI(
test->entry(), -42.0));
4861 EXPECT_EQ(0, CallI(
test->entry(), -0.0));
4862 EXPECT_EQ(0, CallI(
test->entry(), +0.0));
4863 EXPECT_EQ(42, CallI(
test->entry(), 42.0));
4864 EXPECT_EQ(42, CallI(
test->entry(), 42.4));
4865 EXPECT_EQ(42, CallI(
test->entry(), 42.5));
4866 EXPECT_EQ(42, CallI(
test->entry(), 42.6));
4867 EXPECT_EQ(43, CallI(
test->entry(), 43.0));
4868 EXPECT_EQ(43, CallI(
test->entry(), 43.4));
4869 EXPECT_EQ(43, CallI(
test->entry(), 43.5));
4870 EXPECT_EQ(43, CallI(
test->entry(), 43.6));
4874 FLAG_use_compressed_instructions =
false;
4881 "c2252553 fcvt.l.d a0, fa0, rdn\n"
4883 EXPECT_EQ(-44, CallI(
test->entry(), -43.6));
4884 EXPECT_EQ(-44, CallI(
test->entry(), -43.5));
4885 EXPECT_EQ(-44, CallI(
test->entry(), -43.4));
4886 EXPECT_EQ(-43, CallI(
test->entry(), -43.0));
4887 EXPECT_EQ(-43, CallI(
test->entry(), -42.6));
4888 EXPECT_EQ(-43, CallI(
test->entry(), -42.5));
4889 EXPECT_EQ(-43, CallI(
test->entry(), -42.4));
4890 EXPECT_EQ(-42, CallI(
test->entry(), -42.0));
4891 EXPECT_EQ(0, CallI(
test->entry(), -0.0));
4892 EXPECT_EQ(0, CallI(
test->entry(), +0.0));
4893 EXPECT_EQ(42, CallI(
test->entry(), 42.0));
4894 EXPECT_EQ(42, CallI(
test->entry(), 42.4));
4895 EXPECT_EQ(42, CallI(
test->entry(), 42.5));
4896 EXPECT_EQ(42, CallI(
test->entry(), 42.6));
4897 EXPECT_EQ(43, CallI(
test->entry(), 43.0));
4898 EXPECT_EQ(43, CallI(
test->entry(), 43.4));
4899 EXPECT_EQ(43, CallI(
test->entry(), 43.5));
4900 EXPECT_EQ(43, CallI(
test->entry(), 43.6));
4904 FLAG_use_compressed_instructions =
false;
4911 "c2253553 fcvt.l.d a0, fa0, rup\n"
4913 EXPECT_EQ(-43, CallI(
test->entry(), -43.6));
4914 EXPECT_EQ(-43, CallI(
test->entry(), -43.5));
4915 EXPECT_EQ(-43, CallI(
test->entry(), -43.4));
4916 EXPECT_EQ(-43, CallI(
test->entry(), -43.0));
4917 EXPECT_EQ(-42, CallI(
test->entry(), -42.6));
4918 EXPECT_EQ(-42, CallI(
test->entry(), -42.5));
4919 EXPECT_EQ(-42, CallI(
test->entry(), -42.4));
4920 EXPECT_EQ(-42, CallI(
test->entry(), -42.0));
4921 EXPECT_EQ(0, CallI(
test->entry(), -0.0));
4922 EXPECT_EQ(0, CallI(
test->entry(), +0.0));
4923 EXPECT_EQ(42, CallI(
test->entry(), 42.0));
4924 EXPECT_EQ(43, CallI(
test->entry(), 42.4));
4925 EXPECT_EQ(43, CallI(
test->entry(), 42.5));
4926 EXPECT_EQ(43, CallI(
test->entry(), 42.6));
4927 EXPECT_EQ(43, CallI(
test->entry(), 43.0));
4928 EXPECT_EQ(44, CallI(
test->entry(), 43.5));
4929 EXPECT_EQ(44, CallI(
test->entry(), 43.5));
4930 EXPECT_EQ(44, CallI(
test->entry(), 43.6));
4934 FLAG_use_compressed_instructions =
false;
4941 "c2254553 fcvt.l.d a0, fa0, rmm\n"
4943 EXPECT_EQ(-44, CallI(
test->entry(), -43.6));
4944 EXPECT_EQ(-44, CallI(
test->entry(), -43.5));
4945 EXPECT_EQ(-43, CallI(
test->entry(), -43.4));
4946 EXPECT_EQ(-43, CallI(
test->entry(), -43.0));
4947 EXPECT_EQ(-43, CallI(
test->entry(), -42.6));
4948 EXPECT_EQ(-43, CallI(
test->entry(), -42.5));
4949 EXPECT_EQ(-42, CallI(
test->entry(), -42.4));
4950 EXPECT_EQ(-42, CallI(
test->entry(), -42.0));
4951 EXPECT_EQ(0, CallI(
test->entry(), -0.0));
4952 EXPECT_EQ(0, CallI(
test->entry(), +0.0));
4953 EXPECT_EQ(42, CallI(
test->entry(), 42.0));
4954 EXPECT_EQ(42, CallI(
test->entry(), 42.4));
4955 EXPECT_EQ(43, CallI(
test->entry(), 42.5));
4956 EXPECT_EQ(43, CallI(
test->entry(), 42.6));
4957 EXPECT_EQ(43, CallI(
test->entry(), 43.0));
4958 EXPECT_EQ(43, CallI(
test->entry(), 43.4));
4959 EXPECT_EQ(44, CallI(
test->entry(), 43.5));
4960 EXPECT_EQ(44, CallI(
test->entry(), 43.6));
4964 FLAG_use_compressed_instructions =
false;
4971 "c2350553 fcvt.lu.d a0, fa0\n"
4973 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<double>(-42)));
4974 EXPECT_EQ(0, CallI(
test->entry(),
static_cast<double>(0)));
4975 EXPECT_EQ(42, CallI(
test->entry(),
static_cast<double>(42)));
4976 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(0)),
4978 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxInt32)),
4980 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint32)),
4982 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(0)),
4984 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxInt64) + 1),
4986 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint64)),
4988 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(0)),
4989 CallI(
test->entry(), -std::numeric_limits<double>::infinity()));
4990 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint64)),
4991 CallI(
test->entry(), std::numeric_limits<double>::infinity()));
4992 EXPECT_EQ(
static_cast<int64_t
>(
static_cast<uint64_t
>(
kMaxUint64)),
4993 CallI(
test->entry(), std::numeric_limits<double>::signaling_NaN()));
4997 FLAG_use_compressed_instructions =
false;
5004 "e2050553 fmv.x.d a0, fa0\n"
5006 EXPECT_EQ(bit_cast<int64_t>(0.0), CallI(
test->entry(), 0.0));
5007 EXPECT_EQ(bit_cast<int64_t>(-0.0), CallI(
test->entry(), -0.0));
5008 EXPECT_EQ(bit_cast<int64_t>(42.0), CallI(
test->entry(), 42.0));
5009 EXPECT_EQ(bit_cast<int64_t>(-42.0), CallI(
test->entry(), -42.0));
5010 EXPECT_EQ(bit_cast<int64_t>(std::numeric_limits<double>::quiet_NaN()),
5011 CallI(
test->entry(), std::numeric_limits<double>::quiet_NaN()));
5012 EXPECT_EQ(bit_cast<int64_t>(std::numeric_limits<double>::signaling_NaN()),
5013 CallI(
test->entry(), std::numeric_limits<double>::signaling_NaN()));
5014 EXPECT_EQ(bit_cast<int64_t>(std::numeric_limits<double>::infinity()),
5015 CallI(
test->entry(), std::numeric_limits<double>::infinity()));
5016 EXPECT_EQ(bit_cast<int64_t>(-std::numeric_limits<double>::infinity()),
5017 CallI(
test->entry(), -std::numeric_limits<double>::infinity()));
5021 FLAG_use_compressed_instructions =
false;
5028 "d2250553 fcvt.d.l fa0, a0\n"
5033 EXPECT_EQ(
static_cast<double>(
kMinInt32),
5035 EXPECT_EQ(
static_cast<double>(
kMaxInt32),
5039 EXPECT_EQ(
static_cast<double>(
kMinInt64),
5041 EXPECT_EQ(
static_cast<double>(
kMaxInt64),
5048 FLAG_use_compressed_instructions =
false;
5055 "d2350553 fcvt.d.lu fa0, a0\n"
5059 EXPECT_EQ(
static_cast<double>(
static_cast<uint64_t
>(
sign_extend(-42))),
5076 FLAG_use_compressed_instructions =
false;
5083 "f2050553 fmv.d.x fa0, a0\n"
5085 EXPECT_EQ(0.0, CallD(
test->entry(), bit_cast<int64_t>(0.0)));
5086 EXPECT_EQ(-0.0, CallD(
test->entry(), bit_cast<int64_t>(-0.0)));
5087 EXPECT_EQ(42.0, CallD(
test->entry(), bit_cast<int64_t>(42.0)));
5088 EXPECT_EQ(-42.0, CallD(
test->entry(), bit_cast<int64_t>(-42.0)));
5089 EXPECT_EQ(
true, isnan(CallD(
test->entry(),
5091 std::numeric_limits<double>::quiet_NaN()))));
5093 isnan(CallD(
test->entry(),
5095 std::numeric_limits<double>::signaling_NaN()))));
5096 EXPECT_EQ(std::numeric_limits<double>::infinity(),
5097 CallD(
test->entry(),
5098 bit_cast<int64_t>(std::numeric_limits<double>::infinity())));
5099 EXPECT_EQ(-std::numeric_limits<double>::infinity(),
5100 CallD(
test->entry(),
5101 bit_cast<int64_t>(-std::numeric_limits<double>::infinity())));
5106 FLAG_use_compressed_instructions =
false;
5110 __ subi(
SP,
SP,
sizeof(uintx_t) * 4);
5111 __ sx(
RA, Address(
SP, 3 *
sizeof(uintx_t)));
5112 __ sx(
A0, Address(
SP, 2 *
sizeof(uintx_t)));
5117 __ sx(
A0, Address(
SP, 1 *
sizeof(uintx_t)));
5118 __ lx(
A0, Address(
SP, 2 *
sizeof(uintx_t)));
5121 __ lx(
A1, Address(
SP, 1 *
sizeof(uintx_t)));
5129 __ lx(
RA, Address(
SP, 3 *
sizeof(uintx_t)));
5130 __ addi(
SP,
SP,
sizeof(uintx_t) * 4);
5137 "ff010113 addi sp, sp, -16\n"
5138 "00112623 sw ra, 12(sp)\n"
5139 "00a12423 sw a0, 8(sp)\n"
5140 "fff50513 addi a0, a0, -1\n"
5141 "02a05263 blez a0, +36\n"
5142 "fedff0ef jal -20\n"
5143 "00a12223 sw a0, 4(sp)\n"
5144 "00812503 lw a0, 8(sp)\n"
5145 "ffe50513 addi a0, a0, -2\n"
5146 "fddff0ef jal -36\n"
5147 "00412583 lw a1, 4(sp)\n"
5148 "00b50533 add a0, a0, a1\n"
5150 "00100513 li a0, 1\n"
5151 "00c12083 lw ra, 12(sp)\n"
5152 "01010113 addi sp, sp, 16\n"
5157 "fe010113 addi sp, sp, -32\n"
5158 "00113c23 sd ra, 24(sp)\n"
5159 "00a13823 sd a0, 16(sp)\n"
5160 "fff50513 addi a0, a0, -1\n"
5161 "02a05263 blez a0, +36\n"
5162 "fedff0ef jal -20\n"
5163 "00a13423 sd a0, 8(sp)\n"
5164 "01013503 ld a0, 16(sp)\n"
5165 "ffe50513 addi a0, a0, -2\n"
5166 "fddff0ef jal -36\n"
5167 "00813583 ld a1, 8(sp)\n"
5168 "00b50533 add a0, a0, a1\n"
5170 "00100513 li a0, 1\n"
5171 "01813083 ld ra, 24(sp)\n"
5172 "02010113 addi sp, sp, 32\n"
5178 EXPECT_EQ(1, Call(
test->entry(), 0));
5179 EXPECT_EQ(1, Call(
test->entry(), 1));
5180 EXPECT_EQ(2, Call(
test->entry(), 2));
5181 EXPECT_EQ(3, Call(
test->entry(), 3));
5182 EXPECT_EQ(5, Call(
test->entry(), 4));
5183 EXPECT_EQ(8, Call(
test->entry(), 5));
5184 EXPECT_EQ(13, Call(
test->entry(), 6));
5188 FLAG_use_compressed_instructions =
true;
5192 __ sw(
A1, Address(
SP, 0));
5193 __ lw(
A0, Address(
SP, 0));
5199 " 7111 addi sp, sp, -256\n"
5200 " c02e sw a1, 0(sp)\n"
5201 " 4502 lw a0, 0(sp)\n"
5202 " 6111 addi sp, sp, 256\n"
5205 EXPECT_EQ(
sign_extend(0xAB010203), Call(
test->entry(), 0, 0xAB010203));
5206 EXPECT_EQ(
sign_extend(0xCD020405), Call(
test->entry(), 0, 0xCD020405));
5207 EXPECT_EQ(
sign_extend(0xEF030607), Call(
test->entry(), 0, 0xEF030607));
5210 FLAG_use_compressed_instructions =
true;
5214 __ sw(
A1, Address(
SP, 4));
5215 __ lw(
A0, Address(
SP, 4));
5221 " 7111 addi sp, sp, -256\n"
5222 " c22e sw a1, 4(sp)\n"
5223 " 4512 lw a0, 4(sp)\n"
5224 " 6111 addi sp, sp, 256\n"
5227 EXPECT_EQ(
sign_extend(0xAB010203), Call(
test->entry(), 0, 0xAB010203));
5228 EXPECT_EQ(
sign_extend(0xCD020405), Call(
test->entry(), 0, 0xCD020405));
5229 EXPECT_EQ(
sign_extend(0xEF030607), Call(
test->entry(), 0, 0xEF030607));
5234 FLAG_use_compressed_instructions =
true;
5244 " 7111 addi sp, sp, -256\n"
5245 " e02e fsw fa1, 0(sp)\n"
5246 " 6502 flw fa0, 0(sp)\n"
5247 " 6111 addi sp, sp, 256\n"
5250 EXPECT_EQ(1.7f, CallF(
test->entry(), 0.0f, 1.7f));
5251 EXPECT_EQ(2.8f, CallF(
test->entry(), 0.0f, 2.8f));
5252 EXPECT_EQ(3.9f, CallF(
test->entry(), 0.0f, 3.9f));
5256 FLAG_use_compressed_instructions =
true;
5266 " 7111 addi sp, sp, -256\n"
5267 " e22e fsw fa1, 4(sp)\n"
5268 " 6512 flw fa0, 4(sp)\n"
5269 " 6111 addi sp, sp, 256\n"
5272 EXPECT_EQ(1.7f, CallF(
test->entry(), 0.0f, 1.7f));
5273 EXPECT_EQ(2.8f, CallF(
test->entry(), 0.0f, 2.8f));
5274 EXPECT_EQ(3.9f, CallF(
test->entry(), 0.0f, 3.9f));
5279 FLAG_use_compressed_instructions =
true;
5289 " 7111 addi sp, sp, -256\n"
5290 " a02e fsd fa1, 0(sp)\n"
5291 " 2502 fld fa0, 0(sp)\n"
5292 " 6111 addi sp, sp, 256\n"
5295 EXPECT_EQ(1.7, CallD(
test->entry(), 0.0, 1.7));
5296 EXPECT_EQ(2.8, CallD(
test->entry(), 0.0, 2.8));
5297 EXPECT_EQ(3.9, CallD(
test->entry(), 0.0, 3.9));
5300 FLAG_use_compressed_instructions =
true;
5310 " 7111 addi sp, sp, -256\n"
5311 " a42e fsd fa1, 8(sp)\n"
5312 " 2522 fld fa0, 8(sp)\n"
5313 " 6111 addi sp, sp, 256\n"
5316 EXPECT_EQ(1.7, CallD(
test->entry(), 0.0, 1.7));
5317 EXPECT_EQ(2.8, CallD(
test->entry(), 0.0, 2.8));
5318 EXPECT_EQ(3.9, CallD(
test->entry(), 0.0, 3.9));
5323 FLAG_use_compressed_instructions =
true;
5326 __ sd(
A1, Address(
SP, 0));
5327 __ ld(
A0, Address(
SP, 0));
5333 " 7111 addi sp, sp, -256\n"
5334 " e02e sd a1, 0(sp)\n"
5335 " 6502 ld a0, 0(sp)\n"
5336 " 6111 addi sp, sp, 256\n"
5339 EXPECT_EQ((intx_t)0xAB01020304050607,
5340 Call(
test->entry(), 0, 0xAB01020304050607));
5341 EXPECT_EQ((intx_t)0xCD02040505060708,
5342 Call(
test->entry(), 0, 0xCD02040505060708));
5343 EXPECT_EQ((intx_t)0xEF03060708090A0B,
5344 Call(
test->entry(), 0, 0xEF03060708090A0B));
5347 FLAG_use_compressed_instructions =
true;
5350 __ sd(
A1, Address(
SP, 8));
5351 __ ld(
A0, Address(
SP, 8));
5357 " 7111 addi sp, sp, -256\n"
5358 " e42e sd a1, 8(sp)\n"
5359 " 6522 ld a0, 8(sp)\n"
5360 " 6111 addi sp, sp, 256\n"
5363 EXPECT_EQ((intx_t)0xAB01020304050607,
5364 Call(
test->entry(), 0, 0xAB01020304050607));
5365 EXPECT_EQ((intx_t)0xCD02040505060708,
5366 Call(
test->entry(), 0, 0xCD02040505060708));
5367 EXPECT_EQ((intx_t)0xEF03060708090A0B,
5368 Call(
test->entry(), 0, 0xEF03060708090A0B));
5373 FLAG_use_compressed_instructions =
true;
5375 __ lw(
A0, Address(
A0, 0));
5380 " 4108 lw a0, 0(a0)\n"
5383 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
5388 EXPECT_EQ(-855505915,
5389 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
5392 FLAG_use_compressed_instructions =
true;
5394 __ lw(
A0, Address(
A0, 4));
5399 " 4148 lw a0, 4(a0)\n"
5402 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
5407 EXPECT_EQ(-285014521,
5408 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
5412 FLAG_use_compressed_instructions =
true;
5414 __ sw(
A1, Address(
A0, 0));
5419 " c10c sw a1, 0(a0)\n"
5422 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
5427 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xCD020405);
5428 EXPECT_EQ(0u,
values[0]);
5429 EXPECT_EQ(0xCD020405,
values[1]);
5430 EXPECT_EQ(0u,
values[2]);
5433 FLAG_use_compressed_instructions =
true;
5435 __ sw(
A1, Address(
A0, 4));
5440 " c14c sw a1, 4(a0)\n"
5443 uint32_t*
values =
reinterpret_cast<uint32_t*
>(
malloc(3 *
sizeof(uint32_t)));
5448 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xEF030607);
5449 EXPECT_EQ(0u,
values[0]);
5450 EXPECT_EQ(0u,
values[1]);
5451 EXPECT_EQ(0xEF030607,
values[2]);
5456 FLAG_use_compressed_instructions =
true;
5458 __ flw(
FA0, Address(
A0, 1 *
sizeof(
float)));
5463 " 6148 flw fa0, 4(a0)\n"
5466 float*
data =
reinterpret_cast<float*
>(
malloc(3 *
sizeof(
float)));
5470 EXPECT_EQ(
data[1], CallF(
test->entry(),
reinterpret_cast<intx_t
>(
data)));
5474 FLAG_use_compressed_instructions =
true;
5476 __ fsw(
FA0, Address(
A0, 1 *
sizeof(
float)));
5481 " e148 fsw fa0, 4(a0)\n"
5484 float*
data =
reinterpret_cast<float*
>(
malloc(3 *
sizeof(
float)));
5488 CallF(
test->entry(),
reinterpret_cast<intx_t
>(
data), 4.2f);
5489 EXPECT_EQ(4.2f,
data[1]);
5495 FLAG_use_compressed_instructions =
true;
5497 __ ld(
A0, Address(
A0, 0));
5502 " 6108 ld a0, 0(a0)\n"
5505 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
5506 values[0] = 0xAB01020304050607;
5507 values[1] = 0xCD02040505060708;
5508 values[2] = 0xEF03060708090A0B;
5510 EXPECT_EQ(-3674369926375274744,
5511 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
5514 FLAG_use_compressed_instructions =
true;
5516 __ ld(
A0, Address(
A0, 8));
5521 " 6508 ld a0, 8(a0)\n"
5524 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
5525 values[0] = 0xAB01020304050607;
5526 values[1] = 0xCD02040505060708;
5527 values[2] = 0xEF03060708090A0B;
5529 EXPECT_EQ(-1224128046445295093,
5530 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1])));
5534 FLAG_use_compressed_instructions =
true;
5536 __ sd(
A1, Address(
A0, 0));
5541 " e10c sd a1, 0(a0)\n"
5544 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
5549 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xCD02040505060708);
5550 EXPECT_EQ(0u,
values[0]);
5551 EXPECT_EQ(0xCD02040505060708,
values[1]);
5552 EXPECT_EQ(0u,
values[2]);
5555 FLAG_use_compressed_instructions =
true;
5557 __ sd(
A1, Address(
A0, 8));
5562 " e50c sd a1, 8(a0)\n"
5565 uint64_t*
values =
reinterpret_cast<uint64_t*
>(
malloc(3 *
sizeof(uint64_t)));
5570 Call(
test->entry(),
reinterpret_cast<intx_t
>(&
values[1]), 0xEF03060708090A0B);
5571 EXPECT_EQ(0u,
values[0]);
5572 EXPECT_EQ(0u,
values[1]);
5573 EXPECT_EQ(0xEF03060708090A0B,
values[2]);
5577 FLAG_use_compressed_instructions =
true;
5579 __ fld(
FA0, Address(
A0, 1 *
sizeof(
double)));
5584 " 2508 fld fa0, 8(a0)\n"
5587 double*
data =
reinterpret_cast<double*
>(
malloc(3 *
sizeof(
double)));
5591 EXPECT_EQ(
data[1], CallD(
test->entry(),
reinterpret_cast<intx_t
>(
data)));
5596 FLAG_use_compressed_instructions =
true;
5598 __ fsd(
FA0, Address(
A0, 1 *
sizeof(
double)));
5603 " a508 fsd fa0, 8(a0)\n"
5606 double*
data =
reinterpret_cast<double*
>(
malloc(3 *
sizeof(
double)));
5610 CallD(
test->entry(),
reinterpret_cast<intx_t
>(
data), 4.2);
5611 EXPECT_EQ(4.2,
data[1]);
5617 FLAG_use_compressed_instructions =
true;
5620 Label label1, label2;
5646 "40628533 sub a0, t0, t1\n"
5660 EXPECT_EQ(-3, Call(
test->entry()));
5665 FLAG_use_compressed_instructions =
true;
5667 Label label1, label2;
5684 "40628533 sub a0, t0, t1\n"
5689 EXPECT_EQ(-3, Call(
test->entry()));
5692static int CompressedJumpAndLinkRegister_label1 = 0;
5693static int CompressedJumpAndLinkRegister_label2 = 0;
5695 FLAG_use_compressed_instructions =
true;
5697 Label label1, label2;
5717 CompressedJumpAndLinkRegister_label1 = label1.Position();
5718 CompressedJumpAndLinkRegister_label2 = label2.Position();
5724 "40628533 sub a0, t0, t1\n"
5737 Call(
test->entry(), 0,
5738 static_cast<intx_t
>(
test->entry() +
5739 CompressedJumpAndLinkRegister_label1),
5740 static_cast<intx_t
>(
test->entry() +
5741 CompressedJumpAndLinkRegister_label2)));
5744static int CompressedJumpRegister_label = 0;
5746 FLAG_use_compressed_instructions =
true;
5754 CompressedJumpRegister_label = label.Position();
5760 "02a00513 li a0, 42\n"
5762 EXPECT_EQ(42, Call(
test->entry(), 0,
5763 static_cast<intx_t
>(
test->entry() +
5764 CompressedJumpRegister_label)));
5768 FLAG_use_compressed_instructions =
true;
5780 " c119 beqz a0, +6\n"
5785 EXPECT_EQ(3, Call(
test->entry(), -42));
5786 EXPECT_EQ(4, Call(
test->entry(), 0));
5787 EXPECT_EQ(3, Call(
test->entry(), 42));
5791 FLAG_use_compressed_instructions =
true;
5803 " e119 bnez a0, +6\n"
5808 EXPECT_EQ(4, Call(
test->entry(), -42));
5809 EXPECT_EQ(3, Call(
test->entry(), 0));
5810 EXPECT_EQ(4, Call(
test->entry(), 42));
5814 FLAG_use_compressed_instructions =
true;
5823 EXPECT_EQ(-7, Call(
test->entry()));
5827 FLAG_use_compressed_instructions =
true;
5829 __ lui(
A0, 7 << 12);
5834 " 651d lui a0, 28672\n"
5836 EXPECT_EQ(7 << 12, Call(
test->entry()));
5840 FLAG_use_compressed_instructions =
true;
5847 " 054d addi a0, a0, 19\n"
5849 EXPECT_EQ(42, Call(
test->entry(), 23));
5854 FLAG_use_compressed_instructions =
true;
5861 " 254d addiw a0, a0, 19\n"
5863 EXPECT_EQ(19, Call(
test->entry(), 0xFFFFFFFF00000000));
5864 EXPECT_EQ(-237, Call(
test->entry(), 0x00000000FFFFFF00));
5869 FLAG_use_compressed_instructions =
true;
5877 " 7119 addi sp, sp, -128\n"
5878 " 6109 addi sp, sp, 128\n"
5880 EXPECT_EQ(0, Call(
test->entry(), 0));
5884 FLAG_use_compressed_instructions =
true;
5892 " 104c addi a1, sp, 36\n"
5893 "40258533 sub a0, a1, sp\n"
5895 EXPECT_EQ(36, Call(
test->entry()));
5899 FLAG_use_compressed_instructions =
true;
5906 " 050e slli a0, a0, 3\n"
5908 EXPECT_EQ(0, Call(
test->entry(), 0));
5909 EXPECT_EQ(336, Call(
test->entry(), 42));
5910 EXPECT_EQ(15872, Call(
test->entry(), 1984));
5911 EXPECT_EQ(-336, Call(
test->entry(), -42));
5912 EXPECT_EQ(-15872, Call(
test->entry(), -1984));
5916 FLAG_use_compressed_instructions =
true;
5923 " 810d srli a0, a0, 3\n"
5925 EXPECT_EQ(0, Call(
test->entry(), 0));
5926 EXPECT_EQ(5, Call(
test->entry(), 42));
5927 EXPECT_EQ(248, Call(
test->entry(), 1984));
5928 EXPECT_EQ(
static_cast<intx_t
>(
static_cast<uintx_t
>(-42) >> 3),
5929 Call(
test->entry(), -42));
5930 EXPECT_EQ(
static_cast<intx_t
>(
static_cast<uintx_t
>(-1984) >> 3),
5931 Call(
test->entry(), -1984));
5935 FLAG_use_compressed_instructions =
true;
5942 " 850d srai a0, a0, 3\n"
5944 EXPECT_EQ(0, Call(
test->entry(), 0));
5945 EXPECT_EQ(5, Call(
test->entry(), 42));
5946 EXPECT_EQ(248, Call(
test->entry(), 1984));
5947 EXPECT_EQ(-6, Call(
test->entry(), -42));
5948 EXPECT_EQ(-248, Call(
test->entry(), -1984));
5952 FLAG_use_compressed_instructions =
true;
5959 " 8919 andi a0, a0, 6\n"
5961 EXPECT_EQ(0, Call(
test->entry(), 0));
5962 EXPECT_EQ(2, Call(
test->entry(), 43));
5963 EXPECT_EQ(0, Call(
test->entry(), 1984));
5964 EXPECT_EQ(6, Call(
test->entry(), -42));
5965 EXPECT_EQ(0, Call(
test->entry(), -1984));
5969 FLAG_use_compressed_instructions =
true;
5976 " 9969 andi a0, a0, -6\n"
5978 EXPECT_EQ(0, Call(
test->entry(), 0));
5979 EXPECT_EQ(42, Call(
test->entry(), 43));
5980 EXPECT_EQ(1984, Call(
test->entry(), 1984));
5981 EXPECT_EQ(-46, Call(
test->entry(), -42));
5982 EXPECT_EQ(-1984, Call(
test->entry(), -1984));
5986 FLAG_use_compressed_instructions =
true;
5995 EXPECT_EQ(42, Call(
test->entry(), 0, 42));
5999 FLAG_use_compressed_instructions =
true;
6006 " 952e add a0, a0, a1\n"
6008 EXPECT_EQ(24, Call(
test->entry(), 7, 17));
6009 EXPECT_EQ(-10, Call(
test->entry(), 7, -17));
6010 EXPECT_EQ(10, Call(
test->entry(), -7, 17));
6011 EXPECT_EQ(-24, Call(
test->entry(), -7, -17));
6012 EXPECT_EQ(24, Call(
test->entry(), 17, 7));
6013 EXPECT_EQ(10, Call(
test->entry(), 17, -7));
6014 EXPECT_EQ(-10, Call(
test->entry(), -17, 7));
6015 EXPECT_EQ(-24, Call(
test->entry(), -17, -7));
6019 FLAG_use_compressed_instructions =
true;
6026 " 8d6d and a0, a0, a1\n"
6028 EXPECT_EQ(1, Call(
test->entry(), 7, 17));
6029 EXPECT_EQ(7, Call(
test->entry(), 7, -17));
6030 EXPECT_EQ(17, Call(
test->entry(), -7, 17));
6031 EXPECT_EQ(-23, Call(
test->entry(), -7, -17));
6032 EXPECT_EQ(1, Call(
test->entry(), 17, 7));
6033 EXPECT_EQ(17, Call(
test->entry(), 17, -7));
6034 EXPECT_EQ(7, Call(
test->entry(), -17, 7));
6035 EXPECT_EQ(-23, Call(
test->entry(), -17, -7));
6039 FLAG_use_compressed_instructions =
true;
6046 " 8d4d or a0, a0, a1\n"
6048 EXPECT_EQ(23, Call(
test->entry(), 7, 17));
6049 EXPECT_EQ(-17, Call(
test->entry(), 7, -17));
6050 EXPECT_EQ(-7, Call(
test->entry(), -7, 17));
6051 EXPECT_EQ(-1, Call(
test->entry(), -7, -17));
6052 EXPECT_EQ(23, Call(
test->entry(), 17, 7));
6053 EXPECT_EQ(-7, Call(
test->entry(), 17, -7));
6054 EXPECT_EQ(-17, Call(
test->entry(), -17, 7));
6055 EXPECT_EQ(-1, Call(
test->entry(), -17, -7));
6059 FLAG_use_compressed_instructions =
true;
6066 " 8d2d xor a0, a0, a1\n"
6068 EXPECT_EQ(22, Call(
test->entry(), 7, 17));
6069 EXPECT_EQ(-24, Call(
test->entry(), 7, -17));
6070 EXPECT_EQ(-24, Call(
test->entry(), -7, 17));
6071 EXPECT_EQ(22, Call(
test->entry(), -7, -17));
6072 EXPECT_EQ(22, Call(
test->entry(), 17, 7));
6073 EXPECT_EQ(-24, Call(
test->entry(), 17, -7));
6074 EXPECT_EQ(-24, Call(
test->entry(), -17, 7));
6075 EXPECT_EQ(22, Call(
test->entry(), -17, -7));
6079 FLAG_use_compressed_instructions =
true;
6086 " 8d0d sub a0, a0, a1\n"
6088 EXPECT_EQ(-10, Call(
test->entry(), 7, 17));
6089 EXPECT_EQ(24, Call(
test->entry(), 7, -17));
6090 EXPECT_EQ(-24, Call(
test->entry(), -7, 17));
6091 EXPECT_EQ(10, Call(
test->entry(), -7, -17));
6092 EXPECT_EQ(10, Call(
test->entry(), 17, 7));
6093 EXPECT_EQ(24, Call(
test->entry(), 17, -7));
6094 EXPECT_EQ(-24, Call(
test->entry(), -17, 7));
6095 EXPECT_EQ(-10, Call(
test->entry(), -17, -7));
6100 FLAG_use_compressed_instructions =
true;
6107 " 9d2d addw a0, a0, a1\n"
6109 EXPECT_EQ(24, Call(
test->entry(), 7, 17));
6110 EXPECT_EQ(-10, Call(
test->entry(), 7, -17));
6111 EXPECT_EQ(10, Call(
test->entry(), -7, 17));
6112 EXPECT_EQ(-24, Call(
test->entry(), -7, -17));
6113 EXPECT_EQ(24, Call(
test->entry(), 17, 7));
6114 EXPECT_EQ(10, Call(
test->entry(), 17, -7));
6115 EXPECT_EQ(-10, Call(
test->entry(), -17, 7));
6116 EXPECT_EQ(-24, Call(
test->entry(), -17, -7));
6117 EXPECT_EQ(3, Call(
test->entry(), 0x200000002, 0x100000001));
6121 FLAG_use_compressed_instructions =
true;
6128 " 9d0d subw a0, a0, a1\n"
6130 EXPECT_EQ(-10, Call(
test->entry(), 7, 17));
6131 EXPECT_EQ(24, Call(
test->entry(), 7, -17));
6132 EXPECT_EQ(-24, Call(
test->entry(), -7, 17));
6133 EXPECT_EQ(10, Call(
test->entry(), -7, -17));
6134 EXPECT_EQ(10, Call(
test->entry(), 17, 7));
6135 EXPECT_EQ(24, Call(
test->entry(), 17, -7));
6136 EXPECT_EQ(-24, Call(
test->entry(), -17, 7));
6137 EXPECT_EQ(-10, Call(
test->entry(), -17, -7));
6138 EXPECT_EQ(1, Call(
test->entry(), 0x200000002, 0x100000001));
6143 FLAG_use_compressed_instructions =
true;
6152 EXPECT_EQ(123, Call(
test->entry(), 123));
6156 FLAG_use_compressed_instructions =
true;
6177 "08b5053b add.uw a0, a0, a1\n"
6180 EXPECT_EQ(0x200000001, Call(
test->entry(), 0x1, 0x200000000));
6181 EXPECT_EQ(0x200000001, Call(
test->entry(), 0x100000001, 0x200000000));
6182 EXPECT_EQ(0x2FFFFFFFF, Call(
test->entry(), -0x1, 0x200000000));
6193 "20b52533 sh1add a0, a0, a1\n"
6196 EXPECT_EQ(1002, Call(
test->entry(), 1, 1000));
6197 EXPECT_EQ(1000, Call(
test->entry(), 0, 1000));
6198 EXPECT_EQ(998, Call(
test->entry(), -1, 1000));
6208 "20b54533 sh2add a0, a0, a1\n"
6211 EXPECT_EQ(1004, Call(
test->entry(), 1, 1000));
6212 EXPECT_EQ(1000, Call(
test->entry(), 0, 1000));
6213 EXPECT_EQ(996, Call(
test->entry(), -1, 1000));
6223 "20b56533 sh3add a0, a0, a1\n"
6226 EXPECT_EQ(1008, Call(
test->entry(), 1, 1000));
6227 EXPECT_EQ(1000, Call(
test->entry(), 0, 1000));
6228 EXPECT_EQ(992, Call(
test->entry(), -1, 1000));
6239 "20b5253b sh1add.uw a0, a0, a1\n"
6242 EXPECT_EQ(1002, Call(
test->entry(), 1, 1000));
6243 EXPECT_EQ(1002, Call(
test->entry(), 0x100000001, 1000));
6244 EXPECT_EQ(1000, Call(
test->entry(), 0, 1000));
6245 EXPECT_EQ(8589935590, Call(
test->entry(), -1, 1000));
6255 "20b5453b sh2add.uw a0, a0, a1\n"
6258 EXPECT_EQ(1004, Call(
test->entry(), 1, 1000));
6259 EXPECT_EQ(1004, Call(
test->entry(), 0x100000001, 1000));
6260 EXPECT_EQ(1000, Call(
test->entry(), 0, 1000));
6261 EXPECT_EQ(17179870180, Call(
test->entry(), -1, 1000));
6271 "20b5653b sh3add.uw a0, a0, a1\n"
6274 EXPECT_EQ(1008, Call(
test->entry(), 1, 1000));
6275 EXPECT_EQ(1008, Call(
test->entry(), 0x100000001, 1000));
6276 EXPECT_EQ(1000, Call(
test->entry(), 0, 1000));
6277 EXPECT_EQ(34359739360, Call(
test->entry(), -1, 1000));
6287 "0885151b slli.uw a0, a0, 0x8\n"
6290 EXPECT_EQ(0x100, Call(
test->entry(), 0x1));
6291 EXPECT_EQ(0x1000000000, Call(
test->entry(), 0x10000000));
6292 EXPECT_EQ(0, Call(
test->entry(), 0x100000000));
6293 EXPECT_EQ(0x100, Call(
test->entry(), 0x100000001));
6304 "40b57533 andn a0, a0, a1\n"
6307 EXPECT_EQ(6, Call(
test->entry(), 7, 17));
6308 EXPECT_EQ(0, Call(
test->entry(), 7, -17));
6309 EXPECT_EQ(-24, Call(
test->entry(), -7, 17));
6310 EXPECT_EQ(16, Call(
test->entry(), -7, -17));
6311 EXPECT_EQ(16, Call(
test->entry(), 17, 7));
6312 EXPECT_EQ(0, Call(
test->entry(), 17, -7));
6313 EXPECT_EQ(-24, Call(
test->entry(), -17, 7));
6314 EXPECT_EQ(6, Call(
test->entry(), -17, -7));
6324 "40b56533 orn a0, a0, a1\n"
6327 EXPECT_EQ(-17, Call(
test->entry(), 7, 17));
6328 EXPECT_EQ(23, Call(
test->entry(), 7, -17));
6329 EXPECT_EQ(-1, Call(
test->entry(), -7, 17));
6330 EXPECT_EQ(-7, Call(
test->entry(), -7, -17));
6331 EXPECT_EQ(-7, Call(
test->entry(), 17, 7));
6332 EXPECT_EQ(23, Call(
test->entry(), 17, -7));
6333 EXPECT_EQ(-1, Call(
test->entry(), -17, 7));
6334 EXPECT_EQ(-17, Call(
test->entry(), -17, -7));
6344 "40b54533 xnor a0, a0, a1\n"
6347 EXPECT_EQ(-23, Call(
test->entry(), 7, 17));
6348 EXPECT_EQ(23, Call(
test->entry(), 7, -17));
6349 EXPECT_EQ(23, Call(
test->entry(), -7, 17));
6350 EXPECT_EQ(-23, Call(
test->entry(), -7, -17));
6351 EXPECT_EQ(-23, Call(
test->entry(), 17, 7));
6352 EXPECT_EQ(23, Call(
test->entry(), 17, -7));
6353 EXPECT_EQ(23, Call(
test->entry(), -17, 7));
6354 EXPECT_EQ(-23, Call(
test->entry(), -17, -7));
6364 "60051513 clz a0, a0\n"
6367 EXPECT_EQ(XLEN, Call(
test->entry(), 0));
6368 EXPECT_EQ(XLEN - 1, Call(
test->entry(), 1));
6369 EXPECT_EQ(XLEN - 2, Call(
test->entry(), 2));
6370 EXPECT_EQ(XLEN - 3, Call(
test->entry(), 4));
6371 EXPECT_EQ(XLEN - 8, Call(
test->entry(), 240));
6372 EXPECT_EQ(0, Call(
test->entry(), -1));
6373 EXPECT_EQ(0, Call(
test->entry(), -2));
6374 EXPECT_EQ(0, Call(
test->entry(), -4));
6375 EXPECT_EQ(0, Call(
test->entry(), -240));
6385 "60151513 ctz a0, a0\n"
6388 EXPECT_EQ(XLEN, Call(
test->entry(), 0));
6389 EXPECT_EQ(0, Call(
test->entry(), 1));
6390 EXPECT_EQ(1, Call(
test->entry(), 2));
6391 EXPECT_EQ(2, Call(
test->entry(), 4));
6392 EXPECT_EQ(4, Call(
test->entry(), 240));
6393 EXPECT_EQ(0, Call(
test->entry(), -1));
6394 EXPECT_EQ(1, Call(
test->entry(), -2));
6395 EXPECT_EQ(2, Call(
test->entry(), -4));
6396 EXPECT_EQ(4, Call(
test->entry(), -240));
6406 "60251513 cpop a0, a0\n"
6409 EXPECT_EQ(0, Call(
test->entry(), 0));
6410 EXPECT_EQ(1, Call(
test->entry(), 1));
6411 EXPECT_EQ(3, Call(
test->entry(), 7));
6412 EXPECT_EQ(4, Call(
test->entry(), 30));
6413 EXPECT_EQ(XLEN, Call(
test->entry(), -1));
6414 EXPECT_EQ(XLEN - 2, Call(
test->entry(), -7));
6415 EXPECT_EQ(XLEN - 4, Call(
test->entry(), -30));
6426 "6005151b clzw a0, a0\n"
6429 EXPECT_EQ(32, Call(
test->entry(), 0));
6430 EXPECT_EQ(31, Call(
test->entry(), 1));
6431 EXPECT_EQ(30, Call(
test->entry(), 2));
6432 EXPECT_EQ(29, Call(
test->entry(), 4));
6433 EXPECT_EQ(24, Call(
test->entry(), 240));
6434 EXPECT_EQ(0, Call(
test->entry(), -1));
6435 EXPECT_EQ(0, Call(
test->entry(), -2));
6436 EXPECT_EQ(0, Call(
test->entry(), -4));
6437 EXPECT_EQ(0, Call(
test->entry(), -240));
6447 "6015151b ctzw a0, a0\n"
6450 EXPECT_EQ(32, Call(
test->entry(), 0));
6451 EXPECT_EQ(0, Call(
test->entry(), 1));
6452 EXPECT_EQ(1, Call(
test->entry(), 2));
6453 EXPECT_EQ(2, Call(
test->entry(), 4));
6454 EXPECT_EQ(4, Call(
test->entry(), 240));
6455 EXPECT_EQ(0, Call(
test->entry(), -1));
6456 EXPECT_EQ(1, Call(
test->entry(), -2));
6457 EXPECT_EQ(2, Call(
test->entry(), -4));
6458 EXPECT_EQ(4, Call(
test->entry(), -240));
6468 "6025151b cpopw a0, a0\n"
6471 EXPECT_EQ(0, Call(
test->entry(), 0));
6472 EXPECT_EQ(1, Call(
test->entry(), 1));
6473 EXPECT_EQ(3, Call(
test->entry(), 7));
6474 EXPECT_EQ(4, Call(
test->entry(), 30));
6475 EXPECT_EQ(32, Call(
test->entry(), -1));
6476 EXPECT_EQ(30, Call(
test->entry(), -7));
6477 EXPECT_EQ(28, Call(
test->entry(), -30));
6478 EXPECT_EQ(0, Call(
test->entry(), 0x7FFFFFFF00000000));
6489 "0ab56533 max a0, a0, a1\n"
6492 EXPECT_EQ(17, Call(
test->entry(), 7, 17));
6493 EXPECT_EQ(17, Call(
test->entry(), -7, 17));
6494 EXPECT_EQ(7, Call(
test->entry(), 7, -17));
6495 EXPECT_EQ(-7, Call(
test->entry(), -7, -17));
6505 "0ab57533 maxu a0, a0, a1\n"
6508 EXPECT_EQ(17, Call(
test->entry(), 7, 17));
6509 EXPECT_EQ(-7, Call(
test->entry(), -7, 17));
6510 EXPECT_EQ(-17, Call(
test->entry(), 7, -17));
6511 EXPECT_EQ(-7, Call(
test->entry(), -7, -17));
6521 "0ab54533 min a0, a0, a1\n"
6524 EXPECT_EQ(7, Call(
test->entry(), 7, 17));
6525 EXPECT_EQ(-7, Call(
test->entry(), -7, 17));
6526 EXPECT_EQ(-17, Call(
test->entry(), 7, -17));
6527 EXPECT_EQ(-17, Call(
test->entry(), -7, -17));
6537 "0ab55533 minu a0, a0, a1\n"
6540 EXPECT_EQ(7, Call(
test->entry(), 7, 17));
6541 EXPECT_EQ(17, Call(
test->entry(), -7, 17));
6542 EXPECT_EQ(7, Call(
test->entry(), 7, -17));
6543 EXPECT_EQ(-17, Call(
test->entry(), -7, -17));
6553 "60451513 sext.b a0, a0\n"
6556 EXPECT_EQ(1, Call(
test->entry(), 1));
6557 EXPECT_EQ(127, Call(
test->entry(), 127));
6558 EXPECT_EQ(-128, Call(
test->entry(), 128));
6568 "60551513 sext.h a0, a0\n"
6571 EXPECT_EQ(0, Call(
test->entry(), 0));
6572 EXPECT_EQ(0x7BCD, Call(
test->entry(), 0x12347BCD));
6573 EXPECT_EQ(-1, Call(
test->entry(), 0xFFFF));
6574 EXPECT_EQ(-1, Call(
test->entry(), -1));
6585 "08054533 zext.h a0, a0\n"
6589 "0805453b zext.h a0, a0\n"
6593 EXPECT_EQ(0, Call(
test->entry(), 0));
6594 EXPECT_EQ(0xABCD, Call(
test->entry(), 0x1234ABCD));
6595 EXPECT_EQ(0xFFFF, Call(
test->entry(), 0xFFFF));
6596 EXPECT_EQ(0xFFFF, Call(
test->entry(), -1));
6606 "60b55533 ror a0, a0, a1\n"
6610 EXPECT_EQ(
static_cast<intx_t
>(0x12345678),
6611 Call(
test->entry(), 0x12345678, 0));
6612 EXPECT_EQ(
static_cast<intx_t
>(0x81234567),
6613 Call(
test->entry(), 0x12345678, 4));
6614 EXPECT_EQ(
static_cast<intx_t
>(0x23456781),
6615 Call(
test->entry(), 0x12345678, 28));
6616 EXPECT_EQ(
static_cast<intx_t
>(0x81234567),
6617 Call(
test->entry(), 0x12345678, 36));
6619 EXPECT_EQ(
static_cast<intx_t
>(0x0123456789ABCDEF),
6620 Call(
test->entry(), 0x0123456789ABCDEF, 0));
6621 EXPECT_EQ(
static_cast<intx_t
>(0xF0123456789ABCDE),
6622 Call(
test->entry(), 0x0123456789ABCDEF, 4));
6623 EXPECT_EQ(
static_cast<intx_t
>(0x123456789ABCDEF0),
6624 Call(
test->entry(), 0x0123456789ABCDEF, 60));
6625 EXPECT_EQ(
static_cast<intx_t
>(0xF0123456789ABCDE),
6626 Call(
test->entry(), 0x0123456789ABCDEF, 68));
6637 "60b51533 rol a0, a0, a1\n"
6641 EXPECT_EQ(
static_cast<intx_t
>(0x12345678),
6642 Call(
test->entry(), 0x12345678, 0));
6643 EXPECT_EQ(
static_cast<intx_t
>(0x23456781),
6644 Call(
test->entry(), 0x12345678, 4));
6645 EXPECT_EQ(
static_cast<intx_t
>(0x81234567),
6646 Call(
test->entry(), 0x12345678, 28));
6647 EXPECT_EQ(
static_cast<intx_t
>(0x23456781),
6648 Call(
test->entry(), 0x12345678, 36));
6650 EXPECT_EQ(
static_cast<intx_t
>(0x0123456789ABCDEF),
6651 Call(
test->entry(), 0x0123456789ABCDEF, 0));
6652 EXPECT_EQ(
static_cast<intx_t
>(0x123456789ABCDEF0),
6653 Call(
test->entry(), 0x0123456789ABCDEF, 4));
6654 EXPECT_EQ(
static_cast<intx_t
>(0xF0123456789ABCDE),
6655 Call(
test->entry(), 0x0123456789ABCDEF, 60));
6656 EXPECT_EQ(
static_cast<intx_t
>(0x123456789ABCDEF0),
6657 Call(
test->entry(), 0x0123456789ABCDEF, 68));
6668 "60455513 rori a0, a0, 0x4\n"
6672 EXPECT_EQ(
static_cast<intx_t
>(0x81234567), Call(
test->entry(), 0x12345678));
6674 EXPECT_EQ(
static_cast<intx_t
>(0xF0123456789ABCDE),
6675 Call(
test->entry(), 0x0123456789ABCDEF));
6687 "60b5553b rorw a0, a0, a1\n"
6690 EXPECT_EQ(
sign_extend(0x12345678), Call(
test->entry(), 0x12345678, 0));
6691 EXPECT_EQ(
sign_extend(0x81234567), Call(
test->entry(), 0x12345678, 4));
6692 EXPECT_EQ(
sign_extend(0x23456781), Call(
test->entry(), 0x12345678, 28));
6693 EXPECT_EQ(
sign_extend(0x81234567), Call(
test->entry(), 0x12345678, 36));
6703 "60b5153b rolw a0, a0, a1\n"
6706 EXPECT_EQ(
sign_extend(0x12345678), Call(
test->entry(), 0x12345678, 0));
6707 EXPECT_EQ(
sign_extend(0x23456781), Call(
test->entry(), 0x12345678, 4));
6708 EXPECT_EQ(
sign_extend(0x81234567), Call(
test->entry(), 0x12345678, 28));
6709 EXPECT_EQ(
sign_extend(0x23456781), Call(
test->entry(), 0x12345678, 36));
6719 "6045551b roriw a0, a0, 0x4\n"
6733 "28755513 orc.b a0, a0\n"
6736 EXPECT_EQ(0, Call(
test->entry(), 0));
6737 EXPECT_EQ(-1, Call(
test->entry(), -1));
6738 EXPECT_EQ(0x00FF00FF, Call(
test->entry(), 0x00010001));
6740 EXPECT_EQ(0x00FF00FF00FF00FF, Call(
test->entry(), 0x0001000100010001));
6752 "69855513 rev8 a0, a0\n"
6756 "6b855513 rev8 a0, a0\n"
6760 EXPECT_EQ(0, Call(
test->entry(), 0));
6761 EXPECT_EQ(-1, Call(
test->entry(), -1));
6763 EXPECT_EQ(0x11223344, Call(
test->entry(), 0x44332211));
6765 EXPECT_EQ(0x1122334455667788, Call(
test->entry(), 0x8877665544332211));
6776 "0ab51533 clmul a0, a0, a1\n"
6780 EXPECT_EQ(0x55555555, Call(
test->entry(), -1, -1));
6782 EXPECT_EQ(0x5555555555555555, Call(
test->entry(), -1, -1));
6784 EXPECT_EQ(0, Call(
test->entry(), -1, 0));
6785 EXPECT_EQ(-1, Call(
test->entry(), -1, 1));
6786 EXPECT_EQ(0, Call(
test->entry(), 0, -1));
6787 EXPECT_EQ(0, Call(
test->entry(), 0, 0));
6788 EXPECT_EQ(0, Call(
test->entry(), 0, 1));
6789 EXPECT_EQ(-1, Call(
test->entry(), 1, -1));
6790 EXPECT_EQ(0, Call(
test->entry(), 1, 0));
6791 EXPECT_EQ(1, Call(
test->entry(), 1, 1));
6793 EXPECT_EQ(4, Call(
test->entry(), 2, 2));
6794 EXPECT_EQ(5, Call(
test->entry(), 3, 3));
6795 EXPECT_EQ(16, Call(
test->entry(), 4, 4));
6796 EXPECT_EQ(20, Call(
test->entry(), 6, 6));
6806 "0ab53533 clmulh a0, a0, a1\n"
6810 EXPECT_EQ(0x55555555, Call(
test->entry(), -1, -1));
6812 EXPECT_EQ(0x5555555555555555, Call(
test->entry(), -1, -1));
6814 EXPECT_EQ(0, Call(
test->entry(), -1, 0));
6815 EXPECT_EQ(0, Call(
test->entry(), -1, 1));
6816 EXPECT_EQ(0, Call(
test->entry(), 0, -1));
6817 EXPECT_EQ(0, Call(
test->entry(), 0, 0));
6818 EXPECT_EQ(0, Call(
test->entry(), 0, 1));
6819 EXPECT_EQ(0, Call(
test->entry(), 1, -1));
6820 EXPECT_EQ(0, Call(
test->entry(), 1, 0));
6821 EXPECT_EQ(0, Call(
test->entry(), 1, 1));
6823 EXPECT_EQ(0, Call(
test->entry(), 2, 2));
6824 EXPECT_EQ(0, Call(
test->entry(), 3, 3));
6825 EXPECT_EQ(0, Call(
test->entry(), 4, 4));
6826 EXPECT_EQ(0, Call(
test->entry(), 6, 6));
6836 "0ab52533 clmulr a0, a0, a1\n"
6840 EXPECT_EQ(-0x55555556, Call(
test->entry(), -1, -1));
6842 EXPECT_EQ(-0x5555555555555556, Call(
test->entry(), -1, -1));
6844 EXPECT_EQ(0, Call(
test->entry(), -1, 0));
6845 EXPECT_EQ(1, Call(
test->entry(), -1, 1));
6846 EXPECT_EQ(0, Call(
test->entry(), 0, -1));
6847 EXPECT_EQ(0, Call(
test->entry(), 0, 0));
6848 EXPECT_EQ(0, Call(
test->entry(), 0, 1));
6849 EXPECT_EQ(1, Call(
test->entry(), 1, -1));
6850 EXPECT_EQ(0, Call(
test->entry(), 1, 0));
6851 EXPECT_EQ(0, Call(
test->entry(), 1, 1));
6853 EXPECT_EQ(0, Call(
test->entry(), 2, 2));
6854 EXPECT_EQ(0, Call(
test->entry(), 3, 3));
6855 EXPECT_EQ(0, Call(
test->entry(), 4, 4));
6856 EXPECT_EQ(0, Call(
test->entry(), 6, 6));
6866 "48b51533 bclr a0, a0, a1\n"
6869 EXPECT_EQ(42, Call(
test->entry(), 42, 0));
6870 EXPECT_EQ(40, Call(
test->entry(), 42, 1));
6871 EXPECT_EQ(42, Call(
test->entry(), 42, 2));
6872 EXPECT_EQ(34, Call(
test->entry(), 42, 3));
6873 EXPECT_EQ(42, Call(
test->entry(), 42, 4));
6874 EXPECT_EQ(10, Call(
test->entry(), 42, 5));
6875 EXPECT_EQ(42, Call(
test->entry(), 42, 6));
6876 EXPECT_EQ(42, Call(
test->entry(), 42, 7));
6877 EXPECT_EQ(42, Call(
test->entry(), 42, 8));
6879 EXPECT_EQ(42, Call(
test->entry(), 42, 64));
6880 EXPECT_EQ(40, Call(
test->entry(), 42, 65));
6890 "48351513 bclri a0, a0, 0x3\n"
6893 EXPECT_EQ(0, Call(
test->entry(), 0));
6894 EXPECT_EQ(7, Call(
test->entry(), 7));
6895 EXPECT_EQ(0, Call(
test->entry(), 8));
6896 EXPECT_EQ(1, Call(
test->entry(), 9));
6897 EXPECT_EQ(-15, Call(
test->entry(), -7));
6898 EXPECT_EQ(-16, Call(
test->entry(), -8));
6899 EXPECT_EQ(-9, Call(
test->entry(), -9));
6904 __ bclri(
A0,
A0, XLEN - 1);
6910 "49f51513 bclri a0, a0, 0x1f\n"
6914 "4bf51513 bclri a0, a0, 0x3f\n"
6918 EXPECT_EQ(0, Call(
test->entry(), 0));
6919 EXPECT_EQ(1, Call(
test->entry(), 1));
6920 EXPECT_EQ(kMaxIntX, Call(
test->entry(), -1));
6930 "48b55533 bext a0, a0, a1\n"
6933 EXPECT_EQ(0, Call(
test->entry(), 42, 0));
6934 EXPECT_EQ(1, Call(
test->entry(), 42, 1));
6935 EXPECT_EQ(0, Call(
test->entry(), 42, 2));
6936 EXPECT_EQ(1, Call(
test->entry(), 42, 3));
6937 EXPECT_EQ(0, Call(
test->entry(), 42, 4));
6938 EXPECT_EQ(1, Call(
test->entry(), 42, 5));
6939 EXPECT_EQ(0, Call(
test->entry(), 42, 6));
6940 EXPECT_EQ(0, Call(
test->entry(), 42, 7));
6941 EXPECT_EQ(0, Call(
test->entry(), 42, 8));
6943 EXPECT_EQ(0, Call(
test->entry(), 42, 64));
6944 EXPECT_EQ(1, Call(
test->entry(), 42, 65));
6954 "48355513 bexti a0, a0, 0x3\n"
6957 EXPECT_EQ(0, Call(
test->entry(), 0));
6958 EXPECT_EQ(0, Call(
test->entry(), 7));
6959 EXPECT_EQ(1, Call(
test->entry(), 8));
6960 EXPECT_EQ(1, Call(
test->entry(), 9));
6961 EXPECT_EQ(1, Call(
test->entry(), -7));
6962 EXPECT_EQ(1, Call(
test->entry(), -8));
6963 EXPECT_EQ(0, Call(
test->entry(), -9));
6968 __ bexti(
A0,
A0, XLEN - 1);
6974 "49f55513 bexti a0, a0, 0x1f\n"
6978 "4bf55513 bexti a0, a0, 0x3f\n"
6982 EXPECT_EQ(0, Call(
test->entry(), 0));
6983 EXPECT_EQ(0, Call(
test->entry(), 1));
6984 EXPECT_EQ(1, Call(
test->entry(), -1));
6994 "68b51533 binv a0, a0, a1\n"
6997 EXPECT_EQ(43, Call(
test->entry(), 42, 0));
6998 EXPECT_EQ(40, Call(
test->entry(), 42, 1));
6999 EXPECT_EQ(46, Call(
test->entry(), 42, 2));
7000 EXPECT_EQ(34, Call(
test->entry(), 42, 3));
7001 EXPECT_EQ(58, Call(
test->entry(), 42, 4));
7002 EXPECT_EQ(10, Call(
test->entry(), 42, 5));
7003 EXPECT_EQ(106, Call(
test->entry(), 42, 6));
7004 EXPECT_EQ(170, Call(
test->entry(), 42, 7));
7005 EXPECT_EQ(298, Call(
test->entry(), 42, 8));
7007 EXPECT_EQ(43, Call(
test->entry(), 42, 64));
7008 EXPECT_EQ(40, Call(
test->entry(), 42, 65));
7018 "68351513 binvi a0, a0, 0x3\n"
7021 EXPECT_EQ(8, Call(
test->entry(), 0));
7022 EXPECT_EQ(15, Call(
test->entry(), 7));
7023 EXPECT_EQ(0, Call(
test->entry(), 8));
7024 EXPECT_EQ(1, Call(
test->entry(), 9));
7025 EXPECT_EQ(-15, Call(
test->entry(), -7));
7026 EXPECT_EQ(-16, Call(
test->entry(), -8));
7027 EXPECT_EQ(-1, Call(
test->entry(), -9));
7032 __ binvi(
A0,
A0, XLEN - 1);
7038 "69f51513 binvi a0, a0, 0x1f\n"
7042 "6bf51513 binvi a0, a0, 0x3f\n"
7046 EXPECT_EQ(kMinIntX, Call(
test->entry(), 0));
7047 EXPECT_EQ(kMinIntX + 1, Call(
test->entry(), 1));
7048 EXPECT_EQ(kMaxIntX, Call(
test->entry(), -1));
7058 "28b51533 bset a0, a0, a1\n"
7061 EXPECT_EQ(43, Call(
test->entry(), 42, 0));
7062 EXPECT_EQ(42, Call(
test->entry(), 42, 1));
7063 EXPECT_EQ(46, Call(
test->entry(), 42, 2));
7064 EXPECT_EQ(42, Call(
test->entry(), 42, 3));
7065 EXPECT_EQ(58, Call(
test->entry(), 42, 4));
7066 EXPECT_EQ(42, Call(
test->entry(), 42, 5));
7067 EXPECT_EQ(106, Call(
test->entry(), 42, 6));
7068 EXPECT_EQ(170, Call(
test->entry(), 42, 7));
7069 EXPECT_EQ(298, Call(
test->entry(), 42, 8));
7071 EXPECT_EQ(43, Call(
test->entry(), 42, 64));
7072 EXPECT_EQ(42, Call(
test->entry(), 42, 65));
7082 "28351513 bseti a0, a0, 0x3\n"
7085 EXPECT_EQ(8, Call(
test->entry(), 0));
7086 EXPECT_EQ(15, Call(
test->entry(), 7));
7087 EXPECT_EQ(8, Call(
test->entry(), 8));
7088 EXPECT_EQ(9, Call(
test->entry(), 9));
7089 EXPECT_EQ(-7, Call(
test->entry(), -7));
7090 EXPECT_EQ(-8, Call(
test->entry(), -8));
7091 EXPECT_EQ(-1, Call(
test->entry(), -9));
7096 __ bseti(
A0,
A0, XLEN - 1);
7102 "29f51513 bseti a0, a0, 0x1f\n"
7106 "2bf51513 bseti a0, a0, 0x3f\n"
7110 EXPECT_EQ(kMinIntX, Call(
test->entry(), 0));
7111 EXPECT_EQ(kMinIntX + 1, Call(
test->entry(), 1));
7112 EXPECT_EQ(-1, Call(
test->entry(), -1));
7117 __ lb(
A0, Address(
A1), std::memory_order_acquire);
7122 "3405852f lb.aq a0, (a1)\n"
7126 EXPECT_EQ(-42, Call(
test->entry(), 0,
reinterpret_cast<intx_t
>(&
data)));
7131 __ lh(
A0, Address(
A1), std::memory_order_acquire);
7136 "3405952f lh.aq a0, (a1)\n"
7140 EXPECT_EQ(-42, Call(
test->entry(), 0,
reinterpret_cast<intx_t
>(&
data)));
7145 __ lw(
A0, Address(
A1), std::memory_order_acquire);
7150 "3405a52f lw.aq a0, (a1)\n"
7154 EXPECT_EQ(-42, Call(
test->entry(), 0,
reinterpret_cast<intx_t
>(&
data)));
7159 __ sb(
A0, Address(
A1), std::memory_order_release);
7164 "3aa5802f sb.rl a0, (a1)\n"
7168 EXPECT_EQ(-42, Call(
test->entry(), -42,
reinterpret_cast<intx_t
>(&
data)));
7169 EXPECT_EQ(-42,
data);
7174 __ sh(
A0, Address(
A1), std::memory_order_release);
7179 "3aa5902f sh.rl a0, (a1)\n"
7183 EXPECT_EQ(-42, Call(
test->entry(), -42,
reinterpret_cast<intx_t
>(&
data)));
7184 EXPECT_EQ(-42,
data);
7189 __ sw(
A0, Address(
A1), std::memory_order_release);
7194 "3aa5a02f sw.rl a0, (a1)\n"
7198 EXPECT_EQ(-42, Call(
test->entry(), -42,
reinterpret_cast<intx_t
>(&
data)));
7199 EXPECT_EQ(-42,
data);
7205 __ ld(
A0, Address(
A1), std::memory_order_acquire);
7210 "3405b52f ld.aq a0, (a1)\n"
7214 EXPECT_EQ(-42, Call(
test->entry(), 0,
reinterpret_cast<intx_t
>(&
data)));
7219 __ sd(
A0, Address(
A1), std::memory_order_release);
7224 "3aa5b02f sd.rl a0, (a1)\n"
7228 EXPECT_EQ(-42, Call(
test->entry(), -42,
reinterpret_cast<intx_t
>(&
data)));
7229 EXPECT_EQ(-42,
data);
7234 FLAG_use_compressed_instructions =
true;
7242 "80000537 lui a0, -2147483648\n"
7243 " 157d addi a0, a0, -1\n"
7247 "80000537 lui a0, -2147483648\n"
7248 " 357d addiw a0, a0, -1\n"
7255 FLAG_use_compressed_instructions =
true;
7262 "80000537 lui a0, -2147483648\n"
7269 FLAG_use_compressed_instructions =
true;
7277 "03f51513 slli a0, a0, 0x3f\n"
7283 FLAG_use_compressed_instructions =
true;
7285 __ LoadImmediate(
A0, 0xABCDABCDABCDABCD);
7290 "feaf3537 lui a0, -22073344\n"
7291 "6af5051b addiw a0, a0, 1711\n"
7292 " 0532 slli a0, a0, 12\n"
7293 "36b50513 addi a0, a0, 875\n"
7294 " 053a slli a0, a0, 14\n"
7295 "cdb50513 addi a0, a0, -805\n"
7296 " 0532 slli a0, a0, 12\n"
7297 "bcd50513 addi a0, a0, -1075\n"
7299 EXPECT_EQ(
static_cast<int64_t
>(0xABCDABCDABCDABCD), Call(
test->entry()));
7303 FLAG_use_compressed_instructions =
true;
7305 __ LoadImmediate(
A0, 0x7BCDABCD00000);
7310 "7bcdb537 lui a0, 2077077504\n"
7311 "bcd5051b addiw a0, a0, -1075\n"
7312 " 0552 slli a0, a0, 20\n"
7314 EXPECT_EQ(
static_cast<int64_t
>(0x7BCDABCD00000), Call(
test->entry()));
7318 FLAG_use_compressed_instructions =
true;
7320 __ LoadImmediate(
A0, 0xABCDE00000000000);
7325 "d5e6f537 lui a0, -706285568\n"
7326 "02151513 slli a0, a0, 0x21\n"
7328 EXPECT_EQ(
static_cast<int64_t
>(0xABCDE00000000000), Call(
test->entry()));
7332 FLAG_use_compressed_instructions =
true;
7334 __ LoadImmediate(
A0, 0xABC00000000000);
7339 "2af00513 li a0, 687\n"
7340 "02e51513 slli a0, a0, 0x2e\n"
7342 EXPECT_EQ(
static_cast<int64_t
>(0xABC00000000000), Call(
test->entry()));
7346 FLAG_use_compressed_instructions =
true;
7348 __ LoadImmediate(
A0, 0xFF000000000000FF);
7354 "03851513 slli a0, a0, 0x38\n"
7355 "0ff50513 addi a0, a0, 255\n"
7357 EXPECT_EQ(
static_cast<int64_t
>(0xFF000000000000FF), Call(
test->entry()));
7362 FLAG_use_compressed_instructions =
true;
7364 __ AndImmediate(
A0,
A1, ~0x10000000);
7365 __ OrImmediate(
A0,
A1, 0x10000000);
7366 __ XorImmediate(
A0,
A1, 0x10000000);
7372 "f0000737 lui tmp2, -268435456\n"
7373 " 177d addi tmp2, tmp2, -1\n"
7374 "00e5f533 and a0, a1, tmp2\n"
7375 "10000737 lui tmp2, 268435456\n"
7376 "00e5e533 or a0, a1, tmp2\n"
7377 "10000737 lui tmp2, 268435456\n"
7378 "00e5c533 xor a0, a1, tmp2\n"
7382 "f0000737 lui tmp2, -268435456\n"
7383 " 377d addiw tmp2, tmp2, -1\n"
7384 "00e5f533 and a0, a1, tmp2\n"
7385 "10000737 lui tmp2, 268435456\n"
7386 "00e5e533 or a0, a1, tmp2\n"
7387 "10000737 lui tmp2, 268435456\n"
7388 "00e5c533 xor a0, a1, tmp2\n"
7394 FLAG_use_compressed_instructions =
true;
7396 __ AndImmediate(
A0,
A1, ~0x10000000);
7397 __ OrImmediate(
A0,
A1, 0x10000000);
7398 __ XorImmediate(
A0,
A1, 0x10000000);
7403 "49c59513 bclri a0, a1, 0x1c\n"
7404 "29c59513 bseti a0, a1, 0x1c\n"
7405 "69c59513 binvi a0, a1, 0x1c\n"
7410 FLAG_use_compressed_instructions =
true;
7414 __ AddImmediateBranchOverflow(
A0,
A0, 2, &overflow);
7422 " 872a mv tmp2, a0\n"
7423 " 0509 addi a0, a0, 2\n"
7424 "00e54363 blt a0, tmp2, +6\n"
7428 EXPECT_EQ(kMaxIntX - 1, Call(
test->entry(), kMaxIntX - 3));
7429 EXPECT_EQ(kMaxIntX, Call(
test->entry(), kMaxIntX - 2));
7430 EXPECT_EQ(0, Call(
test->entry(), kMaxIntX - 1));
7431 EXPECT_EQ(0, Call(
test->entry(), kMaxIntX));
7435 FLAG_use_compressed_instructions =
true;
7439 __ AddBranchOverflow(
A0,
A1,
A2, &overflow);
7447 "00c58533 add a0, a1, a2\n"
7448 "00062693 slti tmp, a2, 0\n"
7449 "00b52733 slt tmp2, a0, a1\n"
7450 "00e69363 bne tmp, tmp2, +6\n"
7454 EXPECT_EQ(kMaxIntX - 1, Call(
test->entry(), 42, kMaxIntX, -1));
7455 EXPECT_EQ(kMaxIntX, Call(
test->entry(), 42, kMaxIntX, 0));
7456 EXPECT_EQ(0, Call(
test->entry(), 42, kMaxIntX, 1));
7458 EXPECT_EQ(0, Call(
test->entry(), 42, kMinIntX, -1));
7459 EXPECT_EQ(kMinIntX + 1, Call(
test->entry(), 42, kMinIntX, 1));
7460 EXPECT_EQ(kMinIntX, Call(
test->entry(), 42, kMinIntX, 0));
7464 FLAG_use_compressed_instructions =
true;
7468 __ AddBranchOverflow(
A0,
A1,
A0, &overflow);
7476 "00052693 slti tmp, a0, 0\n"
7477 " 952e add a0, a0, a1\n"
7478 "00b52733 slt tmp2, a0, a1\n"
7479 "00e69363 bne tmp, tmp2, +6\n"
7483 EXPECT_EQ(kMaxIntX - 1, Call(
test->entry(), kMaxIntX, -1));
7484 EXPECT_EQ(kMaxIntX, Call(
test->entry(), kMaxIntX, 0));
7485 EXPECT_EQ(0, Call(
test->entry(), kMaxIntX, 1));
7487 EXPECT_EQ(0, Call(
test->entry(), kMinIntX, -1));
7488 EXPECT_EQ(kMinIntX + 1, Call(
test->entry(), kMinIntX, 1));
7489 EXPECT_EQ(kMinIntX, Call(
test->entry(), kMinIntX, 0));
7493 FLAG_use_compressed_instructions =
true;
7497 __ SubtractImmediateBranchOverflow(
A0,
A0, 2, &overflow);
7505 " 872a mv tmp2, a0\n"
7506 " 1579 addi a0, a0, -2\n"
7507 "00a74363 blt tmp2, a0, +6\n"
7511 EXPECT_EQ(kMinIntX + 1, Call(
test->entry(), kMinIntX + 3));
7512 EXPECT_EQ(kMinIntX, Call(
test->entry(), kMinIntX + 2));
7513 EXPECT_EQ(0, Call(
test->entry(), kMinIntX + 1));
7514 EXPECT_EQ(0, Call(
test->entry(), kMinIntX));
7518 FLAG_use_compressed_instructions =
true;
7522 __ SubtractBranchOverflow(
A0,
A1,
A2, &overflow);
7530 "40c58533 sub a0, a1, a2\n"
7531 "00062693 slti tmp, a2, 0\n"
7532 "00a5a733 slt tmp2, a1, a0\n"
7533 "00e69363 bne tmp, tmp2, +6\n"
7537 EXPECT_EQ(kMaxIntX - 1, Call(
test->entry(), 42, kMaxIntX, 1));
7538 EXPECT_EQ(kMaxIntX, Call(
test->entry(), 42, kMaxIntX, 0));
7539 EXPECT_EQ(0, Call(
test->entry(), 42, kMaxIntX, -1));
7541 EXPECT_EQ(0, Call(
test->entry(), 42, kMinIntX, 1));
7542 EXPECT_EQ(kMinIntX + 1, Call(
test->entry(), 42, kMinIntX, -1));
7543 EXPECT_EQ(kMinIntX, Call(
test->entry(), 42, kMinIntX, 0));
7547 FLAG_use_compressed_instructions =
true;
7551 __ SubtractBranchOverflow(
A0,
A0,
A1, &overflow);
7559 "00052693 slti tmp, a0, 0\n"
7560 " 8d0d sub a0, a0, a1\n"
7561 "00b52733 slt tmp2, a0, a1\n"
7562 "00e69363 bne tmp, tmp2, +6\n"
7566 EXPECT_EQ(kMaxIntX - 1, Call(
test->entry(), kMaxIntX, 1));
7567 EXPECT_EQ(kMaxIntX, Call(
test->entry(), kMaxIntX, 0));
7568 EXPECT_EQ(0, Call(
test->entry(), kMaxIntX, -1));
7570 EXPECT_EQ(0, Call(
test->entry(), kMinIntX, 1));
7571 EXPECT_EQ(kMinIntX + 1, Call(
test->entry(), kMinIntX, -1));
7572 EXPECT_EQ(kMinIntX, Call(
test->entry(), kMinIntX, 0));
7576 FLAG_use_compressed_instructions =
true;
7580 __ MultiplyImmediateBranchOverflow(
A0,
A0, 2, &overflow);
7589 " 4709 li tmp2, 2\n"
7590 "02e516b3 mulh tmp, a0, tmp2\n"
7591 "02e50533 mul a0, a0, tmp2\n"
7592 "43f55713 srai tmp2, a0, 0x3f\n"
7593 "00e69363 bne tmp, tmp2, +6\n"
7599 " 4709 li tmp2, 2\n"
7600 "02e516b3 mulh tmp, a0, tmp2\n"
7601 "02e50533 mul a0, a0, tmp2\n"
7602 "41f55713 srai tmp2, a0, 0x1f\n"
7603 "00e69363 bne tmp, tmp2, +6\n"
7608 EXPECT_EQ(0, Call(
test->entry(), kMinIntX));
7609 EXPECT_EQ(0, Call(
test->entry(), kMaxIntX));
7610 EXPECT_EQ(-2, Call(
test->entry(), -1));
7611 EXPECT_EQ(2, Call(
test->entry(), 1));
7612 EXPECT_EQ(kMinIntX, Call(
test->entry(), kMinIntX / 2));
7613 EXPECT_EQ(kMaxIntX - 1, Call(
test->entry(), (kMaxIntX - 1) / 2));
7617 FLAG_use_compressed_instructions =
true;
7621 __ MultiplyBranchOverflow(
A0,
A1,
A2, &overflow);
7630 "02c596b3 mulh tmp, a1, a2\n"
7631 "02c58533 mul a0, a1, a2\n"
7632 "43f55713 srai tmp2, a0, 0x3f\n"
7633 "00e69363 bne tmp, tmp2, +6\n"
7635 "02a00513 li a0, 42\n"
7639 "02c596b3 mulh tmp, a1, a2\n"
7640 "02c58533 mul a0, a1, a2\n"
7641 "41f55713 srai tmp2, a0, 0x1f\n"
7642 "00e69363 bne tmp, tmp2, +6\n"
7644 "02a00513 li a0, 42\n"
7647 EXPECT_EQ(42, Call(
test->entry(), 42, kMaxIntX, -2));
7648 EXPECT_EQ(-kMaxIntX, Call(
test->entry(), 42, kMaxIntX, -1));
7649 EXPECT_EQ(0, Call(
test->entry(), 42, kMaxIntX, 0));
7650 EXPECT_EQ(kMaxIntX, Call(
test->entry(), 42, kMaxIntX, 1));
7651 EXPECT_EQ(42, Call(
test->entry(), 42, kMaxIntX, 2));
7653 EXPECT_EQ(42, Call(
test->entry(), 42, kMinIntX, -2));
7654 EXPECT_EQ(42, Call(
test->entry(), 42, kMinIntX, -1));
7655 EXPECT_EQ(0, Call(
test->entry(), 42, kMinIntX, 0));
7656 EXPECT_EQ(kMinIntX, Call(
test->entry(), 42, kMinIntX, 1));
7657 EXPECT_EQ(42, Call(
test->entry(), 42, kMinIntX, 2));
7661 FLAG_use_compressed_instructions =
true;
7665 __ MultiplyBranchOverflow(
A0,
A0,
A1, &overflow);
7674 "02b516b3 mulh tmp, a0, a1\n"
7675 "02b50533 mul a0, a0, a1\n"
7676 "43f55713 srai tmp2, a0, 0x3f\n"
7677 "00e69363 bne tmp, tmp2, +6\n"
7679 "02a00513 li a0, 42\n"
7683 "02b516b3 mulh tmp, a0, a1\n"
7684 "02b50533 mul a0, a0, a1\n"
7685 "41f55713 srai tmp2, a0, 0x1f\n"
7686 "00e69363 bne tmp, tmp2, +6\n"
7688 "02a00513 li a0, 42\n"
7691 EXPECT_EQ(42, Call(
test->entry(), kMaxIntX, -2));
7692 EXPECT_EQ(-kMaxIntX, Call(
test->entry(), kMaxIntX, -1));
7693 EXPECT_EQ(0, Call(
test->entry(), kMaxIntX, 0));
7694 EXPECT_EQ(kMaxIntX, Call(
test->entry(), kMaxIntX, 1));
7695 EXPECT_EQ(42, Call(
test->entry(), kMaxIntX, 2));
7697 EXPECT_EQ(42, Call(
test->entry(), kMinIntX, -2));
7698 EXPECT_EQ(42, Call(
test->entry(), kMinIntX, -1));
7699 EXPECT_EQ(0, Call(
test->entry(), kMinIntX, 0));
7700 EXPECT_EQ(kMinIntX, Call(
test->entry(), kMinIntX, 1));
7701 EXPECT_EQ(42, Call(
test->entry(), kMinIntX, 2));
7704#define TEST_ENCODING(type, name) \
7705 VM_UNIT_TEST_CASE(Encoding##name) { \
7706 for (intptr_t v = -(1 << 21); v <= (1 << 21); v++) { \
7707 type value = static_cast<type>(v); \
7708 if (!Is##name(value)) continue; \
7709 int32_t encoded = Encode##name(value); \
7710 type decoded = Decode##name(encoded); \
7711 EXPECT_EQ(value, decoded); \
7728TEST_ENCODING(intptr_t, BTypeImm)
7729TEST_ENCODING(intptr_t, JTypeImm)
7730TEST_ENCODING(intptr_t, ITypeImm)
7731TEST_ENCODING(intptr_t, STypeImm)
7732TEST_ENCODING(intptr_t, UTypeImm)
7746TEST_ENCODING(intptr_t, CSPLoad4Imm)
7747TEST_ENCODING(intptr_t, CSPLoad8Imm)
7748TEST_ENCODING(intptr_t, CSPStore4Imm)
7749TEST_ENCODING(intptr_t, CSPStore8Imm)
7750TEST_ENCODING(intptr_t, CMem4Imm)
7751TEST_ENCODING(intptr_t, CMem8Imm)
7752TEST_ENCODING(intptr_t, CJImm)
7753TEST_ENCODING(intptr_t, CBImm)
7754TEST_ENCODING(intptr_t, CIImm)
7755TEST_ENCODING(intptr_t, CUImm)
7756TEST_ENCODING(intptr_t, CI16Imm)
7757TEST_ENCODING(intptr_t, CI4SPNImm)
7766 __ LoadImmediate(return_reg, 0);
7769 __ LoadImmediate(return_reg, 1);
7776 RangeCheck(assembler,
value, temp);
7781 result =
test->Invoke<intptr_t, intptr_t>(kErrorCid);
7783 result =
test->Invoke<intptr_t, intptr_t>(kUnwindErrorCid);
7785 result =
test->Invoke<intptr_t, intptr_t>(kFunctionCid);
7787 result =
test->Invoke<intptr_t, intptr_t>(kMintCid);
7794 RangeCheck(assembler,
value, temp);
7799 result =
test->Invoke<intptr_t, intptr_t>(kErrorCid);
7801 result =
test->Invoke<intptr_t, intptr_t>(kUnwindErrorCid);
7803 result =
test->Invoke<intptr_t, intptr_t>(kFunctionCid);
7805 result =
test->Invoke<intptr_t, intptr_t>(kMintCid);
7817 __ MoveRegister(return_reg,
value);
7823 result =
test->Invoke<intptr_t, intptr_t>(kErrorCid);
7824 EXPECT_EQ(kErrorCid,
result);
7825 result =
test->Invoke<intptr_t, intptr_t>(kUnwindErrorCid);
7826 EXPECT_EQ(kUnwindErrorCid,
result);
7827 result =
test->Invoke<intptr_t, intptr_t>(kFunctionCid);
7828 EXPECT_EQ(kFunctionCid,
result);
7829 result =
test->Invoke<intptr_t, intptr_t>(kMintCid);
7830 EXPECT_EQ(kMintCid,
result);
7836 __ PushRegister(
THR);
7837 __ PushRegister(
PP);
7840 __ LoadPoolPointer(
PP);
7845 __ PopRegister(
THR);
7854 const auto& do_nothing_just_return =
7858 __ PushRegister(
RA);
7860 const RegisterSet clobbered_regs(
7863 __ PushRegisters(clobbered_regs);
7867 const auto check_all_allocatable_registers_are_preserved_by_call = [&]() {
7869 __ LoadImmediate(reg,
static_cast<int32_t
>(reg));
7871 __ JumpAndLink(do_nothing_just_return);
7874 if (!FLAG_precompiled_mode && reg ==
CODE_REG)
continue;
7877 __ CompareImmediate(reg,
static_cast<int32_t
>(reg));
7879 __ LoadImmediate(
A0, reg);
7885 check_all_allocatable_registers_are_preserved_by_call();
7887 FLAG_precompiled_mode =
true;
7888 check_all_allocatable_registers_are_preserved_by_call();
7889 FLAG_precompiled_mode =
false;
7891 __ LoadImmediate(
A0, 42);
7893 __ PopRegisters(clobbered_regs);
7900 const intptr_t
result =
test->InvokeWithCodeAndThread<int64_t>();
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
static bool ok(int result)
static const Code & Generate(const char *name, const std::function< void(compiler::Assembler *assembler)> &generator)
static const Register ArgumentRegisters[]
static constexpr Register kReturnReg
static intptr_t data_offset()
double CallD(intx_t function, intx_t arg0, intx_t arg1=0)
static Simulator * Current()
intx_t CallI(intx_t function, double arg0, double arg1=0.0)
float CallF(intx_t function, intx_t arg0, intx_t arg1=0)
int64_t Call(int32_t entry, int32_t parameter0, int32_t parameter1, int32_t parameter2, int32_t parameter3, bool fp_return=false, bool fp_args=false)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
void LeaveTestFrame(Assembler *assembler)
ASSEMBLER_TEST_GENERATE(InstantiateTypeArgumentsHashKeys, assembler)
void EnterTestFrame(Assembler *assembler)
constexpr int64_t kMaxInt64
static constexpr ExtensionSet RV_GCB
constexpr int64_t kMinInt64
static Utils::BitsRange< Register > RegisterRange(uint32_t regs)
static uint64_t RotateRight(uint64_t value, uint8_t rotate, uint8_t width)
static constexpr Extension RV_Zbc(9)
static constexpr ExtensionSet RV_GC
constexpr int32_t kMinInt32
void * malloc(size_t size)
static const ClassId kLastErrorCid
constexpr uint64_t kMaxUint64
constexpr uint32_t kMaxUint32
static const ClassId kFirstErrorCid
static constexpr Extension RV_Zalasr(10)
intx_t sign_extend(int32_t x)
constexpr RegList kDartAvailableCpuRegs
ASSEMBLER_TEST_RUN(StoreIntoObject, test)
constexpr int32_t kMaxInt32
static int8_t data[kExtLength]
static constexpr ExtensionSet RV_G
static constexpr Color Min(Color c, float threshold)
static bool Bind(PassBindingsCacheMTL &pass, ShaderStage stage, size_t bind_index, const BufferView &view)