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

Side by Side Diff: src/IceOperand.cpp

Issue 802003003: Subzero: Clean up live range construction. (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/IceInst.h ('k') | src/IceTimerTree.def » ('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 15 matching lines...) Expand all
26 26
27 bool operator<(const RegWeight &A, const RegWeight &B) { 27 bool operator<(const RegWeight &A, const RegWeight &B) {
28 return A.getWeight() < B.getWeight(); 28 return A.getWeight() < B.getWeight();
29 } 29 }
30 bool operator<=(const RegWeight &A, const RegWeight &B) { return !(B < A); } 30 bool operator<=(const RegWeight &A, const RegWeight &B) { return !(B < A); }
31 bool operator==(const RegWeight &A, const RegWeight &B) { 31 bool operator==(const RegWeight &A, const RegWeight &B) {
32 return !(B < A) && !(A < B); 32 return !(B < A) && !(A < B);
33 } 33 }
34 34
35 void LiveRange::addSegment(InstNumberT Start, InstNumberT End) { 35 void LiveRange::addSegment(InstNumberT Start, InstNumberT End) {
36 if (Range.empty()) { 36 if (!Range.empty()) {
37 Range.push_back(RangeElementType(Start, End)); 37 // Check for merge opportunity.
38 return; 38 InstNumberT CurrentEnd = Range.back().second;
39 } 39 assert(Start >= CurrentEnd);
40 // Special case for faking in-arg liveness. 40 if (Start == CurrentEnd) {
41 if (End < Range.front().first) { 41 Range.back().second = End;
42 assert(Start < 0); 42 return;
43 // This is inefficient with Range as a std::vector, but there are 43 }
44 // generally very few arguments compared to the total number of
45 // variables with non-empty live ranges.
46 Range.insert(Range.begin(), RangeElementType(Start, End));
47 return;
48 }
49 InstNumberT CurrentEnd = Range.back().second;
50 assert(Start >= CurrentEnd);
51 // Check for merge opportunity.
52 if (Start == CurrentEnd) {
53 Range.back().second = End;
54 return;
55 } 44 }
56 Range.push_back(RangeElementType(Start, End)); 45 Range.push_back(RangeElementType(Start, End));
57 } 46 }
58 47
59 // Returns true if this live range ends before Other's live range 48 // Returns true if this live range ends before Other's live range
60 // starts. This means that the highest instruction number in this 49 // starts. This means that the highest instruction number in this
61 // live range is less than or equal to the lowest instruction number 50 // live range is less than or equal to the lowest instruction number
62 // of the Other live range. 51 // of the Other live range.
63 bool LiveRange::endsBefore(const LiveRange &Other) const { 52 bool LiveRange::endsBefore(const LiveRange &Other) const {
64 // Neither range should be empty, but let's be graceful. 53 // Neither range should be empty, but let's be graceful.
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if (!ALLOW_DUMP) 480 if (!ALLOW_DUMP)
492 return Str; 481 return Str;
493 if (W.getWeight() == RegWeight::Inf) 482 if (W.getWeight() == RegWeight::Inf)
494 Str << "Inf"; 483 Str << "Inf";
495 else 484 else
496 Str << W.getWeight(); 485 Str << W.getWeight();
497 return Str; 486 return Str;
498 } 487 }
499 488
500 } // end of namespace Ice 489 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInst.h ('k') | src/IceTimerTree.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698