diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2007-04-17 20:25:11 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2007-04-17 20:25:11 +0000 |
| commit | 57b5214d59037c16b5240ce5ba3f020389203f44 (patch) | |
| tree | 0b590c66c969491792cabeaa0696cf19d14e4beb /llvm | |
| parent | 2f45bf31c521a89dd944adcf575ddb5059959f51 (diff) | |
| download | bcm5719-llvm-57b5214d59037c16b5240ce5ba3f020389203f44.tar.gz bcm5719-llvm-57b5214d59037c16b5240ce5ba3f020389203f44.zip | |
Add a register allocation preference field; add a method to compute size of a live interval.
llvm-svn: 36216
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/CodeGen/LiveInterval.h | 7 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/LiveInterval.cpp | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h index 63d02c85731..1912d642960 100644 --- a/llvm/include/llvm/CodeGen/LiveInterval.h +++ b/llvm/include/llvm/CodeGen/LiveInterval.h @@ -81,6 +81,7 @@ namespace llvm { struct LiveInterval { typedef SmallVector<LiveRange,4> Ranges; unsigned reg; // the register of this interval + unsigned preference; // preferred register to allocate for this interval float weight; // weight of this interval MachineInstr* remat; // definition if the definition rematerializable Ranges ranges; // the ranges in which this register is live @@ -94,7 +95,7 @@ namespace llvm { public: LiveInterval(unsigned Reg, float Weight) - : reg(Reg), weight(Weight), remat(NULL) { + : reg(Reg), preference(0), weight(Weight), remat(NULL) { } typedef Ranges::iterator iterator; @@ -256,6 +257,10 @@ namespace llvm { removeRange(LR.start, LR.end); } + /// getSize - Returns the sum of sizes of all the LiveRange's. + /// + unsigned getSize() const; + bool operator<(const LiveInterval& other) const { return beginNumber() < other.beginNumber(); } diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index 0ca16007b2d..45c1dd03da5 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -349,6 +349,8 @@ void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments, ValueNumberInfo.clear(); ValueNumberInfo.append(NewValueNumberInfo.begin(), NewValueNumberInfo.end()); weight += Other.weight; + if (Other.preference && !preference) + preference = Other.preference; } /// MergeRangesInAsValue - Merge all of the intervals in RHS into this live @@ -467,6 +469,13 @@ void LiveInterval::MergeValueNumberInto(unsigned V1, unsigned V2) { } } +unsigned LiveInterval::getSize() const { + unsigned Sum = 0; + for (const_iterator I = begin(), E = end(); I != E; ++I) + Sum += I->end - I->start; + return Sum; +} + std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) { return os << '[' << LR.start << ',' << LR.end << ':' << LR.ValId << ")"; } |

