aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-08-07 23:49:57 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-08-07 23:49:57 +0000
commita8d94f1315f722de056af03763664b77a5baac26 (patch)
tree0d6df32277e39c84a3e18c7c0bfdb8a46da98258 /lib
parent002fe25dd7ae240369eae70195ccf17b8921585f (diff)
downloadexternal_llvm-a8d94f1315f722de056af03763664b77a5baac26.zip
external_llvm-a8d94f1315f722de056af03763664b77a5baac26.tar.gz
external_llvm-a8d94f1315f722de056af03763664b77a5baac26.tar.bz2
- LiveInterval value#'s now have 3 components: def instruction #,
kill instruction #, and source register number (iff the value# is defined by a copy). - Now def instruction # is set for every value#, not just for copy defined ones. - Update some outdated code related inactive live ranges. - Kill info not yet set. That's next patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40913 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/LiveInterval.cpp19
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp13
-rw-r--r--lib/CodeGen/SimpleRegisterCoalescing.cpp24
3 files changed, 30 insertions, 26 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
index 45c1dd0..1aa02f0 100644
--- a/lib/CodeGen/LiveInterval.cpp
+++ b/lib/CodeGen/LiveInterval.cpp
@@ -281,8 +281,7 @@ LiveInterval::FindLiveRangeContaining(unsigned Idx) {
/// the intervals are not joinable, this aborts.
void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments,
int *RHSValNoAssignments,
- SmallVector<std::pair<unsigned,
- unsigned>, 16> &NewValueNumberInfo) {
+ SmallVector<VNInfo, 16> &NewValueNumberInfo) {
// Try to do the least amount of work possible. In particular, if there are
// more liverange chunks in the other set than there are in the 'this' set,
@@ -301,7 +300,8 @@ void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments,
// we want to avoid the interval scan if not.
bool MustMapCurValNos = false;
for (unsigned i = 0, e = getNumValNums(); i != e; ++i) {
- if (ValueNumberInfo[i].first == ~2U) continue; // tombstone value #
+ assert(ValueNumberInfo[i].def != ~2U);
+ if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value #
if (i != (unsigned)LHSValNoAssignments[i]) {
MustMapCurValNos = true;
break;
@@ -463,9 +463,9 @@ void LiveInterval::MergeValueNumberInto(unsigned V1, unsigned V2) {
if (V1 == getNumValNums()-1) {
do {
ValueNumberInfo.pop_back();
- } while (ValueNumberInfo.back().first == ~1U);
+ } while (ValueNumberInfo.back().def == ~1U);
} else {
- ValueNumberInfo[V1].first = ~1U;
+ ValueNumberInfo[V1].def = ~1U;
}
}
@@ -507,10 +507,15 @@ void LiveInterval::print(std::ostream &OS, const MRegisterInfo *MRI) const {
for (unsigned i = 0; i != getNumValNums(); ++i) {
if (i) OS << " ";
OS << i << "@";
- if (ValueNumberInfo[i].first == ~0U) {
+ if (ValueNumberInfo[i].def == ~0U) {
OS << "?";
} else {
- OS << ValueNumberInfo[i].first;
+ OS << ValueNumberInfo[i].def;
+ }
+ if (ValueNumberInfo[i].kill == ~0U) {
+ OS << ",?";
+ } else {
+ OS << "," << ValueNumberInfo[i].kill;
}
}
}
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 369493f..c17f2ac 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -351,7 +351,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
unsigned ValNum;
unsigned SrcReg, DstReg;
if (!tii_->isMoveInstr(*mi, SrcReg, DstReg))
- ValNum = interval.getNextValue(~0U, 0);
+ ValNum = interval.getNextValue(defIndex, 0);
else
ValNum = interval.getNextValue(defIndex, SrcReg);
@@ -450,7 +450,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
interval.setValueNumberInfo(1, interval.getValNumInfo(0));
// Value#0 is now defined by the 2-addr instruction.
- interval.setValueNumberInfo(0, std::make_pair(~0U, 0U));
+ interval.setValueNumberInfo(0, LiveInterval::VNInfo(DefIndex, ~0U, 0U));
// Add the new live interval which replaces the range for the input copy.
LiveRange LR(DefIndex, RedefIndex, ValNo);
@@ -484,7 +484,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
// Replace the interval with one of a NEW value number. Note that this
// value number isn't actually defined by an instruction, weird huh? :)
- LiveRange LR(Start, End, interval.getNextValue(~0U, 0));
+ LiveRange LR(Start, End, interval.getNextValue(~0, 0));
DOUT << " replace range with " << LR;
interval.addRange(LR);
DOUT << " RESULT: "; interval.print(DOUT, mri_);
@@ -498,7 +498,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
unsigned ValNum;
unsigned SrcReg, DstReg;
if (!tii_->isMoveInstr(*mi, SrcReg, DstReg))
- ValNum = interval.getNextValue(~0U, 0);
+ ValNum = interval.getNextValue(defIndex, 0);
else
ValNum = interval.getNextValue(defIndex, SrcReg);
@@ -566,8 +566,7 @@ exit:
// Already exists? Extend old live interval.
LiveInterval::iterator OldLR = interval.FindLiveRangeContaining(start);
unsigned Id = (OldLR != interval.end())
- ? OldLR->ValId
- : interval.getNextValue(SrcReg != 0 ? start : ~0U, SrcReg);
+ ? OldLR->ValId : interval.getNextValue(start, SrcReg);
LiveRange LR(start, end, Id);
interval.addRange(LR);
DOUT << " +" << LR << '\n';
@@ -634,7 +633,7 @@ exit:
}
}
- LiveRange LR(start, end, interval.getNextValue(~0U, 0));
+ LiveRange LR(start, end, interval.getNextValue(start, 0));
DOUT << " +" << LR << '\n';
interval.addRange(LR);
}
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp
index a3f8cca..a37a005 100644
--- a/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -91,7 +91,7 @@ bool SimpleRegisterCoalescing::AdjustCopiesBackFrom(LiveInterval &IntA, LiveInte
// an unknown definition point or it is defined at CopyIdx. If unknown, we
// can't process it.
unsigned BValNoDefIdx = IntB.getInstForValNum(BValNo);
- if (BValNoDefIdx == ~0U) return false;
+ if (!IntB.getSrcRegForValNum(BValNo)) return false;
assert(BValNoDefIdx == CopyIdx &&
"Copy doesn't define the value?");
@@ -128,14 +128,15 @@ bool SimpleRegisterCoalescing::AdjustCopiesBackFrom(LiveInterval &IntA, LiveInte
DOUT << "\nExtending: "; IntB.print(DOUT, mri_);
+ unsigned FillerStart = ValLR->end, FillerEnd = BLR->start;
// We are about to delete CopyMI, so need to remove it as the 'instruction
- // that defines this value #'.
- IntB.setValueNumberInfo(BValNo, std::make_pair(~0U, 0));
+ // that defines this value #'. Update the the valnum with the new defining
+ // instruction #.
+ IntB.setValueNumberInfo(BValNo, LiveInterval::VNInfo(FillerStart, ~0U, 0));
// Okay, we can merge them. We need to insert a new liverange:
// [ValLR.end, BLR.begin) of either value number, then we merge the
// two value numbers.
- unsigned FillerStart = ValLR->end, FillerEnd = BLR->start;
IntB.addRange(LiveRange(FillerStart, FillerEnd, BValNo));
// If the IntB live range is assigned to a physical register, and if that
@@ -145,7 +146,7 @@ bool SimpleRegisterCoalescing::AdjustCopiesBackFrom(LiveInterval &IntA, LiveInte
for (const unsigned *AS = mri_->getSubRegisters(IntB.reg); *AS; ++AS) {
LiveInterval &AliasLI = li_->getInterval(*AS);
AliasLI.addRange(LiveRange(FillerStart, FillerEnd,
- AliasLI.getNextValue(~0U, 0)));
+ AliasLI.getNextValue(FillerStart, 0)));
}
}
@@ -398,8 +399,7 @@ bool SimpleRegisterCoalescing::JoinCopy(MachineInstr *CopyMI,
/// contains the value number the copy is from.
///
static unsigned ComputeUltimateVN(unsigned VN,
- SmallVector<std::pair<unsigned,
- unsigned>, 16> &ValueNumberInfo,
+ SmallVector<LiveInterval::VNInfo, 16> &ValueNumberInfo,
SmallVector<int, 16> &ThisFromOther,
SmallVector<int, 16> &OtherFromThis,
SmallVector<int, 16> &ThisValNoAssignments,
@@ -574,7 +574,7 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS, LiveInterval &RH
// coalesced.
SmallVector<int, 16> LHSValNoAssignments;
SmallVector<int, 16> RHSValNoAssignments;
- SmallVector<std::pair<unsigned,unsigned>, 16> ValueNumberInfo;
+ SmallVector<LiveInterval::VNInfo, 16> ValueNumberInfo;
// If a live interval is a physical register, conservatively check if any
// of its sub-registers is overlapping the live interval of the virtual
@@ -605,7 +605,7 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS, LiveInterval &RH
// Find out if the RHS is defined as a copy from some value in the LHS.
int RHSValID = -1;
- std::pair<unsigned,unsigned> RHSValNoInfo;
+ LiveInterval::VNInfo RHSValNoInfo;
unsigned RHSSrcReg = RHS.getSrcRegForValNum(0);
if ((RHSSrcReg == 0 || rep(RHSSrcReg) != LHS.reg)) {
// If RHS is not defined as a copy from the LHS, we can use simpler and
@@ -645,7 +645,7 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS, LiveInterval &RH
// Otherwise, use the specified value #.
LHSValNoAssignments[VN] = RHSValID;
if (VN != (unsigned)RHSValID)
- ValueNumberInfo[VN].first = ~1U;
+ ValueNumberInfo[VN].def = ~1U;
else
ValueNumberInfo[VN] = RHSValNoInfo;
}
@@ -702,14 +702,14 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS, LiveInterval &RH
ValueNumberInfo.reserve(LHS.getNumValNums() + RHS.getNumValNums());
for (unsigned VN = 0, e = LHS.getNumValNums(); VN != e; ++VN) {
- if (LHSValNoAssignments[VN] >= 0 || LHS.getInstForValNum(VN) == ~2U)
+ if (LHSValNoAssignments[VN] >= 0 || LHS.getInstForValNum(VN) == ~1U)
continue;
ComputeUltimateVN(VN, ValueNumberInfo,
LHSValsDefinedFromRHS, RHSValsDefinedFromLHS,
LHSValNoAssignments, RHSValNoAssignments, LHS, RHS);
}
for (unsigned VN = 0, e = RHS.getNumValNums(); VN != e; ++VN) {
- if (RHSValNoAssignments[VN] >= 0 || RHS.getInstForValNum(VN) == ~2U)
+ if (RHSValNoAssignments[VN] >= 0 || RHS.getInstForValNum(VN) == ~1U)
continue;
// If this value number isn't a copy from the LHS, it's a new number.
if (RHSValsDefinedFromLHS[VN] == -1) {