| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 StreamBuilder m(this, kMachInt32, kMachInt32); | 626 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 627 MLabel a, b; | 627 MLabel a, b; |
| 628 m.Branch(m.Word32And(m.Parameter(0), m.Int32Constant(imm)), &a, &b); | 628 m.Branch(m.Word32And(m.Parameter(0), m.Int32Constant(imm)), &a, &b); |
| 629 m.Bind(&a); | 629 m.Bind(&a); |
| 630 m.Return(m.Int32Constant(1)); | 630 m.Return(m.Int32Constant(1)); |
| 631 m.Bind(&b); | 631 m.Bind(&b); |
| 632 m.Return(m.Int32Constant(0)); | 632 m.Return(m.Int32Constant(0)); |
| 633 Stream s = m.Build(); | 633 Stream s = m.Build(); |
| 634 ASSERT_EQ(1U, s.size()); | 634 ASSERT_EQ(1U, s.size()); |
| 635 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); | 635 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); |
| 636 EXPECT_EQ(4U, s[0]->InputCount()); |
| 637 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 636 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 638 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 637 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 639 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 638 } | 640 } |
| 639 } | 641 } |
| 640 | 642 |
| 641 | 643 |
| 642 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnRight) { | 644 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnRight) { |
| 643 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { | 645 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { |
| 644 StreamBuilder m(this, kMachInt32, kMachInt32); | 646 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 645 MLabel a, b; | 647 MLabel a, b; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 StreamBuilder m(this, kMachInt32, kMachInt32); | 682 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 681 MLabel a, b; | 683 MLabel a, b; |
| 682 m.Branch(m.Word32And(m.Int32Constant(imm), m.Parameter(0)), &a, &b); | 684 m.Branch(m.Word32And(m.Int32Constant(imm), m.Parameter(0)), &a, &b); |
| 683 m.Bind(&a); | 685 m.Bind(&a); |
| 684 m.Return(m.Int32Constant(1)); | 686 m.Return(m.Int32Constant(1)); |
| 685 m.Bind(&b); | 687 m.Bind(&b); |
| 686 m.Return(m.Int32Constant(0)); | 688 m.Return(m.Int32Constant(0)); |
| 687 Stream s = m.Build(); | 689 Stream s = m.Build(); |
| 688 ASSERT_EQ(1U, s.size()); | 690 ASSERT_EQ(1U, s.size()); |
| 689 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); | 691 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); |
| 692 EXPECT_EQ(4U, s[0]->InputCount()); |
| 693 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 690 ASSERT_LE(1U, s[0]->InputCount()); | 694 ASSERT_LE(1U, s[0]->InputCount()); |
| 691 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 695 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 692 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 696 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 693 } | 697 } |
| 694 } | 698 } |
| 695 | 699 |
| 696 | 700 |
| 697 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnLeft) { | 701 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnLeft) { |
| 698 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { | 702 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { |
| 699 StreamBuilder m(this, kMachInt32, kMachInt32); | 703 StreamBuilder m(this, kMachInt32, kMachInt32); |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 ASSERT_EQ(2U, s[1]->InputCount()); | 1781 ASSERT_EQ(2U, s[1]->InputCount()); |
| 1778 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 1782 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 1779 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1))); | 1783 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1))); |
| 1780 ASSERT_EQ(1U, s[1]->OutputCount()); | 1784 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1781 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output())); | 1785 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output())); |
| 1782 } | 1786 } |
| 1783 | 1787 |
| 1784 } // namespace compiler | 1788 } // namespace compiler |
| 1785 } // namespace internal | 1789 } // namespace internal |
| 1786 } // namespace v8 | 1790 } // namespace v8 |
| OLD | NEW |