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 | 8 |
8 namespace v8 { | 9 namespace v8 { |
9 namespace internal { | 10 namespace internal { |
10 namespace compiler { | 11 namespace compiler { |
11 | 12 |
12 enum ImmediateMode { | 13 enum ImmediateMode { |
13 kArithmeticImm, // 12 bit unsigned immediate shifted left 0 or 12 bits | 14 kArithmeticImm, // 12 bit unsigned immediate shifted left 0 or 12 bits |
14 kShift32Imm, // 0 - 31 | 15 kShift32Imm, // 0 - 31 |
15 kShift64Imm, // 0 - 63 | 16 kShift64Imm, // 0 - 63 |
16 kLogical32Imm, | 17 kLogical32Imm, |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 return VisitFloat64Compare(this, value, &cont); | 1304 return VisitFloat64Compare(this, value, &cont); |
1304 case IrOpcode::kFloat64LessThan: | 1305 case IrOpcode::kFloat64LessThan: |
1305 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); | 1306 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); |
1306 return VisitFloat64Compare(this, value, &cont); | 1307 return VisitFloat64Compare(this, value, &cont); |
1307 case IrOpcode::kFloat64LessThanOrEqual: | 1308 case IrOpcode::kFloat64LessThanOrEqual: |
1308 cont.OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); | 1309 cont.OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); |
1309 return VisitFloat64Compare(this, value, &cont); | 1310 return VisitFloat64Compare(this, value, &cont); |
1310 case IrOpcode::kProjection: | 1311 case IrOpcode::kProjection: |
1311 // Check if this is the overflow output projection of an | 1312 // Check if this is the overflow output projection of an |
1312 // <Operation>WithOverflow node. | 1313 // <Operation>WithOverflow node. |
1313 if (OpParameter<size_t>(value) == 1u) { | 1314 if (ProjectionIndexOf(value->op()) == 1u) { |
1314 // We cannot combine the <Operation>WithOverflow with this branch | 1315 // We cannot combine the <Operation>WithOverflow with this branch |
1315 // unless the 0th projection (the use of the actual value of the | 1316 // unless the 0th projection (the use of the actual value of the |
1316 // <Operation> is either NULL, which means there's no use of the | 1317 // <Operation> is either NULL, which means there's no use of the |
1317 // actual value, or was already defined, which means it is scheduled | 1318 // actual value, or was already defined, which means it is scheduled |
1318 // *AFTER* this branch). | 1319 // *AFTER* this branch). |
1319 Node* node = value->InputAt(0); | 1320 Node* const node = value->InputAt(0); |
1320 Node* result = node->FindProjection(0); | 1321 Node* const result = NodeProperties::FindProjection(node, 0); |
1321 if (result == NULL || IsDefined(result)) { | 1322 if (result == NULL || IsDefined(result)) { |
1322 switch (node->opcode()) { | 1323 switch (node->opcode()) { |
1323 case IrOpcode::kInt32AddWithOverflow: | 1324 case IrOpcode::kInt32AddWithOverflow: |
1324 cont.OverwriteAndNegateIfEqual(kOverflow); | 1325 cont.OverwriteAndNegateIfEqual(kOverflow); |
1325 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Add32, | 1326 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Add32, |
1326 kArithmeticImm, &cont); | 1327 kArithmeticImm, &cont); |
1327 case IrOpcode::kInt32SubWithOverflow: | 1328 case IrOpcode::kInt32SubWithOverflow: |
1328 cont.OverwriteAndNegateIfEqual(kOverflow); | 1329 cont.OverwriteAndNegateIfEqual(kOverflow); |
1329 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Sub32, | 1330 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Sub32, |
1330 kArithmeticImm, &cont); | 1331 kArithmeticImm, &cont); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 break; | 1455 break; |
1455 } | 1456 } |
1456 return VisitWord64Test(this, value, &cont); | 1457 return VisitWord64Test(this, value, &cont); |
1457 } | 1458 } |
1458 } | 1459 } |
1459 VisitWordCompare(this, node, kArm64Cmp, &cont, false, kArithmeticImm); | 1460 VisitWordCompare(this, node, kArm64Cmp, &cont, false, kArithmeticImm); |
1460 } | 1461 } |
1461 | 1462 |
1462 | 1463 |
1463 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { | 1464 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { |
1464 if (Node* ovf = node->FindProjection(1)) { | 1465 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1465 FlagsContinuation cont(kOverflow, ovf); | 1466 FlagsContinuation cont(kOverflow, ovf); |
1466 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Add32, | 1467 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Add32, |
1467 kArithmeticImm, &cont); | 1468 kArithmeticImm, &cont); |
1468 } | 1469 } |
1469 FlagsContinuation cont; | 1470 FlagsContinuation cont; |
1470 VisitBinop<Int32BinopMatcher>(this, node, kArm64Add32, kArithmeticImm, &cont); | 1471 VisitBinop<Int32BinopMatcher>(this, node, kArm64Add32, kArithmeticImm, &cont); |
1471 } | 1472 } |
1472 | 1473 |
1473 | 1474 |
1474 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { | 1475 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { |
1475 if (Node* ovf = node->FindProjection(1)) { | 1476 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1476 FlagsContinuation cont(kOverflow, ovf); | 1477 FlagsContinuation cont(kOverflow, ovf); |
1477 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Sub32, | 1478 return VisitBinop<Int32BinopMatcher>(this, node, kArm64Sub32, |
1478 kArithmeticImm, &cont); | 1479 kArithmeticImm, &cont); |
1479 } | 1480 } |
1480 FlagsContinuation cont; | 1481 FlagsContinuation cont; |
1481 VisitBinop<Int32BinopMatcher>(this, node, kArm64Sub32, kArithmeticImm, &cont); | 1482 VisitBinop<Int32BinopMatcher>(this, node, kArm64Sub32, kArithmeticImm, &cont); |
1482 } | 1483 } |
1483 | 1484 |
1484 | 1485 |
1485 void InstructionSelector::VisitInt64LessThan(Node* node) { | 1486 void InstructionSelector::VisitInt64LessThan(Node* node) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 MachineOperatorBuilder::kFloat64RoundTruncate | | 1527 MachineOperatorBuilder::kFloat64RoundTruncate | |
1527 MachineOperatorBuilder::kFloat64RoundTiesAway | | 1528 MachineOperatorBuilder::kFloat64RoundTiesAway | |
1528 MachineOperatorBuilder::kWord32ShiftIsSafe | | 1529 MachineOperatorBuilder::kWord32ShiftIsSafe | |
1529 MachineOperatorBuilder::kInt32DivIsSafe | | 1530 MachineOperatorBuilder::kInt32DivIsSafe | |
1530 MachineOperatorBuilder::kUint32DivIsSafe; | 1531 MachineOperatorBuilder::kUint32DivIsSafe; |
1531 } | 1532 } |
1532 | 1533 |
1533 } // namespace compiler | 1534 } // namespace compiler |
1534 } // namespace internal | 1535 } // namespace internal |
1535 } // namespace v8 | 1536 } // namespace v8 |
OLD | NEW |