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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 | 108 |
109 InstMIPS32Br::InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, | 109 InstMIPS32Br::InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, |
110 const CfgNode *TargetFalse, | 110 const CfgNode *TargetFalse, |
111 const InstMIPS32Label *Label) | 111 const InstMIPS32Label *Label) |
112 : InstMIPS32(Func, InstMIPS32::Br, 0, nullptr), TargetTrue(TargetTrue), | 112 : InstMIPS32(Func, InstMIPS32::Br, 0, nullptr), TargetTrue(TargetTrue), |
113 TargetFalse(TargetFalse), Label(Label) {} | 113 TargetFalse(TargetFalse), Label(Label) {} |
114 | 114 |
115 InstMIPS32Label::InstMIPS32Label(Cfg *Func, TargetMIPS32 *Target) | 115 InstMIPS32Label::InstMIPS32Label(Cfg *Func, TargetMIPS32 *Target) |
116 : InstMIPS32(Func, InstMIPS32::Label, 0, nullptr), | 116 : InstMIPS32(Func, InstMIPS32::Label, 0, nullptr), |
117 Number(Target->makeNextLabelNumber()) {} | 117 Number(Target->makeNextLabelNumber()) { |
118 | 118 if (BuildDefs::dump()) { |
119 IceString InstMIPS32Label::getName(const Cfg *Func) const { | 119 Name = GlobalString::createWithString( |
120 if (!BuildDefs::dump()) | 120 Func->getContext(), |
121 return ""; | 121 ".L" + Func->getFunctionName() + "$local$__" + std::to_string(Number)); |
122 return ".L" + Func->getFunctionName() + "$local$__" + std::to_string(Number); | 122 } else { |
| 123 Name = GlobalString::createWithoutString(Func->getContext()); |
| 124 } |
123 } | 125 } |
124 | 126 |
125 void InstMIPS32Label::dump(const Cfg *Func) const { | 127 void InstMIPS32Label::dump(const Cfg *Func) const { |
126 if (!BuildDefs::dump()) | 128 if (!BuildDefs::dump()) |
127 return; | 129 return; |
128 Ostream &Str = Func->getContext()->getStrDump(); | 130 Ostream &Str = Func->getContext()->getStrDump(); |
129 Str << getName(Func) << ":"; | 131 Str << getLabelName() << ":"; |
130 } | 132 } |
131 | 133 |
132 void InstMIPS32Label::emit(const Cfg *Func) const { | 134 void InstMIPS32Label::emit(const Cfg *Func) const { |
133 if (!BuildDefs::dump()) | 135 if (!BuildDefs::dump()) |
134 return; | 136 return; |
135 Ostream &Str = Func->getContext()->getStrEmit(); | 137 Ostream &Str = Func->getContext()->getStrEmit(); |
136 Str << getName(Func) << ":"; | 138 Str << getLabelName() << ":"; |
137 } | 139 } |
138 | 140 |
139 void InstMIPS32Label::emitIAS(const Cfg *Func) const { | 141 void InstMIPS32Label::emitIAS(const Cfg *Func) const { |
140 (void)Func; | 142 (void)Func; |
141 llvm_unreachable("Not yet implemented"); | 143 llvm_unreachable("Not yet implemented"); |
142 } | 144 } |
143 | 145 |
144 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) | 146 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) |
145 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { | 147 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { |
146 HasSideEffects = true; | 148 HasSideEffects = true; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 263 } |
262 | 264 |
263 void InstMIPS32Br::emit(const Cfg *Func) const { | 265 void InstMIPS32Br::emit(const Cfg *Func) const { |
264 if (!BuildDefs::dump()) | 266 if (!BuildDefs::dump()) |
265 return; | 267 return; |
266 Ostream &Str = Func->getContext()->getStrEmit(); | 268 Ostream &Str = Func->getContext()->getStrEmit(); |
267 Str << "\t" | 269 Str << "\t" |
268 "b" | 270 "b" |
269 << "\t"; | 271 << "\t"; |
270 if (Label) { | 272 if (Label) { |
271 Str << Label->getName(Func); | 273 Str << Label->getLabelName(); |
272 } else { | 274 } else { |
273 if (isUnconditionalBranch()) { | 275 if (isUnconditionalBranch()) { |
274 Str << getTargetFalse()->getAsmName(); | 276 Str << getTargetFalse()->getAsmName(); |
275 } else { | 277 } else { |
276 // TODO(reed kotler): Finish implementing conditional branch. | 278 // TODO(reed kotler): Finish implementing conditional branch. |
277 } | 279 } |
278 } | 280 } |
279 } | 281 } |
280 | 282 |
281 void InstMIPS32Call::emit(const Cfg *Func) const { | 283 void InstMIPS32Call::emit(const Cfg *Func) const { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 } | 447 } |
446 | 448 |
447 Str << "\t"; | 449 Str << "\t"; |
448 getDest()->emit(Func); | 450 getDest()->emit(Func); |
449 Str << ", "; | 451 Str << ", "; |
450 getSrc(0)->emit(Func); | 452 getSrc(0)->emit(Func); |
451 } | 453 } |
452 | 454 |
453 } // end of namespace MIPS32 | 455 } // end of namespace MIPS32 |
454 } // end of namespace Ice | 456 } // end of namespace Ice |
OLD | NEW |