Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// | 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) 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 /// \file | 10 /// \file |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 if (!Insts.empty()) { | 45 if (!Insts.empty()) { |
| 46 Func->setError("Phi instruction added to the middle of a block"); | 46 Func->setError("Phi instruction added to the middle of a block"); |
| 47 return; | 47 return; |
| 48 } | 48 } |
| 49 Phis.push_back(Phi); | 49 Phis.push_back(Phi); |
| 50 } else { | 50 } else { |
| 51 Insts.push_back(Instr); | 51 Insts.push_back(Instr); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Renumbers the non-deleted instructions in the node. This needs to be done in | 55 namespace { |
| 56 // preparation for live range analysis. The instruction numbers in a block must | 56 template <typename List> void removeDeletedAndRenumber(List *L, Cfg *Func) { |
|
John
2016/03/14 13:27:15
You don't need a template here -- L is always an I
Jim Stichnoth
2016/03/14 13:51:15
In one case it's InstList, in another case it's Ph
John
2016/03/14 14:55:50
Well, not a big deal --hence the previous LGTM, bu
| |
| 57 // be monotonically increasing. The range of instruction numbers in a block, | 57 const bool DoDelete = |
| 58 // from lowest to highest, must not overlap with the range of any other block. | 58 BuildDefs::minimal() || !GlobalContext::getFlags().getKeepDeletedInsts(); |
| 59 auto I = L->begin(), E = L->end(), Next = I; | |
| 60 for (++Next; I != E; I = Next++) { | |
|
Eric Holk
2016/03/14 13:20:14
Does a ranged for loop work here?
Jim Stichnoth
2016/03/14 13:51:16
I don't think so, because erase(I) invalidates ite
Eric Holk
2016/03/14 14:01:03
Ah, I see. I figured you had a good reason :)
| |
| 61 if (DoDelete && I->isDeleted()) { | |
| 62 L->erase(I); | |
| 63 } else { | |
| 64 I->renumber(Func); | |
| 65 } | |
| 66 } | |
| 67 } | |
| 68 } // end of anonymous namespace | |
| 69 | |
| 59 void CfgNode::renumberInstructions() { | 70 void CfgNode::renumberInstructions() { |
| 60 InstNumberT FirstNumber = Func->getNextInstNumber(); | 71 InstNumberT FirstNumber = Func->getNextInstNumber(); |
| 61 for (Inst &I : Phis) | 72 removeDeletedAndRenumber(&Phis, Func); |
| 62 I.renumber(Func); | 73 removeDeletedAndRenumber(&Insts, Func); |
| 63 for (Inst &I : Insts) | |
| 64 I.renumber(Func); | |
| 65 InstCountEstimate = Func->getNextInstNumber() - FirstNumber; | 74 InstCountEstimate = Func->getNextInstNumber() - FirstNumber; |
| 66 } | 75 } |
| 67 | 76 |
| 68 // When a node is created, the OutEdges are immediately known, but the InEdges | 77 // When a node is created, the OutEdges are immediately known, but the InEdges |
| 69 // have to be built up incrementally. After the CFG has been constructed, the | 78 // have to be built up incrementally. After the CFG has been constructed, the |
| 70 // computePredecessors() pass finalizes it by creating the InEdges list. | 79 // computePredecessors() pass finalizes it by creating the InEdges list. |
| 71 void CfgNode::computePredecessors() { | 80 void CfgNode::computePredecessors() { |
| 72 for (CfgNode *Succ : OutEdges) | 81 for (CfgNode *Succ : OutEdges) |
| 73 Succ->InEdges.push_back(this); | 82 Succ->InEdges.push_back(this); |
| 74 } | 83 } |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1440 auto *Instr = InstIntrinsicCall::create( | 1449 auto *Instr = InstIntrinsicCall::create( |
| 1441 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); | 1450 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); |
| 1442 Instr->addArg(AtomicRMWOp); | 1451 Instr->addArg(AtomicRMWOp); |
| 1443 Instr->addArg(Counter); | 1452 Instr->addArg(Counter); |
| 1444 Instr->addArg(One); | 1453 Instr->addArg(One); |
| 1445 Instr->addArg(OrderAcquireRelease); | 1454 Instr->addArg(OrderAcquireRelease); |
| 1446 Insts.push_front(Instr); | 1455 Insts.push_front(Instr); |
| 1447 } | 1456 } |
| 1448 | 1457 |
| 1449 } // end of namespace Ice | 1458 } // end of namespace Ice |
| OLD | NEW |