21 #ifndef LLVM_CODEGEN_LIVEINTERVAL_H
22 #define LLVM_CODEGEN_LIVEINTERVAL_H
36 class MachineRegisterInfo;
37 class TargetRegisterInfo;
39 template <
typename T,
unsigned Small>
class SmallPtrSet;
95 : EarlyVal(EarlyVal), LateVal(LateVal), EndPoint(EndPoint), Kill(Kill)
132 return EarlyVal == LateVal ?
nullptr : LateVal;
168 assert(S < E &&
"Cannot create empty or backwards segment");
178 assert((S < E) &&
"Backwards interval?");
229 "Copying of LiveRanges with active SegmentSets is not supported");
250 while (I->end <= Pos) ++
I;
258 while (I->end <= Pos) ++
I;
357 assert(!
empty() &&
"Call to beginIndex() on empty range.");
364 assert(!
empty() &&
"Call to endIndex() on empty range.");
374 return r !=
end() && r->start <= index;
381 return I ==
end() ?
nullptr : &*
I;
388 return I ==
end() ?
nullptr : &*
I;
394 return I ==
end() ?
nullptr : I->valno;
402 return I ==
end() ?
nullptr : I->valno;
409 return I !=
end() && I->start <= Idx ? I :
end();
414 return I !=
end() && I->start <= Idx ? I :
end();
462 const int *ValNoAssignments,
463 const int *RHSValNoAssignments,
478 bool RemoveDeadValNo =
false);
503 VNInfo *EarlyVal =
nullptr;
504 VNInfo *LateVal =
nullptr;
549 return thisIndex < otherIndex;
572 void append(
const LiveRange::Segment S);
576 void addSegmentToSet(
Segment S);
577 void markValNoForDeletion(
VNInfo *V);
602 :
Next(nullptr), LaneMask(LaneMask) {
608 :
LiveRange(Other, Allocator),
Next(nullptr), LaneMask(LaneMask) {
620 : SubRanges(nullptr),
reg(Reg),
weight(Weight) {}
641 return P != Other.operator->();
644 return P == Other.operator->();
682 appendSubRange(Range);
691 appendSubRange(Range);
697 return SubRanges !=
nullptr;
728 return std::tie(thisIndex,
reg) < std::tie(otherIndex, other.
reg);
740 void verify(
const MachineRegisterInfo *MRI =
nullptr)
const;
745 void appendSubRange(SubRange *Range) {
746 Range->Next = SubRanges;
751 void freeSubRange(SubRange *S);
759 raw_ostream &
operator<<(raw_ostream &OS,
const LiveRange::Segment &S);
846 void Connect(
unsigned a,
unsigned b);
void add(LiveRange::Segment)
Add a segment to LR and coalesce when possible, just like LR.addSegment().
void RenumberValues()
RenumberValues - Renumber all values in order of appearance and remove unused values.
void push_back(const T &Elt)
const_vni_iterator vni_end() const
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
void flush()
Flush the updater state to LR so it is valid and contains all added segments.
const_subrange_iterator subrange_begin() const
Segments::iterator iterator
VNInfo(unsigned i, SlotIndex d)
VNInfo constructor.
SlotIndex def
The index of the defining instruction.
bool contains(SlotIndex I) const
Return true if the index is covered by this segment.
SlotIndex getBoundaryIndex() const
Returns the boundary index for associated with this index.
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
void MergeValueInAsValue(const LiveRange &RHS, const VNInfo *RHSValNo, VNInfo *LHSValNo)
MergeValueInAsValue - Merge all of the segments of a specific val# in RHS into this live range as the...
Segment * getSegmentContaining(SlotIndex Idx)
Return the live segment that contains the specified index, or null if there is none.
LiveInterval - This class represents the liveness of a register, or stack slot.
bool isSpillable() const
isSpillable - Can this interval be spilled?
iterator advanceTo(iterator I, SlotIndex Pos)
advanceTo - Advance the specified iterator to point to the Segment containing the specified position...
void constructMainRangeFromSubranges(const SlotIndexes &Indexes, VNInfo::Allocator &VNIAllocator)
Construct main live range by merging the SubRanges of LI.
SubRange(unsigned LaneMask)
Constructs a new SubRange object.
bool isLocal(SlotIndex Start, SlotIndex End) const
True iff this segment is a single segment that lies between the specified boundaries, exclusively.
LiveRangeUpdater(LiveRange *lr=nullptr)
Create a LiveRangeUpdater for adding segments to LR.
bool isKill() const
Return true if the live-in value is killed by this instruction.
LiveInterval(unsigned Reg, float Weight)
A live range for subregisters.
This represents a simple continuous liveness interval for a value.
bool containsInterval(SlotIndex S, SlotIndex E) const
Return true if the given interval, [S, E), is covered by this segment.
SlotIndex endPoint() const
Return the end point of the last live range segment to interact with the instruction, if any.
bool operator<(const LiveInterval &other) const
void markUnused()
Mark this value as unused.
VNInfo - Value Number Information.
unsigned getNumValNums() const
void flushSegmentSet()
Flush segment set into the regular segment vector.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
This class represents the liveness of a register, stack slot, etc.
SubRange * createSubRangeFrom(BumpPtrAllocator &Allocator, unsigned LaneMask, const LiveRange &CopyFrom)
Like createSubRange() but the new range is filled with a copy of the liveness information in CopyFrom...
bool isDirty() const
Return true if the LR is currently in an invalid state, and flush() needs to be called.
static bool isEarlierInstr(SlotIndex A, SlotIndex B)
isEarlierInstr - Return true if A refers to an instruction earlier than B.
void removeEmptySubRanges()
Removes all subranges without any segments (subranges without segments are not considered valid and s...
const_iterator FindSegmentContaining(SlotIndex Idx) const
bool operator<(const LiveRange &other) const
A Use represents the edge between a Value definition and its users.
A helper class for register coalescers.
iterator_range< subrange_iterator > subranges()
Result of a LiveRange query.
SingleLinkedListIterator< T > & operator++()
Reg
All possible values of the reg field in the ModR/M byte.
unsigned Classify(const LiveInterval *LI)
Classify - Classify the values in LI into connected components.
bool operator<(const Segment &Other) const
bool isBlock() const
isBlock - Returns true if this is a block boundary slot.
unsigned getSize() const
getSize - Returns the sum of sizes of all the LiveRange's.
void print(raw_ostream &OS) const
bool isUnused() const
Returns true if this value is unused.
void MergeSegmentsInAsValue(const LiveRange &RHS, VNInfo *LHSValNo)
Merge all of the live segments of a specific val# in RHS into this live range as the specified value ...
SlotIndex getNextNonNullIndex(SlotIndex Index)
Returns the next non-null index, if one exists.
void Distribute(LiveInterval *LIV[], MachineRegisterInfo &MRI)
Distribute - Distribute values in LIV[0] into a separate LiveInterval for each connected component...
bool isDead() const
isDead - Returns true if this is a dead def kill slot.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
iterator addSegment(Segment S)
Add the specified Segment to this range, merging segments as appropriate.
LiveQueryResult(VNInfo *EarlyVal, VNInfo *LateVal, SlotIndex EndPoint, bool Kill)
VNInfo * MergeValueNumberInto(VNInfo *V1, VNInfo *V2)
MergeValueNumberInto - This method is called when two value numbers are found to be equivalent...
VNInfo * valueOutOrDead() const
Returns the value alive at the end of the instruction, if any.
VNInfo * extendInBlock(SlotIndex StartIdx, SlotIndex Use)
If this range is live before Use in the basic block that starts at StartIdx, extend it to be live up ...
LiveRange(const LiveRange &Other, BumpPtrAllocator &Allocator)
Constructs a new LiveRange object by copying segments and valnos from another LiveRange.
iterator_range< const_subrange_iterator > subranges() const
bool expiredAt(SlotIndex index) const
VNInfoList::const_iterator const_vni_iterator
const VNInfo * getValNumInfo(unsigned ValNo) const
const_iterator advanceTo(const_iterator I, SlotIndex Pos) const
void copyFrom(VNInfo &src)
Copy from the parameter into this VNInfo.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
bool isDeadDef() const
Return true if this instruction has a dead def.
void removeValNo(VNInfo *ValNo)
removeValNo - Remove all the segments defined by the specified value#.
bool hasAtLeastOneValue() const
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
bool isValid() const
Returns true if this is a valid index.
void removeSegment(Segment S, bool RemoveDeadValNo=false)
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
Allocate memory in an ever growing pool, as if by bump-pointer.
LiveRange(bool UseSegmentSet=false)
Constructs a new LiveRange object.
void setDest(LiveRange *lr)
Select a different destination live range.
const_iterator begin() const
bool overlaps(const LiveRange &other) const
overlaps - Return true if the intersection of the two live ranges is not empty.
void add(SlotIndex Start, SlotIndex End, VNInfo *VNI)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
VNInfo * valueDefined() const
Return the value defined by this instruction, if any.
void append(const LiveRange::Segment S)
Append a segment to the list of segments.
void verify() const
Walk the range and assert if any invariants fail to hold.
iterator removeSegment(iterator I)
Remove segment pointed to by iterator I from this range.
LiveRange * getDest() const
Get the current destination live range.
iterator erase(iterator I)
bool liveAt(SlotIndex index) const
VNInfoList::iterator vni_iterator
VNInfo(unsigned i, const VNInfo &orig)
VNInfo construtor, copies values from orig, except for the value number.
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
bool containsValue(const VNInfo *VNI) const
containsValue - Returns true if VNI belongs to this range.
bool operator==(const Segment &Other) const
iterator find(SlotIndex Pos)
find - Return an iterator pointing to the first segment that ends after Pos, or end().
VNInfo * valueOut() const
Return the value leaving the instruction, if any.
unsigned id
The ID number of this value.
void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
Remove the specified segment from this range.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
ConnectedVNInfoEqClasses(LiveIntervals &lis)
const_vni_iterator vni_begin() const
Segments::const_iterator const_iterator
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
BumpPtrAllocator Allocator
SingleLinkedListIterator< SubRange > subrange_iterator
ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a LiveInterval into equivalence cl...
bool operator==(const SingleLinkedListIterator< T > &Other)
std::unique_ptr< SegmentSet > segmentSet
void markNotSpillable()
markNotSpillable - Mark interval as not spillable
SingleLinkedListIterator< const SubRange > const_subrange_iterator
void clearSubRanges()
Removes all subregister liveness information.
A range adaptor for a pair of iterators.
bool isZeroLength(SlotIndexes *Indexes) const
Returns true if the live range is zero length, i.e.
SubRange(unsigned LaneMask, const LiveRange &Other, BumpPtrAllocator &Allocator)
Constructs a new SubRange object by copying liveness from Other.
VNInfo * getValNumInfo(unsigned ValNo)
getValNumInfo - Returns pointer to the specified val#.
bool containsOneValue() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
SlotIndex beginIndex() const
beginIndex - Return the lowest numbered slot covered.
SmallVector< Segment, 4 > Segments
void print(raw_ostream &OS) const
void print(raw_ostream &) const
VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
createDeadDef - Make sure the range has a value defined at Def.
SubRange * createSubRange(BumpPtrAllocator &Allocator, unsigned LaneMask)
Creates a new empty subregister live range.
SlotIndex endIndex() const
endNumber - return the maximum point of the range of the whole, exclusive.
const_subrange_iterator subrange_end() const
bool operator!=(const SingleLinkedListIterator< T > &Other)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
SmallVector< VNInfo *, 4 > VNInfoList
Helper class for performant LiveRange bulk updates.
std::set< Segment > SegmentSet
VNInfo * getNextValue(SlotIndex def, VNInfo::Allocator &VNInfoAllocator)
getNextValue - Create a new value number and return it.
bool operator<(int64_t V1, const APSInt &V2)
Segment(SlotIndex S, SlotIndex E, VNInfo *V)
This class implements an extremely fast bulk output stream that can only output to a stream...
subrange_iterator subrange_end()
SingleLinkedListIterator< T > & operator++(int)
void join(LiveRange &Other, const int *ValNoAssignments, const int *RHSValNoAssignments, SmallVectorImpl< VNInfo * > &NewVNInfo)
join - Join two live ranges (this, and other) together.
iterator FindSegmentContaining(SlotIndex Idx)
Return an iterator to the segment that contains the specified index, or end() if there is none...
VNInfo * valueIn() const
Return the value that is live-in to the instruction.
unsigned getEqClass(const VNInfo *VNI) const
getEqClass - Classify creates equivalence classes numbered 0..N.
const_iterator find(SlotIndex Pos) const
bool hasSubRanges() const
Returns true if subregister liveness information is available.
subrange_iterator subrange_begin()
SlotIndex - An opaque wrapper around machine indexes.
bool overlapsFrom(const LiveRange &Other, const_iterator I) const
overlapsFrom - Return true if the intersection of the two live ranges is not empty.
bool covers(const LiveRange &Other) const
Returns true if all segments of the Other live range are completely covered by this live range...
const_iterator end() const
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarilly including Idx...
VNInfo * createValueCopy(const VNInfo *orig, VNInfo::Allocator &VNInfoAllocator)
Create a copy of the given value.