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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 | 10 |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 } | 1348 } |
1349 } | 1349 } |
1350 } | 1350 } |
1351 } | 1351 } |
1352 | 1352 |
1353 | 1353 |
1354 bool InstructionSelector::IsTailCallAddressImmediate() { return false; } | 1354 bool InstructionSelector::IsTailCallAddressImmediate() { return false; } |
1355 | 1355 |
1356 int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } | 1356 int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } |
1357 | 1357 |
| 1358 void InstructionSelector::VisitUnalignedLoad(Node* node) { |
| 1359 UnalignedLoadRepresentation load_rep = |
| 1360 UnalignedLoadRepresentationOf(node->op()); |
| 1361 Mips64OperandGenerator g(this); |
| 1362 Node* base = node->InputAt(0); |
| 1363 Node* index = node->InputAt(1); |
| 1364 |
| 1365 ArchOpcode opcode = kArchNop; |
| 1366 switch (load_rep.representation()) { |
| 1367 case MachineRepresentation::kFloat32: |
| 1368 opcode = kMips64Ulwc1; |
| 1369 break; |
| 1370 case MachineRepresentation::kFloat64: |
| 1371 opcode = kMips64Uldc1; |
| 1372 break; |
| 1373 case MachineRepresentation::kBit: // Fall through. |
| 1374 case MachineRepresentation::kWord8: |
| 1375 UNREACHABLE(); |
| 1376 break; |
| 1377 case MachineRepresentation::kWord16: |
| 1378 opcode = load_rep.IsUnsigned() ? kMips64Ulhu : kMips64Ulh; |
| 1379 break; |
| 1380 case MachineRepresentation::kWord32: |
| 1381 opcode = load_rep.IsUnsigned() ? kMips64Ulwu : kMips64Ulw; |
| 1382 break; |
| 1383 case MachineRepresentation::kTagged: // Fall through. |
| 1384 case MachineRepresentation::kWord64: |
| 1385 opcode = kMips64Uld; |
| 1386 break; |
| 1387 case MachineRepresentation::kSimd128: // Fall through. |
| 1388 case MachineRepresentation::kNone: |
| 1389 UNREACHABLE(); |
| 1390 return; |
| 1391 } |
| 1392 |
| 1393 if (g.CanBeImmediate(index, opcode)) { |
| 1394 Emit(opcode | AddressingModeField::encode(kMode_MRI), |
| 1395 g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index)); |
| 1396 } else { |
| 1397 InstructionOperand addr_reg = g.TempRegister(); |
| 1398 Emit(kMips64Dadd | AddressingModeField::encode(kMode_None), addr_reg, |
| 1399 g.UseRegister(index), g.UseRegister(base)); |
| 1400 // Emit desired load opcode, using temp addr_reg. |
| 1401 Emit(opcode | AddressingModeField::encode(kMode_MRI), |
| 1402 g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); |
| 1403 } |
| 1404 } |
| 1405 |
| 1406 void InstructionSelector::VisitUnalignedStore(Node* node) { |
| 1407 Mips64OperandGenerator g(this); |
| 1408 Node* base = node->InputAt(0); |
| 1409 Node* index = node->InputAt(1); |
| 1410 Node* value = node->InputAt(2); |
| 1411 |
| 1412 UnalignedStoreRepresentation rep = UnalignedStoreRepresentationOf(node->op()); |
| 1413 ArchOpcode opcode = kArchNop; |
| 1414 switch (rep) { |
| 1415 case MachineRepresentation::kFloat32: |
| 1416 opcode = kMips64Uswc1; |
| 1417 break; |
| 1418 case MachineRepresentation::kFloat64: |
| 1419 opcode = kMips64Usdc1; |
| 1420 break; |
| 1421 case MachineRepresentation::kBit: // Fall through. |
| 1422 case MachineRepresentation::kWord8: |
| 1423 UNREACHABLE(); |
| 1424 break; |
| 1425 case MachineRepresentation::kWord16: |
| 1426 opcode = kMips64Ush; |
| 1427 break; |
| 1428 case MachineRepresentation::kWord32: |
| 1429 opcode = kMips64Usw; |
| 1430 break; |
| 1431 case MachineRepresentation::kTagged: // Fall through. |
| 1432 case MachineRepresentation::kWord64: |
| 1433 opcode = kMips64Usd; |
| 1434 break; |
| 1435 case MachineRepresentation::kSimd128: // Fall through. |
| 1436 case MachineRepresentation::kNone: |
| 1437 UNREACHABLE(); |
| 1438 return; |
| 1439 } |
| 1440 |
| 1441 if (g.CanBeImmediate(index, opcode)) { |
| 1442 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), |
| 1443 g.UseRegister(base), g.UseImmediate(index), g.UseRegister(value)); |
| 1444 } else { |
| 1445 InstructionOperand addr_reg = g.TempRegister(); |
| 1446 Emit(kMips64Dadd | AddressingModeField::encode(kMode_None), addr_reg, |
| 1447 g.UseRegister(index), g.UseRegister(base)); |
| 1448 // Emit desired store opcode, using temp addr_reg. |
| 1449 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), |
| 1450 addr_reg, g.TempImmediate(0), g.UseRegister(value)); |
| 1451 } |
| 1452 } |
| 1453 |
1358 void InstructionSelector::VisitCheckedLoad(Node* node) { | 1454 void InstructionSelector::VisitCheckedLoad(Node* node) { |
1359 CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); | 1455 CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); |
1360 Mips64OperandGenerator g(this); | 1456 Mips64OperandGenerator g(this); |
1361 Node* const buffer = node->InputAt(0); | 1457 Node* const buffer = node->InputAt(0); |
1362 Node* const offset = node->InputAt(1); | 1458 Node* const offset = node->InputAt(1); |
1363 Node* const length = node->InputAt(2); | 1459 Node* const length = node->InputAt(2); |
1364 ArchOpcode opcode = kArchNop; | 1460 ArchOpcode opcode = kArchNop; |
1365 switch (load_rep.representation()) { | 1461 switch (load_rep.representation()) { |
1366 case MachineRepresentation::kWord8: | 1462 case MachineRepresentation::kWord8: |
1367 opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; | 1463 opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 g.UseRegister(index), g.UseRegister(base)); | 2118 g.UseRegister(index), g.UseRegister(base)); |
2023 // Emit desired store opcode, using temp addr_reg. | 2119 // Emit desired store opcode, using temp addr_reg. |
2024 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), | 2120 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), |
2025 addr_reg, g.TempImmediate(0), g.UseRegister(value)); | 2121 addr_reg, g.TempImmediate(0), g.UseRegister(value)); |
2026 } | 2122 } |
2027 } | 2123 } |
2028 | 2124 |
2029 // static | 2125 // static |
2030 MachineOperatorBuilder::Flags | 2126 MachineOperatorBuilder::Flags |
2031 InstructionSelector::SupportedMachineOperatorFlags() { | 2127 InstructionSelector::SupportedMachineOperatorFlags() { |
2032 return MachineOperatorBuilder::kWord32Ctz | | 2128 MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags; |
| 2129 return flags | MachineOperatorBuilder::kWord32Ctz | |
2033 MachineOperatorBuilder::kWord64Ctz | | 2130 MachineOperatorBuilder::kWord64Ctz | |
2034 MachineOperatorBuilder::kWord32Popcnt | | 2131 MachineOperatorBuilder::kWord32Popcnt | |
2035 MachineOperatorBuilder::kWord64Popcnt | | 2132 MachineOperatorBuilder::kWord64Popcnt | |
2036 MachineOperatorBuilder::kWord32ShiftIsSafe | | 2133 MachineOperatorBuilder::kWord32ShiftIsSafe | |
2037 MachineOperatorBuilder::kInt32DivIsSafe | | 2134 MachineOperatorBuilder::kInt32DivIsSafe | |
2038 MachineOperatorBuilder::kUint32DivIsSafe | | 2135 MachineOperatorBuilder::kUint32DivIsSafe | |
2039 MachineOperatorBuilder::kFloat64RoundDown | | 2136 MachineOperatorBuilder::kFloat64RoundDown | |
2040 MachineOperatorBuilder::kFloat32RoundDown | | 2137 MachineOperatorBuilder::kFloat32RoundDown | |
2041 MachineOperatorBuilder::kFloat64RoundUp | | 2138 MachineOperatorBuilder::kFloat64RoundUp | |
2042 MachineOperatorBuilder::kFloat32RoundUp | | 2139 MachineOperatorBuilder::kFloat32RoundUp | |
(...skipping 12 matching lines...) Expand all Loading... |
2055 } else { | 2152 } else { |
2056 DCHECK(kArchVariant == kMips64r2); | 2153 DCHECK(kArchVariant == kMips64r2); |
2057 return MachineOperatorBuilder::AlignmentRequirements:: | 2154 return MachineOperatorBuilder::AlignmentRequirements:: |
2058 NoUnalignedAccessSupport(); | 2155 NoUnalignedAccessSupport(); |
2059 } | 2156 } |
2060 } | 2157 } |
2061 | 2158 |
2062 } // namespace compiler | 2159 } // namespace compiler |
2063 } // namespace internal | 2160 } // namespace internal |
2064 } // namespace v8 | 2161 } // namespace v8 |
OLD | NEW |