| 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.h" | 7 #include "src/compiler/node-properties.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 IA32OperandGenerator g(selector); | 146 IA32OperandGenerator g(selector); |
| 147 InstructionOperand operand0 = g.UseRegister(node->InputAt(0)); | 147 InstructionOperand operand0 = g.UseRegister(node->InputAt(0)); |
| 148 InstructionOperand operand1 = g.Use(node->InputAt(1)); | 148 InstructionOperand operand1 = g.Use(node->InputAt(1)); |
| 149 if (selector->IsSupported(AVX)) { | 149 if (selector->IsSupported(AVX)) { |
| 150 selector->Emit(avx_opcode, g.DefineAsRegister(node), operand0, operand1); | 150 selector->Emit(avx_opcode, g.DefineAsRegister(node), operand0, operand1); |
| 151 } else { | 151 } else { |
| 152 selector->Emit(sse_opcode, g.DefineSameAsFirst(node), operand0, operand1); | 152 selector->Emit(sse_opcode, g.DefineSameAsFirst(node), operand0, operand1); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 |
| 157 void VisitFloatUnop(InstructionSelector* selector, Node* node, Node* input, |
| 158 ArchOpcode avx_opcode, ArchOpcode sse_opcode) { |
| 159 IA32OperandGenerator g(selector); |
| 160 if (selector->IsSupported(AVX)) { |
| 161 selector->Emit(avx_opcode, g.DefineAsRegister(node), g.Use(input)); |
| 162 } else { |
| 163 selector->Emit(sse_opcode, g.DefineSameAsFirst(node), g.UseRegister(input)); |
| 164 } |
| 165 } |
| 166 |
| 167 |
| 156 } // namespace | 168 } // namespace |
| 157 | 169 |
| 158 | 170 |
| 159 void InstructionSelector::VisitLoad(Node* node) { | 171 void InstructionSelector::VisitLoad(Node* node) { |
| 160 MachineType rep = RepresentationOf(OpParameter<LoadRepresentation>(node)); | 172 MachineType rep = RepresentationOf(OpParameter<LoadRepresentation>(node)); |
| 161 MachineType typ = TypeOf(OpParameter<LoadRepresentation>(node)); | 173 MachineType typ = TypeOf(OpParameter<LoadRepresentation>(node)); |
| 162 | 174 |
| 163 ArchOpcode opcode; | 175 ArchOpcode opcode; |
| 164 switch (rep) { | 176 switch (rep) { |
| 165 case kRepFloat32: | 177 case kRepFloat32: |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 | 689 |
| 678 void InstructionSelector::VisitFloat64Add(Node* node) { | 690 void InstructionSelector::VisitFloat64Add(Node* node) { |
| 679 VisitRROFloat(this, node, kAVXFloat64Add, kSSEFloat64Add); | 691 VisitRROFloat(this, node, kAVXFloat64Add, kSSEFloat64Add); |
| 680 } | 692 } |
| 681 | 693 |
| 682 | 694 |
| 683 void InstructionSelector::VisitFloat32Sub(Node* node) { | 695 void InstructionSelector::VisitFloat32Sub(Node* node) { |
| 684 IA32OperandGenerator g(this); | 696 IA32OperandGenerator g(this); |
| 685 Float32BinopMatcher m(node); | 697 Float32BinopMatcher m(node); |
| 686 if (m.left().IsMinusZero()) { | 698 if (m.left().IsMinusZero()) { |
| 687 Emit(kSSEFloat32Neg, g.DefineSameAsFirst(node), | 699 VisitFloatUnop(this, node, m.right().node(), kAVXFloat32Neg, |
| 688 g.UseRegister(m.right().node())); | 700 kSSEFloat32Neg); |
| 689 return; | 701 return; |
| 690 } | 702 } |
| 691 VisitRROFloat(this, node, kAVXFloat32Sub, kSSEFloat32Sub); | 703 VisitRROFloat(this, node, kAVXFloat32Sub, kSSEFloat32Sub); |
| 692 } | 704 } |
| 693 | 705 |
| 694 | 706 |
| 695 void InstructionSelector::VisitFloat64Sub(Node* node) { | 707 void InstructionSelector::VisitFloat64Sub(Node* node) { |
| 696 IA32OperandGenerator g(this); | 708 IA32OperandGenerator g(this); |
| 697 Float64BinopMatcher m(node); | 709 Float64BinopMatcher m(node); |
| 698 if (m.left().IsMinusZero()) { | 710 if (m.left().IsMinusZero()) { |
| 699 if (m.right().IsFloat64RoundDown() && | 711 if (m.right().IsFloat64RoundDown() && |
| 700 CanCover(m.node(), m.right().node())) { | 712 CanCover(m.node(), m.right().node())) { |
| 701 if (m.right().InputAt(0)->opcode() == IrOpcode::kFloat64Sub && | 713 if (m.right().InputAt(0)->opcode() == IrOpcode::kFloat64Sub && |
| 702 CanCover(m.right().node(), m.right().InputAt(0))) { | 714 CanCover(m.right().node(), m.right().InputAt(0))) { |
| 703 Float64BinopMatcher mright0(m.right().InputAt(0)); | 715 Float64BinopMatcher mright0(m.right().InputAt(0)); |
| 704 if (mright0.left().IsMinusZero()) { | 716 if (mright0.left().IsMinusZero()) { |
| 705 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp), | 717 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp), |
| 706 g.DefineAsRegister(node), g.UseRegister(mright0.right().node())); | 718 g.DefineAsRegister(node), g.UseRegister(mright0.right().node())); |
| 707 return; | 719 return; |
| 708 } | 720 } |
| 709 } | 721 } |
| 710 } | 722 } |
| 711 Emit(kSSEFloat64Neg, g.DefineSameAsFirst(node), | 723 VisitFloatUnop(this, node, m.right().node(), kAVXFloat64Neg, |
| 712 g.UseRegister(m.right().node())); | 724 kSSEFloat64Neg); |
| 713 return; | 725 return; |
| 714 } | 726 } |
| 715 VisitRROFloat(this, node, kAVXFloat64Sub, kSSEFloat64Sub); | 727 VisitRROFloat(this, node, kAVXFloat64Sub, kSSEFloat64Sub); |
| 716 } | 728 } |
| 717 | 729 |
| 718 | 730 |
| 719 void InstructionSelector::VisitFloat32Mul(Node* node) { | 731 void InstructionSelector::VisitFloat32Mul(Node* node) { |
| 720 VisitRROFloat(this, node, kAVXFloat32Mul, kSSEFloat32Mul); | 732 VisitRROFloat(this, node, kAVXFloat32Mul, kSSEFloat32Mul); |
| 721 } | 733 } |
| 722 | 734 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 772 } |
| 761 | 773 |
| 762 | 774 |
| 763 void InstructionSelector::VisitFloat64Min(Node* node) { | 775 void InstructionSelector::VisitFloat64Min(Node* node) { |
| 764 VisitRROFloat(this, node, kAVXFloat64Min, kSSEFloat64Min); | 776 VisitRROFloat(this, node, kAVXFloat64Min, kSSEFloat64Min); |
| 765 } | 777 } |
| 766 | 778 |
| 767 | 779 |
| 768 void InstructionSelector::VisitFloat32Abs(Node* node) { | 780 void InstructionSelector::VisitFloat32Abs(Node* node) { |
| 769 IA32OperandGenerator g(this); | 781 IA32OperandGenerator g(this); |
| 770 Emit(kSSEFloat32Abs, g.DefineSameAsFirst(node), g.Use(node->InputAt(0))); | 782 VisitFloatUnop(this, node, node->InputAt(0), kAVXFloat32Abs, kSSEFloat32Abs); |
| 771 } | 783 } |
| 772 | 784 |
| 773 | 785 |
| 774 void InstructionSelector::VisitFloat64Abs(Node* node) { | 786 void InstructionSelector::VisitFloat64Abs(Node* node) { |
| 775 IA32OperandGenerator g(this); | 787 IA32OperandGenerator g(this); |
| 776 Emit(kSSEFloat64Abs, g.DefineSameAsFirst(node), g.Use(node->InputAt(0))); | 788 VisitFloatUnop(this, node, node->InputAt(0), kAVXFloat64Abs, kSSEFloat64Abs); |
| 777 } | 789 } |
| 778 | 790 |
| 779 | 791 |
| 780 void InstructionSelector::VisitFloat32Sqrt(Node* node) { | 792 void InstructionSelector::VisitFloat32Sqrt(Node* node) { |
| 781 VisitROFloat(this, node, kSSEFloat32Sqrt); | 793 VisitROFloat(this, node, kSSEFloat32Sqrt); |
| 782 } | 794 } |
| 783 | 795 |
| 784 | 796 |
| 785 void InstructionSelector::VisitFloat64Sqrt(Node* node) { | 797 void InstructionSelector::VisitFloat64Sqrt(Node* node) { |
| 786 VisitROFloat(this, node, kSSEFloat64Sqrt); | 798 VisitROFloat(this, node, kSSEFloat64Sqrt); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 if (CpuFeatures::IsSupported(SSE4_1)) { | 1236 if (CpuFeatures::IsSupported(SSE4_1)) { |
| 1225 flags |= MachineOperatorBuilder::kFloat64RoundDown | | 1237 flags |= MachineOperatorBuilder::kFloat64RoundDown | |
| 1226 MachineOperatorBuilder::kFloat64RoundTruncate; | 1238 MachineOperatorBuilder::kFloat64RoundTruncate; |
| 1227 } | 1239 } |
| 1228 return flags; | 1240 return flags; |
| 1229 } | 1241 } |
| 1230 | 1242 |
| 1231 } // namespace compiler | 1243 } // namespace compiler |
| 1232 } // namespace internal | 1244 } // namespace internal |
| 1233 } // namespace v8 | 1245 } // namespace v8 |
| OLD | NEW |