Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 470533002: Add FOR_INT32_SHIFTS to value-helper.h (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/compiler/value-helper.h » ('j') | test/cctest/compiler/value-helper.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <functional> 5 #include <functional>
6 #include <limits> 6 #include <limits>
7 7
8 #include "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/codegen-tester.h" 9 #include "test/cctest/compiler/codegen-tester.h"
10 #include "test/cctest/compiler/value-helper.h" 10 #include "test/cctest/compiler/value-helper.h"
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 567
568 TEST(RunInt32AddAndWord32SarP) { 568 TEST(RunInt32AddAndWord32SarP) {
569 { 569 {
570 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 570 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
571 kMachineWord32); 571 kMachineWord32);
572 m.Return(m.Int32Add(m.Parameter(0), 572 m.Return(m.Int32Add(m.Parameter(0),
573 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 573 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
574 FOR_UINT32_INPUTS(i) { 574 FOR_UINT32_INPUTS(i) {
575 FOR_INT32_INPUTS(j) { 575 FOR_INT32_INPUTS(j) {
576 FOR_UINT32_INPUTS(k) { 576 FOR_UINT32_SHIFTS(shift) {
577 uint32_t shift = *k & 0x1F;
578 // Use uint32_t because signed overflow is UB in C. 577 // Use uint32_t because signed overflow is UB in C.
579 int32_t expected = *i + (*j >> shift); 578 int32_t expected = *i + (*j >> shift);
580 CHECK_EQ(expected, m.Call(*i, *j, shift)); 579 CHECK_EQ(expected, m.Call(*i, *j, shift));
581 } 580 }
582 } 581 }
583 } 582 }
584 } 583 }
585 { 584 {
586 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 585 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
587 kMachineWord32); 586 kMachineWord32);
588 m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 587 m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
589 m.Parameter(2))); 588 m.Parameter(2)));
590 FOR_INT32_INPUTS(i) { 589 FOR_INT32_INPUTS(i) {
591 FOR_UINT32_INPUTS(j) { 590 FOR_UINT32_SHIFTS(shift) {
592 FOR_UINT32_INPUTS(k) { 591 FOR_UINT32_INPUTS(k) {
593 uint32_t shift = *j & 0x1F;
594 // Use uint32_t because signed overflow is UB in C. 592 // Use uint32_t because signed overflow is UB in C.
595 int32_t expected = (*i >> shift) + *k; 593 int32_t expected = (*i >> shift) + *k;
596 CHECK_EQ(expected, m.Call(*i, shift, *k)); 594 CHECK_EQ(expected, m.Call(*i, shift, *k));
597 } 595 }
598 } 596 }
599 } 597 }
600 } 598 }
601 } 599 }
602 600
603 601
604 TEST(RunInt32AddAndWord32ShlP) { 602 TEST(RunInt32AddAndWord32ShlP) {
605 { 603 {
606 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 604 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
607 kMachineWord32); 605 kMachineWord32);
608 m.Return(m.Int32Add(m.Parameter(0), 606 m.Return(m.Int32Add(m.Parameter(0),
609 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 607 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
610 FOR_UINT32_INPUTS(i) { 608 FOR_UINT32_INPUTS(i) {
611 FOR_INT32_INPUTS(j) { 609 FOR_INT32_INPUTS(j) {
612 FOR_UINT32_INPUTS(k) { 610 FOR_UINT32_SHIFTS(shift) {
613 uint32_t shift = *k & 0x1F;
614 // Use uint32_t because signed overflow is UB in C. 611 // Use uint32_t because signed overflow is UB in C.
615 int32_t expected = *i + (*j << shift); 612 int32_t expected = *i + (*j << shift);
616 CHECK_EQ(expected, m.Call(*i, *j, shift)); 613 CHECK_EQ(expected, m.Call(*i, *j, shift));
617 } 614 }
618 } 615 }
619 } 616 }
620 } 617 }
621 { 618 {
622 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 619 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
623 kMachineWord32); 620 kMachineWord32);
624 m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 621 m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
625 m.Parameter(2))); 622 m.Parameter(2)));
626 FOR_INT32_INPUTS(i) { 623 FOR_INT32_INPUTS(i) {
627 FOR_UINT32_INPUTS(j) { 624 FOR_UINT32_SHIFTS(shift) {
628 FOR_UINT32_INPUTS(k) { 625 FOR_UINT32_INPUTS(k) {
629 uint32_t shift = *j & 0x1F;
630 // Use uint32_t because signed overflow is UB in C. 626 // Use uint32_t because signed overflow is UB in C.
631 int32_t expected = (*i << shift) + *k; 627 int32_t expected = (*i << shift) + *k;
632 CHECK_EQ(expected, m.Call(*i, shift, *k)); 628 CHECK_EQ(expected, m.Call(*i, shift, *k));
633 } 629 }
634 } 630 }
635 } 631 }
636 } 632 }
637 } 633 }
638 634
639 635
640 TEST(RunInt32AddAndWord32ShrP) { 636 TEST(RunInt32AddAndWord32ShrP) {
641 { 637 {
642 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 638 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
643 kMachineWord32); 639 kMachineWord32);
644 m.Return(m.Int32Add(m.Parameter(0), 640 m.Return(m.Int32Add(m.Parameter(0),
645 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 641 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
646 FOR_UINT32_INPUTS(i) { 642 FOR_UINT32_INPUTS(i) {
647 FOR_UINT32_INPUTS(j) { 643 FOR_UINT32_INPUTS(j) {
648 FOR_UINT32_INPUTS(k) { 644 FOR_UINT32_SHIFTS(shift) {
649 uint32_t shift = *k & 0x1F;
650 // Use uint32_t because signed overflow is UB in C. 645 // Use uint32_t because signed overflow is UB in C.
651 int32_t expected = *i + (*j >> shift); 646 int32_t expected = *i + (*j >> shift);
652 CHECK_EQ(expected, m.Call(*i, *j, shift)); 647 CHECK_EQ(expected, m.Call(*i, *j, shift));
653 } 648 }
654 } 649 }
655 } 650 }
656 } 651 }
657 { 652 {
658 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 653 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
659 kMachineWord32); 654 kMachineWord32);
660 m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 655 m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
661 m.Parameter(2))); 656 m.Parameter(2)));
662 FOR_UINT32_INPUTS(i) { 657 FOR_UINT32_INPUTS(i) {
663 FOR_UINT32_INPUTS(j) { 658 FOR_UINT32_SHIFTS(shift) {
664 FOR_UINT32_INPUTS(k) { 659 FOR_UINT32_INPUTS(k) {
665 uint32_t shift = *j & 0x1F;
666 // Use uint32_t because signed overflow is UB in C. 660 // Use uint32_t because signed overflow is UB in C.
667 int32_t expected = (*i >> shift) + *k; 661 int32_t expected = (*i >> shift) + *k;
668 CHECK_EQ(expected, m.Call(*i, shift, *k)); 662 CHECK_EQ(expected, m.Call(*i, shift, *k));
669 } 663 }
670 } 664 }
671 } 665 }
672 } 666 }
673 } 667 }
674 668
675 669
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 m.NewNode(shops[n], m.Parameter(1), 751 m.NewNode(shops[n], m.Parameter(1),
758 m.Parameter(2))), 752 m.Parameter(2))),
759 m.Int32Constant(0)), 753 m.Int32Constant(0)),
760 &blocka, &blockb); 754 &blocka, &blockb);
761 m.Bind(&blocka); 755 m.Bind(&blocka);
762 m.Return(m.Int32Constant(constant)); 756 m.Return(m.Int32Constant(constant));
763 m.Bind(&blockb); 757 m.Bind(&blockb);
764 m.Return(m.Int32Constant(0 - constant)); 758 m.Return(m.Int32Constant(0 - constant));
765 FOR_UINT32_INPUTS(i) { 759 FOR_UINT32_INPUTS(i) {
766 FOR_INT32_INPUTS(j) { 760 FOR_INT32_INPUTS(j) {
767 FOR_UINT32_INPUTS(k) { 761 FOR_UINT32_SHIFTS(shift) {
768 uint32_t shift = *k & 0x1F;
769 int32_t right; 762 int32_t right;
770 switch (shops[n]->opcode()) { 763 switch (shops[n]->opcode()) {
771 default: 764 default:
772 UNREACHABLE(); 765 UNREACHABLE();
773 case IrOpcode::kWord32Sar: 766 case IrOpcode::kWord32Sar:
774 right = *j >> shift; 767 right = *j >> shift;
775 break; 768 break;
776 case IrOpcode::kWord32Shl: 769 case IrOpcode::kWord32Shl:
777 right = *j << shift; 770 right = *j << shift;
778 break; 771 break;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 m.machine()->Word32Shr()}; 836 m.machine()->Word32Shr()};
844 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 837 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
845 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 838 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
846 kMachineWord32); 839 kMachineWord32);
847 m.Return(m.Word32Equal( 840 m.Return(m.Word32Equal(
848 m.Int32Add(m.Parameter(0), 841 m.Int32Add(m.Parameter(0),
849 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), 842 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))),
850 m.Int32Constant(0))); 843 m.Int32Constant(0)));
851 FOR_UINT32_INPUTS(i) { 844 FOR_UINT32_INPUTS(i) {
852 FOR_INT32_INPUTS(j) { 845 FOR_INT32_INPUTS(j) {
853 FOR_UINT32_INPUTS(k) { 846 FOR_UINT32_SHIFTS(shift) {
854 uint32_t shift = *k & 0x1F;
855 int32_t right; 847 int32_t right;
856 switch (shops[n]->opcode()) { 848 switch (shops[n]->opcode()) {
857 default: 849 default:
858 UNREACHABLE(); 850 UNREACHABLE();
859 case IrOpcode::kWord32Sar: 851 case IrOpcode::kWord32Sar:
860 right = *j >> shift; 852 right = *j >> shift;
861 break; 853 break;
862 case IrOpcode::kWord32Shl: 854 case IrOpcode::kWord32Shl:
863 right = *j << shift; 855 right = *j << shift;
864 break; 856 break;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 911
920 912
921 TEST(RunInt32SubAndWord32SarP) { 913 TEST(RunInt32SubAndWord32SarP) {
922 { 914 {
923 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 915 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
924 kMachineWord32); 916 kMachineWord32);
925 m.Return(m.Int32Sub(m.Parameter(0), 917 m.Return(m.Int32Sub(m.Parameter(0),
926 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 918 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
927 FOR_UINT32_INPUTS(i) { 919 FOR_UINT32_INPUTS(i) {
928 FOR_INT32_INPUTS(j) { 920 FOR_INT32_INPUTS(j) {
929 FOR_UINT32_INPUTS(k) { 921 FOR_UINT32_SHIFTS(shift) {
930 uint32_t shift = *k & 0x1F;
931 // Use uint32_t because signed overflow is UB in C. 922 // Use uint32_t because signed overflow is UB in C.
932 int32_t expected = *i - (*j >> shift); 923 int32_t expected = *i - (*j >> shift);
933 CHECK_EQ(expected, m.Call(*i, *j, shift)); 924 CHECK_EQ(expected, m.Call(*i, *j, shift));
934 } 925 }
935 } 926 }
936 } 927 }
937 } 928 }
938 { 929 {
939 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 930 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
940 kMachineWord32); 931 kMachineWord32);
941 m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 932 m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
942 m.Parameter(2))); 933 m.Parameter(2)));
943 FOR_INT32_INPUTS(i) { 934 FOR_INT32_INPUTS(i) {
944 FOR_UINT32_INPUTS(j) { 935 FOR_UINT32_SHIFTS(shift) {
945 FOR_UINT32_INPUTS(k) { 936 FOR_UINT32_INPUTS(k) {
946 uint32_t shift = *j & 0x1F;
947 // Use uint32_t because signed overflow is UB in C. 937 // Use uint32_t because signed overflow is UB in C.
948 int32_t expected = (*i >> shift) - *k; 938 int32_t expected = (*i >> shift) - *k;
949 CHECK_EQ(expected, m.Call(*i, shift, *k)); 939 CHECK_EQ(expected, m.Call(*i, shift, *k));
950 } 940 }
951 } 941 }
952 } 942 }
953 } 943 }
954 } 944 }
955 945
956 946
957 TEST(RunInt32SubAndWord32ShlP) { 947 TEST(RunInt32SubAndWord32ShlP) {
958 { 948 {
959 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 949 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
960 kMachineWord32); 950 kMachineWord32);
961 m.Return(m.Int32Sub(m.Parameter(0), 951 m.Return(m.Int32Sub(m.Parameter(0),
962 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 952 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
963 FOR_UINT32_INPUTS(i) { 953 FOR_UINT32_INPUTS(i) {
964 FOR_INT32_INPUTS(j) { 954 FOR_INT32_INPUTS(j) {
965 FOR_UINT32_INPUTS(k) { 955 FOR_UINT32_SHIFTS(shift) {
966 uint32_t shift = *k & 0x1F;
967 // Use uint32_t because signed overflow is UB in C. 956 // Use uint32_t because signed overflow is UB in C.
968 int32_t expected = *i - (*j << shift); 957 int32_t expected = *i - (*j << shift);
969 CHECK_EQ(expected, m.Call(*i, *j, shift)); 958 CHECK_EQ(expected, m.Call(*i, *j, shift));
970 } 959 }
971 } 960 }
972 } 961 }
973 } 962 }
974 { 963 {
975 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 964 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
976 kMachineWord32); 965 kMachineWord32);
977 m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 966 m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
978 m.Parameter(2))); 967 m.Parameter(2)));
979 FOR_INT32_INPUTS(i) { 968 FOR_INT32_INPUTS(i) {
980 FOR_UINT32_INPUTS(j) { 969 FOR_UINT32_SHIFTS(shift) {
981 FOR_UINT32_INPUTS(k) { 970 FOR_UINT32_INPUTS(k) {
982 uint32_t shift = *j & 0x1F;
983 // Use uint32_t because signed overflow is UB in C. 971 // Use uint32_t because signed overflow is UB in C.
984 int32_t expected = (*i << shift) - *k; 972 int32_t expected = (*i << shift) - *k;
985 CHECK_EQ(expected, m.Call(*i, shift, *k)); 973 CHECK_EQ(expected, m.Call(*i, shift, *k));
986 } 974 }
987 } 975 }
988 } 976 }
989 } 977 }
990 } 978 }
991 979
992 980
993 TEST(RunInt32SubAndWord32ShrP) { 981 TEST(RunInt32SubAndWord32ShrP) {
994 { 982 {
995 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 983 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
996 kMachineWord32); 984 kMachineWord32);
997 m.Return(m.Int32Sub(m.Parameter(0), 985 m.Return(m.Int32Sub(m.Parameter(0),
998 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 986 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
999 FOR_UINT32_INPUTS(i) { 987 FOR_UINT32_INPUTS(i) {
1000 FOR_UINT32_INPUTS(j) { 988 FOR_UINT32_INPUTS(j) {
1001 FOR_UINT32_INPUTS(k) { 989 FOR_UINT32_SHIFTS(shift) {
1002 uint32_t shift = *k & 0x1F;
1003 // Use uint32_t because signed overflow is UB in C. 990 // Use uint32_t because signed overflow is UB in C.
1004 int32_t expected = *i - (*j >> shift); 991 int32_t expected = *i - (*j >> shift);
1005 CHECK_EQ(expected, m.Call(*i, *j, shift)); 992 CHECK_EQ(expected, m.Call(*i, *j, shift));
1006 } 993 }
1007 } 994 }
1008 } 995 }
1009 } 996 }
1010 { 997 {
1011 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 998 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
1012 kMachineWord32); 999 kMachineWord32);
1013 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 1000 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
1014 m.Parameter(2))); 1001 m.Parameter(2)));
1015 FOR_UINT32_INPUTS(i) { 1002 FOR_UINT32_INPUTS(i) {
1016 FOR_UINT32_INPUTS(j) { 1003 FOR_UINT32_SHIFTS(shift) {
1017 FOR_UINT32_INPUTS(k) { 1004 FOR_UINT32_INPUTS(k) {
1018 uint32_t shift = *j & 0x1F;
1019 // Use uint32_t because signed overflow is UB in C. 1005 // Use uint32_t because signed overflow is UB in C.
1020 int32_t expected = (*i >> shift) - *k; 1006 int32_t expected = (*i >> shift) - *k;
1021 CHECK_EQ(expected, m.Call(*i, shift, *k)); 1007 CHECK_EQ(expected, m.Call(*i, shift, *k));
1022 } 1008 }
1023 } 1009 }
1024 } 1010 }
1025 } 1011 }
1026 } 1012 }
1027 1013
1028 1014
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 m.NewNode(shops[n], m.Parameter(1), 1096 m.NewNode(shops[n], m.Parameter(1),
1111 m.Parameter(2))), 1097 m.Parameter(2))),
1112 m.Int32Constant(0)), 1098 m.Int32Constant(0)),
1113 &blocka, &blockb); 1099 &blocka, &blockb);
1114 m.Bind(&blocka); 1100 m.Bind(&blocka);
1115 m.Return(m.Int32Constant(constant)); 1101 m.Return(m.Int32Constant(constant));
1116 m.Bind(&blockb); 1102 m.Bind(&blockb);
1117 m.Return(m.Int32Constant(0 - constant)); 1103 m.Return(m.Int32Constant(0 - constant));
1118 FOR_UINT32_INPUTS(i) { 1104 FOR_UINT32_INPUTS(i) {
1119 FOR_INT32_INPUTS(j) { 1105 FOR_INT32_INPUTS(j) {
1120 FOR_UINT32_INPUTS(k) { 1106 FOR_UINT32_SHIFTS(shift) {
1121 uint32_t shift = *k & 0x1F;
1122 int32_t right; 1107 int32_t right;
1123 switch (shops[n]->opcode()) { 1108 switch (shops[n]->opcode()) {
1124 default: 1109 default:
1125 UNREACHABLE(); 1110 UNREACHABLE();
1126 case IrOpcode::kWord32Sar: 1111 case IrOpcode::kWord32Sar:
1127 right = *j >> shift; 1112 right = *j >> shift;
1128 break; 1113 break;
1129 case IrOpcode::kWord32Shl: 1114 case IrOpcode::kWord32Shl:
1130 right = *j << shift; 1115 right = *j << shift;
1131 break; 1116 break;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 m.machine()->Word32Shr()}; 1181 m.machine()->Word32Shr()};
1197 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 1182 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
1198 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1183 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
1199 kMachineWord32); 1184 kMachineWord32);
1200 m.Return(m.Word32Equal( 1185 m.Return(m.Word32Equal(
1201 m.Int32Sub(m.Parameter(0), 1186 m.Int32Sub(m.Parameter(0),
1202 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), 1187 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))),
1203 m.Int32Constant(0))); 1188 m.Int32Constant(0)));
1204 FOR_UINT32_INPUTS(i) { 1189 FOR_UINT32_INPUTS(i) {
1205 FOR_INT32_INPUTS(j) { 1190 FOR_INT32_INPUTS(j) {
1206 FOR_UINT32_INPUTS(k) { 1191 FOR_UINT32_SHIFTS(shift) {
1207 uint32_t shift = *k & 0x1F;
1208 int32_t right; 1192 int32_t right;
1209 switch (shops[n]->opcode()) { 1193 switch (shops[n]->opcode()) {
1210 default: 1194 default:
1211 UNREACHABLE(); 1195 UNREACHABLE();
1212 case IrOpcode::kWord32Sar: 1196 case IrOpcode::kWord32Sar:
1213 right = *j >> shift; 1197 right = *j >> shift;
1214 break; 1198 break;
1215 case IrOpcode::kWord32Shl: 1199 case IrOpcode::kWord32Shl:
1216 right = *j << shift; 1200 right = *j << shift;
1217 break; 1201 break;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 m.NewNode(shops[n], m.Parameter(1), 1722 m.NewNode(shops[n], m.Parameter(1),
1739 m.Parameter(2))), 1723 m.Parameter(2))),
1740 m.Int32Constant(0)), 1724 m.Int32Constant(0)),
1741 &blocka, &blockb); 1725 &blocka, &blockb);
1742 m.Bind(&blocka); 1726 m.Bind(&blocka);
1743 m.Return(m.Int32Constant(constant)); 1727 m.Return(m.Int32Constant(constant));
1744 m.Bind(&blockb); 1728 m.Bind(&blockb);
1745 m.Return(m.Int32Constant(0 - constant)); 1729 m.Return(m.Int32Constant(0 - constant));
1746 FOR_UINT32_INPUTS(i) { 1730 FOR_UINT32_INPUTS(i) {
1747 FOR_INT32_INPUTS(j) { 1731 FOR_INT32_INPUTS(j) {
1748 FOR_UINT32_INPUTS(k) { 1732 FOR_UINT32_SHIFTS(shift) {
1749 uint32_t shift = *k & 0x1F;
1750 int32_t right; 1733 int32_t right;
1751 switch (shops[n]->opcode()) { 1734 switch (shops[n]->opcode()) {
1752 default: 1735 default:
1753 UNREACHABLE(); 1736 UNREACHABLE();
1754 case IrOpcode::kWord32Sar: 1737 case IrOpcode::kWord32Sar:
1755 right = *j >> shift; 1738 right = *j >> shift;
1756 break; 1739 break;
1757 case IrOpcode::kWord32Shl: 1740 case IrOpcode::kWord32Shl:
1758 right = *j << shift; 1741 right = *j << shift;
1759 break; 1742 break;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 m.NewNode(shops[n], m.Parameter(1), 1949 m.NewNode(shops[n], m.Parameter(1),
1967 m.Parameter(2))), 1950 m.Parameter(2))),
1968 m.Int32Constant(0)), 1951 m.Int32Constant(0)),
1969 &blocka, &blockb); 1952 &blocka, &blockb);
1970 m.Bind(&blocka); 1953 m.Bind(&blocka);
1971 m.Return(m.Int32Constant(constant)); 1954 m.Return(m.Int32Constant(constant));
1972 m.Bind(&blockb); 1955 m.Bind(&blockb);
1973 m.Return(m.Int32Constant(0 - constant)); 1956 m.Return(m.Int32Constant(0 - constant));
1974 FOR_UINT32_INPUTS(i) { 1957 FOR_UINT32_INPUTS(i) {
1975 FOR_INT32_INPUTS(j) { 1958 FOR_INT32_INPUTS(j) {
1976 FOR_UINT32_INPUTS(k) { 1959 FOR_UINT32_SHIFTS(shift) {
1977 uint32_t shift = *k & 0x1F;
1978 int32_t right; 1960 int32_t right;
1979 switch (shops[n]->opcode()) { 1961 switch (shops[n]->opcode()) {
1980 default: 1962 default:
1981 UNREACHABLE(); 1963 UNREACHABLE();
1982 case IrOpcode::kWord32Sar: 1964 case IrOpcode::kWord32Sar:
1983 right = *j >> shift; 1965 right = *j >> shift;
1984 break; 1966 break;
1985 case IrOpcode::kWord32Shl: 1967 case IrOpcode::kWord32Shl:
1986 right = *j << shift; 1968 right = *j << shift;
1987 break; 1969 break;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 m.NewNode(shops[n], m.Parameter(1), 2173 m.NewNode(shops[n], m.Parameter(1),
2192 m.Parameter(2))), 2174 m.Parameter(2))),
2193 m.Int32Constant(0)), 2175 m.Int32Constant(0)),
2194 &blocka, &blockb); 2176 &blocka, &blockb);
2195 m.Bind(&blocka); 2177 m.Bind(&blocka);
2196 m.Return(m.Int32Constant(constant)); 2178 m.Return(m.Int32Constant(constant));
2197 m.Bind(&blockb); 2179 m.Bind(&blockb);
2198 m.Return(m.Int32Constant(0 - constant)); 2180 m.Return(m.Int32Constant(0 - constant));
2199 FOR_UINT32_INPUTS(i) { 2181 FOR_UINT32_INPUTS(i) {
2200 FOR_INT32_INPUTS(j) { 2182 FOR_INT32_INPUTS(j) {
2201 FOR_UINT32_INPUTS(k) { 2183 FOR_UINT32_SHIFTS(shift) {
2202 uint32_t shift = *k & 0x1F;
2203 int32_t right; 2184 int32_t right;
2204 switch (shops[n]->opcode()) { 2185 switch (shops[n]->opcode()) {
2205 default: 2186 default:
2206 UNREACHABLE(); 2187 UNREACHABLE();
2207 case IrOpcode::kWord32Sar: 2188 case IrOpcode::kWord32Sar:
2208 right = *j >> shift; 2189 right = *j >> shift;
2209 break; 2190 break;
2210 case IrOpcode::kWord32Shl: 2191 case IrOpcode::kWord32Shl:
2211 right = *j << shift; 2192 right = *j << shift;
2212 break; 2193 break;
2213 case IrOpcode::kWord32Shr: 2194 case IrOpcode::kWord32Shr:
2214 right = static_cast<uint32_t>(*j) >> shift; 2195 right = static_cast<uint32_t>(*j) >> shift;
2215 break; 2196 break;
2216 } 2197 }
2217 int32_t expected = ((*i ^ right) == 0) ? constant : 0 - constant; 2198 int32_t expected = ((*i ^ right) == 0) ? constant : 0 - constant;
2218 CHECK_EQ(expected, m.Call(*i, *j, shift)); 2199 CHECK_EQ(expected, m.Call(*i, *j, shift));
2219 } 2200 }
2220 } 2201 }
2221 } 2202 }
2222 } 2203 }
2223 } 2204 }
2224 } 2205 }
2225 2206
2226 2207
2227 TEST(RunWord32ShlP) { 2208 TEST(RunWord32ShlP) {
2228 { 2209 {
2229 FOR_UINT32_INPUTS(i) { 2210 FOR_UINT32_SHIFTS(shift) {
2230 uint32_t shift = *i & 0x1F;
2231 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2211 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
2232 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); 2212 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)));
2233 FOR_UINT32_INPUTS(j) { 2213 FOR_UINT32_INPUTS(j) {
2234 uint32_t expected = *j << shift; 2214 uint32_t expected = *j << shift;
2235 CHECK_EQ(expected, m.Call(*j)); 2215 CHECK_EQ(expected, m.Call(*j));
2236 } 2216 }
2237 } 2217 }
2238 } 2218 }
2239 { 2219 {
2240 RawMachineAssemblerTester<int32_t> m; 2220 RawMachineAssemblerTester<int32_t> m;
2241 Int32BinopTester bt(&m); 2221 Int32BinopTester bt(&m);
2242 bt.AddReturn(m.Word32Shl(bt.param0, bt.param1)); 2222 bt.AddReturn(m.Word32Shl(bt.param0, bt.param1));
2243 FOR_UINT32_INPUTS(i) { 2223 FOR_UINT32_INPUTS(i) {
2244 FOR_UINT32_INPUTS(j) { 2224 FOR_UINT32_SHIFTS(shift) {
2245 uint32_t shift = *j & 0x1F;
2246 uint32_t expected = *i << shift; 2225 uint32_t expected = *i << shift;
2247 CHECK_EQ(expected, bt.call(*i, shift)); 2226 CHECK_EQ(expected, bt.call(*i, shift));
2248 } 2227 }
2249 } 2228 }
2250 } 2229 }
2251 } 2230 }
2252 2231
2253 2232
2254 TEST(RunWord32ShrP) { 2233 TEST(RunWord32ShrP) {
2255 { 2234 {
2256 FOR_UINT32_INPUTS(i) { 2235 FOR_UINT32_SHIFTS(shift) {
2257 uint32_t shift = *i & 0x1F;
2258 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2236 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
2259 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); 2237 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)));
2260 FOR_UINT32_INPUTS(j) { 2238 FOR_UINT32_INPUTS(j) {
2261 uint32_t expected = *j >> shift; 2239 uint32_t expected = *j >> shift;
2262 CHECK_EQ(expected, m.Call(*j)); 2240 CHECK_EQ(expected, m.Call(*j));
2263 } 2241 }
2264 } 2242 }
2265 } 2243 }
2266 { 2244 {
2267 RawMachineAssemblerTester<int32_t> m; 2245 RawMachineAssemblerTester<int32_t> m;
2268 Int32BinopTester bt(&m); 2246 Int32BinopTester bt(&m);
2269 bt.AddReturn(m.Word32Shr(bt.param0, bt.param1)); 2247 bt.AddReturn(m.Word32Shr(bt.param0, bt.param1));
2270 FOR_UINT32_INPUTS(i) { 2248 FOR_UINT32_INPUTS(i) {
2271 FOR_UINT32_INPUTS(j) { 2249 FOR_UINT32_SHIFTS(shift) {
2272 uint32_t shift = *j & 0x1F;
2273 uint32_t expected = *i >> shift; 2250 uint32_t expected = *i >> shift;
2274 CHECK_EQ(expected, bt.call(*i, shift)); 2251 CHECK_EQ(expected, bt.call(*i, shift));
2275 } 2252 }
2276 } 2253 }
2277 CHECK_EQ(0x00010000, bt.call(0x80000000, 15)); 2254 CHECK_EQ(0x00010000, bt.call(0x80000000, 15));
2278 } 2255 }
2279 } 2256 }
2280 2257
2281 2258
2282 TEST(RunWord32SarP) { 2259 TEST(RunWord32SarP) {
2283 { 2260 {
2284 FOR_INT32_INPUTS(i) { 2261 FOR_INT32_SHIFTS(shift) {
2285 int32_t shift = *i & 0x1F;
2286 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2262 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
2287 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); 2263 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)));
2288 FOR_INT32_INPUTS(j) { 2264 FOR_INT32_INPUTS(j) {
2289 int32_t expected = *j >> shift; 2265 int32_t expected = *j >> shift;
2290 CHECK_EQ(expected, m.Call(*j)); 2266 CHECK_EQ(expected, m.Call(*j));
2291 } 2267 }
2292 } 2268 }
2293 } 2269 }
2294 { 2270 {
2295 RawMachineAssemblerTester<int32_t> m; 2271 RawMachineAssemblerTester<int32_t> m;
2296 Int32BinopTester bt(&m); 2272 Int32BinopTester bt(&m);
2297 bt.AddReturn(m.Word32Sar(bt.param0, bt.param1)); 2273 bt.AddReturn(m.Word32Sar(bt.param0, bt.param1));
2298 FOR_INT32_INPUTS(i) { 2274 FOR_INT32_INPUTS(i) {
2299 FOR_INT32_INPUTS(j) { 2275 FOR_INT32_SHIFTS(shift) {
2300 int32_t shift = *j & 0x1F;
2301 int32_t expected = *i >> shift; 2276 int32_t expected = *i >> shift;
2302 CHECK_EQ(expected, bt.call(*i, shift)); 2277 CHECK_EQ(expected, bt.call(*i, shift));
2303 } 2278 }
2304 } 2279 }
2305 CHECK_EQ(0xFFFF0000, bt.call(0x80000000, 15)); 2280 CHECK_EQ(0xFFFF0000, bt.call(0x80000000, 15));
2306 } 2281 }
2307 } 2282 }
2308 2283
2309 2284
2310 TEST(RunWord32NotP) { 2285 TEST(RunWord32NotP) {
(...skipping 17 matching lines...) Expand all
2328 2303
2329 2304
2330 TEST(RunWord32EqualAndWord32SarP) { 2305 TEST(RunWord32EqualAndWord32SarP) {
2331 { 2306 {
2332 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2307 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
2333 kMachineWord32); 2308 kMachineWord32);
2334 m.Return(m.Word32Equal(m.Parameter(0), 2309 m.Return(m.Word32Equal(m.Parameter(0),
2335 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 2310 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
2336 FOR_INT32_INPUTS(i) { 2311 FOR_INT32_INPUTS(i) {
2337 FOR_INT32_INPUTS(j) { 2312 FOR_INT32_INPUTS(j) {
2338 FOR_UINT32_INPUTS(k) { 2313 FOR_UINT32_SHIFTS(shift) {
2339 uint32_t shift = *k & 0x1F;
2340 int32_t expected = (*i == (*j >> shift)); 2314 int32_t expected = (*i == (*j >> shift));
2341 CHECK_EQ(expected, m.Call(*i, *j, shift)); 2315 CHECK_EQ(expected, m.Call(*i, *j, shift));
2342 } 2316 }
2343 } 2317 }
2344 } 2318 }
2345 } 2319 }
2346 { 2320 {
2347 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2321 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
2348 kMachineWord32); 2322 kMachineWord32);
2349 m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 2323 m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
2350 m.Parameter(2))); 2324 m.Parameter(2)));
2351 FOR_INT32_INPUTS(i) { 2325 FOR_INT32_INPUTS(i) {
2352 FOR_UINT32_INPUTS(j) { 2326 FOR_UINT32_SHIFTS(shift) {
2353 FOR_INT32_INPUTS(k) { 2327 FOR_INT32_INPUTS(k) {
2354 uint32_t shift = *j & 0x1F;
2355 int32_t expected = ((*i >> shift) == *k); 2328 int32_t expected = ((*i >> shift) == *k);
2356 CHECK_EQ(expected, m.Call(*i, shift, *k)); 2329 CHECK_EQ(expected, m.Call(*i, shift, *k));
2357 } 2330 }
2358 } 2331 }
2359 } 2332 }
2360 } 2333 }
2361 } 2334 }
2362 2335
2363 2336
2364 TEST(RunWord32EqualAndWord32ShlP) { 2337 TEST(RunWord32EqualAndWord32ShlP) {
2365 { 2338 {
2366 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2339 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
2367 kMachineWord32); 2340 kMachineWord32);
2368 m.Return(m.Word32Equal(m.Parameter(0), 2341 m.Return(m.Word32Equal(m.Parameter(0),
2369 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 2342 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
2370 FOR_UINT32_INPUTS(i) { 2343 FOR_UINT32_INPUTS(i) {
2371 FOR_UINT32_INPUTS(j) { 2344 FOR_UINT32_INPUTS(j) {
2372 FOR_UINT32_INPUTS(k) { 2345 FOR_UINT32_SHIFTS(shift) {
2373 uint32_t shift = *k & 0x1F;
2374 int32_t expected = (*i == (*j << shift)); 2346 int32_t expected = (*i == (*j << shift));
2375 CHECK_EQ(expected, m.Call(*i, *j, shift)); 2347 CHECK_EQ(expected, m.Call(*i, *j, shift));
2376 } 2348 }
2377 } 2349 }
2378 } 2350 }
2379 } 2351 }
2380 { 2352 {
2381 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2353 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
2382 kMachineWord32); 2354 kMachineWord32);
2383 m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 2355 m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
2384 m.Parameter(2))); 2356 m.Parameter(2)));
2385 FOR_UINT32_INPUTS(i) { 2357 FOR_UINT32_INPUTS(i) {
2386 FOR_UINT32_INPUTS(j) { 2358 FOR_UINT32_SHIFTS(shift) {
2387 FOR_UINT32_INPUTS(k) { 2359 FOR_UINT32_INPUTS(k) {
2388 uint32_t shift = *j & 0x1F;
2389 int32_t expected = ((*i << shift) == *k); 2360 int32_t expected = ((*i << shift) == *k);
2390 CHECK_EQ(expected, m.Call(*i, shift, *k)); 2361 CHECK_EQ(expected, m.Call(*i, shift, *k));
2391 } 2362 }
2392 } 2363 }
2393 } 2364 }
2394 } 2365 }
2395 } 2366 }
2396 2367
2397 2368
2398 TEST(RunWord32EqualAndWord32ShrP) { 2369 TEST(RunWord32EqualAndWord32ShrP) {
2399 { 2370 {
2400 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2371 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
2401 kMachineWord32); 2372 kMachineWord32);
2402 m.Return(m.Word32Equal(m.Parameter(0), 2373 m.Return(m.Word32Equal(m.Parameter(0),
2403 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 2374 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
2404 FOR_UINT32_INPUTS(i) { 2375 FOR_UINT32_INPUTS(i) {
2405 FOR_UINT32_INPUTS(j) { 2376 FOR_UINT32_INPUTS(j) {
2406 FOR_UINT32_INPUTS(k) { 2377 FOR_UINT32_SHIFTS(shift) {
2407 uint32_t shift = *k & 0x1F;
2408 int32_t expected = (*i == (*j >> shift)); 2378 int32_t expected = (*i == (*j >> shift));
2409 CHECK_EQ(expected, m.Call(*i, *j, shift)); 2379 CHECK_EQ(expected, m.Call(*i, *j, shift));
2410 } 2380 }
2411 } 2381 }
2412 } 2382 }
2413 } 2383 }
2414 { 2384 {
2415 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2385 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
2416 kMachineWord32); 2386 kMachineWord32);
2417 m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 2387 m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
2418 m.Parameter(2))); 2388 m.Parameter(2)));
2419 FOR_UINT32_INPUTS(i) { 2389 FOR_UINT32_INPUTS(i) {
2420 FOR_UINT32_INPUTS(j) { 2390 FOR_UINT32_SHIFTS(shift) {
2421 FOR_UINT32_INPUTS(k) { 2391 FOR_UINT32_INPUTS(k) {
2422 uint32_t shift = *j & 0x1F;
2423 int32_t expected = ((*i >> shift) == *k); 2392 int32_t expected = ((*i >> shift) == *k);
2424 CHECK_EQ(expected, m.Call(*i, shift, *k)); 2393 CHECK_EQ(expected, m.Call(*i, shift, *k));
2425 } 2394 }
2426 } 2395 }
2427 } 2396 }
2428 } 2397 }
2429 } 2398 }
2430 2399
2431 2400
2432 TEST(RunDeadNodes) { 2401 TEST(RunDeadNodes) {
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 FOR_UINT32_INPUTS(i) { 4037 FOR_UINT32_INPUTS(i) {
4069 FOR_UINT32_INPUTS(j) { 4038 FOR_UINT32_INPUTS(j) {
4070 int32_t expected; 4039 int32_t expected;
4071 if (ssub_overflow(*i, *j, &expected)) expected = constant; 4040 if (ssub_overflow(*i, *j, &expected)) expected = constant;
4072 CHECK_EQ(expected, bt.call(*i, *j)); 4041 CHECK_EQ(expected, bt.call(*i, *j));
4073 } 4042 }
4074 } 4043 }
4075 } 4044 }
4076 4045
4077 #endif // V8_TURBOFAN_TARGET 4046 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « no previous file | test/cctest/compiler/value-helper.h » ('j') | test/cctest/compiler/value-helper.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698