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 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1353 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
1354 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 1354 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
1355 {MachineType::Int64(), | 1355 {MachineType::Int64(), |
1356 kMips64Ld, | 1356 kMips64Ld, |
1357 kMips64Sd, | 1357 kMips64Sd, |
1358 &InstructionSelectorTest::Stream::IsInteger, | 1358 &InstructionSelectorTest::Stream::IsInteger, |
1359 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1359 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
1360 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1360 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
1361 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}}; | 1361 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}}; |
1362 | 1362 |
1363 | |
1364 const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { | 1363 const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { |
1365 {MachineType::Int8(), | 1364 {MachineType::Int8(), |
1366 kMips64Lb, | 1365 kMips64Lb, |
1367 kMips64Sb, | 1366 kMips64Sb, |
1368 &InstructionSelectorTest::Stream::IsInteger, | 1367 &InstructionSelectorTest::Stream::IsInteger, |
1369 {-65000, -55000, 32777, 55000, 65000}}, | 1368 {-65000, -55000, 32777, 55000, 65000}}, |
1370 {MachineType::Int8(), | 1369 {MachineType::Uint8(), |
1371 kMips64Lbu, | 1370 kMips64Lbu, |
1372 kMips64Sb, | 1371 kMips64Sb, |
1373 &InstructionSelectorTest::Stream::IsInteger, | 1372 &InstructionSelectorTest::Stream::IsInteger, |
1374 {-65000, -55000, 32777, 55000, 65000}}, | 1373 {-65000, -55000, 32777, 55000, 65000}}, |
1375 {MachineType::Int16(), | 1374 {MachineType::Int16(), |
1376 kMips64Lh, | 1375 kMips64Lh, |
1377 kMips64Sh, | 1376 kMips64Sh, |
1378 &InstructionSelectorTest::Stream::IsInteger, | 1377 &InstructionSelectorTest::Stream::IsInteger, |
1379 {-65000, -55000, 32777, 55000, 65000}}, | 1378 {-65000, -55000, 32777, 55000, 65000}}, |
1380 {MachineType::Int16(), | 1379 {MachineType::Uint16(), |
1381 kMips64Lhu, | 1380 kMips64Lhu, |
1382 kMips64Sh, | 1381 kMips64Sh, |
1383 &InstructionSelectorTest::Stream::IsInteger, | 1382 &InstructionSelectorTest::Stream::IsInteger, |
1384 {-65000, -55000, 32777, 55000, 65000}}, | 1383 {-65000, -55000, 32777, 55000, 65000}}, |
1385 {MachineType::Int32(), | 1384 {MachineType::Int32(), |
1386 kMips64Lw, | 1385 kMips64Lw, |
1387 kMips64Sw, | 1386 kMips64Sw, |
1388 &InstructionSelectorTest::Stream::IsInteger, | 1387 &InstructionSelectorTest::Stream::IsInteger, |
1389 {-65000, -55000, 32777, 55000, 65000}}, | 1388 {-65000, -55000, 32777, 55000, 65000}}, |
1390 {MachineType::Float32(), | 1389 {MachineType::Float32(), |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 typedef InstructionSelectorTestWithParam<MemoryAccessImm1> | 1593 typedef InstructionSelectorTestWithParam<MemoryAccessImm1> |
1595 InstructionSelectorMemoryAccessImmMoreThan16bitTest; | 1594 InstructionSelectorMemoryAccessImmMoreThan16bitTest; |
1596 | 1595 |
1597 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1596 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1598 LoadWithImmediateIndex) { | 1597 LoadWithImmediateIndex) { |
1599 const MemoryAccessImm1 memacc = GetParam(); | 1598 const MemoryAccessImm1 memacc = GetParam(); |
1600 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1599 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1601 StreamBuilder m(this, memacc.type, MachineType::Pointer()); | 1600 StreamBuilder m(this, memacc.type, MachineType::Pointer()); |
1602 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); | 1601 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); |
1603 Stream s = m.Build(); | 1602 Stream s = m.Build(); |
1604 ASSERT_EQ(2U, s.size()); | 1603 ASSERT_EQ(1U, s.size()); |
1605 // kMips64Dadd is expected opcode | 1604 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); |
1606 // size more than 16 bits wide | 1605 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1607 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); | |
1608 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | |
1609 EXPECT_EQ(2U, s[0]->InputCount()); | 1606 EXPECT_EQ(2U, s[0]->InputCount()); |
1610 EXPECT_EQ(1U, s[0]->OutputCount()); | 1607 EXPECT_EQ(1U, s[0]->OutputCount()); |
1611 } | 1608 } |
1612 } | 1609 } |
1613 | 1610 |
1614 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1611 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1615 StoreWithImmediateIndex) { | 1612 StoreWithImmediateIndex) { |
1616 const MemoryAccessImm1 memacc = GetParam(); | 1613 const MemoryAccessImm1 memacc = GetParam(); |
1617 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1614 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1618 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 1615 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
1619 memacc.type); | 1616 memacc.type); |
1620 m.Store(memacc.type.representation(), m.Parameter(0), | 1617 m.Store(memacc.type.representation(), m.Parameter(0), |
1621 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); | 1618 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); |
1622 m.Return(m.Int32Constant(0)); | 1619 m.Return(m.Int32Constant(0)); |
1623 Stream s = m.Build(); | 1620 Stream s = m.Build(); |
1624 ASSERT_EQ(2U, s.size()); | 1621 ASSERT_EQ(1U, s.size()); |
1625 // kMips64Add is expected opcode | 1622 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
1626 // size more than 16 bits wide | 1623 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1627 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); | 1624 EXPECT_EQ(3U, s[0]->InputCount()); |
1628 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1625 EXPECT_EQ(0U, s[0]->OutputCount()); |
1629 EXPECT_EQ(2U, s[0]->InputCount()); | |
1630 EXPECT_EQ(1U, s[0]->OutputCount()); | |
1631 } | 1626 } |
1632 } | 1627 } |
1633 | 1628 |
1634 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 1629 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
1635 InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1630 InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1636 ::testing::ValuesIn(kMemoryAccessImmMoreThan16bit)); | 1631 ::testing::ValuesIn(kMemoryAccessImmMoreThan16bit)); |
1637 | 1632 |
1638 | 1633 |
1639 // ---------------------------------------------------------------------------- | 1634 // ---------------------------------------------------------------------------- |
1640 // kMips64Cmp with zero testing. | 1635 // kMips64Cmp with zero testing. |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 #endif | 2006 #endif |
2012 | 2007 |
2013 ASSERT_EQ(1U, s[0]->OutputCount()); | 2008 ASSERT_EQ(1U, s[0]->OutputCount()); |
2014 } | 2009 } |
2015 } | 2010 } |
2016 } | 2011 } |
2017 | 2012 |
2018 } // namespace compiler | 2013 } // namespace compiler |
2019 } // namespace internal | 2014 } // namespace internal |
2020 } // namespace v8 | 2015 } // namespace v8 |
OLD | NEW |