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

Side by Side Diff: src/IceInstMIPS32.cpp

Issue 1414383004: Lower a few basic MIPS binops for i{8,16,32,64}. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: patch 2 per change requests from stichnot Created 5 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 const char *InstMIPS32::getWidthString(Type Ty) { 46 const char *InstMIPS32::getWidthString(Type Ty) {
47 (void)Ty; 47 (void)Ty;
48 return "TBD"; 48 return "TBD";
49 } 49 }
50 50
51 template <> const char *InstMIPS32Addiu::Opcode = "addiu"; 51 template <> const char *InstMIPS32Addiu::Opcode = "addiu";
52 template <> const char *InstMIPS32Lui::Opcode = "lui"; 52 template <> const char *InstMIPS32Lui::Opcode = "lui";
53 template <> const char *InstMIPS32La::Opcode = "la"; 53 template <> const char *InstMIPS32La::Opcode = "la";
54 54 // Three-addr ops
55 template <> const char *InstMIPS32Add::Opcode = "add";
56 template <> const char *InstMIPS32And::Opcode = "and";
57 template <> const char *InstMIPS32Mul::Opcode = "mul";
58 template <> const char *InstMIPS32Or::Opcode = "or";
55 template <> const char *InstMIPS32Ori::Opcode = "ori"; 59 template <> const char *InstMIPS32Ori::Opcode = "ori";
60 template <> const char *InstMIPS32Sub::Opcode = "sub";
61 template <> const char *InstMIPS32Xor::Opcode = "xor";
56 62
57 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) 63 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src)
58 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { 64 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) {
59 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); 65 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest);
60 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src); 66 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src);
61 67
62 assert(Dest64 == nullptr || Src64 == nullptr); 68 assert(Dest64 == nullptr || Src64 == nullptr);
63 69
64 if (Dest64 != nullptr) { 70 if (Dest64 != nullptr) {
65 // this-> is needed below because there is a parameter named Dest. 71 // this-> is needed below because there is a parameter named Dest.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return; 103 return;
98 llvm_unreachable("Not yet implemented"); 104 llvm_unreachable("Not yet implemented");
99 (void)Func; 105 (void)Func;
100 } 106 }
101 107
102 void InstMIPS32::emitUnaryopGPR(const char *Opcode, const InstMIPS32 *Inst, 108 void InstMIPS32::emitUnaryopGPR(const char *Opcode, const InstMIPS32 *Inst,
103 const Cfg *Func) { 109 const Cfg *Func) {
104 if (!BuildDefs::dump()) 110 if (!BuildDefs::dump())
105 return; 111 return;
106 Ostream &Str = Func->getContext()->getStrEmit(); 112 Ostream &Str = Func->getContext()->getStrEmit();
107 // Type SrcTy = Inst->getSrc(0)->getType();
108 Str << "\t" << Opcode << "\t"; 113 Str << "\t" << Opcode << "\t";
109 Inst->getDest()->emit(Func); 114 Inst->getDest()->emit(Func);
110 Str << ", "; 115 Str << ", ";
111 Inst->getSrc(0)->emit(Func); 116 Inst->getSrc(0)->emit(Func);
112 } 117 }
113 118
119 void InstMIPS32::emitThreeAddr(const char *Opcode, const InstMIPS32 *Inst,
120 const Cfg *Func) {
121 if (!BuildDefs::dump())
122 return;
123 Ostream &Str = Func->getContext()->getStrEmit();
124 assert(Inst->getSrcSize() == 2);
125 Str << "\t" << Opcode << "\t";
126 Inst->getDest()->emit(Func);
127 Str << ", ";
128 Inst->getSrc(0)->emit(Func);
129 Str << ", ";
130 Inst->getSrc(1)->emit(Func);
131 }
132
114 void InstMIPS32Ret::emit(const Cfg *Func) const { 133 void InstMIPS32Ret::emit(const Cfg *Func) const {
115 if (!BuildDefs::dump()) 134 if (!BuildDefs::dump())
116 return; 135 return;
117 assert(getSrcSize() > 0); 136 assert(getSrcSize() > 0);
118 Variable *RA = llvm::cast<Variable>(getSrc(0)); 137 Variable *RA = llvm::cast<Variable>(getSrc(0));
119 assert(RA->hasReg()); 138 assert(RA->hasReg());
120 assert(RA->getRegNum() == RegMIPS32::Reg_RA); 139 assert(RA->getRegNum() == RegMIPS32::Reg_RA);
121 Ostream &Str = Func->getContext()->getStrEmit(); 140 Ostream &Str = Func->getContext()->getStrEmit();
122 Str << "\t" 141 Str << "\t"
123 << "jr" 142 << "jr"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 Str << ", "; 240 Str << ", ";
222 SrcLo->emit(Func); 241 SrcLo->emit(Func);
223 Str << ", "; 242 Str << ", ";
224 SrcHi->emit(Func); 243 SrcHi->emit(Func);
225 } 244 }
226 245
227 void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const { 246 void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const {
228 Ostream &Str = Func->getContext()->getStrEmit(); 247 Ostream &Str = Func->getContext()->getStrEmit();
229 // assert(Inst->getSrcSize() == 1); 248 // assert(Inst->getSrcSize() == 1);
230 // Type SrcTy = Inst->getSrc(0)->getType(); 249 // Type SrcTy = Inst->getSrc(0)->getType();
231 Str << "\t" 250 auto *Dest = getDest();
Jim Stichnoth 2015/11/05 05:21:28 Please use Variable* here and Operand* in the next
rkotlerimgtec 2015/11/05 22:12:27 Done.
232 << "move" 251 auto *Src = getSrc(0);
233 << "\t"; 252 auto *S = llvm::dyn_cast<Variable>(Src);
253 Str << "\t";
254 if (Dest->hasReg()) {
255 if (S && S->hasReg())
256 Str << "move";
257 else
258 Str << "lw";
259 } else {
260 if (S && S->hasReg()) {
261 Str << "sw";
262 Str << "\t";
263 getSrc(0)->emit(Func);
264 Str << ", ";
265 getDest()->emit(Func);
266 return;
267 } else
268 Str << "move";
269 }
270
271 Str << "\t";
234 getDest()->emit(Func); 272 getDest()->emit(Func);
235 Str << ", "; 273 Str << ", ";
236 getSrc(0)->emit(Func); 274 getSrc(0)->emit(Func);
237 } 275 }
238 276
239 } // end of namespace Ice 277 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698