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 "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 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 ASSERT_EQ(1U, s.size()); | 1098 ASSERT_EQ(1U, s.size()); |
1099 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); | 1099 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); |
1100 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); | 1100 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1101 } | 1101 } |
1102 | 1102 |
1103 | 1103 |
1104 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { | 1104 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { |
1105 const MemoryAccess memacc = GetParam(); | 1105 const MemoryAccess memacc = GetParam(); |
1106 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 1106 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
1107 MachineType::Int32(), memacc.type); | 1107 MachineType::Int32(), memacc.type); |
1108 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), kNoWriteBarrier); | 1108 m.Store(memacc.type.representation(), m.Parameter(0), m.Parameter(1), |
| 1109 kNoWriteBarrier); |
1109 m.Return(m.Int32Constant(0)); | 1110 m.Return(m.Int32Constant(0)); |
1110 Stream s = m.Build(); | 1111 Stream s = m.Build(); |
1111 ASSERT_EQ(1U, s.size()); | 1112 ASSERT_EQ(1U, s.size()); |
1112 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); | 1113 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
1113 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); | 1114 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1114 } | 1115 } |
1115 | 1116 |
1116 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 1117 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
1117 InstructionSelectorMemoryAccessTest, | 1118 InstructionSelectorMemoryAccessTest, |
1118 ::testing::ValuesIn(kMemoryAccesses)); | 1119 ::testing::ValuesIn(kMemoryAccesses)); |
(...skipping 28 matching lines...) Expand all Loading... |
1147 // ---------------------------------------------------------------------------- | 1148 // ---------------------------------------------------------------------------- |
1148 // Store immediate. | 1149 // Store immediate. |
1149 // ---------------------------------------------------------------------------- | 1150 // ---------------------------------------------------------------------------- |
1150 | 1151 |
1151 | 1152 |
1152 TEST_P(InstructionSelectorMemoryAccessImmTest, StoreWithImmediateIndex) { | 1153 TEST_P(InstructionSelectorMemoryAccessImmTest, StoreWithImmediateIndex) { |
1153 const MemoryAccessImm memacc = GetParam(); | 1154 const MemoryAccessImm memacc = GetParam(); |
1154 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1155 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1155 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 1156 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
1156 memacc.type); | 1157 memacc.type); |
1157 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), | 1158 m.Store(memacc.type.representation(), m.Parameter(0), |
1158 kNoWriteBarrier); | 1159 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); |
1159 m.Return(m.Int32Constant(0)); | 1160 m.Return(m.Int32Constant(0)); |
1160 Stream s = m.Build(); | 1161 Stream s = m.Build(); |
1161 ASSERT_EQ(1U, s.size()); | 1162 ASSERT_EQ(1U, s.size()); |
1162 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); | 1163 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
1163 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); | 1164 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1164 ASSERT_EQ(3U, s[0]->InputCount()); | 1165 ASSERT_EQ(3U, s[0]->InputCount()); |
1165 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 1166 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
1166 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); | 1167 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); |
1167 EXPECT_EQ(0U, s[0]->OutputCount()); | 1168 EXPECT_EQ(0U, s[0]->OutputCount()); |
1168 } | 1169 } |
(...skipping 28 matching lines...) Expand all Loading... |
1197 EXPECT_EQ(1U, s[0]->OutputCount()); | 1198 EXPECT_EQ(1U, s[0]->OutputCount()); |
1198 } | 1199 } |
1199 } | 1200 } |
1200 | 1201 |
1201 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1202 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1202 StoreWithImmediateIndex) { | 1203 StoreWithImmediateIndex) { |
1203 const MemoryAccessImm1 memacc = GetParam(); | 1204 const MemoryAccessImm1 memacc = GetParam(); |
1204 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1205 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1205 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 1206 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
1206 memacc.type); | 1207 memacc.type); |
1207 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), | 1208 m.Store(memacc.type.representation(), m.Parameter(0), |
1208 kNoWriteBarrier); | 1209 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); |
1209 m.Return(m.Int32Constant(0)); | 1210 m.Return(m.Int32Constant(0)); |
1210 Stream s = m.Build(); | 1211 Stream s = m.Build(); |
1211 ASSERT_EQ(2U, s.size()); | 1212 ASSERT_EQ(2U, s.size()); |
1212 // kMips64Add is expected opcode | 1213 // kMips64Add is expected opcode |
1213 // size more than 16 bits wide | 1214 // size more than 16 bits wide |
1214 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); | 1215 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); |
1215 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1216 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
1216 EXPECT_EQ(2U, s[0]->InputCount()); | 1217 EXPECT_EQ(2U, s[0]->InputCount()); |
1217 EXPECT_EQ(1U, s[0]->OutputCount()); | 1218 EXPECT_EQ(1U, s[0]->OutputCount()); |
1218 } | 1219 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 ASSERT_EQ(1U, s.size()); | 1408 ASSERT_EQ(1U, s.size()); |
1408 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); | 1409 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); |
1409 ASSERT_EQ(2U, s[0]->InputCount()); | 1410 ASSERT_EQ(2U, s[0]->InputCount()); |
1410 ASSERT_EQ(1U, s[0]->OutputCount()); | 1411 ASSERT_EQ(1U, s[0]->OutputCount()); |
1411 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1412 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1412 } | 1413 } |
1413 | 1414 |
1414 } // namespace compiler | 1415 } // namespace compiler |
1415 } // namespace internal | 1416 } // namespace internal |
1416 } // namespace v8 | 1417 } // namespace v8 |
OLD | NEW |