33 #define DEBUG_TYPE "regalloc" 36 const InterferenceCache::BlockInterference
37 InterferenceCache::Cursor::NoInterference;
48 if (PhysRegEntriesCount == TRI->
getNumRegs())
return;
51 PhysRegEntries =
static_cast<unsigned char*
>(
52 safe_calloc(PhysRegEntriesCount,
sizeof(
unsigned char)));
64 for (
unsigned i = 0; i != CacheEntries; ++i)
65 Entries[i].
clear(mf, indexes, lis);
68 InterferenceCache::Entry *InterferenceCache::get(
unsigned PhysReg) {
69 unsigned E = PhysRegEntries[PhysReg];
70 if (E < CacheEntries && Entries[E].getPhysReg() == PhysReg) {
71 if (!Entries[E].valid(LIUArray, TRI))
72 Entries[
E].revalidate(LIUArray, TRI);
77 if (++RoundRobin == CacheEntries)
79 for (
unsigned i = 0; i != CacheEntries; ++i) {
81 if (Entries[E].hasRefs()) {
82 if (++E == CacheEntries)
86 Entries[
E].reset(PhysReg, LIUArray, TRI, MF);
87 PhysRegEntries[PhysReg] =
E;
102 RegUnits[i].VirtTag = LIUArray[*Units].
getTag();
105 void InterferenceCache::Entry::reset(
unsigned physReg,
109 assert(!hasRefs() &&
"Cannot reset cache entry with references");
119 RegUnits.push_back(LIUArray[*Units]);
120 RegUnits.back().Fixed = &LIS->getRegUnit(*Units);
126 unsigned i = 0, e = RegUnits.size();
130 if (LIUArray[*Units].changedSince(RegUnits[i].VirtTag))
136 void InterferenceCache::Entry::update(
unsigned MBBNum) {
138 std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
141 if (PrevPos != Start) {
142 if (!PrevPos.isValid() || Start < PrevPos) {
143 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
144 RegUnitInfo &RUI = RegUnits[i];
145 RUI.VirtI.find(Start);
146 RUI.FixedI = RUI.Fixed->find(Start);
149 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
150 RegUnitInfo &RUI = RegUnits[i];
151 RUI.VirtI.advanceTo(Start);
152 if (RUI.FixedI != RUI.Fixed->end())
153 RUI.FixedI = RUI.Fixed->advanceTo(RUI.FixedI, Start);
161 BlockInterference *BI = &Blocks[MBBNum];
169 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
176 if (!BI->First.isValid() || StartI < BI->First)
181 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
189 if (!BI->First.isValid() || StartI < BI->First)
194 RegMaskSlots = LIS->getRegMaskSlotsInBlock(MBBNum);
195 RegMaskBits = LIS->getRegMaskBitsInBlock(MBBNum);
197 for (
unsigned i = 0, e = RegMaskSlots.
size();
198 i != e && RegMaskSlots[i] < Limit; ++i)
201 BI->First = RegMaskSlots[i];
206 if (BI->First.isValid())
210 if (++MFI == MF->
end())
212 MBBNum = MFI->getNumber();
213 BI = &Blocks[MBBNum];
216 std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
220 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
225 bool Backup = !I.
valid() || I.
start() >= Stop;
229 if (!BI->Last.isValid() || StopI > BI->Last)
236 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
239 if (I == LR->
end() || I->start >= Stop)
242 bool Backup = I == LR->
end() || I->start >= Stop;
246 if (!BI->Last.isValid() || StopI > BI->Last)
254 for (
unsigned i = RegMaskSlots.
size();
255 i && RegMaskSlots[i-1].getDeadSlot() > Limit; --i)
259 BI->Last = RegMaskSlots[i-1].getDeadSlot();
This class represents lattice values for constants.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
Segments::iterator iterator
iterator advanceTo(iterator I, SlotIndex Pos)
advanceTo - Advance the specified iterator to point to the Segment containing the specified position...
bool isValid() const
Returns true if this is a valid index.
bool valid() const
valid - Return true if the current position is valid, false for end().
This class represents the liveness of a register, stack slot, etc.
void init(MachineFunction *mf, LiveIntervalUnion *liuarray, SlotIndexes *indexes, LiveIntervals *lis, const TargetRegisterInfo *tri)
init - Prepare cache for a new function.
void advanceTo(KeyT x)
advanceTo - Move to the first interval with stop >= x, or end().
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
MachineBasicBlock * getBlockNumbered(unsigned N) const
getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the mach...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const KeyT & start() const
start - Return the beginning of the current interval.
Union of live intervals that are strong candidates for coalescing into a single register (either phys...
self_iterator getIterator()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Iterator for intrusive lists based on ilist_node.
Segments::const_iterator const_iterator
static Optional< unsigned > getTag(const TargetRegisterInfo *TRI, const MachineInstr &MI, const LoadInfo &LI)
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
static void clear(coro::Shape &Shape)
const KeyT & stop() const
stop - Return the end of the current interval.
void reinitPhysRegEntries()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
SlotIndex - An opaque wrapper around machine indexes.