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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 | 340 |
341 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new | 341 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new |
342 // instruction "a=a_phi". | 342 // instruction "a=a_phi". |
343 Inst *InstPhi::lower(Cfg *Func) { | 343 Inst *InstPhi::lower(Cfg *Func) { |
344 Variable *Dest = getDest(); | 344 Variable *Dest = getDest(); |
345 assert(Dest); | 345 assert(Dest); |
346 IceString PhiName = Dest->getName() + "_phi"; | 346 IceString PhiName = Dest->getName() + "_phi"; |
347 Variable *NewSrc = Func->makeVariable(Dest->getType(), PhiName); | 347 Variable *NewSrc = Func->makeVariable(Dest->getType(), PhiName); |
348 this->Dest = NewSrc; | 348 this->Dest = NewSrc; |
349 InstAssign *NewInst = InstAssign::create(Func, Dest, NewSrc); | 349 return InstAssign::create(Func, Dest, NewSrc); |
350 // Set Dest and NewSrc to have affinity with each other, as a hint | |
351 // for register allocation. | |
352 Dest->setPreferredRegister(NewSrc, false); | |
353 NewSrc->setPreferredRegister(Dest, false); | |
354 return NewInst; | |
355 } | 350 } |
356 | 351 |
357 InstRet::InstRet(Cfg *Func, Operand *RetValue) | 352 InstRet::InstRet(Cfg *Func, Operand *RetValue) |
358 : Inst(Func, Ret, RetValue ? 1 : 0, NULL) { | 353 : Inst(Func, Ret, RetValue ? 1 : 0, NULL) { |
359 if (RetValue) | 354 if (RetValue) |
360 addSource(RetValue); | 355 addSource(RetValue); |
361 } | 356 } |
362 | 357 |
363 InstSelect::InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, | 358 InstSelect::InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, |
364 Operand *SourceTrue, Operand *SourceFalse) | 359 Operand *SourceTrue, Operand *SourceFalse) |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 750 |
756 void InstTarget::dump(const Cfg *Func) const { | 751 void InstTarget::dump(const Cfg *Func) const { |
757 Ostream &Str = Func->getContext()->getStrDump(); | 752 Ostream &Str = Func->getContext()->getStrDump(); |
758 Str << "[TARGET] "; | 753 Str << "[TARGET] "; |
759 Inst::dump(Func); | 754 Inst::dump(Func); |
760 } | 755 } |
761 | 756 |
762 void InstTarget::dumpExtras(const Cfg *Func) const { Inst::dumpExtras(Func); } | 757 void InstTarget::dumpExtras(const Cfg *Func) const { Inst::dumpExtras(Func); } |
763 | 758 |
764 } // end of namespace Ice | 759 } // end of namespace Ice |
OLD | NEW |