LLVM API Documentation

LiveInterval.h

Go to the documentation of this file.
00001 //===-- llvm/CodeGen/LiveInterval.h - Interval representation ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the LiveRange and LiveInterval classes.  Given some
00011 // numbering of each the machine instructions an interval [i, j) is said to be a
00012 // live interval for register v if there is no instruction with number j' >= j
00013 // such that v is live at j' and there is no instruction with number i' < i such
00014 // that v is live at i'. In this implementation intervals can have holes,
00015 // i.e. an interval might look like [1,20), [50,65), [1000,1001).  Each
00016 // individual range is represented as an instance of LiveRange, and the whole
00017 // interval is represented as an instance of LiveInterval.
00018 //
00019 //===----------------------------------------------------------------------===//
00020 
00021 #ifndef LLVM_CODEGEN_LIVEINTERVAL_H
00022 #define LLVM_CODEGEN_LIVEINTERVAL_H
00023 
00024 #include "llvm/ADT/SmallVector.h"
00025 #include "llvm/Support/Allocator.h"
00026 #include "llvm/Support/AlignOf.h"
00027 #include <iosfwd>
00028 #include <cassert>
00029 #include <climits>
00030 
00031 namespace llvm {
00032   class MachineInstr;
00033   class MachineRegisterInfo;
00034   class TargetRegisterInfo;
00035   class raw_ostream;
00036 
00037   /// VNInfo - Value Number Information.
00038   /// This class holds information about a machine level values, including
00039   /// definition and use points.
00040   ///
00041   /// Care must be taken in interpreting the def index of the value. The 
00042   /// following rules apply:
00043   ///
00044   /// If the isDefAccurate() method returns false then def does not contain the
00045   /// index of the defining MachineInstr, or even (necessarily) to a
00046   /// MachineInstr at all. In general such a def index is not meaningful
00047   /// and should not be used. The exception is that, for values originally
00048   /// defined by PHI instructions, after PHI elimination def will contain the
00049   /// index of the MBB in which the PHI originally existed. This can be used
00050   /// to insert code (spills or copies) which deals with the value, which will
00051   /// be live in to the block.
00052 
00053   class VNInfo {
00054   private:
00055     enum {
00056       HAS_PHI_KILL    = 1,                         
00057       REDEF_BY_EC     = 1 << 1,
00058       IS_PHI_DEF      = 1 << 2,
00059       IS_UNUSED       = 1 << 3,
00060       IS_DEF_ACCURATE = 1 << 4
00061     };
00062 
00063     unsigned char flags;
00064     union {
00065       MachineInstr *copy;
00066       unsigned reg;
00067     } cr;
00068 
00069   public:
00070     /// Holds information about individual kills.
00071     struct KillInfo {
00072       bool isPHIKill : 1;
00073       unsigned killIdx : 31;
00074 
00075       KillInfo(bool isPHIKill, unsigned killIdx)
00076         : isPHIKill(isPHIKill), killIdx(killIdx) {
00077 
00078         assert(killIdx != 0 && "Zero kill indices are no longer permitted.");
00079       }
00080 
00081     };
00082 
00083     typedef SmallVector<KillInfo, 4> KillSet;
00084 
00085     /// The ID number of this value.
00086     unsigned id;
00087     
00088     /// The index of the defining instruction (if isDefAccurate() returns true).
00089     unsigned def;
00090 
00091     KillSet kills;
00092 
00093     VNInfo()
00094       : flags(IS_UNUSED), id(~1U), def(0) { cr.copy = 0; }
00095 
00096     /// VNInfo constructor.
00097     /// d is presumed to point to the actual defining instr. If it doesn't
00098     /// setIsDefAccurate(false) should be called after construction.
00099     VNInfo(unsigned i, unsigned d, MachineInstr *c)
00100       : flags(IS_DEF_ACCURATE), id(i), def(d) { cr.copy = c; }
00101 
00102     /// VNInfo construtor, copies values from orig, except for the value number.
00103     VNInfo(unsigned i, const VNInfo &orig)
00104       : flags(orig.flags), cr(orig.cr), id(i), def(orig.def), kills(orig.kills)
00105     { }
00106 
00107     /// Copy from the parameter into this VNInfo.
00108     void copyFrom(VNInfo &src) {
00109       flags = src.flags;
00110       cr = src.cr;
00111       def = src.def;
00112       kills = src.kills;
00113     }
00114 
00115     /// Used for copying value number info.
00116     unsigned getFlags() const { return flags; }
00117     void setFlags(unsigned flags) { this->flags = flags; }
00118 
00119     /// For a register interval, if this VN was definied by a copy instr
00120     /// getCopy() returns a pointer to it, otherwise returns 0.
00121     /// For a stack interval the behaviour of this method is undefined.
00122     MachineInstr* getCopy() const { return cr.copy; }
00123     /// For a register interval, set the copy member.
00124     /// This method should not be called on stack intervals as it may lead to
00125     /// undefined behavior.
00126     void setCopy(MachineInstr *c) { cr.copy = c; }
00127     
00128     /// For a stack interval, returns the reg which this stack interval was
00129     /// defined from.
00130     /// For a register interval the behaviour of this method is undefined. 
00131     unsigned getReg() const { return cr.reg; }
00132     /// For a stack interval, set the defining register.
00133     /// This method should not be called on register intervals as it may lead
00134     /// to undefined behaviour.
00135     void setReg(unsigned reg) { cr.reg = reg; }
00136 
00137     /// Returns true if one or more kills are PHI nodes.
00138     bool hasPHIKill() const { return flags & HAS_PHI_KILL; }
00139     void setHasPHIKill(bool hasKill) {
00140       if (hasKill)
00141         flags |= HAS_PHI_KILL;
00142       else
00143         flags &= ~HAS_PHI_KILL;
00144     }
00145 
00146     /// Returns true if this value is re-defined by an early clobber somewhere
00147     /// during the live range.
00148     bool hasRedefByEC() const { return flags & REDEF_BY_EC; }
00149     void setHasRedefByEC(bool hasRedef) {
00150       if (hasRedef)
00151         flags |= REDEF_BY_EC;
00152       else
00153         flags &= ~REDEF_BY_EC;
00154     }
00155    
00156     /// Returns true if this value is defined by a PHI instruction (or was,
00157     /// PHI instrucions may have been eliminated).
00158     bool isPHIDef() const { return flags & IS_PHI_DEF; }
00159     void setIsPHIDef(bool phiDef) {
00160       if (phiDef)
00161         flags |= IS_PHI_DEF;
00162       else
00163         flags &= ~IS_PHI_DEF;
00164     }
00165 
00166     /// Returns true if this value is unused.
00167     bool isUnused() const { return flags & IS_UNUSED; }
00168     void setIsUnused(bool unused) {
00169       if (unused)
00170         flags |= IS_UNUSED;
00171       else
00172         flags &= ~IS_UNUSED;
00173     }
00174 
00175     /// Returns true if the def is accurate.
00176     bool isDefAccurate() const { return flags & IS_DEF_ACCURATE; }
00177     void setIsDefAccurate(bool defAccurate) {
00178       if (defAccurate)
00179         flags |= IS_DEF_ACCURATE;
00180       else 
00181         flags &= ~IS_DEF_ACCURATE;
00182     }
00183 
00184   };
00185 
00186   inline bool operator<(const VNInfo::KillInfo &k1, const VNInfo::KillInfo &k2) {
00187     return k1.killIdx < k2.killIdx;
00188   }
00189   
00190   inline bool operator<(const VNInfo::KillInfo &k, unsigned idx) {
00191     return k.killIdx < idx;
00192   }
00193 
00194   inline bool operator<(unsigned idx, const VNInfo::KillInfo &k) {
00195     return idx < k.killIdx;
00196   }
00197 
00198   /// LiveRange structure - This represents a simple register range in the
00199   /// program, with an inclusive start point and an exclusive end point.
00200   /// These ranges are rendered as [start,end).
00201   struct LiveRange {
00202     unsigned start;  // Start point of the interval (inclusive)
00203     unsigned end;    // End point of the interval (exclusive)
00204     VNInfo *valno;   // identifier for the value contained in this interval.
00205 
00206     LiveRange(unsigned S, unsigned E, VNInfo *V) : start(S), end(E), valno(V) {
00207       assert(S < E && "Cannot create empty or backwards range");
00208     }
00209 
00210     /// contains - Return true if the index is covered by this range.
00211     ///
00212     bool contains(unsigned I) const {
00213       return start <= I && I < end;
00214     }
00215 
00216     bool operator<(const LiveRange &LR) const {
00217       return start < LR.start || (start == LR.start && end < LR.end);
00218     }
00219     bool operator==(const LiveRange &LR) const {
00220       return start == LR.start && end == LR.end;
00221     }
00222 
00223     void dump() const;
00224     void print(std::ostream &os) const;
00225     void print(std::ostream *os) const { if (os) print(*os); }
00226     void print(raw_ostream &os) const;
00227     void print(raw_ostream *os) const { if (os) print(*os); }
00228 
00229   private:
00230     LiveRange(); // DO NOT IMPLEMENT
00231   };
00232 
00233   std::ostream& operator<<(std::ostream& os, const LiveRange &LR);
00234   raw_ostream& operator<<(raw_ostream& os, const LiveRange &LR);
00235 
00236 
00237   inline bool operator<(unsigned V, const LiveRange &LR) {
00238     return V < LR.start;
00239   }
00240 
00241   inline bool operator<(const LiveRange &LR, unsigned V) {
00242     return LR.start < V;
00243   }
00244 
00245   /// LiveInterval - This class represents some number of live ranges for a
00246   /// register or value.  This class also contains a bit of register allocator
00247   /// state.
00248   class LiveInterval {
00249   public:
00250 
00251     typedef SmallVector<LiveRange,4> Ranges;
00252     typedef SmallVector<VNInfo*,4> VNInfoList;
00253 
00254     unsigned reg;        // the register or stack slot of this interval
00255                          // if the top bits is set, it represents a stack slot.
00256     float weight;        // weight of this interval
00257     Ranges ranges;       // the ranges in which this register is live
00258     VNInfoList valnos;   // value#'s
00259     
00260     struct InstrSlots {
00261       enum {
00262         LOAD  = 0,
00263         USE   = 1,
00264         DEF   = 2,
00265         STORE = 3,
00266         NUM   = 4
00267       };
00268 
00269       static unsigned scale(unsigned slot, unsigned factor) {
00270         unsigned index = slot / NUM,
00271                  offset = slot % NUM;
00272         assert(index <= ~0U / (factor * NUM) &&
00273                "Rescaled interval would overflow");
00274         return index * NUM * factor + offset;
00275       }
00276 
00277     };
00278 
00279     LiveInterval(unsigned Reg, float Weight, bool IsSS = false)
00280       : reg(Reg), weight(Weight) {
00281       if (IsSS)
00282         reg = reg | (1U << (sizeof(unsigned)*CHAR_BIT-1));
00283     }
00284 
00285     typedef Ranges::iterator iterator;
00286     iterator begin() { return ranges.begin(); }
00287     iterator end()   { return ranges.end(); }
00288 
00289     typedef Ranges::const_iterator const_iterator;
00290     const_iterator begin() const { return ranges.begin(); }
00291     const_iterator end() const  { return ranges.end(); }
00292 
00293     typedef VNInfoList::iterator vni_iterator;
00294     vni_iterator vni_begin() { return valnos.begin(); }
00295     vni_iterator vni_end() { return valnos.end(); }
00296 
00297     typedef VNInfoList::const_iterator const_vni_iterator;
00298     const_vni_iterator vni_begin() const { return valnos.begin(); }
00299     const_vni_iterator vni_end() const { return valnos.end(); }
00300 
00301     /// advanceTo - Advance the specified iterator to point to the LiveRange
00302     /// containing the specified position, or end() if the position is past the
00303     /// end of the interval.  If no LiveRange contains this position, but the
00304     /// position is in a hole, this method returns an iterator pointing the the
00305     /// LiveRange immediately after the hole.
00306     iterator advanceTo(iterator I, unsigned Pos) {
00307       if (Pos >= endNumber())
00308         return end();
00309       while (I->end <= Pos) ++I;
00310       return I;
00311     }
00312     
00313     void clear() {
00314       while (!valnos.empty()) {
00315         VNInfo *VNI = valnos.back();
00316         valnos.pop_back();
00317         VNI->~VNInfo();
00318       }
00319       
00320       ranges.clear();
00321     }
00322 
00323     /// isStackSlot - Return true if this is a stack slot interval.
00324     ///
00325     bool isStackSlot() const {
00326       return reg & (1U << (sizeof(unsigned)*CHAR_BIT-1));
00327     }
00328 
00329     /// getStackSlotIndex - Return stack slot index if this is a stack slot
00330     /// interval.
00331     int getStackSlotIndex() const {
00332       assert(isStackSlot() && "Interval is not a stack slot interval!");
00333       return reg & ~(1U << (sizeof(unsigned)*CHAR_BIT-1));
00334     }
00335 
00336     bool hasAtLeastOneValue() const { return !valnos.empty(); }
00337 
00338     bool containsOneValue() const { return valnos.size() == 1; }
00339 
00340     unsigned getNumValNums() const { return (unsigned)valnos.size(); }
00341     
00342     /// getValNumInfo - Returns pointer to the specified val#.
00343     ///
00344     inline VNInfo *getValNumInfo(unsigned ValNo) {
00345       return valnos[ValNo];
00346     }
00347     inline const VNInfo *getValNumInfo(unsigned ValNo) const {
00348       return valnos[ValNo];
00349     }
00350 
00351     /// getNextValue - Create a new value number and return it.  MIIdx specifies
00352     /// the instruction that defines the value number.
00353     VNInfo *getNextValue(unsigned MIIdx, MachineInstr *CopyMI,
00354                          bool isDefAccurate, BumpPtrAllocator &VNInfoAllocator) {
00355 
00356       assert(MIIdx != ~0u && MIIdx != ~1u &&
00357              "PHI def / unused flags should now be passed explicitly.");
00358       VNInfo *VNI =
00359         static_cast<VNInfo*>(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo),
00360                                                       alignof<VNInfo>()));
00361       new (VNI) VNInfo((unsigned)valnos.size(), MIIdx, CopyMI);
00362       VNI->setIsDefAccurate(isDefAccurate);
00363       valnos.push_back(VNI);
00364       return VNI;
00365     }
00366 
00367     /// Create a copy of the given value. The new value will be identical except
00368     /// for the Value number.
00369     VNInfo *createValueCopy(const VNInfo *orig, BumpPtrAllocator &VNInfoAllocator) {
00370 
00371       VNInfo *VNI =
00372         static_cast<VNInfo*>(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo),
00373                                                       alignof<VNInfo>()));
00374     
00375       new (VNI) VNInfo((unsigned)valnos.size(), *orig);
00376       valnos.push_back(VNI);
00377       return VNI;
00378     }
00379 
00380     /// addKill - Add a kill instruction index to the specified value
00381     /// number.
00382     static void addKill(VNInfo *VNI, unsigned KillIdx, bool phiKill) {
00383       VNInfo::KillSet &kills = VNI->kills;
00384       VNInfo::KillInfo newKill(phiKill, KillIdx);
00385       if (kills.empty()) {
00386         kills.push_back(newKill);
00387       } else {
00388         VNInfo::KillSet::iterator
00389           I = std::lower_bound(kills.begin(), kills.end(), newKill);
00390         kills.insert(I, newKill);
00391       }
00392     }
00393 
00394     /// addKills - Add a number of kills into the VNInfo kill vector. If this
00395     /// interval is live at a kill point, then the kill is not added.
00396     void addKills(VNInfo *VNI, const VNInfo::KillSet &kills) {
00397       for (unsigned i = 0, e = static_cast<unsigned>(kills.size());
00398            i != e; ++i) {
00399         const VNInfo::KillInfo &Kill = kills[i];
00400         if (!liveBeforeAndAt(Kill.killIdx)) {
00401           VNInfo::KillSet::iterator
00402             I = std::lower_bound(VNI->kills.begin(), VNI->kills.end(), Kill);
00403           VNI->kills.insert(I, Kill);
00404         }
00405       }
00406     }
00407 
00408     /// removeKill - Remove the specified kill from the list of kills of
00409     /// the specified val#.
00410     static bool removeKill(VNInfo *VNI, unsigned KillIdx) {
00411       VNInfo::KillSet &kills = VNI->kills;
00412       VNInfo::KillSet::iterator
00413         I = std::lower_bound(kills.begin(), kills.end(), KillIdx);
00414       if (I != kills.end() && I->killIdx == KillIdx) {
00415         kills.erase(I);
00416         return true;
00417       }
00418       return false;
00419     }
00420 
00421     /// removeKills - Remove all the kills in specified range
00422     /// [Start, End] of the specified val#.
00423     static void removeKills(VNInfo *VNI, unsigned Start, unsigned End) {
00424       VNInfo::KillSet &kills = VNI->kills;
00425 
00426       VNInfo::KillSet::iterator
00427         I = std::lower_bound(kills.begin(), kills.end(), Start);
00428       VNInfo::KillSet::iterator
00429         E = std::upper_bound(kills.begin(), kills.end(), End);
00430       kills.erase(I, E);
00431     }
00432 
00433     /// isKill - Return true if the specified index is a kill of the
00434     /// specified val#.
00435     static bool isKill(const VNInfo *VNI, unsigned KillIdx) {
00436       const VNInfo::KillSet &kills = VNI->kills;
00437       VNInfo::KillSet::const_iterator
00438         I = std::lower_bound(kills.begin(), kills.end(), KillIdx);
00439       return I != kills.end() && I->killIdx == KillIdx;
00440     }
00441 
00442     /// isOnlyLROfValNo - Return true if the specified live range is the only
00443     /// one defined by the its val#.
00444     bool isOnlyLROfValNo(const LiveRange *LR) {
00445       for (const_iterator I = begin(), E = end(); I != E; ++I) {
00446         const LiveRange *Tmp = I;
00447         if (Tmp != LR && Tmp->valno == LR->valno)
00448           return false;
00449       }
00450       return true;
00451     }
00452     
00453     /// MergeValueNumberInto - This method is called when two value nubmers
00454     /// are found to be equivalent.  This eliminates V1, replacing all
00455     /// LiveRanges with the V1 value number with the V2 value number.  This can
00456     /// cause merging of V1/V2 values numbers and compaction of the value space.
00457     VNInfo* MergeValueNumberInto(VNInfo *V1, VNInfo *V2);
00458 
00459     /// MergeInClobberRanges - For any live ranges that are not defined in the
00460     /// current interval, but are defined in the Clobbers interval, mark them
00461     /// used with an unknown definition value. Caller must pass in reference to
00462     /// VNInfoAllocator since it will create a new val#.
00463     void MergeInClobberRanges(const LiveInterval &Clobbers,
00464                               BumpPtrAllocator &VNInfoAllocator);
00465 
00466     /// MergeInClobberRange - Same as MergeInClobberRanges except it merge in a
00467     /// single LiveRange only.
00468     void MergeInClobberRange(unsigned Start, unsigned End,
00469                              BumpPtrAllocator &VNInfoAllocator);
00470 
00471     /// MergeValueInAsValue - Merge all of the live ranges of a specific val#
00472     /// in RHS into this live interval as the specified value number.
00473     /// The LiveRanges in RHS are allowed to overlap with LiveRanges in the
00474     /// current interval, it will replace the value numbers of the overlaped
00475     /// live ranges with the specified value number.
00476     void MergeRangesInAsValue(const LiveInterval &RHS, VNInfo *LHSValNo);
00477 
00478     /// MergeValueInAsValue - Merge all of the live ranges of a specific val#
00479     /// in RHS into this live interval as the specified value number.
00480     /// The LiveRanges in RHS are allowed to overlap with LiveRanges in the
00481     /// current interval, but only if the overlapping LiveRanges have the
00482     /// specified value number.
00483     void MergeValueInAsValue(const LiveInterval &RHS,
00484                              const VNInfo *RHSValNo, VNInfo *LHSValNo);
00485 
00486     /// Copy - Copy the specified live interval. This copies all the fields
00487     /// except for the register of the interval.
00488     void Copy(const LiveInterval &RHS, MachineRegisterInfo *MRI,
00489               BumpPtrAllocator &VNInfoAllocator);
00490     
00491     bool empty() const { return ranges.empty(); }
00492 
00493     /// beginNumber - Return the lowest numbered slot covered by interval.
00494     unsigned beginNumber() const {
00495       if (empty())
00496         return 0;
00497       return ranges.front().start;
00498     }
00499 
00500     /// endNumber - return the maximum point of the interval of the whole,
00501     /// exclusive.
00502     unsigned endNumber() const {
00503       if (empty())
00504         return 0;
00505       return ranges.back().end;
00506     }
00507 
00508     bool expiredAt(unsigned index) const {
00509       return index >= endNumber();
00510     }
00511 
00512     bool liveAt(unsigned index) const;
00513 
00514     // liveBeforeAndAt - Check if the interval is live at the index and the
00515     // index just before it. If index is liveAt, check if it starts a new live
00516     // range.If it does, then check if the previous live range ends at index-1.
00517     bool liveBeforeAndAt(unsigned index) const;
00518 
00519     /// getLiveRangeContaining - Return the live range that contains the
00520     /// specified index, or null if there is none.
00521     const LiveRange *getLiveRangeContaining(unsigned Idx) const {
00522       const_iterator I = FindLiveRangeContaining(Idx);
00523       return I == end() ? 0 : &*I;
00524     }
00525 
00526     /// getLiveRangeContaining - Return the live range that contains the
00527     /// specified index, or null if there is none.
00528     LiveRange *getLiveRangeContaining(unsigned Idx) {
00529       iterator I = FindLiveRangeContaining(Idx);
00530       return I == end() ? 0 : &*I;
00531     }
00532 
00533     /// FindLiveRangeContaining - Return an iterator to the live range that
00534     /// contains the specified index, or end() if there is none.
00535     const_iterator FindLiveRangeContaining(unsigned Idx) const;
00536 
00537     /// FindLiveRangeContaining - Return an iterator to the live range that
00538     /// contains the specified index, or end() if there is none.
00539     iterator FindLiveRangeContaining(unsigned Idx);
00540 
00541     /// findDefinedVNInfo - Find the VNInfo that's defined at the specified
00542     /// index (register interval) or defined by the specified register (stack
00543     /// inteval).
00544     VNInfo *findDefinedVNInfo(unsigned DefIdxOrReg) const;
00545     
00546     /// overlaps - Return true if the intersection of the two live intervals is
00547     /// not empty.
00548     bool overlaps(const LiveInterval& other) const {
00549       return overlapsFrom(other, other.begin());
00550     }
00551 
00552     /// overlaps - Return true if the live interval overlaps a range specified
00553     /// by [Start, End).
00554     bool overlaps(unsigned Start, unsigned End) const;
00555 
00556     /// overlapsFrom - Return true if the intersection of the two live intervals
00557     /// is not empty.  The specified iterator is a hint that we can begin
00558     /// scanning the Other interval starting at I.
00559     bool overlapsFrom(const LiveInterval& other, const_iterator I) const;
00560 
00561     /// addRange - Add the specified LiveRange to this interval, merging
00562     /// intervals as appropriate.  This returns an iterator to the inserted live
00563     /// range (which may have grown since it was inserted.
00564     void addRange(LiveRange LR) {
00565       addRangeFrom(LR, ranges.begin());
00566     }
00567 
00568     /// join - Join two live intervals (this, and other) together.  This applies
00569     /// mappings to the value numbers in the LHS/RHS intervals as specified.  If
00570     /// the intervals are not joinable, this aborts.
00571     void join(LiveInterval &Other, const int *ValNoAssignments,
00572               const int *RHSValNoAssignments,
00573               SmallVector<VNInfo*, 16> &NewVNInfo,
00574               MachineRegisterInfo *MRI);
00575 
00576     /// isInOneLiveRange - Return true if the range specified is entirely in the
00577     /// a single LiveRange of the live interval.
00578     bool isInOneLiveRange(unsigned Start, unsigned End);
00579 
00580     /// removeRange - Remove the specified range from this interval.  Note that
00581     /// the range must be a single LiveRange in its entirety.
00582     void removeRange(unsigned Start, unsigned End, bool RemoveDeadValNo = false);
00583 
00584     void removeRange(LiveRange LR, bool RemoveDeadValNo = false) {
00585       removeRange(LR.start, LR.end, RemoveDeadValNo);
00586     }
00587 
00588     /// removeValNo - Remove all the ranges defined by the specified value#.
00589     /// Also remove the value# from value# list.
00590     void removeValNo(VNInfo *ValNo);
00591 
00592     /// scaleNumbering - Renumber VNI and ranges to provide gaps for new
00593     /// instructions.
00594     void scaleNumbering(unsigned factor);
00595 
00596     /// getSize - Returns the sum of sizes of all the LiveRange's.
00597     ///
00598     unsigned getSize() const;
00599 
00600     /// ComputeJoinedWeight - Set the weight of a live interval after
00601     /// Other has been merged into it.
00602     void ComputeJoinedWeight(const LiveInterval &Other);
00603 
00604     bool operator<(const LiveInterval& other) const {
00605       return beginNumber() < other.beginNumber();
00606     }
00607 
00608     void print(std::ostream &OS, const TargetRegisterInfo *TRI = 0) const;
00609     void print(std::ostream *OS, const TargetRegisterInfo *TRI = 0) const {
00610       if (OS) print(*OS, TRI);
00611     }
00612     void print(raw_ostream &OS, const TargetRegisterInfo *TRI = 0) const;
00613     void print(raw_ostream *OS, const TargetRegisterInfo *TRI = 0) const {
00614       if (OS) print(*OS, TRI);
00615     }
00616     void dump() const;
00617 
00618   private:
00619 
00620     Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From);
00621     void extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd);
00622     Ranges::iterator extendIntervalStartTo(Ranges::iterator I, unsigned NewStr);
00623     LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT
00624 
00625   };
00626 
00627   inline std::ostream &operator<<(std::ostream &OS, const LiveInterval &LI) {
00628     LI.print(OS);
00629     return OS;
00630   }
00631   inline raw_ostream &operator<<(raw_ostream &OS, const LiveInterval &LI) {
00632     LI.print(OS);
00633     return OS;
00634   }
00635 }
00636 
00637 #endif