OLD | NEW |
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 <cmath> | 5 #include <cmath> |
6 #include <functional> | 6 #include <functional> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
11 #include "test/cctest/cctest.h" | 11 #include "test/cctest/cctest.h" |
12 #include "test/cctest/compiler/codegen-tester.h" | 12 #include "test/cctest/compiler/codegen-tester.h" |
13 #include "test/cctest/compiler/value-helper.h" | 13 #include "test/cctest/compiler/value-helper.h" |
14 | 14 |
15 #if V8_TURBOFAN_TARGET | 15 #if V8_TURBOFAN_TARGET |
16 | 16 |
17 using namespace v8::base; | 17 using namespace v8::base; |
18 | |
19 #define CHECK_UINT32_EQ(x, y) \ | |
20 CHECK_EQ(static_cast<int32_t>(x), static_cast<int32_t>(y)) | |
21 | |
22 using namespace v8::internal; | 18 using namespace v8::internal; |
23 using namespace v8::internal::compiler; | 19 using namespace v8::internal::compiler; |
24 | 20 |
25 typedef RawMachineAssembler::Label MLabel; | 21 typedef RawMachineAssembler::Label MLabel; |
26 | 22 |
27 TEST(RunInt32Add) { | 23 TEST(RunInt32Add) { |
28 RawMachineAssemblerTester<int32_t> m; | 24 RawMachineAssemblerTester<int32_t> m; |
29 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); | 25 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); |
30 m.Return(add); | 26 m.Return(add); |
31 CHECK_EQ(1, m.Call()); | 27 CHECK_EQ(1, m.Call()); |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 // generate load [#base + #index] | 494 // generate load [#base + #index] |
499 Node* load = | 495 Node* load = |
500 m.Load(kMachFloat64, m.PointerConstant(from), m.Int32Constant(offset)); | 496 m.Load(kMachFloat64, m.PointerConstant(from), m.Int32Constant(offset)); |
501 m.Store(kMachFloat64, m.PointerConstant(to), m.Int32Constant(offset), load); | 497 m.Store(kMachFloat64, m.PointerConstant(to), m.Int32Constant(offset), load); |
502 m.Return(m.Int32Constant(magic)); | 498 m.Return(m.Int32Constant(magic)); |
503 | 499 |
504 FOR_FLOAT64_INPUTS(j) { | 500 FOR_FLOAT64_INPUTS(j) { |
505 p1 = *j; | 501 p1 = *j; |
506 p2 = *j - 5; | 502 p2 = *j - 5; |
507 CHECK_EQ(magic, m.Call()); | 503 CHECK_EQ(magic, m.Call()); |
508 CHECK_EQ(p1, p2); | 504 CheckDoubleEq(p1, p2); |
509 } | 505 } |
510 } | 506 } |
511 } | 507 } |
512 | 508 |
513 | 509 |
514 TEST(RunInt32AddP) { | 510 TEST(RunInt32AddP) { |
515 RawMachineAssemblerTester<int32_t> m; | 511 RawMachineAssemblerTester<int32_t> m; |
516 Int32BinopTester bt(&m); | 512 Int32BinopTester bt(&m); |
517 | 513 |
518 bt.AddReturn(m.Int32Add(bt.param0, bt.param1)); | 514 bt.AddReturn(m.Int32Add(bt.param0, bt.param1)); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 } | 752 } |
757 } | 753 } |
758 } | 754 } |
759 } | 755 } |
760 | 756 |
761 | 757 |
762 TEST(RunInt32AddInBranch) { | 758 TEST(RunInt32AddInBranch) { |
763 static const int32_t constant = 987654321; | 759 static const int32_t constant = 987654321; |
764 { | 760 { |
765 RawMachineAssemblerTester<int32_t> m; | 761 RawMachineAssemblerTester<int32_t> m; |
766 Uint32BinopTester bt(&m); | 762 Int32BinopTester bt(&m); |
767 MLabel blocka, blockb; | 763 MLabel blocka, blockb; |
768 m.Branch( | 764 m.Branch( |
769 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), | 765 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), |
770 &blocka, &blockb); | 766 &blocka, &blockb); |
771 m.Bind(&blocka); | 767 m.Bind(&blocka); |
772 bt.AddReturn(m.Int32Constant(constant)); | 768 bt.AddReturn(m.Int32Constant(constant)); |
773 m.Bind(&blockb); | 769 m.Bind(&blockb); |
774 bt.AddReturn(m.Int32Constant(0 - constant)); | 770 bt.AddReturn(m.Int32Constant(0 - constant)); |
775 FOR_UINT32_INPUTS(i) { | 771 FOR_UINT32_INPUTS(i) { |
776 FOR_UINT32_INPUTS(j) { | 772 FOR_UINT32_INPUTS(j) { |
777 int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; | 773 int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; |
778 CHECK_EQ(expected, bt.call(*i, *j)); | 774 CHECK_EQ(expected, bt.call(*i, *j)); |
779 } | 775 } |
780 } | 776 } |
781 } | 777 } |
782 { | 778 { |
783 RawMachineAssemblerTester<int32_t> m; | 779 RawMachineAssemblerTester<int32_t> m; |
784 Uint32BinopTester bt(&m); | 780 Int32BinopTester bt(&m); |
785 MLabel blocka, blockb; | 781 MLabel blocka, blockb; |
786 m.Branch( | 782 m.Branch( |
787 m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), | 783 m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), |
788 &blocka, &blockb); | 784 &blocka, &blockb); |
789 m.Bind(&blocka); | 785 m.Bind(&blocka); |
790 bt.AddReturn(m.Int32Constant(constant)); | 786 bt.AddReturn(m.Int32Constant(constant)); |
791 m.Bind(&blockb); | 787 m.Bind(&blockb); |
792 bt.AddReturn(m.Int32Constant(0 - constant)); | 788 bt.AddReturn(m.Int32Constant(0 - constant)); |
793 FOR_UINT32_INPUTS(i) { | 789 FOR_UINT32_INPUTS(i) { |
794 FOR_UINT32_INPUTS(j) { | 790 FOR_UINT32_INPUTS(j) { |
795 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; | 791 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; |
796 CHECK_EQ(expected, bt.call(*i, *j)); | 792 CHECK_EQ(expected, bt.call(*i, *j)); |
797 } | 793 } |
798 } | 794 } |
799 } | 795 } |
800 { | 796 { |
801 FOR_UINT32_INPUTS(i) { | 797 FOR_UINT32_INPUTS(i) { |
802 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 798 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
803 MLabel blocka, blockb; | 799 MLabel blocka, blockb; |
804 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), | 800 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), |
805 m.Int32Constant(0)), | 801 m.Int32Constant(0)), |
806 &blocka, &blockb); | 802 &blocka, &blockb); |
807 m.Bind(&blocka); | 803 m.Bind(&blocka); |
808 m.Return(m.Int32Constant(constant)); | 804 m.Return(m.Int32Constant(constant)); |
809 m.Bind(&blockb); | 805 m.Bind(&blockb); |
810 m.Return(m.Int32Constant(0 - constant)); | 806 m.Return(m.Int32Constant(0 - constant)); |
811 FOR_UINT32_INPUTS(j) { | 807 FOR_UINT32_INPUTS(j) { |
812 uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant; | 808 uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant; |
813 CHECK_UINT32_EQ(expected, m.Call(*j)); | 809 CHECK_EQ(expected, m.Call(*j)); |
814 } | 810 } |
815 } | 811 } |
816 } | 812 } |
817 { | 813 { |
818 FOR_UINT32_INPUTS(i) { | 814 FOR_UINT32_INPUTS(i) { |
819 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 815 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
820 MLabel blocka, blockb; | 816 MLabel blocka, blockb; |
821 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), | 817 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), |
822 m.Int32Constant(0)), | 818 m.Int32Constant(0)), |
823 &blocka, &blockb); | 819 &blocka, &blockb); |
824 m.Bind(&blocka); | 820 m.Bind(&blocka); |
825 m.Return(m.Int32Constant(constant)); | 821 m.Return(m.Int32Constant(constant)); |
826 m.Bind(&blockb); | 822 m.Bind(&blockb); |
827 m.Return(m.Int32Constant(0 - constant)); | 823 m.Return(m.Int32Constant(0 - constant)); |
828 FOR_UINT32_INPUTS(j) { | 824 FOR_UINT32_INPUTS(j) { |
829 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; | 825 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; |
830 CHECK_UINT32_EQ(expected, m.Call(*j)); | 826 CHECK_EQ(expected, m.Call(*j)); |
831 } | 827 } |
832 } | 828 } |
833 } | 829 } |
834 { | 830 { |
835 RawMachineAssemblerTester<void> m; | 831 RawMachineAssemblerTester<void> m; |
836 const Operator* shops[] = {m.machine()->Word32Sar(), | 832 const Operator* shops[] = {m.machine()->Word32Sar(), |
837 m.machine()->Word32Shl(), | 833 m.machine()->Word32Shl(), |
838 m.machine()->Word32Shr()}; | 834 m.machine()->Word32Shr()}; |
839 for (size_t n = 0; n < arraysize(shops); n++) { | 835 for (size_t n = 0; n < arraysize(shops); n++) { |
840 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 836 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 | 874 |
879 TEST(RunInt32AddInComparison) { | 875 TEST(RunInt32AddInComparison) { |
880 { | 876 { |
881 RawMachineAssemblerTester<int32_t> m; | 877 RawMachineAssemblerTester<int32_t> m; |
882 Uint32BinopTester bt(&m); | 878 Uint32BinopTester bt(&m); |
883 bt.AddReturn( | 879 bt.AddReturn( |
884 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0))); | 880 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0))); |
885 FOR_UINT32_INPUTS(i) { | 881 FOR_UINT32_INPUTS(i) { |
886 FOR_UINT32_INPUTS(j) { | 882 FOR_UINT32_INPUTS(j) { |
887 uint32_t expected = (*i + *j) == 0; | 883 uint32_t expected = (*i + *j) == 0; |
888 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 884 CHECK_EQ(expected, bt.call(*i, *j)); |
889 } | 885 } |
890 } | 886 } |
891 } | 887 } |
892 { | 888 { |
893 RawMachineAssemblerTester<int32_t> m; | 889 RawMachineAssemblerTester<int32_t> m; |
894 Uint32BinopTester bt(&m); | 890 Uint32BinopTester bt(&m); |
895 bt.AddReturn( | 891 bt.AddReturn( |
896 m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1))); | 892 m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1))); |
897 FOR_UINT32_INPUTS(i) { | 893 FOR_UINT32_INPUTS(i) { |
898 FOR_UINT32_INPUTS(j) { | 894 FOR_UINT32_INPUTS(j) { |
899 uint32_t expected = (*i + *j) == 0; | 895 uint32_t expected = (*i + *j) == 0; |
900 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 896 CHECK_EQ(expected, bt.call(*i, *j)); |
901 } | 897 } |
902 } | 898 } |
903 } | 899 } |
904 { | 900 { |
905 FOR_UINT32_INPUTS(i) { | 901 FOR_UINT32_INPUTS(i) { |
906 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 902 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
907 m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), | 903 m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), |
908 m.Int32Constant(0))); | 904 m.Int32Constant(0))); |
909 FOR_UINT32_INPUTS(j) { | 905 FOR_UINT32_INPUTS(j) { |
910 uint32_t expected = (*i + *j) == 0; | 906 uint32_t expected = (*i + *j) == 0; |
911 CHECK_UINT32_EQ(expected, m.Call(*j)); | 907 CHECK_EQ(expected, m.Call(*j)); |
912 } | 908 } |
913 } | 909 } |
914 } | 910 } |
915 { | 911 { |
916 FOR_UINT32_INPUTS(i) { | 912 FOR_UINT32_INPUTS(i) { |
917 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 913 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
918 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), | 914 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), |
919 m.Int32Constant(0))); | 915 m.Int32Constant(0))); |
920 FOR_UINT32_INPUTS(j) { | 916 FOR_UINT32_INPUTS(j) { |
921 uint32_t expected = (*j + *i) == 0; | 917 uint32_t expected = (*j + *i) == 0; |
922 CHECK_UINT32_EQ(expected, m.Call(*j)); | 918 CHECK_EQ(expected, m.Call(*j)); |
923 } | 919 } |
924 } | 920 } |
925 } | 921 } |
926 { | 922 { |
927 RawMachineAssemblerTester<void> m; | 923 RawMachineAssemblerTester<void> m; |
928 const Operator* shops[] = {m.machine()->Word32Sar(), | 924 const Operator* shops[] = {m.machine()->Word32Sar(), |
929 m.machine()->Word32Shl(), | 925 m.machine()->Word32Shl(), |
930 m.machine()->Word32Shr()}; | 926 m.machine()->Word32Shr()}; |
931 for (size_t n = 0; n < arraysize(shops); n++) { | 927 for (size_t n = 0; n < arraysize(shops); n++) { |
932 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 928 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 | 960 |
965 TEST(RunInt32SubP) { | 961 TEST(RunInt32SubP) { |
966 RawMachineAssemblerTester<int32_t> m; | 962 RawMachineAssemblerTester<int32_t> m; |
967 Uint32BinopTester bt(&m); | 963 Uint32BinopTester bt(&m); |
968 | 964 |
969 m.Return(m.Int32Sub(bt.param0, bt.param1)); | 965 m.Return(m.Int32Sub(bt.param0, bt.param1)); |
970 | 966 |
971 FOR_UINT32_INPUTS(i) { | 967 FOR_UINT32_INPUTS(i) { |
972 FOR_UINT32_INPUTS(j) { | 968 FOR_UINT32_INPUTS(j) { |
973 uint32_t expected = static_cast<int32_t>(*i - *j); | 969 uint32_t expected = static_cast<int32_t>(*i - *j); |
974 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 970 CHECK_EQ(expected, bt.call(*i, *j)); |
975 } | 971 } |
976 } | 972 } |
977 } | 973 } |
978 | 974 |
979 | 975 |
980 TEST(RunInt32SubImm) { | 976 TEST(RunInt32SubImm) { |
981 { | 977 { |
982 FOR_UINT32_INPUTS(i) { | 978 FOR_UINT32_INPUTS(i) { |
983 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 979 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
984 m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0))); | 980 m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0))); |
985 FOR_UINT32_INPUTS(j) { | 981 FOR_UINT32_INPUTS(j) { |
986 uint32_t expected = *i - *j; | 982 uint32_t expected = *i - *j; |
987 CHECK_UINT32_EQ(expected, m.Call(*j)); | 983 CHECK_EQ(expected, m.Call(*j)); |
988 } | 984 } |
989 } | 985 } |
990 } | 986 } |
991 { | 987 { |
992 FOR_UINT32_INPUTS(i) { | 988 FOR_UINT32_INPUTS(i) { |
993 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 989 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
994 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i))); | 990 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i))); |
995 FOR_UINT32_INPUTS(j) { | 991 FOR_UINT32_INPUTS(j) { |
996 uint32_t expected = *j - *i; | 992 uint32_t expected = *j - *i; |
997 CHECK_UINT32_EQ(expected, m.Call(*j)); | 993 CHECK_EQ(expected, m.Call(*j)); |
998 } | 994 } |
999 } | 995 } |
1000 } | 996 } |
1001 } | 997 } |
1002 | 998 |
1003 | 999 |
1004 TEST(RunInt32SubAndWord32SarP) { | 1000 TEST(RunInt32SubAndWord32SarP) { |
1005 { | 1001 { |
1006 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); | 1002 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); |
1007 m.Return(m.Int32Sub(m.Parameter(0), | 1003 m.Return(m.Int32Sub(m.Parameter(0), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 TEST(RunInt32SubAndWord32ShrP) { | 1061 TEST(RunInt32SubAndWord32ShrP) { |
1066 { | 1062 { |
1067 RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, | 1063 RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, |
1068 kMachUint32); | 1064 kMachUint32); |
1069 m.Return(m.Int32Sub(m.Parameter(0), | 1065 m.Return(m.Int32Sub(m.Parameter(0), |
1070 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); | 1066 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); |
1071 FOR_UINT32_INPUTS(i) { | 1067 FOR_UINT32_INPUTS(i) { |
1072 FOR_UINT32_INPUTS(j) { | 1068 FOR_UINT32_INPUTS(j) { |
1073 FOR_UINT32_SHIFTS(shift) { | 1069 FOR_UINT32_SHIFTS(shift) { |
1074 // Use uint32_t because signed overflow is UB in C. | 1070 // Use uint32_t because signed overflow is UB in C. |
1075 int32_t expected = *i - (*j >> shift); | 1071 uint32_t expected = *i - (*j >> shift); |
1076 CHECK_UINT32_EQ(expected, m.Call(*i, *j, shift)); | 1072 CHECK_EQ(expected, m.Call(*i, *j, shift)); |
1077 } | 1073 } |
1078 } | 1074 } |
1079 } | 1075 } |
1080 } | 1076 } |
1081 { | 1077 { |
1082 RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, | 1078 RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, |
1083 kMachUint32); | 1079 kMachUint32); |
1084 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), | 1080 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), |
1085 m.Parameter(2))); | 1081 m.Parameter(2))); |
1086 FOR_UINT32_INPUTS(i) { | 1082 FOR_UINT32_INPUTS(i) { |
1087 FOR_UINT32_SHIFTS(shift) { | 1083 FOR_UINT32_SHIFTS(shift) { |
1088 FOR_UINT32_INPUTS(k) { | 1084 FOR_UINT32_INPUTS(k) { |
1089 // Use uint32_t because signed overflow is UB in C. | 1085 // Use uint32_t because signed overflow is UB in C. |
1090 int32_t expected = (*i >> shift) - *k; | 1086 uint32_t expected = (*i >> shift) - *k; |
1091 CHECK_EQ(expected, m.Call(*i, shift, *k)); | 1087 CHECK_EQ(expected, m.Call(*i, shift, *k)); |
1092 } | 1088 } |
1093 } | 1089 } |
1094 } | 1090 } |
1095 } | 1091 } |
1096 } | 1092 } |
1097 | 1093 |
1098 | 1094 |
1099 TEST(RunInt32SubInBranch) { | 1095 TEST(RunInt32SubInBranch) { |
1100 static const int constant = 987654321; | 1096 static const int constant = 987654321; |
1101 { | 1097 { |
1102 RawMachineAssemblerTester<int32_t> m; | 1098 RawMachineAssemblerTester<int32_t> m; |
1103 Uint32BinopTester bt(&m); | 1099 Int32BinopTester bt(&m); |
1104 MLabel blocka, blockb; | 1100 MLabel blocka, blockb; |
1105 m.Branch( | 1101 m.Branch( |
1106 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), | 1102 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), |
1107 &blocka, &blockb); | 1103 &blocka, &blockb); |
1108 m.Bind(&blocka); | 1104 m.Bind(&blocka); |
1109 bt.AddReturn(m.Int32Constant(constant)); | 1105 bt.AddReturn(m.Int32Constant(constant)); |
1110 m.Bind(&blockb); | 1106 m.Bind(&blockb); |
1111 bt.AddReturn(m.Int32Constant(0 - constant)); | 1107 bt.AddReturn(m.Int32Constant(0 - constant)); |
1112 FOR_UINT32_INPUTS(i) { | 1108 FOR_UINT32_INPUTS(i) { |
1113 FOR_UINT32_INPUTS(j) { | 1109 FOR_UINT32_INPUTS(j) { |
1114 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; | 1110 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; |
1115 CHECK_EQ(expected, bt.call(*i, *j)); | 1111 CHECK_EQ(expected, bt.call(*i, *j)); |
1116 } | 1112 } |
1117 } | 1113 } |
1118 } | 1114 } |
1119 { | 1115 { |
1120 RawMachineAssemblerTester<int32_t> m; | 1116 RawMachineAssemblerTester<int32_t> m; |
1121 Uint32BinopTester bt(&m); | 1117 Int32BinopTester bt(&m); |
1122 MLabel blocka, blockb; | 1118 MLabel blocka, blockb; |
1123 m.Branch( | 1119 m.Branch( |
1124 m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), | 1120 m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), |
1125 &blocka, &blockb); | 1121 &blocka, &blockb); |
1126 m.Bind(&blocka); | 1122 m.Bind(&blocka); |
1127 bt.AddReturn(m.Int32Constant(constant)); | 1123 bt.AddReturn(m.Int32Constant(constant)); |
1128 m.Bind(&blockb); | 1124 m.Bind(&blockb); |
1129 bt.AddReturn(m.Int32Constant(0 - constant)); | 1125 bt.AddReturn(m.Int32Constant(0 - constant)); |
1130 FOR_UINT32_INPUTS(i) { | 1126 FOR_UINT32_INPUTS(i) { |
1131 FOR_UINT32_INPUTS(j) { | 1127 FOR_UINT32_INPUTS(j) { |
1132 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; | 1128 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; |
1133 CHECK_EQ(expected, bt.call(*i, *j)); | 1129 CHECK_EQ(expected, bt.call(*i, *j)); |
1134 } | 1130 } |
1135 } | 1131 } |
1136 } | 1132 } |
1137 { | 1133 { |
1138 FOR_UINT32_INPUTS(i) { | 1134 FOR_UINT32_INPUTS(i) { |
1139 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1135 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1140 MLabel blocka, blockb; | 1136 MLabel blocka, blockb; |
1141 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), | 1137 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), |
1142 m.Int32Constant(0)), | 1138 m.Int32Constant(0)), |
1143 &blocka, &blockb); | 1139 &blocka, &blockb); |
1144 m.Bind(&blocka); | 1140 m.Bind(&blocka); |
1145 m.Return(m.Int32Constant(constant)); | 1141 m.Return(m.Int32Constant(constant)); |
1146 m.Bind(&blockb); | 1142 m.Bind(&blockb); |
1147 m.Return(m.Int32Constant(0 - constant)); | 1143 m.Return(m.Int32Constant(0 - constant)); |
1148 FOR_UINT32_INPUTS(j) { | 1144 FOR_UINT32_INPUTS(j) { |
1149 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; | 1145 uint32_t expected = (*i - *j) == 0 ? constant : 0 - constant; |
1150 CHECK_EQ(expected, m.Call(*j)); | 1146 CHECK_EQ(expected, m.Call(*j)); |
1151 } | 1147 } |
1152 } | 1148 } |
1153 } | 1149 } |
1154 { | 1150 { |
1155 FOR_UINT32_INPUTS(i) { | 1151 FOR_UINT32_INPUTS(i) { |
1156 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 1152 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
1157 MLabel blocka, blockb; | 1153 MLabel blocka, blockb; |
1158 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), | 1154 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), |
1159 m.Int32Constant(0)), | 1155 m.Int32Constant(0)), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 | 1211 |
1216 TEST(RunInt32SubInComparison) { | 1212 TEST(RunInt32SubInComparison) { |
1217 { | 1213 { |
1218 RawMachineAssemblerTester<int32_t> m; | 1214 RawMachineAssemblerTester<int32_t> m; |
1219 Uint32BinopTester bt(&m); | 1215 Uint32BinopTester bt(&m); |
1220 bt.AddReturn( | 1216 bt.AddReturn( |
1221 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0))); | 1217 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0))); |
1222 FOR_UINT32_INPUTS(i) { | 1218 FOR_UINT32_INPUTS(i) { |
1223 FOR_UINT32_INPUTS(j) { | 1219 FOR_UINT32_INPUTS(j) { |
1224 uint32_t expected = (*i - *j) == 0; | 1220 uint32_t expected = (*i - *j) == 0; |
1225 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1221 CHECK_EQ(expected, bt.call(*i, *j)); |
1226 } | 1222 } |
1227 } | 1223 } |
1228 } | 1224 } |
1229 { | 1225 { |
1230 RawMachineAssemblerTester<int32_t> m; | 1226 RawMachineAssemblerTester<int32_t> m; |
1231 Uint32BinopTester bt(&m); | 1227 Uint32BinopTester bt(&m); |
1232 bt.AddReturn( | 1228 bt.AddReturn( |
1233 m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1))); | 1229 m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1))); |
1234 FOR_UINT32_INPUTS(i) { | 1230 FOR_UINT32_INPUTS(i) { |
1235 FOR_UINT32_INPUTS(j) { | 1231 FOR_UINT32_INPUTS(j) { |
1236 uint32_t expected = (*i - *j) == 0; | 1232 uint32_t expected = (*i - *j) == 0; |
1237 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1233 CHECK_EQ(expected, bt.call(*i, *j)); |
1238 } | 1234 } |
1239 } | 1235 } |
1240 } | 1236 } |
1241 { | 1237 { |
1242 FOR_UINT32_INPUTS(i) { | 1238 FOR_UINT32_INPUTS(i) { |
1243 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1239 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1244 m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), | 1240 m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), |
1245 m.Int32Constant(0))); | 1241 m.Int32Constant(0))); |
1246 FOR_UINT32_INPUTS(j) { | 1242 FOR_UINT32_INPUTS(j) { |
1247 uint32_t expected = (*i - *j) == 0; | 1243 uint32_t expected = (*i - *j) == 0; |
1248 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1244 CHECK_EQ(expected, m.Call(*j)); |
1249 } | 1245 } |
1250 } | 1246 } |
1251 } | 1247 } |
1252 { | 1248 { |
1253 FOR_UINT32_INPUTS(i) { | 1249 FOR_UINT32_INPUTS(i) { |
1254 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1250 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1255 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), | 1251 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), |
1256 m.Int32Constant(0))); | 1252 m.Int32Constant(0))); |
1257 FOR_UINT32_INPUTS(j) { | 1253 FOR_UINT32_INPUTS(j) { |
1258 uint32_t expected = (*j - *i) == 0; | 1254 uint32_t expected = (*j - *i) == 0; |
1259 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1255 CHECK_EQ(expected, m.Call(*j)); |
1260 } | 1256 } |
1261 } | 1257 } |
1262 } | 1258 } |
1263 { | 1259 { |
1264 RawMachineAssemblerTester<void> m; | 1260 RawMachineAssemblerTester<void> m; |
1265 const Operator* shops[] = {m.machine()->Word32Sar(), | 1261 const Operator* shops[] = {m.machine()->Word32Sar(), |
1266 m.machine()->Word32Shl(), | 1262 m.machine()->Word32Shl(), |
1267 m.machine()->Word32Shr()}; | 1263 m.machine()->Word32Shr()}; |
1268 for (size_t n = 0; n < arraysize(shops); n++) { | 1264 for (size_t n = 0; n < arraysize(shops); n++) { |
1269 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1265 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 } | 1307 } |
1312 } | 1308 } |
1313 } | 1309 } |
1314 { | 1310 { |
1315 RawMachineAssemblerTester<int32_t> m; | 1311 RawMachineAssemblerTester<int32_t> m; |
1316 Uint32BinopTester bt(&m); | 1312 Uint32BinopTester bt(&m); |
1317 bt.AddReturn(m.Int32Mul(bt.param0, bt.param1)); | 1313 bt.AddReturn(m.Int32Mul(bt.param0, bt.param1)); |
1318 FOR_UINT32_INPUTS(i) { | 1314 FOR_UINT32_INPUTS(i) { |
1319 FOR_UINT32_INPUTS(j) { | 1315 FOR_UINT32_INPUTS(j) { |
1320 uint32_t expected = *i * *j; | 1316 uint32_t expected = *i * *j; |
1321 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1317 CHECK_EQ(expected, bt.call(*i, *j)); |
1322 } | 1318 } |
1323 } | 1319 } |
1324 } | 1320 } |
1325 } | 1321 } |
1326 | 1322 |
1327 | 1323 |
1328 TEST(RunInt32MulHighP) { | 1324 TEST(RunInt32MulHighP) { |
1329 RawMachineAssemblerTester<int32_t> m; | 1325 RawMachineAssemblerTester<int32_t> m; |
1330 Int32BinopTester bt(&m); | 1326 Int32BinopTester bt(&m); |
1331 bt.AddReturn(m.Int32MulHigh(bt.param0, bt.param1)); | 1327 bt.AddReturn(m.Int32MulHigh(bt.param0, bt.param1)); |
1332 FOR_INT32_INPUTS(i) { | 1328 FOR_INT32_INPUTS(i) { |
1333 FOR_INT32_INPUTS(j) { | 1329 FOR_INT32_INPUTS(j) { |
1334 int32_t expected = static_cast<int32_t>( | 1330 int32_t expected = static_cast<int32_t>( |
1335 (static_cast<int64_t>(*i) * static_cast<int64_t>(*j)) >> 32); | 1331 (static_cast<int64_t>(*i) * static_cast<int64_t>(*j)) >> 32); |
1336 CHECK_EQ(expected, bt.call(*i, *j)); | 1332 CHECK_EQ(expected, bt.call(*i, *j)); |
1337 } | 1333 } |
1338 } | 1334 } |
1339 } | 1335 } |
1340 | 1336 |
1341 | 1337 |
1342 TEST(RunInt32MulImm) { | 1338 TEST(RunInt32MulImm) { |
1343 { | 1339 { |
1344 FOR_UINT32_INPUTS(i) { | 1340 FOR_UINT32_INPUTS(i) { |
1345 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1341 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1346 m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0))); | 1342 m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0))); |
1347 FOR_UINT32_INPUTS(j) { | 1343 FOR_UINT32_INPUTS(j) { |
1348 uint32_t expected = *i * *j; | 1344 uint32_t expected = *i * *j; |
1349 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1345 CHECK_EQ(expected, m.Call(*j)); |
1350 } | 1346 } |
1351 } | 1347 } |
1352 } | 1348 } |
1353 { | 1349 { |
1354 FOR_UINT32_INPUTS(i) { | 1350 FOR_UINT32_INPUTS(i) { |
1355 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1351 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1356 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i))); | 1352 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i))); |
1357 FOR_UINT32_INPUTS(j) { | 1353 FOR_UINT32_INPUTS(j) { |
1358 uint32_t expected = *j * *i; | 1354 uint32_t expected = *j * *i; |
1359 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1355 CHECK_EQ(expected, m.Call(*j)); |
1360 } | 1356 } |
1361 } | 1357 } |
1362 } | 1358 } |
1363 } | 1359 } |
1364 | 1360 |
1365 | 1361 |
1366 TEST(RunInt32MulAndInt32AddP) { | 1362 TEST(RunInt32MulAndInt32AddP) { |
1367 { | 1363 { |
1368 FOR_INT32_INPUTS(i) { | 1364 FOR_INT32_INPUTS(i) { |
1369 FOR_INT32_INPUTS(j) { | 1365 FOR_INT32_INPUTS(j) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 TEST(RunUint32DivP) { | 1516 TEST(RunUint32DivP) { |
1521 { | 1517 { |
1522 RawMachineAssemblerTester<int32_t> m; | 1518 RawMachineAssemblerTester<int32_t> m; |
1523 Int32BinopTester bt(&m); | 1519 Int32BinopTester bt(&m); |
1524 bt.AddReturn(m.Uint32Div(bt.param0, bt.param1)); | 1520 bt.AddReturn(m.Uint32Div(bt.param0, bt.param1)); |
1525 FOR_UINT32_INPUTS(i) { | 1521 FOR_UINT32_INPUTS(i) { |
1526 FOR_UINT32_INPUTS(j) { | 1522 FOR_UINT32_INPUTS(j) { |
1527 uint32_t p0 = *i; | 1523 uint32_t p0 = *i; |
1528 uint32_t p1 = *j; | 1524 uint32_t p1 = *j; |
1529 if (p1 != 0) { | 1525 if (p1 != 0) { |
1530 uint32_t expected = static_cast<uint32_t>(p0 / p1); | 1526 int32_t expected = bit_cast<int32_t>(p0 / p1); |
1531 CHECK_EQ(expected, bt.call(p0, p1)); | 1527 CHECK_EQ(expected, bt.call(p0, p1)); |
1532 } | 1528 } |
1533 } | 1529 } |
1534 } | 1530 } |
1535 } | 1531 } |
1536 { | 1532 { |
1537 RawMachineAssemblerTester<int32_t> m; | 1533 RawMachineAssemblerTester<int32_t> m; |
1538 Int32BinopTester bt(&m); | 1534 Int32BinopTester bt(&m); |
1539 bt.AddReturn(m.Int32Add(bt.param0, m.Uint32Div(bt.param0, bt.param1))); | 1535 bt.AddReturn(m.Int32Add(bt.param0, m.Uint32Div(bt.param0, bt.param1))); |
1540 FOR_UINT32_INPUTS(i) { | 1536 FOR_UINT32_INPUTS(i) { |
1541 FOR_UINT32_INPUTS(j) { | 1537 FOR_UINT32_INPUTS(j) { |
1542 uint32_t p0 = *i; | 1538 uint32_t p0 = *i; |
1543 uint32_t p1 = *j; | 1539 uint32_t p1 = *j; |
1544 if (p1 != 0) { | 1540 if (p1 != 0) { |
1545 uint32_t expected = static_cast<uint32_t>(p0 + (p0 / p1)); | 1541 int32_t expected = bit_cast<int32_t>(p0 + (p0 / p1)); |
1546 CHECK_EQ(expected, bt.call(p0, p1)); | 1542 CHECK_EQ(expected, bt.call(p0, p1)); |
1547 } | 1543 } |
1548 } | 1544 } |
1549 } | 1545 } |
1550 } | 1546 } |
1551 } | 1547 } |
1552 | 1548 |
1553 | 1549 |
1554 TEST(RunInt32ModP) { | 1550 TEST(RunInt32ModP) { |
1555 { | 1551 { |
(...skipping 25 matching lines...) Expand all Loading... |
1581 } | 1577 } |
1582 } | 1578 } |
1583 } | 1579 } |
1584 } | 1580 } |
1585 } | 1581 } |
1586 | 1582 |
1587 | 1583 |
1588 TEST(RunUint32ModP) { | 1584 TEST(RunUint32ModP) { |
1589 { | 1585 { |
1590 RawMachineAssemblerTester<int32_t> m; | 1586 RawMachineAssemblerTester<int32_t> m; |
1591 Int32BinopTester bt(&m); | 1587 Uint32BinopTester bt(&m); |
1592 bt.AddReturn(m.Uint32Mod(bt.param0, bt.param1)); | 1588 bt.AddReturn(m.Uint32Mod(bt.param0, bt.param1)); |
1593 FOR_UINT32_INPUTS(i) { | 1589 FOR_UINT32_INPUTS(i) { |
1594 FOR_UINT32_INPUTS(j) { | 1590 FOR_UINT32_INPUTS(j) { |
1595 uint32_t p0 = *i; | 1591 uint32_t p0 = *i; |
1596 uint32_t p1 = *j; | 1592 uint32_t p1 = *j; |
1597 if (p1 != 0) { | 1593 if (p1 != 0) { |
1598 uint32_t expected = static_cast<uint32_t>(p0 % p1); | 1594 uint32_t expected = static_cast<uint32_t>(p0 % p1); |
1599 CHECK_EQ(expected, bt.call(p0, p1)); | 1595 CHECK_EQ(expected, bt.call(p0, p1)); |
1600 } | 1596 } |
1601 } | 1597 } |
1602 } | 1598 } |
1603 } | 1599 } |
1604 { | 1600 { |
1605 RawMachineAssemblerTester<int32_t> m; | 1601 RawMachineAssemblerTester<int32_t> m; |
1606 Int32BinopTester bt(&m); | 1602 Uint32BinopTester bt(&m); |
1607 bt.AddReturn(m.Int32Add(bt.param0, m.Uint32Mod(bt.param0, bt.param1))); | 1603 bt.AddReturn(m.Int32Add(bt.param0, m.Uint32Mod(bt.param0, bt.param1))); |
1608 FOR_UINT32_INPUTS(i) { | 1604 FOR_UINT32_INPUTS(i) { |
1609 FOR_UINT32_INPUTS(j) { | 1605 FOR_UINT32_INPUTS(j) { |
1610 uint32_t p0 = *i; | 1606 uint32_t p0 = *i; |
1611 uint32_t p1 = *j; | 1607 uint32_t p1 = *j; |
1612 if (p1 != 0) { | 1608 if (p1 != 0) { |
1613 uint32_t expected = static_cast<uint32_t>(p0 + (p0 % p1)); | 1609 uint32_t expected = static_cast<uint32_t>(p0 + (p0 % p1)); |
1614 CHECK_EQ(expected, bt.call(p0, p1)); | 1610 CHECK_EQ(expected, bt.call(p0, p1)); |
1615 } | 1611 } |
1616 } | 1612 } |
1617 } | 1613 } |
1618 } | 1614 } |
1619 } | 1615 } |
1620 | 1616 |
1621 | 1617 |
1622 TEST(RunWord32AndP) { | 1618 TEST(RunWord32AndP) { |
1623 { | 1619 { |
1624 RawMachineAssemblerTester<int32_t> m; | 1620 RawMachineAssemblerTester<int32_t> m; |
1625 Int32BinopTester bt(&m); | 1621 Int32BinopTester bt(&m); |
1626 bt.AddReturn(m.Word32And(bt.param0, bt.param1)); | 1622 bt.AddReturn(m.Word32And(bt.param0, bt.param1)); |
1627 FOR_UINT32_INPUTS(i) { | 1623 FOR_UINT32_INPUTS(i) { |
1628 FOR_UINT32_INPUTS(j) { | 1624 FOR_UINT32_INPUTS(j) { |
1629 uint32_t expected = *i & *j; | 1625 int32_t expected = *i & *j; |
1630 CHECK_EQ(expected, bt.call(*i, *j)); | 1626 CHECK_EQ(expected, bt.call(*i, *j)); |
1631 } | 1627 } |
1632 } | 1628 } |
1633 } | 1629 } |
1634 { | 1630 { |
1635 RawMachineAssemblerTester<int32_t> m; | 1631 RawMachineAssemblerTester<int32_t> m; |
1636 Int32BinopTester bt(&m); | 1632 Int32BinopTester bt(&m); |
1637 bt.AddReturn(m.Word32And(bt.param0, m.Word32Not(bt.param1))); | 1633 bt.AddReturn(m.Word32And(bt.param0, m.Word32Not(bt.param1))); |
1638 FOR_UINT32_INPUTS(i) { | 1634 FOR_UINT32_INPUTS(i) { |
1639 FOR_UINT32_INPUTS(j) { | 1635 FOR_UINT32_INPUTS(j) { |
1640 uint32_t expected = *i & ~(*j); | 1636 int32_t expected = *i & ~(*j); |
1641 CHECK_EQ(expected, bt.call(*i, *j)); | 1637 CHECK_EQ(expected, bt.call(*i, *j)); |
1642 } | 1638 } |
1643 } | 1639 } |
1644 } | 1640 } |
1645 { | 1641 { |
1646 RawMachineAssemblerTester<int32_t> m; | 1642 RawMachineAssemblerTester<int32_t> m; |
1647 Int32BinopTester bt(&m); | 1643 Int32BinopTester bt(&m); |
1648 bt.AddReturn(m.Word32And(m.Word32Not(bt.param0), bt.param1)); | 1644 bt.AddReturn(m.Word32And(m.Word32Not(bt.param0), bt.param1)); |
1649 FOR_UINT32_INPUTS(i) { | 1645 FOR_UINT32_INPUTS(i) { |
1650 FOR_UINT32_INPUTS(j) { | 1646 FOR_UINT32_INPUTS(j) { |
1651 uint32_t expected = ~(*i) & *j; | 1647 int32_t expected = ~(*i) & *j; |
1652 CHECK_EQ(expected, bt.call(*i, *j)); | 1648 CHECK_EQ(expected, bt.call(*i, *j)); |
1653 } | 1649 } |
1654 } | 1650 } |
1655 } | 1651 } |
1656 } | 1652 } |
1657 | 1653 |
1658 | 1654 |
1659 TEST(RunWord32AndAndWord32ShlP) { | 1655 TEST(RunWord32AndAndWord32ShlP) { |
1660 { | 1656 { |
1661 RawMachineAssemblerTester<int32_t> m; | 1657 RawMachineAssemblerTester<int32_t> m; |
1662 Uint32BinopTester bt(&m); | 1658 Uint32BinopTester bt(&m); |
1663 bt.AddReturn( | 1659 bt.AddReturn( |
1664 m.Word32Shl(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); | 1660 m.Word32Shl(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); |
1665 FOR_UINT32_INPUTS(i) { | 1661 FOR_UINT32_INPUTS(i) { |
1666 FOR_UINT32_INPUTS(j) { | 1662 FOR_UINT32_INPUTS(j) { |
1667 uint32_t expected = *i << (*j & 0x1f); | 1663 uint32_t expected = *i << (*j & 0x1f); |
1668 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1664 CHECK_EQ(expected, bt.call(*i, *j)); |
1669 } | 1665 } |
1670 } | 1666 } |
1671 } | 1667 } |
1672 { | 1668 { |
1673 RawMachineAssemblerTester<int32_t> m; | 1669 RawMachineAssemblerTester<int32_t> m; |
1674 Uint32BinopTester bt(&m); | 1670 Uint32BinopTester bt(&m); |
1675 bt.AddReturn( | 1671 bt.AddReturn( |
1676 m.Word32Shl(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); | 1672 m.Word32Shl(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); |
1677 FOR_UINT32_INPUTS(i) { | 1673 FOR_UINT32_INPUTS(i) { |
1678 FOR_UINT32_INPUTS(j) { | 1674 FOR_UINT32_INPUTS(j) { |
1679 uint32_t expected = *i << (0x1f & *j); | 1675 uint32_t expected = *i << (0x1f & *j); |
1680 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1676 CHECK_EQ(expected, bt.call(*i, *j)); |
1681 } | 1677 } |
1682 } | 1678 } |
1683 } | 1679 } |
1684 } | 1680 } |
1685 | 1681 |
1686 | 1682 |
1687 TEST(RunWord32AndAndWord32ShrP) { | 1683 TEST(RunWord32AndAndWord32ShrP) { |
1688 { | 1684 { |
1689 RawMachineAssemblerTester<int32_t> m; | 1685 RawMachineAssemblerTester<int32_t> m; |
1690 Uint32BinopTester bt(&m); | 1686 Uint32BinopTester bt(&m); |
1691 bt.AddReturn( | 1687 bt.AddReturn( |
1692 m.Word32Shr(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); | 1688 m.Word32Shr(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); |
1693 FOR_UINT32_INPUTS(i) { | 1689 FOR_UINT32_INPUTS(i) { |
1694 FOR_UINT32_INPUTS(j) { | 1690 FOR_UINT32_INPUTS(j) { |
1695 uint32_t expected = *i >> (*j & 0x1f); | 1691 uint32_t expected = *i >> (*j & 0x1f); |
1696 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1692 CHECK_EQ(expected, bt.call(*i, *j)); |
1697 } | 1693 } |
1698 } | 1694 } |
1699 } | 1695 } |
1700 { | 1696 { |
1701 RawMachineAssemblerTester<int32_t> m; | 1697 RawMachineAssemblerTester<int32_t> m; |
1702 Uint32BinopTester bt(&m); | 1698 Uint32BinopTester bt(&m); |
1703 bt.AddReturn( | 1699 bt.AddReturn( |
1704 m.Word32Shr(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); | 1700 m.Word32Shr(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); |
1705 FOR_UINT32_INPUTS(i) { | 1701 FOR_UINT32_INPUTS(i) { |
1706 FOR_UINT32_INPUTS(j) { | 1702 FOR_UINT32_INPUTS(j) { |
1707 uint32_t expected = *i >> (0x1f & *j); | 1703 uint32_t expected = *i >> (0x1f & *j); |
1708 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1704 CHECK_EQ(expected, bt.call(*i, *j)); |
1709 } | 1705 } |
1710 } | 1706 } |
1711 } | 1707 } |
1712 } | 1708 } |
1713 | 1709 |
1714 | 1710 |
1715 TEST(RunWord32AndAndWord32SarP) { | 1711 TEST(RunWord32AndAndWord32SarP) { |
1716 { | 1712 { |
1717 RawMachineAssemblerTester<int32_t> m; | 1713 RawMachineAssemblerTester<int32_t> m; |
1718 Int32BinopTester bt(&m); | 1714 Int32BinopTester bt(&m); |
1719 bt.AddReturn( | 1715 bt.AddReturn( |
1720 m.Word32Sar(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); | 1716 m.Word32Sar(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); |
1721 FOR_INT32_INPUTS(i) { | 1717 FOR_INT32_INPUTS(i) { |
1722 FOR_INT32_INPUTS(j) { | 1718 FOR_INT32_INPUTS(j) { |
1723 int32_t expected = *i >> (*j & 0x1f); | 1719 int32_t expected = *i >> (*j & 0x1f); |
1724 CHECK_EQ(expected, bt.call(*i, *j)); | 1720 CHECK_EQ(expected, bt.call(*i, *j)); |
1725 } | 1721 } |
1726 } | 1722 } |
1727 } | 1723 } |
1728 { | 1724 { |
1729 RawMachineAssemblerTester<int32_t> m; | 1725 RawMachineAssemblerTester<int32_t> m; |
1730 Int32BinopTester bt(&m); | 1726 Int32BinopTester bt(&m); |
1731 bt.AddReturn( | 1727 bt.AddReturn( |
1732 m.Word32Sar(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); | 1728 m.Word32Sar(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); |
1733 FOR_INT32_INPUTS(i) { | 1729 FOR_INT32_INPUTS(i) { |
1734 FOR_INT32_INPUTS(j) { | 1730 FOR_INT32_INPUTS(j) { |
1735 uint32_t expected = *i >> (0x1f & *j); | 1731 int32_t expected = *i >> (0x1f & *j); |
1736 CHECK_EQ(expected, bt.call(*i, *j)); | 1732 CHECK_EQ(expected, bt.call(*i, *j)); |
1737 } | 1733 } |
1738 } | 1734 } |
1739 } | 1735 } |
1740 } | 1736 } |
1741 | 1737 |
1742 | 1738 |
1743 TEST(RunWord32AndImm) { | 1739 TEST(RunWord32AndImm) { |
1744 { | 1740 { |
1745 FOR_UINT32_INPUTS(i) { | 1741 FOR_UINT32_INPUTS(i) { |
1746 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1742 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1747 m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0))); | 1743 m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0))); |
1748 FOR_UINT32_INPUTS(j) { | 1744 FOR_UINT32_INPUTS(j) { |
1749 uint32_t expected = *i & *j; | 1745 uint32_t expected = *i & *j; |
1750 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1746 CHECK_EQ(expected, m.Call(*j)); |
1751 } | 1747 } |
1752 } | 1748 } |
1753 } | 1749 } |
1754 { | 1750 { |
1755 FOR_UINT32_INPUTS(i) { | 1751 FOR_UINT32_INPUTS(i) { |
1756 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1752 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1757 m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); | 1753 m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); |
1758 FOR_UINT32_INPUTS(j) { | 1754 FOR_UINT32_INPUTS(j) { |
1759 uint32_t expected = *i & ~(*j); | 1755 uint32_t expected = *i & ~(*j); |
1760 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1756 CHECK_EQ(expected, m.Call(*j)); |
1761 } | 1757 } |
1762 } | 1758 } |
1763 } | 1759 } |
1764 } | 1760 } |
1765 | 1761 |
1766 | 1762 |
1767 TEST(RunWord32AndInBranch) { | 1763 TEST(RunWord32AndInBranch) { |
1768 static const int constant = 987654321; | 1764 static const int constant = 987654321; |
1769 { | 1765 { |
1770 RawMachineAssemblerTester<int32_t> m; | 1766 RawMachineAssemblerTester<int32_t> m; |
1771 Uint32BinopTester bt(&m); | 1767 Int32BinopTester bt(&m); |
1772 MLabel blocka, blockb; | 1768 MLabel blocka, blockb; |
1773 m.Branch( | 1769 m.Branch( |
1774 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), | 1770 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), |
1775 &blocka, &blockb); | 1771 &blocka, &blockb); |
1776 m.Bind(&blocka); | 1772 m.Bind(&blocka); |
1777 bt.AddReturn(m.Int32Constant(constant)); | 1773 bt.AddReturn(m.Int32Constant(constant)); |
1778 m.Bind(&blockb); | 1774 m.Bind(&blockb); |
1779 bt.AddReturn(m.Int32Constant(0 - constant)); | 1775 bt.AddReturn(m.Int32Constant(0 - constant)); |
1780 FOR_UINT32_INPUTS(i) { | 1776 FOR_UINT32_INPUTS(i) { |
1781 FOR_UINT32_INPUTS(j) { | 1777 FOR_UINT32_INPUTS(j) { |
1782 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; | 1778 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; |
1783 CHECK_EQ(expected, bt.call(*i, *j)); | 1779 CHECK_EQ(expected, bt.call(*i, *j)); |
1784 } | 1780 } |
1785 } | 1781 } |
1786 } | 1782 } |
1787 { | 1783 { |
1788 RawMachineAssemblerTester<int32_t> m; | 1784 RawMachineAssemblerTester<int32_t> m; |
1789 Uint32BinopTester bt(&m); | 1785 Int32BinopTester bt(&m); |
1790 MLabel blocka, blockb; | 1786 MLabel blocka, blockb; |
1791 m.Branch( | 1787 m.Branch( |
1792 m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), | 1788 m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), |
1793 &blocka, &blockb); | 1789 &blocka, &blockb); |
1794 m.Bind(&blocka); | 1790 m.Bind(&blocka); |
1795 bt.AddReturn(m.Int32Constant(constant)); | 1791 bt.AddReturn(m.Int32Constant(constant)); |
1796 m.Bind(&blockb); | 1792 m.Bind(&blockb); |
1797 bt.AddReturn(m.Int32Constant(0 - constant)); | 1793 bt.AddReturn(m.Int32Constant(0 - constant)); |
1798 FOR_UINT32_INPUTS(i) { | 1794 FOR_UINT32_INPUTS(i) { |
1799 FOR_UINT32_INPUTS(j) { | 1795 FOR_UINT32_INPUTS(j) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 | 1880 |
1885 TEST(RunWord32AndInComparison) { | 1881 TEST(RunWord32AndInComparison) { |
1886 { | 1882 { |
1887 RawMachineAssemblerTester<int32_t> m; | 1883 RawMachineAssemblerTester<int32_t> m; |
1888 Uint32BinopTester bt(&m); | 1884 Uint32BinopTester bt(&m); |
1889 bt.AddReturn( | 1885 bt.AddReturn( |
1890 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0))); | 1886 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0))); |
1891 FOR_UINT32_INPUTS(i) { | 1887 FOR_UINT32_INPUTS(i) { |
1892 FOR_UINT32_INPUTS(j) { | 1888 FOR_UINT32_INPUTS(j) { |
1893 uint32_t expected = (*i & *j) == 0; | 1889 uint32_t expected = (*i & *j) == 0; |
1894 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1890 CHECK_EQ(expected, bt.call(*i, *j)); |
1895 } | 1891 } |
1896 } | 1892 } |
1897 } | 1893 } |
1898 { | 1894 { |
1899 RawMachineAssemblerTester<int32_t> m; | 1895 RawMachineAssemblerTester<int32_t> m; |
1900 Uint32BinopTester bt(&m); | 1896 Uint32BinopTester bt(&m); |
1901 bt.AddReturn( | 1897 bt.AddReturn( |
1902 m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1))); | 1898 m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1))); |
1903 FOR_UINT32_INPUTS(i) { | 1899 FOR_UINT32_INPUTS(i) { |
1904 FOR_UINT32_INPUTS(j) { | 1900 FOR_UINT32_INPUTS(j) { |
1905 uint32_t expected = (*i & *j) == 0; | 1901 uint32_t expected = (*i & *j) == 0; |
1906 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1902 CHECK_EQ(expected, bt.call(*i, *j)); |
1907 } | 1903 } |
1908 } | 1904 } |
1909 } | 1905 } |
1910 { | 1906 { |
1911 FOR_UINT32_INPUTS(i) { | 1907 FOR_UINT32_INPUTS(i) { |
1912 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1908 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1913 m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), | 1909 m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), |
1914 m.Int32Constant(0))); | 1910 m.Int32Constant(0))); |
1915 FOR_UINT32_INPUTS(j) { | 1911 FOR_UINT32_INPUTS(j) { |
1916 uint32_t expected = (*i & *j) == 0; | 1912 uint32_t expected = (*i & *j) == 0; |
1917 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1913 CHECK_EQ(expected, m.Call(*j)); |
1918 } | 1914 } |
1919 } | 1915 } |
1920 } | 1916 } |
1921 { | 1917 { |
1922 FOR_UINT32_INPUTS(i) { | 1918 FOR_UINT32_INPUTS(i) { |
1923 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1919 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1924 m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)), | 1920 m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)), |
1925 m.Int32Constant(0))); | 1921 m.Int32Constant(0))); |
1926 FOR_UINT32_INPUTS(j) { | 1922 FOR_UINT32_INPUTS(j) { |
1927 uint32_t expected = (*j & *i) == 0; | 1923 uint32_t expected = (*j & *i) == 0; |
1928 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1924 CHECK_EQ(expected, m.Call(*j)); |
1929 } | 1925 } |
1930 } | 1926 } |
1931 } | 1927 } |
1932 } | 1928 } |
1933 | 1929 |
1934 | 1930 |
1935 TEST(RunWord32OrP) { | 1931 TEST(RunWord32OrP) { |
1936 { | 1932 { |
1937 RawMachineAssemblerTester<int32_t> m; | 1933 RawMachineAssemblerTester<int32_t> m; |
1938 Uint32BinopTester bt(&m); | 1934 Uint32BinopTester bt(&m); |
1939 bt.AddReturn(m.Word32Or(bt.param0, bt.param1)); | 1935 bt.AddReturn(m.Word32Or(bt.param0, bt.param1)); |
1940 FOR_UINT32_INPUTS(i) { | 1936 FOR_UINT32_INPUTS(i) { |
1941 FOR_UINT32_INPUTS(j) { | 1937 FOR_UINT32_INPUTS(j) { |
1942 uint32_t expected = *i | *j; | 1938 uint32_t expected = *i | *j; |
1943 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1939 CHECK_EQ(expected, bt.call(*i, *j)); |
1944 } | 1940 } |
1945 } | 1941 } |
1946 } | 1942 } |
1947 { | 1943 { |
1948 RawMachineAssemblerTester<int32_t> m; | 1944 RawMachineAssemblerTester<int32_t> m; |
1949 Uint32BinopTester bt(&m); | 1945 Uint32BinopTester bt(&m); |
1950 bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1))); | 1946 bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1))); |
1951 FOR_UINT32_INPUTS(i) { | 1947 FOR_UINT32_INPUTS(i) { |
1952 FOR_UINT32_INPUTS(j) { | 1948 FOR_UINT32_INPUTS(j) { |
1953 uint32_t expected = *i | ~(*j); | 1949 uint32_t expected = *i | ~(*j); |
1954 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1950 CHECK_EQ(expected, bt.call(*i, *j)); |
1955 } | 1951 } |
1956 } | 1952 } |
1957 } | 1953 } |
1958 { | 1954 { |
1959 RawMachineAssemblerTester<int32_t> m; | 1955 RawMachineAssemblerTester<int32_t> m; |
1960 Uint32BinopTester bt(&m); | 1956 Uint32BinopTester bt(&m); |
1961 bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1)); | 1957 bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1)); |
1962 FOR_UINT32_INPUTS(i) { | 1958 FOR_UINT32_INPUTS(i) { |
1963 FOR_UINT32_INPUTS(j) { | 1959 FOR_UINT32_INPUTS(j) { |
1964 uint32_t expected = ~(*i) | *j; | 1960 uint32_t expected = ~(*i) | *j; |
1965 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 1961 CHECK_EQ(expected, bt.call(*i, *j)); |
1966 } | 1962 } |
1967 } | 1963 } |
1968 } | 1964 } |
1969 } | 1965 } |
1970 | 1966 |
1971 | 1967 |
1972 TEST(RunWord32OrImm) { | 1968 TEST(RunWord32OrImm) { |
1973 { | 1969 { |
1974 FOR_UINT32_INPUTS(i) { | 1970 FOR_UINT32_INPUTS(i) { |
1975 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1971 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1976 m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0))); | 1972 m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0))); |
1977 FOR_UINT32_INPUTS(j) { | 1973 FOR_UINT32_INPUTS(j) { |
1978 uint32_t expected = *i | *j; | 1974 uint32_t expected = *i | *j; |
1979 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1975 CHECK_EQ(expected, m.Call(*j)); |
1980 } | 1976 } |
1981 } | 1977 } |
1982 } | 1978 } |
1983 { | 1979 { |
1984 FOR_UINT32_INPUTS(i) { | 1980 FOR_UINT32_INPUTS(i) { |
1985 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1981 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
1986 m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); | 1982 m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); |
1987 FOR_UINT32_INPUTS(j) { | 1983 FOR_UINT32_INPUTS(j) { |
1988 uint32_t expected = *i | ~(*j); | 1984 uint32_t expected = *i | ~(*j); |
1989 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1985 CHECK_EQ(expected, m.Call(*j)); |
1990 } | 1986 } |
1991 } | 1987 } |
1992 } | 1988 } |
1993 } | 1989 } |
1994 | 1990 |
1995 | 1991 |
1996 TEST(RunWord32OrInBranch) { | 1992 TEST(RunWord32OrInBranch) { |
1997 static const int constant = 987654321; | 1993 static const int constant = 987654321; |
1998 { | 1994 { |
1999 RawMachineAssemblerTester<int32_t> m; | 1995 RawMachineAssemblerTester<int32_t> m; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 } | 2102 } |
2107 } | 2103 } |
2108 } | 2104 } |
2109 } | 2105 } |
2110 } | 2106 } |
2111 | 2107 |
2112 | 2108 |
2113 TEST(RunWord32OrInComparison) { | 2109 TEST(RunWord32OrInComparison) { |
2114 { | 2110 { |
2115 RawMachineAssemblerTester<int32_t> m; | 2111 RawMachineAssemblerTester<int32_t> m; |
2116 Uint32BinopTester bt(&m); | 2112 Int32BinopTester bt(&m); |
2117 bt.AddReturn( | 2113 bt.AddReturn( |
2118 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0))); | 2114 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0))); |
2119 FOR_UINT32_INPUTS(i) { | 2115 FOR_UINT32_INPUTS(i) { |
2120 FOR_UINT32_INPUTS(j) { | 2116 FOR_UINT32_INPUTS(j) { |
2121 int32_t expected = (*i | *j) == 0; | 2117 int32_t expected = (*i | *j) == 0; |
2122 CHECK_EQ(expected, bt.call(*i, *j)); | 2118 CHECK_EQ(expected, bt.call(*i, *j)); |
2123 } | 2119 } |
2124 } | 2120 } |
2125 } | 2121 } |
2126 { | 2122 { |
2127 RawMachineAssemblerTester<int32_t> m; | 2123 RawMachineAssemblerTester<int32_t> m; |
2128 Uint32BinopTester bt(&m); | 2124 Int32BinopTester bt(&m); |
2129 bt.AddReturn( | 2125 bt.AddReturn( |
2130 m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1))); | 2126 m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1))); |
2131 FOR_UINT32_INPUTS(i) { | 2127 FOR_UINT32_INPUTS(i) { |
2132 FOR_UINT32_INPUTS(j) { | 2128 FOR_UINT32_INPUTS(j) { |
2133 int32_t expected = (*i | *j) == 0; | 2129 int32_t expected = (*i | *j) == 0; |
2134 CHECK_EQ(expected, bt.call(*i, *j)); | 2130 CHECK_EQ(expected, bt.call(*i, *j)); |
2135 } | 2131 } |
2136 } | 2132 } |
2137 } | 2133 } |
2138 { | 2134 { |
2139 FOR_UINT32_INPUTS(i) { | 2135 FOR_UINT32_INPUTS(i) { |
2140 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2136 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2141 m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), | 2137 m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), |
2142 m.Int32Constant(0))); | 2138 m.Int32Constant(0))); |
2143 FOR_UINT32_INPUTS(j) { | 2139 FOR_UINT32_INPUTS(j) { |
2144 uint32_t expected = (*i | *j) == 0; | 2140 uint32_t expected = (*i | *j) == 0; |
2145 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2141 CHECK_EQ(expected, m.Call(*j)); |
2146 } | 2142 } |
2147 } | 2143 } |
2148 } | 2144 } |
2149 { | 2145 { |
2150 FOR_UINT32_INPUTS(i) { | 2146 FOR_UINT32_INPUTS(i) { |
2151 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2147 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2152 m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)), | 2148 m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)), |
2153 m.Int32Constant(0))); | 2149 m.Int32Constant(0))); |
2154 FOR_UINT32_INPUTS(j) { | 2150 FOR_UINT32_INPUTS(j) { |
2155 uint32_t expected = (*j | *i) == 0; | 2151 uint32_t expected = (*j | *i) == 0; |
2156 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2152 CHECK_EQ(expected, m.Call(*j)); |
2157 } | 2153 } |
2158 } | 2154 } |
2159 } | 2155 } |
2160 } | 2156 } |
2161 | 2157 |
2162 | 2158 |
2163 TEST(RunWord32XorP) { | 2159 TEST(RunWord32XorP) { |
2164 { | 2160 { |
2165 FOR_UINT32_INPUTS(i) { | 2161 FOR_UINT32_INPUTS(i) { |
2166 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2162 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2167 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0))); | 2163 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0))); |
2168 FOR_UINT32_INPUTS(j) { | 2164 FOR_UINT32_INPUTS(j) { |
2169 uint32_t expected = *i ^ *j; | 2165 uint32_t expected = *i ^ *j; |
2170 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2166 CHECK_EQ(expected, m.Call(*j)); |
2171 } | 2167 } |
2172 } | 2168 } |
2173 } | 2169 } |
2174 { | 2170 { |
2175 RawMachineAssemblerTester<int32_t> m; | 2171 RawMachineAssemblerTester<int32_t> m; |
2176 Uint32BinopTester bt(&m); | 2172 Uint32BinopTester bt(&m); |
2177 bt.AddReturn(m.Word32Xor(bt.param0, bt.param1)); | 2173 bt.AddReturn(m.Word32Xor(bt.param0, bt.param1)); |
2178 FOR_UINT32_INPUTS(i) { | 2174 FOR_UINT32_INPUTS(i) { |
2179 FOR_UINT32_INPUTS(j) { | 2175 FOR_UINT32_INPUTS(j) { |
2180 int32_t expected = *i ^ *j; | 2176 uint32_t expected = *i ^ *j; |
2181 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 2177 CHECK_EQ(expected, bt.call(*i, *j)); |
2182 } | 2178 } |
2183 } | 2179 } |
2184 } | 2180 } |
2185 { | 2181 { |
2186 RawMachineAssemblerTester<int32_t> m; | 2182 RawMachineAssemblerTester<int32_t> m; |
2187 Int32BinopTester bt(&m); | 2183 Int32BinopTester bt(&m); |
2188 bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1))); | 2184 bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1))); |
2189 FOR_INT32_INPUTS(i) { | 2185 FOR_INT32_INPUTS(i) { |
2190 FOR_INT32_INPUTS(j) { | 2186 FOR_INT32_INPUTS(j) { |
2191 int32_t expected = *i ^ ~(*j); | 2187 int32_t expected = *i ^ ~(*j); |
(...skipping 11 matching lines...) Expand all Loading... |
2203 CHECK_EQ(expected, bt.call(*i, *j)); | 2199 CHECK_EQ(expected, bt.call(*i, *j)); |
2204 } | 2200 } |
2205 } | 2201 } |
2206 } | 2202 } |
2207 { | 2203 { |
2208 FOR_UINT32_INPUTS(i) { | 2204 FOR_UINT32_INPUTS(i) { |
2209 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2205 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2210 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); | 2206 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); |
2211 FOR_UINT32_INPUTS(j) { | 2207 FOR_UINT32_INPUTS(j) { |
2212 uint32_t expected = *i ^ ~(*j); | 2208 uint32_t expected = *i ^ ~(*j); |
2213 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2209 CHECK_EQ(expected, m.Call(*j)); |
2214 } | 2210 } |
2215 } | 2211 } |
2216 } | 2212 } |
2217 } | 2213 } |
2218 | 2214 |
2219 | 2215 |
2220 TEST(RunWord32XorInBranch) { | 2216 TEST(RunWord32XorInBranch) { |
2221 static const uint32_t constant = 987654321; | 2217 static const uint32_t constant = 987654321; |
2222 { | 2218 { |
2223 RawMachineAssemblerTester<int32_t> m; | 2219 RawMachineAssemblerTester<int32_t> m; |
2224 Uint32BinopTester bt(&m); | 2220 Uint32BinopTester bt(&m); |
2225 MLabel blocka, blockb; | 2221 MLabel blocka, blockb; |
2226 m.Branch( | 2222 m.Branch( |
2227 m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), | 2223 m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), |
2228 &blocka, &blockb); | 2224 &blocka, &blockb); |
2229 m.Bind(&blocka); | 2225 m.Bind(&blocka); |
2230 bt.AddReturn(m.Int32Constant(constant)); | 2226 bt.AddReturn(m.Int32Constant(constant)); |
2231 m.Bind(&blockb); | 2227 m.Bind(&blockb); |
2232 bt.AddReturn(m.Int32Constant(0 - constant)); | 2228 bt.AddReturn(m.Int32Constant(0 - constant)); |
2233 FOR_UINT32_INPUTS(i) { | 2229 FOR_UINT32_INPUTS(i) { |
2234 FOR_UINT32_INPUTS(j) { | 2230 FOR_UINT32_INPUTS(j) { |
2235 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; | 2231 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; |
2236 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 2232 CHECK_EQ(expected, bt.call(*i, *j)); |
2237 } | 2233 } |
2238 } | 2234 } |
2239 } | 2235 } |
2240 { | 2236 { |
2241 RawMachineAssemblerTester<int32_t> m; | 2237 RawMachineAssemblerTester<int32_t> m; |
2242 Uint32BinopTester bt(&m); | 2238 Uint32BinopTester bt(&m); |
2243 MLabel blocka, blockb; | 2239 MLabel blocka, blockb; |
2244 m.Branch( | 2240 m.Branch( |
2245 m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), | 2241 m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), |
2246 &blocka, &blockb); | 2242 &blocka, &blockb); |
2247 m.Bind(&blocka); | 2243 m.Bind(&blocka); |
2248 bt.AddReturn(m.Int32Constant(constant)); | 2244 bt.AddReturn(m.Int32Constant(constant)); |
2249 m.Bind(&blockb); | 2245 m.Bind(&blockb); |
2250 bt.AddReturn(m.Int32Constant(0 - constant)); | 2246 bt.AddReturn(m.Int32Constant(0 - constant)); |
2251 FOR_UINT32_INPUTS(i) { | 2247 FOR_UINT32_INPUTS(i) { |
2252 FOR_UINT32_INPUTS(j) { | 2248 FOR_UINT32_INPUTS(j) { |
2253 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; | 2249 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; |
2254 CHECK_UINT32_EQ(expected, bt.call(*i, *j)); | 2250 CHECK_EQ(expected, bt.call(*i, *j)); |
2255 } | 2251 } |
2256 } | 2252 } |
2257 } | 2253 } |
2258 { | 2254 { |
2259 FOR_UINT32_INPUTS(i) { | 2255 FOR_UINT32_INPUTS(i) { |
2260 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2256 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2261 MLabel blocka, blockb; | 2257 MLabel blocka, blockb; |
2262 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), | 2258 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), |
2263 m.Int32Constant(0)), | 2259 m.Int32Constant(0)), |
2264 &blocka, &blockb); | 2260 &blocka, &blockb); |
2265 m.Bind(&blocka); | 2261 m.Bind(&blocka); |
2266 m.Return(m.Int32Constant(constant)); | 2262 m.Return(m.Int32Constant(constant)); |
2267 m.Bind(&blockb); | 2263 m.Bind(&blockb); |
2268 m.Return(m.Int32Constant(0 - constant)); | 2264 m.Return(m.Int32Constant(0 - constant)); |
2269 FOR_UINT32_INPUTS(j) { | 2265 FOR_UINT32_INPUTS(j) { |
2270 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; | 2266 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; |
2271 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2267 CHECK_EQ(expected, m.Call(*j)); |
2272 } | 2268 } |
2273 } | 2269 } |
2274 } | 2270 } |
2275 { | 2271 { |
2276 FOR_UINT32_INPUTS(i) { | 2272 FOR_UINT32_INPUTS(i) { |
2277 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2273 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2278 MLabel blocka, blockb; | 2274 MLabel blocka, blockb; |
2279 m.Branch( | 2275 m.Branch( |
2280 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), | 2276 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), |
2281 m.Int32Constant(0)), | 2277 m.Int32Constant(0)), |
2282 &blocka, &blockb); | 2278 &blocka, &blockb); |
2283 m.Bind(&blocka); | 2279 m.Bind(&blocka); |
2284 m.Return(m.Int32Constant(constant)); | 2280 m.Return(m.Int32Constant(constant)); |
2285 m.Bind(&blockb); | 2281 m.Bind(&blockb); |
2286 m.Return(m.Int32Constant(0 - constant)); | 2282 m.Return(m.Int32Constant(0 - constant)); |
2287 FOR_UINT32_INPUTS(j) { | 2283 FOR_UINT32_INPUTS(j) { |
2288 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; | 2284 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; |
2289 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2285 CHECK_EQ(expected, m.Call(*j)); |
2290 } | 2286 } |
2291 } | 2287 } |
2292 } | 2288 } |
2293 { | 2289 { |
2294 RawMachineAssemblerTester<void> m; | 2290 RawMachineAssemblerTester<void> m; |
2295 const Operator* shops[] = {m.machine()->Word32Sar(), | 2291 const Operator* shops[] = {m.machine()->Word32Sar(), |
2296 m.machine()->Word32Shl(), | 2292 m.machine()->Word32Shl(), |
2297 m.machine()->Word32Shr()}; | 2293 m.machine()->Word32Shr()}; |
2298 for (size_t n = 0; n < arraysize(shops); n++) { | 2294 for (size_t n = 0; n < arraysize(shops); n++) { |
2299 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2295 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 } | 2331 } |
2336 | 2332 |
2337 | 2333 |
2338 TEST(RunWord32ShlP) { | 2334 TEST(RunWord32ShlP) { |
2339 { | 2335 { |
2340 FOR_UINT32_SHIFTS(shift) { | 2336 FOR_UINT32_SHIFTS(shift) { |
2341 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2337 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2342 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); | 2338 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); |
2343 FOR_UINT32_INPUTS(j) { | 2339 FOR_UINT32_INPUTS(j) { |
2344 uint32_t expected = *j << shift; | 2340 uint32_t expected = *j << shift; |
2345 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2341 CHECK_EQ(expected, m.Call(*j)); |
2346 } | 2342 } |
2347 } | 2343 } |
2348 } | 2344 } |
2349 { | 2345 { |
2350 RawMachineAssemblerTester<int32_t> m; | 2346 RawMachineAssemblerTester<int32_t> m; |
2351 Uint32BinopTester bt(&m); | 2347 Uint32BinopTester bt(&m); |
2352 bt.AddReturn(m.Word32Shl(bt.param0, bt.param1)); | 2348 bt.AddReturn(m.Word32Shl(bt.param0, bt.param1)); |
2353 FOR_UINT32_INPUTS(i) { | 2349 FOR_UINT32_INPUTS(i) { |
2354 FOR_UINT32_SHIFTS(shift) { | 2350 FOR_UINT32_SHIFTS(shift) { |
2355 uint32_t expected = *i << shift; | 2351 uint32_t expected = *i << shift; |
2356 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2352 CHECK_EQ(expected, bt.call(*i, shift)); |
2357 } | 2353 } |
2358 } | 2354 } |
2359 } | 2355 } |
2360 } | 2356 } |
2361 | 2357 |
2362 | 2358 |
2363 TEST(RunWord32ShlInComparison) { | 2359 TEST(RunWord32ShlInComparison) { |
2364 { | 2360 { |
2365 RawMachineAssemblerTester<int32_t> m; | 2361 RawMachineAssemblerTester<int32_t> m; |
2366 Uint32BinopTester bt(&m); | 2362 Uint32BinopTester bt(&m); |
2367 bt.AddReturn( | 2363 bt.AddReturn( |
2368 m.Word32Equal(m.Word32Shl(bt.param0, bt.param1), m.Int32Constant(0))); | 2364 m.Word32Equal(m.Word32Shl(bt.param0, bt.param1), m.Int32Constant(0))); |
2369 FOR_UINT32_INPUTS(i) { | 2365 FOR_UINT32_INPUTS(i) { |
2370 FOR_UINT32_SHIFTS(shift) { | 2366 FOR_UINT32_SHIFTS(shift) { |
2371 uint32_t expected = 0 == (*i << shift); | 2367 uint32_t expected = 0 == (*i << shift); |
2372 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2368 CHECK_EQ(expected, bt.call(*i, shift)); |
2373 } | 2369 } |
2374 } | 2370 } |
2375 } | 2371 } |
2376 { | 2372 { |
2377 RawMachineAssemblerTester<int32_t> m; | 2373 RawMachineAssemblerTester<int32_t> m; |
2378 Uint32BinopTester bt(&m); | 2374 Uint32BinopTester bt(&m); |
2379 bt.AddReturn( | 2375 bt.AddReturn( |
2380 m.Word32Equal(m.Int32Constant(0), m.Word32Shl(bt.param0, bt.param1))); | 2376 m.Word32Equal(m.Int32Constant(0), m.Word32Shl(bt.param0, bt.param1))); |
2381 FOR_UINT32_INPUTS(i) { | 2377 FOR_UINT32_INPUTS(i) { |
2382 FOR_UINT32_SHIFTS(shift) { | 2378 FOR_UINT32_SHIFTS(shift) { |
2383 uint32_t expected = 0 == (*i << shift); | 2379 uint32_t expected = 0 == (*i << shift); |
2384 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2380 CHECK_EQ(expected, bt.call(*i, shift)); |
2385 } | 2381 } |
2386 } | 2382 } |
2387 } | 2383 } |
2388 { | 2384 { |
2389 FOR_UINT32_SHIFTS(shift) { | 2385 FOR_UINT32_SHIFTS(shift) { |
2390 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2386 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2391 m.Return( | 2387 m.Return( |
2392 m.Word32Equal(m.Int32Constant(0), | 2388 m.Word32Equal(m.Int32Constant(0), |
2393 m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)))); | 2389 m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)))); |
2394 FOR_UINT32_INPUTS(i) { | 2390 FOR_UINT32_INPUTS(i) { |
2395 uint32_t expected = 0 == (*i << shift); | 2391 uint32_t expected = 0 == (*i << shift); |
2396 CHECK_UINT32_EQ(expected, m.Call(*i)); | 2392 CHECK_EQ(expected, m.Call(*i)); |
2397 } | 2393 } |
2398 } | 2394 } |
2399 } | 2395 } |
2400 { | 2396 { |
2401 FOR_UINT32_SHIFTS(shift) { | 2397 FOR_UINT32_SHIFTS(shift) { |
2402 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2398 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2403 m.Return( | 2399 m.Return( |
2404 m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)), | 2400 m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)), |
2405 m.Int32Constant(0))); | 2401 m.Int32Constant(0))); |
2406 FOR_UINT32_INPUTS(i) { | 2402 FOR_UINT32_INPUTS(i) { |
2407 uint32_t expected = 0 == (*i << shift); | 2403 uint32_t expected = 0 == (*i << shift); |
2408 CHECK_UINT32_EQ(expected, m.Call(*i)); | 2404 CHECK_EQ(expected, m.Call(*i)); |
2409 } | 2405 } |
2410 } | 2406 } |
2411 } | 2407 } |
2412 } | 2408 } |
2413 | 2409 |
2414 | 2410 |
2415 TEST(RunWord32ShrP) { | 2411 TEST(RunWord32ShrP) { |
2416 { | 2412 { |
2417 FOR_UINT32_SHIFTS(shift) { | 2413 FOR_UINT32_SHIFTS(shift) { |
2418 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2414 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2419 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); | 2415 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); |
2420 FOR_UINT32_INPUTS(j) { | 2416 FOR_UINT32_INPUTS(j) { |
2421 uint32_t expected = *j >> shift; | 2417 uint32_t expected = *j >> shift; |
2422 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2418 CHECK_EQ(expected, m.Call(*j)); |
2423 } | 2419 } |
2424 } | 2420 } |
2425 } | 2421 } |
2426 { | 2422 { |
2427 RawMachineAssemblerTester<int32_t> m; | 2423 RawMachineAssemblerTester<int32_t> m; |
2428 Uint32BinopTester bt(&m); | 2424 Uint32BinopTester bt(&m); |
2429 bt.AddReturn(m.Word32Shr(bt.param0, bt.param1)); | 2425 bt.AddReturn(m.Word32Shr(bt.param0, bt.param1)); |
2430 FOR_UINT32_INPUTS(i) { | 2426 FOR_UINT32_INPUTS(i) { |
2431 FOR_UINT32_SHIFTS(shift) { | 2427 FOR_UINT32_SHIFTS(shift) { |
2432 uint32_t expected = *i >> shift; | 2428 uint32_t expected = *i >> shift; |
2433 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2429 CHECK_EQ(expected, bt.call(*i, shift)); |
2434 } | 2430 } |
2435 } | 2431 } |
2436 CHECK_EQ(0x00010000, bt.call(0x80000000, 15)); | 2432 CHECK_EQ(0x00010000u, bt.call(0x80000000, 15)); |
2437 } | 2433 } |
2438 } | 2434 } |
2439 | 2435 |
2440 | 2436 |
2441 TEST(RunWord32ShrInComparison) { | 2437 TEST(RunWord32ShrInComparison) { |
2442 { | 2438 { |
2443 RawMachineAssemblerTester<int32_t> m; | 2439 RawMachineAssemblerTester<int32_t> m; |
2444 Uint32BinopTester bt(&m); | 2440 Uint32BinopTester bt(&m); |
2445 bt.AddReturn( | 2441 bt.AddReturn( |
2446 m.Word32Equal(m.Word32Shr(bt.param0, bt.param1), m.Int32Constant(0))); | 2442 m.Word32Equal(m.Word32Shr(bt.param0, bt.param1), m.Int32Constant(0))); |
2447 FOR_UINT32_INPUTS(i) { | 2443 FOR_UINT32_INPUTS(i) { |
2448 FOR_UINT32_SHIFTS(shift) { | 2444 FOR_UINT32_SHIFTS(shift) { |
2449 uint32_t expected = 0 == (*i >> shift); | 2445 uint32_t expected = 0 == (*i >> shift); |
2450 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2446 CHECK_EQ(expected, bt.call(*i, shift)); |
2451 } | 2447 } |
2452 } | 2448 } |
2453 } | 2449 } |
2454 { | 2450 { |
2455 RawMachineAssemblerTester<int32_t> m; | 2451 RawMachineAssemblerTester<int32_t> m; |
2456 Uint32BinopTester bt(&m); | 2452 Uint32BinopTester bt(&m); |
2457 bt.AddReturn( | 2453 bt.AddReturn( |
2458 m.Word32Equal(m.Int32Constant(0), m.Word32Shr(bt.param0, bt.param1))); | 2454 m.Word32Equal(m.Int32Constant(0), m.Word32Shr(bt.param0, bt.param1))); |
2459 FOR_UINT32_INPUTS(i) { | 2455 FOR_UINT32_INPUTS(i) { |
2460 FOR_UINT32_SHIFTS(shift) { | 2456 FOR_UINT32_SHIFTS(shift) { |
2461 uint32_t expected = 0 == (*i >> shift); | 2457 uint32_t expected = 0 == (*i >> shift); |
2462 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2458 CHECK_EQ(expected, bt.call(*i, shift)); |
2463 } | 2459 } |
2464 } | 2460 } |
2465 } | 2461 } |
2466 { | 2462 { |
2467 FOR_UINT32_SHIFTS(shift) { | 2463 FOR_UINT32_SHIFTS(shift) { |
2468 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2464 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2469 m.Return( | 2465 m.Return( |
2470 m.Word32Equal(m.Int32Constant(0), | 2466 m.Word32Equal(m.Int32Constant(0), |
2471 m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); | 2467 m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); |
2472 FOR_UINT32_INPUTS(i) { | 2468 FOR_UINT32_INPUTS(i) { |
2473 uint32_t expected = 0 == (*i >> shift); | 2469 uint32_t expected = 0 == (*i >> shift); |
2474 CHECK_UINT32_EQ(expected, m.Call(*i)); | 2470 CHECK_EQ(expected, m.Call(*i)); |
2475 } | 2471 } |
2476 } | 2472 } |
2477 } | 2473 } |
2478 { | 2474 { |
2479 FOR_UINT32_SHIFTS(shift) { | 2475 FOR_UINT32_SHIFTS(shift) { |
2480 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2476 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2481 m.Return( | 2477 m.Return( |
2482 m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), | 2478 m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), |
2483 m.Int32Constant(0))); | 2479 m.Int32Constant(0))); |
2484 FOR_UINT32_INPUTS(i) { | 2480 FOR_UINT32_INPUTS(i) { |
2485 uint32_t expected = 0 == (*i >> shift); | 2481 uint32_t expected = 0 == (*i >> shift); |
2486 CHECK_UINT32_EQ(expected, m.Call(*i)); | 2482 CHECK_EQ(expected, m.Call(*i)); |
2487 } | 2483 } |
2488 } | 2484 } |
2489 } | 2485 } |
2490 } | 2486 } |
2491 | 2487 |
2492 | 2488 |
2493 TEST(RunWord32SarP) { | 2489 TEST(RunWord32SarP) { |
2494 { | 2490 { |
2495 FOR_INT32_SHIFTS(shift) { | 2491 FOR_INT32_SHIFTS(shift) { |
2496 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 2492 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
2497 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); | 2493 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); |
2498 FOR_INT32_INPUTS(j) { | 2494 FOR_INT32_INPUTS(j) { |
2499 int32_t expected = *j >> shift; | 2495 int32_t expected = *j >> shift; |
2500 CHECK_EQ(expected, m.Call(*j)); | 2496 CHECK_EQ(expected, m.Call(*j)); |
2501 } | 2497 } |
2502 } | 2498 } |
2503 } | 2499 } |
2504 { | 2500 { |
2505 RawMachineAssemblerTester<int32_t> m; | 2501 RawMachineAssemblerTester<int32_t> m; |
2506 Int32BinopTester bt(&m); | 2502 Int32BinopTester bt(&m); |
2507 bt.AddReturn(m.Word32Sar(bt.param0, bt.param1)); | 2503 bt.AddReturn(m.Word32Sar(bt.param0, bt.param1)); |
2508 FOR_INT32_INPUTS(i) { | 2504 FOR_INT32_INPUTS(i) { |
2509 FOR_INT32_SHIFTS(shift) { | 2505 FOR_INT32_SHIFTS(shift) { |
2510 int32_t expected = *i >> shift; | 2506 int32_t expected = *i >> shift; |
2511 CHECK_EQ(expected, bt.call(*i, shift)); | 2507 CHECK_EQ(expected, bt.call(*i, shift)); |
2512 } | 2508 } |
2513 } | 2509 } |
2514 CHECK_EQ(0xFFFF0000, bt.call(0x80000000, 15)); | 2510 CHECK_EQ(bit_cast<int32_t>(0xFFFF0000), bt.call(0x80000000, 15)); |
2515 } | 2511 } |
2516 } | 2512 } |
2517 | 2513 |
2518 | 2514 |
2519 TEST(RunWord32SarInComparison) { | 2515 TEST(RunWord32SarInComparison) { |
2520 { | 2516 { |
2521 RawMachineAssemblerTester<int32_t> m; | 2517 RawMachineAssemblerTester<int32_t> m; |
2522 Int32BinopTester bt(&m); | 2518 Int32BinopTester bt(&m); |
2523 bt.AddReturn( | 2519 bt.AddReturn( |
2524 m.Word32Equal(m.Word32Sar(bt.param0, bt.param1), m.Int32Constant(0))); | 2520 m.Word32Equal(m.Word32Sar(bt.param0, bt.param1), m.Int32Constant(0))); |
(...skipping 28 matching lines...) Expand all Loading... |
2553 } | 2549 } |
2554 } | 2550 } |
2555 } | 2551 } |
2556 { | 2552 { |
2557 FOR_INT32_SHIFTS(shift) { | 2553 FOR_INT32_SHIFTS(shift) { |
2558 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 2554 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
2559 m.Return( | 2555 m.Return( |
2560 m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)), | 2556 m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)), |
2561 m.Int32Constant(0))); | 2557 m.Int32Constant(0))); |
2562 FOR_INT32_INPUTS(i) { | 2558 FOR_INT32_INPUTS(i) { |
2563 uint32_t expected = 0 == (*i >> shift); | 2559 int32_t expected = 0 == (*i >> shift); |
2564 CHECK_EQ(expected, m.Call(*i)); | 2560 CHECK_EQ(expected, m.Call(*i)); |
2565 } | 2561 } |
2566 } | 2562 } |
2567 } | 2563 } |
2568 } | 2564 } |
2569 | 2565 |
2570 | 2566 |
2571 TEST(RunWord32RorP) { | 2567 TEST(RunWord32RorP) { |
2572 { | 2568 { |
2573 FOR_UINT32_SHIFTS(shift) { | 2569 FOR_UINT32_SHIFTS(shift) { |
2574 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2570 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
2575 m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift))); | 2571 m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift))); |
2576 FOR_UINT32_INPUTS(j) { | 2572 FOR_UINT32_INPUTS(j) { |
2577 int32_t expected = bits::RotateRight32(*j, shift); | 2573 int32_t expected = bits::RotateRight32(*j, shift); |
2578 CHECK_EQ(expected, m.Call(*j)); | 2574 CHECK_EQ(expected, m.Call(*j)); |
2579 } | 2575 } |
2580 } | 2576 } |
2581 } | 2577 } |
2582 { | 2578 { |
2583 RawMachineAssemblerTester<int32_t> m; | 2579 RawMachineAssemblerTester<int32_t> m; |
2584 Uint32BinopTester bt(&m); | 2580 Uint32BinopTester bt(&m); |
2585 bt.AddReturn(m.Word32Ror(bt.param0, bt.param1)); | 2581 bt.AddReturn(m.Word32Ror(bt.param0, bt.param1)); |
2586 FOR_UINT32_INPUTS(i) { | 2582 FOR_UINT32_INPUTS(i) { |
2587 FOR_UINT32_SHIFTS(shift) { | 2583 FOR_UINT32_SHIFTS(shift) { |
2588 uint32_t expected = bits::RotateRight32(*i, shift); | 2584 uint32_t expected = bits::RotateRight32(*i, shift); |
2589 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2585 CHECK_EQ(expected, bt.call(*i, shift)); |
2590 } | 2586 } |
2591 } | 2587 } |
2592 } | 2588 } |
2593 } | 2589 } |
2594 | 2590 |
2595 | 2591 |
2596 TEST(RunWord32RorInComparison) { | 2592 TEST(RunWord32RorInComparison) { |
2597 { | 2593 { |
2598 RawMachineAssemblerTester<int32_t> m; | 2594 RawMachineAssemblerTester<int32_t> m; |
2599 Uint32BinopTester bt(&m); | 2595 Uint32BinopTester bt(&m); |
2600 bt.AddReturn( | 2596 bt.AddReturn( |
2601 m.Word32Equal(m.Word32Ror(bt.param0, bt.param1), m.Int32Constant(0))); | 2597 m.Word32Equal(m.Word32Ror(bt.param0, bt.param1), m.Int32Constant(0))); |
2602 FOR_UINT32_INPUTS(i) { | 2598 FOR_UINT32_INPUTS(i) { |
2603 FOR_UINT32_SHIFTS(shift) { | 2599 FOR_UINT32_SHIFTS(shift) { |
2604 uint32_t expected = 0 == bits::RotateRight32(*i, shift); | 2600 uint32_t expected = 0 == bits::RotateRight32(*i, shift); |
2605 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2601 CHECK_EQ(expected, bt.call(*i, shift)); |
2606 } | 2602 } |
2607 } | 2603 } |
2608 } | 2604 } |
2609 { | 2605 { |
2610 RawMachineAssemblerTester<int32_t> m; | 2606 RawMachineAssemblerTester<int32_t> m; |
2611 Uint32BinopTester bt(&m); | 2607 Uint32BinopTester bt(&m); |
2612 bt.AddReturn( | 2608 bt.AddReturn( |
2613 m.Word32Equal(m.Int32Constant(0), m.Word32Ror(bt.param0, bt.param1))); | 2609 m.Word32Equal(m.Int32Constant(0), m.Word32Ror(bt.param0, bt.param1))); |
2614 FOR_UINT32_INPUTS(i) { | 2610 FOR_UINT32_INPUTS(i) { |
2615 FOR_UINT32_SHIFTS(shift) { | 2611 FOR_UINT32_SHIFTS(shift) { |
2616 uint32_t expected = 0 == bits::RotateRight32(*i, shift); | 2612 uint32_t expected = 0 == bits::RotateRight32(*i, shift); |
2617 CHECK_UINT32_EQ(expected, bt.call(*i, shift)); | 2613 CHECK_EQ(expected, bt.call(*i, shift)); |
2618 } | 2614 } |
2619 } | 2615 } |
2620 } | 2616 } |
2621 { | 2617 { |
2622 FOR_UINT32_SHIFTS(shift) { | 2618 FOR_UINT32_SHIFTS(shift) { |
2623 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2619 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2624 m.Return( | 2620 m.Return( |
2625 m.Word32Equal(m.Int32Constant(0), | 2621 m.Word32Equal(m.Int32Constant(0), |
2626 m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)))); | 2622 m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)))); |
2627 FOR_UINT32_INPUTS(i) { | 2623 FOR_UINT32_INPUTS(i) { |
2628 uint32_t expected = 0 == bits::RotateRight32(*i, shift); | 2624 uint32_t expected = 0 == bits::RotateRight32(*i, shift); |
2629 CHECK_UINT32_EQ(expected, m.Call(*i)); | 2625 CHECK_EQ(expected, m.Call(*i)); |
2630 } | 2626 } |
2631 } | 2627 } |
2632 } | 2628 } |
2633 { | 2629 { |
2634 FOR_UINT32_SHIFTS(shift) { | 2630 FOR_UINT32_SHIFTS(shift) { |
2635 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2631 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
2636 m.Return( | 2632 m.Return( |
2637 m.Word32Equal(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)), | 2633 m.Word32Equal(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)), |
2638 m.Int32Constant(0))); | 2634 m.Int32Constant(0))); |
2639 FOR_UINT32_INPUTS(i) { | 2635 FOR_UINT32_INPUTS(i) { |
2640 uint32_t expected = 0 == bits::RotateRight32(*i, shift); | 2636 uint32_t expected = 0 == bits::RotateRight32(*i, shift); |
2641 CHECK_UINT32_EQ(expected, m.Call(*i)); | 2637 CHECK_EQ(expected, m.Call(*i)); |
2642 } | 2638 } |
2643 } | 2639 } |
2644 } | 2640 } |
2645 } | 2641 } |
2646 | 2642 |
2647 | 2643 |
2648 TEST(RunWord32NotP) { | 2644 TEST(RunWord32NotP) { |
2649 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 2645 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
2650 m.Return(m.Word32Not(m.Parameter(0))); | 2646 m.Return(m.Word32Not(m.Parameter(0))); |
2651 FOR_INT32_INPUTS(i) { | 2647 FOR_INT32_INPUTS(i) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 | 2953 |
2958 TEST(RunFloat64AddP) { | 2954 TEST(RunFloat64AddP) { |
2959 RawMachineAssemblerTester<int32_t> m; | 2955 RawMachineAssemblerTester<int32_t> m; |
2960 Float64BinopTester bt(&m); | 2956 Float64BinopTester bt(&m); |
2961 | 2957 |
2962 bt.AddReturn(m.Float64Add(bt.param0, bt.param1)); | 2958 bt.AddReturn(m.Float64Add(bt.param0, bt.param1)); |
2963 | 2959 |
2964 FOR_FLOAT64_INPUTS(pl) { | 2960 FOR_FLOAT64_INPUTS(pl) { |
2965 FOR_FLOAT64_INPUTS(pr) { | 2961 FOR_FLOAT64_INPUTS(pr) { |
2966 double expected = *pl + *pr; | 2962 double expected = *pl + *pr; |
2967 CHECK_EQ(expected, bt.call(*pl, *pr)); | 2963 CheckDoubleEq(expected, bt.call(*pl, *pr)); |
2968 } | 2964 } |
2969 } | 2965 } |
2970 } | 2966 } |
2971 | 2967 |
2972 | 2968 |
2973 TEST(RunFloat64SubP) { | 2969 TEST(RunFloat64SubP) { |
2974 RawMachineAssemblerTester<int32_t> m; | 2970 RawMachineAssemblerTester<int32_t> m; |
2975 Float64BinopTester bt(&m); | 2971 Float64BinopTester bt(&m); |
2976 | 2972 |
2977 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); | 2973 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); |
2978 | 2974 |
2979 FOR_FLOAT64_INPUTS(pl) { | 2975 FOR_FLOAT64_INPUTS(pl) { |
2980 FOR_FLOAT64_INPUTS(pr) { | 2976 FOR_FLOAT64_INPUTS(pr) { |
2981 double expected = *pl - *pr; | 2977 double expected = *pl - *pr; |
2982 CHECK_EQ(expected, bt.call(*pl, *pr)); | 2978 CheckDoubleEq(expected, bt.call(*pl, *pr)); |
2983 } | 2979 } |
2984 } | 2980 } |
2985 } | 2981 } |
2986 | 2982 |
2987 | 2983 |
2988 TEST(RunFloat64SubImm1) { | 2984 TEST(RunFloat64SubImm1) { |
2989 double input = 0.0; | 2985 double input = 0.0; |
2990 double output = 0.0; | 2986 double output = 0.0; |
2991 | 2987 |
2992 FOR_FLOAT64_INPUTS(i) { | 2988 FOR_FLOAT64_INPUTS(i) { |
2993 RawMachineAssemblerTester<int32_t> m; | 2989 RawMachineAssemblerTester<int32_t> m; |
2994 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); | 2990 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); |
2995 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0); | 2991 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0); |
2996 m.StoreToPointer(&output, kMachFloat64, t1); | 2992 m.StoreToPointer(&output, kMachFloat64, t1); |
2997 m.Return(m.Int32Constant(0)); | 2993 m.Return(m.Int32Constant(0)); |
2998 FOR_FLOAT64_INPUTS(j) { | 2994 FOR_FLOAT64_INPUTS(j) { |
2999 input = *j; | 2995 input = *j; |
3000 double expected = *i - input; | 2996 double expected = *i - input; |
3001 CHECK_EQ(0, m.Call()); | 2997 CHECK_EQ(0, m.Call()); |
3002 CHECK_EQ(expected, output); | 2998 CheckDoubleEq(expected, output); |
3003 } | 2999 } |
3004 } | 3000 } |
3005 } | 3001 } |
3006 | 3002 |
3007 | 3003 |
3008 TEST(RunFloat64SubImm2) { | 3004 TEST(RunFloat64SubImm2) { |
3009 double input = 0.0; | 3005 double input = 0.0; |
3010 double output = 0.0; | 3006 double output = 0.0; |
3011 | 3007 |
3012 FOR_FLOAT64_INPUTS(i) { | 3008 FOR_FLOAT64_INPUTS(i) { |
3013 RawMachineAssemblerTester<int32_t> m; | 3009 RawMachineAssemblerTester<int32_t> m; |
3014 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); | 3010 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); |
3015 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i)); | 3011 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i)); |
3016 m.StoreToPointer(&output, kMachFloat64, t1); | 3012 m.StoreToPointer(&output, kMachFloat64, t1); |
3017 m.Return(m.Int32Constant(0)); | 3013 m.Return(m.Int32Constant(0)); |
3018 FOR_FLOAT64_INPUTS(j) { | 3014 FOR_FLOAT64_INPUTS(j) { |
3019 input = *j; | 3015 input = *j; |
3020 double expected = input - *i; | 3016 double expected = input - *i; |
3021 CHECK_EQ(0, m.Call()); | 3017 CHECK_EQ(0, m.Call()); |
3022 CHECK_EQ(expected, output); | 3018 CheckDoubleEq(expected, output); |
3023 } | 3019 } |
3024 } | 3020 } |
3025 } | 3021 } |
3026 | 3022 |
3027 | 3023 |
3028 TEST(RunFloat64MulP) { | 3024 TEST(RunFloat64MulP) { |
3029 RawMachineAssemblerTester<int32_t> m; | 3025 RawMachineAssemblerTester<int32_t> m; |
3030 Float64BinopTester bt(&m); | 3026 Float64BinopTester bt(&m); |
3031 | 3027 |
3032 bt.AddReturn(m.Float64Mul(bt.param0, bt.param1)); | 3028 bt.AddReturn(m.Float64Mul(bt.param0, bt.param1)); |
3033 | 3029 |
3034 FOR_FLOAT64_INPUTS(pl) { | 3030 FOR_FLOAT64_INPUTS(pl) { |
3035 FOR_FLOAT64_INPUTS(pr) { | 3031 FOR_FLOAT64_INPUTS(pr) { |
3036 double expected = *pl * *pr; | 3032 double expected = *pl * *pr; |
3037 CHECK_EQ(expected, bt.call(*pl, *pr)); | 3033 CheckDoubleEq(expected, bt.call(*pl, *pr)); |
3038 } | 3034 } |
3039 } | 3035 } |
3040 } | 3036 } |
3041 | 3037 |
3042 | 3038 |
3043 TEST(RunFloat64MulAndFloat64AddP) { | 3039 TEST(RunFloat64MulAndFloat64AddP) { |
3044 double input_a = 0.0; | 3040 double input_a = 0.0; |
3045 double input_b = 0.0; | 3041 double input_b = 0.0; |
3046 double input_c = 0.0; | 3042 double input_c = 0.0; |
3047 double output = 0.0; | 3043 double output = 0.0; |
3048 | 3044 |
3049 { | 3045 { |
3050 RawMachineAssemblerTester<int32_t> m; | 3046 RawMachineAssemblerTester<int32_t> m; |
3051 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); | 3047 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); |
3052 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); | 3048 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); |
3053 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); | 3049 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); |
3054 m.StoreToPointer(&output, kMachFloat64, | 3050 m.StoreToPointer(&output, kMachFloat64, |
3055 m.Float64Add(m.Float64Mul(a, b), c)); | 3051 m.Float64Add(m.Float64Mul(a, b), c)); |
3056 m.Return(m.Int32Constant(0)); | 3052 m.Return(m.Int32Constant(0)); |
3057 FOR_FLOAT64_INPUTS(i) { | 3053 FOR_FLOAT64_INPUTS(i) { |
3058 FOR_FLOAT64_INPUTS(j) { | 3054 FOR_FLOAT64_INPUTS(j) { |
3059 FOR_FLOAT64_INPUTS(k) { | 3055 FOR_FLOAT64_INPUTS(k) { |
3060 input_a = *i; | 3056 input_a = *i; |
3061 input_b = *j; | 3057 input_b = *j; |
3062 input_c = *k; | 3058 input_c = *k; |
3063 volatile double temp = input_a * input_b; | 3059 volatile double temp = input_a * input_b; |
3064 volatile double expected = temp + input_c; | 3060 volatile double expected = temp + input_c; |
3065 CHECK_EQ(0, m.Call()); | 3061 CHECK_EQ(0, m.Call()); |
3066 CHECK_EQ(expected, output); | 3062 CheckDoubleEq(expected, output); |
3067 } | 3063 } |
3068 } | 3064 } |
3069 } | 3065 } |
3070 } | 3066 } |
3071 { | 3067 { |
3072 RawMachineAssemblerTester<int32_t> m; | 3068 RawMachineAssemblerTester<int32_t> m; |
3073 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); | 3069 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); |
3074 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); | 3070 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); |
3075 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); | 3071 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); |
3076 m.StoreToPointer(&output, kMachFloat64, | 3072 m.StoreToPointer(&output, kMachFloat64, |
3077 m.Float64Add(a, m.Float64Mul(b, c))); | 3073 m.Float64Add(a, m.Float64Mul(b, c))); |
3078 m.Return(m.Int32Constant(0)); | 3074 m.Return(m.Int32Constant(0)); |
3079 FOR_FLOAT64_INPUTS(i) { | 3075 FOR_FLOAT64_INPUTS(i) { |
3080 FOR_FLOAT64_INPUTS(j) { | 3076 FOR_FLOAT64_INPUTS(j) { |
3081 FOR_FLOAT64_INPUTS(k) { | 3077 FOR_FLOAT64_INPUTS(k) { |
3082 input_a = *i; | 3078 input_a = *i; |
3083 input_b = *j; | 3079 input_b = *j; |
3084 input_c = *k; | 3080 input_c = *k; |
3085 volatile double temp = input_b * input_c; | 3081 volatile double temp = input_b * input_c; |
3086 volatile double expected = input_a + temp; | 3082 volatile double expected = input_a + temp; |
3087 CHECK_EQ(0, m.Call()); | 3083 CHECK_EQ(0, m.Call()); |
3088 CHECK_EQ(expected, output); | 3084 CheckDoubleEq(expected, output); |
3089 } | 3085 } |
3090 } | 3086 } |
3091 } | 3087 } |
3092 } | 3088 } |
3093 } | 3089 } |
3094 | 3090 |
3095 | 3091 |
3096 TEST(RunFloat64MulAndFloat64SubP) { | 3092 TEST(RunFloat64MulAndFloat64SubP) { |
3097 double input_a = 0.0; | 3093 double input_a = 0.0; |
3098 double input_b = 0.0; | 3094 double input_b = 0.0; |
3099 double input_c = 0.0; | 3095 double input_c = 0.0; |
3100 double output = 0.0; | 3096 double output = 0.0; |
3101 | 3097 |
3102 RawMachineAssemblerTester<int32_t> m; | 3098 RawMachineAssemblerTester<int32_t> m; |
3103 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); | 3099 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); |
3104 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); | 3100 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); |
3105 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); | 3101 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); |
3106 m.StoreToPointer(&output, kMachFloat64, m.Float64Sub(a, m.Float64Mul(b, c))); | 3102 m.StoreToPointer(&output, kMachFloat64, m.Float64Sub(a, m.Float64Mul(b, c))); |
3107 m.Return(m.Int32Constant(0)); | 3103 m.Return(m.Int32Constant(0)); |
3108 | 3104 |
3109 FOR_FLOAT64_INPUTS(i) { | 3105 FOR_FLOAT64_INPUTS(i) { |
3110 FOR_FLOAT64_INPUTS(j) { | 3106 FOR_FLOAT64_INPUTS(j) { |
3111 FOR_FLOAT64_INPUTS(k) { | 3107 FOR_FLOAT64_INPUTS(k) { |
3112 input_a = *i; | 3108 input_a = *i; |
3113 input_b = *j; | 3109 input_b = *j; |
3114 input_c = *k; | 3110 input_c = *k; |
3115 volatile double temp = input_b * input_c; | 3111 volatile double temp = input_b * input_c; |
3116 volatile double expected = input_a - temp; | 3112 volatile double expected = input_a - temp; |
3117 CHECK_EQ(0, m.Call()); | 3113 CHECK_EQ(0, m.Call()); |
3118 CHECK_EQ(expected, output); | 3114 CheckDoubleEq(expected, output); |
3119 } | 3115 } |
3120 } | 3116 } |
3121 } | 3117 } |
3122 } | 3118 } |
3123 | 3119 |
3124 | 3120 |
3125 TEST(RunFloat64MulImm) { | 3121 TEST(RunFloat64MulImm) { |
3126 double input = 0.0; | 3122 double input = 0.0; |
3127 double output = 0.0; | 3123 double output = 0.0; |
3128 | 3124 |
3129 { | 3125 { |
3130 FOR_FLOAT64_INPUTS(i) { | 3126 FOR_FLOAT64_INPUTS(i) { |
3131 RawMachineAssemblerTester<int32_t> m; | 3127 RawMachineAssemblerTester<int32_t> m; |
3132 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); | 3128 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); |
3133 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0); | 3129 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0); |
3134 m.StoreToPointer(&output, kMachFloat64, t1); | 3130 m.StoreToPointer(&output, kMachFloat64, t1); |
3135 m.Return(m.Int32Constant(0)); | 3131 m.Return(m.Int32Constant(0)); |
3136 FOR_FLOAT64_INPUTS(j) { | 3132 FOR_FLOAT64_INPUTS(j) { |
3137 input = *j; | 3133 input = *j; |
3138 double expected = *i * input; | 3134 double expected = *i * input; |
3139 CHECK_EQ(0, m.Call()); | 3135 CHECK_EQ(0, m.Call()); |
3140 CHECK_EQ(expected, output); | 3136 CheckDoubleEq(expected, output); |
3141 } | 3137 } |
3142 } | 3138 } |
3143 } | 3139 } |
3144 { | 3140 { |
3145 FOR_FLOAT64_INPUTS(i) { | 3141 FOR_FLOAT64_INPUTS(i) { |
3146 RawMachineAssemblerTester<int32_t> m; | 3142 RawMachineAssemblerTester<int32_t> m; |
3147 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); | 3143 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); |
3148 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i)); | 3144 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i)); |
3149 m.StoreToPointer(&output, kMachFloat64, t1); | 3145 m.StoreToPointer(&output, kMachFloat64, t1); |
3150 m.Return(m.Int32Constant(0)); | 3146 m.Return(m.Int32Constant(0)); |
3151 FOR_FLOAT64_INPUTS(j) { | 3147 FOR_FLOAT64_INPUTS(j) { |
3152 input = *j; | 3148 input = *j; |
3153 double expected = input * *i; | 3149 double expected = input * *i; |
3154 CHECK_EQ(0, m.Call()); | 3150 CHECK_EQ(0, m.Call()); |
3155 CHECK_EQ(expected, output); | 3151 CheckDoubleEq(expected, output); |
3156 } | 3152 } |
3157 } | 3153 } |
3158 } | 3154 } |
3159 } | 3155 } |
3160 | 3156 |
3161 | 3157 |
3162 TEST(RunFloat64DivP) { | 3158 TEST(RunFloat64DivP) { |
3163 RawMachineAssemblerTester<int32_t> m; | 3159 RawMachineAssemblerTester<int32_t> m; |
3164 Float64BinopTester bt(&m); | 3160 Float64BinopTester bt(&m); |
3165 | 3161 |
3166 bt.AddReturn(m.Float64Div(bt.param0, bt.param1)); | 3162 bt.AddReturn(m.Float64Div(bt.param0, bt.param1)); |
3167 | 3163 |
3168 FOR_FLOAT64_INPUTS(pl) { | 3164 FOR_FLOAT64_INPUTS(pl) { |
3169 FOR_FLOAT64_INPUTS(pr) { | 3165 FOR_FLOAT64_INPUTS(pr) { |
3170 double expected = *pl / *pr; | 3166 double expected = *pl / *pr; |
3171 CHECK_EQ(expected, bt.call(*pl, *pr)); | 3167 CheckDoubleEq(expected, bt.call(*pl, *pr)); |
3172 } | 3168 } |
3173 } | 3169 } |
3174 } | 3170 } |
3175 | 3171 |
3176 | 3172 |
3177 TEST(RunFloat64ModP) { | 3173 TEST(RunFloat64ModP) { |
3178 RawMachineAssemblerTester<int32_t> m; | 3174 RawMachineAssemblerTester<int32_t> m; |
3179 Float64BinopTester bt(&m); | 3175 Float64BinopTester bt(&m); |
3180 | 3176 |
3181 bt.AddReturn(m.Float64Mod(bt.param0, bt.param1)); | 3177 bt.AddReturn(m.Float64Mod(bt.param0, bt.param1)); |
3182 | 3178 |
3183 FOR_FLOAT64_INPUTS(i) { | 3179 FOR_FLOAT64_INPUTS(i) { |
3184 FOR_FLOAT64_INPUTS(j) { | 3180 FOR_FLOAT64_INPUTS(j) { |
3185 double expected = modulo(*i, *j); | 3181 double expected = modulo(*i, *j); |
3186 double found = bt.call(*i, *j); | 3182 double found = bt.call(*i, *j); |
3187 CHECK_EQ(expected, found); | 3183 CheckDoubleEq(expected, found); |
3188 } | 3184 } |
3189 } | 3185 } |
3190 } | 3186 } |
3191 | 3187 |
3192 | 3188 |
3193 TEST(RunChangeInt32ToFloat64_A) { | 3189 TEST(RunChangeInt32ToFloat64_A) { |
3194 RawMachineAssemblerTester<int32_t> m; | 3190 RawMachineAssemblerTester<int32_t> m; |
3195 int32_t magic = 0x986234; | 3191 int32_t magic = 0x986234; |
3196 double result = 0; | 3192 double result = 0; |
3197 | 3193 |
(...skipping 18 matching lines...) Expand all Loading... |
3216 | 3212 |
3217 FOR_INT32_INPUTS(i) { | 3213 FOR_INT32_INPUTS(i) { |
3218 int32_t expect = *i; | 3214 int32_t expect = *i; |
3219 CHECK_EQ(expect, m.Call(expect)); | 3215 CHECK_EQ(expect, m.Call(expect)); |
3220 CHECK_EQ(static_cast<double>(expect), output); | 3216 CHECK_EQ(static_cast<double>(expect), output); |
3221 } | 3217 } |
3222 } | 3218 } |
3223 | 3219 |
3224 | 3220 |
3225 TEST(RunChangeUint32ToFloat64_B) { | 3221 TEST(RunChangeUint32ToFloat64_B) { |
3226 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 3222 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
3227 double output = 0; | 3223 double output = 0; |
3228 | 3224 |
3229 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0)); | 3225 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0)); |
3230 m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), | 3226 m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), |
3231 convert); | 3227 convert); |
3232 m.Return(m.Parameter(0)); | 3228 m.Return(m.Parameter(0)); |
3233 | 3229 |
3234 FOR_UINT32_INPUTS(i) { | 3230 FOR_UINT32_INPUTS(i) { |
3235 uint32_t expect = *i; | 3231 uint32_t expect = *i; |
3236 CHECK_EQ(expect, m.Call(expect)); | 3232 CHECK_EQ(expect, m.Call(expect)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3397 | 3393 |
3398 for (int i = 0; i < kNumInputs; i++) { | 3394 for (int i = 0; i < kNumInputs; i++) { |
3399 CHECK_EQ(result[i], 100 + i); | 3395 CHECK_EQ(result[i], 100 + i); |
3400 } | 3396 } |
3401 } | 3397 } |
3402 | 3398 |
3403 | 3399 |
3404 TEST(RunChangeFloat64ToUint32_spilled) { | 3400 TEST(RunChangeFloat64ToUint32_spilled) { |
3405 RawMachineAssemblerTester<uint32_t> m; | 3401 RawMachineAssemblerTester<uint32_t> m; |
3406 const int kNumInputs = 32; | 3402 const int kNumInputs = 32; |
3407 int32_t magic = 0x786234; | 3403 uint32_t magic = 0x786234; |
3408 double input[kNumInputs]; | 3404 double input[kNumInputs]; |
3409 uint32_t result[kNumInputs]; | 3405 uint32_t result[kNumInputs]; |
3410 Node* input_node[kNumInputs]; | 3406 Node* input_node[kNumInputs]; |
3411 | 3407 |
3412 for (int i = 0; i < kNumInputs; i++) { | 3408 for (int i = 0; i < kNumInputs; i++) { |
3413 input_node[i] = | 3409 input_node[i] = |
3414 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); | 3410 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); |
3415 } | 3411 } |
3416 | 3412 |
3417 for (int i = 0; i < kNumInputs; i++) { | 3413 for (int i = 0; i < kNumInputs; i++) { |
3418 m.Store(kMachUint32, m.PointerConstant(&result), m.Int32Constant(i * 4), | 3414 m.Store(kMachUint32, m.PointerConstant(&result), m.Int32Constant(i * 4), |
3419 m.ChangeFloat64ToUint32(input_node[i])); | 3415 m.ChangeFloat64ToUint32(input_node[i])); |
3420 } | 3416 } |
3421 | 3417 |
3422 m.Return(m.Int32Constant(magic)); | 3418 m.Return(m.Int32Constant(magic)); |
3423 | 3419 |
3424 for (int i = 0; i < kNumInputs; i++) { | 3420 for (int i = 0; i < kNumInputs; i++) { |
3425 if (i % 2) { | 3421 if (i % 2) { |
3426 input[i] = 100 + i + 2147483648u; | 3422 input[i] = 100 + i + 2147483648u; |
3427 } else { | 3423 } else { |
3428 input[i] = 100 + i; | 3424 input[i] = 100 + i; |
3429 } | 3425 } |
3430 } | 3426 } |
3431 | 3427 |
3432 CHECK_EQ(magic, m.Call()); | 3428 CHECK_EQ(magic, m.Call()); |
3433 | 3429 |
3434 for (int i = 0; i < kNumInputs; i++) { | 3430 for (int i = 0; i < kNumInputs; i++) { |
3435 if (i % 2) { | 3431 if (i % 2) { |
3436 CHECK_UINT32_EQ(result[i], static_cast<uint32_t>(100 + i + 2147483648u)); | 3432 CHECK_EQ(result[i], static_cast<uint32_t>(100 + i + 2147483648u)); |
3437 } else { | 3433 } else { |
3438 CHECK_UINT32_EQ(result[i], static_cast<uint32_t>(100 + i)); | 3434 CHECK_EQ(result[i], static_cast<uint32_t>(100 + i)); |
3439 } | 3435 } |
3440 } | 3436 } |
3441 } | 3437 } |
3442 | 3438 |
3443 | 3439 |
3444 TEST(RunTruncateFloat64ToFloat32_spilled) { | 3440 TEST(RunTruncateFloat64ToFloat32_spilled) { |
3445 RawMachineAssemblerTester<uint32_t> m; | 3441 RawMachineAssemblerTester<uint32_t> m; |
3446 const int kNumInputs = 32; | 3442 const int kNumInputs = 32; |
3447 int32_t magic = 0x786234; | 3443 uint32_t magic = 0x786234; |
3448 double input[kNumInputs]; | 3444 double input[kNumInputs]; |
3449 float result[kNumInputs]; | 3445 float result[kNumInputs]; |
3450 Node* input_node[kNumInputs]; | 3446 Node* input_node[kNumInputs]; |
3451 | 3447 |
3452 for (int i = 0; i < kNumInputs; i++) { | 3448 for (int i = 0; i < kNumInputs; i++) { |
3453 input_node[i] = | 3449 input_node[i] = |
3454 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); | 3450 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); |
3455 } | 3451 } |
3456 | 3452 |
3457 for (int i = 0; i < kNumInputs; i++) { | 3453 for (int i = 0; i < kNumInputs; i++) { |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4361 | 4357 |
4362 | 4358 |
4363 TEST(RunTruncateInt64ToInt32P) { | 4359 TEST(RunTruncateInt64ToInt32P) { |
4364 if (kPointerSize < 8) return; | 4360 if (kPointerSize < 8) return; |
4365 int64_t expected = -1; | 4361 int64_t expected = -1; |
4366 RawMachineAssemblerTester<int32_t> m; | 4362 RawMachineAssemblerTester<int32_t> m; |
4367 m.Return(m.TruncateInt64ToInt32(m.LoadFromPointer(&expected, kMachInt64))); | 4363 m.Return(m.TruncateInt64ToInt32(m.LoadFromPointer(&expected, kMachInt64))); |
4368 FOR_UINT32_INPUTS(i) { | 4364 FOR_UINT32_INPUTS(i) { |
4369 FOR_UINT32_INPUTS(j) { | 4365 FOR_UINT32_INPUTS(j) { |
4370 expected = (static_cast<uint64_t>(*j) << 32) | *i; | 4366 expected = (static_cast<uint64_t>(*j) << 32) | *i; |
4371 CHECK_UINT32_EQ(expected, m.Call()); | 4367 CHECK_EQ(static_cast<int32_t>(expected), m.Call()); |
4372 } | 4368 } |
4373 } | 4369 } |
4374 } | 4370 } |
4375 | 4371 |
4376 | 4372 |
4377 TEST(RunTruncateFloat64ToInt32P) { | 4373 TEST(RunTruncateFloat64ToInt32P) { |
4378 struct { | 4374 struct { |
4379 double from; | 4375 double from; |
4380 double raw; | 4376 double raw; |
4381 } kValues[] = {{0, 0}, | 4377 } kValues[] = {{0, 0}, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4497 double input = 0.0; | 4493 double input = 0.0; |
4498 RawMachineAssemblerTester<int32_t> m; | 4494 RawMachineAssemblerTester<int32_t> m; |
4499 m.StoreToPointer( | 4495 m.StoreToPointer( |
4500 &actual, kMachFloat32, | 4496 &actual, kMachFloat32, |
4501 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); | 4497 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); |
4502 m.Return(m.Int32Constant(0)); | 4498 m.Return(m.Int32Constant(0)); |
4503 FOR_FLOAT64_INPUTS(i) { | 4499 FOR_FLOAT64_INPUTS(i) { |
4504 input = *i; | 4500 input = *i; |
4505 volatile double expected = DoubleToFloat32(input); | 4501 volatile double expected = DoubleToFloat32(input); |
4506 CHECK_EQ(0, m.Call()); | 4502 CHECK_EQ(0, m.Call()); |
4507 CHECK_EQ(expected, actual); | 4503 CheckDoubleEq(expected, actual); |
4508 } | 4504 } |
4509 } | 4505 } |
4510 | 4506 |
4511 | 4507 |
4512 TEST(RunFloat32Constant) { | 4508 TEST(RunFloat32Constant) { |
4513 FOR_FLOAT32_INPUTS(i) { | 4509 FOR_FLOAT32_INPUTS(i) { |
4514 float expected = *i; | 4510 float expected = *i; |
4515 float actual = *i; | 4511 float actual = *i; |
4516 RawMachineAssemblerTester<int32_t> m; | 4512 RawMachineAssemblerTester<int32_t> m; |
4517 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); | 4513 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4682 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); | 4678 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); |
4683 m.Return(m.Int32Constant(0)); | 4679 m.Return(m.Int32Constant(0)); |
4684 for (size_t i = 0; i < arraysize(kValues); ++i) { | 4680 for (size_t i = 0; i < arraysize(kValues); ++i) { |
4685 input = kValues[i]; | 4681 input = kValues[i]; |
4686 CHECK_EQ(0, m.Call()); | 4682 CHECK_EQ(0, m.Call()); |
4687 double expected = round(kValues[i]); | 4683 double expected = round(kValues[i]); |
4688 CHECK_EQ(expected, result); | 4684 CHECK_EQ(expected, result); |
4689 } | 4685 } |
4690 } | 4686 } |
4691 #endif // V8_TURBOFAN_TARGET | 4687 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |