OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_ASSEMBLER_MIPS_H_ | 5 #ifndef VM_ASSEMBLER_MIPS_H_ |
6 #define VM_ASSEMBLER_MIPS_H_ | 6 #define VM_ASSEMBLER_MIPS_H_ |
7 | 7 |
8 #ifndef VM_ASSEMBLER_H_ | 8 #ifndef VM_ASSEMBLER_H_ |
9 #error Do not include assembler_mips.h directly; use assembler.h instead. | 9 #error Do not include assembler_mips.h directly; use assembler.h instead. |
10 #endif | 10 #endif |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 Emit(opcode << kOpcodeShift | | 665 Emit(opcode << kOpcodeShift | |
666 rs << kRsShift | | 666 rs << kRsShift | |
667 rt << kRtShift | | 667 rt << kRtShift | |
668 rd << kRdShift | | 668 rd << kRdShift | |
669 sa << kSaShift | | 669 sa << kSaShift | |
670 func << kFunctionShift); | 670 func << kFunctionShift); |
671 } | 671 } |
672 | 672 |
673 void EmitBranch(Opcode b, Register rs, Register rt, Label* label) { | 673 void EmitBranch(Opcode b, Register rs, Register rt, Label* label) { |
674 if (label->IsBound()) { | 674 if (label->IsBound()) { |
675 // Reletive destination from an instruction after the branch. | 675 // Relative destination from an instruction after the branch. |
676 const int32_t dest = | 676 const int32_t dest = |
677 label->Position() - (buffer_.Size() + Instr::kInstrSize); | 677 label->Position() - (buffer_.Size() + Instr::kInstrSize); |
678 const uint16_t dest_off = EncodeBranchOffset(dest, 0); | 678 const uint16_t dest_off = EncodeBranchOffset(dest, 0); |
679 EmitIType(b, rs, rt, dest_off); | 679 EmitIType(b, rs, rt, dest_off); |
680 } else { | 680 } else { |
681 const int position = buffer_.Size(); | 681 const int position = buffer_.Size(); |
682 EmitIType(b, rs, rt, label->position_); | 682 EmitIType(b, rs, rt, label->position_); |
683 label->LinkTo(position); | 683 label->LinkTo(position); |
684 } | 684 } |
685 } | 685 } |
686 | 686 |
687 void EmitRegImmBranch(RtRegImm b, Register rs, Label* label) { | 687 void EmitRegImmBranch(RtRegImm b, Register rs, Label* label) { |
688 if (label->IsBound()) { | 688 if (label->IsBound()) { |
689 // Reletive destination from an instruction after the branch. | 689 // Relative destination from an instruction after the branch. |
690 const int32_t dest = | 690 const int32_t dest = |
691 label->Position() - (buffer_.Size() + Instr::kInstrSize); | 691 label->Position() - (buffer_.Size() + Instr::kInstrSize); |
692 const uint16_t dest_off = EncodeBranchOffset(dest, 0); | 692 const uint16_t dest_off = EncodeBranchOffset(dest, 0); |
693 EmitRegImmType(REGIMM, rs, b, dest_off); | 693 EmitRegImmType(REGIMM, rs, b, dest_off); |
694 } else { | 694 } else { |
695 const int position = buffer_.Size(); | 695 const int position = buffer_.Size(); |
696 EmitRegImmType(REGIMM, rs, b, label->position_); | 696 EmitRegImmType(REGIMM, rs, b, label->position_); |
697 label->LinkTo(position); | 697 label->LinkTo(position); |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 static int32_t EncodeBranchOffset(int32_t offset, int32_t instr); | 701 static int32_t EncodeBranchOffset(int32_t offset, int32_t instr); |
702 static int DecodeBranchOffset(int32_t instr); | 702 static int DecodeBranchOffset(int32_t instr); |
703 | 703 |
704 void EmitBranchDelayNop() { | 704 void EmitBranchDelayNop() { |
705 Emit(Instr::kNopInstruction); // Branch delay NOP. | 705 Emit(Instr::kNopInstruction); // Branch delay NOP. |
706 delay_slot_available_ = true; | 706 delay_slot_available_ = true; |
707 } | 707 } |
708 | 708 |
709 DISALLOW_ALLOCATION(); | 709 DISALLOW_ALLOCATION(); |
710 DISALLOW_COPY_AND_ASSIGN(Assembler); | 710 DISALLOW_COPY_AND_ASSIGN(Assembler); |
711 }; | 711 }; |
712 | 712 |
713 } // namespace dart | 713 } // namespace dart |
714 | 714 |
715 #endif // VM_ASSEMBLER_MIPS_H_ | 715 #endif // VM_ASSEMBLER_MIPS_H_ |
OLD | NEW |