Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/IceInst.cpp

Issue 680733002: Subzero: Allow delaying Phi lowering until after register allocation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix vector const undef lowering for phis. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceInst.h ('k') | src/IceInstX8632.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 continue; 128 continue;
129 SizeT Index = Var->getIndex(); 129 SizeT Index = Var->getIndex();
130 if (Live[Index]) 130 if (Live[Index])
131 continue; 131 continue;
132 Live[Index] = true; 132 Live[Index] = true;
133 setLastUse(VarIndex); 133 setLastUse(VarIndex);
134 } 134 }
135 } 135 }
136 } 136 }
137 137
138 void Inst::liveness(InstNumberT InstNumber, LivenessBV &Live, 138 bool Inst::liveness(InstNumberT InstNumber, LivenessBV &Live,
139 Liveness *Liveness, LiveBeginEndMap *LiveBegin, 139 Liveness *Liveness, LiveBeginEndMap *LiveBegin,
140 LiveBeginEndMap *LiveEnd) { 140 LiveBeginEndMap *LiveEnd) {
141 assert(!isDeleted()); 141 assert(!isDeleted());
142 if (llvm::isa<InstFakeKill>(this)) 142 if (llvm::isa<InstFakeKill>(this))
143 return; 143 return true;
144 144
145 Dead = false; 145 Dead = false;
146 if (Dest) { 146 if (Dest) {
147 SizeT VarNum = Liveness->getLiveIndex(Dest->getIndex()); 147 SizeT VarNum = Liveness->getLiveIndex(Dest->getIndex());
148 if (Live[VarNum]) { 148 if (Live[VarNum]) {
149 if (!isDestNonKillable()) { 149 if (!isDestNonKillable()) {
150 Live[VarNum] = false; 150 Live[VarNum] = false;
151 if (LiveBegin) { 151 if (LiveBegin) {
152 LiveBegin->push_back(std::make_pair(VarNum, InstNumber)); 152 LiveBegin->push_back(std::make_pair(VarNum, InstNumber));
153 } 153 }
154 } 154 }
155 } else { 155 } else {
156 if (!hasSideEffects()) 156 if (!hasSideEffects())
157 Dead = true; 157 Dead = true;
158 } 158 }
159 } 159 }
160 if (Dead) 160 if (Dead)
161 return; 161 return false;
162 // Phi arguments only get added to Live in the predecessor node, but 162 // Phi arguments only get added to Live in the predecessor node, but
163 // we still need to update LiveRangesEnded. 163 // we still need to update LiveRangesEnded.
164 bool IsPhi = llvm::isa<InstPhi>(this); 164 bool IsPhi = llvm::isa<InstPhi>(this);
165 resetLastUses(); 165 resetLastUses();
166 SizeT VarIndex = 0; 166 SizeT VarIndex = 0;
167 for (SizeT I = 0; I < getSrcSize(); ++I) { 167 for (SizeT I = 0; I < getSrcSize(); ++I) {
168 Operand *Src = getSrc(I); 168 Operand *Src = getSrc(I);
169 SizeT NumVars = Src->getNumVars(); 169 SizeT NumVars = Src->getNumVars();
170 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) { 170 for (SizeT J = 0; J < NumVars; ++J, ++VarIndex) {
171 const Variable *Var = Src->getVar(J); 171 const Variable *Var = Src->getVar(J);
(...skipping 23 matching lines...) Expand all
195 // added in this block, but this can't be done very 195 // added in this block, but this can't be done very
196 // efficiently with LiveEnd as a vector. Instead, 196 // efficiently with LiveEnd as a vector. Instead,
197 // livenessPostprocess() verifies this after the vector 197 // livenessPostprocess() verifies this after the vector
198 // has been sorted. 198 // has been sorted.
199 LiveEnd->push_back(std::make_pair(VarNum, InstNumber)); 199 LiveEnd->push_back(std::make_pair(VarNum, InstNumber));
200 } 200 }
201 } 201 }
202 } 202 }
203 } 203 }
204 } 204 }
205 return true;
205 } 206 }
206 207
207 InstAlloca::InstAlloca(Cfg *Func, Operand *ByteCount, uint32_t AlignInBytes, 208 InstAlloca::InstAlloca(Cfg *Func, Operand *ByteCount, uint32_t AlignInBytes,
208 Variable *Dest) 209 Variable *Dest)
209 : InstHighLevel(Func, Inst::Alloca, 1, Dest), AlignInBytes(AlignInBytes) { 210 : InstHighLevel(Func, Inst::Alloca, 1, Dest), AlignInBytes(AlignInBytes) {
210 // Verify AlignInBytes is 0 or a power of 2. 211 // Verify AlignInBytes is 0 or a power of 2.
211 assert(AlignInBytes == 0 || llvm::isPowerOf2_32(AlignInBytes)); 212 assert(AlignInBytes == 0 || llvm::isPowerOf2_32(AlignInBytes));
212 addSource(ByteCount); 213 addSource(ByteCount);
213 } 214 }
214 215
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 TargetTrue(NULL) {} 255 TargetTrue(NULL) {}
255 256
256 NodeList InstBr::getTerminatorEdges() const { 257 NodeList InstBr::getTerminatorEdges() const {
257 NodeList OutEdges; 258 NodeList OutEdges;
258 OutEdges.push_back(TargetFalse); 259 OutEdges.push_back(TargetFalse);
259 if (TargetTrue) 260 if (TargetTrue)
260 OutEdges.push_back(TargetTrue); 261 OutEdges.push_back(TargetTrue);
261 return OutEdges; 262 return OutEdges;
262 } 263 }
263 264
265 bool InstBr::repointEdge(CfgNode *OldNode, CfgNode *NewNode) {
266 if (TargetFalse == OldNode) {
267 TargetFalse = NewNode;
268 return true;
269 } else if (TargetTrue == OldNode) {
270 TargetTrue = NewNode;
271 return true;
272 }
273 return false;
274 }
275
264 InstCast::InstCast(Cfg *Func, OpKind CastKind, Variable *Dest, Operand *Source) 276 InstCast::InstCast(Cfg *Func, OpKind CastKind, Variable *Dest, Operand *Source)
265 : InstHighLevel(Func, Inst::Cast, 1, Dest), CastKind(CastKind) { 277 : InstHighLevel(Func, Inst::Cast, 1, Dest), CastKind(CastKind) {
266 addSource(Source); 278 addSource(Source);
267 } 279 }
268 280
269 InstExtractElement::InstExtractElement(Cfg *Func, Variable *Dest, 281 InstExtractElement::InstExtractElement(Cfg *Func, Variable *Dest,
270 Operand *Source1, Operand *Source2) 282 Operand *Source1, Operand *Source2)
271 : InstHighLevel(Func, Inst::ExtractElement, 2, Dest) { 283 : InstHighLevel(Func, Inst::ExtractElement, 2, Dest) {
272 addSource(Source1); 284 addSource(Source1);
273 addSource(Source2); 285 addSource(Source2);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 415
404 NodeList InstSwitch::getTerminatorEdges() const { 416 NodeList InstSwitch::getTerminatorEdges() const {
405 NodeList OutEdges; 417 NodeList OutEdges;
406 OutEdges.push_back(LabelDefault); 418 OutEdges.push_back(LabelDefault);
407 for (SizeT I = 0; I < NumCases; ++I) { 419 for (SizeT I = 0; I < NumCases; ++I) {
408 OutEdges.push_back(Labels[I]); 420 OutEdges.push_back(Labels[I]);
409 } 421 }
410 return OutEdges; 422 return OutEdges;
411 } 423 }
412 424
425 bool InstSwitch::repointEdge(CfgNode *OldNode, CfgNode *NewNode) {
426 if (LabelDefault == OldNode) {
427 LabelDefault = NewNode;
428 return true;
429 }
430 for (SizeT I = 0; I < NumCases; ++I) {
431 if (Labels[I] == OldNode) {
432 Labels[I] = NewNode;
433 return true;
434 }
435 }
436 return false;
437 }
438
413 InstUnreachable::InstUnreachable(Cfg *Func) 439 InstUnreachable::InstUnreachable(Cfg *Func)
414 : InstHighLevel(Func, Inst::Unreachable, 0, NULL) {} 440 : InstHighLevel(Func, Inst::Unreachable, 0, NULL) {}
415 441
416 InstFakeDef::InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src) 442 InstFakeDef::InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src)
417 : InstHighLevel(Func, Inst::FakeDef, Src ? 1 : 0, Dest) { 443 : InstHighLevel(Func, Inst::FakeDef, Src ? 1 : 0, Dest) {
418 assert(Dest); 444 assert(Dest);
419 if (Src) 445 if (Src)
420 addSource(Src); 446 addSource(Src);
421 } 447 }
422 448
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 dumpSources(Func); 774 dumpSources(Func);
749 } 775 }
750 776
751 void InstTarget::dump(const Cfg *Func) const { 777 void InstTarget::dump(const Cfg *Func) const {
752 Ostream &Str = Func->getContext()->getStrDump(); 778 Ostream &Str = Func->getContext()->getStrDump();
753 Str << "[TARGET] "; 779 Str << "[TARGET] ";
754 Inst::dump(Func); 780 Inst::dump(Func);
755 } 781 }
756 782
757 } // end of namespace Ice 783 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInst.h ('k') | src/IceInstX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698