OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/s390/frames-s390.h" | 9 #include "src/s390/frames-s390.h" |
10 | 10 |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 g.DefineAsRegister(node), g.UseRegister(base), | 867 g.DefineAsRegister(node), g.UseRegister(base), |
868 g.UseRegister(offset)); | 868 g.UseRegister(offset)); |
869 return; | 869 return; |
870 } | 870 } |
871 } | 871 } |
872 Emit(kS390_LoadReverse32RR, g.DefineAsRegister(node), | 872 Emit(kS390_LoadReverse32RR, g.DefineAsRegister(node), |
873 g.UseRegister(node->InputAt(0))); | 873 g.UseRegister(node->InputAt(0))); |
874 } | 874 } |
875 | 875 |
876 void InstructionSelector::VisitInt32Add(Node* node) { | 876 void InstructionSelector::VisitInt32Add(Node* node) { |
877 VisitBinop<Int32BinopMatcher>(this, node, kS390_Add, kInt16Imm); | 877 VisitBinop<Int32BinopMatcher>(this, node, kS390_Add32, kInt16Imm); |
878 } | 878 } |
879 | 879 |
880 #if V8_TARGET_ARCH_S390X | 880 #if V8_TARGET_ARCH_S390X |
881 void InstructionSelector::VisitInt64Add(Node* node) { | 881 void InstructionSelector::VisitInt64Add(Node* node) { |
882 VisitBinop<Int64BinopMatcher>(this, node, kS390_Add, kInt16Imm); | 882 VisitBinop<Int64BinopMatcher>(this, node, kS390_Add64, kInt16Imm); |
883 } | 883 } |
884 #endif | 884 #endif |
885 | 885 |
886 void InstructionSelector::VisitInt32Sub(Node* node) { | 886 void InstructionSelector::VisitInt32Sub(Node* node) { |
887 S390OperandGenerator g(this); | 887 S390OperandGenerator g(this); |
888 Int32BinopMatcher m(node); | 888 Int32BinopMatcher m(node); |
889 if (m.left().Is(0)) { | 889 if (m.left().Is(0)) { |
890 Emit(kS390_Neg, g.DefineAsRegister(node), g.UseRegister(m.right().node())); | 890 Emit(kS390_Neg32, g.DefineAsRegister(node), |
| 891 g.UseRegister(m.right().node())); |
891 } else { | 892 } else { |
892 VisitBinop<Int32BinopMatcher>(this, node, kS390_Sub, kInt16Imm_Negate); | 893 VisitBinop<Int32BinopMatcher>(this, node, kS390_Sub32, kInt16Imm_Negate); |
893 } | 894 } |
894 } | 895 } |
895 | 896 |
896 #if V8_TARGET_ARCH_S390X | 897 #if V8_TARGET_ARCH_S390X |
897 void InstructionSelector::VisitInt64Sub(Node* node) { | 898 void InstructionSelector::VisitInt64Sub(Node* node) { |
898 S390OperandGenerator g(this); | 899 S390OperandGenerator g(this); |
899 Int64BinopMatcher m(node); | 900 Int64BinopMatcher m(node); |
900 if (m.left().Is(0)) { | 901 if (m.left().Is(0)) { |
901 Emit(kS390_Neg, g.DefineAsRegister(node), g.UseRegister(m.right().node())); | 902 Emit(kS390_Neg64, g.DefineAsRegister(node), |
| 903 g.UseRegister(m.right().node())); |
902 } else { | 904 } else { |
903 VisitBinop<Int64BinopMatcher>(this, node, kS390_Sub, kInt16Imm_Negate); | 905 VisitBinop<Int64BinopMatcher>(this, node, kS390_Sub64, kInt16Imm_Negate); |
904 } | 906 } |
905 } | 907 } |
906 #endif | 908 #endif |
907 | 909 |
908 namespace { | 910 namespace { |
909 | 911 |
910 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 912 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
911 InstructionOperand left, InstructionOperand right, | 913 InstructionOperand left, InstructionOperand right, |
912 FlagsContinuation* cont); | 914 FlagsContinuation* cont); |
913 void EmitInt32MulWithOverflow(InstructionSelector* selector, Node* node, | 915 void EmitInt32MulWithOverflow(InstructionSelector* selector, Node* node, |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 UNREACHABLE(); | 1279 UNREACHABLE(); |
1278 } | 1280 } |
1279 | 1281 |
1280 void InstructionSelector::VisitFloat32Neg(Node* node) { UNREACHABLE(); } | 1282 void InstructionSelector::VisitFloat32Neg(Node* node) { UNREACHABLE(); } |
1281 | 1283 |
1282 void InstructionSelector::VisitFloat64Neg(Node* node) { UNREACHABLE(); } | 1284 void InstructionSelector::VisitFloat64Neg(Node* node) { UNREACHABLE(); } |
1283 | 1285 |
1284 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { | 1286 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { |
1285 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { | 1287 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1286 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); | 1288 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); |
1287 return VisitBinop<Int32BinopMatcher>(this, node, kS390_AddWithOverflow32, | 1289 return VisitBinop<Int32BinopMatcher>(this, node, kS390_Add32, kInt16Imm, |
1288 kInt16Imm, &cont); | 1290 &cont); |
1289 } | 1291 } |
1290 FlagsContinuation cont; | 1292 FlagsContinuation cont; |
1291 VisitBinop<Int32BinopMatcher>(this, node, kS390_AddWithOverflow32, kInt16Imm, | 1293 VisitBinop<Int32BinopMatcher>(this, node, kS390_Add32, kInt16Imm, &cont); |
1292 &cont); | |
1293 } | 1294 } |
1294 | 1295 |
1295 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { | 1296 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { |
1296 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { | 1297 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1297 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); | 1298 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); |
1298 return VisitBinop<Int32BinopMatcher>(this, node, kS390_SubWithOverflow32, | 1299 return VisitBinop<Int32BinopMatcher>(this, node, kS390_Sub32, |
1299 kInt16Imm_Negate, &cont); | 1300 kInt16Imm_Negate, &cont); |
1300 } | 1301 } |
1301 FlagsContinuation cont; | 1302 FlagsContinuation cont; |
1302 VisitBinop<Int32BinopMatcher>(this, node, kS390_SubWithOverflow32, | 1303 VisitBinop<Int32BinopMatcher>(this, node, kS390_Sub32, kInt16Imm_Negate, |
1303 kInt16Imm_Negate, &cont); | 1304 &cont); |
1304 } | 1305 } |
1305 | 1306 |
1306 #if V8_TARGET_ARCH_S390X | 1307 #if V8_TARGET_ARCH_S390X |
1307 void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { | 1308 void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { |
1308 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { | 1309 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1309 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); | 1310 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); |
1310 return VisitBinop<Int64BinopMatcher>(this, node, kS390_Add, kInt16Imm, | 1311 return VisitBinop<Int64BinopMatcher>(this, node, kS390_Add64, kInt16Imm, |
1311 &cont); | 1312 &cont); |
1312 } | 1313 } |
1313 FlagsContinuation cont; | 1314 FlagsContinuation cont; |
1314 VisitBinop<Int64BinopMatcher>(this, node, kS390_Add, kInt16Imm, &cont); | 1315 VisitBinop<Int64BinopMatcher>(this, node, kS390_Add64, kInt16Imm, &cont); |
1315 } | 1316 } |
1316 | 1317 |
1317 void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { | 1318 void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { |
1318 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { | 1319 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1319 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); | 1320 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); |
1320 return VisitBinop<Int64BinopMatcher>(this, node, kS390_Sub, | 1321 return VisitBinop<Int64BinopMatcher>(this, node, kS390_Sub64, |
1321 kInt16Imm_Negate, &cont); | 1322 kInt16Imm_Negate, &cont); |
1322 } | 1323 } |
1323 FlagsContinuation cont; | 1324 FlagsContinuation cont; |
1324 VisitBinop<Int64BinopMatcher>(this, node, kS390_Sub, kInt16Imm_Negate, &cont); | 1325 VisitBinop<Int64BinopMatcher>(this, node, kS390_Sub64, kInt16Imm_Negate, |
| 1326 &cont); |
1325 } | 1327 } |
1326 #endif | 1328 #endif |
1327 | 1329 |
1328 static bool CompareLogical(FlagsContinuation* cont) { | 1330 static bool CompareLogical(FlagsContinuation* cont) { |
1329 switch (cont->condition()) { | 1331 switch (cont->condition()) { |
1330 case kUnsignedLessThan: | 1332 case kUnsignedLessThan: |
1331 case kUnsignedGreaterThanOrEqual: | 1333 case kUnsignedGreaterThanOrEqual: |
1332 case kUnsignedLessThanOrEqual: | 1334 case kUnsignedLessThanOrEqual: |
1333 case kUnsignedGreaterThan: | 1335 case kUnsignedGreaterThan: |
1334 return true; | 1336 return true; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 // <Operation> is either nullptr, which means there's no use of the | 1492 // <Operation> is either nullptr, which means there's no use of the |
1491 // actual value, or was already defined, which means it is scheduled | 1493 // actual value, or was already defined, which means it is scheduled |
1492 // *AFTER* this branch). | 1494 // *AFTER* this branch). |
1493 Node* const node = value->InputAt(0); | 1495 Node* const node = value->InputAt(0); |
1494 Node* const result = NodeProperties::FindProjection(node, 0); | 1496 Node* const result = NodeProperties::FindProjection(node, 0); |
1495 if (result == nullptr || selector->IsDefined(result)) { | 1497 if (result == nullptr || selector->IsDefined(result)) { |
1496 switch (node->opcode()) { | 1498 switch (node->opcode()) { |
1497 case IrOpcode::kInt32AddWithOverflow: | 1499 case IrOpcode::kInt32AddWithOverflow: |
1498 cont->OverwriteAndNegateIfEqual(kOverflow); | 1500 cont->OverwriteAndNegateIfEqual(kOverflow); |
1499 return VisitBinop<Int32BinopMatcher>( | 1501 return VisitBinop<Int32BinopMatcher>( |
1500 selector, node, kS390_AddWithOverflow32, kInt16Imm, cont); | 1502 selector, node, kS390_Add32, kInt16Imm, cont); |
1501 case IrOpcode::kInt32SubWithOverflow: | 1503 case IrOpcode::kInt32SubWithOverflow: |
1502 cont->OverwriteAndNegateIfEqual(kOverflow); | 1504 cont->OverwriteAndNegateIfEqual(kOverflow); |
1503 return VisitBinop<Int32BinopMatcher>(selector, node, | 1505 return VisitBinop<Int32BinopMatcher>( |
1504 kS390_SubWithOverflow32, | 1506 selector, node, kS390_Sub32, kInt16Imm_Negate, cont); |
1505 kInt16Imm_Negate, cont); | |
1506 case IrOpcode::kInt32MulWithOverflow: | 1507 case IrOpcode::kInt32MulWithOverflow: |
1507 cont->OverwriteAndNegateIfEqual(kNotEqual); | 1508 cont->OverwriteAndNegateIfEqual(kNotEqual); |
1508 return EmitInt32MulWithOverflow(selector, node, cont); | 1509 return EmitInt32MulWithOverflow(selector, node, cont); |
1509 #if V8_TARGET_ARCH_S390X | 1510 #if V8_TARGET_ARCH_S390X |
1510 case IrOpcode::kInt64AddWithOverflow: | 1511 case IrOpcode::kInt64AddWithOverflow: |
1511 cont->OverwriteAndNegateIfEqual(kOverflow); | 1512 cont->OverwriteAndNegateIfEqual(kOverflow); |
1512 return VisitBinop<Int64BinopMatcher>(selector, node, kS390_Add, | 1513 return VisitBinop<Int64BinopMatcher>( |
1513 kInt16Imm, cont); | 1514 selector, node, kS390_Add64, kInt16Imm, cont); |
1514 case IrOpcode::kInt64SubWithOverflow: | 1515 case IrOpcode::kInt64SubWithOverflow: |
1515 cont->OverwriteAndNegateIfEqual(kOverflow); | 1516 cont->OverwriteAndNegateIfEqual(kOverflow); |
1516 return VisitBinop<Int64BinopMatcher>(selector, node, kS390_Sub, | 1517 return VisitBinop<Int64BinopMatcher>( |
1517 kInt16Imm_Negate, cont); | 1518 selector, node, kS390_Sub64, kInt16Imm_Negate, cont); |
1518 #endif | 1519 #endif |
1519 default: | 1520 default: |
1520 break; | 1521 break; |
1521 } | 1522 } |
1522 } | 1523 } |
1523 } | 1524 } |
1524 break; | 1525 break; |
1525 case IrOpcode::kInt32Sub: | 1526 case IrOpcode::kInt32Sub: |
1526 return VisitWord32Compare(selector, value, cont); | 1527 return VisitWord32Compare(selector, value, cont); |
1527 case IrOpcode::kWord32And: | 1528 case IrOpcode::kWord32And: |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 size_t table_time_cost = 3; | 1604 size_t table_time_cost = 3; |
1604 size_t lookup_space_cost = 3 + 2 * sw.case_count; | 1605 size_t lookup_space_cost = 3 + 2 * sw.case_count; |
1605 size_t lookup_time_cost = sw.case_count; | 1606 size_t lookup_time_cost = sw.case_count; |
1606 if (sw.case_count > 0 && | 1607 if (sw.case_count > 0 && |
1607 table_space_cost + 3 * table_time_cost <= | 1608 table_space_cost + 3 * table_time_cost <= |
1608 lookup_space_cost + 3 * lookup_time_cost && | 1609 lookup_space_cost + 3 * lookup_time_cost && |
1609 sw.min_value > std::numeric_limits<int32_t>::min()) { | 1610 sw.min_value > std::numeric_limits<int32_t>::min()) { |
1610 InstructionOperand index_operand = value_operand; | 1611 InstructionOperand index_operand = value_operand; |
1611 if (sw.min_value) { | 1612 if (sw.min_value) { |
1612 index_operand = g.TempRegister(); | 1613 index_operand = g.TempRegister(); |
1613 Emit(kS390_Sub, index_operand, value_operand, | 1614 Emit(kS390_Sub32, index_operand, value_operand, |
1614 g.TempImmediate(sw.min_value)); | 1615 g.TempImmediate(sw.min_value)); |
1615 } | 1616 } |
1616 // Generate a table lookup. | 1617 // Generate a table lookup. |
1617 return EmitTableSwitch(sw, index_operand); | 1618 return EmitTableSwitch(sw, index_operand); |
1618 } | 1619 } |
1619 | 1620 |
1620 // Generate a sequence of conditional jumps. | 1621 // Generate a sequence of conditional jumps. |
1621 return EmitLookupSwitch(sw, value_operand); | 1622 return EmitLookupSwitch(sw, value_operand); |
1622 } | 1623 } |
1623 | 1624 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 // static | 1886 // static |
1886 MachineOperatorBuilder::AlignmentRequirements | 1887 MachineOperatorBuilder::AlignmentRequirements |
1887 InstructionSelector::AlignmentRequirements() { | 1888 InstructionSelector::AlignmentRequirements() { |
1888 return MachineOperatorBuilder::AlignmentRequirements:: | 1889 return MachineOperatorBuilder::AlignmentRequirements:: |
1889 FullUnalignedAccessSupport(); | 1890 FullUnalignedAccessSupport(); |
1890 } | 1891 } |
1891 | 1892 |
1892 } // namespace compiler | 1893 } // namespace compiler |
1893 } // namespace internal | 1894 } // namespace internal |
1894 } // namespace v8 | 1895 } // namespace v8 |
OLD | NEW |