mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Change std::map<unsigned, LiveInterval*> into a std::map<unsigned,
LiveInterval>. This saves some space and removes the pointer indirection caused by following the pointer. llvm-svn: 15167
This commit is contained in:
parent
0d3969f3d1
commit
0618429149
@ -75,8 +75,8 @@ bool LiveInterval::overlaps(const LiveInterval& other) const {
|
||||
return true;
|
||||
|
||||
if (i->start > j->start) {
|
||||
swap(i, j);
|
||||
swap(ie, je);
|
||||
std::swap(i, j);
|
||||
std::swap(ie, je);
|
||||
}
|
||||
assert(i->start < j->start);
|
||||
|
||||
|
@ -76,6 +76,21 @@ namespace llvm {
|
||||
: reg(Reg), weight(Weight), NumValues(0) {
|
||||
}
|
||||
|
||||
LiveInterval& operator=(const LiveInterval& rhs) {
|
||||
reg = rhs.reg;
|
||||
weight = rhs.weight;
|
||||
ranges = rhs.ranges;
|
||||
NumValues = rhs.NumValues;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(LiveInterval& other) {
|
||||
std::swap(reg, other.reg);
|
||||
std::swap(weight, other.weight);
|
||||
ranges.swap(other.ranges);
|
||||
std::swap(NumValues, other.NumValues);
|
||||
}
|
||||
|
||||
bool containsOneValue() const { return NumValues == 1; }
|
||||
|
||||
unsigned getNextValue() {
|
||||
|
@ -76,11 +76,7 @@ void LiveIntervals::releaseMemory()
|
||||
{
|
||||
mi2iMap_.clear();
|
||||
i2miMap_.clear();
|
||||
for (std::map<unsigned, LiveInterval*>::iterator I = r2iMap_.begin(),
|
||||
E = r2iMap_.end(); I != E; ++I)
|
||||
delete I->second; // free all intervals.
|
||||
r2iMap_.clear();
|
||||
|
||||
r2rMap_.clear();
|
||||
}
|
||||
|
||||
@ -112,7 +108,7 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
|
||||
#if 1
|
||||
DEBUG(std::cerr << "********** INTERVALS **********\n");
|
||||
DEBUG(for (iterator I = begin(), E = end(); I != E; ++I)
|
||||
std::cerr << *I->second << "\n");
|
||||
std::cerr << I->second << "\n");
|
||||
#endif
|
||||
|
||||
// join intervals if requested
|
||||
@ -169,7 +165,7 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
|
||||
|
||||
DEBUG(std::cerr << "********** INTERVALS **********\n");
|
||||
DEBUG (for (iterator I = begin(), E = end(); I != E; ++I)
|
||||
std::cerr << *I->second << "\n");
|
||||
std::cerr << I->second << "\n");
|
||||
DEBUG(std::cerr << "********** MACHINEINSTRS **********\n");
|
||||
DEBUG(
|
||||
for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
|
||||
@ -561,7 +557,6 @@ void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) {
|
||||
if ((TriviallyJoinable || !IntB.joinable(IntA, MIDefIdx)) &&
|
||||
!overlapsAliases(&IntA, &IntB)) {
|
||||
IntB.join(IntA, MIDefIdx);
|
||||
delete r2iMap_[regA]; // Delete the dead interval
|
||||
|
||||
if (!MRegisterInfo::isPhysicalRegister(regA)) {
|
||||
r2iMap_.erase(regA);
|
||||
@ -571,7 +566,7 @@ void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) {
|
||||
// the physreg information.
|
||||
r2rMap_[regB] = regA;
|
||||
IntB.reg = regA;
|
||||
r2iMap_[regA] = r2iMap_[regB];
|
||||
IntA.swap(IntB);
|
||||
r2iMap_.erase(regB);
|
||||
}
|
||||
DEBUG(std::cerr << "Joined. Result = " << IntB << "\n");
|
||||
@ -661,8 +656,8 @@ bool LiveIntervals::overlapsAliases(const LiveInterval *LHS,
|
||||
return false;
|
||||
}
|
||||
|
||||
LiveInterval *LiveIntervals::createInterval(unsigned reg) const {
|
||||
LiveInterval LiveIntervals::createInterval(unsigned reg) {
|
||||
float Weight = MRegisterInfo::isPhysicalRegister(reg) ? HUGE_VAL :0.0F;
|
||||
return new LiveInterval(reg, Weight);
|
||||
return LiveInterval(reg, Weight);
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,8 @@ namespace llvm {
|
||||
typedef std::vector<MachineInstr*> Index2MiMap;
|
||||
Index2MiMap i2miMap_;
|
||||
|
||||
/// r2iMap_ - This map OWNS the interval pointed to by the map. When
|
||||
/// this map is destroyed or when entries are modified, this intervals
|
||||
/// should be destroyed or modified as well.
|
||||
std::map<unsigned, LiveInterval*> r2iMap_;
|
||||
typedef std::map<unsigned, LiveInterval> Reg2IntervalMap;
|
||||
Reg2IntervalMap r2iMap_;
|
||||
|
||||
typedef std::map<unsigned, unsigned> Reg2RegMap;
|
||||
Reg2RegMap r2rMap_;
|
||||
@ -80,16 +78,22 @@ namespace llvm {
|
||||
return getBaseIndex(index) + InstrSlots::STORE;
|
||||
}
|
||||
|
||||
typedef std::map<unsigned, LiveInterval*>::const_iterator iterator;
|
||||
iterator begin() const { return r2iMap_.begin(); }
|
||||
iterator end() const { return r2iMap_.end(); }
|
||||
unsigned getNumIntervals() const { return r2iMap_.size(); }
|
||||
// FIXME: this should really be a const_iterator
|
||||
typedef Reg2IntervalMap::iterator iterator;
|
||||
iterator begin() { return r2iMap_.begin(); }
|
||||
iterator end() { return r2iMap_.end(); }
|
||||
unsigned getNumIntervals() const { return r2iMap_.size(); }
|
||||
|
||||
LiveInterval &getInterval(unsigned reg) const {
|
||||
std::map<unsigned, LiveInterval*>::const_iterator I =
|
||||
r2iMap_.find(reg);
|
||||
LiveInterval &getInterval(unsigned reg) {
|
||||
Reg2IntervalMap::iterator I = r2iMap_.find(reg);
|
||||
assert(I != r2iMap_.end() && "Interval does not exist for register");
|
||||
return *I->second;
|
||||
return I->second;
|
||||
}
|
||||
|
||||
const LiveInterval &getInterval(unsigned reg) const {
|
||||
Reg2IntervalMap::const_iterator I = r2iMap_.find(reg);
|
||||
assert(I != r2iMap_.end() && "Interval does not exist for register");
|
||||
return I->second;
|
||||
}
|
||||
|
||||
/// getInstructionIndex - returns the base index of instr
|
||||
@ -155,13 +159,13 @@ namespace llvm {
|
||||
bool overlapsAliases(const LiveInterval *lhs,
|
||||
const LiveInterval *rhs) const;
|
||||
|
||||
LiveInterval *createInterval(unsigned Reg) const;
|
||||
static LiveInterval createInterval(unsigned Reg);
|
||||
|
||||
LiveInterval &getOrCreateInterval(unsigned reg) {
|
||||
LiveInterval *&LI = r2iMap_[reg];
|
||||
if (LI == 0)
|
||||
LI = createInterval(reg);
|
||||
return *LI;
|
||||
Reg2IntervalMap::iterator I = r2iMap_.find(reg);
|
||||
if (I == r2iMap_.end())
|
||||
I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg)));
|
||||
return I->second;
|
||||
}
|
||||
|
||||
/// rep - returns the representative of this register
|
||||
|
@ -257,9 +257,9 @@ void RA::initIntervalSets() {
|
||||
"interval sets should be empty on initialization");
|
||||
|
||||
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i){
|
||||
unhandled_.push_back(i->second);
|
||||
if (MRegisterInfo::isPhysicalRegister(i->second->reg))
|
||||
fixed_.push_back(i->second);
|
||||
unhandled_.push_back(&i->second);
|
||||
if (MRegisterInfo::isPhysicalRegister(i->second.reg))
|
||||
fixed_.push_back(&i->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,9 +224,9 @@ void RA::initIntervalSets()
|
||||
"interval sets should be empty on initialization");
|
||||
|
||||
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i){
|
||||
unhandled_.push(i->second);
|
||||
if (MRegisterInfo::isPhysicalRegister(i->second->reg))
|
||||
fixed_.push_back(i->second);
|
||||
unhandled_.push(&i->second);
|
||||
if (MRegisterInfo::isPhysicalRegister(i->second.reg))
|
||||
fixed_.push_back(&i->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user