mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 06:32:09 +00:00
Fixes for MachineLoopInfo, mostly from Evan. With these, it should be almost useable!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e62f97c094
commit
528b00adc4
@ -141,7 +141,7 @@ public:
|
|||||||
|
|
||||||
/// isLoopInvariant - Return true if the specified value is loop invariant
|
/// isLoopInvariant - Return true if the specified value is loop invariant
|
||||||
///
|
///
|
||||||
bool isLoopInvariant(Value *V) const {
|
inline bool isLoopInvariant(Value *V) const {
|
||||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||||
return !contains(I->getParent());
|
return !contains(I->getParent());
|
||||||
return true; // All non-instructions are loop invariant
|
return true; // All non-instructions are loop invariant
|
||||||
@ -327,7 +327,7 @@ public:
|
|||||||
/// by one each time through the loop. If so, return the phi node that
|
/// by one each time through the loop. If so, return the phi node that
|
||||||
/// corresponds to it.
|
/// corresponds to it.
|
||||||
///
|
///
|
||||||
PHINode *getCanonicalInductionVariable() const {
|
inline PHINode *getCanonicalInductionVariable() const {
|
||||||
BlockT *H = getHeader();
|
BlockT *H = getHeader();
|
||||||
|
|
||||||
BlockT *Incoming = 0, *Backedge = 0;
|
BlockT *Incoming = 0, *Backedge = 0;
|
||||||
@ -365,7 +365,7 @@ public:
|
|||||||
/// the canonical induction variable value for the "next" iteration of the
|
/// the canonical induction variable value for the "next" iteration of the
|
||||||
/// loop. This always succeeds if getCanonicalInductionVariable succeeds.
|
/// loop. This always succeeds if getCanonicalInductionVariable succeeds.
|
||||||
///
|
///
|
||||||
Instruction *getCanonicalInductionVariableIncrement() const {
|
inline Instruction *getCanonicalInductionVariableIncrement() const {
|
||||||
if (PHINode *PN = getCanonicalInductionVariable()) {
|
if (PHINode *PN = getCanonicalInductionVariable()) {
|
||||||
bool P1InLoop = contains(PN->getIncomingBlock(1));
|
bool P1InLoop = contains(PN->getIncomingBlock(1));
|
||||||
return cast<Instruction>(PN->getIncomingValue(P1InLoop));
|
return cast<Instruction>(PN->getIncomingValue(P1InLoop));
|
||||||
@ -378,7 +378,7 @@ public:
|
|||||||
/// of the loop executes N-1 times. If the trip-count cannot be determined,
|
/// of the loop executes N-1 times. If the trip-count cannot be determined,
|
||||||
/// this returns null.
|
/// this returns null.
|
||||||
///
|
///
|
||||||
Value *getTripCount() const {
|
inline Value *getTripCount() const {
|
||||||
// Canonical loops will end with a 'cmp ne I, V', where I is the incremented
|
// Canonical loops will end with a 'cmp ne I, V', where I is the incremented
|
||||||
// canonical induction variable and V is the trip count of the loop.
|
// canonical induction variable and V is the trip count of the loop.
|
||||||
Instruction *Inc = getCanonicalInductionVariableIncrement();
|
Instruction *Inc = getCanonicalInductionVariableIncrement();
|
||||||
@ -405,7 +405,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// isLCSSAForm - Return true if the Loop is in LCSSA form
|
/// isLCSSAForm - Return true if the Loop is in LCSSA form
|
||||||
bool isLCSSAForm() const {
|
inline bool isLCSSAForm() const {
|
||||||
// Sort the blocks vector so that we can use binary search to do quick
|
// Sort the blocks vector so that we can use binary search to do quick
|
||||||
// lookups.
|
// lookups.
|
||||||
SmallPtrSet<BlockT*, 16> LoopBBs(block_begin(), block_end());
|
SmallPtrSet<BlockT*, 16> LoopBBs(block_begin(), block_end());
|
||||||
|
@ -39,14 +39,13 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
// Provide overrides for Loop methods that don't make sense for machine loops.
|
// Provide overrides for Loop methods that don't make sense for machine loops.
|
||||||
template<>
|
template<> inline
|
||||||
PHINode *LoopBase<MachineBasicBlock>::getCanonicalInductionVariable() const {
|
PHINode *LoopBase<MachineBasicBlock>::getCanonicalInductionVariable() const {
|
||||||
assert(0 && "getCanonicalInductionVariable not supported for machine loops!");
|
assert(0 && "getCanonicalInductionVariable not supported for machine loops!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<> inline Instruction*
|
||||||
Instruction*
|
|
||||||
LoopBase<MachineBasicBlock>::getCanonicalInductionVariableIncrement() const {
|
LoopBase<MachineBasicBlock>::getCanonicalInductionVariableIncrement() const {
|
||||||
assert(0 &&
|
assert(0 &&
|
||||||
"getCanonicalInductionVariableIncrement not supported for machine loops!");
|
"getCanonicalInductionVariableIncrement not supported for machine loops!");
|
||||||
@ -54,19 +53,19 @@ LoopBase<MachineBasicBlock>::getCanonicalInductionVariableIncrement() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool LoopBase<MachineBasicBlock>::isLoopInvariant(Value *V) const {
|
inline bool LoopBase<MachineBasicBlock>::isLoopInvariant(Value *V) const {
|
||||||
assert(0 && "isLoopInvariant not supported for machine loops!");
|
assert(0 && "isLoopInvariant not supported for machine loops!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
Value *LoopBase<MachineBasicBlock>::getTripCount() const {
|
inline Value *LoopBase<MachineBasicBlock>::getTripCount() const {
|
||||||
assert(0 && "getTripCount not supported for machine loops!");
|
assert(0 && "getTripCount not supported for machine loops!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool LoopBase<MachineBasicBlock>::isLCSSAForm() const {
|
inline bool LoopBase<MachineBasicBlock>::isLCSSAForm() const {
|
||||||
assert(0 && "isLCSSAForm not supported for machine loops");
|
assert(0 && "isLCSSAForm not supported for machine loops");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -129,10 +128,6 @@ public:
|
|||||||
|
|
||||||
virtual void releaseMemory() { LI->releaseMemory(); }
|
virtual void releaseMemory() { LI->releaseMemory(); }
|
||||||
|
|
||||||
virtual void print(std::ostream &O, const Module* M = 0) const {
|
|
||||||
if (O) LI->print(O, M);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||||
|
|
||||||
/// removeLoop - This removes the specified top-level loop from this loop info
|
/// removeLoop - This removes the specified top-level loop from this loop info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user