mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Rename some methods, use 'begin' instead of 'start', add new LiveInterval
iterator/begin/end members. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17930 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4b92ed6d58
commit
23b71c1e1e
@ -76,6 +76,11 @@ namespace llvm {
|
|||||||
: reg(Reg), weight(Weight), NumValues(0) {
|
: reg(Reg), weight(Weight), NumValues(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef Ranges::iterator iterator;
|
||||||
|
iterator begin() { return ranges.begin(); }
|
||||||
|
iterator end() { return ranges.end(); }
|
||||||
|
|
||||||
void swap(LiveInterval& other) {
|
void swap(LiveInterval& other) {
|
||||||
std::swap(reg, other.reg);
|
std::swap(reg, other.reg);
|
||||||
std::swap(weight, other.weight);
|
std::swap(weight, other.weight);
|
||||||
@ -91,21 +96,21 @@ namespace llvm {
|
|||||||
|
|
||||||
bool empty() const { return ranges.empty(); }
|
bool empty() const { return ranges.empty(); }
|
||||||
|
|
||||||
/// start - Return the lowest numbered slot covered by interval.
|
/// beginNumber - Return the lowest numbered slot covered by interval.
|
||||||
unsigned start() const {
|
unsigned beginNumber() const {
|
||||||
assert(!empty() && "empty interval for register");
|
assert(!empty() && "empty interval for register");
|
||||||
return ranges.front().start;
|
return ranges.front().start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// end - return the maximum point of the interval of the whole,
|
/// endNumber - return the maximum point of the interval of the whole,
|
||||||
/// exclusive.
|
/// exclusive.
|
||||||
unsigned end() const {
|
unsigned endNumber() const {
|
||||||
assert(!empty() && "empty interval for register");
|
assert(!empty() && "empty interval for register");
|
||||||
return ranges.back().end;
|
return ranges.back().end;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool expiredAt(unsigned index) const {
|
bool expiredAt(unsigned index) const {
|
||||||
return end() <= (index + 1);
|
return endNumber() <= (index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool liveAt(unsigned index) const;
|
bool liveAt(unsigned index) const;
|
||||||
@ -142,7 +147,7 @@ namespace llvm {
|
|||||||
void removeRange(unsigned Start, unsigned End);
|
void removeRange(unsigned Start, unsigned End);
|
||||||
|
|
||||||
bool operator<(const LiveInterval& other) const {
|
bool operator<(const LiveInterval& other) const {
|
||||||
return start() < other.start();
|
return beginNumber() < other.beginNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
@ -76,6 +76,11 @@ namespace llvm {
|
|||||||
: reg(Reg), weight(Weight), NumValues(0) {
|
: reg(Reg), weight(Weight), NumValues(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef Ranges::iterator iterator;
|
||||||
|
iterator begin() { return ranges.begin(); }
|
||||||
|
iterator end() { return ranges.end(); }
|
||||||
|
|
||||||
void swap(LiveInterval& other) {
|
void swap(LiveInterval& other) {
|
||||||
std::swap(reg, other.reg);
|
std::swap(reg, other.reg);
|
||||||
std::swap(weight, other.weight);
|
std::swap(weight, other.weight);
|
||||||
@ -91,21 +96,21 @@ namespace llvm {
|
|||||||
|
|
||||||
bool empty() const { return ranges.empty(); }
|
bool empty() const { return ranges.empty(); }
|
||||||
|
|
||||||
/// start - Return the lowest numbered slot covered by interval.
|
/// beginNumber - Return the lowest numbered slot covered by interval.
|
||||||
unsigned start() const {
|
unsigned beginNumber() const {
|
||||||
assert(!empty() && "empty interval for register");
|
assert(!empty() && "empty interval for register");
|
||||||
return ranges.front().start;
|
return ranges.front().start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// end - return the maximum point of the interval of the whole,
|
/// endNumber - return the maximum point of the interval of the whole,
|
||||||
/// exclusive.
|
/// exclusive.
|
||||||
unsigned end() const {
|
unsigned endNumber() const {
|
||||||
assert(!empty() && "empty interval for register");
|
assert(!empty() && "empty interval for register");
|
||||||
return ranges.back().end;
|
return ranges.back().end;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool expiredAt(unsigned index) const {
|
bool expiredAt(unsigned index) const {
|
||||||
return end() <= (index + 1);
|
return endNumber() <= (index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool liveAt(unsigned index) const;
|
bool liveAt(unsigned index) const;
|
||||||
@ -142,7 +147,7 @@ namespace llvm {
|
|||||||
void removeRange(unsigned Start, unsigned End);
|
void removeRange(unsigned Start, unsigned End);
|
||||||
|
|
||||||
bool operator<(const LiveInterval& other) const {
|
bool operator<(const LiveInterval& other) const {
|
||||||
return start() < other.start();
|
return beginNumber() < other.beginNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
@ -270,7 +270,7 @@ void RA::processActiveIntervals(IntervalPtrs::value_type cur)
|
|||||||
unsigned reg = i->reg;
|
unsigned reg = i->reg;
|
||||||
|
|
||||||
// remove expired intervals
|
// remove expired intervals
|
||||||
if (i->expiredAt(cur->start())) {
|
if (i->expiredAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
||||||
if (MRegisterInfo::isVirtualRegister(reg))
|
if (MRegisterInfo::isVirtualRegister(reg))
|
||||||
reg = vrm_->getPhys(reg);
|
reg = vrm_->getPhys(reg);
|
||||||
@ -279,7 +279,7 @@ void RA::processActiveIntervals(IntervalPtrs::value_type cur)
|
|||||||
std::iter_swap(ii, --ie);
|
std::iter_swap(ii, --ie);
|
||||||
}
|
}
|
||||||
// move inactive intervals to inactive list
|
// move inactive intervals to inactive list
|
||||||
else if (!i->liveAt(cur->start())) {
|
else if (!i->liveAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " inactive\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " inactive\n");
|
||||||
if (MRegisterInfo::isVirtualRegister(reg))
|
if (MRegisterInfo::isVirtualRegister(reg))
|
||||||
reg = vrm_->getPhys(reg);
|
reg = vrm_->getPhys(reg);
|
||||||
@ -305,13 +305,13 @@ void RA::processInactiveIntervals(IntervalPtrs::value_type cur)
|
|||||||
unsigned reg = i->reg;
|
unsigned reg = i->reg;
|
||||||
|
|
||||||
// remove expired intervals
|
// remove expired intervals
|
||||||
if (i->expiredAt(cur->start())) {
|
if (i->expiredAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
||||||
// swap with last element and move end iterator back one position
|
// swap with last element and move end iterator back one position
|
||||||
std::iter_swap(ii, --ie);
|
std::iter_swap(ii, --ie);
|
||||||
}
|
}
|
||||||
// move re-activated intervals in active list
|
// move re-activated intervals in active list
|
||||||
else if (i->liveAt(cur->start())) {
|
else if (i->liveAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " active\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " active\n");
|
||||||
if (MRegisterInfo::isVirtualRegister(reg))
|
if (MRegisterInfo::isVirtualRegister(reg))
|
||||||
reg = vrm_->getPhys(reg);
|
reg = vrm_->getPhys(reg);
|
||||||
@ -424,7 +424,7 @@ void RA::assignRegOrSpillAtInterval(IntervalPtrs::value_type cur)
|
|||||||
toSpill[minReg] = true;
|
toSpill[minReg] = true;
|
||||||
for (const unsigned* as = mri_->getAliasSet(minReg); *as; ++as)
|
for (const unsigned* as = mri_->getAliasSet(minReg); *as; ++as)
|
||||||
toSpill[*as] = true;
|
toSpill[*as] = true;
|
||||||
unsigned earliestStart = cur->start();
|
unsigned earliestStart = cur->beginNumber();
|
||||||
|
|
||||||
std::set<unsigned> spilled;
|
std::set<unsigned> spilled;
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -45,7 +44,8 @@ namespace {
|
|||||||
const TargetMachine* tm_;
|
const TargetMachine* tm_;
|
||||||
const MRegisterInfo* mri_;
|
const MRegisterInfo* mri_;
|
||||||
LiveIntervals* li_;
|
LiveIntervals* li_;
|
||||||
typedef std::vector<LiveInterval*> IntervalPtrs;
|
typedef LiveInterval* IntervalPtr;
|
||||||
|
typedef std::vector<IntervalPtr> IntervalPtrs;
|
||||||
IntervalPtrs handled_, fixed_, active_, inactive_;
|
IntervalPtrs handled_, fixed_, active_, inactive_;
|
||||||
typedef std::priority_queue<LiveInterval*,
|
typedef std::priority_queue<LiveInterval*,
|
||||||
IntervalPtrs,
|
IntervalPtrs,
|
||||||
@ -231,13 +231,14 @@ void RA::initIntervalSets()
|
|||||||
void RA::processActiveIntervals(IntervalPtrs::value_type cur)
|
void RA::processActiveIntervals(IntervalPtrs::value_type cur)
|
||||||
{
|
{
|
||||||
DEBUG(std::cerr << "\tprocessing active intervals:\n");
|
DEBUG(std::cerr << "\tprocessing active intervals:\n");
|
||||||
|
|
||||||
IntervalPtrs::iterator ii = active_.begin(), ie = active_.end();
|
IntervalPtrs::iterator ii = active_.begin(), ie = active_.end();
|
||||||
while (ii != ie) {
|
while (ii != ie) {
|
||||||
LiveInterval* i = *ii;
|
LiveInterval* i = *ii;
|
||||||
unsigned reg = i->reg;
|
unsigned reg = i->reg;
|
||||||
|
|
||||||
// remove expired intervals
|
// remove expired intervals
|
||||||
if (i->expiredAt(cur->start())) {
|
if (i->expiredAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
||||||
if (MRegisterInfo::isVirtualRegister(reg))
|
if (MRegisterInfo::isVirtualRegister(reg))
|
||||||
reg = vrm_->getPhys(reg);
|
reg = vrm_->getPhys(reg);
|
||||||
@ -246,7 +247,7 @@ void RA::processActiveIntervals(IntervalPtrs::value_type cur)
|
|||||||
std::iter_swap(ii, --ie);
|
std::iter_swap(ii, --ie);
|
||||||
}
|
}
|
||||||
// move inactive intervals to inactive list
|
// move inactive intervals to inactive list
|
||||||
else if (!i->liveAt(cur->start())) {
|
else if (!i->liveAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " inactive\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " inactive\n");
|
||||||
if (MRegisterInfo::isVirtualRegister(reg))
|
if (MRegisterInfo::isVirtualRegister(reg))
|
||||||
reg = vrm_->getPhys(reg);
|
reg = vrm_->getPhys(reg);
|
||||||
@ -267,18 +268,19 @@ void RA::processInactiveIntervals(IntervalPtrs::value_type cur)
|
|||||||
{
|
{
|
||||||
DEBUG(std::cerr << "\tprocessing inactive intervals:\n");
|
DEBUG(std::cerr << "\tprocessing inactive intervals:\n");
|
||||||
IntervalPtrs::iterator ii = inactive_.begin(), ie = inactive_.end();
|
IntervalPtrs::iterator ii = inactive_.begin(), ie = inactive_.end();
|
||||||
|
|
||||||
while (ii != ie) {
|
while (ii != ie) {
|
||||||
LiveInterval* i = *ii;
|
LiveInterval* i = *ii;
|
||||||
unsigned reg = i->reg;
|
unsigned reg = i->reg;
|
||||||
|
|
||||||
// remove expired intervals
|
// remove expired intervals
|
||||||
if (i->expiredAt(cur->start())) {
|
if (i->expiredAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
|
||||||
// swap with last element and move end iterator back one position
|
// swap with last element and move end iterator back one position
|
||||||
std::iter_swap(ii, --ie);
|
std::iter_swap(ii, --ie);
|
||||||
}
|
}
|
||||||
// move re-activated intervals in active list
|
// move re-activated intervals in active list
|
||||||
else if (i->liveAt(cur->start())) {
|
else if (i->liveAt(cur->beginNumber())) {
|
||||||
DEBUG(std::cerr << "\t\tinterval " << *i << " active\n");
|
DEBUG(std::cerr << "\t\tinterval " << *i << " active\n");
|
||||||
if (MRegisterInfo::isVirtualRegister(reg))
|
if (MRegisterInfo::isVirtualRegister(reg))
|
||||||
reg = vrm_->getPhys(reg);
|
reg = vrm_->getPhys(reg);
|
||||||
@ -413,7 +415,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
|
|||||||
|
|
||||||
// the earliest start of a spilled interval indicates up to where
|
// the earliest start of a spilled interval indicates up to where
|
||||||
// in handled we need to roll back
|
// in handled we need to roll back
|
||||||
unsigned earliestStart = cur->start();
|
unsigned earliestStart = cur->beginNumber();
|
||||||
|
|
||||||
// set of spilled vregs (used later to rollback properly)
|
// set of spilled vregs (used later to rollback properly)
|
||||||
std::set<unsigned> spilled;
|
std::set<unsigned> spilled;
|
||||||
@ -431,7 +433,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
|
|||||||
toSpill[vrm_->getPhys(reg)] &&
|
toSpill[vrm_->getPhys(reg)] &&
|
||||||
cur->overlaps(**i)) {
|
cur->overlaps(**i)) {
|
||||||
DEBUG(std::cerr << "\t\t\tspilling(a): " << **i << '\n');
|
DEBUG(std::cerr << "\t\t\tspilling(a): " << **i << '\n');
|
||||||
earliestStart = std::min(earliestStart, (*i)->start());
|
earliestStart = std::min(earliestStart, (*i)->beginNumber());
|
||||||
int slot = vrm_->assignVirt2StackSlot((*i)->reg);
|
int slot = vrm_->assignVirt2StackSlot((*i)->reg);
|
||||||
std::vector<LiveInterval*> newIs =
|
std::vector<LiveInterval*> newIs =
|
||||||
li_->addIntervalsForSpills(**i, *vrm_, slot);
|
li_->addIntervalsForSpills(**i, *vrm_, slot);
|
||||||
@ -446,7 +448,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
|
|||||||
toSpill[vrm_->getPhys(reg)] &&
|
toSpill[vrm_->getPhys(reg)] &&
|
||||||
cur->overlaps(**i)) {
|
cur->overlaps(**i)) {
|
||||||
DEBUG(std::cerr << "\t\t\tspilling(i): " << **i << '\n');
|
DEBUG(std::cerr << "\t\t\tspilling(i): " << **i << '\n');
|
||||||
earliestStart = std::min(earliestStart, (*i)->start());
|
earliestStart = std::min(earliestStart, (*i)->beginNumber());
|
||||||
int slot = vrm_->assignVirt2StackSlot((*i)->reg);
|
int slot = vrm_->assignVirt2StackSlot((*i)->reg);
|
||||||
std::vector<LiveInterval*> newIs =
|
std::vector<LiveInterval*> newIs =
|
||||||
li_->addIntervalsForSpills(**i, *vrm_, slot);
|
li_->addIntervalsForSpills(**i, *vrm_, slot);
|
||||||
@ -462,7 +464,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
|
|||||||
while (!handled_.empty()) {
|
while (!handled_.empty()) {
|
||||||
LiveInterval* i = handled_.back();
|
LiveInterval* i = handled_.back();
|
||||||
// if this interval starts before t we are done
|
// if this interval starts before t we are done
|
||||||
if (i->start() < earliestStart)
|
if (i->beginNumber() < earliestStart)
|
||||||
break;
|
break;
|
||||||
DEBUG(std::cerr << "\t\t\tundo changes for: " << *i << '\n');
|
DEBUG(std::cerr << "\t\t\tundo changes for: " << *i << '\n');
|
||||||
handled_.pop_back();
|
handled_.pop_back();
|
||||||
@ -505,7 +507,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
|
|||||||
// put it in inactive if required)
|
// put it in inactive if required)
|
||||||
for (IntervalPtrs::iterator i = handled_.begin(), e = handled_.end();
|
for (IntervalPtrs::iterator i = handled_.begin(), e = handled_.end();
|
||||||
i != e; ++i) {
|
i != e; ++i) {
|
||||||
if (!(*i)->expiredAt(earliestStart) && (*i)->expiredAt(cur->start())) {
|
if (!(*i)->expiredAt(earliestStart) && (*i)->expiredAt(cur->beginNumber())){
|
||||||
DEBUG(std::cerr << "\t\t\tundo changes for: " << **i << '\n');
|
DEBUG(std::cerr << "\t\t\tundo changes for: " << **i << '\n');
|
||||||
active_.push_back(*i);
|
active_.push_back(*i);
|
||||||
if (MRegisterInfo::isPhysicalRegister((*i)->reg))
|
if (MRegisterInfo::isPhysicalRegister((*i)->reg))
|
||||||
|
Loading…
Reference in New Issue
Block a user