OLD | NEW |
1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===// | 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan 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 LinearScan class, which performs the | 10 // This file implements the LinearScan class, which performs the |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (Var->hasReg()) { | 102 if (Var->hasReg()) { |
103 Var->setRegNumTmp(Var->getRegNum()); | 103 Var->setRegNumTmp(Var->getRegNum()); |
104 Var->setLiveRangeInfiniteWeight(); | 104 Var->setLiveRangeInfiniteWeight(); |
105 UnhandledPrecolored.push_back(Var); | 105 UnhandledPrecolored.push_back(Var); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 // Build the (ordered) list of FakeKill instruction numbers. | 109 // Build the (ordered) list of FakeKill instruction numbers. |
110 Kills.clear(); | 110 Kills.clear(); |
111 for (CfgNode *Node : Func->getNodes()) { | 111 for (CfgNode *Node : Func->getNodes()) { |
112 for (auto I = Node->getInsts().begin(), E = Node->getInsts().end(); I != E; | 112 for (Inst &I : Node->getInsts()) { |
113 ++I) { | 113 if (auto Kill = llvm::dyn_cast<InstFakeKill>(&I)) { |
114 if (auto Kill = llvm::dyn_cast<InstFakeKill>(I)) { | |
115 if (!Kill->isDeleted() && !Kill->getLinked()->isDeleted()) | 114 if (!Kill->isDeleted() && !Kill->getLinked()->isDeleted()) |
116 Kills.push_back(I->getNumber()); | 115 Kills.push_back(I.getNumber()); |
117 } | 116 } |
118 } | 117 } |
119 } | 118 } |
120 } | 119 } |
121 | 120 |
122 // Prepare for very simple register allocation of only infinite-weight | 121 // Prepare for very simple register allocation of only infinite-weight |
123 // Variables while respecting pre-colored Variables. Some properties | 122 // Variables while respecting pre-colored Variables. Some properties |
124 // we take advantage of: | 123 // we take advantage of: |
125 // | 124 // |
126 // * Live ranges of interest consist of a single segment. | 125 // * Live ranges of interest consist of a single segment. |
(...skipping 26 matching lines...) Expand all Loading... |
153 FindOverlap = false; | 152 FindOverlap = false; |
154 SizeT NumVars = 0; | 153 SizeT NumVars = 0; |
155 const VarList &Vars = Func->getVariables(); | 154 const VarList &Vars = Func->getVariables(); |
156 | 155 |
157 // Iterate across all instructions and record the begin and end of | 156 // Iterate across all instructions and record the begin and end of |
158 // the live range for each variable that is pre-colored or infinite | 157 // the live range for each variable that is pre-colored or infinite |
159 // weight. | 158 // weight. |
160 std::vector<InstNumberT> LRBegin(Vars.size(), Inst::NumberSentinel); | 159 std::vector<InstNumberT> LRBegin(Vars.size(), Inst::NumberSentinel); |
161 std::vector<InstNumberT> LREnd(Vars.size(), Inst::NumberSentinel); | 160 std::vector<InstNumberT> LREnd(Vars.size(), Inst::NumberSentinel); |
162 for (CfgNode *Node : Func->getNodes()) { | 161 for (CfgNode *Node : Func->getNodes()) { |
163 for (auto Inst = Node->getInsts().begin(), E = Node->getInsts().end(); | 162 for (Inst &Inst : Node->getInsts()) { |
164 Inst != E; ++Inst) { | 163 if (Inst.isDeleted()) |
165 if (Inst->isDeleted()) | |
166 continue; | 164 continue; |
167 if (const Variable *Var = Inst->getDest()) { | 165 if (const Variable *Var = Inst.getDest()) { |
168 if (Var->hasReg() || Var->getWeight() == RegWeight::Inf) { | 166 if (Var->hasReg() || Var->getWeight() == RegWeight::Inf) { |
169 if (LRBegin[Var->getIndex()] == Inst::NumberSentinel) { | 167 if (LRBegin[Var->getIndex()] == Inst::NumberSentinel) { |
170 LRBegin[Var->getIndex()] = Inst->getNumber(); | 168 LRBegin[Var->getIndex()] = Inst.getNumber(); |
171 ++NumVars; | 169 ++NumVars; |
172 } | 170 } |
173 } | 171 } |
174 } | 172 } |
175 for (SizeT I = 0; I < Inst->getSrcSize(); ++I) { | 173 for (SizeT I = 0; I < Inst.getSrcSize(); ++I) { |
176 Operand *Src = Inst->getSrc(I); | 174 Operand *Src = Inst.getSrc(I); |
177 SizeT NumVars = Src->getNumVars(); | 175 SizeT NumVars = Src->getNumVars(); |
178 for (SizeT J = 0; J < NumVars; ++J) { | 176 for (SizeT J = 0; J < NumVars; ++J) { |
179 const Variable *Var = Src->getVar(J); | 177 const Variable *Var = Src->getVar(J); |
180 if (Var->hasReg() || Var->getWeight() == RegWeight::Inf) | 178 if (Var->hasReg() || Var->getWeight() == RegWeight::Inf) |
181 LREnd[Var->getIndex()] = Inst->getNumber(); | 179 LREnd[Var->getIndex()] = Inst.getNumber(); |
182 } | 180 } |
183 } | 181 } |
184 } | 182 } |
185 } | 183 } |
186 | 184 |
187 Unhandled.reserve(NumVars); | 185 Unhandled.reserve(NumVars); |
188 UnhandledPrecolored.reserve(NumVars); | 186 UnhandledPrecolored.reserve(NumVars); |
189 for (SizeT i = 0; i < Vars.size(); ++i) { | 187 for (SizeT i = 0; i < Vars.size(); ++i) { |
190 Variable *Var = Vars[i]; | 188 Variable *Var = Vars[i]; |
191 if (LRBegin[i] != Inst::NumberSentinel) { | 189 if (LRBegin[i] != Inst::NumberSentinel) { |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 Str << "\n"; | 741 Str << "\n"; |
744 } | 742 } |
745 Str << "++++++ Inactive:\n"; | 743 Str << "++++++ Inactive:\n"; |
746 for (const Variable *Item : Inactive) { | 744 for (const Variable *Item : Inactive) { |
747 dumpLiveRange(Item, Func); | 745 dumpLiveRange(Item, Func); |
748 Str << "\n"; | 746 Str << "\n"; |
749 } | 747 } |
750 } | 748 } |
751 | 749 |
752 } // end of namespace Ice | 750 } // end of namespace Ice |
OLD | NEW |