| OLD | NEW |
| 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 Loading... |
| 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 #ifdef USE_SET | |
| 37 RangeElementType Element(Start, End); | |
| 38 RangeType::iterator Next = Range.lower_bound(Element); | |
| 39 assert(Next == Range.upper_bound(Element)); // Element not already present | |
| 40 | |
| 41 // Beginning of code that merges contiguous segments. TODO: change | |
| 42 // "if(true)" to "if(false)" to see if this extra optimization code | |
| 43 // gives any performance gain, or is just destabilizing. | |
| 44 if (true) { | |
| 45 RangeType::iterator FirstDelete = Next; | |
| 46 RangeType::iterator Prev = Next; | |
| 47 bool hasPrev = (Next != Range.begin()); | |
| 48 bool hasNext = (Next != Range.end()); | |
| 49 if (hasPrev) | |
| 50 --Prev; | |
| 51 // See if Element and Next should be joined. | |
| 52 if (hasNext && End == Next->first) { | |
| 53 Element.second = Next->second; | |
| 54 ++Next; | |
| 55 } | |
| 56 // See if Prev and Element should be joined. | |
| 57 if (hasPrev && Prev->second == Start) { | |
| 58 Element.first = Prev->first; | |
| 59 FirstDelete = Prev; | |
| 60 } | |
| 61 Range.erase(FirstDelete, Next); | |
| 62 } | |
| 63 // End of code that merges contiguous segments. | |
| 64 | |
| 65 Range.insert(Next, Element); | |
| 66 #else | |
| 67 if (Range.empty()) { | 36 if (Range.empty()) { |
| 68 Range.push_back(RangeElementType(Start, End)); | 37 Range.push_back(RangeElementType(Start, End)); |
| 69 return; | 38 return; |
| 70 } | 39 } |
| 71 // Special case for faking in-arg liveness. | 40 // Special case for faking in-arg liveness. |
| 72 if (End < Range.front().first) { | 41 if (End < Range.front().first) { |
| 73 assert(Start < 0); | 42 assert(Start < 0); |
| 74 Range.push_front(RangeElementType(Start, End)); | 43 // This is inefficient with Range as a std::vector, but there are |
| 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)); |
| 75 return; | 47 return; |
| 76 } | 48 } |
| 77 InstNumberT CurrentEnd = Range.back().second; | 49 InstNumberT CurrentEnd = Range.back().second; |
| 78 assert(Start >= CurrentEnd); | 50 assert(Start >= CurrentEnd); |
| 79 // Check for merge opportunity. | 51 // Check for merge opportunity. |
| 80 if (Start == CurrentEnd) { | 52 if (Start == CurrentEnd) { |
| 81 Range.back().second = End; | 53 Range.back().second = End; |
| 82 return; | 54 return; |
| 83 } | 55 } |
| 84 Range.push_back(RangeElementType(Start, End)); | 56 Range.push_back(RangeElementType(Start, End)); |
| 85 #endif | |
| 86 } | 57 } |
| 87 | 58 |
| 88 // Returns true if this live range ends before Other's live range | 59 // Returns true if this live range ends before Other's live range |
| 89 // starts. This means that the highest instruction number in this | 60 // starts. This means that the highest instruction number in this |
| 90 // live range is less than or equal to the lowest instruction number | 61 // live range is less than or equal to the lowest instruction number |
| 91 // of the Other live range. | 62 // of the Other live range. |
| 92 bool LiveRange::endsBefore(const LiveRange &Other) const { | 63 bool LiveRange::endsBefore(const LiveRange &Other) const { |
| 93 // Neither range should be empty, but let's be graceful. | 64 // Neither range should be empty, but let's be graceful. |
| 94 if (Range.empty() || Other.Range.empty()) | 65 if (Range.empty() || Other.Range.empty()) |
| 95 return true; | 66 return true; |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 if (!ALLOW_DUMP) | 487 if (!ALLOW_DUMP) |
| 517 return Str; | 488 return Str; |
| 518 if (W.getWeight() == RegWeight::Inf) | 489 if (W.getWeight() == RegWeight::Inf) |
| 519 Str << "Inf"; | 490 Str << "Inf"; |
| 520 else | 491 else |
| 521 Str << W.getWeight(); | 492 Str << W.getWeight(); |
| 522 return Str; | 493 return Str; |
| 523 } | 494 } |
| 524 | 495 |
| 525 } // end of namespace Ice | 496 } // end of namespace Ice |
| OLD | NEW |