mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-03 11:08:32 +00:00
LIU:::Query: Query LiveRange instead of LiveInterval; NFC
- We only need the information from the base class, not the additional details in the LiveInterval class. - Spread more `const` - Some code cleanup git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296684 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4c3428b604
commit
a9e2ca030f
@ -57,6 +57,9 @@ public:
|
||||
// to reach the current segment's containing virtual register.
|
||||
typedef LiveSegments::iterator SegmentIter;
|
||||
|
||||
/// Const version of SegmentIter.
|
||||
typedef LiveSegments::const_iterator ConstSegmentIter;
|
||||
|
||||
// LiveIntervalUnions share an external allocator.
|
||||
typedef LiveSegments::Allocator Allocator;
|
||||
|
||||
@ -72,12 +75,16 @@ public:
|
||||
SegmentIter begin() { return Segments.begin(); }
|
||||
SegmentIter end() { return Segments.end(); }
|
||||
SegmentIter find(SlotIndex x) { return Segments.find(x); }
|
||||
ConstSegmentIter begin() const { return Segments.begin(); }
|
||||
ConstSegmentIter end() const { return Segments.end(); }
|
||||
ConstSegmentIter find(SlotIndex x) const { return Segments.find(x); }
|
||||
|
||||
bool empty() const { return Segments.empty(); }
|
||||
SlotIndex startIndex() const { return Segments.start(); }
|
||||
|
||||
// Provide public access to the underlying map to allow overlap iteration.
|
||||
typedef LiveSegments Map;
|
||||
const Map &getMap() { return Segments; }
|
||||
const Map &getMap() const { return Segments; }
|
||||
|
||||
/// getTag - Return an opaque tag representing the current state of the union.
|
||||
unsigned getTag() const { return Tag; }
|
||||
@ -105,45 +112,42 @@ public:
|
||||
/// Query interferences between a single live virtual register and a live
|
||||
/// interval union.
|
||||
class Query {
|
||||
LiveIntervalUnion *LiveUnion = nullptr;
|
||||
LiveInterval *VirtReg = nullptr;
|
||||
LiveInterval::iterator VirtRegI; // current position in VirtReg
|
||||
SegmentIter LiveUnionI; // current position in LiveUnion
|
||||
const LiveIntervalUnion *LiveUnion = nullptr;
|
||||
const LiveRange *LR = nullptr;
|
||||
LiveRange::const_iterator LRI; ///< current position in LR
|
||||
ConstSegmentIter LiveUnionI; ///< current position in LiveUnion
|
||||
SmallVector<LiveInterval*,4> InterferingVRegs;
|
||||
bool CheckedFirstInterference = false;
|
||||
bool SeenAllInterferences = false;
|
||||
unsigned Tag = 0;
|
||||
unsigned UserTag = 0;
|
||||
|
||||
public:
|
||||
Query() = default;
|
||||
Query(LiveInterval *VReg, LiveIntervalUnion *LIU):
|
||||
LiveUnion(LIU), VirtReg(VReg) {}
|
||||
Query(const Query &) = delete;
|
||||
Query &operator=(const Query &) = delete;
|
||||
|
||||
void clear() {
|
||||
LiveUnion = nullptr;
|
||||
VirtReg = nullptr;
|
||||
void reset(unsigned NewUserTag, const LiveRange &NewLR,
|
||||
const LiveIntervalUnion &NewLiveUnion) {
|
||||
LiveUnion = &NewLiveUnion;
|
||||
LR = &NewLR;
|
||||
InterferingVRegs.clear();
|
||||
CheckedFirstInterference = false;
|
||||
SeenAllInterferences = false;
|
||||
Tag = 0;
|
||||
UserTag = 0;
|
||||
Tag = NewLiveUnion.getTag();
|
||||
UserTag = NewUserTag;
|
||||
}
|
||||
|
||||
void init(unsigned UTag, LiveInterval *VReg, LiveIntervalUnion *LIU) {
|
||||
assert(VReg && LIU && "Invalid arguments");
|
||||
if (UserTag == UTag && VirtReg == VReg &&
|
||||
LiveUnion == LIU && !LIU->changedSince(Tag)) {
|
||||
public:
|
||||
Query() = default;
|
||||
Query(const LiveRange &LR, const LiveIntervalUnion &LIU):
|
||||
LiveUnion(&LIU), LR(&LR) {}
|
||||
Query(const Query &) = delete;
|
||||
Query &operator=(const Query &) = delete;
|
||||
|
||||
void init(unsigned NewUserTag, const LiveRange &NewLR,
|
||||
const LiveIntervalUnion &NewLiveUnion) {
|
||||
if (UserTag == NewUserTag && LR == &NewLR && LiveUnion == &NewLiveUnion &&
|
||||
!NewLiveUnion.changedSince(Tag)) {
|
||||
// Retain cached results, e.g. firstInterference.
|
||||
return;
|
||||
}
|
||||
clear();
|
||||
LiveUnion = LIU;
|
||||
VirtReg = VReg;
|
||||
Tag = LIU->getTag();
|
||||
UserTag = UTag;
|
||||
reset(NewUserTag, NewLR, NewLiveUnion);
|
||||
}
|
||||
|
||||
// Does this live virtual register interfere with the union?
|
||||
|
@ -126,25 +126,24 @@ collectInterferingVRegs(unsigned MaxInterferingRegs) {
|
||||
CheckedFirstInterference = true;
|
||||
|
||||
// Quickly skip interference check for empty sets.
|
||||
if (VirtReg->empty() || LiveUnion->empty()) {
|
||||
if (LR->empty() || LiveUnion->empty()) {
|
||||
SeenAllInterferences = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// In most cases, the union will start before VirtReg.
|
||||
VirtRegI = VirtReg->begin();
|
||||
// In most cases, the union will start before LR.
|
||||
LRI = LR->begin();
|
||||
LiveUnionI.setMap(LiveUnion->getMap());
|
||||
LiveUnionI.find(VirtRegI->start);
|
||||
LiveUnionI.find(LRI->start);
|
||||
}
|
||||
|
||||
LiveInterval::iterator VirtRegEnd = VirtReg->end();
|
||||
LiveRange::const_iterator LREnd = LR->end();
|
||||
LiveInterval *RecentReg = nullptr;
|
||||
while (LiveUnionI.valid()) {
|
||||
assert(VirtRegI != VirtRegEnd && "Reached end of VirtReg");
|
||||
assert(LRI != LREnd && "Reached end of LR");
|
||||
|
||||
// Check for overlapping interference.
|
||||
while (VirtRegI->start < LiveUnionI.stop() &&
|
||||
VirtRegI->end > LiveUnionI.start()) {
|
||||
while (LRI->start < LiveUnionI.stop() && LRI->end > LiveUnionI.start()) {
|
||||
// This is an overlap, record the interfering register.
|
||||
LiveInterval *VReg = LiveUnionI.value();
|
||||
if (VReg != RecentReg && !isSeenInterference(VReg)) {
|
||||
@ -161,20 +160,20 @@ collectInterferingVRegs(unsigned MaxInterferingRegs) {
|
||||
}
|
||||
|
||||
// The iterators are now not overlapping, LiveUnionI has been advanced
|
||||
// beyond VirtRegI.
|
||||
assert(VirtRegI->end <= LiveUnionI.start() && "Expected non-overlap");
|
||||
// beyond LRI.
|
||||
assert(LRI->end <= LiveUnionI.start() && "Expected non-overlap");
|
||||
|
||||
// Advance the iterator that ends first.
|
||||
VirtRegI = VirtReg->advanceTo(VirtRegI, LiveUnionI.start());
|
||||
if (VirtRegI == VirtRegEnd)
|
||||
LRI = LR->advanceTo(LRI, LiveUnionI.start());
|
||||
if (LRI == LREnd)
|
||||
break;
|
||||
|
||||
// Detect overlap, handle above.
|
||||
if (VirtRegI->start < LiveUnionI.stop())
|
||||
if (LRI->start < LiveUnionI.stop())
|
||||
continue;
|
||||
|
||||
// Still not overlapping. Catch up LiveUnionI.
|
||||
LiveUnionI.advanceTo(VirtRegI->start);
|
||||
LiveUnionI.advanceTo(LRI->start);
|
||||
}
|
||||
SeenAllInterferences = true;
|
||||
return InterferingVRegs.size();
|
||||
|
@ -178,7 +178,7 @@ bool LiveRegMatrix::checkRegUnitInterference(LiveInterval &VirtReg,
|
||||
LiveIntervalUnion::Query &LiveRegMatrix::query(LiveInterval &VirtReg,
|
||||
unsigned RegUnit) {
|
||||
LiveIntervalUnion::Query &Q = Queries[RegUnit];
|
||||
Q.init(UserTag, &VirtReg, &Matrix[RegUnit]);
|
||||
Q.init(UserTag, VirtReg, Matrix[RegUnit]);
|
||||
return Q;
|
||||
}
|
||||
|
||||
|
@ -698,7 +698,7 @@ unsigned RAGreedy::canReassign(LiveInterval &VirtReg, unsigned PrevReg) {
|
||||
MCRegUnitIterator Units(PhysReg, TRI);
|
||||
for (; Units.isValid(); ++Units) {
|
||||
// Instantiate a "subquery", not to be confused with the Queries array.
|
||||
LiveIntervalUnion::Query subQ(&VirtReg, &Matrix->getLiveUnions()[*Units]);
|
||||
LiveIntervalUnion::Query subQ(VirtReg, Matrix->getLiveUnions()[*Units]);
|
||||
if (subQ.checkInterference())
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user