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

Side by Side Diff: test/unittests/compiler/mips/instruction-selector-mips-unittest.cc

Issue 2470133005: MIPS[64]: Port '[turbofan] Use zr to store immediate zero' (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file 3 // found in the LICENSE file
4 4
5 #include "test/unittests/compiler/instruction-selector-unittest.h" 5 #include "test/unittests/compiler/instruction-selector-unittest.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 bool (InstructionSelectorTest::Stream::*val_predicate)( 852 bool (InstructionSelectorTest::Stream::*val_predicate)(
853 const InstructionOperand*) const; 853 const InstructionOperand*) const;
854 const int32_t immediates[5]; 854 const int32_t immediates[5];
855 }; 855 };
856 856
857 857
858 std::ostream& operator<<(std::ostream& os, const MemoryAccessImm1& acc) { 858 std::ostream& operator<<(std::ostream& os, const MemoryAccessImm1& acc) {
859 return os << acc.type; 859 return os << acc.type;
860 } 860 }
861 861
862 struct MemoryAccessImm2 {
863 MachineType type;
864 ArchOpcode store_opcode;
865 ArchOpcode store_opcode_unaligned;
866 bool (InstructionSelectorTest::Stream::*val_predicate)(
867 const InstructionOperand*) const;
868 const int32_t immediates[40];
869 };
870
871 std::ostream& operator<<(std::ostream& os, const MemoryAccessImm2& acc) {
872 return os << acc.type;
873 }
862 874
863 // ---------------------------------------------------------------------------- 875 // ----------------------------------------------------------------------------
864 // Loads and stores immediate values. 876 // Loads and stores immediate values.
865 // ---------------------------------------------------------------------------- 877 // ----------------------------------------------------------------------------
866 878
867 879
868 const MemoryAccessImm kMemoryAccessesImm[] = { 880 const MemoryAccessImm kMemoryAccessesImm[] = {
869 {MachineType::Int8(), 881 {MachineType::Int8(),
870 kMipsLb, 882 kMipsLb,
871 kMipsSb, 883 kMipsSb,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 kMipsLwc1, 959 kMipsLwc1,
948 kMipsSwc1, 960 kMipsSwc1,
949 &InstructionSelectorTest::Stream::IsDouble, 961 &InstructionSelectorTest::Stream::IsDouble,
950 {-65000, -55000, 32777, 55000, 65000}}, 962 {-65000, -55000, 32777, 55000, 65000}},
951 {MachineType::Float64(), 963 {MachineType::Float64(),
952 kMipsLdc1, 964 kMipsLdc1,
953 kMipsSdc1, 965 kMipsSdc1,
954 &InstructionSelectorTest::Stream::IsDouble, 966 &InstructionSelectorTest::Stream::IsDouble,
955 {-65000, -55000, 32777, 55000, 65000}}}; 967 {-65000, -55000, 32777, 55000, 65000}}};
956 968
969 const MemoryAccessImm2 kMemoryAccessesImmUnaligned[] = {
970 {MachineType::Int16(),
971 kMipsUsh,
972 kMipsSh,
973 &InstructionSelectorTest::Stream::IsInteger,
974 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91,
975 -89, -87, -86, -82, -44, -23, -3, 0, 7, 10,
976 39, 52, 69, 71, 91, 92, 107, 109, 115, 124,
977 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}},
978 {MachineType::Int32(),
979 kMipsUsw,
980 kMipsSw,
981 &InstructionSelectorTest::Stream::IsInteger,
982 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91,
983 -89, -87, -86, -82, -44, -23, -3, 0, 7, 10,
984 39, 52, 69, 71, 91, 92, 107, 109, 115, 124,
985 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}},
986 {MachineType::Float32(),
987 kMipsUswc1,
988 kMipsSwc1,
989 &InstructionSelectorTest::Stream::IsDouble,
990 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91,
991 -89, -87, -86, -82, -44, -23, -3, 0, 7, 10,
992 39, 52, 69, 71, 91, 92, 107, 109, 115, 124,
993 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}},
994 {MachineType::Float64(),
995 kMipsUsdc1,
996 kMipsSdc1,
997 &InstructionSelectorTest::Stream::IsDouble,
998 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91,
999 -89, -87, -86, -82, -44, -23, -3, 0, 7, 10,
1000 39, 52, 69, 71, 91, 92, 107, 109, 115, 124,
1001 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}};
1002
957 } // namespace 1003 } // namespace
958 1004
959 1005
960 typedef InstructionSelectorTestWithParam<MemoryAccess> 1006 typedef InstructionSelectorTestWithParam<MemoryAccess>
961 InstructionSelectorMemoryAccessTest; 1007 InstructionSelectorMemoryAccessTest;
962 1008
963 1009
964 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { 1010 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) {
965 const MemoryAccess memacc = GetParam(); 1011 const MemoryAccess memacc = GetParam();
966 StreamBuilder m(this, memacc.type, MachineType::Pointer(), 1012 StreamBuilder m(this, memacc.type, MachineType::Pointer(),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 ASSERT_EQ(1U, s.size()); 1082 ASSERT_EQ(1U, s.size());
1037 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); 1083 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
1038 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); 1084 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
1039 ASSERT_EQ(3U, s[0]->InputCount()); 1085 ASSERT_EQ(3U, s[0]->InputCount());
1040 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); 1086 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
1041 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); 1087 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
1042 EXPECT_EQ(0U, s[0]->OutputCount()); 1088 EXPECT_EQ(0U, s[0]->OutputCount());
1043 } 1089 }
1044 } 1090 }
1045 1091
1092 TEST_P(InstructionSelectorMemoryAccessImmTest, StoreZero) {
1093 const MemoryAccessImm memacc = GetParam();
1094 TRACED_FOREACH(int32_t, index, memacc.immediates) {
1095 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer());
1096 m.Store(memacc.type.representation(), m.Parameter(0),
1097 m.Int32Constant(index), m.Int32Constant(0), kNoWriteBarrier);
1098 m.Return(m.Int32Constant(0));
1099 Stream s = m.Build();
1100 ASSERT_EQ(1U, s.size());
1101 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
1102 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
1103 ASSERT_EQ(3U, s[0]->InputCount());
1104 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
1105 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
1106 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(2)->kind());
1107 EXPECT_EQ(0, s.ToInt64(s[0]->InputAt(2)));
1108 EXPECT_EQ(0U, s[0]->OutputCount());
1109 }
1110 }
1046 1111
1047 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 1112 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
1048 InstructionSelectorMemoryAccessImmTest, 1113 InstructionSelectorMemoryAccessImmTest,
1049 ::testing::ValuesIn(kMemoryAccessesImm)); 1114 ::testing::ValuesIn(kMemoryAccessesImm));
1050 1115
1116 typedef InstructionSelectorTestWithParam<MemoryAccessImm2>
1117 InstructionSelectorMemoryAccessUnalignedImmTest;
1118
1119 TEST_P(InstructionSelectorMemoryAccessUnalignedImmTest, StoreZero) {
1120 const MemoryAccessImm2 memacc = GetParam();
1121 TRACED_FOREACH(int32_t, index, memacc.immediates) {
1122 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer());
1123 bool unaligned_store_supported = m.machine()->UnalignedStoreSupported(
1124 MachineType::TypeForRepresentation(memacc.type.representation()), 1);
1125 m.UnalignedStore(memacc.type.representation(), m.Parameter(0),
1126 m.Int32Constant(index), m.Int32Constant(0));
1127 m.Return(m.Int32Constant(0));
1128 Stream s = m.Build();
1129 ASSERT_EQ(1U, s.size());
1130 EXPECT_EQ(unaligned_store_supported ? memacc.store_opcode_unaligned
1131 : memacc.store_opcode,
1132 s[0]->arch_opcode());
1133 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
1134 ASSERT_EQ(3U, s[0]->InputCount());
1135 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
1136 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
1137 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(2)->kind());
1138 EXPECT_EQ(0, s.ToInt64(s[0]->InputAt(2)));
1139 EXPECT_EQ(0U, s[0]->OutputCount());
1140 }
1141 }
1142
1143 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
1144 InstructionSelectorMemoryAccessUnalignedImmTest,
1145 ::testing::ValuesIn(kMemoryAccessesImmUnaligned));
1051 1146
1052 // ---------------------------------------------------------------------------- 1147 // ----------------------------------------------------------------------------
1053 // Load/store offsets more than 16 bits. 1148 // Load/store offsets more than 16 bits.
1054 // ---------------------------------------------------------------------------- 1149 // ----------------------------------------------------------------------------
1055 1150
1056 1151
1057 typedef InstructionSelectorTestWithParam<MemoryAccessImm1> 1152 typedef InstructionSelectorTestWithParam<MemoryAccessImm1>
1058 InstructionSelectorMemoryAccessImmMoreThan16bitTest; 1153 InstructionSelectorMemoryAccessImmMoreThan16bitTest;
1059 1154
1060 1155
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 ASSERT_EQ(1U, s.size()); 1515 ASSERT_EQ(1U, s.size());
1421 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); 1516 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode());
1422 ASSERT_EQ(2U, s[0]->InputCount()); 1517 ASSERT_EQ(2U, s[0]->InputCount());
1423 ASSERT_EQ(1U, s[0]->OutputCount()); 1518 ASSERT_EQ(1U, s[0]->OutputCount());
1424 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 1519 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1425 } 1520 }
1426 1521
1427 } // namespace compiler 1522 } // namespace compiler
1428 } // namespace internal 1523 } // namespace internal
1429 } // namespace v8 1524 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698