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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 bool LiveRange::endsBefore(const LiveRange &Other) const { | 98 bool LiveRange::endsBefore(const LiveRange &Other) const { |
99 // Neither range should be empty, but let's be graceful. | 99 // Neither range should be empty, but let's be graceful. |
100 if (Range.empty() || Other.Range.empty()) | 100 if (Range.empty() || Other.Range.empty()) |
101 return true; | 101 return true; |
102 InstNumberT MyEnd = (*Range.rbegin()).second; | 102 InstNumberT MyEnd = (*Range.rbegin()).second; |
103 InstNumberT OtherStart = (*Other.Range.begin()).first; | 103 InstNumberT OtherStart = (*Other.Range.begin()).first; |
104 return MyEnd <= OtherStart; | 104 return MyEnd <= OtherStart; |
105 } | 105 } |
106 | 106 |
107 // Returns true if there is any overlap between the two live ranges. | 107 // Returns true if there is any overlap between the two live ranges. |
108 bool LiveRange::overlaps(const LiveRange &Other) const { | 108 bool LiveRange::overlaps(const LiveRange &Other, bool UseTrimmed) const { |
109 // Do a two-finger walk through the two sorted lists of segments. | 109 // Do a two-finger walk through the two sorted lists of segments. |
110 RangeType::const_iterator I1 = Range.begin(), I2 = Other.Range.begin(); | 110 RangeType::const_iterator I1 = (UseTrimmed ? TrimmedBegin : Range.begin()), |
111 I2 = (UseTrimmed ? Other.TrimmedBegin | |
112 : Other.Range.begin()); | |
111 RangeType::const_iterator E1 = Range.end(), E2 = Other.Range.end(); | 113 RangeType::const_iterator E1 = Range.end(), E2 = Other.Range.end(); |
112 while (I1 != E1 && I2 != E2) { | 114 while (I1 != E1 && I2 != E2) { |
113 if (I1->second <= I2->first) { | 115 if (I1->second <= I2->first) { |
114 ++I1; | 116 ++I1; |
115 continue; | 117 continue; |
116 } | 118 } |
117 if (I2->second <= I1->first) { | 119 if (I2->second <= I1->first) { |
118 ++I2; | 120 ++I2; |
119 continue; | 121 continue; |
120 } | 122 } |
121 return true; | 123 return true; |
122 } | 124 } |
123 return false; | 125 return false; |
124 } | 126 } |
125 | 127 |
126 bool LiveRange::overlaps(InstNumberT OtherBegin) const { | 128 bool LiveRange::overlaps(InstNumberT OtherBegin) const { |
jvoung (off chromium)
2014/10/05 20:34:13
Would it help to have this overlaps() check use a
Jim Stichnoth
2014/10/06 13:38:01
I think you're right.
There are two instances of
| |
127 if (!IsNonpoints) | 129 if (!IsNonpoints) |
128 return false; | 130 return false; |
129 bool Result = false; | 131 bool Result = false; |
130 for (const RangeElementType &I : Range) { | 132 for (const RangeElementType &I : Range) { |
131 if (OtherBegin < I.first) { | 133 if (OtherBegin < I.first) { |
132 Result = false; | 134 Result = false; |
133 break; | 135 break; |
134 } | 136 } |
135 if (OtherBegin < I.second) { | 137 if (OtherBegin < I.second) { |
136 Result = true; | 138 Result = true; |
(...skipping 14 matching lines...) Expand all Loading... | |
151 // number. This is only used for validating the live range | 153 // number. This is only used for validating the live range |
152 // calculation. | 154 // calculation. |
153 bool LiveRange::containsValue(InstNumberT Value) const { | 155 bool LiveRange::containsValue(InstNumberT Value) const { |
154 for (const RangeElementType &I : Range) { | 156 for (const RangeElementType &I : Range) { |
155 if (I.first <= Value && Value <= I.second) | 157 if (I.first <= Value && Value <= I.second) |
156 return true; | 158 return true; |
157 } | 159 } |
158 return false; | 160 return false; |
159 } | 161 } |
160 | 162 |
163 void LiveRange::trim(InstNumberT Lower) { | |
164 while (TrimmedBegin != Range.end() && TrimmedBegin->second <= Lower) | |
jvoung (off chromium)
2014/10/05 20:34:13
I might be reading this wrong, but it looks like t
Jim Stichnoth
2014/10/06 13:38:01
Are you asking e.g. what would happen if "this" li
jvoung (off chromium)
2014/10/06 21:57:26
Okay, I see I think I was confused by the order of
| |
165 ++TrimmedBegin; | |
166 } | |
167 | |
161 IceString Variable::getName() const { | 168 IceString Variable::getName() const { |
162 if (!Name.empty()) | 169 if (!Name.empty()) |
163 return Name; | 170 return Name; |
164 char buf[30]; | 171 char buf[30]; |
165 snprintf(buf, llvm::array_lengthof(buf), "__%u", getIndex()); | 172 snprintf(buf, llvm::array_lengthof(buf), "__%u", getIndex()); |
166 return buf; | 173 return buf; |
167 } | 174 } |
168 | 175 |
169 Variable Variable::asType(Type Ty) { | 176 Variable Variable::asType(Type Ty) { |
170 // Note: This returns a Variable, even if the "this" object is a | 177 // Note: This returns a Variable, even if the "this" object is a |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 | 459 |
453 Ostream &operator<<(Ostream &Str, const RegWeight &W) { | 460 Ostream &operator<<(Ostream &Str, const RegWeight &W) { |
454 if (W.getWeight() == RegWeight::Inf) | 461 if (W.getWeight() == RegWeight::Inf) |
455 Str << "Inf"; | 462 Str << "Inf"; |
456 else | 463 else |
457 Str << W.getWeight(); | 464 Str << W.getWeight(); |
458 return Str; | 465 return Str; |
459 } | 466 } |
460 | 467 |
461 } // end of namespace Ice | 468 } // end of namespace Ice |
OLD | NEW |