mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 17:24:48 +00:00
whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -49,7 +49,7 @@ namespace {
|
|||||||
CurrentAllowPartial = (P == -1) ? UnrollAllowPartial : (bool)P;
|
CurrentAllowPartial = (P == -1) ? UnrollAllowPartial : (bool)P;
|
||||||
|
|
||||||
UserThreshold = (T != -1) || (UnrollThreshold.getNumOccurrences() > 0);
|
UserThreshold = (T != -1) || (UnrollThreshold.getNumOccurrences() > 0);
|
||||||
|
|
||||||
initializeLoopUnrollPass(*PassRegistry::getPassRegistry());
|
initializeLoopUnrollPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,11 +57,11 @@ namespace {
|
|||||||
/// that the loop unroll should be performed regardless of how much
|
/// that the loop unroll should be performed regardless of how much
|
||||||
/// code expansion would result.
|
/// code expansion would result.
|
||||||
static const unsigned NoThreshold = UINT_MAX;
|
static const unsigned NoThreshold = UINT_MAX;
|
||||||
|
|
||||||
// Threshold to use when optsize is specified (and there is no
|
// Threshold to use when optsize is specified (and there is no
|
||||||
// explicit -unroll-threshold).
|
// explicit -unroll-threshold).
|
||||||
static const unsigned OptSizeUnrollThreshold = 50;
|
static const unsigned OptSizeUnrollThreshold = 50;
|
||||||
|
|
||||||
unsigned CurrentCount;
|
unsigned CurrentCount;
|
||||||
unsigned CurrentThreshold;
|
unsigned CurrentThreshold;
|
||||||
bool CurrentAllowPartial;
|
bool CurrentAllowPartial;
|
||||||
@ -107,14 +107,14 @@ static unsigned ApproximateLoopSize(const Loop *L, unsigned &NumCalls) {
|
|||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
Metrics.analyzeBasicBlock(*I);
|
Metrics.analyzeBasicBlock(*I);
|
||||||
NumCalls = Metrics.NumInlineCandidates;
|
NumCalls = Metrics.NumInlineCandidates;
|
||||||
|
|
||||||
unsigned LoopSize = Metrics.NumInsts;
|
unsigned LoopSize = Metrics.NumInsts;
|
||||||
|
|
||||||
// Don't allow an estimate of size zero. This would allows unrolling of loops
|
// Don't allow an estimate of size zero. This would allows unrolling of loops
|
||||||
// with huge iteration counts, which is a compile time problem even if it's
|
// with huge iteration counts, which is a compile time problem even if it's
|
||||||
// not a problem for code quality.
|
// not a problem for code quality.
|
||||||
if (LoopSize == 0) LoopSize = 1;
|
if (LoopSize == 0) LoopSize = 1;
|
||||||
|
|
||||||
return LoopSize;
|
return LoopSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,13 +125,13 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
|
|||||||
DEBUG(dbgs() << "Loop Unroll: F[" << Header->getParent()->getName()
|
DEBUG(dbgs() << "Loop Unroll: F[" << Header->getParent()->getName()
|
||||||
<< "] Loop %" << Header->getName() << "\n");
|
<< "] Loop %" << Header->getName() << "\n");
|
||||||
(void)Header;
|
(void)Header;
|
||||||
|
|
||||||
// Determine the current unrolling threshold. While this is normally set
|
// Determine the current unrolling threshold. While this is normally set
|
||||||
// from UnrollThreshold, it is overridden to a smaller value if the current
|
// from UnrollThreshold, it is overridden to a smaller value if the current
|
||||||
// function is marked as optimize-for-size, and the unroll threshold was
|
// function is marked as optimize-for-size, and the unroll threshold was
|
||||||
// not user specified.
|
// not user specified.
|
||||||
unsigned Threshold = CurrentThreshold;
|
unsigned Threshold = CurrentThreshold;
|
||||||
if (!UserThreshold &&
|
if (!UserThreshold &&
|
||||||
Header->getParent()->hasFnAttr(Attribute::OptimizeForSize))
|
Header->getParent()->hasFnAttr(Attribute::OptimizeForSize))
|
||||||
Threshold = OptSizeUnrollThreshold;
|
Threshold = OptSizeUnrollThreshold;
|
||||||
|
|
||||||
|
@ -129,14 +129,14 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count,
|
|||||||
|
|
||||||
BasicBlock *Header = L->getHeader();
|
BasicBlock *Header = L->getHeader();
|
||||||
BranchInst *BI = dyn_cast<BranchInst>(LatchBlock->getTerminator());
|
BranchInst *BI = dyn_cast<BranchInst>(LatchBlock->getTerminator());
|
||||||
|
|
||||||
if (!BI || BI->isUnconditional()) {
|
if (!BI || BI->isUnconditional()) {
|
||||||
// The loop-rotate pass can be helpful to avoid this in many cases.
|
// The loop-rotate pass can be helpful to avoid this in many cases.
|
||||||
DEBUG(dbgs() <<
|
DEBUG(dbgs() <<
|
||||||
" Can't unroll; loop not terminated by a conditional branch.\n");
|
" Can't unroll; loop not terminated by a conditional branch.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Header->hasAddressTaken()) {
|
if (Header->hasAddressTaken()) {
|
||||||
// The loop-rotate pass can be helpful to avoid this in many cases.
|
// The loop-rotate pass can be helpful to avoid this in many cases.
|
||||||
DEBUG(dbgs() <<
|
DEBUG(dbgs() <<
|
||||||
@ -210,7 +210,7 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count,
|
|||||||
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
|
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
|
||||||
PHINode *PN = cast<PHINode>(I);
|
PHINode *PN = cast<PHINode>(I);
|
||||||
OrigPHINode.push_back(PN);
|
OrigPHINode.push_back(PN);
|
||||||
if (Instruction *I =
|
if (Instruction *I =
|
||||||
dyn_cast<Instruction>(PN->getIncomingValueForBlock(LatchBlock)))
|
dyn_cast<Instruction>(PN->getIncomingValueForBlock(LatchBlock)))
|
||||||
if (L->contains(I))
|
if (L->contains(I))
|
||||||
LastValueMap[I] = I;
|
LastValueMap[I] = I;
|
||||||
@ -223,7 +223,7 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count,
|
|||||||
|
|
||||||
for (unsigned It = 1; It != Count; ++It) {
|
for (unsigned It = 1; It != Count; ++It) {
|
||||||
std::vector<BasicBlock*> NewBlocks;
|
std::vector<BasicBlock*> NewBlocks;
|
||||||
|
|
||||||
for (std::vector<BasicBlock*>::iterator BB = LoopBlocks.begin(),
|
for (std::vector<BasicBlock*>::iterator BB = LoopBlocks.begin(),
|
||||||
E = LoopBlocks.end(); BB != E; ++BB) {
|
E = LoopBlocks.end(); BB != E; ++BB) {
|
||||||
ValueToValueMapTy VMap;
|
ValueToValueMapTy VMap;
|
||||||
@ -282,14 +282,14 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count,
|
|||||||
|
|
||||||
NewBlocks.push_back(New);
|
NewBlocks.push_back(New);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remap all instructions in the most recent iteration
|
// Remap all instructions in the most recent iteration
|
||||||
for (unsigned i = 0; i < NewBlocks.size(); ++i)
|
for (unsigned i = 0; i < NewBlocks.size(); ++i)
|
||||||
for (BasicBlock::iterator I = NewBlocks[i]->begin(),
|
for (BasicBlock::iterator I = NewBlocks[i]->begin(),
|
||||||
E = NewBlocks[i]->end(); I != E; ++I)
|
E = NewBlocks[i]->end(); I != E; ++I)
|
||||||
::RemapInstruction(I, LastValueMap);
|
::RemapInstruction(I, LastValueMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The latch block exits the loop. If there are any PHI nodes in the
|
// The latch block exits the loop. If there are any PHI nodes in the
|
||||||
// successor blocks, update them to use the appropriate values computed as the
|
// successor blocks, update them to use the appropriate values computed as the
|
||||||
// last iteration of the loop.
|
// last iteration of the loop.
|
||||||
@ -366,7 +366,7 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count,
|
|||||||
std::replace(Latches.begin(), Latches.end(), Dest, Fold);
|
std::replace(Latches.begin(), Latches.end(), Dest, Fold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, the code is well formed. We now do a quick sweep over the
|
// At this point, the code is well formed. We now do a quick sweep over the
|
||||||
// inserted code, doing constant propagation and dead code elimination as we
|
// inserted code, doing constant propagation and dead code elimination as we
|
||||||
// go.
|
// go.
|
||||||
|
Reference in New Issue
Block a user