Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: src/IceInstMIPS32.cpp

Issue 2504253002: [Subzero][MIPS] Implements atomic intrinsics for MIPS32 (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 template <> const char *InstMIPS32Cvt_d_w::Opcode = "cvt.d.w"; 90 template <> const char *InstMIPS32Cvt_d_w::Opcode = "cvt.d.w";
91 template <> const char *InstMIPS32Cvt_s_d::Opcode = "cvt.s.d"; 91 template <> const char *InstMIPS32Cvt_s_d::Opcode = "cvt.s.d";
92 template <> const char *InstMIPS32Cvt_s_l::Opcode = "cvt.s.l"; 92 template <> const char *InstMIPS32Cvt_s_l::Opcode = "cvt.s.l";
93 template <> const char *InstMIPS32Cvt_s_w::Opcode = "cvt.s.w"; 93 template <> const char *InstMIPS32Cvt_s_w::Opcode = "cvt.s.w";
94 template <> const char *InstMIPS32Div::Opcode = "div"; 94 template <> const char *InstMIPS32Div::Opcode = "div";
95 template <> const char *InstMIPS32Div_d::Opcode = "div.d"; 95 template <> const char *InstMIPS32Div_d::Opcode = "div.d";
96 template <> const char *InstMIPS32Div_s::Opcode = "div.s"; 96 template <> const char *InstMIPS32Div_s::Opcode = "div.s";
97 template <> const char *InstMIPS32Divu::Opcode = "divu"; 97 template <> const char *InstMIPS32Divu::Opcode = "divu";
98 template <> const char *InstMIPS32La::Opcode = "la"; 98 template <> const char *InstMIPS32La::Opcode = "la";
99 template <> const char *InstMIPS32Ldc1::Opcode = "ldc1"; 99 template <> const char *InstMIPS32Ldc1::Opcode = "ldc1";
100 template <> const char *InstMIPS32Ll::Opcode = "ll";
100 template <> const char *InstMIPS32Lui::Opcode = "lui"; 101 template <> const char *InstMIPS32Lui::Opcode = "lui";
101 template <> const char *InstMIPS32Lw::Opcode = "lw"; 102 template <> const char *InstMIPS32Lw::Opcode = "lw";
102 template <> const char *InstMIPS32Lwc1::Opcode = "lwc1"; 103 template <> const char *InstMIPS32Lwc1::Opcode = "lwc1";
103 template <> const char *InstMIPS32Mfc1::Opcode = "mfc1"; 104 template <> const char *InstMIPS32Mfc1::Opcode = "mfc1";
104 template <> const char *InstMIPS32Mfhi::Opcode = "mfhi"; 105 template <> const char *InstMIPS32Mfhi::Opcode = "mfhi";
105 template <> const char *InstMIPS32Mflo::Opcode = "mflo"; 106 template <> const char *InstMIPS32Mflo::Opcode = "mflo";
106 template <> const char *InstMIPS32Mov_d::Opcode = "mov.d"; 107 template <> const char *InstMIPS32Mov_d::Opcode = "mov.d";
107 template <> const char *InstMIPS32Mov_s::Opcode = "mov.s"; 108 template <> const char *InstMIPS32Mov_s::Opcode = "mov.s";
108 template <> const char *InstMIPS32Movf::Opcode = "movf"; 109 template <> const char *InstMIPS32Movf::Opcode = "movf";
109 template <> const char *InstMIPS32Movn::Opcode = "movn"; 110 template <> const char *InstMIPS32Movn::Opcode = "movn";
110 template <> const char *InstMIPS32Movn_d::Opcode = "movn.d"; 111 template <> const char *InstMIPS32Movn_d::Opcode = "movn.d";
111 template <> const char *InstMIPS32Movn_s::Opcode = "movn.s"; 112 template <> const char *InstMIPS32Movn_s::Opcode = "movn.s";
112 template <> const char *InstMIPS32Movt::Opcode = "movt"; 113 template <> const char *InstMIPS32Movt::Opcode = "movt";
113 template <> const char *InstMIPS32Movz::Opcode = "movz"; 114 template <> const char *InstMIPS32Movz::Opcode = "movz";
114 template <> const char *InstMIPS32Movz_d::Opcode = "movz.d"; 115 template <> const char *InstMIPS32Movz_d::Opcode = "movz.d";
115 template <> const char *InstMIPS32Movz_s::Opcode = "movz.s"; 116 template <> const char *InstMIPS32Movz_s::Opcode = "movz.s";
116 template <> const char *InstMIPS32Mtc1::Opcode = "mtc1"; 117 template <> const char *InstMIPS32Mtc1::Opcode = "mtc1";
117 template <> const char *InstMIPS32Mthi::Opcode = "mthi"; 118 template <> const char *InstMIPS32Mthi::Opcode = "mthi";
118 template <> const char *InstMIPS32Mtlo::Opcode = "mtlo"; 119 template <> const char *InstMIPS32Mtlo::Opcode = "mtlo";
119 template <> const char *InstMIPS32Mul::Opcode = "mul"; 120 template <> const char *InstMIPS32Mul::Opcode = "mul";
120 template <> const char *InstMIPS32Mul_d::Opcode = "mul.d"; 121 template <> const char *InstMIPS32Mul_d::Opcode = "mul.d";
121 template <> const char *InstMIPS32Mul_s::Opcode = "mul.s"; 122 template <> const char *InstMIPS32Mul_s::Opcode = "mul.s";
122 template <> const char *InstMIPS32Mult::Opcode = "mult"; 123 template <> const char *InstMIPS32Mult::Opcode = "mult";
123 template <> const char *InstMIPS32Multu::Opcode = "multu"; 124 template <> const char *InstMIPS32Multu::Opcode = "multu";
124 template <> const char *InstMIPS32Nor::Opcode = "nor"; 125 template <> const char *InstMIPS32Nor::Opcode = "nor";
125 template <> const char *InstMIPS32Or::Opcode = "or"; 126 template <> const char *InstMIPS32Or::Opcode = "or";
126 template <> const char *InstMIPS32Ori::Opcode = "ori"; 127 template <> const char *InstMIPS32Ori::Opcode = "ori";
128 template <> const char *InstMIPS32Sc::Opcode = "sc";
127 template <> const char *InstMIPS32Sdc1::Opcode = "sdc1"; 129 template <> const char *InstMIPS32Sdc1::Opcode = "sdc1";
128 template <> const char *InstMIPS32Sll::Opcode = "sll"; 130 template <> const char *InstMIPS32Sll::Opcode = "sll";
129 template <> const char *InstMIPS32Sllv::Opcode = "sllv"; 131 template <> const char *InstMIPS32Sllv::Opcode = "sllv";
130 template <> const char *InstMIPS32Slt::Opcode = "slt"; 132 template <> const char *InstMIPS32Slt::Opcode = "slt";
131 template <> const char *InstMIPS32Slti::Opcode = "slti"; 133 template <> const char *InstMIPS32Slti::Opcode = "slti";
132 template <> const char *InstMIPS32Sltiu::Opcode = "sltiu"; 134 template <> const char *InstMIPS32Sltiu::Opcode = "sltiu";
133 template <> const char *InstMIPS32Sltu::Opcode = "sltu"; 135 template <> const char *InstMIPS32Sltu::Opcode = "sltu";
134 template <> const char *InstMIPS32Sqrt_d::Opcode = "sqrt.d"; 136 template <> const char *InstMIPS32Sqrt_d::Opcode = "sqrt.d";
135 template <> const char *InstMIPS32Sqrt_s::Opcode = "sqrt.s"; 137 template <> const char *InstMIPS32Sqrt_s::Opcode = "sqrt.s";
136 template <> const char *InstMIPS32Sra::Opcode = "sra"; 138 template <> const char *InstMIPS32Sra::Opcode = "sra";
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 Str << "\t" 424 Str << "\t"
423 "jr" 425 "jr"
424 "\t"; 426 "\t";
425 RA->emit(Func); 427 RA->emit(Func);
426 } 428 }
427 429
428 void InstMIPS32Br::emitIAS(const Cfg *Func) const { 430 void InstMIPS32Br::emitIAS(const Cfg *Func) const {
429 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 431 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
430 if (Label != nullptr) { 432 if (Label != nullptr) {
431 // Intra-block branches are of kind bcc 433 // Intra-block branches are of kind bcc
432 Asm->bcc(Predicate, getSrc(0), getSrc(1), 434 if (isUnconditionalBranch()) {
433 Asm->getOrCreateLocalLabel(Label->getNumber())); 435 Asm->b(Asm->getOrCreateLocalLabel(Label->getNumber()));
436 } else {
437 Asm->bcc(Predicate, getSrc(0), getSrc(1),
438 Asm->getOrCreateLocalLabel(Label->getNumber()));
439 }
434 } else if (isUnconditionalBranch()) { 440 } else if (isUnconditionalBranch()) {
435 Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); 441 Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
436 } else { 442 } else {
437 switch (Predicate) { 443 switch (Predicate) {
438 default: 444 default:
439 break; 445 break;
440 case CondMIPS32::EQ: 446 case CondMIPS32::EQ:
441 case CondMIPS32::NE: 447 case CondMIPS32::NE:
442 Asm->bcc(Predicate, getSrc(0), getSrc(1), 448 Asm->bcc(Predicate, getSrc(0), getSrc(1),
443 Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); 449 Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
(...skipping 14 matching lines...) Expand all
458 } 464 }
459 } 465 }
460 466
461 void InstMIPS32Br::emit(const Cfg *Func) const { 467 void InstMIPS32Br::emit(const Cfg *Func) const {
462 if (!BuildDefs::dump()) 468 if (!BuildDefs::dump())
463 return; 469 return;
464 Ostream &Str = Func->getContext()->getStrEmit(); 470 Ostream &Str = Func->getContext()->getStrEmit();
465 Str << "\t" 471 Str << "\t"
466 "b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t"; 472 "b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t";
467 if (Label != nullptr) { 473 if (Label != nullptr) {
468 getSrc(0)->emit(Func); 474 if (isUnconditionalBranch()) {
469 Str << ", "; 475 Str << Label->getLabelName();
470 getSrc(1)->emit(Func); 476 } else {
471 Str << ", " << Label->getLabelName(); 477 getSrc(0)->emit(Func);
478 Str << ", ";
479 getSrc(1)->emit(Func);
480 Str << ", " << Label->getLabelName();
481 }
472 } else { 482 } else {
473 if (isUnconditionalBranch()) { 483 if (isUnconditionalBranch()) {
474 Str << getTargetFalse()->getAsmName(); 484 Str << getTargetFalse()->getAsmName();
475 } else { 485 } else {
476 switch (Predicate) { 486 switch (Predicate) {
477 default: 487 default:
478 break; 488 break;
479 case CondMIPS32::EQ: 489 case CondMIPS32::EQ:
480 case CondMIPS32::NE: { 490 case CondMIPS32::NE: {
481 getSrc(0)->emit(Func); 491 getSrc(0)->emit(Func);
(...skipping 24 matching lines...) Expand all
506 } 516 }
507 517
508 void InstMIPS32Br::dump(const Cfg *Func) const { 518 void InstMIPS32Br::dump(const Cfg *Func) const {
509 if (!BuildDefs::dump()) 519 if (!BuildDefs::dump())
510 return; 520 return;
511 Ostream &Str = Func->getContext()->getStrDump(); 521 Ostream &Str = Func->getContext()->getStrDump();
512 Str << "\t" 522 Str << "\t"
513 "b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t"; 523 "b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t";
514 524
515 if (Label != nullptr) { 525 if (Label != nullptr) {
516 getSrc(0)->dump(Func); 526 if (isUnconditionalBranch()) {
517 Str << ", "; 527 Str << Label->getLabelName();
518 getSrc(1)->dump(Func); 528 } else {
519 Str << ", " << Label->getLabelName(); 529 getSrc(0)->dump(Func);
530 Str << ", ";
531 getSrc(1)->dump(Func);
532 Str << ", " << Label->getLabelName();
533 }
520 } else { 534 } else {
521 if (isUnconditionalBranch()) { 535 if (isUnconditionalBranch()) {
522 Str << getTargetFalse()->getAsmName(); 536 Str << getTargetFalse()->getAsmName();
523 } else { 537 } else {
524 dumpSources(Func); 538 dumpSources(Func);
525 Str << ", "; 539 Str << ", ";
526 Str << getTargetFalse()->getAsmName(); 540 Str << getTargetFalse()->getAsmName();
527 if (getTargetTrue()) { 541 if (getTargetTrue()) {
528 Str << "\n\t" 542 Str << "\n\t"
529 << "b" 543 << "b"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 893 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
880 Asm->lui(getDest(), getSrc(0), Reloc); 894 Asm->lui(getDest(), getSrc(0), Reloc);
881 } 895 }
882 896
883 template <> void InstMIPS32Ldc1::emitIAS(const Cfg *Func) const { 897 template <> void InstMIPS32Ldc1::emitIAS(const Cfg *Func) const {
884 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 898 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
885 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); 899 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
886 Asm->ldc1(getDest(), Mem->getBase(), Mem->getOffset(), Reloc); 900 Asm->ldc1(getDest(), Mem->getBase(), Mem->getOffset(), Reloc);
887 } 901 }
888 902
903 template <> void InstMIPS32Ll::emitIAS(const Cfg *Func) const {
904 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
905 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
906 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
907 uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
908 Asm->ll(getDest(), Mem->getBase(), Imm);
909 }
910
889 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const { 911 template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const {
890 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 912 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
891 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); 913 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
892 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset()); 914 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
893 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); 915 uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
894 Asm->lw(getDest(), Mem->getBase(), Imm); 916 Asm->lw(getDest(), Mem->getBase(), Imm);
895 } 917 }
896 918
897 template <> void InstMIPS32Lwc1::emitIAS(const Cfg *Func) const { 919 template <> void InstMIPS32Lwc1::emitIAS(const Cfg *Func) const {
898 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 920 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 template <> void InstMIPS32Or::emitIAS(const Cfg *Func) const { 1082 template <> void InstMIPS32Or::emitIAS(const Cfg *Func) const {
1061 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1083 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1062 Asm->or_(getDest(), getSrc(0), getSrc(1)); 1084 Asm->or_(getDest(), getSrc(0), getSrc(1));
1063 } 1085 }
1064 1086
1065 template <> void InstMIPS32Ori::emitIAS(const Cfg *Func) const { 1087 template <> void InstMIPS32Ori::emitIAS(const Cfg *Func) const {
1066 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1088 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1067 Asm->ori(getDest(), getSrc(0), Imm); 1089 Asm->ori(getDest(), getSrc(0), Imm);
1068 } 1090 }
1069 1091
1092 template <> void InstMIPS32Sc::emitIAS(const Cfg *Func) const {
1093 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1094 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(1));
1095 ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
1096 uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
1097 Asm->sc(getSrc(0), Mem->getBase(), Imm);
1098 }
1099
1070 template <> void InstMIPS32Sll::emitIAS(const Cfg *Func) const { 1100 template <> void InstMIPS32Sll::emitIAS(const Cfg *Func) const {
1071 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1101 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1072 Asm->sll(getDest(), getSrc(0), Imm); 1102 Asm->sll(getDest(), getSrc(0), Imm);
1073 } 1103 }
1074 1104
1075 template <> void InstMIPS32Sllv::emitIAS(const Cfg *Func) const { 1105 template <> void InstMIPS32Sllv::emitIAS(const Cfg *Func) const {
1076 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1106 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1077 Asm->sllv(getDest(), getSrc(0), getSrc(1)); 1107 Asm->sllv(getDest(), getSrc(0), getSrc(1));
1078 } 1108 }
1079 1109
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 uint32_t Imm = static_cast<uint32_t>(Offset->getValue()); 1185 uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
1156 Asm->sw(getSrc(0), Mem->getBase(), Imm); 1186 Asm->sw(getSrc(0), Mem->getBase(), Imm);
1157 } 1187 }
1158 1188
1159 template <> void InstMIPS32Swc1::emitIAS(const Cfg *Func) const { 1189 template <> void InstMIPS32Swc1::emitIAS(const Cfg *Func) const {
1160 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1190 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1161 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0)); 1191 auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
1162 Asm->swc1(getSrc(0), Mem->getBase(), Mem->getOffset(), Reloc); 1192 Asm->swc1(getSrc(0), Mem->getBase(), Mem->getOffset(), Reloc);
1163 } 1193 }
1164 1194
1195 void InstMIPS32Sync::emitIAS(const Cfg *Func) const {
1196 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1197 Asm->sync();
1198 }
1199
1165 template <> void InstMIPS32Teq::emitIAS(const Cfg *Func) const { 1200 template <> void InstMIPS32Teq::emitIAS(const Cfg *Func) const {
1166 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1201 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1167 Asm->teq(getSrc(0), getSrc(1), getTrapCode()); 1202 Asm->teq(getSrc(0), getSrc(1), getTrapCode());
1168 } 1203 }
1169 1204
1170 template <> void InstMIPS32Trunc_l_d::emitIAS(const Cfg *Func) const { 1205 template <> void InstMIPS32Trunc_l_d::emitIAS(const Cfg *Func) const {
1171 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1206 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1172 Asm->trunc_l_d(getDest(), getSrc(0)); 1207 Asm->trunc_l_d(getDest(), getSrc(0));
1173 } 1208 }
1174 1209
(...skipping 17 matching lines...) Expand all
1192 Asm->xor_(getDest(), getSrc(0), getSrc(1)); 1227 Asm->xor_(getDest(), getSrc(0), getSrc(1));
1193 } 1228 }
1194 1229
1195 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const { 1230 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const {
1196 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); 1231 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
1197 Asm->xori(getDest(), getSrc(0), Imm); 1232 Asm->xori(getDest(), getSrc(0), Imm);
1198 } 1233 }
1199 1234
1200 } // end of namespace MIPS32 1235 } // end of namespace MIPS32
1201 } // end of namespace Ice 1236 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698