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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "test/unittests/compiler/instruction-selector-unittest.h" | 7 #include "test/unittests/compiler/instruction-selector-unittest.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 1385 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
1386 memacc.type); | 1386 memacc.type); |
1387 m.Store(memacc.type.representation(), m.Parameter(0), | 1387 m.Store(memacc.type.representation(), m.Parameter(0), |
1388 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); | 1388 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); |
1389 m.Return(m.Int32Constant(0)); | 1389 m.Return(m.Int32Constant(0)); |
1390 Stream s = m.Build(); | 1390 Stream s = m.Build(); |
1391 ASSERT_EQ(1U, s.size()); | 1391 ASSERT_EQ(1U, s.size()); |
1392 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode()); | 1392 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode()); |
1393 EXPECT_EQ(kMode_Offset_RI, s[0]->addressing_mode()); | 1393 EXPECT_EQ(kMode_Offset_RI, s[0]->addressing_mode()); |
1394 ASSERT_EQ(3U, s[0]->InputCount()); | 1394 ASSERT_EQ(3U, s[0]->InputCount()); |
1395 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 1395 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(2)->kind()); |
1396 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); | 1396 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(2))); |
1397 EXPECT_EQ(0U, s[0]->OutputCount()); | 1397 EXPECT_EQ(0U, s[0]->OutputCount()); |
1398 } | 1398 } |
1399 } | 1399 } |
1400 | 1400 |
1401 | 1401 |
1402 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 1402 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
1403 InstructionSelectorMemoryAccessTest, | 1403 InstructionSelectorMemoryAccessTest, |
1404 ::testing::ValuesIn(kMemoryAccesses)); | 1404 ::testing::ValuesIn(kMemoryAccesses)); |
1405 | 1405 |
| 1406 TEST_F(InstructionSelectorMemoryAccessTest, LoadWithShiftedIndex) { |
| 1407 TRACED_FORRANGE(int, immediate_shift, 1, 31) { |
| 1408 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
| 1409 MachineType::Int32()); |
| 1410 Node* const index = |
| 1411 m.Word32Shl(m.Parameter(1), m.Int32Constant(immediate_shift)); |
| 1412 m.Return(m.Load(MachineType::Int32(), m.Parameter(0), index)); |
| 1413 Stream s = m.Build(); |
| 1414 ASSERT_EQ(1U, s.size()); |
| 1415 EXPECT_EQ(kArmLdr, s[0]->arch_opcode()); |
| 1416 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 1417 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1418 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1419 } |
| 1420 } |
| 1421 |
| 1422 TEST_F(InstructionSelectorMemoryAccessTest, StoreWithShiftedIndex) { |
| 1423 TRACED_FORRANGE(int, immediate_shift, 1, 31) { |
| 1424 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
| 1425 MachineType::Int32(), MachineType::Int32()); |
| 1426 Node* const index = |
| 1427 m.Word32Shl(m.Parameter(1), m.Int32Constant(immediate_shift)); |
| 1428 m.Store(MachineRepresentation::kWord32, m.Parameter(0), index, |
| 1429 m.Parameter(2), kNoWriteBarrier); |
| 1430 m.Return(m.Int32Constant(0)); |
| 1431 Stream s = m.Build(); |
| 1432 ASSERT_EQ(1U, s.size()); |
| 1433 EXPECT_EQ(kArmStr, s[0]->arch_opcode()); |
| 1434 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 1435 EXPECT_EQ(4U, s[0]->InputCount()); |
| 1436 EXPECT_EQ(0U, s[0]->OutputCount()); |
| 1437 } |
| 1438 } |
1406 | 1439 |
1407 // ----------------------------------------------------------------------------- | 1440 // ----------------------------------------------------------------------------- |
1408 // Conversions. | 1441 // Conversions. |
1409 | 1442 |
1410 | 1443 |
1411 TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { | 1444 TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { |
1412 StreamBuilder m(this, MachineType::Float64(), MachineType::Float32()); | 1445 StreamBuilder m(this, MachineType::Float64(), MachineType::Float32()); |
1413 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); | 1446 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); |
1414 Stream s = m.Build(); | 1447 Stream s = m.Build(); |
1415 ASSERT_EQ(1U, s.size()); | 1448 ASSERT_EQ(1U, s.size()); |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3022 ASSERT_EQ(2U, s[0]->InputCount()); | 3055 ASSERT_EQ(2U, s[0]->InputCount()); |
3023 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 3056 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
3024 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 3057 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
3025 ASSERT_EQ(1U, s[0]->OutputCount()); | 3058 ASSERT_EQ(1U, s[0]->OutputCount()); |
3026 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 3059 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
3027 } | 3060 } |
3028 | 3061 |
3029 } // namespace compiler | 3062 } // namespace compiler |
3030 } // namespace internal | 3063 } // namespace internal |
3031 } // namespace v8 | 3064 } // namespace v8 |
OLD | NEW |