OLD | NEW |
1 //===- subzero/src/IceInst.cpp - High-level instruction implementation ----===// | 1 //===- subzero/src/IceInst.cpp - High-level 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 // This file implements the Inst class, primarily the various | 10 // This file implements the Inst class, primarily the various |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 addSource(Source); | 243 addSource(Source); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 InstBr::InstBr(Cfg *Func, CfgNode *Target) | 247 InstBr::InstBr(Cfg *Func, CfgNode *Target) |
248 : InstHighLevel(Func, Inst::Br, 0, NULL), TargetFalse(Target), | 248 : InstHighLevel(Func, Inst::Br, 0, NULL), TargetFalse(Target), |
249 TargetTrue(NULL) {} | 249 TargetTrue(NULL) {} |
250 | 250 |
251 NodeList InstBr::getTerminatorEdges() const { | 251 NodeList InstBr::getTerminatorEdges() const { |
252 NodeList OutEdges; | 252 NodeList OutEdges; |
| 253 OutEdges.reserve(TargetTrue ? 2 : 1); |
253 OutEdges.push_back(TargetFalse); | 254 OutEdges.push_back(TargetFalse); |
254 if (TargetTrue) | 255 if (TargetTrue) |
255 OutEdges.push_back(TargetTrue); | 256 OutEdges.push_back(TargetTrue); |
256 return OutEdges; | 257 return OutEdges; |
257 } | 258 } |
258 | 259 |
259 bool InstBr::repointEdge(CfgNode *OldNode, CfgNode *NewNode) { | 260 bool InstBr::repointEdge(CfgNode *OldNode, CfgNode *NewNode) { |
260 if (TargetFalse == OldNode) { | 261 if (TargetFalse == OldNode) { |
261 TargetFalse = NewNode; | 262 TargetFalse = NewNode; |
262 return true; | 263 return true; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 403 } |
403 | 404 |
404 void InstSwitch::addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label) { | 405 void InstSwitch::addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label) { |
405 assert(CaseIndex < NumCases); | 406 assert(CaseIndex < NumCases); |
406 Values[CaseIndex] = Value; | 407 Values[CaseIndex] = Value; |
407 Labels[CaseIndex] = Label; | 408 Labels[CaseIndex] = Label; |
408 } | 409 } |
409 | 410 |
410 NodeList InstSwitch::getTerminatorEdges() const { | 411 NodeList InstSwitch::getTerminatorEdges() const { |
411 NodeList OutEdges; | 412 NodeList OutEdges; |
| 413 OutEdges.reserve(NumCases + 1); |
412 OutEdges.push_back(LabelDefault); | 414 OutEdges.push_back(LabelDefault); |
413 for (SizeT I = 0; I < NumCases; ++I) { | 415 for (SizeT I = 0; I < NumCases; ++I) { |
414 OutEdges.push_back(Labels[I]); | 416 OutEdges.push_back(Labels[I]); |
415 } | 417 } |
416 return OutEdges; | 418 return OutEdges; |
417 } | 419 } |
418 | 420 |
419 bool InstSwitch::repointEdge(CfgNode *OldNode, CfgNode *NewNode) { | 421 bool InstSwitch::repointEdge(CfgNode *OldNode, CfgNode *NewNode) { |
420 if (LabelDefault == OldNode) { | 422 if (LabelDefault == OldNode) { |
421 LabelDefault = NewNode; | 423 LabelDefault = NewNode; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 810 |
809 void InstTarget::dump(const Cfg *Func) const { | 811 void InstTarget::dump(const Cfg *Func) const { |
810 if (!ALLOW_DUMP) | 812 if (!ALLOW_DUMP) |
811 return; | 813 return; |
812 Ostream &Str = Func->getContext()->getStrDump(); | 814 Ostream &Str = Func->getContext()->getStrDump(); |
813 Str << "[TARGET] "; | 815 Str << "[TARGET] "; |
814 Inst::dump(Func); | 816 Inst::dump(Func); |
815 } | 817 } |
816 | 818 |
817 } // end of namespace Ice | 819 } // end of namespace Ice |
OLD | NEW |