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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 EXPECT_EQ(dpi.mi.arch_opcode, s[0]->arch_opcode()); | 465 EXPECT_EQ(dpi.mi.arch_opcode, s[0]->arch_opcode()); |
466 EXPECT_EQ(shift.mode, s[0]->addressing_mode()); | 466 EXPECT_EQ(shift.mode, s[0]->addressing_mode()); |
467 EXPECT_EQ(3U, s[0]->InputCount()); | 467 EXPECT_EQ(3U, s[0]->InputCount()); |
468 EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); | 468 EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); |
469 EXPECT_EQ(1U, s[0]->OutputCount()); | 469 EXPECT_EQ(1U, s[0]->OutputCount()); |
470 } | 470 } |
471 } | 471 } |
472 } | 472 } |
473 | 473 |
474 | 474 |
| 475 TEST_P(InstructionSelectorAddSubTest, ExtendByte) { |
| 476 const AddSub dpi = GetParam(); |
| 477 const MachineType type = dpi.mi.machine_type; |
| 478 StreamBuilder m(this, type, type, type); |
| 479 m.Return((m.*dpi.mi.constructor)( |
| 480 m.Parameter(0), m.Word32And(m.Parameter(1), m.Int32Constant(0xff)))); |
| 481 Stream s = m.Build(); |
| 482 ASSERT_EQ(1U, s.size()); |
| 483 EXPECT_EQ(dpi.mi.arch_opcode, s[0]->arch_opcode()); |
| 484 EXPECT_EQ(kMode_Operand2_R_UXTB, s[0]->addressing_mode()); |
| 485 ASSERT_EQ(2U, s[0]->InputCount()); |
| 486 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 487 } |
| 488 |
| 489 |
| 490 TEST_P(InstructionSelectorAddSubTest, ExtendHalfword) { |
| 491 const AddSub dpi = GetParam(); |
| 492 const MachineType type = dpi.mi.machine_type; |
| 493 StreamBuilder m(this, type, type, type); |
| 494 m.Return((m.*dpi.mi.constructor)( |
| 495 m.Parameter(0), m.Word32And(m.Parameter(1), m.Int32Constant(0xffff)))); |
| 496 Stream s = m.Build(); |
| 497 ASSERT_EQ(1U, s.size()); |
| 498 EXPECT_EQ(dpi.mi.arch_opcode, s[0]->arch_opcode()); |
| 499 EXPECT_EQ(kMode_Operand2_R_UXTH, s[0]->addressing_mode()); |
| 500 ASSERT_EQ(2U, s[0]->InputCount()); |
| 501 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 502 } |
| 503 |
| 504 |
475 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorAddSubTest, | 505 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorAddSubTest, |
476 ::testing::ValuesIn(kAddSubInstructions)); | 506 ::testing::ValuesIn(kAddSubInstructions)); |
477 | 507 |
478 | 508 |
479 TEST_F(InstructionSelectorTest, AddImmediateOnLeft) { | 509 TEST_F(InstructionSelectorTest, AddImmediateOnLeft) { |
480 { | 510 { |
481 // 32-bit add. | 511 // 32-bit add. |
482 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { | 512 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { |
483 StreamBuilder m(this, kMachInt32, kMachInt32); | 513 StreamBuilder m(this, kMachInt32, kMachInt32); |
484 m.Return(m.Int32Add(m.Int32Constant(imm), m.Parameter(0))); | 514 m.Return(m.Int32Add(m.Int32Constant(imm), m.Parameter(0))); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 EXPECT_EQ(kArm64Add, s[0]->arch_opcode()); | 639 EXPECT_EQ(kArm64Add, s[0]->arch_opcode()); |
610 EXPECT_EQ(shift.mode, s[0]->addressing_mode()); | 640 EXPECT_EQ(shift.mode, s[0]->addressing_mode()); |
611 EXPECT_EQ(3U, s[0]->InputCount()); | 641 EXPECT_EQ(3U, s[0]->InputCount()); |
612 EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); | 642 EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(2))); |
613 EXPECT_EQ(1U, s[0]->OutputCount()); | 643 EXPECT_EQ(1U, s[0]->OutputCount()); |
614 } | 644 } |
615 } | 645 } |
616 } | 646 } |
617 | 647 |
618 | 648 |
| 649 TEST_F(InstructionSelectorTest, AddExtendByteOnLeft) { |
| 650 { |
| 651 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 652 m.Return(m.Int32Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xff)), |
| 653 m.Parameter(1))); |
| 654 Stream s = m.Build(); |
| 655 ASSERT_EQ(1U, s.size()); |
| 656 EXPECT_EQ(kArm64Add32, s[0]->arch_opcode()); |
| 657 EXPECT_EQ(kMode_Operand2_R_UXTB, s[0]->addressing_mode()); |
| 658 ASSERT_EQ(2U, s[0]->InputCount()); |
| 659 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 660 } |
| 661 { |
| 662 StreamBuilder m(this, kMachInt64, kMachInt32, kMachInt64); |
| 663 m.Return(m.Int64Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xff)), |
| 664 m.Parameter(1))); |
| 665 Stream s = m.Build(); |
| 666 ASSERT_EQ(1U, s.size()); |
| 667 EXPECT_EQ(kArm64Add, s[0]->arch_opcode()); |
| 668 EXPECT_EQ(kMode_Operand2_R_UXTB, s[0]->addressing_mode()); |
| 669 ASSERT_EQ(2U, s[0]->InputCount()); |
| 670 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 671 } |
| 672 } |
| 673 |
| 674 |
| 675 TEST_F(InstructionSelectorTest, AddExtendHalfwordOnLeft) { |
| 676 { |
| 677 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 678 m.Return(m.Int32Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xffff)), |
| 679 m.Parameter(1))); |
| 680 Stream s = m.Build(); |
| 681 ASSERT_EQ(1U, s.size()); |
| 682 EXPECT_EQ(kArm64Add32, s[0]->arch_opcode()); |
| 683 EXPECT_EQ(kMode_Operand2_R_UXTH, s[0]->addressing_mode()); |
| 684 ASSERT_EQ(2U, s[0]->InputCount()); |
| 685 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 686 } |
| 687 { |
| 688 StreamBuilder m(this, kMachInt64, kMachInt32, kMachInt64); |
| 689 m.Return(m.Int64Add(m.Word32And(m.Parameter(0), m.Int32Constant(0xffff)), |
| 690 m.Parameter(1))); |
| 691 Stream s = m.Build(); |
| 692 ASSERT_EQ(1U, s.size()); |
| 693 EXPECT_EQ(kArm64Add, s[0]->arch_opcode()); |
| 694 EXPECT_EQ(kMode_Operand2_R_UXTH, s[0]->addressing_mode()); |
| 695 ASSERT_EQ(2U, s[0]->InputCount()); |
| 696 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 697 } |
| 698 } |
| 699 |
| 700 |
619 // ----------------------------------------------------------------------------- | 701 // ----------------------------------------------------------------------------- |
620 // Data processing controlled branches. | 702 // Data processing controlled branches. |
621 | 703 |
622 | 704 |
623 typedef InstructionSelectorTestWithParam<MachInst2> | 705 typedef InstructionSelectorTestWithParam<MachInst2> |
624 InstructionSelectorDPFlagSetTest; | 706 InstructionSelectorDPFlagSetTest; |
625 | 707 |
626 | 708 |
627 TEST_P(InstructionSelectorDPFlagSetTest, BranchWithParameters) { | 709 TEST_P(InstructionSelectorDPFlagSetTest, BranchWithParameters) { |
628 const MachInst2 dpi = GetParam(); | 710 const MachInst2 dpi = GetParam(); |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 ASSERT_EQ(1U, s[0]->InputCount()); | 2238 ASSERT_EQ(1U, s[0]->InputCount()); |
2157 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2239 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
2158 ASSERT_EQ(1U, s[0]->OutputCount()); | 2240 ASSERT_EQ(1U, s[0]->OutputCount()); |
2159 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2241 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
2160 } | 2242 } |
2161 } | 2243 } |
2162 | 2244 |
2163 } // namespace compiler | 2245 } // namespace compiler |
2164 } // namespace internal | 2246 } // namespace internal |
2165 } // namespace v8 | 2247 } // namespace v8 |
OLD | NEW |