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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 return; | 99 return; |
100 emitThreeAddrLoHi(Opcode, this, Func); | 100 emitThreeAddrLoHi(Opcode, this, Func); |
101 } | 101 } |
102 | 102 |
103 template <> void InstMIPS32Multu::emit(const Cfg *Func) const { | 103 template <> void InstMIPS32Multu::emit(const Cfg *Func) const { |
104 if (!BuildDefs::dump()) | 104 if (!BuildDefs::dump()) |
105 return; | 105 return; |
106 emitThreeAddrLoHi(Opcode, this, Func); | 106 emitThreeAddrLoHi(Opcode, this, Func); |
107 } | 107 } |
108 | 108 |
109 InstMIPS32Br::InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, | |
110 const CfgNode *TargetFalse, | |
111 const InstMIPS32Label *Label) | |
112 : InstMIPS32(Func, InstMIPS32::Br, 0, nullptr), TargetTrue(TargetTrue), | |
113 TargetFalse(TargetFalse), Label(Label) {} | |
114 | |
115 InstMIPS32Label::InstMIPS32Label(Cfg *Func, TargetMIPS32 *Target) | |
Jim Stichnoth
2016/02/23 06:18:51
You may want to consider alphabetizing or otherwis
rkotlerimgtec
2016/02/23 23:17:20
Let's alphabetize in another patch. Otherwise it w
| |
116 : InstMIPS32(Func, InstMIPS32::Label, 0, nullptr), | |
117 Number(Target->makeNextLabelNumber()) {} | |
118 | |
119 IceString InstMIPS32Label::getName(const Cfg *Func) const { | |
120 return ".L" + Func->getFunctionName() + "$local$__" + std::to_string(Number); | |
Jim Stichnoth
2016/02/23 06:18:51
This method should probably start with something l
rkotlerimgtec
2016/02/23 23:17:20
Done.
| |
121 } | |
122 | |
109 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) | 123 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) |
110 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { | 124 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { |
111 HasSideEffects = true; | 125 HasSideEffects = true; |
112 addSource(CallTarget); | 126 addSource(CallTarget); |
113 } | 127 } |
114 | 128 |
115 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) | 129 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) |
116 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { | 130 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { |
117 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); | 131 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); |
118 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src); | 132 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 auto *RA = llvm::cast<Variable>(getSrc(0)); | 232 auto *RA = llvm::cast<Variable>(getSrc(0)); |
219 assert(RA->hasReg()); | 233 assert(RA->hasReg()); |
220 assert(RA->getRegNum() == RegMIPS32::Reg_RA); | 234 assert(RA->getRegNum() == RegMIPS32::Reg_RA); |
221 Ostream &Str = Func->getContext()->getStrEmit(); | 235 Ostream &Str = Func->getContext()->getStrEmit(); |
222 Str << "\t" | 236 Str << "\t" |
223 "jr" | 237 "jr" |
224 "\t"; | 238 "\t"; |
225 RA->emit(Func); | 239 RA->emit(Func); |
226 } | 240 } |
227 | 241 |
242 void InstMIPS32Br::emit(const Cfg *Func) const { | |
243 if (!BuildDefs::dump()) | |
244 return; | |
245 Ostream &Str = Func->getContext()->getStrEmit(); | |
246 Str << "\t" | |
247 "b" | |
248 << "\t"; | |
249 if (Label) { | |
250 Str << Label->getName(Func); | |
251 } else { | |
252 if (isUnconditionalBranch()) { | |
253 Str << getTargetFalse()->getAsmName(); | |
254 } else { | |
255 } | |
Jim Stichnoth
2016/02/23 06:18:51
Leave something here, like a TODO or an assert?
rkotlerimgtec
2016/02/23 23:17:20
Done.
| |
256 } | |
257 } | |
258 | |
228 void InstMIPS32Call::emit(const Cfg *Func) const { | 259 void InstMIPS32Call::emit(const Cfg *Func) const { |
229 if (!BuildDefs::dump()) | 260 if (!BuildDefs::dump()) |
230 return; | 261 return; |
231 Ostream &Str = Func->getContext()->getStrEmit(); | 262 Ostream &Str = Func->getContext()->getStrEmit(); |
232 assert(getSrcSize() == 1); | 263 assert(getSrcSize() == 1); |
233 if (llvm::isa<ConstantInteger32>(getCallTarget())) { | 264 if (llvm::isa<ConstantInteger32>(getCallTarget())) { |
234 // This shouldn't happen (typically have to copy the full 32-bits to a | 265 // This shouldn't happen (typically have to copy the full 32-bits to a |
235 // register and do an indirect jump). | 266 // register and do an indirect jump). |
236 llvm::report_fatal_error("MIPS2Call to ConstantInteger32"); | 267 llvm::report_fatal_error("MIPS2Call to ConstantInteger32"); |
237 } else if (const auto *CallTarget = | 268 } else if (const auto *CallTarget = |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 } | 423 } |
393 | 424 |
394 Str << "\t"; | 425 Str << "\t"; |
395 getDest()->emit(Func); | 426 getDest()->emit(Func); |
396 Str << ", "; | 427 Str << ", "; |
397 getSrc(0)->emit(Func); | 428 getSrc(0)->emit(Func); |
398 } | 429 } |
399 | 430 |
400 } // end of namespace MIPS32 | 431 } // end of namespace MIPS32 |
401 } // end of namespace Ice | 432 } // end of namespace Ice |
OLD | NEW |