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 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 Stream s = m.Build(); | 1511 Stream s = m.Build(); |
1512 ASSERT_EQ(1U, s.size()); | 1512 ASSERT_EQ(1U, s.size()); |
1513 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); | 1513 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); |
1514 EXPECT_EQ(2U, s[0]->InputCount()); | 1514 EXPECT_EQ(2U, s[0]->InputCount()); |
1515 EXPECT_EQ(1U, s[0]->OutputCount()); | 1515 EXPECT_EQ(1U, s[0]->OutputCount()); |
1516 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1516 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
1517 EXPECT_EQ(cmp.cond, s[0]->flags_condition()); | 1517 EXPECT_EQ(cmp.cond, s[0]->flags_condition()); |
1518 } | 1518 } |
1519 | 1519 |
1520 | 1520 |
| 1521 TEST_P(InstructionSelectorFPCmpTest, WithImmediateZeroOnRight) { |
| 1522 const FPCmp cmp = GetParam(); |
| 1523 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type); |
| 1524 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Float64Constant(0.0))); |
| 1525 Stream s = m.Build(); |
| 1526 ASSERT_EQ(1U, s.size()); |
| 1527 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); |
| 1528 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1529 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 1530 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1531 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1532 EXPECT_EQ(cmp.cond, s[0]->flags_condition()); |
| 1533 } |
| 1534 |
| 1535 |
1521 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFPCmpTest, | 1536 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFPCmpTest, |
1522 ::testing::ValuesIn(kFPCmpInstructions)); | 1537 ::testing::ValuesIn(kFPCmpInstructions)); |
1523 | 1538 |
1524 | 1539 |
| 1540 TEST_F(InstructionSelectorTest, Float64EqualWithImmediateZeroOnLeft) { |
| 1541 StreamBuilder m(this, kMachInt32, kMachFloat64); |
| 1542 m.Return(m.Float64Equal(m.Float64Constant(0.0), m.Parameter(0))); |
| 1543 Stream s = m.Build(); |
| 1544 ASSERT_EQ(1U, s.size()); |
| 1545 EXPECT_EQ(kArm64Float64Cmp, s[0]->arch_opcode()); |
| 1546 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1547 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 1548 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1549 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1550 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1551 } |
| 1552 |
| 1553 |
1525 // ----------------------------------------------------------------------------- | 1554 // ----------------------------------------------------------------------------- |
1526 // Conversions. | 1555 // Conversions. |
1527 | 1556 |
1528 typedef InstructionSelectorTestWithParam<Conversion> | 1557 typedef InstructionSelectorTestWithParam<Conversion> |
1529 InstructionSelectorConversionTest; | 1558 InstructionSelectorConversionTest; |
1530 | 1559 |
1531 | 1560 |
1532 TEST_P(InstructionSelectorConversionTest, Parameter) { | 1561 TEST_P(InstructionSelectorConversionTest, Parameter) { |
1533 const Conversion conv = GetParam(); | 1562 const Conversion conv = GetParam(); |
1534 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); | 1563 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 ASSERT_EQ(1U, s[0]->InputCount()); | 2196 ASSERT_EQ(1U, s[0]->InputCount()); |
2168 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2197 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
2169 ASSERT_EQ(1U, s[0]->OutputCount()); | 2198 ASSERT_EQ(1U, s[0]->OutputCount()); |
2170 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2199 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
2171 } | 2200 } |
2172 } | 2201 } |
2173 | 2202 |
2174 } // namespace compiler | 2203 } // namespace compiler |
2175 } // namespace internal | 2204 } // namespace internal |
2176 } // namespace v8 | 2205 } // namespace v8 |
OLD | NEW |