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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 EXPECT_EQ(1U, s[0]->OutputCount()); | 249 EXPECT_EQ(1U, s[0]->OutputCount()); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { | 254 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { |
255 const MemoryAccess memacc = GetParam(); | 255 const MemoryAccess memacc = GetParam(); |
256 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 256 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
257 MachineType::Int32(), memacc.type); | 257 MachineType::Int32(), memacc.type); |
258 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2), | 258 m.Store(memacc.type.representation(), m.Parameter(0), m.Parameter(1), |
259 kNoWriteBarrier); | 259 m.Parameter(2), kNoWriteBarrier); |
260 m.Return(m.Int32Constant(0)); | 260 m.Return(m.Int32Constant(0)); |
261 Stream s = m.Build(); | 261 Stream s = m.Build(); |
262 ASSERT_EQ(1U, s.size()); | 262 ASSERT_EQ(1U, s.size()); |
263 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); | 263 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
264 EXPECT_EQ(3U, s[0]->InputCount()); | 264 EXPECT_EQ(3U, s[0]->InputCount()); |
265 EXPECT_EQ(0U, s[0]->OutputCount()); | 265 EXPECT_EQ(0U, s[0]->OutputCount()); |
266 } | 266 } |
267 | 267 |
268 | 268 |
269 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateBase) { | 269 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateBase) { |
270 const MemoryAccess memacc = GetParam(); | 270 const MemoryAccess memacc = GetParam(); |
271 TRACED_FOREACH(int32_t, base, kImmediates) { | 271 TRACED_FOREACH(int32_t, base, kImmediates) { |
272 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), | 272 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
273 memacc.type); | 273 memacc.type); |
274 m.Store(memacc.type, m.Int32Constant(base), m.Parameter(0), m.Parameter(1), | 274 m.Store(memacc.type.representation(), m.Int32Constant(base), m.Parameter(0), |
275 kNoWriteBarrier); | 275 m.Parameter(1), kNoWriteBarrier); |
276 m.Return(m.Int32Constant(0)); | 276 m.Return(m.Int32Constant(0)); |
277 Stream s = m.Build(); | 277 Stream s = m.Build(); |
278 ASSERT_EQ(1U, s.size()); | 278 ASSERT_EQ(1U, s.size()); |
279 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); | 279 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
280 if (base == 0) { | 280 if (base == 0) { |
281 ASSERT_EQ(2U, s[0]->InputCount()); | 281 ASSERT_EQ(2U, s[0]->InputCount()); |
282 } else { | 282 } else { |
283 ASSERT_EQ(3U, s[0]->InputCount()); | 283 ASSERT_EQ(3U, s[0]->InputCount()); |
284 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 284 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
285 EXPECT_EQ(base, s.ToInt32(s[0]->InputAt(1))); | 285 EXPECT_EQ(base, s.ToInt32(s[0]->InputAt(1))); |
286 } | 286 } |
287 EXPECT_EQ(0U, s[0]->OutputCount()); | 287 EXPECT_EQ(0U, s[0]->OutputCount()); |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) { | 292 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) { |
293 const MemoryAccess memacc = GetParam(); | 293 const MemoryAccess memacc = GetParam(); |
294 TRACED_FOREACH(int32_t, index, kImmediates) { | 294 TRACED_FOREACH(int32_t, index, kImmediates) { |
295 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 295 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
296 memacc.type); | 296 memacc.type); |
297 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), | 297 m.Store(memacc.type.representation(), m.Parameter(0), |
298 kNoWriteBarrier); | 298 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); |
299 m.Return(m.Int32Constant(0)); | 299 m.Return(m.Int32Constant(0)); |
300 Stream s = m.Build(); | 300 Stream s = m.Build(); |
301 ASSERT_EQ(1U, s.size()); | 301 ASSERT_EQ(1U, s.size()); |
302 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); | 302 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
303 if (index == 0) { | 303 if (index == 0) { |
304 ASSERT_EQ(2U, s[0]->InputCount()); | 304 ASSERT_EQ(2U, s[0]->InputCount()); |
305 } else { | 305 } else { |
306 ASSERT_EQ(3U, s[0]->InputCount()); | 306 ASSERT_EQ(3U, s[0]->InputCount()); |
307 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 307 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
308 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); | 308 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); |
(...skipping 13 matching lines...) Expand all Loading... |
322 | 322 |
323 | 323 |
324 class AddressingModeUnitTest : public InstructionSelectorTest { | 324 class AddressingModeUnitTest : public InstructionSelectorTest { |
325 public: | 325 public: |
326 AddressingModeUnitTest() : m(NULL) { Reset(); } | 326 AddressingModeUnitTest() : m(NULL) { Reset(); } |
327 ~AddressingModeUnitTest() { delete m; } | 327 ~AddressingModeUnitTest() { delete m; } |
328 | 328 |
329 void Run(Node* base, Node* load_index, Node* store_index, | 329 void Run(Node* base, Node* load_index, Node* store_index, |
330 AddressingMode mode) { | 330 AddressingMode mode) { |
331 Node* load = m->Load(MachineType::Int32(), base, load_index); | 331 Node* load = m->Load(MachineType::Int32(), base, load_index); |
332 m->Store(MachineType::Int32(), base, store_index, load, kNoWriteBarrier); | 332 m->Store(MachineRepresentation::kWord32, base, store_index, load, |
| 333 kNoWriteBarrier); |
333 m->Return(m->Int32Constant(0)); | 334 m->Return(m->Int32Constant(0)); |
334 Stream s = m->Build(); | 335 Stream s = m->Build(); |
335 ASSERT_EQ(2U, s.size()); | 336 ASSERT_EQ(2U, s.size()); |
336 EXPECT_EQ(mode, s[0]->addressing_mode()); | 337 EXPECT_EQ(mode, s[0]->addressing_mode()); |
337 EXPECT_EQ(mode, s[1]->addressing_mode()); | 338 EXPECT_EQ(mode, s[1]->addressing_mode()); |
338 } | 339 } |
339 | 340 |
340 Node* zero; | 341 Node* zero; |
341 Node* null_ptr; | 342 Node* null_ptr; |
342 Node* non_zero; | 343 Node* non_zero; |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); | 849 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); |
849 ASSERT_EQ(1U, s[0]->InputCount()); | 850 ASSERT_EQ(1U, s[0]->InputCount()); |
850 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 851 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
851 ASSERT_EQ(1U, s[0]->OutputCount()); | 852 ASSERT_EQ(1U, s[0]->OutputCount()); |
852 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 853 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
853 } | 854 } |
854 | 855 |
855 } // namespace compiler | 856 } // namespace compiler |
856 } // namespace internal | 857 } // namespace internal |
857 } // namespace v8 | 858 } // namespace v8 |
OLD | NEW |