32 #define DEBUG_TYPE "regalloc" 35 const InterferenceCache::BlockInterference
36 InterferenceCache::Cursor::NoInterference;
47 if (PhysRegEntriesCount == TRI->
getNumRegs())
return;
50 PhysRegEntries =
static_cast<unsigned char*
>(
51 safe_calloc(PhysRegEntriesCount,
sizeof(
unsigned char)));
63 for (
unsigned i = 0; i != CacheEntries; ++i)
64 Entries[i].
clear(mf, indexes, lis);
67 InterferenceCache::Entry *InterferenceCache::get(
unsigned PhysReg) {
68 unsigned E = PhysRegEntries[PhysReg];
69 if (E < CacheEntries && Entries[E].getPhysReg() == PhysReg) {
70 if (!Entries[E].valid(LIUArray, TRI))
71 Entries[
E].revalidate(LIUArray, TRI);
76 if (++RoundRobin == CacheEntries)
78 for (
unsigned i = 0; i != CacheEntries; ++i) {
80 if (Entries[E].hasRefs()) {
81 if (++E == CacheEntries)
85 Entries[
E].reset(PhysReg, LIUArray, TRI, MF);
86 PhysRegEntries[PhysReg] =
E;
101 RegUnits[i].VirtTag = LIUArray[*Units].
getTag();
104 void InterferenceCache::Entry::reset(
unsigned physReg,
108 assert(!hasRefs() &&
"Cannot reset cache entry with references");
118 RegUnits.push_back(LIUArray[*Units]);
119 RegUnits.back().Fixed = &LIS->getRegUnit(*Units);
125 unsigned i = 0,
e = RegUnits.size();
129 if (LIUArray[*Units].changedSince(RegUnits[i].VirtTag))
135 void InterferenceCache::Entry::update(
unsigned MBBNum) {
137 std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
140 if (PrevPos != Start) {
141 if (!PrevPos.isValid() || Start < PrevPos) {
142 for (
unsigned i = 0,
e = RegUnits.size(); i !=
e; ++i) {
143 RegUnitInfo &RUI = RegUnits[i];
144 RUI.VirtI.find(Start);
145 RUI.FixedI = RUI.Fixed->find(Start);
148 for (
unsigned i = 0,
e = RegUnits.size(); i !=
e; ++i) {
149 RegUnitInfo &RUI = RegUnits[i];
150 RUI.VirtI.advanceTo(Start);
151 if (RUI.FixedI != RUI.Fixed->end())
152 RUI.FixedI = RUI.Fixed->advanceTo(RUI.FixedI, Start);
160 BlockInterference *BI = &Blocks[MBBNum];
168 for (
unsigned i = 0,
e = RegUnits.size(); i !=
e; ++i) {
175 if (!BI->First.isValid() || StartI < BI->First)
180 for (
unsigned i = 0,
e = RegUnits.size(); i !=
e; ++i) {
188 if (!BI->First.isValid() || StartI < BI->First)
193 RegMaskSlots = LIS->getRegMaskSlotsInBlock(MBBNum);
194 RegMaskBits = LIS->getRegMaskBitsInBlock(MBBNum);
196 for (
unsigned i = 0,
e = RegMaskSlots.
size();
197 i !=
e && RegMaskSlots[i] < Limit; ++i)
200 BI->First = RegMaskSlots[i];
205 if (BI->First.isValid())
209 if (++MFI == MF->
end())
211 MBBNum = MFI->getNumber();
212 BI = &Blocks[MBBNum];
215 std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
219 for (
unsigned i = 0,
e = RegUnits.size(); i !=
e; ++i) {
224 bool Backup = !I.
valid() || I.
start() >= Stop;
228 if (!BI->Last.isValid() || StopI > BI->Last)
235 for (
unsigned i = 0,
e = RegUnits.size(); i !=
e; ++i) {
238 if (I == LR->
end() || I->start >= Stop)
241 bool Backup = I == LR->
end() || I->start >= Stop;
245 if (!BI->Last.isValid() || StopI > BI->Last)
253 for (
unsigned i = RegMaskSlots.
size();
254 i && RegMaskSlots[i-1].getDeadSlot() > Limit; --i)
258 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.