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

Side by Side Diff: src/IceOperand.cpp

Issue 610813002: Subzero: Rewrite the pass timing infrastructure. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Make the optimized overlaps() implementation actually correct Created 6 years, 2 months 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/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (I2->second <= I1->first) { 115 if (I2->second <= I1->first) {
116 ++I2; 116 ++I2;
117 continue; 117 continue;
118 } 118 }
119 return true; 119 return true;
120 } 120 }
121 return false; 121 return false;
122 } 122 }
123 123
124 bool LiveRange::overlaps(InstNumberT OtherBegin) const { 124 bool LiveRange::overlaps(InstNumberT OtherBegin) const {
125 bool Result = false;
126 for (RangeType::const_iterator I = Range.begin(), E = Range.end(); I != E;
127 ++I) {
128 if (OtherBegin < I->first) {
129 Result = false;
130 break;
131 }
132 if (OtherBegin < I->second) {
133 Result = true;
134 break;
135 }
136 }
137 #if 0
138 // An equivalent but less inefficient implementation:
Jim Stichnoth 2014/09/30 22:46:00 Actual comparisons indicated this was a lie. The
125 LiveRange Temp; 139 LiveRange Temp;
126 Temp.addSegment(OtherBegin, OtherBegin + 1); 140 Temp.addSegment(OtherBegin, OtherBegin + 1);
127 return overlaps(Temp); 141 bool Validation = overlaps(Temp);
142 assert(Result == Validation);
143 #endif
144 return Result;
128 } 145 }
129 146
130 // Returns true if the live range contains the given instruction 147 // Returns true if the live range contains the given instruction
131 // number. This is only used for validating the live range 148 // number. This is only used for validating the live range
132 // calculation. 149 // calculation.
133 bool LiveRange::containsValue(InstNumberT Value) const { 150 bool LiveRange::containsValue(InstNumberT Value) const {
134 for (RangeType::const_iterator I = Range.begin(), E = Range.end(); I != E; 151 for (RangeType::const_iterator I = Range.begin(), E = Range.end(); I != E;
135 ++I) { 152 ++I) {
136 if (I->first <= Value && Value <= I->second) 153 if (I->first <= Value && Value <= I->second)
137 return true; 154 return true;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 case MDS_MultiDefMultiBlock: 269 case MDS_MultiDefMultiBlock:
253 case MDS_MultiDefSingleBlock: 270 case MDS_MultiDefSingleBlock:
254 return NULL; 271 return NULL;
255 case MDS_SingleDef: 272 case MDS_SingleDef:
256 assert(!Definitions.empty()); 273 assert(!Definitions.empty());
257 return Definitions[0]; 274 return Definitions[0];
258 } 275 }
259 } 276 }
260 277
261 void VariablesMetadata::init() { 278 void VariablesMetadata::init() {
279 static TimerIdT IDvmetadata = GlobalContext::getTimerID("vmetadata");
280 TimerMarker T(IDvmetadata, Func->getContext());
262 Metadata.clear(); 281 Metadata.clear();
263 Metadata.resize(Func->getNumVariables()); 282 Metadata.resize(Func->getNumVariables());
264 283
265 // Mark implicit args as being used in the entry node. 284 // Mark implicit args as being used in the entry node.
266 const VarList &ImplicitArgList = Func->getImplicitArgs(); 285 const VarList &ImplicitArgList = Func->getImplicitArgs();
267 for (VarList::const_iterator I = ImplicitArgList.begin(), 286 for (VarList::const_iterator I = ImplicitArgList.begin(),
268 E = ImplicitArgList.end(); 287 E = ImplicitArgList.end();
269 I != E; ++I) { 288 I != E; ++I) {
270 const Variable *Var = *I; 289 const Variable *Var = *I;
271 const Inst *NoInst = NULL; 290 const Inst *NoInst = NULL;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 455
437 Ostream &operator<<(Ostream &Str, const RegWeight &W) { 456 Ostream &operator<<(Ostream &Str, const RegWeight &W) {
438 if (W.getWeight() == RegWeight::Inf) 457 if (W.getWeight() == RegWeight::Inf)
439 Str << "Inf"; 458 Str << "Inf";
440 else 459 else
441 Str << W.getWeight(); 460 Str << W.getWeight();
442 return Str; 461 return Str;
443 } 462 }
444 463
445 } // end of namespace Ice 464 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInst.h ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698