mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-13 08:26:02 +00:00
Whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86855 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -63,7 +63,6 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BranchFolder::BranchFolder(bool defaultEnableTailMerge) {
|
BranchFolder::BranchFolder(bool defaultEnableTailMerge) {
|
||||||
switch (FlagEnableTailMerge) {
|
switch (FlagEnableTailMerge) {
|
||||||
case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
|
case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break;
|
||||||
@@ -279,7 +278,6 @@ static unsigned HashMachineInstr(const MachineInstr *MI) {
|
|||||||
/// branch must be inserted). For blocks with a successor, one of the
|
/// branch must be inserted). For blocks with a successor, one of the
|
||||||
/// two blocks to be tail-merged will end with a branch already, so
|
/// two blocks to be tail-merged will end with a branch already, so
|
||||||
/// it gains to cross-jump even for one instruction.
|
/// it gains to cross-jump even for one instruction.
|
||||||
|
|
||||||
static unsigned HashEndOfMBB(const MachineBasicBlock *MBB,
|
static unsigned HashEndOfMBB(const MachineBasicBlock *MBB,
|
||||||
unsigned minCommonTailLength) {
|
unsigned minCommonTailLength) {
|
||||||
MachineBasicBlock::const_iterator I = MBB->end();
|
MachineBasicBlock::const_iterator I = MBB->end();
|
||||||
@@ -404,7 +402,6 @@ static unsigned EstimateRuntime(MachineBasicBlock::iterator I,
|
|||||||
// branches temporarily for tail merging). In the case where CurMBB ends
|
// branches temporarily for tail merging). In the case where CurMBB ends
|
||||||
// with a conditional branch to the next block, optimize by reversing the
|
// with a conditional branch to the next block, optimize by reversing the
|
||||||
// test and conditionally branching to SuccMBB instead.
|
// test and conditionally branching to SuccMBB instead.
|
||||||
|
|
||||||
static void FixTail(MachineBasicBlock* CurMBB, MachineBasicBlock *SuccBB,
|
static void FixTail(MachineBasicBlock* CurMBB, MachineBasicBlock *SuccBB,
|
||||||
const TargetInstrInfo *TII) {
|
const TargetInstrInfo *TII) {
|
||||||
MachineFunction *MF = CurMBB->getParent();
|
MachineFunction *MF = CurMBB->getParent();
|
||||||
@@ -493,9 +490,9 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
|
|||||||
MPIterator HighestMPIter = prior(MergePotentials.end());
|
MPIterator HighestMPIter = prior(MergePotentials.end());
|
||||||
for (MPIterator CurMPIter = prior(MergePotentials.end()),
|
for (MPIterator CurMPIter = prior(MergePotentials.end()),
|
||||||
B = MergePotentials.begin();
|
B = MergePotentials.begin();
|
||||||
CurMPIter!=B && CurMPIter->first==CurHash;
|
CurMPIter!=B && CurMPIter->first == CurHash;
|
||||||
--CurMPIter) {
|
--CurMPIter) {
|
||||||
for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) {
|
for (MPIterator I = prior(CurMPIter); I->first == CurHash ; --I) {
|
||||||
unsigned CommonTailLen;
|
unsigned CommonTailLen;
|
||||||
if (ProfitableToMerge(CurMPIter->second, I->second, minCommonTailLength,
|
if (ProfitableToMerge(CurMPIter->second, I->second, minCommonTailLength,
|
||||||
CommonTailLen, TrialBBI1, TrialBBI2)) {
|
CommonTailLen, TrialBBI1, TrialBBI2)) {
|
||||||
@@ -509,7 +506,7 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
|
|||||||
CommonTailLen == maxCommonTailLength)
|
CommonTailLen == maxCommonTailLength)
|
||||||
SameTails.push_back(std::make_pair(I, TrialBBI2));
|
SameTails.push_back(std::make_pair(I, TrialBBI2));
|
||||||
}
|
}
|
||||||
if (I==B)
|
if (I == B)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,13 +520,13 @@ void BranchFolder::RemoveBlocksWithHash(unsigned CurHash,
|
|||||||
MachineBasicBlock* PredBB) {
|
MachineBasicBlock* PredBB) {
|
||||||
MPIterator CurMPIter, B;
|
MPIterator CurMPIter, B;
|
||||||
for (CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin();
|
for (CurMPIter = prior(MergePotentials.end()), B = MergePotentials.begin();
|
||||||
CurMPIter->first==CurHash;
|
CurMPIter->first == CurHash;
|
||||||
--CurMPIter) {
|
--CurMPIter) {
|
||||||
// Put the unconditional branch back, if we need one.
|
// Put the unconditional branch back, if we need one.
|
||||||
MachineBasicBlock *CurMBB = CurMPIter->second;
|
MachineBasicBlock *CurMBB = CurMPIter->second;
|
||||||
if (SuccBB && CurMBB != PredBB)
|
if (SuccBB && CurMBB != PredBB)
|
||||||
FixTail(CurMBB, SuccBB, TII);
|
FixTail(CurMBB, SuccBB, TII);
|
||||||
if (CurMPIter==B)
|
if (CurMPIter == B)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (CurMPIter->first!=CurHash)
|
if (CurMPIter->first!=CurHash)
|
||||||
@@ -545,7 +542,7 @@ unsigned BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB,
|
|||||||
unsigned TimeEstimate = ~0U;
|
unsigned TimeEstimate = ~0U;
|
||||||
for (i=0, commonTailIndex=0; i<SameTails.size(); i++) {
|
for (i=0, commonTailIndex=0; i<SameTails.size(); i++) {
|
||||||
// Use PredBB if possible; that doesn't require a new branch.
|
// Use PredBB if possible; that doesn't require a new branch.
|
||||||
if (SameTails[i].first->second==PredBB) {
|
if (SameTails[i].first->second == PredBB) {
|
||||||
commonTailIndex = i;
|
commonTailIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -553,7 +550,7 @@ unsigned BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB,
|
|||||||
// how long it will take the various blocks to execute.
|
// how long it will take the various blocks to execute.
|
||||||
unsigned t = EstimateRuntime(SameTails[i].first->second->begin(),
|
unsigned t = EstimateRuntime(SameTails[i].first->second->begin(),
|
||||||
SameTails[i].second);
|
SameTails[i].second);
|
||||||
if (t<=TimeEstimate) {
|
if (t <= TimeEstimate) {
|
||||||
TimeEstimate = t;
|
TimeEstimate = t;
|
||||||
commonTailIndex = i;
|
commonTailIndex = i;
|
||||||
}
|
}
|
||||||
@@ -568,8 +565,9 @@ unsigned BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB,
|
|||||||
MachineBasicBlock *newMBB = SplitMBBAt(*MBB, BBI);
|
MachineBasicBlock *newMBB = SplitMBBAt(*MBB, BBI);
|
||||||
SameTails[commonTailIndex].first->second = newMBB;
|
SameTails[commonTailIndex].first->second = newMBB;
|
||||||
SameTails[commonTailIndex].second = newMBB->begin();
|
SameTails[commonTailIndex].second = newMBB->begin();
|
||||||
|
|
||||||
// If we split PredBB, newMBB is the new predecessor.
|
// If we split PredBB, newMBB is the new predecessor.
|
||||||
if (PredBB==MBB)
|
if (PredBB == MBB)
|
||||||
PredBB = newMBB;
|
PredBB = newMBB;
|
||||||
|
|
||||||
return commonTailIndex;
|
return commonTailIndex;
|
||||||
@@ -625,12 +623,12 @@ bool BranchFolder::TryMergeBlocks(MachineBasicBlock *SuccBB,
|
|||||||
MachineBasicBlock *MBB = SameTails[i].first->second;
|
MachineBasicBlock *MBB = SameTails[i].first->second;
|
||||||
if (MBB->begin() == SameTails[i].second && MBB != EntryBB) {
|
if (MBB->begin() == SameTails[i].second && MBB != EntryBB) {
|
||||||
commonTailIndex = i;
|
commonTailIndex = i;
|
||||||
if (MBB==PredBB)
|
if (MBB == PredBB)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commonTailIndex==SameTails.size()) {
|
if (commonTailIndex == SameTails.size()) {
|
||||||
// None of the blocks consist entirely of the common tail.
|
// None of the blocks consist entirely of the common tail.
|
||||||
// Split a block so that one does.
|
// Split a block so that one does.
|
||||||
commonTailIndex = CreateCommonTailOnlyBlock(PredBB, maxCommonTailLength);
|
commonTailIndex = CreateCommonTailOnlyBlock(PredBB, maxCommonTailLength);
|
||||||
@@ -641,7 +639,7 @@ bool BranchFolder::TryMergeBlocks(MachineBasicBlock *SuccBB,
|
|||||||
// Traversal must be forwards so erases work.
|
// Traversal must be forwards so erases work.
|
||||||
DEBUG(errs() << "\nUsing common tail BB#" << MBB->getNumber() << " for ");
|
DEBUG(errs() << "\nUsing common tail BB#" << MBB->getNumber() << " for ");
|
||||||
for (unsigned int i=0; i<SameTails.size(); ++i) {
|
for (unsigned int i=0; i<SameTails.size(); ++i) {
|
||||||
if (commonTailIndex==i)
|
if (commonTailIndex == i)
|
||||||
continue;
|
continue;
|
||||||
DEBUG(errs() << "BB#" << SameTails[i].first->second->getNumber() << ", ");
|
DEBUG(errs() << "BB#" << SameTails[i].first->second->getNumber() << ", ");
|
||||||
// Hack the end off BB i, making it jump to BB commonTailIndex instead.
|
// Hack the end off BB i, making it jump to BB commonTailIndex instead.
|
||||||
@@ -669,6 +667,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
|
|||||||
if (I->succ_empty())
|
if (I->succ_empty())
|
||||||
MergePotentials.push_back(std::make_pair(HashEndOfMBB(I, 2U), I));
|
MergePotentials.push_back(std::make_pair(HashEndOfMBB(I, 2U), I));
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we can do any tail merging on those.
|
// See if we can do any tail merging on those.
|
||||||
if (MergePotentials.size() < TailMergeThreshold &&
|
if (MergePotentials.size() < TailMergeThreshold &&
|
||||||
MergePotentials.size() >= 2)
|
MergePotentials.size() >= 2)
|
||||||
@@ -704,7 +703,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
|
|||||||
P != E2; ++P) {
|
P != E2; ++P) {
|
||||||
MachineBasicBlock* PBB = *P;
|
MachineBasicBlock* PBB = *P;
|
||||||
// Skip blocks that loop to themselves, can't tail merge these.
|
// Skip blocks that loop to themselves, can't tail merge these.
|
||||||
if (PBB==IBB)
|
if (PBB == IBB)
|
||||||
continue;
|
continue;
|
||||||
// Visit each predecessor only once.
|
// Visit each predecessor only once.
|
||||||
if (!UniquePreds.insert(PBB))
|
if (!UniquePreds.insert(PBB))
|
||||||
@@ -715,7 +714,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
|
|||||||
// Failing case: IBB is the target of a cbr, and
|
// Failing case: IBB is the target of a cbr, and
|
||||||
// we cannot reverse the branch.
|
// we cannot reverse the branch.
|
||||||
SmallVector<MachineOperand, 4> NewCond(Cond);
|
SmallVector<MachineOperand, 4> NewCond(Cond);
|
||||||
if (!Cond.empty() && TBB==IBB) {
|
if (!Cond.empty() && TBB == IBB) {
|
||||||
if (TII->ReverseBranchCondition(NewCond))
|
if (TII->ReverseBranchCondition(NewCond))
|
||||||
continue;
|
continue;
|
||||||
// This is the QBB case described above
|
// This is the QBB case described above
|
||||||
@@ -730,7 +729,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
|
|||||||
MachineBasicBlock* PredNextBB = NULL;
|
MachineBasicBlock* PredNextBB = NULL;
|
||||||
if (IP!=MF.end())
|
if (IP!=MF.end())
|
||||||
PredNextBB = IP;
|
PredNextBB = IP;
|
||||||
if (TBB==NULL) {
|
if (TBB == NULL) {
|
||||||
if (IBB!=PredNextBB) // fallthrough
|
if (IBB!=PredNextBB) // fallthrough
|
||||||
continue;
|
continue;
|
||||||
} else if (FBB) {
|
} else if (FBB) {
|
||||||
@@ -749,7 +748,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
|
|||||||
TII->RemoveBranch(*PBB);
|
TII->RemoveBranch(*PBB);
|
||||||
if (!Cond.empty())
|
if (!Cond.empty())
|
||||||
// reinsert conditional branch only, for now
|
// reinsert conditional branch only, for now
|
||||||
TII->InsertBranch(*PBB, (TBB==IBB) ? FBB : TBB, 0, NewCond);
|
TII->InsertBranch(*PBB, (TBB == IBB) ? FBB : TBB, 0, NewCond);
|
||||||
}
|
}
|
||||||
MergePotentials.push_back(std::make_pair(HashEndOfMBB(PBB, 1U), *P));
|
MergePotentials.push_back(std::make_pair(HashEndOfMBB(PBB, 1U), *P));
|
||||||
}
|
}
|
||||||
@@ -759,7 +758,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
|
|||||||
// Reinsert an unconditional branch if needed.
|
// Reinsert an unconditional branch if needed.
|
||||||
// The 1 below can occur as a result of removing blocks in TryMergeBlocks.
|
// The 1 below can occur as a result of removing blocks in TryMergeBlocks.
|
||||||
PredBB = prior(I); // this may have been changed in TryMergeBlocks
|
PredBB = prior(I); // this may have been changed in TryMergeBlocks
|
||||||
if (MergePotentials.size()==1 &&
|
if (MergePotentials.size() == 1 &&
|
||||||
MergePotentials.begin()->second != PredBB)
|
MergePotentials.begin()->second != PredBB)
|
||||||
FixTail(MergePotentials.begin()->second, I, TII);
|
FixTail(MergePotentials.begin()->second, I, TII);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user