diff options
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/ADT/IntervalMap.h | 26 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineLoopRanges.h | 12 |
2 files changed, 34 insertions, 4 deletions
diff --git a/include/llvm/ADT/IntervalMap.h b/include/llvm/ADT/IntervalMap.h index 86652f5673..3f7a4c7d89 100644 --- a/include/llvm/ADT/IntervalMap.h +++ b/include/llvm/ADT/IntervalMap.h @@ -940,6 +940,8 @@ class IntervalMap { public: typedef typename Sizer::Allocator Allocator; + typedef KeyT KeyType; + typedef ValT ValueType; typedef Traits KeyTraits; private: @@ -2025,6 +2027,7 @@ iterator::overflow(unsigned Level) { /// template <typename MapA, typename MapB> class IntervalMapOverlaps { + typedef typename MapA::KeyType KeyType; typedef typename MapA::KeyTraits Traits; typename MapA::const_iterator posA; typename MapB::const_iterator posB; @@ -2065,6 +2068,20 @@ public: /// b - access the right hand side in the overlap. const typename MapB::const_iterator &b() const { return posB; } + /// start - Beginning of the overlapping interval. + KeyType start() const { + KeyType ak = a().start(); + KeyType bk = b().start(); + return Traits::startLess(ak, bk) ? bk : ak; + } + + /// stop - End of the overlaping interval. + KeyType stop() const { + KeyType ak = a().stop(); + KeyType bk = b().stop(); + return Traits::startLess(ak, bk) ? ak : bk; + } + /// skipA - Move to the next overlap that doesn't involve a(). void skipA() { ++posA; @@ -2094,8 +2111,15 @@ public: skipA(); return *this; } -}; + /// advanceTo - Move to the first overlapping interval with + /// stopLess(x, stop()). + void advanceTo(KeyType x) { + posA.advanceTo(x); + posB.advanceTo(x); + advance(); + } +}; } // namespace llvm diff --git a/include/llvm/CodeGen/MachineLoopRanges.h b/include/llvm/CodeGen/MachineLoopRanges.h index 7e6bec639c..730b729dba 100644 --- a/include/llvm/CodeGen/MachineLoopRanges.h +++ b/include/llvm/CodeGen/MachineLoopRanges.h @@ -29,15 +29,18 @@ class raw_ostream; /// MachineLoopRange - Range information for a single loop. class MachineLoopRange { friend class MachineLoopRanges; - typedef IntervalMap<SlotIndex, unsigned, 4> RangeMap; - typedef RangeMap::Allocator Allocator; +public: + typedef IntervalMap<SlotIndex, unsigned, 4> Map; + typedef Map::Allocator Allocator; + +private: /// The mapped loop. const MachineLoop *const Loop; /// Map intervals to a bit mask. /// Bit 0 = inside loop block. - RangeMap Intervals; + Map Intervals; /// Create a MachineLoopRange, only accessible to MachineLoopRanges. MachineLoopRange(const MachineLoop*, Allocator&, SlotIndexes&); @@ -47,6 +50,9 @@ public: /// inteructions. bool overlaps(SlotIndex Start, SlotIndex Stop); + /// getMap - Allow public read-only access for IntervalMapOverlaps. + const Map &getMap() { return Intervals; } + /// print - Print loop ranges on OS. void print(raw_ostream&) const; }; |