26#define DEBUG_TYPE "regalloc"
40 while (SegPos.valid()) {
41 SegPos.insert(RegPos->start, RegPos->end, &VirtReg);
42 if (++RegPos == RegEnd)
44 SegPos.advanceTo(RegPos->start);
51 SegPos.insert(RegEnd->start, RegEnd->end, &VirtReg);
52 for (; RegPos != RegEnd; ++RegPos, ++SegPos)
53 SegPos.insert(RegPos->start, RegPos->end, &VirtReg);
69 assert(SegPos.value() == &VirtReg &&
"Inconsistent LiveInterval");
75 RegPos =
Range.advanceTo(RegPos, SegPos.start());
79 SegPos.advanceTo(RegPos->start);
88 for (
SegmentIter SegPos = Segments.begin(); SegPos.valid();) {
89 if (SegPos.value()->reg() == VirtRegLI.
reg())
102 for (LiveSegments::const_iterator
SI = Segments.begin();
SI.valid(); ++
SI) {
103 OS <<
" [" <<
SI.start() <<
' ' <<
SI.stop()
113 VisitedVRegs.
set(
SI.value()->reg().id());
120 for (LiveSegments::const_iterator
SI = Segments.begin();
SI.valid(); ++
SI) {
129bool LiveIntervalUnion::Query::isSeenInterference(
144LiveIntervalUnion::Query::collectInterferingVRegs(
unsigned MaxInterferingRegs) {
146 if (SeenAllInterferences || InterferingVRegs.size() >= MaxInterferingRegs)
147 return InterferingVRegs.size();
150 if (!CheckedFirstInterference) {
151 CheckedFirstInterference =
true;
154 if (LR->empty() || LiveUnion->empty()) {
155 SeenAllInterferences =
true;
161 LiveUnionI.setMap(LiveUnion->getMap());
162 LiveUnionI.find(LRI->start);
166 const LiveInterval *RecentReg =
nullptr;
167 while (LiveUnionI.valid()) {
168 assert(LRI != LREnd &&
"Reached end of LR");
171 while (LRI->start < LiveUnionI.stop() && LRI->end > LiveUnionI.start()) {
173 const LiveInterval *VReg = LiveUnionI.value();
174 if (VReg != RecentReg && !isSeenInterference(VReg)) {
176 InterferingVRegs.push_back(VReg);
177 if (InterferingVRegs.size() >= MaxInterferingRegs)
178 return InterferingVRegs.
size();
181 if (!(++LiveUnionI).valid()) {
182 SeenAllInterferences =
true;
183 return InterferingVRegs.size();
189 assert(LRI->end <= LiveUnionI.start() &&
"Expected non-overlap");
192 LRI = LR->advanceTo(LRI, LiveUnionI.start());
197 if (LRI->start < LiveUnionI.stop())
201 LiveUnionI.advanceTo(LRI->start);
203 SeenAllInterferences =
true;
204 return InterferingVRegs.size();
216 for (
unsigned i = 0; i != Size; ++i)
223 for (
unsigned i = 0; i != Size; ++i)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Register const TargetRegisterInfo * TRI
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the SparseBitVector class.
LLVM_ABI void init(LiveIntervalUnion::Allocator &, unsigned Size)
LiveIntervalUnion(Allocator &a)
LLVM_ABI void unify(const LiveInterval &VirtReg, const LiveRange &Range)
LLVM_ABI const LiveInterval * getOneVReg() const
NDEBUG.
LLVM_ABI void extract(const LiveInterval &VirtReg, const LiveRange &Range)
LiveSegments::iterator SegmentIter
void verify(LiveVirtRegBitSet &VisitedVRegs)
LLVM_ABI void print(raw_ostream &OS, const TargetRegisterInfo *TRI) const
LLVM_ABI void clearAllSegmentsReferencing(const LiveInterval &VirtRegLI)
LiveSegments::Allocator Allocator
LiveInterval - This class represents the liveness of a register, or stack slot.
This class represents the liveness of a register, stack slot, etc.
Segments::const_iterator const_iterator
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
SparseBitVector< 128 > LiveVirtRegBitSet
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.