OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "src/compiler/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 | 10 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 Int64Constant(value(0))), | 653 Int64Constant(value(0))), |
654 MachineRepresentation::kWord64); | 654 MachineRepresentation::kWord64); |
655 | 655 |
656 EXPECT_THAT( | 656 EXPECT_THAT( |
657 graph()->end()->InputAt(1), | 657 graph()->end()->InputAt(1), |
658 IsReturn2(IsInt32Add(IsWord32Popcnt(IsInt32Constant(low_word_value(0))), | 658 IsReturn2(IsInt32Add(IsWord32Popcnt(IsInt32Constant(low_word_value(0))), |
659 IsWord32Popcnt(IsInt32Constant(high_word_value(0)))), | 659 IsWord32Popcnt(IsInt32Constant(high_word_value(0)))), |
660 IsInt32Constant(0), start(), start())); | 660 IsInt32Constant(0), start(), start())); |
661 } | 661 } |
662 | 662 |
| 663 TEST_F(Int64LoweringTest, I64Ror) { |
| 664 LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), |
| 665 Parameter(0)), |
| 666 MachineRepresentation::kWord64, MachineRepresentation::kWord64, 1); |
| 667 |
| 668 Matcher<Node*> branch_lt32_matcher = |
| 669 IsBranch(IsInt32LessThan(IsParameter(0), IsInt32Constant(32)), start()); |
| 670 |
| 671 Matcher<Node*> low_input_matcher = IsPhi( |
| 672 MachineRepresentation::kWord32, IsInt32Constant(low_word_value(0)), |
| 673 IsInt32Constant(high_word_value(0)), |
| 674 IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher))); |
| 675 |
| 676 Matcher<Node*> high_input_matcher = IsPhi( |
| 677 MachineRepresentation::kWord32, IsInt32Constant(high_word_value(0)), |
| 678 IsInt32Constant(low_word_value(0)), |
| 679 IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher))); |
| 680 |
| 681 Matcher<Node*> shift_matcher = |
| 682 IsWord32And(IsParameter(0), IsInt32Constant(0x1f)); |
| 683 |
| 684 Matcher<Node*> bit_mask_matcher = IsWord32Shl( |
| 685 IsWord32Sar(IsInt32Constant(std::numeric_limits<int32_t>::min()), |
| 686 shift_matcher), |
| 687 IsInt32Constant(1)); |
| 688 |
| 689 Matcher<Node*> inv_mask_matcher = |
| 690 IsWord32Xor(bit_mask_matcher, IsInt32Constant(-1)); |
| 691 |
| 692 EXPECT_THAT( |
| 693 graph()->end()->InputAt(1), |
| 694 IsReturn2( |
| 695 IsWord32Or(IsWord32And(IsWord32Ror(low_input_matcher, shift_matcher), |
| 696 inv_mask_matcher), |
| 697 IsWord32And(IsWord32Ror(high_input_matcher, shift_matcher), |
| 698 bit_mask_matcher)), |
| 699 IsWord32Or(IsWord32And(IsWord32Ror(high_input_matcher, shift_matcher), |
| 700 inv_mask_matcher), |
| 701 IsWord32And(IsWord32Ror(low_input_matcher, shift_matcher), |
| 702 bit_mask_matcher)), |
| 703 start(), start())); |
| 704 } |
| 705 |
| 706 TEST_F(Int64LoweringTest, I64Ror_0) { |
| 707 LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), |
| 708 Int32Constant(0)), |
| 709 MachineRepresentation::kWord64); |
| 710 |
| 711 EXPECT_THAT(graph()->end()->InputAt(1), |
| 712 IsReturn2(IsInt32Constant(low_word_value(0)), |
| 713 IsInt32Constant(high_word_value(0)), start(), start())); |
| 714 } |
| 715 |
| 716 TEST_F(Int64LoweringTest, I64Ror_32) { |
| 717 LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), |
| 718 Int32Constant(32)), |
| 719 MachineRepresentation::kWord64); |
| 720 |
| 721 EXPECT_THAT(graph()->end()->InputAt(1), |
| 722 IsReturn2(IsInt32Constant(high_word_value(0)), |
| 723 IsInt32Constant(low_word_value(0)), start(), start())); |
| 724 } |
| 725 |
| 726 TEST_F(Int64LoweringTest, I64Ror_11) { |
| 727 LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), |
| 728 Int32Constant(11)), |
| 729 MachineRepresentation::kWord64); |
| 730 |
| 731 EXPECT_THAT( |
| 732 graph()->end()->InputAt(1), |
| 733 IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)), |
| 734 IsInt32Constant(11)), |
| 735 IsWord32Shl(IsInt32Constant(high_word_value(0)), |
| 736 IsInt32Constant(21))), |
| 737 IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)), |
| 738 IsInt32Constant(11)), |
| 739 IsWord32Shl(IsInt32Constant(low_word_value(0)), |
| 740 IsInt32Constant(21))), |
| 741 start(), start())); |
| 742 } |
| 743 |
| 744 TEST_F(Int64LoweringTest, I64Ror_43) { |
| 745 LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), |
| 746 Int32Constant(43)), |
| 747 MachineRepresentation::kWord64); |
| 748 |
| 749 EXPECT_THAT( |
| 750 graph()->end()->InputAt(1), |
| 751 IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)), |
| 752 IsInt32Constant(11)), |
| 753 IsWord32Shl(IsInt32Constant(low_word_value(0)), |
| 754 IsInt32Constant(21))), |
| 755 IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)), |
| 756 IsInt32Constant(11)), |
| 757 IsWord32Shl(IsInt32Constant(high_word_value(0)), |
| 758 IsInt32Constant(21))), |
| 759 start(), start())); |
| 760 } |
| 761 |
663 TEST_F(Int64LoweringTest, I64PhiWord64) { | 762 TEST_F(Int64LoweringTest, I64PhiWord64) { |
664 LowerGraph(graph()->NewNode(common()->Phi(MachineRepresentation::kWord64, 2), | 763 LowerGraph(graph()->NewNode(common()->Phi(MachineRepresentation::kWord64, 2), |
665 Int64Constant(value(0)), Int64Constant(value(1)), | 764 Int64Constant(value(0)), Int64Constant(value(1)), |
666 start()), | 765 start()), |
667 MachineRepresentation::kWord64); | 766 MachineRepresentation::kWord64); |
668 | 767 |
669 EXPECT_THAT(graph()->end()->InputAt(1), | 768 EXPECT_THAT(graph()->end()->InputAt(1), |
670 IsReturn2(IsPhi(MachineRepresentation::kWord32, | 769 IsReturn2(IsPhi(MachineRepresentation::kWord32, |
671 IsInt32Constant(low_word_value(0)), | 770 IsInt32Constant(low_word_value(0)), |
672 IsInt32Constant(low_word_value(1)), start()), | 771 IsInt32Constant(low_word_value(1)), start()), |
(...skipping 24 matching lines...) Expand all Loading... |
697 Float32Constant(2.5)); | 796 Float32Constant(2.5)); |
698 } | 797 } |
699 | 798 |
700 TEST_F(Int64LoweringTest, I64PhiWord32) { | 799 TEST_F(Int64LoweringTest, I64PhiWord32) { |
701 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), | 800 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), |
702 Float32Constant(2)); | 801 Float32Constant(2)); |
703 } | 802 } |
704 } // namespace compiler | 803 } // namespace compiler |
705 } // namespace internal | 804 } // namespace internal |
706 } // namespace v8 | 805 } // namespace v8 |
OLD | NEW |