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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 g.UseImmediate(right)); | 832 g.UseImmediate(right)); |
833 } else { | 833 } else { |
834 if (g.CanBeBetterLeftOperand(right)) { | 834 if (g.CanBeBetterLeftOperand(right)) { |
835 std::swap(left, right); | 835 std::swap(left, right); |
836 } | 836 } |
837 selector->Emit(opcode, g.DefineSameAsFirst(node), g.UseRegister(left), | 837 selector->Emit(opcode, g.DefineSameAsFirst(node), g.UseRegister(left), |
838 g.Use(right)); | 838 g.Use(right)); |
839 } | 839 } |
840 } | 840 } |
841 | 841 |
842 | |
843 void VisitMulHigh(InstructionSelector* selector, Node* node, | 842 void VisitMulHigh(InstructionSelector* selector, Node* node, |
844 ArchOpcode opcode) { | 843 ArchOpcode opcode) { |
845 X64OperandGenerator g(selector); | 844 X64OperandGenerator g(selector); |
846 Node* left = node->InputAt(0); | 845 Node* left = node->InputAt(0); |
847 Node* right = node->InputAt(1); | 846 Node* right = node->InputAt(1); |
848 if (selector->IsLive(left) && !selector->IsLive(right)) { | 847 if (selector->IsLive(left) && !selector->IsLive(right)) { |
849 std::swap(left, right); | 848 std::swap(left, right); |
850 } | 849 } |
851 InstructionOperand temps[] = {g.TempRegister(rax)}; | 850 InstructionOperand temps[] = {g.TempRegister(rax)}; |
852 // TODO(turbofan): We use UseUniqueRegister here to improve register | 851 // TODO(turbofan): We use UseUniqueRegister here to improve register |
(...skipping 27 matching lines...) Expand all Loading... |
880 Int32ScaleMatcher m(node, true); | 879 Int32ScaleMatcher m(node, true); |
881 if (m.matches()) { | 880 if (m.matches()) { |
882 Node* index = node->InputAt(0); | 881 Node* index = node->InputAt(0); |
883 Node* base = m.power_of_two_plus_one() ? index : nullptr; | 882 Node* base = m.power_of_two_plus_one() ? index : nullptr; |
884 EmitLea(this, kX64Lea32, node, index, m.scale(), base, nullptr); | 883 EmitLea(this, kX64Lea32, node, index, m.scale(), base, nullptr); |
885 return; | 884 return; |
886 } | 885 } |
887 VisitMul(this, node, kX64Imul32); | 886 VisitMul(this, node, kX64Imul32); |
888 } | 887 } |
889 | 888 |
| 889 void InstructionSelector::VisitInt32MulWithOverflow(Node* node) { |
| 890 // TODO(mvstanton): Use Int32ScaleMatcher somehow. |
| 891 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
| 892 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); |
| 893 return VisitBinop(this, node, kX64Imul32, &cont); |
| 894 } |
| 895 FlagsContinuation cont; |
| 896 VisitBinop(this, node, kX64Imul32, &cont); |
| 897 } |
890 | 898 |
891 void InstructionSelector::VisitInt64Mul(Node* node) { | 899 void InstructionSelector::VisitInt64Mul(Node* node) { |
892 VisitMul(this, node, kX64Imul); | 900 VisitMul(this, node, kX64Imul); |
893 } | 901 } |
894 | 902 |
895 | |
896 void InstructionSelector::VisitInt32MulHigh(Node* node) { | 903 void InstructionSelector::VisitInt32MulHigh(Node* node) { |
897 VisitMulHigh(this, node, kX64ImulHigh32); | 904 VisitMulHigh(this, node, kX64ImulHigh32); |
898 } | 905 } |
899 | 906 |
900 | 907 |
901 void InstructionSelector::VisitInt32Div(Node* node) { | 908 void InstructionSelector::VisitInt32Div(Node* node) { |
902 VisitDiv(this, node, kX64Idiv32); | 909 VisitDiv(this, node, kX64Idiv32); |
903 } | 910 } |
904 | 911 |
905 | 912 |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 Node* const node = value->InputAt(0); | 1766 Node* const node = value->InputAt(0); |
1760 Node* const result = NodeProperties::FindProjection(node, 0); | 1767 Node* const result = NodeProperties::FindProjection(node, 0); |
1761 if (result == nullptr || selector->IsDefined(result)) { | 1768 if (result == nullptr || selector->IsDefined(result)) { |
1762 switch (node->opcode()) { | 1769 switch (node->opcode()) { |
1763 case IrOpcode::kInt32AddWithOverflow: | 1770 case IrOpcode::kInt32AddWithOverflow: |
1764 cont->OverwriteAndNegateIfEqual(kOverflow); | 1771 cont->OverwriteAndNegateIfEqual(kOverflow); |
1765 return VisitBinop(selector, node, kX64Add32, cont); | 1772 return VisitBinop(selector, node, kX64Add32, cont); |
1766 case IrOpcode::kInt32SubWithOverflow: | 1773 case IrOpcode::kInt32SubWithOverflow: |
1767 cont->OverwriteAndNegateIfEqual(kOverflow); | 1774 cont->OverwriteAndNegateIfEqual(kOverflow); |
1768 return VisitBinop(selector, node, kX64Sub32, cont); | 1775 return VisitBinop(selector, node, kX64Sub32, cont); |
| 1776 case IrOpcode::kInt32MulWithOverflow: |
| 1777 cont->OverwriteAndNegateIfEqual(kOverflow); |
| 1778 return VisitBinop(selector, node, kX64Imul32, cont); |
1769 case IrOpcode::kInt64AddWithOverflow: | 1779 case IrOpcode::kInt64AddWithOverflow: |
1770 cont->OverwriteAndNegateIfEqual(kOverflow); | 1780 cont->OverwriteAndNegateIfEqual(kOverflow); |
1771 return VisitBinop(selector, node, kX64Add, cont); | 1781 return VisitBinop(selector, node, kX64Add, cont); |
1772 case IrOpcode::kInt64SubWithOverflow: | 1782 case IrOpcode::kInt64SubWithOverflow: |
1773 cont->OverwriteAndNegateIfEqual(kOverflow); | 1783 cont->OverwriteAndNegateIfEqual(kOverflow); |
1774 return VisitBinop(selector, node, kX64Sub, cont); | 1784 return VisitBinop(selector, node, kX64Sub, cont); |
1775 default: | 1785 default: |
1776 break; | 1786 break; |
1777 } | 1787 } |
1778 } | 1788 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2136 // static | 2146 // static |
2137 MachineOperatorBuilder::AlignmentRequirements | 2147 MachineOperatorBuilder::AlignmentRequirements |
2138 InstructionSelector::AlignmentRequirements() { | 2148 InstructionSelector::AlignmentRequirements() { |
2139 return MachineOperatorBuilder::AlignmentRequirements:: | 2149 return MachineOperatorBuilder::AlignmentRequirements:: |
2140 FullUnalignedAccessSupport(); | 2150 FullUnalignedAccessSupport(); |
2141 } | 2151 } |
2142 | 2152 |
2143 } // namespace compiler | 2153 } // namespace compiler |
2144 } // namespace internal | 2154 } // namespace internal |
2145 } // namespace v8 | 2155 } // namespace v8 |
OLD | NEW |