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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 template <> void InstMIPS32Cvt_s_l::emitIAS(const Cfg *Func) const { | 883 template <> void InstMIPS32Cvt_s_l::emitIAS(const Cfg *Func) const { |
884 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 884 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
885 Asm->cvt_s_l(getDest(), getSrc(0)); | 885 Asm->cvt_s_l(getDest(), getSrc(0)); |
886 } | 886 } |
887 | 887 |
888 template <> void InstMIPS32Cvt_s_w::emitIAS(const Cfg *Func) const { | 888 template <> void InstMIPS32Cvt_s_w::emitIAS(const Cfg *Func) const { |
889 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 889 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
890 Asm->cvt_s_w(getDest(), getSrc(0)); | 890 Asm->cvt_s_w(getDest(), getSrc(0)); |
891 } | 891 } |
892 | 892 |
| 893 template <> void InstMIPS32Div::emitIAS(const Cfg *Func) const { |
| 894 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 895 Asm->div(getDest(), getSrc(0)); |
| 896 } |
| 897 |
893 template <> void InstMIPS32Div_d::emitIAS(const Cfg *Func) const { | 898 template <> void InstMIPS32Div_d::emitIAS(const Cfg *Func) const { |
894 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 899 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
895 Asm->div_d(getDest(), getSrc(0), getSrc(1)); | 900 Asm->div_d(getDest(), getSrc(0), getSrc(1)); |
896 } | 901 } |
897 | 902 |
898 template <> void InstMIPS32Div_s::emitIAS(const Cfg *Func) const { | 903 template <> void InstMIPS32Div_s::emitIAS(const Cfg *Func) const { |
899 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 904 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
900 Asm->div_s(getDest(), getSrc(0), getSrc(1)); | 905 Asm->div_s(getDest(), getSrc(0), getSrc(1)); |
901 } | 906 } |
902 | 907 |
| 908 template <> void InstMIPS32Lui::emitIAS(const Cfg *Func) const { |
| 909 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 910 auto *C32 = llvm::dyn_cast<ConstantInteger32>(getSrc(0)); |
| 911 uint16_t Imm = static_cast<uint16_t>(C32->getValue()); |
| 912 Asm->lui(getDest(), Imm); |
| 913 } |
| 914 |
903 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { | 915 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { |
904 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 916 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
905 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); | 917 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); |
906 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); | 918 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); |
907 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); | 919 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); |
908 Asm->lw(getDest(), Mem->getBase(), Imm); | 920 Asm->lw(getDest(), Mem->getBase(), Imm); |
909 } | 921 } |
910 | 922 |
911 template <> void InstMIPS32Mfc1::emitIAS(const Cfg *Func) const { | 923 template <> void InstMIPS32Mfc1::emitIAS(const Cfg *Func) const { |
912 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 924 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
913 Asm->mfc1(getDest(), getSrc(0)); | 925 Asm->mfc1(getDest(), getSrc(0)); |
914 } | 926 } |
915 | 927 |
916 template <> void InstMIPS32Mflo::emit(const Cfg *Func) const { | 928 template <> void InstMIPS32Mflo::emit(const Cfg *Func) const { |
917 if (!BuildDefs::dump()) | 929 if (!BuildDefs::dump()) |
918 return; | 930 return; |
919 emitUnaryopGPRFLoHi(Opcode, this, Func); | 931 emitUnaryopGPRFLoHi(Opcode, this, Func); |
920 } | 932 } |
921 | 933 |
| 934 template <> void InstMIPS32Mflo::emitIAS(const Cfg *Func) const { |
| 935 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 936 Asm->mflo(getDest()); |
| 937 } |
| 938 |
922 template <> void InstMIPS32Mfhi::emit(const Cfg *Func) const { | 939 template <> void InstMIPS32Mfhi::emit(const Cfg *Func) const { |
923 if (!BuildDefs::dump()) | 940 if (!BuildDefs::dump()) |
924 return; | 941 return; |
925 emitUnaryopGPRFLoHi(Opcode, this, Func); | 942 emitUnaryopGPRFLoHi(Opcode, this, Func); |
926 } | 943 } |
927 | 944 |
| 945 template <> void InstMIPS32Mfhi::emitIAS(const Cfg *Func) const { |
| 946 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 947 Asm->mfhi(getDest()); |
| 948 } |
| 949 |
928 template <> void InstMIPS32Mov_d::emitIAS(const Cfg *Func) const { | 950 template <> void InstMIPS32Mov_d::emitIAS(const Cfg *Func) const { |
929 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 951 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
930 Asm->mov_d(getDest(), getSrc(0)); | 952 Asm->mov_d(getDest(), getSrc(0)); |
931 } | 953 } |
932 | 954 |
933 template <> void InstMIPS32Mov_s::emitIAS(const Cfg *Func) const { | 955 template <> void InstMIPS32Mov_s::emitIAS(const Cfg *Func) const { |
934 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 956 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
935 Asm->mov_s(getDest(), getSrc(0)); | 957 Asm->mov_s(getDest(), getSrc(0)); |
936 } | 958 } |
937 | 959 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 996 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
975 Asm->mtc1(getDest(), getSrc(0)); | 997 Asm->mtc1(getDest(), getSrc(0)); |
976 } | 998 } |
977 | 999 |
978 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const { | 1000 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const { |
979 if (!BuildDefs::dump()) | 1001 if (!BuildDefs::dump()) |
980 return; | 1002 return; |
981 emitUnaryopGPRTLoHi(Opcode, this, Func); | 1003 emitUnaryopGPRTLoHi(Opcode, this, Func); |
982 } | 1004 } |
983 | 1005 |
| 1006 template <> void InstMIPS32Mtlo::emitIAS(const Cfg *Func) const { |
| 1007 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 1008 Asm->mtlo(getDest()); |
| 1009 } |
| 1010 |
984 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const { | 1011 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const { |
985 if (!BuildDefs::dump()) | 1012 if (!BuildDefs::dump()) |
986 return; | 1013 return; |
987 emitUnaryopGPRTLoHi(Opcode, this, Func); | 1014 emitUnaryopGPRTLoHi(Opcode, this, Func); |
988 } | 1015 } |
989 | 1016 |
| 1017 template <> void InstMIPS32Mthi::emitIAS(const Cfg *Func) const { |
| 1018 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 1019 Asm->mthi(getDest()); |
| 1020 } |
| 1021 |
| 1022 template <> void InstMIPS32Mul::emitIAS(const Cfg *Func) const { |
| 1023 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 1024 Asm->mul(getDest(), getSrc(0), getSrc(1)); |
| 1025 } |
| 1026 |
990 template <> void InstMIPS32Mul_d::emitIAS(const Cfg *Func) const { | 1027 template <> void InstMIPS32Mul_d::emitIAS(const Cfg *Func) const { |
991 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1028 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
992 Asm->mul_d(getDest(), getSrc(0), getSrc(1)); | 1029 Asm->mul_d(getDest(), getSrc(0), getSrc(1)); |
993 } | 1030 } |
994 | 1031 |
995 template <> void InstMIPS32Mul_s::emitIAS(const Cfg *Func) const { | 1032 template <> void InstMIPS32Mul_s::emitIAS(const Cfg *Func) const { |
996 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1033 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
997 Asm->mul_s(getDest(), getSrc(0), getSrc(1)); | 1034 Asm->mul_s(getDest(), getSrc(0), getSrc(1)); |
998 } | 1035 } |
999 | 1036 |
1000 template <> void InstMIPS32Mult::emit(const Cfg *Func) const { | 1037 template <> void InstMIPS32Mult::emit(const Cfg *Func) const { |
1001 if (!BuildDefs::dump()) | 1038 if (!BuildDefs::dump()) |
1002 return; | 1039 return; |
1003 emitThreeAddrLoHi(Opcode, this, Func); | 1040 emitThreeAddrLoHi(Opcode, this, Func); |
1004 } | 1041 } |
1005 | 1042 |
1006 template <> void InstMIPS32Multu::emit(const Cfg *Func) const { | 1043 template <> void InstMIPS32Multu::emit(const Cfg *Func) const { |
1007 if (!BuildDefs::dump()) | 1044 if (!BuildDefs::dump()) |
1008 return; | 1045 return; |
1009 emitThreeAddrLoHi(Opcode, this, Func); | 1046 emitThreeAddrLoHi(Opcode, this, Func); |
1010 } | 1047 } |
1011 | 1048 |
| 1049 template <> void InstMIPS32Multu::emitIAS(const Cfg *Func) const { |
| 1050 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 1051 Asm->multu(getDest(), getSrc(0)); |
| 1052 } |
| 1053 |
1012 template <> void InstMIPS32Nor::emitIAS(const Cfg *Func) const { | 1054 template <> void InstMIPS32Nor::emitIAS(const Cfg *Func) const { |
1013 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1055 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1014 Asm->nor(getDest(), getSrc(0), getSrc(1)); | 1056 Asm->nor(getDest(), getSrc(0), getSrc(1)); |
1015 } | 1057 } |
1016 | 1058 |
1017 template <> void InstMIPS32Or::emitIAS(const Cfg *Func) const { | 1059 template <> void InstMIPS32Or::emitIAS(const Cfg *Func) const { |
1018 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1060 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1019 Asm->or_(getDest(), getSrc(0), getSrc(1)); | 1061 Asm->or_(getDest(), getSrc(0), getSrc(1)); |
1020 } | 1062 } |
1021 | 1063 |
1022 template <> void InstMIPS32Ori::emitIAS(const Cfg *Func) const { | 1064 template <> void InstMIPS32Ori::emitIAS(const Cfg *Func) const { |
1023 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1065 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1024 Asm->ori(getDest(), getSrc(0), Imm); | 1066 Asm->ori(getDest(), getSrc(0), Imm); |
1025 } | 1067 } |
1026 | 1068 |
1027 template <> void InstMIPS32Sll::emitIAS(const Cfg *Func) const { | 1069 template <> void InstMIPS32Sll::emitIAS(const Cfg *Func) const { |
1028 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1070 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1029 Asm->sll(getDest(), getSrc(0), Imm); | 1071 Asm->sll(getDest(), getSrc(0), Imm); |
1030 } | 1072 } |
1031 | 1073 |
| 1074 template <> void InstMIPS32Sllv::emitIAS(const Cfg *Func) const { |
| 1075 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 1076 Asm->sllv(getDest(), getSrc(0), getSrc(1)); |
| 1077 } |
| 1078 |
1032 template <> void InstMIPS32Slt::emitIAS(const Cfg *Func) const { | 1079 template <> void InstMIPS32Slt::emitIAS(const Cfg *Func) const { |
1033 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1080 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1034 Asm->slt(getDest(), getSrc(0), getSrc(1)); | 1081 Asm->slt(getDest(), getSrc(0), getSrc(1)); |
1035 } | 1082 } |
1036 | 1083 |
1037 template <> void InstMIPS32Slti::emitIAS(const Cfg *Func) const { | 1084 template <> void InstMIPS32Slti::emitIAS(const Cfg *Func) const { |
1038 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1085 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1039 Asm->slti(getDest(), getSrc(0), Imm); | 1086 Asm->slti(getDest(), getSrc(0), Imm); |
1040 } | 1087 } |
1041 | 1088 |
(...skipping 20 matching lines...) Expand all Loading... |
1062 template <> void InstMIPS32Sra::emitIAS(const Cfg *Func) const { | 1109 template <> void InstMIPS32Sra::emitIAS(const Cfg *Func) const { |
1063 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1110 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1064 Asm->sra(getDest(), getSrc(0), Imm); | 1111 Asm->sra(getDest(), getSrc(0), Imm); |
1065 } | 1112 } |
1066 | 1113 |
1067 template <> void InstMIPS32Srl::emitIAS(const Cfg *Func) const { | 1114 template <> void InstMIPS32Srl::emitIAS(const Cfg *Func) const { |
1068 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1115 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1069 Asm->srl(getDest(), getSrc(0), Imm); | 1116 Asm->srl(getDest(), getSrc(0), Imm); |
1070 } | 1117 } |
1071 | 1118 |
| 1119 template <> void InstMIPS32Srlv::emitIAS(const Cfg *Func) const { |
| 1120 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 1121 Asm->srlv(getDest(), getSrc(0), getSrc(1)); |
| 1122 } |
| 1123 |
1072 template <> void InstMIPS32Sub_d::emitIAS(const Cfg *Func) const { | 1124 template <> void InstMIPS32Sub_d::emitIAS(const Cfg *Func) const { |
1073 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1125 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1074 Asm->sub_d(getDest(), getSrc(0), getSrc(1)); | 1126 Asm->sub_d(getDest(), getSrc(0), getSrc(1)); |
1075 } | 1127 } |
1076 | 1128 |
1077 template <> void InstMIPS32Sub_s::emitIAS(const Cfg *Func) const { | 1129 template <> void InstMIPS32Sub_s::emitIAS(const Cfg *Func) const { |
1078 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1130 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1079 Asm->sub_s(getDest(), getSrc(0), getSrc(1)); | 1131 Asm->sub_s(getDest(), getSrc(0), getSrc(1)); |
1080 } | 1132 } |
1081 | 1133 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 Asm->xor_(getDest(), getSrc(0), getSrc(1)); | 1174 Asm->xor_(getDest(), getSrc(0), getSrc(1)); |
1123 } | 1175 } |
1124 | 1176 |
1125 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const { | 1177 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const { |
1126 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1178 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
1127 Asm->xori(getDest(), getSrc(0), Imm); | 1179 Asm->xori(getDest(), getSrc(0), Imm); |
1128 } | 1180 } |
1129 | 1181 |
1130 } // end of namespace MIPS32 | 1182 } // end of namespace MIPS32 |
1131 } // end of namespace Ice | 1183 } // end of namespace Ice |
OLD | NEW |