Skip to content

Commit

Permalink
LiveIntervalUnion: Allow specification of liverange when unifying/ext…
Browse files Browse the repository at this point in the history
…racting.

This allows it to add subregister ranges into the union.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223890 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
MatzeB committed Dec 10, 2014
1 parent 84cc6ec commit 7b54b4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
10 changes: 8 additions & 2 deletions include/llvm/CodeGen/LiveIntervalUnion.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ class LiveIntervalUnion {
bool changedSince(unsigned tag) const { return tag != Tag; }

// Add a live virtual register to this union and merge its segments.
void unify(LiveInterval &VirtReg);
void unify(LiveInterval &VirtReg, const LiveRange &Range);
void unify(LiveInterval &VirtReg) {
unify(VirtReg, VirtReg);
}

// Remove a live virtual register's segments from this union.
void extract(LiveInterval &VirtReg);
void extract(LiveInterval &VirtReg, const LiveRange &Range);
void extract(LiveInterval &VirtReg) {
extract(VirtReg, VirtReg);
}

// Remove all inserted virtual registers.
void clear() { Segments.clear(); ++Tag; }
Expand Down
18 changes: 9 additions & 9 deletions lib/CodeGen/LiveIntervalUnion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ using namespace llvm;


// Merge a LiveInterval's segments. Guarantee no overlaps.
void LiveIntervalUnion::unify(LiveInterval &VirtReg) {
if (VirtReg.empty())
void LiveIntervalUnion::unify(LiveInterval &VirtReg, const LiveRange &Range) {
if (Range.empty())
return;
++Tag;

// Insert each of the virtual register's live segments into the map.
LiveInterval::iterator RegPos = VirtReg.begin();
LiveInterval::iterator RegEnd = VirtReg.end();
LiveRange::const_iterator RegPos = Range.begin();
LiveRange::const_iterator RegEnd = Range.end();
SegmentIter SegPos = Segments.find(RegPos->start);

while (SegPos.valid()) {
Expand All @@ -53,14 +53,14 @@ void LiveIntervalUnion::unify(LiveInterval &VirtReg) {
}

// Remove a live virtual register's segments from this union.
void LiveIntervalUnion::extract(LiveInterval &VirtReg) {
if (VirtReg.empty())
void LiveIntervalUnion::extract(LiveInterval &VirtReg, const LiveRange &Range) {
if (Range.empty())
return;
++Tag;

// Remove each of the virtual register's live segments from the map.
LiveInterval::iterator RegPos = VirtReg.begin();
LiveInterval::iterator RegEnd = VirtReg.end();
LiveRange::const_iterator RegPos = Range.begin();
LiveRange::const_iterator RegEnd = Range.end();
SegmentIter SegPos = Segments.find(RegPos->start);

for (;;) {
Expand All @@ -70,7 +70,7 @@ void LiveIntervalUnion::extract(LiveInterval &VirtReg) {
return;

// Skip all segments that may have been coalesced.
RegPos = VirtReg.advanceTo(RegPos, SegPos.start());
RegPos = Range.advanceTo(RegPos, SegPos.start());
if (RegPos == RegEnd)
return;

Expand Down

0 comments on commit 7b54b4d

Please sign in to comment.