diff options
| author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-30 07:46:27 +0000 |
|---|---|---|
| committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-30 07:46:27 +0000 |
| commit | 6924063bf2fdcc455bcb87807ab452ab7fc69773 (patch) | |
| tree | 5230d66a408761cea76d447376da0824dffe6960 /lib/CodeGen/LiveIntervalAnalysis.h | |
| parent | 1da7e8e0b3cfc1d3c399da4cdd7dc5c087c9f0d3 (diff) | |
Pull Interval class out of LiveIntervals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13910 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.h')
| -rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.h | 90 |
1 files changed, 40 insertions, 50 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.h b/lib/CodeGen/LiveIntervalAnalysis.h index dda1637984..3e3c817acd 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.h +++ b/lib/CodeGen/LiveIntervalAnalysis.h @@ -30,62 +30,60 @@ namespace llvm { class MRegisterInfo; class VirtRegMap; - class LiveIntervals : public MachineFunctionPass - { - public: - struct Interval { - typedef std::pair<unsigned, unsigned> Range; - typedef std::vector<Range> Ranges; - unsigned reg; // the register of this interval - float weight; // weight of this interval (number of uses - // * 10^loopDepth) - Ranges ranges; // the ranges in which this register is live - Interval(unsigned r); + struct Interval { + typedef std::pair<unsigned, unsigned> Range; + typedef std::vector<Range> Ranges; + unsigned reg; // the register of this interval + float weight; // weight of this interval: + // (number of uses *10^loopDepth) + Ranges ranges; // the ranges in which this register is live - bool empty() const { return ranges.empty(); } + explicit Interval(unsigned r); - bool spilled() const; + bool empty() const { return ranges.empty(); } - unsigned start() const { - assert(!empty() && "empty interval for register"); - return ranges.front().first; - } + bool spilled() const; - unsigned end() const { - assert(!empty() && "empty interval for register"); - return ranges.back().second; - } + unsigned start() const { + assert(!empty() && "empty interval for register"); + return ranges.front().first; + } - bool expiredAt(unsigned index) const { - return end() <= (index + 1); - } + unsigned end() const { + assert(!empty() && "empty interval for register"); + return ranges.back().second; + } - bool liveAt(unsigned index) const; + bool expiredAt(unsigned index) const { + return end() <= (index + 1); + } - bool overlaps(const Interval& other) const; + bool liveAt(unsigned index) const; - void addRange(unsigned start, unsigned end); + bool overlaps(const Interval& other) const; - void join(const Interval& other); + void addRange(unsigned start, unsigned end); - private: - Ranges::iterator mergeRangesForward(Ranges::iterator it); + void join(const Interval& other); - Ranges::iterator mergeRangesBackward(Ranges::iterator it); - }; + bool operator<(const Interval& other) const { + return start() < other.start(); + } - struct StartPointComp { - bool operator()(const Interval& lhs, const Interval& rhs) { - return lhs.ranges.front().first < rhs.ranges.front().first; - } - }; + bool operator==(const Interval& other) const { + return reg == other.reg; + } - struct StartPointPtrComp { - bool operator()(const Interval* lhs, const Interval* rhs) { - return lhs->ranges.front().first < rhs->ranges.front().first; - } - }; + private: + Ranges::iterator mergeRangesForward(Ranges::iterator it); + Ranges::iterator mergeRangesBackward(Ranges::iterator it); + }; + std::ostream& operator<<(std::ostream& os, const Interval& li); + + class LiveIntervals : public MachineFunctionPass + { + public: typedef std::list<Interval> Intervals; private: @@ -205,14 +203,6 @@ namespace llvm { void printRegName(unsigned reg) const; }; - inline bool operator==(const LiveIntervals::Interval& lhs, - const LiveIntervals::Interval& rhs) { - return lhs.reg == rhs.reg; - } - - std::ostream& operator<<(std::ostream& os, - const LiveIntervals::Interval& li); - } // End llvm namespace #endif |
