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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 Emit(kMipsSeb, g.DefineAsRegister(node), | 422 Emit(kMipsSeb, g.DefineAsRegister(node), |
423 g.UseRegister(mleft.left().node())); | 423 g.UseRegister(mleft.left().node())); |
424 return; | 424 return; |
425 } | 425 } |
426 } | 426 } |
427 } | 427 } |
428 VisitRRO(this, kMipsSar, node); | 428 VisitRRO(this, kMipsSar, node); |
429 } | 429 } |
430 | 430 |
431 static void VisitInt32PairBinop(InstructionSelector* selector, | 431 static void VisitInt32PairBinop(InstructionSelector* selector, |
432 InstructionCode opcode, Node* node) { | 432 InstructionCode pair_opcode, |
| 433 InstructionCode single_opcode, Node* node) { |
433 MipsOperandGenerator g(selector); | 434 MipsOperandGenerator g(selector); |
434 | 435 |
435 // We use UseUniqueRegister here to avoid register sharing with the output | 436 Node* projection1 = NodeProperties::FindProjection(node, 1); |
436 // register. | |
437 InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), | |
438 g.UseUniqueRegister(node->InputAt(1)), | |
439 g.UseUniqueRegister(node->InputAt(2)), | |
440 g.UseUniqueRegister(node->InputAt(3))}; | |
441 | 437 |
442 InstructionOperand outputs[] = { | 438 if (projection1) { |
443 g.DefineAsRegister(node), | 439 // We use UseUniqueRegister here to avoid register sharing with the output |
444 g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; | 440 // register. |
445 selector->Emit(opcode, 2, outputs, 4, inputs); | 441 InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), |
| 442 g.UseUniqueRegister(node->InputAt(1)), |
| 443 g.UseUniqueRegister(node->InputAt(2)), |
| 444 g.UseUniqueRegister(node->InputAt(3))}; |
| 445 |
| 446 InstructionOperand outputs[] = { |
| 447 g.DefineAsRegister(node), |
| 448 g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; |
| 449 selector->Emit(pair_opcode, 2, outputs, 4, inputs); |
| 450 } else { |
| 451 // The high word of the result is not used, so we emit the standard 32 bit |
| 452 // instruction. |
| 453 selector->Emit(single_opcode, g.DefineSameAsFirst(node), |
| 454 g.UseRegister(node->InputAt(0)), |
| 455 g.UseRegister(node->InputAt(2))); |
| 456 } |
446 } | 457 } |
447 | 458 |
448 void InstructionSelector::VisitInt32PairAdd(Node* node) { | 459 void InstructionSelector::VisitInt32PairAdd(Node* node) { |
449 VisitInt32PairBinop(this, kMipsAddPair, node); | 460 VisitInt32PairBinop(this, kMipsAddPair, kMipsAdd, node); |
450 } | 461 } |
451 | 462 |
452 void InstructionSelector::VisitInt32PairSub(Node* node) { | 463 void InstructionSelector::VisitInt32PairSub(Node* node) { |
453 VisitInt32PairBinop(this, kMipsSubPair, node); | 464 VisitInt32PairBinop(this, kMipsSubPair, kMipsSub, node); |
454 } | 465 } |
455 | 466 |
456 void InstructionSelector::VisitInt32PairMul(Node* node) { | 467 void InstructionSelector::VisitInt32PairMul(Node* node) { |
457 VisitInt32PairBinop(this, kMipsMulPair, node); | 468 VisitInt32PairBinop(this, kMipsMulPair, kMipsMul, node); |
458 } | 469 } |
459 | 470 |
460 // Shared routine for multiple shift operations. | 471 // Shared routine for multiple shift operations. |
461 static void VisitWord32PairShift(InstructionSelector* selector, | 472 static void VisitWord32PairShift(InstructionSelector* selector, |
462 InstructionCode opcode, Node* node) { | 473 InstructionCode opcode, Node* node) { |
463 MipsOperandGenerator g(selector); | 474 MipsOperandGenerator g(selector); |
464 Int32Matcher m(node->InputAt(2)); | 475 Int32Matcher m(node->InputAt(2)); |
465 InstructionOperand shift_operand; | 476 InstructionOperand shift_operand; |
466 if (m.HasValue()) { | 477 if (m.HasValue()) { |
467 shift_operand = g.UseImmediate(m.node()); | 478 shift_operand = g.UseImmediate(m.node()); |
468 } else { | 479 } else { |
469 shift_operand = g.UseUniqueRegister(m.node()); | 480 shift_operand = g.UseUniqueRegister(m.node()); |
470 } | 481 } |
471 | 482 |
472 // We use UseUniqueRegister here to avoid register sharing with the output | 483 // We use UseUniqueRegister here to avoid register sharing with the output |
473 // register. | 484 // register. |
474 InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), | 485 InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), |
475 g.UseUniqueRegister(node->InputAt(1)), | 486 g.UseUniqueRegister(node->InputAt(1)), |
476 shift_operand}; | 487 shift_operand}; |
477 | 488 |
478 InstructionOperand outputs[] = { | 489 Node* projection1 = NodeProperties::FindProjection(node, 1); |
479 g.DefineAsRegister(node), | |
480 g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; | |
481 | 490 |
482 selector->Emit(opcode, 2, outputs, 3, inputs); | 491 InstructionOperand outputs[2]; |
| 492 InstructionOperand temps[1]; |
| 493 int32_t output_count = 0; |
| 494 int32_t temp_count = 0; |
| 495 |
| 496 outputs[output_count++] = g.DefineAsRegister(node); |
| 497 if (projection1) { |
| 498 outputs[output_count++] = g.DefineAsRegister(projection1); |
| 499 } else { |
| 500 temps[temp_count++] = g.TempRegister(); |
| 501 } |
| 502 |
| 503 selector->Emit(opcode, output_count, outputs, 3, inputs, temp_count, temps); |
483 } | 504 } |
484 | 505 |
485 void InstructionSelector::VisitWord32PairShl(Node* node) { | 506 void InstructionSelector::VisitWord32PairShl(Node* node) { |
486 VisitWord32PairShift(this, kMipsShlPair, node); | 507 VisitWord32PairShift(this, kMipsShlPair, node); |
487 } | 508 } |
488 | 509 |
489 void InstructionSelector::VisitWord32PairShr(Node* node) { | 510 void InstructionSelector::VisitWord32PairShr(Node* node) { |
490 VisitWord32PairShift(this, kMipsShrPair, node); | 511 VisitWord32PairShift(this, kMipsShrPair, node); |
491 } | 512 } |
492 | 513 |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 DCHECK(IsMipsArchVariant(kLoongson) || IsMipsArchVariant(kMips32r1) || | 1807 DCHECK(IsMipsArchVariant(kLoongson) || IsMipsArchVariant(kMips32r1) || |
1787 IsMipsArchVariant(kMips32r2)); | 1808 IsMipsArchVariant(kMips32r2)); |
1788 return MachineOperatorBuilder::AlignmentRequirements:: | 1809 return MachineOperatorBuilder::AlignmentRequirements:: |
1789 NoUnalignedAccessSupport(); | 1810 NoUnalignedAccessSupport(); |
1790 } | 1811 } |
1791 } | 1812 } |
1792 | 1813 |
1793 } // namespace compiler | 1814 } // namespace compiler |
1794 } // namespace internal | 1815 } // namespace internal |
1795 } // namespace v8 | 1816 } // namespace v8 |
OLD | NEW |