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/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/arm64/macro-assembler-arm64.h" | 8 #include "src/arm64/macro-assembler-arm64.h" |
9 #include "src/compiler/code-generator-impl.h" | 9 #include "src/compiler/code-generator-impl.h" |
10 #include "src/compiler/gap-resolver.h" | 10 #include "src/compiler/gap-resolver.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 DoubleRegister OutputFloat32Register() { return OutputDoubleRegister().S(); } | 36 DoubleRegister OutputFloat32Register() { return OutputDoubleRegister().S(); } |
37 | 37 |
38 DoubleRegister OutputFloat64Register() { return OutputDoubleRegister(); } | 38 DoubleRegister OutputFloat64Register() { return OutputDoubleRegister(); } |
39 | 39 |
40 Register InputRegister32(size_t index) { | 40 Register InputRegister32(size_t index) { |
41 return ToRegister(instr_->InputAt(index)).W(); | 41 return ToRegister(instr_->InputAt(index)).W(); |
42 } | 42 } |
43 | 43 |
| 44 Register InputOrZeroRegister32(size_t index) { |
| 45 DCHECK(instr_->InputAt(index)->IsRegister() || |
| 46 (instr_->InputAt(index)->IsImmediate() && (InputInt32(index) == 0))); |
| 47 if (instr_->InputAt(index)->IsImmediate()) { |
| 48 return wzr; |
| 49 } |
| 50 return InputRegister32(index); |
| 51 } |
| 52 |
44 Register InputRegister64(size_t index) { return InputRegister(index); } | 53 Register InputRegister64(size_t index) { return InputRegister(index); } |
45 | 54 |
| 55 Register InputOrZeroRegister64(size_t index) { |
| 56 DCHECK(instr_->InputAt(index)->IsRegister() || |
| 57 (instr_->InputAt(index)->IsImmediate() && (InputInt64(index) == 0))); |
| 58 if (instr_->InputAt(index)->IsImmediate()) { |
| 59 return xzr; |
| 60 } |
| 61 return InputRegister64(index); |
| 62 } |
| 63 |
46 Operand InputImmediate(size_t index) { | 64 Operand InputImmediate(size_t index) { |
47 return ToImmediate(instr_->InputAt(index)); | 65 return ToImmediate(instr_->InputAt(index)); |
48 } | 66 } |
49 | 67 |
50 Operand InputOperand(size_t index) { | 68 Operand InputOperand(size_t index) { |
51 return ToOperand(instr_->InputAt(index)); | 69 return ToOperand(instr_->InputAt(index)); |
52 } | 70 } |
53 | 71 |
54 Operand InputOperand64(size_t index) { return InputOperand(index); } | 72 Operand InputOperand64(size_t index) { return InputOperand(index); } |
55 | 73 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 case kArm64Float64RoundTiesAway: | 530 case kArm64Float64RoundTiesAway: |
513 __ Frinta(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); | 531 __ Frinta(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); |
514 break; | 532 break; |
515 case kArm64Float64RoundTruncate: | 533 case kArm64Float64RoundTruncate: |
516 __ Frintz(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); | 534 __ Frintz(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); |
517 break; | 535 break; |
518 case kArm64Float64RoundUp: | 536 case kArm64Float64RoundUp: |
519 __ Frintp(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); | 537 __ Frintp(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); |
520 break; | 538 break; |
521 case kArm64Add: | 539 case kArm64Add: |
522 __ Add(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 540 __ Add(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 541 i.InputOperand2_64(1)); |
523 break; | 542 break; |
524 case kArm64Add32: | 543 case kArm64Add32: |
525 if (FlagsModeField::decode(opcode) != kFlags_none) { | 544 if (FlagsModeField::decode(opcode) != kFlags_none) { |
526 __ Adds(i.OutputRegister32(), i.InputRegister32(0), | 545 __ Adds(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
527 i.InputOperand2_32(1)); | 546 i.InputOperand2_32(1)); |
528 } else { | 547 } else { |
529 __ Add(i.OutputRegister32(), i.InputRegister32(0), | 548 __ Add(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
530 i.InputOperand2_32(1)); | 549 i.InputOperand2_32(1)); |
531 } | 550 } |
532 break; | 551 break; |
533 case kArm64And: | 552 case kArm64And: |
534 __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 553 __ And(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 554 i.InputOperand2_64(1)); |
535 break; | 555 break; |
536 case kArm64And32: | 556 case kArm64And32: |
537 __ And(i.OutputRegister32(), i.InputRegister32(0), i.InputOperand2_32(1)); | 557 __ And(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
| 558 i.InputOperand2_32(1)); |
538 break; | 559 break; |
539 case kArm64Bic: | 560 case kArm64Bic: |
540 __ Bic(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 561 __ Bic(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 562 i.InputOperand2_64(1)); |
541 break; | 563 break; |
542 case kArm64Bic32: | 564 case kArm64Bic32: |
543 __ Bic(i.OutputRegister32(), i.InputRegister32(0), i.InputOperand2_32(1)); | 565 __ Bic(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
| 566 i.InputOperand2_32(1)); |
544 break; | 567 break; |
545 case kArm64Mul: | 568 case kArm64Mul: |
546 __ Mul(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); | 569 __ Mul(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); |
547 break; | 570 break; |
548 case kArm64Mul32: | 571 case kArm64Mul32: |
549 __ Mul(i.OutputRegister32(), i.InputRegister32(0), i.InputRegister32(1)); | 572 __ Mul(i.OutputRegister32(), i.InputRegister32(0), i.InputRegister32(1)); |
550 break; | 573 break; |
551 case kArm64Smull: | 574 case kArm64Smull: |
552 __ Smull(i.OutputRegister(), i.InputRegister32(0), i.InputRegister32(1)); | 575 __ Smull(i.OutputRegister(), i.InputRegister32(0), i.InputRegister32(1)); |
553 break; | 576 break; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 __ Msub(i.OutputRegister32(), temp, i.InputRegister32(1), | 640 __ Msub(i.OutputRegister32(), temp, i.InputRegister32(1), |
618 i.InputRegister32(0)); | 641 i.InputRegister32(0)); |
619 break; | 642 break; |
620 } | 643 } |
621 case kArm64Not: | 644 case kArm64Not: |
622 __ Mvn(i.OutputRegister(), i.InputOperand(0)); | 645 __ Mvn(i.OutputRegister(), i.InputOperand(0)); |
623 break; | 646 break; |
624 case kArm64Not32: | 647 case kArm64Not32: |
625 __ Mvn(i.OutputRegister32(), i.InputOperand32(0)); | 648 __ Mvn(i.OutputRegister32(), i.InputOperand32(0)); |
626 break; | 649 break; |
627 case kArm64Neg: | |
628 __ Neg(i.OutputRegister(), i.InputOperand(0)); | |
629 break; | |
630 case kArm64Neg32: | |
631 __ Neg(i.OutputRegister32(), i.InputOperand32(0)); | |
632 break; | |
633 case kArm64Or: | 650 case kArm64Or: |
634 __ Orr(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 651 __ Orr(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 652 i.InputOperand2_64(1)); |
635 break; | 653 break; |
636 case kArm64Or32: | 654 case kArm64Or32: |
637 __ Orr(i.OutputRegister32(), i.InputRegister32(0), i.InputOperand2_32(1)); | 655 __ Orr(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
| 656 i.InputOperand2_32(1)); |
638 break; | 657 break; |
639 case kArm64Orn: | 658 case kArm64Orn: |
640 __ Orn(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 659 __ Orn(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 660 i.InputOperand2_64(1)); |
641 break; | 661 break; |
642 case kArm64Orn32: | 662 case kArm64Orn32: |
643 __ Orn(i.OutputRegister32(), i.InputRegister32(0), i.InputOperand2_32(1)); | 663 __ Orn(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
| 664 i.InputOperand2_32(1)); |
644 break; | 665 break; |
645 case kArm64Eor: | 666 case kArm64Eor: |
646 __ Eor(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 667 __ Eor(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 668 i.InputOperand2_64(1)); |
647 break; | 669 break; |
648 case kArm64Eor32: | 670 case kArm64Eor32: |
649 __ Eor(i.OutputRegister32(), i.InputRegister32(0), i.InputOperand2_32(1)); | 671 __ Eor(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
| 672 i.InputOperand2_32(1)); |
650 break; | 673 break; |
651 case kArm64Eon: | 674 case kArm64Eon: |
652 __ Eon(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 675 __ Eon(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 676 i.InputOperand2_64(1)); |
653 break; | 677 break; |
654 case kArm64Eon32: | 678 case kArm64Eon32: |
655 __ Eon(i.OutputRegister32(), i.InputRegister32(0), i.InputOperand2_32(1)); | 679 __ Eon(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
| 680 i.InputOperand2_32(1)); |
656 break; | 681 break; |
657 case kArm64Sub: | 682 case kArm64Sub: |
658 __ Sub(i.OutputRegister(), i.InputRegister(0), i.InputOperand2_64(1)); | 683 __ Sub(i.OutputRegister(), i.InputOrZeroRegister64(0), |
| 684 i.InputOperand2_64(1)); |
659 break; | 685 break; |
660 case kArm64Sub32: | 686 case kArm64Sub32: |
661 if (FlagsModeField::decode(opcode) != kFlags_none) { | 687 if (FlagsModeField::decode(opcode) != kFlags_none) { |
662 __ Subs(i.OutputRegister32(), i.InputRegister32(0), | 688 __ Subs(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
663 i.InputOperand2_32(1)); | 689 i.InputOperand2_32(1)); |
664 } else { | 690 } else { |
665 __ Sub(i.OutputRegister32(), i.InputRegister32(0), | 691 __ Sub(i.OutputRegister32(), i.InputOrZeroRegister32(0), |
666 i.InputOperand2_32(1)); | 692 i.InputOperand2_32(1)); |
667 } | 693 } |
668 break; | 694 break; |
669 case kArm64Lsl: | 695 case kArm64Lsl: |
670 ASSEMBLE_SHIFT(Lsl, 64); | 696 ASSEMBLE_SHIFT(Lsl, 64); |
671 break; | 697 break; |
672 case kArm64Lsl32: | 698 case kArm64Lsl32: |
673 ASSEMBLE_SHIFT(Lsl, 32); | 699 ASSEMBLE_SHIFT(Lsl, 32); |
674 break; | 700 break; |
675 case kArm64Lsr: | 701 case kArm64Lsr: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 } | 766 } |
741 case kArm64PokePair: { | 767 case kArm64PokePair: { |
742 int slot = i.InputInt32(2) - 1; | 768 int slot = i.InputInt32(2) - 1; |
743 __ PokePair(i.InputRegister(1), i.InputRegister(0), slot * kPointerSize); | 769 __ PokePair(i.InputRegister(1), i.InputRegister(0), slot * kPointerSize); |
744 break; | 770 break; |
745 } | 771 } |
746 case kArm64Clz32: | 772 case kArm64Clz32: |
747 __ Clz(i.OutputRegister32(), i.InputRegister32(0)); | 773 __ Clz(i.OutputRegister32(), i.InputRegister32(0)); |
748 break; | 774 break; |
749 case kArm64Cmp: | 775 case kArm64Cmp: |
750 __ Cmp(i.InputRegister(0), i.InputOperand(1)); | 776 __ Cmp(i.InputOrZeroRegister64(0), i.InputOperand(1)); |
751 break; | 777 break; |
752 case kArm64Cmp32: | 778 case kArm64Cmp32: |
753 __ Cmp(i.InputRegister32(0), i.InputOperand2_32(1)); | 779 __ Cmp(i.InputOrZeroRegister32(0), i.InputOperand2_32(1)); |
754 break; | 780 break; |
755 case kArm64Cmn: | 781 case kArm64Cmn: |
756 __ Cmn(i.InputRegister(0), i.InputOperand(1)); | 782 __ Cmn(i.InputRegister(0), i.InputOperand(1)); |
757 break; | 783 break; |
758 case kArm64Cmn32: | 784 case kArm64Cmn32: |
759 __ Cmn(i.InputRegister32(0), i.InputOperand32(1)); | 785 __ Cmn(i.InputRegister32(0), i.InputOperand32(1)); |
760 break; | 786 break; |
761 case kArm64Tst: | 787 case kArm64Tst: |
762 __ Tst(i.InputRegister(0), i.InputOperand(1)); | 788 __ Tst(i.InputRegister(0), i.InputOperand(1)); |
763 break; | 789 break; |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 padding_size -= kInstructionSize; | 1444 padding_size -= kInstructionSize; |
1419 } | 1445 } |
1420 } | 1446 } |
1421 } | 1447 } |
1422 | 1448 |
1423 #undef __ | 1449 #undef __ |
1424 | 1450 |
1425 } // namespace compiler | 1451 } // namespace compiler |
1426 } // namespace internal | 1452 } // namespace internal |
1427 } // namespace v8 | 1453 } // namespace v8 |
OLD | NEW |