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

Side by Side Diff: src/IceOperand.cpp

Issue 819403002: Subzero: Use range-based for loops with llvm::ilist<Inst> lists. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years 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/IceCfgNode.cpp ('k') | src/IceRegAlloc.cpp » ('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/IceOperand.cpp - High-level operand implementation -----===// 1 //===- subzero/src/IceOperand.cpp - High-level operand 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 Operand class and its target-independent 10 // This file implements the Operand class and its target-independent
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 279 }
280 280
281 for (CfgNode *Node : Func->getNodes()) 281 for (CfgNode *Node : Func->getNodes())
282 addNode(Node); 282 addNode(Node);
283 } 283 }
284 284
285 void VariablesMetadata::addNode(CfgNode *Node) { 285 void VariablesMetadata::addNode(CfgNode *Node) {
286 if (Func->getNumVariables() >= Metadata.size()) 286 if (Func->getNumVariables() >= Metadata.size())
287 Metadata.resize(Func->getNumVariables()); 287 Metadata.resize(Func->getNumVariables());
288 288
289 for (auto I = Node->getPhis().begin(), E = Node->getPhis().end(); I != E; 289 for (Inst &I : Node->getPhis()) {
290 ++I) { 290 if (I.isDeleted())
291 if (I->isDeleted())
292 continue; 291 continue;
293 if (Variable *Dest = I->getDest()) { 292 if (Variable *Dest = I.getDest()) {
294 SizeT DestNum = Dest->getIndex(); 293 SizeT DestNum = Dest->getIndex();
295 assert(DestNum < Metadata.size()); 294 assert(DestNum < Metadata.size());
296 Metadata[DestNum].markDef(Kind, I, Node); 295 Metadata[DestNum].markDef(Kind, &I, Node);
297 } 296 }
298 for (SizeT SrcNum = 0; SrcNum < I->getSrcSize(); ++SrcNum) { 297 for (SizeT SrcNum = 0; SrcNum < I.getSrcSize(); ++SrcNum) {
299 if (const Variable *Var = llvm::dyn_cast<Variable>(I->getSrc(SrcNum))) { 298 if (const Variable *Var = llvm::dyn_cast<Variable>(I.getSrc(SrcNum))) {
300 SizeT VarNum = Var->getIndex(); 299 SizeT VarNum = Var->getIndex();
301 assert(VarNum < Metadata.size()); 300 assert(VarNum < Metadata.size());
302 const bool IsFromDef = false; 301 const bool IsFromDef = false;
303 const bool IsImplicit = false; 302 const bool IsImplicit = false;
304 Metadata[VarNum].markUse(Kind, I, Node, IsFromDef, IsImplicit); 303 Metadata[VarNum].markUse(Kind, &I, Node, IsFromDef, IsImplicit);
305 } 304 }
306 } 305 }
307 } 306 }
308 307
309 for (auto I = Node->getInsts().begin(), E = Node->getInsts().end(); I != E; 308 for (Inst &I : Node->getInsts()) {
310 ++I) { 309 if (I.isDeleted())
311 if (I->isDeleted())
312 continue; 310 continue;
313 // Note: The implicit definitions (and uses) from InstFakeKill are 311 // Note: The implicit definitions (and uses) from InstFakeKill are
314 // deliberately ignored. 312 // deliberately ignored.
315 if (Variable *Dest = I->getDest()) { 313 if (Variable *Dest = I.getDest()) {
316 SizeT DestNum = Dest->getIndex(); 314 SizeT DestNum = Dest->getIndex();
317 assert(DestNum < Metadata.size()); 315 assert(DestNum < Metadata.size());
318 Metadata[DestNum].markDef(Kind, I, Node); 316 Metadata[DestNum].markDef(Kind, &I, Node);
319 } 317 }
320 for (SizeT SrcNum = 0; SrcNum < I->getSrcSize(); ++SrcNum) { 318 for (SizeT SrcNum = 0; SrcNum < I.getSrcSize(); ++SrcNum) {
321 Operand *Src = I->getSrc(SrcNum); 319 Operand *Src = I.getSrc(SrcNum);
322 SizeT NumVars = Src->getNumVars(); 320 SizeT NumVars = Src->getNumVars();
323 for (SizeT J = 0; J < NumVars; ++J) { 321 for (SizeT J = 0; J < NumVars; ++J) {
324 const Variable *Var = Src->getVar(J); 322 const Variable *Var = Src->getVar(J);
325 SizeT VarNum = Var->getIndex(); 323 SizeT VarNum = Var->getIndex();
326 assert(VarNum < Metadata.size()); 324 assert(VarNum < Metadata.size());
327 const bool IsFromDef = false; 325 const bool IsFromDef = false;
328 const bool IsImplicit = false; 326 const bool IsImplicit = false;
329 Metadata[VarNum].markUse(Kind, I, Node, IsFromDef, IsImplicit); 327 Metadata[VarNum].markUse(Kind, &I, Node, IsFromDef, IsImplicit);
330 } 328 }
331 } 329 }
332 } 330 }
333 } 331 }
334 332
335 bool VariablesMetadata::isMultiDef(const Variable *Var) const { 333 bool VariablesMetadata::isMultiDef(const Variable *Var) const {
336 assert(Kind != VMK_Uses); 334 assert(Kind != VMK_Uses);
337 if (Var->getIsArg()) 335 if (Var->getIsArg())
338 return false; 336 return false;
339 if (!isTracked(Var)) 337 if (!isTracked(Var))
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 if (!ALLOW_DUMP) 481 if (!ALLOW_DUMP)
484 return Str; 482 return Str;
485 if (W.getWeight() == RegWeight::Inf) 483 if (W.getWeight() == RegWeight::Inf)
486 Str << "Inf"; 484 Str << "Inf";
487 else 485 else
488 Str << W.getWeight(); 486 Str << W.getWeight();
489 return Str; 487 return Str;
490 } 488 }
491 489
492 } // end of namespace Ice 490 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.cpp ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698