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) |
| 116 : InstMIPS32(Func, InstMIPS32::Label, 0, nullptr), |
| 117 Number(Target->makeNextLabelNumber()) {} |
| 118 |
| 119 IceString InstMIPS32Label::getName(const Cfg *Func) const { |
| 120 if (!BuildDefs::dump()) |
| 121 return IceString(); |
| 122 return ".L" + Func->getFunctionName() + "$local$__" + std::to_string(Number); |
| 123 } |
| 124 |
| 125 void InstMIPS32Label::dump(const Cfg *Func) const { |
| 126 if (!BuildDefs::dump()) |
| 127 return; |
| 128 Ostream &Str = Func->getContext()->getStrDump(); |
| 129 Str << getName(Func) << ":"; |
| 130 } |
| 131 |
| 132 void InstMIPS32Label::emitIAS(const Cfg *Func) const { |
| 133 (void)Func; |
| 134 llvm_unreachable("Not yet implemented"); |
| 135 } |
| 136 |
109 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) | 137 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) |
110 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { | 138 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { |
111 HasSideEffects = true; | 139 HasSideEffects = true; |
112 addSource(CallTarget); | 140 addSource(CallTarget); |
113 } | 141 } |
114 | 142 |
115 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) | 143 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) |
116 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { | 144 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { |
117 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); | 145 auto *Dest64 = llvm::dyn_cast<Variable64On32>(Dest); |
118 auto *Src64 = llvm::dyn_cast<Variable64On32>(Src); | 146 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)); | 246 auto *RA = llvm::cast<Variable>(getSrc(0)); |
219 assert(RA->hasReg()); | 247 assert(RA->hasReg()); |
220 assert(RA->getRegNum() == RegMIPS32::Reg_RA); | 248 assert(RA->getRegNum() == RegMIPS32::Reg_RA); |
221 Ostream &Str = Func->getContext()->getStrEmit(); | 249 Ostream &Str = Func->getContext()->getStrEmit(); |
222 Str << "\t" | 250 Str << "\t" |
223 "jr" | 251 "jr" |
224 "\t"; | 252 "\t"; |
225 RA->emit(Func); | 253 RA->emit(Func); |
226 } | 254 } |
227 | 255 |
| 256 void InstMIPS32Br::emit(const Cfg *Func) const { |
| 257 if (!BuildDefs::dump()) |
| 258 return; |
| 259 Ostream &Str = Func->getContext()->getStrEmit(); |
| 260 Str << "\t" |
| 261 "b" |
| 262 << "\t"; |
| 263 if (Label) { |
| 264 Str << Label->getName(Func); |
| 265 } else { |
| 266 if (isUnconditionalBranch()) { |
| 267 Str << getTargetFalse()->getAsmName(); |
| 268 } else { |
| 269 // TODO(reed kotler): Finish implementing conditional branch. |
| 270 } |
| 271 } |
| 272 } |
| 273 |
228 void InstMIPS32Call::emit(const Cfg *Func) const { | 274 void InstMIPS32Call::emit(const Cfg *Func) const { |
229 if (!BuildDefs::dump()) | 275 if (!BuildDefs::dump()) |
230 return; | 276 return; |
231 Ostream &Str = Func->getContext()->getStrEmit(); | 277 Ostream &Str = Func->getContext()->getStrEmit(); |
232 assert(getSrcSize() == 1); | 278 assert(getSrcSize() == 1); |
233 if (llvm::isa<ConstantInteger32>(getCallTarget())) { | 279 if (llvm::isa<ConstantInteger32>(getCallTarget())) { |
234 // This shouldn't happen (typically have to copy the full 32-bits to a | 280 // This shouldn't happen (typically have to copy the full 32-bits to a |
235 // register and do an indirect jump). | 281 // register and do an indirect jump). |
236 llvm::report_fatal_error("MIPS2Call to ConstantInteger32"); | 282 llvm::report_fatal_error("MIPS2Call to ConstantInteger32"); |
237 } else if (const auto *CallTarget = | 283 } else if (const auto *CallTarget = |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 438 } |
393 | 439 |
394 Str << "\t"; | 440 Str << "\t"; |
395 getDest()->emit(Func); | 441 getDest()->emit(Func); |
396 Str << ", "; | 442 Str << ", "; |
397 getSrc(0)->emit(Func); | 443 getSrc(0)->emit(Func); |
398 } | 444 } |
399 | 445 |
400 } // end of namespace MIPS32 | 446 } // end of namespace MIPS32 |
401 } // end of namespace Ice | 447 } // end of namespace Ice |
OLD | NEW |