| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 Mask >>= 1; | 105 Mask >>= 1; |
| 106 if (Mask == 0) | 106 if (Mask == 0) |
| 107 return false; // another early-exit optimization | 107 return false; // another early-exit optimization |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 return false; | 111 return false; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void Inst::updateVars(CfgNode *Node) { | 114 void Inst::livenessLightweight(Cfg *Func, llvm::BitVector &Live) { |
| 115 if (Dest) | |
| 116 Dest->setDefinition(this, Node); | |
| 117 | |
| 118 for (SizeT I = 0; I < getSrcSize(); ++I) { | |
| 119 Operand *Src = getSrc(I); | |
| 120 SizeT NumVars = Src->getNumVars(); | |
| 121 for (SizeT J = 0; J < NumVars; ++J) { | |
| 122 Variable *Var = Src->getVar(J); | |
| 123 Var->setUse(this, Node); | |
| 124 } | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 void Inst::livenessLightweight(llvm::BitVector &Live) { | |
| 129 assert(!isDeleted()); | 115 assert(!isDeleted()); |
| 130 if (llvm::isa<InstFakeKill>(this)) | 116 if (llvm::isa<InstFakeKill>(this)) |
| 131 return; | 117 return; |
| 132 resetLastUses(); | 118 resetLastUses(); |
| 133 SizeT VarIndex = 0; | 119 SizeT VarIndex = 0; |
| 134 for (SizeT I = 0; I < getSrcSize(); ++I) { | 120 for (SizeT I = 0; I < getSrcSize(); ++I) { |
| 135 Operand *Src = getSrc(I); | 121 Operand *Src = getSrc(I); |
| 136 SizeT NumVars = Src->getNumVars(); | 122 SizeT NumVars = Src->getNumVars(); |
| 137 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { | 123 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { |
| 138 const Variable *Var = Src->getVar(J); | 124 const Variable *Var = Src->getVar(J); |
| 139 if (Var->isMultiblockLife()) | 125 if (Func->getVMetadata()->isMultiBlock(Var)) |
| 140 continue; | 126 continue; |
| 141 SizeT Index = Var->getIndex(); | 127 SizeT Index = Var->getIndex(); |
| 142 if (Live[Index]) | 128 if (Live[Index]) |
| 143 continue; | 129 continue; |
| 144 Live[Index] = true; | 130 Live[Index] = true; |
| 145 setLastUse(VarIndex); | 131 setLastUse(VarIndex); |
| 146 } | 132 } |
| 147 } | 133 } |
| 148 } | 134 } |
| 149 | 135 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 333 } |
| 348 } | 334 } |
| 349 return; | 335 return; |
| 350 } | 336 } |
| 351 } | 337 } |
| 352 llvm_unreachable("Phi operand not found for specified target node"); | 338 llvm_unreachable("Phi operand not found for specified target node"); |
| 353 } | 339 } |
| 354 | 340 |
| 355 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new | 341 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new |
| 356 // instruction "a=a_phi". | 342 // instruction "a=a_phi". |
| 357 Inst *InstPhi::lower(Cfg *Func, CfgNode *Node) { | 343 Inst *InstPhi::lower(Cfg *Func) { |
| 358 Variable *Dest = getDest(); | 344 Variable *Dest = getDest(); |
| 359 assert(Dest); | 345 assert(Dest); |
| 360 IceString PhiName = Dest->getName() + "_phi"; | 346 IceString PhiName = Dest->getName() + "_phi"; |
| 361 Variable *NewSrc = Func->makeVariable(Dest->getType(), Node, PhiName); | 347 Variable *NewSrc = Func->makeVariable(Dest->getType(), PhiName); |
| 362 NewSrc->setIsMultidef(); | |
| 363 this->Dest = NewSrc; | 348 this->Dest = NewSrc; |
| 364 InstAssign *NewInst = InstAssign::create(Func, Dest, NewSrc); | 349 InstAssign *NewInst = InstAssign::create(Func, Dest, NewSrc); |
| 365 // Set Dest and NewSrc to have affinity with each other, as a hint | 350 // Set Dest and NewSrc to have affinity with each other, as a hint |
| 366 // for register allocation. | 351 // for register allocation. |
| 367 Dest->setPreferredRegister(NewSrc, false); | 352 Dest->setPreferredRegister(NewSrc, false); |
| 368 NewSrc->setPreferredRegister(Dest, false); | 353 NewSrc->setPreferredRegister(Dest, false); |
| 369 Dest->replaceDefinition(NewInst, Node); | |
| 370 return NewInst; | 354 return NewInst; |
| 371 } | 355 } |
| 372 | 356 |
| 373 InstRet::InstRet(Cfg *Func, Operand *RetValue) | 357 InstRet::InstRet(Cfg *Func, Operand *RetValue) |
| 374 : Inst(Func, Ret, RetValue ? 1 : 0, NULL) { | 358 : Inst(Func, Ret, RetValue ? 1 : 0, NULL) { |
| 375 if (RetValue) | 359 if (RetValue) |
| 376 addSource(RetValue); | 360 addSource(RetValue); |
| 377 } | 361 } |
| 378 | 362 |
| 379 InstSelect::InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, | 363 InstSelect::InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 | 753 |
| 770 void InstTarget::dump(const Cfg *Func) const { | 754 void InstTarget::dump(const Cfg *Func) const { |
| 771 Ostream &Str = Func->getContext()->getStrDump(); | 755 Ostream &Str = Func->getContext()->getStrDump(); |
| 772 Str << "[TARGET] "; | 756 Str << "[TARGET] "; |
| 773 Inst::dump(Func); | 757 Inst::dump(Func); |
| 774 } | 758 } |
| 775 | 759 |
| 776 void InstTarget::dumpExtras(const Cfg *Func) const { Inst::dumpExtras(Func); } | 760 void InstTarget::dumpExtras(const Cfg *Func) const { Inst::dumpExtras(Func); } |
| 777 | 761 |
| 778 } // end of namespace Ice | 762 } // end of namespace Ice |
| OLD | NEW |