| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 "TruncateFloat64ToFloat32", kArm64Float64ToFloat32, | 307 "TruncateFloat64ToFloat32", kArm64Float64ToFloat32, |
| 308 MachineType::Float32()}, | 308 MachineType::Float32()}, |
| 309 MachineType::Float64()}, | 309 MachineType::Float64()}, |
| 310 {{&RawMachineAssembler::ChangeInt32ToInt64, "ChangeInt32ToInt64", | 310 {{&RawMachineAssembler::ChangeInt32ToInt64, "ChangeInt32ToInt64", |
| 311 kArm64Sxtw, MachineType::Int64()}, | 311 kArm64Sxtw, MachineType::Int64()}, |
| 312 MachineType::Int32()}, | 312 MachineType::Int32()}, |
| 313 {{&RawMachineAssembler::ChangeUint32ToUint64, "ChangeUint32ToUint64", | 313 {{&RawMachineAssembler::ChangeUint32ToUint64, "ChangeUint32ToUint64", |
| 314 kArm64Mov32, MachineType::Uint64()}, | 314 kArm64Mov32, MachineType::Uint64()}, |
| 315 MachineType::Uint32()}, | 315 MachineType::Uint32()}, |
| 316 {{&RawMachineAssembler::TruncateInt64ToInt32, "TruncateInt64ToInt32", | 316 {{&RawMachineAssembler::TruncateInt64ToInt32, "TruncateInt64ToInt32", |
| 317 kArm64Mov32, MachineType::Int32()}, | 317 kArchNop, MachineType::Int32()}, |
| 318 MachineType::Int64()}, | 318 MachineType::Int64()}, |
| 319 {{&RawMachineAssembler::ChangeInt32ToFloat64, "ChangeInt32ToFloat64", | 319 {{&RawMachineAssembler::ChangeInt32ToFloat64, "ChangeInt32ToFloat64", |
| 320 kArm64Int32ToFloat64, MachineType::Float64()}, | 320 kArm64Int32ToFloat64, MachineType::Float64()}, |
| 321 MachineType::Int32()}, | 321 MachineType::Int32()}, |
| 322 {{&RawMachineAssembler::ChangeUint32ToFloat64, "ChangeUint32ToFloat64", | 322 {{&RawMachineAssembler::ChangeUint32ToFloat64, "ChangeUint32ToFloat64", |
| 323 kArm64Uint32ToFloat64, MachineType::Float64()}, | 323 kArm64Uint32ToFloat64, MachineType::Float64()}, |
| 324 MachineType::Uint32()}, | 324 MachineType::Uint32()}, |
| 325 {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", | 325 {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", |
| 326 kArm64Float64ToInt32, MachineType::Int32()}, | 326 kArm64Float64ToInt32, MachineType::Int32()}, |
| 327 MachineType::Float64()}, | 327 MachineType::Float64()}, |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1792 } | 1792 } |
| 1793 | 1793 |
| 1794 | 1794 |
| 1795 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) { | 1795 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) { |
| 1796 StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); | 1796 StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); |
| 1797 Node* const p = m.Parameter(0); | 1797 Node* const p = m.Parameter(0); |
| 1798 Node* const t = m.TruncateInt64ToInt32(m.Word64Sar(p, m.Int64Constant(32))); | 1798 Node* const t = m.TruncateInt64ToInt32(m.Word64Sar(p, m.Int64Constant(32))); |
| 1799 m.Return(t); | 1799 m.Return(t); |
| 1800 Stream s = m.Build(); | 1800 Stream s = m.Build(); |
| 1801 ASSERT_EQ(1U, s.size()); | 1801 ASSERT_EQ(1U, s.size()); |
| 1802 EXPECT_EQ(kArm64Lsr, s[0]->arch_opcode()); | 1802 EXPECT_EQ(kArm64Asr, s[0]->arch_opcode()); |
| 1803 ASSERT_EQ(2U, s[0]->InputCount()); | 1803 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1804 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0))); | 1804 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0))); |
| 1805 EXPECT_EQ(32, s.ToInt64(s[0]->InputAt(1))); | 1805 EXPECT_EQ(32, s.ToInt64(s[0]->InputAt(1))); |
| 1806 ASSERT_EQ(1U, s[0]->OutputCount()); | 1806 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1807 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0))); | |
| 1808 } | 1807 } |
| 1809 | 1808 |
| 1810 | 1809 |
| 1811 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) { | 1810 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) { |
| 1812 TRACED_FORRANGE(int64_t, x, 32, 63) { | 1811 TRACED_FORRANGE(int64_t, x, 32, 63) { |
| 1813 StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); | 1812 StreamBuilder m(this, MachineType::Int32(), MachineType::Int64()); |
| 1814 Node* const p = m.Parameter(0); | 1813 Node* const p = m.Parameter(0); |
| 1815 Node* const t = m.TruncateInt64ToInt32(m.Word64Shr(p, m.Int64Constant(x))); | 1814 Node* const t = m.TruncateInt64ToInt32(m.Word64Shr(p, m.Int64Constant(x))); |
| 1816 m.Return(t); | 1815 m.Return(t); |
| 1817 Stream s = m.Build(); | 1816 Stream s = m.Build(); |
| 1818 ASSERT_EQ(1U, s.size()); | 1817 ASSERT_EQ(1U, s.size()); |
| 1819 EXPECT_EQ(kArm64Lsr, s[0]->arch_opcode()); | 1818 EXPECT_EQ(kArm64Lsr, s[0]->arch_opcode()); |
| 1820 ASSERT_EQ(2U, s[0]->InputCount()); | 1819 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1821 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0))); | 1820 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0))); |
| 1822 EXPECT_EQ(x, s.ToInt64(s[0]->InputAt(1))); | 1821 EXPECT_EQ(x, s.ToInt64(s[0]->InputAt(1))); |
| 1823 ASSERT_EQ(1U, s[0]->OutputCount()); | 1822 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1824 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0))); | |
| 1825 } | 1823 } |
| 1826 } | 1824 } |
| 1827 | 1825 |
| 1828 | 1826 |
| 1829 // ----------------------------------------------------------------------------- | 1827 // ----------------------------------------------------------------------------- |
| 1830 // Mul and Div instructions. | 1828 // Mul and Div instructions. |
| 1831 | 1829 |
| 1832 | 1830 |
| 1833 typedef InstructionSelectorTestWithParam<MachInst2> | 1831 typedef InstructionSelectorTestWithParam<MachInst2> |
| 1834 InstructionSelectorMulDivTest; | 1832 InstructionSelectorMulDivTest; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 | 2310 |
| 2313 typedef InstructionSelectorTestWithParam<Conversion> | 2311 typedef InstructionSelectorTestWithParam<Conversion> |
| 2314 InstructionSelectorConversionTest; | 2312 InstructionSelectorConversionTest; |
| 2315 | 2313 |
| 2316 | 2314 |
| 2317 TEST_P(InstructionSelectorConversionTest, Parameter) { | 2315 TEST_P(InstructionSelectorConversionTest, Parameter) { |
| 2318 const Conversion conv = GetParam(); | 2316 const Conversion conv = GetParam(); |
| 2319 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); | 2317 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); |
| 2320 m.Return((m.*conv.mi.constructor)(m.Parameter(0))); | 2318 m.Return((m.*conv.mi.constructor)(m.Parameter(0))); |
| 2321 Stream s = m.Build(); | 2319 Stream s = m.Build(); |
| 2320 if (conv.mi.arch_opcode == kArchNop) { |
| 2321 ASSERT_EQ(0U, s.size()); |
| 2322 return; |
| 2323 } |
| 2322 ASSERT_EQ(1U, s.size()); | 2324 ASSERT_EQ(1U, s.size()); |
| 2323 EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode()); | 2325 EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode()); |
| 2324 EXPECT_EQ(1U, s[0]->InputCount()); | 2326 EXPECT_EQ(1U, s[0]->InputCount()); |
| 2325 EXPECT_EQ(1U, s[0]->OutputCount()); | 2327 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2326 } | 2328 } |
| 2327 | 2329 |
| 2328 | 2330 |
| 2329 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 2331 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
| 2330 InstructionSelectorConversionTest, | 2332 InstructionSelectorConversionTest, |
| 2331 ::testing::ValuesIn(kConversionInstructions)); | 2333 ::testing::ValuesIn(kConversionInstructions)); |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4280 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); | 4282 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); |
| 4281 ASSERT_EQ(1U, s[0]->InputCount()); | 4283 ASSERT_EQ(1U, s[0]->InputCount()); |
| 4282 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 4284 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 4283 ASSERT_EQ(1U, s[0]->OutputCount()); | 4285 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 4284 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 4286 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 4285 } | 4287 } |
| 4286 | 4288 |
| 4287 } // namespace compiler | 4289 } // namespace compiler |
| 4288 } // namespace internal | 4290 } // namespace internal |
| 4289 } // namespace v8 | 4291 } // namespace v8 |
| OLD | NEW |