| 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_eqz_matcher = | 
|  | 669       IsBranch(IsWord32Equal(IsWord32And(IsParameter(0), IsInt32Constant(0x1f)), | 
|  | 670                              IsInt32Constant(0)), | 
|  | 671                start()); | 
|  | 672 | 
|  | 673   Matcher<Node*> branch_lt32_matcher = IsBranch( | 
|  | 674       IsInt32LessThan(IsWord32And(IsParameter(0), IsInt32Constant(0x3f)), | 
|  | 675                       IsInt32Constant(32)), | 
|  | 676       start()); | 
|  | 677 | 
|  | 678   Matcher<Node*> low_matcher = IsPhi( | 
|  | 679       MachineRepresentation::kWord32, IsInt32Constant(low_word_value(0)), | 
|  | 680       IsInt32Constant(high_word_value(0)), | 
|  | 681       IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher))); | 
|  | 682 | 
|  | 683   Matcher<Node*> high_matcher = IsPhi( | 
|  | 684       MachineRepresentation::kWord32, IsInt32Constant(high_word_value(0)), | 
|  | 685       IsInt32Constant(low_word_value(0)), | 
|  | 686       IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher))); | 
|  | 687 | 
|  | 688   Matcher<Node*> shift_matcher = | 
|  | 689       IsWord32And(IsParameter(0), IsInt32Constant(0x1f)); | 
|  | 690   Matcher<Node*> inv_shift_matcher = | 
|  | 691       IsInt32Sub(IsInt32Constant(32), shift_matcher); | 
|  | 692 | 
|  | 693   EXPECT_THAT( | 
|  | 694       graph()->end()->InputAt(1), | 
|  | 695       IsReturn2(IsPhi(MachineRepresentation::kWord32, low_matcher, | 
|  | 696                       IsWord32Or(IsWord32Shr(low_matcher, shift_matcher), | 
|  | 697                                  IsWord32Shl(high_matcher, inv_shift_matcher)), | 
|  | 698                       IsMerge(IsIfTrue(branch_eqz_matcher), | 
|  | 699                               IsIfFalse(branch_eqz_matcher))), | 
|  | 700                 IsPhi(MachineRepresentation::kWord32, high_matcher, | 
|  | 701                       IsWord32Or(IsWord32Shr(high_matcher, shift_matcher), | 
|  | 702                                  IsWord32Shl(low_matcher, inv_shift_matcher)), | 
|  | 703                       IsMerge(IsIfTrue(branch_eqz_matcher), | 
|  | 704                               IsIfFalse(branch_eqz_matcher))), | 
|  | 705                 start(), start())); | 
|  | 706 } | 
|  | 707 | 
|  | 708 TEST_F(Int64LoweringTest, I64Ror_0) { | 
|  | 709   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), | 
|  | 710                               Int32Constant(0)), | 
|  | 711              MachineRepresentation::kWord64); | 
|  | 712 | 
|  | 713   EXPECT_THAT(graph()->end()->InputAt(1), | 
|  | 714               IsReturn2(IsInt32Constant(low_word_value(0)), | 
|  | 715                         IsInt32Constant(high_word_value(0)), start(), start())); | 
|  | 716 } | 
|  | 717 | 
|  | 718 TEST_F(Int64LoweringTest, I64Ror_32) { | 
|  | 719   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), | 
|  | 720                               Int32Constant(32)), | 
|  | 721              MachineRepresentation::kWord64); | 
|  | 722 | 
|  | 723   EXPECT_THAT(graph()->end()->InputAt(1), | 
|  | 724               IsReturn2(IsInt32Constant(high_word_value(0)), | 
|  | 725                         IsInt32Constant(low_word_value(0)), start(), start())); | 
|  | 726 } | 
|  | 727 | 
|  | 728 TEST_F(Int64LoweringTest, I64Ror_11) { | 
|  | 729   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), | 
|  | 730                               Int32Constant(11)), | 
|  | 731              MachineRepresentation::kWord64); | 
|  | 732 | 
|  | 733   EXPECT_THAT( | 
|  | 734       graph()->end()->InputAt(1), | 
|  | 735       IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)), | 
|  | 736                                        IsInt32Constant(11)), | 
|  | 737                            IsWord32Shl(IsInt32Constant(high_word_value(0)), | 
|  | 738                                        IsInt32Constant(21))), | 
|  | 739                 IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)), | 
|  | 740                                        IsInt32Constant(11)), | 
|  | 741                            IsWord32Shl(IsInt32Constant(low_word_value(0)), | 
|  | 742                                        IsInt32Constant(21))), | 
|  | 743                 start(), start())); | 
|  | 744 } | 
|  | 745 | 
|  | 746 TEST_F(Int64LoweringTest, I64Ror_43) { | 
|  | 747   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)), | 
|  | 748                               Int32Constant(43)), | 
|  | 749              MachineRepresentation::kWord64); | 
|  | 750 | 
|  | 751   EXPECT_THAT( | 
|  | 752       graph()->end()->InputAt(1), | 
|  | 753       IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)), | 
|  | 754                                        IsInt32Constant(11)), | 
|  | 755                            IsWord32Shl(IsInt32Constant(low_word_value(0)), | 
|  | 756                                        IsInt32Constant(21))), | 
|  | 757                 IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)), | 
|  | 758                                        IsInt32Constant(11)), | 
|  | 759                            IsWord32Shl(IsInt32Constant(high_word_value(0)), | 
|  | 760                                        IsInt32Constant(21))), | 
|  | 761                 start(), start())); | 
|  | 762 } | 
|  | 763 | 
| 663 TEST_F(Int64LoweringTest, I64PhiWord64) { | 764 TEST_F(Int64LoweringTest, I64PhiWord64) { | 
| 664   LowerGraph(graph()->NewNode(common()->Phi(MachineRepresentation::kWord64, 2), | 765   LowerGraph(graph()->NewNode(common()->Phi(MachineRepresentation::kWord64, 2), | 
| 665                               Int64Constant(value(0)), Int64Constant(value(1)), | 766                               Int64Constant(value(0)), Int64Constant(value(1)), | 
| 666                               start()), | 767                               start()), | 
| 667              MachineRepresentation::kWord64); | 768              MachineRepresentation::kWord64); | 
| 668 | 769 | 
| 669   EXPECT_THAT(graph()->end()->InputAt(1), | 770   EXPECT_THAT(graph()->end()->InputAt(1), | 
| 670               IsReturn2(IsPhi(MachineRepresentation::kWord32, | 771               IsReturn2(IsPhi(MachineRepresentation::kWord32, | 
| 671                               IsInt32Constant(low_word_value(0)), | 772                               IsInt32Constant(low_word_value(0)), | 
| 672                               IsInt32Constant(low_word_value(1)), start()), | 773                               IsInt32Constant(low_word_value(1)), start()), | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 697           Float32Constant(2.5)); | 798           Float32Constant(2.5)); | 
| 698 } | 799 } | 
| 699 | 800 | 
| 700 TEST_F(Int64LoweringTest, I64PhiWord32) { | 801 TEST_F(Int64LoweringTest, I64PhiWord32) { | 
| 701   TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), | 802   TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), | 
| 702           Float32Constant(2)); | 803           Float32Constant(2)); | 
| 703 } | 804 } | 
| 704 }  // namespace compiler | 805 }  // namespace compiler | 
| 705 }  // namespace internal | 806 }  // namespace internal | 
| 706 }  // namespace v8 | 807 }  // namespace v8 | 
| OLD | NEW | 
|---|