OLD | NEW |
1 //===- subzero/src/IceAssemblerMIPS32.cpp - MIPS32 Assembler --------------===// | 1 //===- subzero/src/IceAssemblerMIPS32.cpp - MIPS32 Assembler --------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 Asm->store(position(), (Inst & ~ImmMask) | (Imm & ImmMask)); | 638 Asm->store(position(), (Inst & ~ImmMask) | (Imm & ImmMask)); |
639 } | 639 } |
640 | 640 |
641 void AssemblerMIPS32::jal(const ConstantRelocatable *Target) { | 641 void AssemblerMIPS32::jal(const ConstantRelocatable *Target) { |
642 IValueT Opcode = 0x0C000000; | 642 IValueT Opcode = 0x0C000000; |
643 emitFixup(createMIPS32Fixup(RelocOp::RO_Jal, Target)); | 643 emitFixup(createMIPS32Fixup(RelocOp::RO_Jal, Target)); |
644 emitInst(Opcode); | 644 emitInst(Opcode); |
645 nop(); | 645 nop(); |
646 } | 646 } |
647 | 647 |
| 648 void AssemblerMIPS32::jalr(const Operand *OpRs, const Operand *OpRd) { |
| 649 IValueT Opcode = 0x00000009; |
| 650 const IValueT Rs = encodeGPRegister(OpRs, "Rs", "jalr"); |
| 651 const IValueT Rd = |
| 652 (OpRd == nullptr) ? 31 : encodeGPRegister(OpRd, "Rd", "jalr"); |
| 653 Opcode |= Rd << 16; |
| 654 Opcode |= Rs << 21; |
| 655 emitInst(Opcode); |
| 656 nop(); |
| 657 } |
| 658 |
648 void AssemblerMIPS32::lui(const Operand *OpRt, const Operand *OpImm, | 659 void AssemblerMIPS32::lui(const Operand *OpRt, const Operand *OpImm, |
649 const RelocOp Reloc) { | 660 const RelocOp Reloc) { |
650 IValueT Opcode = 0x3C000000; | 661 IValueT Opcode = 0x3C000000; |
651 const IValueT Rt = encodeGPRegister(OpRt, "Rt", "lui"); | 662 const IValueT Rt = encodeGPRegister(OpRt, "Rt", "lui"); |
652 IValueT Imm16 = 0; | 663 IValueT Imm16 = 0; |
653 | 664 |
654 if (const auto *OpRel = llvm::dyn_cast<ConstantRelocatable>(OpImm)) { | 665 if (const auto *OpRel = llvm::dyn_cast<ConstantRelocatable>(OpImm)) { |
655 emitFixup(createMIPS32Fixup(Reloc, OpRel)); | 666 emitFixup(createMIPS32Fixup(Reloc, OpRel)); |
656 } else if (auto *C32 = llvm::dyn_cast<ConstantInteger32>(OpImm)) { | 667 } else if (auto *C32 = llvm::dyn_cast<ConstantInteger32>(OpImm)) { |
657 Imm16 = C32->getValue(); | 668 Imm16 = C32->getValue(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 | 837 |
827 void AssemblerMIPS32::movn(const Operand *OpRd, const Operand *OpRs, | 838 void AssemblerMIPS32::movn(const Operand *OpRd, const Operand *OpRs, |
828 const Operand *OpRt) { | 839 const Operand *OpRt) { |
829 static constexpr IValueT Opcode = 0x0000000B; | 840 static constexpr IValueT Opcode = 0x0000000B; |
830 emitRdRsRt(Opcode, OpRd, OpRs, OpRt, "movn"); | 841 emitRdRsRt(Opcode, OpRd, OpRs, OpRt, "movn"); |
831 } | 842 } |
832 | 843 |
833 void AssemblerMIPS32::movn_d(const Operand *OpFd, const Operand *OpFs, | 844 void AssemblerMIPS32::movn_d(const Operand *OpFd, const Operand *OpFs, |
834 const Operand *OpFt) { | 845 const Operand *OpFt) { |
835 static constexpr IValueT Opcode = 0x44000013; | 846 static constexpr IValueT Opcode = 0x44000013; |
836 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.d"); | 847 emitCOP1FmtRtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.d"); |
837 } | 848 } |
838 | 849 |
839 void AssemblerMIPS32::movn_s(const Operand *OpFd, const Operand *OpFs, | 850 void AssemblerMIPS32::movn_s(const Operand *OpFd, const Operand *OpFs, |
840 const Operand *OpFt) { | 851 const Operand *OpFt) { |
841 static constexpr IValueT Opcode = 0x44000013; | 852 static constexpr IValueT Opcode = 0x44000013; |
842 emitCOP1FmtFtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.s"); | 853 emitCOP1FmtRtFsFd(Opcode, SinglePrecision, OpFd, OpFs, OpFt, "movn.s"); |
843 } | 854 } |
844 | 855 |
845 void AssemblerMIPS32::movt(const Operand *OpRd, const Operand *OpRs, | 856 void AssemblerMIPS32::movt(const Operand *OpRd, const Operand *OpRs, |
846 const Operand *OpCc) { | 857 const Operand *OpCc) { |
847 IValueT Opcode = 0x00000001; | 858 IValueT Opcode = 0x00000001; |
848 const IValueT Rd = encodeGPRegister(OpRd, "Rd", "movt"); | 859 const IValueT Rd = encodeGPRegister(OpRd, "Rd", "movt"); |
849 const IValueT Rs = encodeGPRegister(OpRs, "Rs", "movt"); | 860 const IValueT Rs = encodeGPRegister(OpRs, "Rs", "movt"); |
850 OperandMIPS32FCC::FCC Cc = OperandMIPS32FCC::FCC0; | 861 OperandMIPS32FCC::FCC Cc = OperandMIPS32FCC::FCC0; |
851 if (const auto *OpFCC = llvm::dyn_cast<OperandMIPS32FCC>(OpCc)) { | 862 if (const auto *OpFCC = llvm::dyn_cast<OperandMIPS32FCC>(OpCc)) { |
852 Cc = OpFCC->getFCC(); | 863 Cc = OpFCC->getFCC(); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 emitBr(Cond, OpRs, OpRtNone, Dest); | 1234 emitBr(Cond, OpRs, OpRtNone, Dest); |
1224 return; | 1235 return; |
1225 } | 1236 } |
1226 const IOffsetT Position = Buffer.size(); | 1237 const IOffsetT Position = Buffer.size(); |
1227 emitBr(Cond, OpRs, OpRtNone, TargetLabel->getEncodedPosition()); | 1238 emitBr(Cond, OpRs, OpRtNone, TargetLabel->getEncodedPosition()); |
1228 TargetLabel->linkTo(*this, Position); | 1239 TargetLabel->linkTo(*this, Position); |
1229 } | 1240 } |
1230 | 1241 |
1231 } // end of namespace MIPS32 | 1242 } // end of namespace MIPS32 |
1232 } // end of namespace Ice | 1243 } // end of namespace Ice |
OLD | NEW |