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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); | 615 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); |
616 ASSERT_EQ(3U, s[0]->InputCount()); | 616 ASSERT_EQ(3U, s[0]->InputCount()); |
617 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); | 617 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); |
618 int64_t actual_width = (lsb + width > 64) ? (64 - lsb) : width; | 618 int64_t actual_width = (lsb + width > 64) ? (64 - lsb) : width; |
619 EXPECT_EQ(actual_width, s.ToInt64(s[0]->InputAt(2))); | 619 EXPECT_EQ(actual_width, s.ToInt64(s[0]->InputAt(2))); |
620 } | 620 } |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
624 | 624 |
| 625 TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { |
| 626 TRACED_FORRANGE(int32_t, shift, 0, 30) { |
| 627 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 628 Node* const p0 = m.Parameter(0); |
| 629 Node* const r = |
| 630 m.Word32Shl(m.Word32And(p0, m.Int32Constant((1 << (31 - shift)) - 1)), |
| 631 m.Int32Constant(shift + 1)); |
| 632 m.Return(r); |
| 633 Stream s = m.Build(); |
| 634 ASSERT_EQ(1U, s.size()); |
| 635 EXPECT_EQ(kMips64Shl, s[0]->arch_opcode()); |
| 636 ASSERT_EQ(2U, s[0]->InputCount()); |
| 637 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 638 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 639 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 640 } |
| 641 } |
| 642 |
| 643 |
| 644 TEST_F(InstructionSelectorTest, Word64ShlWithWord64And) { |
| 645 TRACED_FORRANGE(int32_t, shift, 0, 62) { |
| 646 StreamBuilder m(this, kMachInt64, kMachInt64); |
| 647 Node* const p0 = m.Parameter(0); |
| 648 Node* const r = |
| 649 m.Word64Shl(m.Word64And(p0, m.Int64Constant((1L << (63 - shift)) - 1)), |
| 650 m.Int64Constant(shift + 1)); |
| 651 m.Return(r); |
| 652 Stream s = m.Build(); |
| 653 ASSERT_EQ(1U, s.size()); |
| 654 EXPECT_EQ(kMips64Dshl, s[0]->arch_opcode()); |
| 655 ASSERT_EQ(2U, s[0]->InputCount()); |
| 656 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 657 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 658 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 659 } |
| 660 } |
| 661 |
| 662 |
625 // ---------------------------------------------------------------------------- | 663 // ---------------------------------------------------------------------------- |
626 // MUL/DIV instructions. | 664 // MUL/DIV instructions. |
627 // ---------------------------------------------------------------------------- | 665 // ---------------------------------------------------------------------------- |
628 typedef InstructionSelectorTestWithParam<MachInst2> | 666 typedef InstructionSelectorTestWithParam<MachInst2> |
629 InstructionSelectorMulDivTest; | 667 InstructionSelectorMulDivTest; |
630 | 668 |
631 TEST_P(InstructionSelectorMulDivTest, Parameter) { | 669 TEST_P(InstructionSelectorMulDivTest, Parameter) { |
632 const MachInst2 dpi = GetParam(); | 670 const MachInst2 dpi = GetParam(); |
633 const MachineType type = dpi.machine_type; | 671 const MachineType type = dpi.machine_type; |
634 StreamBuilder m(this, type, type, type); | 672 StreamBuilder m(this, type, type, type); |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 ASSERT_EQ(1U, s.size()); | 1329 ASSERT_EQ(1U, s.size()); |
1292 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); | 1330 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); |
1293 ASSERT_EQ(2U, s[0]->InputCount()); | 1331 ASSERT_EQ(2U, s[0]->InputCount()); |
1294 ASSERT_EQ(1U, s[0]->OutputCount()); | 1332 ASSERT_EQ(1U, s[0]->OutputCount()); |
1295 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1333 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1296 } | 1334 } |
1297 | 1335 |
1298 } // namespace compiler | 1336 } // namespace compiler |
1299 } // namespace internal | 1337 } // namespace internal |
1300 } // namespace v8 | 1338 } // namespace v8 |
OLD | NEW |