Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 2101123005: [turbofan] Introduce integer multiplication with overflow. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 g.UseImmediate(right)); 841 g.UseImmediate(right));
842 } else { 842 } else {
843 if (g.CanBeBetterLeftOperand(right)) { 843 if (g.CanBeBetterLeftOperand(right)) {
844 std::swap(left, right); 844 std::swap(left, right);
845 } 845 }
846 selector->Emit(opcode, g.DefineSameAsFirst(node), g.UseRegister(left), 846 selector->Emit(opcode, g.DefineSameAsFirst(node), g.UseRegister(left),
847 g.Use(right)); 847 g.Use(right));
848 } 848 }
849 } 849 }
850 850
851
852 void VisitMulHigh(InstructionSelector* selector, Node* node, 851 void VisitMulHigh(InstructionSelector* selector, Node* node,
853 ArchOpcode opcode) { 852 ArchOpcode opcode) {
854 X64OperandGenerator g(selector); 853 X64OperandGenerator g(selector);
855 Node* left = node->InputAt(0); 854 Node* left = node->InputAt(0);
856 Node* right = node->InputAt(1); 855 Node* right = node->InputAt(1);
857 if (selector->IsLive(left) && !selector->IsLive(right)) { 856 if (selector->IsLive(left) && !selector->IsLive(right)) {
858 std::swap(left, right); 857 std::swap(left, right);
859 } 858 }
860 InstructionOperand temps[] = {g.TempRegister(rax)}; 859 InstructionOperand temps[] = {g.TempRegister(rax)};
861 // TODO(turbofan): We use UseUniqueRegister here to improve register 860 // TODO(turbofan): We use UseUniqueRegister here to improve register
(...skipping 28 matching lines...) Expand all
890 if (m.matches()) { 889 if (m.matches()) {
891 Node* index = node->InputAt(0); 890 Node* index = node->InputAt(0);
892 Node* base = m.power_of_two_plus_one() ? index : nullptr; 891 Node* base = m.power_of_two_plus_one() ? index : nullptr;
893 EmitLea(this, kX64Lea32, node, index, m.scale(), base, nullptr, 892 EmitLea(this, kX64Lea32, node, index, m.scale(), base, nullptr,
894 kPositiveDisplacement); 893 kPositiveDisplacement);
895 return; 894 return;
896 } 895 }
897 VisitMul(this, node, kX64Imul32); 896 VisitMul(this, node, kX64Imul32);
898 } 897 }
899 898
899 void InstructionSelector::VisitInt32MulWithOverflow(Node* node) {
900 // TODO(mvstanton): Use Int32ScaleMatcher somehow.
901 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
902 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
903 return VisitBinop(this, node, kX64Imul32, &cont);
904 }
905 FlagsContinuation cont;
906 VisitBinop(this, node, kX64Imul32, &cont);
907 }
900 908
901 void InstructionSelector::VisitInt64Mul(Node* node) { 909 void InstructionSelector::VisitInt64Mul(Node* node) {
902 VisitMul(this, node, kX64Imul); 910 VisitMul(this, node, kX64Imul);
903 } 911 }
904 912
905
906 void InstructionSelector::VisitInt32MulHigh(Node* node) { 913 void InstructionSelector::VisitInt32MulHigh(Node* node) {
907 VisitMulHigh(this, node, kX64ImulHigh32); 914 VisitMulHigh(this, node, kX64ImulHigh32);
908 } 915 }
909 916
910 917
911 void InstructionSelector::VisitInt32Div(Node* node) { 918 void InstructionSelector::VisitInt32Div(Node* node) {
912 VisitDiv(this, node, kX64Idiv32); 919 VisitDiv(this, node, kX64Idiv32);
913 } 920 }
914 921
915 922
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 Node* const node = value->InputAt(0); 1776 Node* const node = value->InputAt(0);
1770 Node* const result = NodeProperties::FindProjection(node, 0); 1777 Node* const result = NodeProperties::FindProjection(node, 0);
1771 if (result == nullptr || selector->IsDefined(result)) { 1778 if (result == nullptr || selector->IsDefined(result)) {
1772 switch (node->opcode()) { 1779 switch (node->opcode()) {
1773 case IrOpcode::kInt32AddWithOverflow: 1780 case IrOpcode::kInt32AddWithOverflow:
1774 cont->OverwriteAndNegateIfEqual(kOverflow); 1781 cont->OverwriteAndNegateIfEqual(kOverflow);
1775 return VisitBinop(selector, node, kX64Add32, cont); 1782 return VisitBinop(selector, node, kX64Add32, cont);
1776 case IrOpcode::kInt32SubWithOverflow: 1783 case IrOpcode::kInt32SubWithOverflow:
1777 cont->OverwriteAndNegateIfEqual(kOverflow); 1784 cont->OverwriteAndNegateIfEqual(kOverflow);
1778 return VisitBinop(selector, node, kX64Sub32, cont); 1785 return VisitBinop(selector, node, kX64Sub32, cont);
1786 case IrOpcode::kInt32MulWithOverflow:
1787 cont->OverwriteAndNegateIfEqual(kOverflow);
1788 return VisitBinop(selector, node, kX64Imul32, cont);
1779 case IrOpcode::kInt64AddWithOverflow: 1789 case IrOpcode::kInt64AddWithOverflow:
1780 cont->OverwriteAndNegateIfEqual(kOverflow); 1790 cont->OverwriteAndNegateIfEqual(kOverflow);
1781 return VisitBinop(selector, node, kX64Add, cont); 1791 return VisitBinop(selector, node, kX64Add, cont);
1782 case IrOpcode::kInt64SubWithOverflow: 1792 case IrOpcode::kInt64SubWithOverflow:
1783 cont->OverwriteAndNegateIfEqual(kOverflow); 1793 cont->OverwriteAndNegateIfEqual(kOverflow);
1784 return VisitBinop(selector, node, kX64Sub, cont); 1794 return VisitBinop(selector, node, kX64Sub, cont);
1785 default: 1795 default:
1786 break; 1796 break;
1787 } 1797 }
1788 } 1798 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 // static 2156 // static
2147 MachineOperatorBuilder::AlignmentRequirements 2157 MachineOperatorBuilder::AlignmentRequirements
2148 InstructionSelector::AlignmentRequirements() { 2158 InstructionSelector::AlignmentRequirements() {
2149 return MachineOperatorBuilder::AlignmentRequirements:: 2159 return MachineOperatorBuilder::AlignmentRequirements::
2150 FullUnalignedAccessSupport(); 2160 FullUnalignedAccessSupport();
2151 } 2161 }
2152 2162
2153 } // namespace compiler 2163 } // namespace compiler
2154 } // namespace internal 2164 } // namespace internal
2155 } // namespace v8 2165 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698