Commit a1528ec0 authored by dcarney's avatar dcarney Committed by Commit bot

[turbofan] make LifetimePostion comparable

BUG=

Review URL: https://codereview.chromium.org/1087133004

Cr-Commit-Position: refs/heads/master@{#28030}
parent 655b0463
......@@ -604,10 +604,10 @@ void GraphC1Visualizer::PrintSchedule(const char* phase,
int last_index = instruction_block->last_instruction_index();
PrintIntProperty(
"first_lir_id",
LifetimePosition::GapFromInstructionIndex(first_index).Value());
LifetimePosition::GapFromInstructionIndex(first_index).value());
PrintIntProperty("last_lir_id",
LifetimePosition::InstructionFromInstructionIndex(
last_index).Value());
last_index).value());
}
{
......@@ -758,14 +758,14 @@ void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type) {
os_ << " " << parent_index << " " << hint_index;
for (auto interval = range->first_interval(); interval != nullptr;
interval = interval->next()) {
os_ << " [" << interval->start().Value() << ", "
<< interval->end().Value() << "[";
os_ << " [" << interval->start().value() << ", "
<< interval->end().value() << "[";
}
UsePosition* current_pos = range->first_pos();
while (current_pos != NULL) {
if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) {
os_ << " " << current_pos->pos().Value() << " M";
os_ << " " << current_pos->pos().value() << " M";
}
current_pos = current_pos->next();
}
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ class LifetimePosition final {
}
// Returns a numeric representation of this lifetime position.
int Value() const { return value_; }
int value() const { return value_; }
// Returns the index of the instruction to which this lifetime position
// corresponds.
......@@ -78,26 +78,26 @@ class LifetimePosition final {
// Returns the lifetime position for the current END.
LifetimePosition End() const {
DCHECK(IsValid());
return LifetimePosition(Start().Value() + kHalfStep / 2);
return LifetimePosition(Start().value_ + kHalfStep / 2);
}
// Returns the lifetime position for the beginning of the next START.
LifetimePosition NextStart() const {
DCHECK(IsValid());
return LifetimePosition(Start().Value() + kHalfStep);
return LifetimePosition(Start().value_ + kHalfStep);
}
// Returns the lifetime position for the beginning of the next gap START.
LifetimePosition NextFullStart() const {
DCHECK(IsValid());
return LifetimePosition(FullStart().Value() + kStep);
return LifetimePosition(FullStart().value_ + kStep);
}
// Returns the lifetime position for the beginning of the previous START.
LifetimePosition PrevStart() const {
DCHECK(IsValid());
DCHECK(value_ >= kHalfStep);
return LifetimePosition(Start().Value() - kHalfStep);
return LifetimePosition(Start().value_ - kHalfStep);
}
// Constructs the lifetime position which does not correspond to any
......@@ -108,6 +108,30 @@ class LifetimePosition final {
// instruction.
bool IsValid() const { return value_ != -1; }
bool operator<(const LifetimePosition& that) const {
return this->value_ < that.value_;
}
bool operator<=(const LifetimePosition& that) const {
return this->value_ <= that.value_;
}
bool operator==(const LifetimePosition& that) const {
return this->value_ == that.value_;
}
bool operator!=(const LifetimePosition& that) const {
return this->value_ != that.value_;
}
bool operator>(const LifetimePosition& that) const {
return this->value_ > that.value_;
}
bool operator>=(const LifetimePosition& that) const {
return this->value_ >= that.value_;
}
static inline LifetimePosition Invalid() { return LifetimePosition(); }
static inline LifetimePosition MaxPosition() {
......@@ -134,7 +158,7 @@ class UseInterval final : public ZoneObject {
public:
UseInterval(LifetimePosition start, LifetimePosition end)
: start_(start), end_(end), next_(nullptr) {
DCHECK(start.Value() < end.Value());
DCHECK(start < end);
}
LifetimePosition start() const { return start_; }
......@@ -151,13 +175,13 @@ class UseInterval final : public ZoneObject {
// If this interval intersects with other return smallest position
// that belongs to both of them.
LifetimePosition Intersect(const UseInterval* other) const {
if (other->start().Value() < start_.Value()) return other->Intersect(this);
if (other->start().Value() < end_.Value()) return other->start();
if (other->start() < start_) return other->Intersect(this);
if (other->start() < end_) return other->start();
return LifetimePosition::Invalid();
}
bool Contains(LifetimePosition point) const {
return start_.Value() <= point.Value() && point.Value() < end_.Value();
return start_ <= point && point < end_;
}
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment