| OLD | NEW |
| 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// | 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// |
| 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 641 |
| 642 Variable *Dest = getDest(); | 642 Variable *Dest = getDest(); |
| 643 Operand *Src = getSrc(0); | 643 Operand *Src = getSrc(0); |
| 644 auto *SrcV = llvm::dyn_cast<Variable>(Src); | 644 auto *SrcV = llvm::dyn_cast<Variable>(Src); |
| 645 assert(!llvm::isa<Constant>(Src)); | 645 assert(!llvm::isa<Constant>(Src)); |
| 646 const bool DestIsReg = Dest->hasReg(); | 646 const bool DestIsReg = Dest->hasReg(); |
| 647 const bool SrcIsReg = (SrcV && SrcV->hasReg()); | 647 const bool SrcIsReg = (SrcV && SrcV->hasReg()); |
| 648 | 648 |
| 649 // reg to reg | 649 // reg to reg |
| 650 if (DestIsReg && SrcIsReg) { | 650 if (DestIsReg && SrcIsReg) { |
| 651 switch (Dest->getType()) { | 651 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 652 default: | 652 Asm->move(getDest(), getSrc(0)); |
| 653 break; | 653 return; |
| 654 case IceType_i1: | |
| 655 case IceType_i8: | |
| 656 case IceType_i16: | |
| 657 case IceType_i32: | |
| 658 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | |
| 659 Asm->move(getDest(), getSrc(0)); | |
| 660 return; | |
| 661 } | |
| 662 } | 654 } |
| 663 llvm_unreachable("Not yet implemented"); | 655 llvm_unreachable("Not yet implemented"); |
| 664 } | 656 } |
| 665 | 657 |
| 666 void InstMIPS32Mov::dump(const Cfg *Func) const { | 658 void InstMIPS32Mov::dump(const Cfg *Func) const { |
| 667 if (!BuildDefs::dump()) | 659 if (!BuildDefs::dump()) |
| 668 return; | 660 return; |
| 669 assert(getSrcSize() == 1 || getSrcSize() == 2); | 661 assert(getSrcSize() == 1 || getSrcSize() == 2); |
| 670 Ostream &Str = Func->getContext()->getStrDump(); | 662 Ostream &Str = Func->getContext()->getStrDump(); |
| 671 Variable *Dest = getDest(); | 663 Variable *Dest = getDest(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 Str << "\t" << ActualOpcode << "\t"; | 771 Str << "\t" << ActualOpcode << "\t"; |
| 780 getDest()->emit(Func); | 772 getDest()->emit(Func); |
| 781 Str << ", "; | 773 Str << ", "; |
| 782 getSrc(0)->emit(Func); | 774 getSrc(0)->emit(Func); |
| 783 return; | 775 return; |
| 784 } | 776 } |
| 785 | 777 |
| 786 llvm::report_fatal_error("Invalid mov instruction. Dest or Src is memory."); | 778 llvm::report_fatal_error("Invalid mov instruction. Dest or Src is memory."); |
| 787 } | 779 } |
| 788 | 780 |
| 781 template <> void InstMIPS32Abs_d::emitIAS(const Cfg *Func) const { |
| 782 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 783 Asm->abs_d(getDest(), getSrc(0)); |
| 784 } |
| 785 |
| 786 template <> void InstMIPS32Abs_s::emitIAS(const Cfg *Func) const { |
| 787 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 788 Asm->abs_s(getDest(), getSrc(0)); |
| 789 } |
| 790 |
| 791 template <> void InstMIPS32Add_d::emitIAS(const Cfg *Func) const { |
| 792 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 793 Asm->add_d(getDest(), getSrc(0), getSrc(1)); |
| 794 } |
| 795 |
| 796 template <> void InstMIPS32Add_s::emitIAS(const Cfg *Func) const { |
| 797 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 798 Asm->add_s(getDest(), getSrc(0), getSrc(1)); |
| 799 } |
| 800 |
| 801 template <> void InstMIPS32Div_d::emitIAS(const Cfg *Func) const { |
| 802 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 803 Asm->div_d(getDest(), getSrc(0), getSrc(1)); |
| 804 } |
| 805 |
| 806 template <> void InstMIPS32Div_s::emitIAS(const Cfg *Func) const { |
| 807 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 808 Asm->div_s(getDest(), getSrc(0), getSrc(1)); |
| 809 } |
| 810 |
| 811 template <> void InstMIPS32Mov_d::emitIAS(const Cfg *Func) const { |
| 812 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 813 Asm->mov_d(getDest(), getSrc(0)); |
| 814 } |
| 815 |
| 816 template <> void InstMIPS32Mov_s::emitIAS(const Cfg *Func) const { |
| 817 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 818 Asm->mov_s(getDest(), getSrc(0)); |
| 819 } |
| 820 |
| 821 template <> void InstMIPS32Movn_d::emitIAS(const Cfg *Func) const { |
| 822 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 823 Asm->movn_d(getDest(), getSrc(0), getSrc(1)); |
| 824 } |
| 825 |
| 826 template <> void InstMIPS32Movn_s::emitIAS(const Cfg *Func) const { |
| 827 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 828 Asm->movn_s(getDest(), getSrc(0), getSrc(1)); |
| 829 } |
| 830 |
| 831 template <> void InstMIPS32Movz_d::emitIAS(const Cfg *Func) const { |
| 832 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 833 Asm->movz_d(getDest(), getSrc(0), getSrc(1)); |
| 834 } |
| 835 |
| 836 template <> void InstMIPS32Movz_s::emitIAS(const Cfg *Func) const { |
| 837 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 838 Asm->movz_s(getDest(), getSrc(0), getSrc(1)); |
| 839 } |
| 840 |
| 841 template <> void InstMIPS32Mul_d::emitIAS(const Cfg *Func) const { |
| 842 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 843 Asm->mul_d(getDest(), getSrc(0), getSrc(1)); |
| 844 } |
| 845 |
| 846 template <> void InstMIPS32Mul_s::emitIAS(const Cfg *Func) const { |
| 847 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 848 Asm->mul_s(getDest(), getSrc(0), getSrc(1)); |
| 849 } |
| 850 |
| 851 template <> void InstMIPS32Sqrt_d::emitIAS(const Cfg *Func) const { |
| 852 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 853 Asm->sqrt_d(getDest(), getSrc(0)); |
| 854 } |
| 855 |
| 856 template <> void InstMIPS32Sqrt_s::emitIAS(const Cfg *Func) const { |
| 857 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 858 Asm->sqrt_s(getDest(), getSrc(0)); |
| 859 } |
| 860 |
| 861 template <> void InstMIPS32Sub_d::emitIAS(const Cfg *Func) const { |
| 862 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 863 Asm->sub_d(getDest(), getSrc(0), getSrc(1)); |
| 864 } |
| 865 |
| 866 template <> void InstMIPS32Sub_s::emitIAS(const Cfg *Func) const { |
| 867 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 868 Asm->sub_s(getDest(), getSrc(0), getSrc(1)); |
| 869 } |
| 870 |
| 789 template <> void InstMIPS32Addiu::emitIAS(const Cfg *Func) const { | 871 template <> void InstMIPS32Addiu::emitIAS(const Cfg *Func) const { |
| 790 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 872 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 791 Asm->addiu(getDest(), getSrc(0), Imm); | 873 Asm->addiu(getDest(), getSrc(0), Imm); |
| 792 } | 874 } |
| 793 | 875 |
| 794 template <> void InstMIPS32Slti::emitIAS(const Cfg *Func) const { | 876 template <> void InstMIPS32Slti::emitIAS(const Cfg *Func) const { |
| 795 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 877 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 796 Asm->slti(getDest(), getSrc(0), Imm); | 878 Asm->slti(getDest(), getSrc(0), Imm); |
| 797 } | 879 } |
| 798 | 880 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { | 954 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { |
| 873 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 955 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 874 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); | 956 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); |
| 875 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); | 957 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); |
| 876 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); | 958 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); |
| 877 Asm->lw(getDest(), Mem->getBase(), Imm); | 959 Asm->lw(getDest(), Mem->getBase(), Imm); |
| 878 } | 960 } |
| 879 | 961 |
| 880 } // end of namespace MIPS32 | 962 } // end of namespace MIPS32 |
| 881 } // end of namespace Ice | 963 } // end of namespace Ice |
| OLD | NEW |