21 #ifndef LLVM_CODEGEN_LIVEINTERVAL_H 22 #define LLVM_CODEGEN_LIVEINTERVAL_H 46 class MachineRegisterInfo;
99 : EarlyVal(EarlyVal), LateVal(LateVal), EndPoint(EndPoint), Kill(Kill)
124 return isDeadDef() ? nullptr : LateVal;
136 return EarlyVal == LateVal ? nullptr : LateVal;
171 : start(S), end(E), valno(V) {
172 assert(S < E &&
"Cannot create empty or backwards segment");
177 return start <= I && I <
end;
182 assert((S < E) &&
"Backwards interval?");
183 return (start <= S && S < end) && (start < E && E <=
end);
187 return std::tie(start, end) < std::tie(Other.
start, Other.
end);
190 return start == Other.
start && end == Other.
end;
235 "Copying of LiveRanges with active SegmentSets is not supported");
236 assign(Other, Allocator);
245 "Copying of LiveRanges with active SegmentSets is not supported");
248 createValueCopy(VNI, Allocator);
261 if (Pos >= endIndex())
263 while (I->end <= Pos) ++
I;
269 if (Pos >= endIndex())
271 while (I->end <= Pos) ++
I;
294 return segments.
size();
306 return valnos[ValNo];
309 return valnos[ValNo];
314 return VNI && VNI->
id < getNumValNums() && VNI == getValNumInfo(VNI->
id);
340 new (VNInfoAllocator)
VNInfo((
unsigned)valnos.
size(), *orig);
347 void RenumberValues();
367 void MergeValueInAsValue(
const LiveRange &RHS,
374 assert(!
empty() &&
"Call to beginIndex() on empty range.");
375 return segments.
front().start;
381 assert(!
empty() &&
"Call to endIndex() on empty range.");
382 return segments.
back().end;
386 return index >= endIndex();
391 return r !=
end() && r->start <= index;
398 return I ==
end() ? nullptr : &*
I;
405 return I ==
end() ? nullptr : &*
I;
411 return I ==
end() ? nullptr : I->valno;
419 return I ==
end() ? nullptr : I->valno;
426 return I !=
end() && I->start <= Idx ?
I :
end();
431 return I !=
end() && I->start <= Idx ?
I :
end();
439 return overlapsFrom(other, other.
begin());
463 bool covers(
const LiveRange &Other)
const;
498 const int *ValNoAssignments,
499 const int *RHSValNoAssignments,
514 bool RemoveDeadValNo =
false);
517 removeSegment(S.
start, S.
end, RemoveDeadValNo);
523 return segments.
erase(I);
539 VNInfo *EarlyVal =
nullptr;
540 VNInfo *LateVal =
nullptr;
570 void removeValNo(
VNInfo *ValNo);
575 for (
const Segment &S : segments)
588 const SlotIndex &thisIndex = beginIndex();
590 return thisIndex < otherIndex;
599 return Begin <= Idx && Idx < End;
607 void flushSegmentSet();
627 void addSegmentToSet(
Segment S);
628 void markValNoForDeletion(
VNInfo *V);
656 :
LiveRange(Other, Allocator), LaneMask(LaneMask) {}
693 return P != Other.operator->();
696 return P == Other.operator->();
724 return make_range(subrange_begin(), subrange_end());
728 return make_range(subrange_begin(), subrange_end());
736 appendSubRange(Range);
746 appendSubRange(Range);
752 return SubRanges !=
nullptr;
756 void clearSubRanges();
760 void removeEmptySubRanges();
764 unsigned getSize()
const;
797 const SlotIndex &thisIndex = beginIndex();
799 return std::tie(thisIndex, reg) < std::tie(otherIndex, other.
reg);
816 void appendSubRange(
SubRange *Range) {
817 Range->
Next = SubRanges;
888 if (LR != lr && isDirty())
943 #endif // LLVM_CODEGEN_LIVEINTERVAL_H std::set< Segment > SegmentSet
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
const_iterator end(StringRef path)
Get end iterator over path.
A common definition of LaneBitmask for use in TableGen and CodeGen.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
VNInfo(unsigned i, SlotIndex d)
VNInfo constructor.
typename SuperClass::const_iterator const_iterator
SlotIndex getBaseIndex() const
Returns the base index for associated with this index.
SlotIndex def
The index of the defining instruction.
This class represents lattice values for constants.
const_subrange_iterator subrange_begin() const
Segment * getSegmentContaining(SlotIndex Idx)
Return the live segment that contains the specified index, or null if there is none.
VNInfoList::iterator vni_iterator
Segments::iterator iterator
SubRange(LaneBitmask LaneMask)
Constructs a new SubRange object.
void push_back(const T &Elt)
bool isUndefIn(ArrayRef< SlotIndex > Undefs, SlotIndex Begin, SlotIndex End) const
Returns true if there is an explicit "undef" between Begin End.
LiveInterval - This class represents the liveness of a register, or stack slot.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
iterator advanceTo(iterator I, SlotIndex Pos)
advanceTo - Advance the specified iterator to point to the Segment containing the specified position...
bool isDead() const
isDead - Returns true if this is a dead def kill slot.
LiveRangeUpdater(LiveRange *lr=nullptr)
Create a LiveRangeUpdater for adding segments to LR.
bool isDeadDef() const
Return true if this instruction has a dead def.
LiveInterval(unsigned Reg, float Weight)
A live range for subregisters.
bool isValid() const
Returns true if this is a valid index.
This represents a simple continuous liveness interval for a value.
void markUnused()
Mark this value as unused.
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...
SubRange * createSubRangeFrom(BumpPtrAllocator &Allocator, LaneBitmask LaneMask, const LiveRange &CopyFrom)
Like createSubRange() but the new range is filled with a copy of the liveness information in CopyFrom...
VNInfo * valueOut() const
Return the value leaving the instruction, if any.
VNInfo - Value Number Information.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
const_iterator find(SlotIndex Pos) const
This class represents the liveness of a register, stack slot, etc.
bool isUnused() const
Returns true if this value is unused.
static bool isEarlierInstr(SlotIndex A, SlotIndex B)
isEarlierInstr - Return true if A refers to an instruction earlier than B.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
bool isBlock() const
isBlock - Returns true if this is a block boundary slot.
bool operator<(const Segment &Other) const
A helper class for register coalescers.
iterator_range< subrange_iterator > subranges()
Result of a LiveRange query.
const_iterator end() const
SingleLinkedListIterator< T > & operator++()
std::string join(IteratorT Begin, IteratorT End, StringRef Separator)
Joins the strings in the range [Begin, End), adding Separator between the elements.
bool hasSubRanges() const
Returns true if subregister liveness information is available.
unsigned getEqClass(const VNInfo *VNI) const
getEqClass - Classify creates equivalence classes numbered 0..N.
SlotIndex getNextNonNullIndex(SlotIndex Index)
Returns the next non-null index, if one exists.
bool contains(SlotIndex I) const
Return true if the index is covered by this segment.
const_iterator advanceTo(const_iterator I, SlotIndex Pos) const
LiveQueryResult(VNInfo *EarlyVal, VNInfo *LateVal, SlotIndex EndPoint, bool Kill)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool operator<(const LiveRange &other) const
const float huge_valf
Use this rather than HUGE_VALF; the latter causes warnings on MSVC.
LiveRange(const LiveRange &Other, BumpPtrAllocator &Allocator)
Constructs a new LiveRange object by copying segments and valnos from another LiveRange.
bool isKill() const
Return true if the live-in value is killed by this instruction.
bool isZeroLength(SlotIndexes *Indexes) const
Returns true if the live range is zero length, i.e.
void print(raw_ostream &OS) const
void copyFrom(VNInfo &src)
Copy from the parameter into this VNInfo.
VNInfo * valueIn() const
Return the value that is live-in to the instruction.
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
bool containsOneValue() const
iterator_range< const_subrange_iterator > subranges() const
BumpPtrAllocator Allocator
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
SubRange(LaneBitmask LaneMask, const LiveRange &Other, BumpPtrAllocator &Allocator)
Constructs a new SubRange object by copying liveness from Other.
SlotIndex endIndex() const
endNumber - return the maximum point of the range of the whole, exclusive.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
SubRange * createSubRange(BumpPtrAllocator &Allocator, LaneBitmask LaneMask)
Creates a new empty subregister live range.
void removeSegment(Segment S, bool RemoveDeadValNo=false)
unsigned const MachineRegisterInfo * MRI
VNInfoList::const_iterator const_vni_iterator
bool expiredAt(SlotIndex index) const
void print(raw_ostream &OS) const
Allocate memory in an ever growing pool, as if by bump-pointer.
bool liveAt(SlotIndex index) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
LiveRange(bool UseSegmentSet=false)
Constructs a new LiveRange object.
bool containsValue(const VNInfo *VNI) const
containsValue - Returns true if VNI belongs to this range.
void setDest(LiveRange *lr)
Select a different destination live range.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
void add(SlotIndex Start, SlotIndex End, VNInfo *VNI)
bool operator<(const LiveInterval &other) const
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
iterator removeSegment(iterator I)
Remove segment pointed to by iterator I from this range.
iterator erase(const_iterator CI)
void print(raw_ostream &) const
const_vni_iterator vni_begin() const
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
VNInfo(unsigned i, const VNInfo &orig)
VNInfo constructor, copies values from orig, except for the value number.
SlotIndex endPoint() const
Return the end point of the last live range segment to interact with the instruction, if any.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
const_iterator FindSegmentContaining(SlotIndex Idx) const
unsigned id
The ID number of this value.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
ConnectedVNInfoEqClasses(LiveIntervals &lis)
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
Segments::const_iterator const_iterator
ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a LiveInterval into equivalence cl...
bool isDirty() const
Return true if the LR is currently in an invalid state, and flush() needs to be called.
const_iterator begin() const
bool operator==(const SingleLinkedListIterator< T > &Other)
std::unique_ptr< SegmentSet > segmentSet
void markNotSpillable()
markNotSpillable - Mark interval as not spillable
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarilly including Idx...
A range adaptor for a pair of iterators.
bool hasAtLeastOneValue() const
VNInfo * valueOutOrDead() const
Returns the value alive at the end of the instruction, if any.
LiveRange * getDest() const
Get the current destination live range.
typename SuperClass::iterator iterator
VNInfo * getValNumInfo(unsigned ValNo)
getValNumInfo - Returns pointer to the specified val#.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
bool operator==(const Segment &Other) const
unsigned getNumValNums() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool overlaps(const LiveRange &other) const
overlaps - Return true if the intersection of the two live ranges is not empty.
void assign(const LiveRange &Other, BumpPtrAllocator &Allocator)
Copies values numbers and live segments from Other into this range.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
LLVM_NODISCARD bool empty() const
static void createDeadDef(SlotIndexes &Indexes, VNInfo::Allocator &Alloc, LiveRange &LR, const MachineOperand &MO)
bool operator!=(const SingleLinkedListIterator< T > &Other)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
const Segment * getSegmentContaining(SlotIndex Idx) const
Return the segment that contains the specified index, or null if there is none.
Helper class for performant LiveRange bulk updates.
VNInfo * getNextValue(SlotIndex def, VNInfo::Allocator &VNInfoAllocator)
getNextValue - Create a new value number and return it.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator<(int64_t V1, const APSInt &V2)
bool isSpillable() const
isSpillable - Can this interval be spilled?
const VNInfo * getValNumInfo(unsigned ValNo) const
SlotIndex beginIndex() const
beginIndex - Return the lowest numbered slot covered.
bool isLocal(SlotIndex Start, SlotIndex End) const
True iff this segment is a single segment that lies between the specified boundaries, exclusively.
const_subrange_iterator subrange_end() const
SingleLinkedListIterator< T > operator++(int)
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()
print Print MemDeps of function
iterator FindSegmentContaining(SlotIndex Idx)
Return an iterator to the segment that contains the specified index, or end() if there is none...
VNInfo * valueDefined() const
Return the value defined by this instruction, if any.
subrange_iterator subrange_begin()
void print(raw_ostream &OS) const
const_vni_iterator vni_end() const
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex getBoundaryIndex() const
Returns the boundary index for associated with this index.
VNInfo * createValueCopy(const VNInfo *orig, VNInfo::Allocator &VNInfoAllocator)
Create a copy of the given value.
bool containsInterval(SlotIndex S, SlotIndex E) const
Return true if the given interval, [S, E), is covered by this segment.