| 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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 case IrOpcode::kInt32Sub: | 1340 case IrOpcode::kInt32Sub: |
| 1341 return VisitWordCompare(this, value, kArm64Cmp32, &cont, false, | 1341 return VisitWordCompare(this, value, kArm64Cmp32, &cont, false, |
| 1342 kArithmeticImm); | 1342 kArithmeticImm); |
| 1343 case IrOpcode::kWord32And: { | 1343 case IrOpcode::kWord32And: { |
| 1344 Int32BinopMatcher m(value); | 1344 Int32BinopMatcher m(value); |
| 1345 if (m.right().HasValue() && | 1345 if (m.right().HasValue() && |
| 1346 (base::bits::CountPopulation32(m.right().Value()) == 1)) { | 1346 (base::bits::CountPopulation32(m.right().Value()) == 1)) { |
| 1347 // If the mask has only one bit set, we can use tbz/tbnz. | 1347 // If the mask has only one bit set, we can use tbz/tbnz. |
| 1348 DCHECK((cont.condition() == kEqual) || | 1348 DCHECK((cont.condition() == kEqual) || |
| 1349 (cont.condition() == kNotEqual)); | 1349 (cont.condition() == kNotEqual)); |
| 1350 ArchOpcode opcode = | 1350 Emit(cont.Encode(kArm64TestAndBranch32), NULL, |
| 1351 (cont.condition() == kEqual) ? kArm64Tbz32 : kArm64Tbnz32; | 1351 g.UseRegister(m.left().node()), |
| 1352 Emit(opcode, NULL, g.UseRegister(m.left().node()), | |
| 1353 g.TempImmediate( | 1352 g.TempImmediate( |
| 1354 base::bits::CountTrailingZeros32(m.right().Value())), | 1353 base::bits::CountTrailingZeros32(m.right().Value())), |
| 1355 g.Label(cont.true_block()), | 1354 g.Label(cont.true_block()), |
| 1356 g.Label(cont.false_block()))->MarkAsControl(); | 1355 g.Label(cont.false_block()))->MarkAsControl(); |
| 1357 return; | 1356 return; |
| 1358 } | 1357 } |
| 1359 return VisitWordCompare(this, value, kArm64Tst32, &cont, true, | 1358 return VisitWordCompare(this, value, kArm64Tst32, &cont, true, |
| 1360 kLogical32Imm); | 1359 kLogical32Imm); |
| 1361 } | 1360 } |
| 1362 case IrOpcode::kWord64And: { | 1361 case IrOpcode::kWord64And: { |
| 1363 Int64BinopMatcher m(value); | 1362 Int64BinopMatcher m(value); |
| 1364 if (m.right().HasValue() && | 1363 if (m.right().HasValue() && |
| 1365 (base::bits::CountPopulation64(m.right().Value()) == 1)) { | 1364 (base::bits::CountPopulation64(m.right().Value()) == 1)) { |
| 1366 // If the mask has only one bit set, we can use tbz/tbnz. | 1365 // If the mask has only one bit set, we can use tbz/tbnz. |
| 1367 DCHECK((cont.condition() == kEqual) || | 1366 DCHECK((cont.condition() == kEqual) || |
| 1368 (cont.condition() == kNotEqual)); | 1367 (cont.condition() == kNotEqual)); |
| 1369 ArchOpcode opcode = | 1368 Emit(cont.Encode(kArm64TestAndBranch), NULL, |
| 1370 (cont.condition() == kEqual) ? kArm64Tbz : kArm64Tbnz; | 1369 g.UseRegister(m.left().node()), |
| 1371 Emit(opcode, NULL, g.UseRegister(m.left().node()), | |
| 1372 g.TempImmediate( | 1370 g.TempImmediate( |
| 1373 base::bits::CountTrailingZeros64(m.right().Value())), | 1371 base::bits::CountTrailingZeros64(m.right().Value())), |
| 1374 g.Label(cont.true_block()), | 1372 g.Label(cont.true_block()), |
| 1375 g.Label(cont.false_block()))->MarkAsControl(); | 1373 g.Label(cont.false_block()))->MarkAsControl(); |
| 1376 return; | 1374 return; |
| 1377 } | 1375 } |
| 1378 return VisitWordCompare(this, value, kArm64Tst, &cont, true, | 1376 return VisitWordCompare(this, value, kArm64Tst, &cont, true, |
| 1379 kLogical64Imm); | 1377 kLogical64Imm); |
| 1380 } | 1378 } |
| 1381 default: | 1379 default: |
| 1382 break; | 1380 break; |
| 1383 } | 1381 } |
| 1384 } | 1382 } |
| 1385 | 1383 |
| 1386 // Branch could not be combined with a compare, compare against 0 and branch. | 1384 // Branch could not be combined with a compare, compare against 0 and branch. |
| 1387 DCHECK((cont.condition() == kEqual) || (cont.condition() == kNotEqual)); | 1385 Emit(cont.Encode(kArm64CompareAndBranch32), NULL, g.UseRegister(value), |
| 1388 ArchOpcode opcode = (cont.condition() == kEqual) ? kArm64Cbz32 : kArm64Cbnz32; | 1386 g.Label(cont.true_block()), |
| 1389 Emit(opcode, NULL, g.UseRegister(value), g.Label(cont.true_block()), | |
| 1390 g.Label(cont.false_block()))->MarkAsControl(); | 1387 g.Label(cont.false_block()))->MarkAsControl(); |
| 1391 } | 1388 } |
| 1392 | 1389 |
| 1393 | 1390 |
| 1394 void InstructionSelector::VisitWord32Equal(Node* const node) { | 1391 void InstructionSelector::VisitWord32Equal(Node* const node) { |
| 1395 Node* const user = node; | 1392 Node* const user = node; |
| 1396 FlagsContinuation cont(kEqual, node); | 1393 FlagsContinuation cont(kEqual, node); |
| 1397 Int32BinopMatcher m(user); | 1394 Int32BinopMatcher m(user); |
| 1398 if (m.right().Is(0)) { | 1395 if (m.right().Is(0)) { |
| 1399 Node* const value = m.left().node(); | 1396 Node* const value = m.left().node(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 MachineOperatorBuilder::kFloat64Ceil | | 1525 MachineOperatorBuilder::kFloat64Ceil | |
| 1529 MachineOperatorBuilder::kFloat64RoundTruncate | | 1526 MachineOperatorBuilder::kFloat64RoundTruncate | |
| 1530 MachineOperatorBuilder::kFloat64RoundTiesAway | | 1527 MachineOperatorBuilder::kFloat64RoundTiesAway | |
| 1531 MachineOperatorBuilder::kWord32ShiftIsSafe | | 1528 MachineOperatorBuilder::kWord32ShiftIsSafe | |
| 1532 MachineOperatorBuilder::kInt32DivIsSafe | | 1529 MachineOperatorBuilder::kInt32DivIsSafe | |
| 1533 MachineOperatorBuilder::kUint32DivIsSafe; | 1530 MachineOperatorBuilder::kUint32DivIsSafe; |
| 1534 } | 1531 } |
| 1535 } // namespace compiler | 1532 } // namespace compiler |
| 1536 } // namespace internal | 1533 } // namespace internal |
| 1537 } // namespace v8 | 1534 } // namespace v8 |
| OLD | NEW |