14 #define DEBUG_TYPE "regalloc"
23 InterferenceCache::BlockInterference InterferenceCache::Cursor::NoInterference;
34 for (
unsigned i = 0; i != CacheEntries; ++i)
35 Entries[i].clear(mf, indexes, lis);
38 InterferenceCache::Entry *InterferenceCache::get(
unsigned PhysReg) {
39 unsigned E = PhysRegEntries[PhysReg];
40 if (E < CacheEntries && Entries[E].getPhysReg() == PhysReg) {
41 if (!Entries[E].valid(LIUArray, TRI))
42 Entries[E].revalidate(LIUArray, TRI);
47 if (++RoundRobin == CacheEntries)
49 for (
unsigned i = 0; i != CacheEntries; ++i) {
51 if (Entries[E].hasRefs()) {
52 if (++E == CacheEntries)
56 Entries[E].reset(PhysReg, LIUArray, TRI, MF);
57 PhysRegEntries[PhysReg] = E;
72 RegUnits[i].VirtTag = LIUArray[*Units].getTag();
75 void InterferenceCache::Entry::reset(
unsigned physReg,
79 assert(!hasRefs() &&
"Cannot reset cache entry with references");
89 RegUnits.push_back(LIUArray[*Units]);
90 RegUnits.back().Fixed = &LIS->getRegUnit(*Units);
96 unsigned i = 0, e = RegUnits.size();
100 if (LIUArray[*Units].changedSince(RegUnits[i].VirtTag))
106 void InterferenceCache::Entry::update(
unsigned MBBNum) {
108 tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
111 if (PrevPos != Start) {
112 if (!PrevPos.isValid() || Start < PrevPos) {
113 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
114 RegUnitInfo &RUI = RegUnits[i];
115 RUI.VirtI.find(Start);
116 RUI.FixedI = RUI.Fixed->find(Start);
119 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
120 RegUnitInfo &RUI = RegUnits[i];
121 RUI.VirtI.advanceTo(Start);
122 if (RUI.FixedI != RUI.Fixed->end())
123 RUI.FixedI = RUI.Fixed->advanceTo(RUI.FixedI, Start);
130 BlockInterference *BI = &Blocks[MBBNum];
138 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
145 if (!BI->First.isValid() || StartI < BI->First)
150 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
158 if (!BI->First.isValid() || StartI < BI->First)
163 RegMaskSlots = LIS->getRegMaskSlotsInBlock(MBBNum);
164 RegMaskBits = LIS->getRegMaskBitsInBlock(MBBNum);
166 for (
unsigned i = 0, e = RegMaskSlots.
size();
167 i != e && RegMaskSlots[i] < Limit; ++i)
170 BI->First = RegMaskSlots[i];
175 if (BI->First.isValid())
179 if (++MFI == MF->
end())
181 MBBNum = MFI->getNumber();
182 BI = &Blocks[MBBNum];
185 tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
189 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
191 if (!I.valid() || I.start() >= Stop)
194 bool Backup = !I.valid() || I.start() >= Stop;
198 if (!BI->Last.isValid() || StopI > BI->Last)
205 for (
unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
208 if (I == LR->
end() || I->start >= Stop)
211 bool Backup = I == LR->
end() || I->start >= Stop;
215 if (!BI->Last.isValid() || StopI > BI->Last)
223 for (
unsigned i = RegMaskSlots.
size();
224 i && RegMaskSlots[i-1].getDeadSlot() > Limit; --i)
228 BI->Last = RegMaskSlots[i-1].getDeadSlot();
Segments::iterator iterator
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
iterator advanceTo(iterator I, SlotIndex Pos)
unsigned getNumBlockIDs() const
#define llvm_unreachable(msg)
void assign(unsigned NumElts, const T &Elt)
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
size_t size() const
size - Get the array size.
void init(MachineFunction *, LiveIntervalUnion *, SlotIndexes *, LiveIntervals *, const TargetRegisterInfo *)
init - Prepare cache for a new function.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
Segments::const_iterator const_iterator
MachineBasicBlock * getBlockNumbered(unsigned N) const
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
LiveSegments::iterator SegmentIter
SlotIndex - An opaque wrapper around machine indexes.
tier< T1, T2 > tie(T1 &f, T2 &s)