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

Side by Side Diff: src/IceOperand.h

Issue 631483002: Subzero: Optimize a common live range overlap calculation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: 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 | « no previous file | src/IceOperand.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.h - High-level operands -----------*- C++ -*-===// 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- C++ -*-===//
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 declares the Operand class and its target-independent 10 // This file declares the Operand class and its target-independent
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 bool operator==(const RegWeight &A, const RegWeight &B); 291 bool operator==(const RegWeight &A, const RegWeight &B);
292 292
293 // LiveRange is a set of instruction number intervals representing 293 // LiveRange is a set of instruction number intervals representing
294 // a variable's live range. Generally there is one interval per basic 294 // a variable's live range. Generally there is one interval per basic
295 // block where the variable is live, but adjacent intervals get 295 // block where the variable is live, but adjacent intervals get
296 // coalesced into a single interval. LiveRange also includes a 296 // coalesced into a single interval. LiveRange also includes a
297 // weight, in case e.g. we want a live range to have higher weight 297 // weight, in case e.g. we want a live range to have higher weight
298 // inside a loop. 298 // inside a loop.
299 class LiveRange { 299 class LiveRange {
300 public: 300 public:
301 LiveRange() : Weight(0) {} 301 LiveRange() : Weight(0), IsNonpoints(false) {}
302 302
303 void reset() { 303 void reset() {
304 Range.clear(); 304 Range.clear();
305 Weight.setWeight(0); 305 Weight.setWeight(0);
jvoung (off chromium) 2014/10/04 05:06:34 Seems like reset() should reset IsNonpoints ?
Jim Stichnoth 2014/10/04 12:44:08 Done.
306 } 306 }
307 void addSegment(InstNumberT Start, InstNumberT End); 307 void addSegment(InstNumberT Start, InstNumberT End);
308 308
309 bool endsBefore(const LiveRange &Other) const; 309 bool endsBefore(const LiveRange &Other) const;
310 bool overlaps(const LiveRange &Other) const; 310 bool overlaps(const LiveRange &Other) const;
311 bool overlaps(InstNumberT OtherBegin) const; 311 bool overlaps(InstNumberT OtherBegin) const;
312 bool containsValue(InstNumberT Value) const; 312 bool containsValue(InstNumberT Value) const;
313 bool isEmpty() const { return Range.empty(); } 313 bool isEmpty() const { return Range.empty(); }
314 InstNumberT getStart() const { 314 InstNumberT getStart() const {
315 return Range.empty() ? -1 : Range.begin()->first; 315 return Range.empty() ? -1 : Range.begin()->first;
(...skipping 12 matching lines...) Expand all
328 328
329 private: 329 private:
330 typedef std::pair<InstNumberT, InstNumberT> RangeElementType; 330 typedef std::pair<InstNumberT, InstNumberT> RangeElementType;
331 #ifdef USE_SET 331 #ifdef USE_SET
332 typedef std::set<RangeElementType> RangeType; 332 typedef std::set<RangeElementType> RangeType;
333 #else 333 #else
334 typedef std::list<RangeElementType> RangeType; 334 typedef std::list<RangeElementType> RangeType;
335 #endif 335 #endif
336 RangeType Range; 336 RangeType Range;
337 RegWeight Weight; 337 RegWeight Weight;
338 // IsNonpoints keeps track of whether the live range contains at
339 // least one interval where Start!=End. If it is empty or has the
340 // form [x,x),[y,y),...,[z,z), then overlaps(InstNumberT) is
341 // trivially false.
342 bool IsNonpoints;
338 }; 343 };
339 344
340 Ostream &operator<<(Ostream &Str, const LiveRange &L); 345 Ostream &operator<<(Ostream &Str, const LiveRange &L);
341 346
342 // Variable represents an operand that is register-allocated or 347 // Variable represents an operand that is register-allocated or
343 // stack-allocated. If it is register-allocated, it will ultimately 348 // stack-allocated. If it is register-allocated, it will ultimately
344 // have a non-negative RegNum field. 349 // have a non-negative RegNum field.
345 class Variable : public Operand { 350 class Variable : public Operand {
346 Variable(const Variable &) = delete; 351 Variable(const Variable &) = delete;
347 Variable &operator=(const Variable &) = delete; 352 Variable &operator=(const Variable &) = delete;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 const Cfg *Func; 564 const Cfg *Func;
560 std::vector<VariableTracking> Metadata; 565 std::vector<VariableTracking> Metadata;
561 const static InstDefList NoDefinitions; 566 const static InstDefList NoDefinitions;
562 VariablesMetadata(const VariablesMetadata &) = delete; 567 VariablesMetadata(const VariablesMetadata &) = delete;
563 VariablesMetadata &operator=(const VariablesMetadata &) = delete; 568 VariablesMetadata &operator=(const VariablesMetadata &) = delete;
564 }; 569 };
565 570
566 } // end of namespace Ice 571 } // end of namespace Ice
567 572
568 #endif // SUBZERO_SRC_ICEOPERAND_H 573 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« no previous file with comments | « no previous file | src/IceOperand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698