forked from OSchip/llvm-project
Fix some style issues in PBQP. Patch by David Blaikie.
llvm-svn: 118883
This commit is contained in:
parent
cabd1b71c7
commit
c702ba6ca1
|
@ -238,11 +238,13 @@ std::auto_ptr<PBQPRAProblem> PBQPBuilder::build(MachineFunction *mf,
|
||||||
unsigned preg = *pregItr;
|
unsigned preg = *pregItr;
|
||||||
const LiveInterval *pregLI = &lis->getInterval(preg);
|
const LiveInterval *pregLI = &lis->getInterval(preg);
|
||||||
|
|
||||||
if (pregLI->empty())
|
if (pregLI->empty()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!vregLI->overlaps(*pregLI))
|
if (!vregLI->overlaps(*pregLI)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the register from the allowed set.
|
// Remove the register from the allowed set.
|
||||||
VRAllowed::iterator eraseItr =
|
VRAllowed::iterator eraseItr =
|
||||||
|
@ -318,10 +320,10 @@ void PBQPBuilder::addInterferenceCosts(
|
||||||
assert(costMat.getRows() == vr1Allowed.size() + 1 && "Matrix height mismatch.");
|
assert(costMat.getRows() == vr1Allowed.size() + 1 && "Matrix height mismatch.");
|
||||||
assert(costMat.getCols() == vr2Allowed.size() + 1 && "Matrix width mismatch.");
|
assert(costMat.getCols() == vr2Allowed.size() + 1 && "Matrix width mismatch.");
|
||||||
|
|
||||||
for (unsigned i = 0; i < vr1Allowed.size(); ++i) {
|
for (unsigned i = 0; i != vr1Allowed.size(); ++i) {
|
||||||
unsigned preg1 = vr1Allowed[i];
|
unsigned preg1 = vr1Allowed[i];
|
||||||
|
|
||||||
for (unsigned j = 0; j < vr2Allowed.size(); ++j) {
|
for (unsigned j = 0; j != vr2Allowed.size(); ++j) {
|
||||||
unsigned preg2 = vr2Allowed[j];
|
unsigned preg2 = vr2Allowed[j];
|
||||||
|
|
||||||
if (tri->regsOverlap(preg1, preg2)) {
|
if (tri->regsOverlap(preg1, preg2)) {
|
||||||
|
@ -355,11 +357,13 @@ std::auto_ptr<PBQPRAProblem> PBQPBuilderWithCoalescing::build(
|
||||||
miItr != miEnd; ++miItr) {
|
miItr != miEnd; ++miItr) {
|
||||||
const MachineInstr *mi = &*miItr;
|
const MachineInstr *mi = &*miItr;
|
||||||
|
|
||||||
if (!cp.setRegisters(mi))
|
if (!cp.setRegisters(mi)) {
|
||||||
continue; // Not coalescable.
|
continue; // Not coalescable.
|
||||||
|
}
|
||||||
|
|
||||||
if (cp.getSrcReg() == cp.getDstReg())
|
if (cp.getSrcReg() == cp.getDstReg()) {
|
||||||
continue; // Already coalesced.
|
continue; // Already coalesced.
|
||||||
|
}
|
||||||
|
|
||||||
unsigned dst = cp.getDstReg(),
|
unsigned dst = cp.getDstReg(),
|
||||||
src = cp.getSrcReg();
|
src = cp.getSrcReg();
|
||||||
|
@ -372,13 +376,15 @@ std::auto_ptr<PBQPRAProblem> PBQPBuilderWithCoalescing::build(
|
||||||
loopInfo->getLoopDepth(mbb));
|
loopInfo->getLoopDepth(mbb));
|
||||||
|
|
||||||
if (cp.isPhys()) {
|
if (cp.isPhys()) {
|
||||||
if (!lis->isAllocatable(dst))
|
if (!lis->isAllocatable(dst)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const PBQPRAProblem::AllowedSet &allowed = p->getAllowedSet(src);
|
const PBQPRAProblem::AllowedSet &allowed = p->getAllowedSet(src);
|
||||||
unsigned pregOpt = 0;
|
unsigned pregOpt = 0;
|
||||||
while (pregOpt < allowed.size() && allowed[pregOpt] != dst)
|
while (pregOpt < allowed.size() && allowed[pregOpt] != dst) {
|
||||||
++pregOpt;
|
++pregOpt;
|
||||||
|
}
|
||||||
if (pregOpt < allowed.size()) {
|
if (pregOpt < allowed.size()) {
|
||||||
++pregOpt; // +1 to account for spill option.
|
++pregOpt; // +1 to account for spill option.
|
||||||
PBQP::Graph::NodeItr node = p->getNodeForVReg(src);
|
PBQP::Graph::NodeItr node = p->getNodeForVReg(src);
|
||||||
|
@ -425,9 +431,9 @@ void PBQPBuilderWithCoalescing::addVirtRegCoalesce(
|
||||||
assert(costMat.getRows() == vr1Allowed.size() + 1 && "Size mismatch.");
|
assert(costMat.getRows() == vr1Allowed.size() + 1 && "Size mismatch.");
|
||||||
assert(costMat.getCols() == vr2Allowed.size() + 1 && "Size mismatch.");
|
assert(costMat.getCols() == vr2Allowed.size() + 1 && "Size mismatch.");
|
||||||
|
|
||||||
for (unsigned i = 0; i < vr1Allowed.size(); ++i) {
|
for (unsigned i = 0; i != vr1Allowed.size(); ++i) {
|
||||||
unsigned preg1 = vr1Allowed[i];
|
unsigned preg1 = vr1Allowed[i];
|
||||||
for (unsigned j = 0; j < vr2Allowed.size(); ++j) {
|
for (unsigned j = 0; j != vr2Allowed.size(); ++j) {
|
||||||
unsigned preg2 = vr2Allowed[j];
|
unsigned preg2 = vr2Allowed[j];
|
||||||
|
|
||||||
if (preg1 == preg2) {
|
if (preg1 == preg2) {
|
||||||
|
@ -473,8 +479,7 @@ void RegAllocPBQP::findVRegIntervalsToAlloc() {
|
||||||
// finalizeAlloc.
|
// finalizeAlloc.
|
||||||
if (!li->empty()) {
|
if (!li->empty()) {
|
||||||
vregsToAlloc.insert(li->reg);
|
vregsToAlloc.insert(li->reg);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
emptyIntervalVRegs.insert(li->reg);
|
emptyIntervalVRegs.insert(li->reg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,18 +489,20 @@ void RegAllocPBQP::addStackInterval(const LiveInterval *spilled,
|
||||||
MachineRegisterInfo* mri) {
|
MachineRegisterInfo* mri) {
|
||||||
int stackSlot = vrm->getStackSlot(spilled->reg);
|
int stackSlot = vrm->getStackSlot(spilled->reg);
|
||||||
|
|
||||||
if (stackSlot == VirtRegMap::NO_STACK_SLOT)
|
if (stackSlot == VirtRegMap::NO_STACK_SLOT) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const TargetRegisterClass *RC = mri->getRegClass(spilled->reg);
|
const TargetRegisterClass *RC = mri->getRegClass(spilled->reg);
|
||||||
LiveInterval &stackInterval = lss->getOrCreateInterval(stackSlot, RC);
|
LiveInterval &stackInterval = lss->getOrCreateInterval(stackSlot, RC);
|
||||||
|
|
||||||
VNInfo *vni;
|
VNInfo *vni;
|
||||||
if (stackInterval.getNumValNums() != 0)
|
if (stackInterval.getNumValNums() != 0) {
|
||||||
vni = stackInterval.getValNumInfo(0);
|
vni = stackInterval.getValNumInfo(0);
|
||||||
else
|
} else {
|
||||||
vni = stackInterval.getNextValue(
|
vni = stackInterval.getNextValue(
|
||||||
SlotIndex(), 0, lss->getVNInfoAllocator());
|
SlotIndex(), 0, lss->getVNInfoAllocator());
|
||||||
|
}
|
||||||
|
|
||||||
LiveInterval &rhsInterval = lis->getInterval(spilled->reg);
|
LiveInterval &rhsInterval = lis->getInterval(spilled->reg);
|
||||||
stackInterval.MergeRangesInAsValue(rhsInterval, vni);
|
stackInterval.MergeRangesInAsValue(rhsInterval, vni);
|
||||||
|
@ -594,11 +601,9 @@ void RegAllocPBQP::finalizeAlloc() const {
|
||||||
// Get the physical register for this interval
|
// Get the physical register for this interval
|
||||||
if (TargetRegisterInfo::isPhysicalRegister(li->reg)) {
|
if (TargetRegisterInfo::isPhysicalRegister(li->reg)) {
|
||||||
reg = li->reg;
|
reg = li->reg;
|
||||||
}
|
} else if (vrm->isAssignedReg(li->reg)) {
|
||||||
else if (vrm->isAssignedReg(li->reg)) {
|
|
||||||
reg = vrm->getPhys(li->reg);
|
reg = vrm->getPhys(li->reg);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Ranges which are assigned a stack slot only are ignored.
|
// Ranges which are assigned a stack slot only are ignored.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +620,7 @@ void RegAllocPBQP::finalizeAlloc() const {
|
||||||
// Find the set of basic blocks which this range is live into...
|
// Find the set of basic blocks which this range is live into...
|
||||||
if (lis->findLiveInMBBs(lrItr->start, lrItr->end, liveInMBBs)) {
|
if (lis->findLiveInMBBs(lrItr->start, lrItr->end, liveInMBBs)) {
|
||||||
// And add the physreg for this interval to their live-in sets.
|
// And add the physreg for this interval to their live-in sets.
|
||||||
for (unsigned i = 0; i < liveInMBBs.size(); ++i) {
|
for (unsigned i = 0; i != liveInMBBs.size(); ++i) {
|
||||||
if (liveInMBBs[i] != entryMBB) {
|
if (liveInMBBs[i] != entryMBB) {
|
||||||
if (!liveInMBBs[i]->isLiveIn(reg)) {
|
if (!liveInMBBs[i]->isLiveIn(reg)) {
|
||||||
liveInMBBs[i]->addLiveIn(reg);
|
liveInMBBs[i]->addLiveIn(reg);
|
||||||
|
|
Loading…
Reference in New Issue