diff options
author | Lang Hames <lhames@gmail.com> | 2009-10-03 04:21:37 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2009-10-03 04:21:37 +0000 |
commit | cc3b0650f1feec45d1a2890b20c05c4b325f1788 (patch) | |
tree | 0fd5a51ecec517e516bf433fa114d4d19f3bd6e6 | |
parent | e2b208a5e1dfece2462f595dec2d8f8ff3c1b98f (diff) |
Renamed MachineInstrIndex to LiveIndex.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83254 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/CodeGen/LiveInterval.h | 174 | ||||
-rw-r--r-- | include/llvm/CodeGen/LiveIntervalAnalysis.h | 102 | ||||
-rw-r--r-- | lib/CodeGen/LiveInterval.cpp | 46 | ||||
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 184 | ||||
-rw-r--r-- | lib/CodeGen/PreAllocSplitting.cpp | 102 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocLinearScan.cpp | 24 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocPBQP.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 90 | ||||
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.h | 8 | ||||
-rw-r--r-- | lib/CodeGen/Spiller.cpp | 44 | ||||
-rw-r--r-- | lib/CodeGen/StrongPHIElimination.cpp | 18 | ||||
-rw-r--r-- | lib/CodeGen/VirtRegMap.h | 10 |
12 files changed, 402 insertions, 402 deletions
diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 1878b2e634..05bd173dd2 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -34,12 +34,12 @@ namespace llvm { class TargetRegisterInfo; class raw_ostream; - /// MachineInstrIndex - An opaque wrapper around machine indexes. - class MachineInstrIndex { + /// LiveIndex - An opaque wrapper around machine indexes. + class LiveIndex { friend class VNInfo; friend class LiveInterval; friend class LiveIntervals; - friend struct DenseMapInfo<MachineInstrIndex>; + friend struct DenseMapInfo<LiveIndex>; public: @@ -53,45 +53,45 @@ namespace llvm { public: - /// Construct a default MachineInstrIndex pointing to a reserved index. - MachineInstrIndex() : index(0) {} + /// Construct a default LiveIndex pointing to a reserved index. + LiveIndex() : index(0) {} /// Construct an index from the given index, pointing to the given slot. - MachineInstrIndex(MachineInstrIndex m, Slot s) + LiveIndex(LiveIndex m, Slot s) : index((m.index / NUM) * NUM + s) {} /// Print this index to the given raw_ostream. void print(raw_ostream &os) const; - /// Compare two MachineInstrIndex objects for equality. - bool operator==(MachineInstrIndex other) const { + /// Compare two LiveIndex objects for equality. + bool operator==(LiveIndex other) const { return ((index & ~PHI_BIT) == (other.index & ~PHI_BIT)); } - /// Compare two MachineInstrIndex objects for inequality. - bool operator!=(MachineInstrIndex other) const { + /// Compare two LiveIndex objects for inequality. + bool operator!=(LiveIndex other) const { return ((index & ~PHI_BIT) != (other.index & ~PHI_BIT)); } - /// Compare two MachineInstrIndex objects. Return true if the first index + /// Compare two LiveIndex objects. Return true if the first index /// is strictly lower than the second. - bool operator<(MachineInstrIndex other) const { + bool operator<(LiveIndex other) const { return ((index & ~PHI_BIT) < (other.index & ~PHI_BIT)); } - /// Compare two MachineInstrIndex objects. Return true if the first index + /// Compare two LiveIndex objects. Return true if the first index /// is lower than, or equal to, the second. - bool operator<=(MachineInstrIndex other) const { + bool operator<=(LiveIndex other) const { return ((index & ~PHI_BIT) <= (other.index & ~PHI_BIT)); } - /// Compare two MachineInstrIndex objects. Return true if the first index + /// Compare two LiveIndex objects. Return true if the first index /// is greater than the second. - bool operator>(MachineInstrIndex other) const { + bool operator>(LiveIndex other) const { return ((index & ~PHI_BIT) > (other.index & ~PHI_BIT)); } - /// Compare two MachineInstrIndex objects. Return true if the first index + /// Compare two LiveIndex objects. Return true if the first index /// is greater than, or equal to, the second. - bool operator>=(MachineInstrIndex other) const { + bool operator>=(LiveIndex other) const { return ((index & ~PHI_BIT) >= (other.index & ~PHI_BIT)); } @@ -115,7 +115,7 @@ namespace llvm { return ((index % NUM) == STORE); } - /// Returns the slot for this MachineInstrIndex. + /// Returns the slot for this LiveIndex. Slot getSlot() const { return static_cast<Slot>(index % NUM); } @@ -133,53 +133,53 @@ namespace llvm { private: /// Construct an index from the given index, with its PHI kill marker set. - MachineInstrIndex(bool phi, MachineInstrIndex o) : index(o.index) { + LiveIndex(bool phi, LiveIndex o) : index(o.index) { if (phi) index |= PHI_BIT; else index &= ~PHI_BIT; } - explicit MachineInstrIndex(unsigned idx) + explicit LiveIndex(unsigned idx) : index(idx & ~PHI_BIT) {} - MachineInstrIndex(bool phi, unsigned idx) + LiveIndex(bool phi, unsigned idx) : index(idx & ~PHI_BIT) { if (phi) index |= PHI_BIT; } - MachineInstrIndex(bool phi, unsigned idx, Slot slot) + LiveIndex(bool phi, unsigned idx, Slot slot) : index(((idx / NUM) * NUM + slot) & ~PHI_BIT) { if (phi) index |= PHI_BIT; } - MachineInstrIndex nextSlot_() const { + LiveIndex nextSlot_() const { assert((index & PHI_BIT) == ((index + 1) & PHI_BIT) && "Index out of bounds."); - return MachineInstrIndex(index + 1); + return LiveIndex(index + 1); } - MachineInstrIndex nextIndex_() const { + LiveIndex nextIndex_() const { assert((index & PHI_BIT) == ((index + NUM) & PHI_BIT) && "Index out of bounds."); - return MachineInstrIndex(index + NUM); + return LiveIndex(index + NUM); } - MachineInstrIndex prevSlot_() const { + LiveIndex prevSlot_() const { assert((index & PHI_BIT) == ((index - 1) & PHI_BIT) && "Index out of bounds."); - return MachineInstrIndex(index - 1); + return LiveIndex(index - 1); } - MachineInstrIndex prevIndex_() const { + LiveIndex prevIndex_() const { assert((index & PHI_BIT) == ((index - NUM) & PHI_BIT) && "Index out of bounds."); - return MachineInstrIndex(index - NUM); + return LiveIndex(index - NUM); } - int distance(MachineInstrIndex other) const { + int distance(LiveIndex other) const { return (other.index & ~PHI_BIT) - (index & ~PHI_BIT); } @@ -190,47 +190,47 @@ namespace llvm { } /// Scale this index by the given factor. - MachineInstrIndex scale(unsigned factor) const { + LiveIndex scale(unsigned factor) const { unsigned i = (index & ~PHI_BIT) / NUM, o = (index % ~PHI_BIT) % NUM; assert(index <= (~0U & ~PHI_BIT) / (factor * NUM) && "Rescaled interval would overflow"); - return MachineInstrIndex(i * NUM * factor, o); + return LiveIndex(i * NUM * factor, o); } - static MachineInstrIndex emptyKey() { - return MachineInstrIndex(true, 0x7fffffff); + static LiveIndex emptyKey() { + return LiveIndex(true, 0x7fffffff); } - static MachineInstrIndex tombstoneKey() { - return MachineInstrIndex(true, 0x7ffffffe); + static LiveIndex tombstoneKey() { + return LiveIndex(true, 0x7ffffffe); } - static unsigned getHashValue(const MachineInstrIndex &v) { + static unsigned getHashValue(const LiveIndex &v) { return v.index * 37; } }; - inline raw_ostream& operator<<(raw_ostream &os, MachineInstrIndex mi) { + inline raw_ostream& operator<<(raw_ostream &os, LiveIndex mi) { mi.print(os); return os; } - /// Densemap specialization for MachineInstrIndex. + /// Densemap specialization for LiveIndex. template <> - struct DenseMapInfo<MachineInstrIndex> { - static inline MachineInstrIndex getEmptyKey() { - return MachineInstrIndex::emptyKey(); + struct DenseMapInfo<LiveIndex> { + static inline LiveIndex getEmptyKey() { + return LiveIndex::emptyKey(); } - static inline MachineInstrIndex getTombstoneKey() { - return MachineInstrIndex::tombstoneKey(); + static inline LiveIndex getTombstoneKey() { + return LiveIndex::tombstoneKey(); } - static inline unsigned getHashValue(const MachineInstrIndex &v) { - return MachineInstrIndex::getHashValue(v); + static inline unsigned getHashValue(const LiveIndex &v) { + return LiveIndex::getHashValue(v); } - static inline bool isEqual(const MachineInstrIndex &LHS, - const MachineInstrIndex &RHS) { + static inline bool isEqual(const LiveIndex &LHS, + const LiveIndex &RHS) { return (LHS == RHS); } static inline bool isPod() { return true; } @@ -270,13 +270,13 @@ namespace llvm { public: - typedef SmallVector<MachineInstrIndex, 4> KillSet; + typedef SmallVector<LiveIndex, 4> KillSet; /// The ID number of this value. unsigned id; /// The index of the defining instruction (if isDefAccurate() returns true). - MachineInstrIndex def; + LiveIndex def; KillSet kills; @@ -286,7 +286,7 @@ namespace llvm { /// VNInfo constructor. /// d is presumed to point to the actual defining instr. If it doesn't /// setIsDefAccurate(false) should be called after construction. - VNInfo(unsigned i, MachineInstrIndex d, MachineInstr *c) + VNInfo(unsigned i, LiveIndex d, MachineInstr *c) : flags(IS_DEF_ACCURATE), id(i), def(d) { cr.copy = c; } /// VNInfo construtor, copies values from orig, except for the value number. @@ -377,7 +377,7 @@ namespace llvm { } /// Returns true if the given index is a kill of this value. - bool isKill(MachineInstrIndex k) const { + bool isKill(LiveIndex k) const { KillSet::const_iterator i = std::lower_bound(kills.begin(), kills.end(), k); return (i != kills.end() && *i == k); @@ -385,7 +385,7 @@ namespace llvm { /// addKill - Add a kill instruction index to the specified value /// number. - void addKill(MachineInstrIndex k) { + void addKill(LiveIndex k) { if (kills.empty()) { kills.push_back(k); } else { @@ -397,7 +397,7 @@ namespace llvm { /// Remove the specified kill index from this value's kills list. /// Returns true if the value was present, otherwise returns false. - bool removeKill(MachineInstrIndex k) { + bool removeKill(LiveIndex k) { KillSet::iterator i = std::lower_bound(kills.begin(), kills.end(), k); if (i != kills.end() && *i == k) { kills.erase(i); @@ -407,7 +407,7 @@ namespace llvm { } /// Remove all kills in the range [s, e). - void removeKills(MachineInstrIndex s, MachineInstrIndex e) { + void removeKills(LiveIndex s, LiveIndex e) { KillSet::iterator si = std::lower_bound(kills.begin(), kills.end(), s), se = std::upper_bound(kills.begin(), kills.end(), e); @@ -421,11 +421,11 @@ namespace llvm { /// program, with an inclusive start point and an exclusive end point. /// These ranges are rendered as [start,end). struct LiveRange { - MachineInstrIndex start; // Start point of the interval (inclusive) - MachineInstrIndex end; // End point of the interval (exclusive) + LiveIndex start; // Start point of the interval (inclusive) + LiveIndex end; // End point of the interval (exclusive) VNInfo *valno; // identifier for the value contained in this interval. - LiveRange(MachineInstrIndex S, MachineInstrIndex E, VNInfo *V) + LiveRange(LiveIndex S, LiveIndex E, VNInfo *V) : start(S), end(E), valno(V) { assert(S < E && "Cannot create empty or backwards range"); @@ -433,13 +433,13 @@ namespace llvm { /// contains - Return true if the index is covered by this range. /// - bool contains(MachineInstrIndex I) const { + bool contains(LiveIndex I) const { return start <= I && I < end; } /// containsRange - Return true if the given range, [S, E), is covered by /// this range. - bool containsRange(MachineInstrIndex S, MachineInstrIndex E) const { + bool containsRange(LiveIndex S, LiveIndex E) const { assert((S < E) && "Backwards interval?"); return (start <= S && S < end) && (start < E && E <= end); } @@ -461,11 +461,11 @@ namespace llvm { raw_ostream& operator<<(raw_ostream& os, const LiveRange &LR); - inline bool operator<(MachineInstrIndex V, const LiveRange &LR) { + inline bool operator<(LiveIndex V, const LiveRange &LR) { return V < LR.start; } - inline bool operator<(const LiveRange &LR, MachineInstrIndex V) { + inline bool operator<(const LiveRange &LR, LiveIndex V) { return LR.start < V; } @@ -522,7 +522,7 @@ namespace llvm { /// end of the interval. If no LiveRange contains this position, but the /// position is in a hole, this method returns an iterator pointing the the /// LiveRange immediately after the hole. - iterator advanceTo(iterator I, MachineInstrIndex Pos) { + iterator advanceTo(iterator I, LiveIndex Pos) { if (Pos >= endIndex()) return end(); while (I->end <= Pos) ++I; @@ -569,7 +569,7 @@ namespace llvm { /// getNextValue - Create a new value number and return it. MIIdx specifies /// the instruction that defines the value number. - VNInfo *getNextValue(MachineInstrIndex def, MachineInstr *CopyMI, + VNInfo *getNextValue(LiveIndex def, MachineInstr *CopyMI, bool isDefAccurate, BumpPtrAllocator &VNInfoAllocator){ VNInfo *VNI = static_cast<VNInfo*>(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), @@ -630,8 +630,8 @@ namespace llvm { /// MergeInClobberRange - Same as MergeInClobberRanges except it merge in a /// single LiveRange only. - void MergeInClobberRange(MachineInstrIndex Start, - MachineInstrIndex End, + void MergeInClobberRange(LiveIndex Start, + LiveIndex End, BumpPtrAllocator &VNInfoAllocator); /// MergeValueInAsValue - Merge all of the live ranges of a specific val# @@ -657,56 +657,56 @@ namespace llvm { bool empty() const { return ranges.empty(); } /// beginIndex - Return the lowest numbered slot covered by interval. - MachineInstrIndex beginIndex() const { + LiveIndex beginIndex() const { if (empty()) - return MachineInstrIndex(); + return LiveIndex(); return ranges.front().start; } /// endNumber - return the maximum point of the interval of the whole, /// exclusive. - MachineInstrIndex endIndex() const { + LiveIndex endIndex() const { if (empty()) - return MachineInstrIndex(); + return LiveIndex(); return ranges.back().end; } - bool expiredAt(MachineInstrIndex index) const { + bool expiredAt(LiveIndex index) const { return index >= endIndex(); } - bool liveAt(MachineInstrIndex index) const; + bool liveAt(LiveIndex index) const; // 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 liveBeforeAndAt(MachineInstrIndex index) const; + bool liveBeforeAndAt(LiveIndex index) const; /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. - const LiveRange *getLiveRangeContaining(MachineInstrIndex Idx) const { + const LiveRange *getLiveRangeContaining(LiveIndex Idx) const { const_iterator I = FindLiveRangeContaining(Idx); return I == end() ? 0 : &*I; } /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. - LiveRange *getLiveRangeContaining(MachineInstrIndex Idx) { + LiveRange *getLiveRangeContaining(LiveIndex Idx) { iterator I = FindLiveRangeContaining(Idx); return I == end() ? 0 : &*I; } /// FindLiveRangeContaining - Return an iterator to the live range that /// contains the specified index, or end() if there is none. - const_iterator FindLiveRangeContaining(MachineInstrIndex Idx) const; + const_iterator FindLiveRangeContaining(LiveIndex Idx) const; /// FindLiveRangeContaining - Return an iterator to the live range that /// contains the specified index, or end() if there is none. - iterator FindLiveRangeContaining(MachineInstrIndex Idx); + iterator FindLiveRangeContaining(LiveIndex Idx); /// findDefinedVNInfo - Find the by the specified /// index (register interval) or defined - VNInfo *findDefinedVNInfoForRegInt(MachineInstrIndex Idx) const; + VNInfo *findDefinedVNInfoForRegInt(LiveIndex Idx) const; /// findDefinedVNInfo - Find the VNInfo that's defined by the specified /// register (stack inteval only). @@ -721,7 +721,7 @@ namespace llvm { /// overlaps - Return true if the live interval overlaps a range specified /// by [Start, End). - bool overlaps(MachineInstrIndex Start, MachineInstrIndex End) const; + bool overlaps(LiveIndex Start, LiveIndex End) const; /// overlapsFrom - Return true if the intersection of the two live intervals /// is not empty. The specified iterator is a hint that we can begin @@ -745,11 +745,11 @@ namespace llvm { /// isInOneLiveRange - Return true if the range specified is entirely in the /// a single LiveRange of the live interval. - bool isInOneLiveRange(MachineInstrIndex Start, MachineInstrIndex End); + bool isInOneLiveRange(LiveIndex Start, LiveIndex End); /// removeRange - Remove the specified range from this interval. Note that /// the range must be a single LiveRange in its entirety. - void removeRange(MachineInstrIndex Start, MachineInstrIndex End, + void removeRange(LiveIndex Start, LiveIndex End, bool RemoveDeadValNo = false); void removeRange(LiveRange LR, bool RemoveDeadValNo = false) { @@ -773,8 +773,8 @@ namespace llvm { void ComputeJoinedWeight(const LiveInterval &Other); bool operator<(const LiveInterval& other) const { - const MachineInstrIndex &thisIndex = beginIndex(); - const MachineInstrIndex &otherIndex = other.beginIndex(); + const LiveIndex &thisIndex = beginIndex(); + const LiveIndex &otherIndex = other.beginIndex(); return (thisIndex < otherIndex || (thisIndex == otherIndex && reg < other.reg)); } @@ -785,8 +785,8 @@ namespace llvm { private: Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From); - void extendIntervalEndTo(Ranges::iterator I, MachineInstrIndex NewEnd); - Ranges::iterator extendIntervalStartTo(Ranges::iterator I, MachineInstrIndex NewStr); + void extendIntervalEndTo(Ranges::iterator I, LiveIndex NewEnd); + Ranges::iterator extendIntervalStartTo(Ranges::iterator I, LiveIndex NewStr); LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT }; diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 3311788290..cf33d48afe 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -40,13 +40,13 @@ namespace llvm { class TargetInstrInfo; class TargetRegisterClass; class VirtRegMap; - typedef std::pair<MachineInstrIndex, MachineBasicBlock*> IdxMBBPair; + typedef std::pair<LiveIndex, MachineBasicBlock*> IdxMBBPair; - inline bool operator<(MachineInstrIndex V, const IdxMBBPair &IM) { + inline bool operator<(LiveIndex V, const IdxMBBPair &IM) { return V < IM.first; } - inline bool operator<(const IdxMBBPair &IM, MachineInstrIndex V) { + inline bool operator<(const IdxMBBPair &IM, LiveIndex V) { return IM.first < V; } @@ -71,7 +71,7 @@ namespace llvm { /// MBB2IdxMap - The indexes of the first and last instructions in the /// specified basic block. - std::vector<std::pair<MachineInstrIndex, MachineInstrIndex> > MBB2IdxMap; + std::vector<std::pair<LiveIndex, LiveIndex> > MBB2IdxMap; /// Idx2MBBMap - Sorted list of pairs of index of first instruction /// and MBB id. @@ -80,7 +80,7 @@ namespace llvm { /// FunctionSize - The number of instructions present in the function uint64_t FunctionSize; - typedef DenseMap<const MachineInstr*, MachineInstrIndex> Mi2IndexMap; + typedef DenseMap<const MachineInstr*, LiveIndex> Mi2IndexMap; Mi2IndexMap mi2iMap_; typedef std::vector<MachineInstr*> Index2MiMap; @@ -89,7 +89,7 @@ namespace llvm { typedef DenseMap<unsigned, LiveInterval*> Reg2IntervalMap; Reg2IntervalMap r2iMap_; - DenseMap<MachineBasicBlock*, MachineInstrIndex> terminatorGaps; + DenseMap<MachineBasicBlock*, LiveIndex> terminatorGaps; /// phiJoinCopies - Copy instructions which are PHI joins. SmallVector<MachineInstr*, 16> phiJoinCopies; @@ -106,39 +106,39 @@ namespace llvm { static char ID; // Pass identification, replacement for typeid LiveIntervals() : MachineFunctionPass(&ID) {} - MachineInstrIndex getBaseIndex(MachineInstrIndex index) { - return MachineInstrIndex(index, MachineInstrIndex::LOAD); + LiveIndex getBaseIndex(LiveIndex index) { + return LiveIndex(index, LiveIndex::LOAD); } - MachineInstrIndex getBoundaryIndex(MachineInstrIndex index) { - return MachineInstrIndex(index, - (MachineInstrIndex::Slot)(MachineInstrIndex::NUM - 1)); + LiveIndex getBoundaryIndex(LiveIndex index) { + return LiveIndex(index, + (LiveIndex::Slot)(LiveIndex::NUM - 1)); } - MachineInstrIndex getLoadIndex(MachineInstrIndex index) { - return MachineInstrIndex(index, MachineInstrIndex::LOAD); + LiveIndex getLoadIndex(LiveIndex index) { + return LiveIndex(index, LiveIndex::LOAD); } - MachineInstrIndex getUseIndex(MachineInstrIndex index) { - return MachineInstrIndex(index, MachineInstrIndex::USE); + LiveIndex getUseIndex(LiveIndex index) { + return LiveIndex(index, LiveIndex::USE); } - MachineInstrIndex getDefIndex(MachineInstrIndex index) { - return MachineInstrIndex(index, MachineInstrIndex::DEF); + LiveIndex getDefIndex(LiveIndex index) { + return LiveIndex(index, LiveIndex::DEF); } - MachineInstrIndex getStoreIndex(MachineInstrIndex index) { - return MachineInstrIndex(index, MachineInstrIndex::STORE); + LiveIndex getStoreIndex(LiveIndex index) { + return LiveIndex(index, LiveIndex::STORE); } - MachineInstrIndex getNextSlot(MachineInstrIndex m) const { + LiveIndex getNextSlot(LiveIndex m) const { return m.nextSlot_(); } - MachineInstrIndex getNextIndex(MachineInstrIndex m) const { + LiveIndex getNextIndex(LiveIndex m) const { return m.nextIndex_(); } - MachineInstrIndex getPrevSlot(MachineInstrIndex m) const { + LiveIndex getPrevSlot(LiveIndex m) const { return m.prevSlot_(); } - MachineInstrIndex getPrevIndex(MachineInstrIndex m) const { + LiveIndex getPrevIndex(LiveIndex m) const { return m.prevIndex_(); } @@ -172,20 +172,20 @@ namespace llvm { /// getMBBStartIdx - Return the base index of the first instruction in the /// specified MachineBasicBlock. - MachineInstrIndex getMBBStartIdx(MachineBasicBlock *MBB) const { + LiveIndex getMBBStartIdx(MachineBasicBlock *MBB) const { return getMBBStartIdx(MBB->getNumber()); } - MachineInstrIndex getMBBStartIdx(unsigned MBBNo) const { + LiveIndex getMBBStartIdx(unsigned MBBNo) const { assert(MBBNo < MBB2IdxMap.size() && "Invalid MBB number!"); return MBB2IdxMap[MBBNo].first; } /// getMBBEndIdx - Return the store index of the last instruction in the /// specified MachineBasicBlock. - MachineInstrIndex getMBBEndIdx(MachineBasicBlock *MBB) const { + LiveIndex getMBBEndIdx(MachineBasicBlock *MBB) const { return getMBBEndIdx(MBB->getNumber()); } - MachineInstrIndex getMBBEndIdx(unsigned MBBNo) const { + LiveIndex getMBBEndIdx(unsigned MBBNo) const { assert(MBBNo < MBB2IdxMap.size() && "Invalid MBB number!"); return MBB2IdxMap[MBBNo].second; } @@ -206,7 +206,7 @@ namespace llvm { /// getMBBFromIndex - given an index in any instruction of an /// MBB return a pointer the MBB - MachineBasicBlock* getMBBFromIndex(MachineInstrIndex index) const { + MachineBasicBlock* getMBBFromIndex(LiveIndex index) const { std::vector<IdxMBBPair>::const_iterator I = std::lower_bound(Idx2MBBMap.begin(), Idx2MBBMap.end(), index); // Take the pair containing the index @@ -221,7 +221,7 @@ namespace llvm { } /// getInstructionIndex - returns the base index of instr - MachineInstrIndex getInstructionIndex(const MachineInstr* instr) const { + LiveIndex getInstructionIndex(const MachineInstr* instr) const { Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); assert(it != mi2iMap_.end() && "Invalid instruction!"); return it->second; @@ -229,7 +229,7 @@ namespace llvm { /// getInstructionFromIndex - given an index in any slot of an /// instruction return a pointer the instruction - MachineInstr* getInstructionFromIndex(MachineInstrIndex index) const { + MachineInstr* getInstructionFromIndex(LiveIndex index) const { // convert index to vector index unsigned i = index.getVecIndex(); assert(i < i2miMap_.size() && @@ -239,14 +239,14 @@ namespace llvm { /// hasGapBeforeInstr - Return true if the previous instruction slot, /// i.e. Index - InstrSlots::NUM, is not occupied. - bool hasGapBeforeInstr(MachineInstrIndex Index) { + bool hasGapBeforeInstr(LiveIndex Index) { Index = getBaseIndex(getPrevIndex(Index)); return getInstructionFromIndex(Index) == 0; } /// hasGapAfterInstr - Return true if the successive instruction slot, /// i.e. Index + InstrSlots::Num, is not occupied. - bool hasGapAfterInstr(MachineInstrIndex Index) { + bool hasGapAfterInstr(LiveIndex Index) { Index = getBaseIndex(getNextIndex(Index)); return getInstructionFromIndex(Index) == 0; } @@ -254,14 +254,14 @@ namespace llvm { /// findGapBeforeInstr - Find an empty instruction slot before the /// specified index. If "Furthest" is true, find one that's furthest /// away from the index (but before any index that's occupied). - MachineInstrIndex findGapBeforeInstr(MachineInstrIndex Index, + LiveIndex findGapBeforeInstr(LiveIndex Index, bool Furthest = false) { Index = getBaseIndex(getPrevIndex(Index)); if (getInstructionFromIndex(Index)) - return MachineInstrIndex(); // No gap! + return LiveIndex(); // No gap! if (!Furthest) return Index; - MachineInstrIndex PrevIndex = getBaseIndex(getPrevIndex(Index)); + LiveIndex PrevIndex = getBaseIndex(getPrevIndex(Index)); while (getInstructionFromIndex(Index)) { Index = PrevIndex; PrevIndex = getBaseIndex(getPrevIndex(Index)); @@ -271,7 +271,7 @@ namespace llvm { /// InsertMachineInstrInMaps - Insert the specified machine instruction /// into the instruction index map at the given index. - void InsertMachineInstrInMaps(MachineInstr *MI, MachineInstrIndex Index) { + void InsertMachineInstrInMaps(MachineInstr *MI, LiveIndex Index) { i2miMap_[Index.getVecIndex()] = MI; Mi2IndexMap::iterator it = mi2iMap_.find(MI); assert(it == mi2iMap_.end() && "Already in map!"); @@ -292,12 +292,12 @@ namespace llvm { /// findLiveInMBBs - Given a live range, if the value of the range /// is live in any MBB returns true as well as the list of basic blocks /// in which the value is live. - bool findLiveInMBBs(MachineInstrIndex Start, MachineInstrIndex End, + bool findLiveInMBBs(LiveIndex Start, LiveIndex End, SmallVectorImpl<MachineBasicBlock*> &MBBs) const; /// findReachableMBBs - Return a list MBB that can be reached via any /// branch or fallthroughs. Return true if the list is not empty. - bool findReachableMBBs(MachineInstrIndex Start, MachineInstrIndex End, + bool findReachableMBBs(LiveIndex Start, LiveIndex End, SmallVectorImpl<MachineBasicBlock*> &MBBs) const; // Interval creation @@ -353,7 +353,7 @@ namespace llvm { i2miMap_[mi2i->second.index/InstrSlots::NUM] = NewMI; Mi2IndexMap::iterator it = mi2iMap_.find(MI); assert(it != mi2iMap_.end() && "Invalid instruction!"); - MachineInstrIndex Index = it->second; + LiveIndex Index = it->second; mi2iMap_.erase(it); mi2iMap_[NewMI] = Index; } @@ -444,14 +444,14 @@ namespace llvm { /// handleVirtualRegisterDef) void handleRegisterDef(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI, - MachineInstrIndex MIIdx, + LiveIndex MIIdx, MachineOperand& MO, unsigned MOIdx); /// handleVirtualRegisterDef - update intervals for a virtual /// register def void handleVirtualRegisterDef(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI, - MachineInstrIndex MIIdx, MachineOperand& MO, + LiveIndex MIIdx, MachineOperand& MO, unsigned MOIdx, LiveInterval& interval); @@ -459,13 +459,13 @@ namespace llvm { /// def. void handlePhysicalRegisterDef(MachineBasicBlock* mbb, MachineBasicBlock::iterator mi, - MachineInstrIndex MIIdx, MachineOperand& MO, + LiveIndex MIIdx, MachineOperand& MO, LiveInterval &interval, MachineInstr *CopyMI); /// handleLiveInRegister - Create interval for a livein register. void handleLiveInRegister(MachineBasicBlock* mbb, - MachineInstrIndex MIIdx, + LiveIndex MIIdx, LiveInterval &interval, bool isAlias = false); /// getReMatImplicitUse - If the remat definition MI has one (for now, we @@ -478,7 +478,7 @@ namespace llvm { /// which reaches the given instruction also reaches the specified use /// index. bool isValNoAvailableAt(const LiveInterval &li, MachineInstr *MI, - MachineInstrIndex UseIdx) const; + LiveIndex UseIdx) const; /// isReMaterializable - Returns true if the definition MI of the specified /// val# of the specified interval is re-materializable. Also returns true @@ -493,7 +493,7 @@ namespace llvm { /// MI. If it is successul, MI is updated with the newly created MI and /// returns true. bool tryFoldMemoryOperand(MachineInstr* &MI, VirtRegMap &vrm, - MachineInstr *DefMI, MachineInstrIndex InstrIdx, + MachineInstr *DefMI, LiveIndex InstrIdx, SmallVector<unsigned, 2> &Ops, bool isSS, int FrameIndex, unsigned Reg); @@ -507,7 +507,7 @@ namespace llvm { /// VNInfo that's after the specified index but is within the basic block. bool anyKillInMBBAfterIdx(const LiveInterval &li, const VNInfo *VNI, MachineBasicBlock *MBB, - MachineInstrIndex Idx) const; + LiveIndex Idx) const; /// hasAllocatableSuperReg - Return true if the specified physical register /// has any super register that's allocatable. @@ -515,17 +515,17 @@ namespace llvm { /// SRInfo - Spill / restore info. struct SRInfo { - MachineInstrIndex index; + LiveIndex index; unsigned vreg; bool canFold; - SRInfo(MachineInstrIndex i, unsigned vr, bool f) + SRInfo(LiveIndex i, unsigned vr, bool f) : index(i), vreg(vr), canFold(f) {} }; - bool alsoFoldARestore(int Id, MachineInstrIndex index, unsigned vr, + bool alsoFoldARestore(int Id, LiveIndex index, unsigned vr, BitVector &RestoreMBBs, DenseMap<unsigned,std::vector<SRInfo> >&RestoreIdxes); - void eraseRestoreInfo(int Id, MachineInstrIndex index, unsigned vr, + void eraseRestoreInfo(int Id, LiveIndex index, unsigned vr, BitVector &RestoreMBBs, DenseMap<unsigned,std::vector<SRInfo> >&RestoreIdxes); @@ -544,7 +544,7 @@ namespace llvm { /// functions for addIntervalsForSpills to rewrite uses / defs for the given /// live range. bool rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI, - bool TrySplit, MachineInstrIndex index, MachineInstrIndex end, + bool TrySplit, LiveIndex index, LiveIndex end, MachineInstr *MI, MachineInstr *OrigDefMI, MachineInstr *DefMI, unsigned Slot, int LdSlot, bool isLoad, bool isLoadSS, bool DefIsReMat, bool CanDelete, diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index 38b9401379..017c3c4be8 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -28,8 +28,8 @@ #include <algorithm> using namespace llvm; -// Print a MachineInstrIndex to a raw_ostream. -void MachineInstrIndex::print(raw_ostream &os) const { +// Print a LiveIndex to a raw_ostream. +void LiveIndex::print(raw_ostream &os) const { os << (index & ~PHI_BIT); } @@ -40,7 +40,7 @@ void MachineInstrIndex::print(raw_ostream &os) const { // variable it represents. This is because slot 1 is used (def slot) and spans // up to slot 3 (store slot). // -bool LiveInterval::liveAt(MachineInstrIndex I) const { +bool LiveInterval::liveAt(LiveIndex I) const { Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), I); if (r == ranges.begin()) @@ -53,7 +53,7 @@ bool LiveInterval::liveAt(MachineInstrIndex I) const { // 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(MachineInstrIndex I) const { +bool LiveInterval::liveBeforeAndAt(LiveIndex I) const { |