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 "src/compiler/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 } else { | 639 } else { |
640 if (g.CanBeBetterLeftOperand(right)) { | 640 if (g.CanBeBetterLeftOperand(right)) { |
641 std::swap(left, right); | 641 std::swap(left, right); |
642 } | 642 } |
643 Emit(kIA32Imul, g.DefineSameAsFirst(node), g.UseRegister(left), | 643 Emit(kIA32Imul, g.DefineSameAsFirst(node), g.UseRegister(left), |
644 g.Use(right)); | 644 g.Use(right)); |
645 } | 645 } |
646 } | 646 } |
647 | 647 |
648 | 648 |
649 void InstructionSelector::VisitInt32MulHigh(Node* node) { | 649 namespace { |
650 IA32OperandGenerator g(this); | 650 |
651 Emit(kIA32ImulHigh, g.DefineAsFixed(node, edx), | 651 void VisitMulHigh(InstructionSelector* selector, Node* node, |
652 g.UseFixed(node->InputAt(0), eax), | 652 ArchOpcode opcode) { |
653 g.UseUniqueRegister(node->InputAt(1))); | 653 IA32OperandGenerator g(selector); |
| 654 selector->Emit(opcode, g.DefineAsFixed(node, edx), |
| 655 g.UseFixed(node->InputAt(0), eax), |
| 656 g.UseUniqueRegister(node->InputAt(1))); |
654 } | 657 } |
655 | 658 |
656 | 659 |
657 static inline void VisitDiv(InstructionSelector* selector, Node* node, | 660 void VisitDiv(InstructionSelector* selector, Node* node, ArchOpcode opcode) { |
658 ArchOpcode opcode) { | |
659 IA32OperandGenerator g(selector); | 661 IA32OperandGenerator g(selector); |
660 InstructionOperand* temps[] = {g.TempRegister(edx)}; | 662 InstructionOperand* temps[] = {g.TempRegister(edx)}; |
661 size_t temp_count = arraysize(temps); | |
662 selector->Emit(opcode, g.DefineAsFixed(node, eax), | 663 selector->Emit(opcode, g.DefineAsFixed(node, eax), |
663 g.UseFixed(node->InputAt(0), eax), | 664 g.UseFixed(node->InputAt(0), eax), |
664 g.UseUnique(node->InputAt(1)), temp_count, temps); | 665 g.UseUnique(node->InputAt(1)), arraysize(temps), temps); |
665 } | 666 } |
666 | 667 |
667 | 668 |
| 669 void VisitMod(InstructionSelector* selector, Node* node, ArchOpcode opcode) { |
| 670 IA32OperandGenerator g(selector); |
| 671 selector->Emit(opcode, g.DefineAsFixed(node, edx), |
| 672 g.UseFixed(node->InputAt(0), eax), |
| 673 g.UseUnique(node->InputAt(1))); |
| 674 } |
| 675 |
| 676 } // namespace |
| 677 |
| 678 |
| 679 void InstructionSelector::VisitInt32MulHigh(Node* node) { |
| 680 VisitMulHigh(this, node, kIA32ImulHigh); |
| 681 } |
| 682 |
| 683 |
| 684 void InstructionSelector::VisitUint32MulHigh(Node* node) { |
| 685 VisitMulHigh(this, node, kIA32UmulHigh); |
| 686 } |
| 687 |
| 688 |
668 void InstructionSelector::VisitInt32Div(Node* node) { | 689 void InstructionSelector::VisitInt32Div(Node* node) { |
669 VisitDiv(this, node, kIA32Idiv); | 690 VisitDiv(this, node, kIA32Idiv); |
670 } | 691 } |
671 | 692 |
672 | 693 |
673 void InstructionSelector::VisitUint32Div(Node* node) { | 694 void InstructionSelector::VisitUint32Div(Node* node) { |
674 VisitDiv(this, node, kIA32Udiv); | 695 VisitDiv(this, node, kIA32Udiv); |
675 } | 696 } |
676 | 697 |
677 | 698 |
678 static inline void VisitMod(InstructionSelector* selector, Node* node, | |
679 ArchOpcode opcode) { | |
680 IA32OperandGenerator g(selector); | |
681 selector->Emit(opcode, g.DefineAsFixed(node, edx), | |
682 g.UseFixed(node->InputAt(0), eax), | |
683 g.UseUnique(node->InputAt(1))); | |
684 } | |
685 | |
686 | |
687 void InstructionSelector::VisitInt32Mod(Node* node) { | 699 void InstructionSelector::VisitInt32Mod(Node* node) { |
688 VisitMod(this, node, kIA32Idiv); | 700 VisitMod(this, node, kIA32Idiv); |
689 } | 701 } |
690 | 702 |
691 | 703 |
692 void InstructionSelector::VisitUint32Mod(Node* node) { | 704 void InstructionSelector::VisitUint32Mod(Node* node) { |
693 VisitMod(this, node, kIA32Udiv); | 705 VisitMod(this, node, kIA32Udiv); |
694 } | 706 } |
695 | 707 |
696 | 708 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 if (CpuFeatures::IsSupported(SSE4_1)) { | 1096 if (CpuFeatures::IsSupported(SSE4_1)) { |
1085 return MachineOperatorBuilder::kFloat64Floor | | 1097 return MachineOperatorBuilder::kFloat64Floor | |
1086 MachineOperatorBuilder::kFloat64Ceil | | 1098 MachineOperatorBuilder::kFloat64Ceil | |
1087 MachineOperatorBuilder::kFloat64RoundTruncate; | 1099 MachineOperatorBuilder::kFloat64RoundTruncate; |
1088 } | 1100 } |
1089 return MachineOperatorBuilder::Flag::kNoFlags; | 1101 return MachineOperatorBuilder::Flag::kNoFlags; |
1090 } | 1102 } |
1091 } // namespace compiler | 1103 } // namespace compiler |
1092 } // namespace internal | 1104 } // namespace internal |
1093 } // namespace v8 | 1105 } // namespace v8 |
OLD | NEW |