| 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 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 namespace compiler { | 10 namespace compiler { |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 | 1020 |
| 1021 | 1021 |
| 1022 // Shared routine for comparison with zero. | 1022 // Shared routine for comparison with zero. |
| 1023 static void VisitCompareZero(InstructionSelector* selector, Node* node, | 1023 static void VisitCompareZero(InstructionSelector* selector, Node* node, |
| 1024 InstructionCode opcode, FlagsContinuation* cont) { | 1024 InstructionCode opcode, FlagsContinuation* cont) { |
| 1025 X64OperandGenerator g(selector); | 1025 X64OperandGenerator g(selector); |
| 1026 VisitCompare(selector, opcode, g.Use(node), g.TempImmediate(0), cont); | 1026 VisitCompare(selector, opcode, g.Use(node), g.TempImmediate(0), cont); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 | 1029 |
| 1030 // Shared routine for multiple float64 compare operations. | 1030 // Shared routine for multiple float64 compare operations (inputs commuted). |
| 1031 static void VisitFloat64Compare(InstructionSelector* selector, Node* node, | 1031 static void VisitFloat64Compare(InstructionSelector* selector, Node* node, |
| 1032 FlagsContinuation* cont) { | 1032 FlagsContinuation* cont) { |
| 1033 VisitCompare(selector, kSSEFloat64Cmp, node->InputAt(0), node->InputAt(1), | 1033 Node* const left = node->InputAt(0); |
| 1034 cont, node->op()->HasProperty(Operator::kCommutative)); | 1034 Node* const right = node->InputAt(1); |
| 1035 VisitCompare(selector, kSSEFloat64Cmp, right, left, cont, false); |
| 1035 } | 1036 } |
| 1036 | 1037 |
| 1037 | 1038 |
| 1038 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1039 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
| 1039 BasicBlock* fbranch) { | 1040 BasicBlock* fbranch) { |
| 1040 X64OperandGenerator g(this); | 1041 X64OperandGenerator g(this); |
| 1041 Node* user = branch; | 1042 Node* user = branch; |
| 1042 Node* value = branch->InputAt(0); | 1043 Node* value = branch->InputAt(0); |
| 1043 | 1044 |
| 1044 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1045 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 case IrOpcode::kInt64LessThanOrEqual: | 1096 case IrOpcode::kInt64LessThanOrEqual: |
| 1096 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); | 1097 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); |
| 1097 return VisitWordCompare(this, value, kX64Cmp, &cont); | 1098 return VisitWordCompare(this, value, kX64Cmp, &cont); |
| 1098 case IrOpcode::kUint64LessThan: | 1099 case IrOpcode::kUint64LessThan: |
| 1099 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); | 1100 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); |
| 1100 return VisitWordCompare(this, value, kX64Cmp, &cont); | 1101 return VisitWordCompare(this, value, kX64Cmp, &cont); |
| 1101 case IrOpcode::kFloat64Equal: | 1102 case IrOpcode::kFloat64Equal: |
| 1102 cont.OverwriteAndNegateIfEqual(kUnorderedEqual); | 1103 cont.OverwriteAndNegateIfEqual(kUnorderedEqual); |
| 1103 return VisitFloat64Compare(this, value, &cont); | 1104 return VisitFloat64Compare(this, value, &cont); |
| 1104 case IrOpcode::kFloat64LessThan: | 1105 case IrOpcode::kFloat64LessThan: |
| 1105 cont.OverwriteAndNegateIfEqual(kUnorderedLessThan); | 1106 cont.OverwriteAndNegateIfEqual(kUnsignedGreaterThan); |
| 1106 return VisitFloat64Compare(this, value, &cont); | 1107 return VisitFloat64Compare(this, value, &cont); |
| 1107 case IrOpcode::kFloat64LessThanOrEqual: | 1108 case IrOpcode::kFloat64LessThanOrEqual: |
| 1108 cont.OverwriteAndNegateIfEqual(kUnorderedLessThanOrEqual); | 1109 cont.OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual); |
| 1109 return VisitFloat64Compare(this, value, &cont); | 1110 return VisitFloat64Compare(this, value, &cont); |
| 1110 case IrOpcode::kProjection: | 1111 case IrOpcode::kProjection: |
| 1111 // Check if this is the overflow output projection of an | 1112 // Check if this is the overflow output projection of an |
| 1112 // <Operation>WithOverflow node. | 1113 // <Operation>WithOverflow node. |
| 1113 if (OpParameter<size_t>(value) == 1u) { | 1114 if (OpParameter<size_t>(value) == 1u) { |
| 1114 // We cannot combine the <Operation>WithOverflow with this branch | 1115 // We cannot combine the <Operation>WithOverflow with this branch |
| 1115 // unless the 0th projection (the use of the actual value of the | 1116 // unless the 0th projection (the use of the actual value of the |
| 1116 // <Operation> is either NULL, which means there's no use of the | 1117 // <Operation> is either NULL, which means there's no use of the |
| 1117 // actual value, or was already defined, which means it is scheduled | 1118 // actual value, or was already defined, which means it is scheduled |
| 1118 // *AFTER* this branch). | 1119 // *AFTER* this branch). |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 } | 1285 } |
| 1285 | 1286 |
| 1286 | 1287 |
| 1287 void InstructionSelector::VisitFloat64Equal(Node* node) { | 1288 void InstructionSelector::VisitFloat64Equal(Node* node) { |
| 1288 FlagsContinuation cont(kUnorderedEqual, node); | 1289 FlagsContinuation cont(kUnorderedEqual, node); |
| 1289 VisitFloat64Compare(this, node, &cont); | 1290 VisitFloat64Compare(this, node, &cont); |
| 1290 } | 1291 } |
| 1291 | 1292 |
| 1292 | 1293 |
| 1293 void InstructionSelector::VisitFloat64LessThan(Node* node) { | 1294 void InstructionSelector::VisitFloat64LessThan(Node* node) { |
| 1294 FlagsContinuation cont(kUnorderedLessThan, node); | 1295 FlagsContinuation cont(kUnsignedGreaterThan, node); |
| 1295 VisitFloat64Compare(this, node, &cont); | 1296 VisitFloat64Compare(this, node, &cont); |
| 1296 } | 1297 } |
| 1297 | 1298 |
| 1298 | 1299 |
| 1299 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { | 1300 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { |
| 1300 FlagsContinuation cont(kUnorderedLessThanOrEqual, node); | 1301 FlagsContinuation cont(kUnsignedGreaterThanOrEqual, node); |
| 1301 VisitFloat64Compare(this, node, &cont); | 1302 VisitFloat64Compare(this, node, &cont); |
| 1302 } | 1303 } |
| 1303 | 1304 |
| 1304 | 1305 |
| 1305 // static | 1306 // static |
| 1306 MachineOperatorBuilder::Flags | 1307 MachineOperatorBuilder::Flags |
| 1307 InstructionSelector::SupportedMachineOperatorFlags() { | 1308 InstructionSelector::SupportedMachineOperatorFlags() { |
| 1308 if (CpuFeatures::IsSupported(SSE4_1)) { | 1309 if (CpuFeatures::IsSupported(SSE4_1)) { |
| 1309 return MachineOperatorBuilder::kFloat64Floor | | 1310 return MachineOperatorBuilder::kFloat64Floor | |
| 1310 MachineOperatorBuilder::kFloat64Ceil | | 1311 MachineOperatorBuilder::kFloat64Ceil | |
| 1311 MachineOperatorBuilder::kFloat64RoundTruncate | | 1312 MachineOperatorBuilder::kFloat64RoundTruncate | |
| 1312 MachineOperatorBuilder::kWord32ShiftIsSafe; | 1313 MachineOperatorBuilder::kWord32ShiftIsSafe; |
| 1313 } | 1314 } |
| 1314 return MachineOperatorBuilder::kNoFlags; | 1315 return MachineOperatorBuilder::kNoFlags; |
| 1315 } | 1316 } |
| 1316 | 1317 |
| 1317 } // namespace compiler | 1318 } // namespace compiler |
| 1318 } // namespace internal | 1319 } // namespace internal |
| 1319 } // namespace v8 | 1320 } // namespace v8 |
| OLD | NEW |