Skip to content

Commit cc8edbc

Browse files
authored
[SandboxVec][Interval][NFC] Rename From/To to Top/Bottom (#112034)
The API was already using top()/bottom() but internally we were still using From/To. This patch fixes this. Top/Bottom seems a better choice because implies program order, whereas From/To does not.
1 parent 58d9703 commit cc8edbc

File tree

1 file changed

+36
-36
lines changed
  • llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer

1 file changed

+36
-36
lines changed

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,56 +74,56 @@ template <typename T, typename IntervalType> class IntervalIterator {
7474
};
7575

7676
template <typename T> class Interval {
77-
T *From;
78-
T *To;
77+
T *Top;
78+
T *Bottom;
7979

8080
public:
81-
Interval() : From(nullptr), To(nullptr) {}
82-
Interval(T *From, T *To) : From(From), To(To) {
83-
assert((From == To || From->comesBefore(To)) &&
84-
"From should come before From!");
81+
Interval() : Top(nullptr), Bottom(nullptr) {}
82+
Interval(T *Top, T *Bottom) : Top(Top), Bottom(Bottom) {
83+
assert((Top == Bottom || Top->comesBefore(Bottom)) &&
84+
"Top should come before Bottom!");
8585
}
8686
Interval(ArrayRef<T *> Elems) {
8787
assert(!Elems.empty() && "Expected non-empty Elems!");
88-
From = Elems[0];
89-
To = Elems[0];
88+
Top = Elems[0];
89+
Bottom = Elems[0];
9090
for (auto *I : drop_begin(Elems)) {
91-
if (I->comesBefore(From))
92-
From = I;
93-
else if (To->comesBefore(I))
94-
To = I;
91+
if (I->comesBefore(Top))
92+
Top = I;
93+
else if (Bottom->comesBefore(I))
94+
Bottom = I;
9595
}
9696
}
9797
bool empty() const {
98-
assert(((From == nullptr && To == nullptr) ||
99-
(From != nullptr && To != nullptr)) &&
98+
assert(((Top == nullptr && Bottom == nullptr) ||
99+
(Top != nullptr && Bottom != nullptr)) &&
100100
"Either none or both should be null");
101-
return From == nullptr;
101+
return Top == nullptr;
102102
}
103103
bool contains(T *I) const {
104104
if (empty())
105105
return false;
106-
return (From == I || From->comesBefore(I)) &&
107-
(I == To || I->comesBefore(To));
106+
return (Top == I || Top->comesBefore(I)) &&
107+
(I == Bottom || I->comesBefore(Bottom));
108108
}
109-
T *top() const { return From; }
110-
T *bottom() const { return To; }
109+
T *top() const { return Top; }
110+
T *bottom() const { return Bottom; }
111111

112112
using iterator = IntervalIterator<T, Interval>;
113-
iterator begin() { return iterator(From, *this); }
113+
iterator begin() { return iterator(Top, *this); }
114114
iterator end() {
115-
return iterator(To != nullptr ? To->getNextNode() : nullptr, *this);
115+
return iterator(Bottom != nullptr ? Bottom->getNextNode() : nullptr, *this);
116116
}
117117
iterator begin() const {
118-
return iterator(From, const_cast<Interval &>(*this));
118+
return iterator(Top, const_cast<Interval &>(*this));
119119
}
120120
iterator end() const {
121-
return iterator(To != nullptr ? To->getNextNode() : nullptr,
121+
return iterator(Bottom != nullptr ? Bottom->getNextNode() : nullptr,
122122
const_cast<Interval &>(*this));
123123
}
124124
/// Equality.
125125
bool operator==(const Interval &Other) const {
126-
return From == Other.From && To == Other.To;
126+
return Top == Other.Top && Bottom == Other.Bottom;
127127
}
128128
/// Inequality.
129129
bool operator!=(const Interval &Other) const { return !(*this == Other); }
@@ -139,7 +139,7 @@ template <typename T> class Interval {
139139
return true;
140140
if (empty())
141141
return true;
142-
return Other.To->comesBefore(From) || To->comesBefore(Other.From);
142+
return Other.Bottom->comesBefore(Top) || Bottom->comesBefore(Other.Top);
143143
}
144144
/// \Returns the intersection between this and \p Other.
145145
// Example:
@@ -154,14 +154,14 @@ template <typename T> class Interval {
154154
// 1. No overlap
155155
// A---B this
156156
// C--D Other
157-
if (To->comesBefore(Other.From) || Other.To->comesBefore(From))
157+
if (Bottom->comesBefore(Other.Top) || Other.Bottom->comesBefore(Top))
158158
return Interval();
159159
// 2. Overlap.
160160
// A---B this
161161
// C--D Other
162-
auto NewFromI = From->comesBefore(Other.From) ? Other.From : From;
163-
auto NewToI = To->comesBefore(Other.To) ? To : Other.To;
164-
return Interval(NewFromI, NewToI);
162+
auto NewTopI = Top->comesBefore(Other.Top) ? Other.Top : Top;
163+
auto NewBottomI = Bottom->comesBefore(Other.Bottom) ? Bottom : Other.Bottom;
164+
return Interval(NewTopI, NewBottomI);
165165
}
166166
/// Difference operation. This returns up to two intervals.
167167
// Example:
@@ -178,11 +178,11 @@ template <typename T> class Interval {
178178
Interval Intersection = intersection(Other);
179179
SmallVector<Interval, 2> Result;
180180
// Part 1, skip if empty.
181-
if (From != Intersection.From)
182-
Result.emplace_back(From, Intersection.From->getPrevNode());
181+
if (Top != Intersection.Top)
182+
Result.emplace_back(Top, Intersection.Top->getPrevNode());
183183
// Part 2, skip if empty.
184-
if (Intersection.To != To)
185-
Result.emplace_back(Intersection.To->getNextNode(), To);
184+
if (Intersection.Bottom != Bottom)
185+
Result.emplace_back(Intersection.Bottom->getNextNode(), Bottom);
186186
return Result;
187187
}
188188
/// \Returns the interval difference `this - Other`. This will crash in Debug
@@ -202,9 +202,9 @@ template <typename T> class Interval {
202202
return Other;
203203
if (Other.empty())
204204
return *this;
205-
auto *NewFrom = From->comesBefore(Other.From) ? From : Other.From;
206-
auto *NewTo = To->comesBefore(Other.To) ? Other.To : To;
207-
return {NewFrom, NewTo};
205+
auto *NewTop = Top->comesBefore(Other.Top) ? Top : Other.Top;
206+
auto *NewBottom = Bottom->comesBefore(Other.Bottom) ? Other.Bottom : Bottom;
207+
return {NewTop, NewBottom};
208208
}
209209

210210
#ifndef NDEBUG

0 commit comments

Comments
 (0)