X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FLiveInterval.cpp;h=40f8cd4388d89bc65bc89358e06d8d74e4b481e0;hb=b0000c376cf13ed63306622ab9642cfae49f074a;hp=b09ffd48e64dffb15bd5214d187d7d6fb38d0b53;hpb=d2b8d7bc51b0e41d09b32aeaa550358ccb379009;p=oota-llvm.git diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index b09ffd48e64..40f8cd4388d 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -44,6 +44,27 @@ bool LiveInterval::liveAt(unsigned I) const { return r->contains(I); } +// liveBeforeAndAt - Check if the interval is live at the index and the index +// just before it. If index is liveAt, check if it starts a new live range. +// If it does, then check if the previous live range ends at index-1. +bool LiveInterval::liveBeforeAndAt(unsigned I) const { + Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), I); + + if (r == ranges.begin()) + return false; + + --r; + if (!r->contains(I)) + return false; + if (I != r->start) + return true; + // I is the start of a live range. Check if the previous live range ends + // at I-1. + if (r == ranges.begin()) + return false; + return r->end == I; +} + // overlaps - Return true if the intersection of the two live intervals is // not empty. // @@ -196,7 +217,7 @@ LiveInterval::addRangeFrom(LiveRange LR, iterator From) { // Otherwise, if this range ends in the middle of, or right next to, another // interval, merge it into that interval. - if (it != ranges.end()) + if (it != ranges.end()) { if (LR.valno == it->valno) { if (it->start <= End) { it = extendIntervalStartTo(it, Start); @@ -216,15 +237,26 @@ LiveInterval::addRangeFrom(LiveRange LR, iterator From) { assert(it->start >= End && "Cannot overlap two LiveRanges with differing ValID's"); } + } // Otherwise, this is just a new range that doesn't interact with anything. // Insert it. return ranges.insert(it, LR); } +/// isInOneLiveRange - Return true if the range specified is entirely in the +/// a single LiveRange of the live interval. +bool LiveInterval::isInOneLiveRange(unsigned Start, unsigned End) { + Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); + if (I == ranges.begin()) + return false; + --I; + return I->contains(Start) && I->contains(End-1); +} + /// removeRange - Remove the specified range from this interval. Note that -/// the range must already be in this interval in its entirety. +/// the range must be in a single LiveRange in its entirety. void LiveInterval::removeRange(unsigned Start, unsigned End, bool RemoveDeadValNo) { // Find the LiveRange containing this span. @@ -336,6 +368,20 @@ LiveInterval::FindLiveRangeContaining(unsigned Idx) { return end(); } +/// findDefinedVNInfo - Find the VNInfo that's defined at the specified index +/// (register interval) or defined by the specified register (stack inteval). +VNInfo *LiveInterval::findDefinedVNInfo(unsigned DefIdxOrReg) const { + VNInfo *VNI = NULL; + for (LiveInterval::const_vni_iterator i = vni_begin(), e = vni_end(); + i != e; ++i) + if ((*i)->def == DefIdxOrReg) { + VNI = *i; + break; + } + return VNI; +} + + /// join - Join two live intervals (this, and other) together. This applies /// mappings to the value numbers in the LHS/RHS intervals as specified. If /// the intervals are not joinable, this aborts. @@ -511,7 +557,7 @@ void LiveInterval::MergeValueInAsValue(const LiveInterval &RHS, /// used with an unknown definition value. void LiveInterval::MergeInClobberRanges(const LiveInterval &Clobbers, BumpPtrAllocator &VNInfoAllocator) { - if (Clobbers.begin() == Clobbers.end()) return; + if (Clobbers.empty()) return; // Find a value # to use for the clobber ranges. If there is already a value# // for unknown values, use it. @@ -545,7 +591,7 @@ void LiveInterval::MergeInClobberRanges(const LiveInterval &Clobbers, /// are found to be equivalent. This eliminates V1, replacing all /// LiveRanges with the V1 value number with the V2 value number. This can /// cause merging of V1/V2 values numbers and compaction of the value space. -void LiveInterval::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) { +VNInfo* LiveInterval::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) { assert(V1 != V2 && "Identical value#'s are always equivalent!"); // This code actually merges the (numerically) larger value number into the @@ -606,6 +652,8 @@ void LiveInterval::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) { } else { V1->def = ~1U; } + + return V2; } void LiveInterval::Copy(const LiveInterval &RHS, @@ -642,7 +690,9 @@ void LiveRange::dump() const { void LiveInterval::print(std::ostream &OS, const TargetRegisterInfo *TRI) const { - if (TRI && TargetRegisterInfo::isPhysicalRegister(reg)) + if (isStackSlot()) + OS << "SS#" << getStackSlotIndex(); + else if (TRI && TargetRegisterInfo::isPhysicalRegister(reg)) OS << TRI->getName(reg); else OS << "%reg" << reg; @@ -650,7 +700,7 @@ void LiveInterval::print(std::ostream &OS, OS << ',' << weight; if (empty()) - OS << "EMPTY"; + OS << " EMPTY"; else { OS << " = "; for (LiveInterval::Ranges::const_iterator I = ranges.begin(),