mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 07:17:36 +00:00
Now LoopStrengthReduce is a LoopPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
|
class LoopPass;
|
||||||
class Pass;
|
class Pass;
|
||||||
class GetElementPtrInst;
|
class GetElementPtrInst;
|
||||||
class PassInfo;
|
class PassInfo;
|
||||||
@@ -120,7 +121,7 @@ FunctionPass *createLICMPass();
|
|||||||
// optional parameter used to consult the target machine whether certain
|
// optional parameter used to consult the target machine whether certain
|
||||||
// transformations are profitable.
|
// transformations are profitable.
|
||||||
//
|
//
|
||||||
FunctionPass *createLoopStrengthReducePass(const TargetLowering *TLI = NULL);
|
LoopPass *createLoopStrengthReducePass(const TargetLowering *TLI = NULL);
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
|
#include "llvm/Analysis/LoopPass.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
|
#include "llvm/Analysis/LoopPass.h"
|
||||||
#include "llvm/Analysis/ScalarEvolutionExpander.h"
|
#include "llvm/Analysis/ScalarEvolutionExpander.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
@@ -104,7 +105,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class VISIBILITY_HIDDEN LoopStrengthReduce : public FunctionPass {
|
class VISIBILITY_HIDDEN LoopStrengthReduce : public LoopPass {
|
||||||
LoopInfo *LI;
|
LoopInfo *LI;
|
||||||
ETForest *EF;
|
ETForest *EF;
|
||||||
ScalarEvolution *SE;
|
ScalarEvolution *SE;
|
||||||
@@ -143,19 +144,7 @@ namespace {
|
|||||||
: TLI(tli) {
|
: TLI(tli) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool runOnFunction(Function &) {
|
bool runOnLoop(Loop *L, LPPassManager &LPM);
|
||||||
LI = &getAnalysis<LoopInfo>();
|
|
||||||
EF = &getAnalysis<ETForest>();
|
|
||||||
SE = &getAnalysis<ScalarEvolution>();
|
|
||||||
TD = &getAnalysis<TargetData>();
|
|
||||||
UIntPtrTy = TD->getIntPtrType();
|
|
||||||
Changed = false;
|
|
||||||
|
|
||||||
for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)
|
|
||||||
runOnLoop(*I);
|
|
||||||
|
|
||||||
return Changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
// We split critical edges, so we change the CFG. However, we do update
|
// We split critical edges, so we change the CFG. However, we do update
|
||||||
@@ -179,7 +168,6 @@ namespace {
|
|||||||
///
|
///
|
||||||
Value *getCastedVersionOf(Instruction::CastOps opcode, Value *V);
|
Value *getCastedVersionOf(Instruction::CastOps opcode, Value *V);
|
||||||
private:
|
private:
|
||||||
void runOnLoop(Loop *L);
|
|
||||||
bool AddUsersIfInteresting(Instruction *I, Loop *L,
|
bool AddUsersIfInteresting(Instruction *I, Loop *L,
|
||||||
std::set<Instruction*> &Processed);
|
std::set<Instruction*> &Processed);
|
||||||
SCEVHandle GetExpressionSCEV(Instruction *E, Loop *L);
|
SCEVHandle GetExpressionSCEV(Instruction *E, Loop *L);
|
||||||
@@ -196,7 +184,7 @@ private:
|
|||||||
RegisterPass<LoopStrengthReduce> X("loop-reduce", "Loop Strength Reduction");
|
RegisterPass<LoopStrengthReduce> X("loop-reduce", "Loop Strength Reduction");
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *llvm::createLoopStrengthReducePass(const TargetLowering *TLI) {
|
LoopPass *llvm::createLoopStrengthReducePass(const TargetLowering *TLI) {
|
||||||
return new LoopStrengthReduce(TLI);
|
return new LoopStrengthReduce(TLI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1271,12 +1259,15 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoopStrengthReduce::runOnLoop(Loop *L) {
|
bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||||
// First step, transform all loops nesting inside of this loop.
|
|
||||||
for (LoopInfo::iterator I = L->begin(), E = L->end(); I != E; ++I)
|
|
||||||
runOnLoop(*I);
|
|
||||||
|
|
||||||
// Next, find all uses of induction variables in this loop, and catagorize
|
LI = &getAnalysis<LoopInfo>();
|
||||||
|
EF = &getAnalysis<ETForest>();
|
||||||
|
SE = &getAnalysis<ScalarEvolution>();
|
||||||
|
TD = &getAnalysis<TargetData>();
|
||||||
|
UIntPtrTy = TD->getIntPtrType();
|
||||||
|
|
||||||
|
// Find all uses of induction variables in this loop, and catagorize
|
||||||
// them by stride. Start by finding all of the PHI nodes in the header for
|
// them by stride. Start by finding all of the PHI nodes in the header for
|
||||||
// this loop. If they are induction variables, inspect their uses.
|
// this loop. If they are induction variables, inspect their uses.
|
||||||
std::set<Instruction*> Processed; // Don't reprocess instructions.
|
std::set<Instruction*> Processed; // Don't reprocess instructions.
|
||||||
@@ -1284,7 +1275,7 @@ void LoopStrengthReduce::runOnLoop(Loop *L) {
|
|||||||
AddUsersIfInteresting(I, L, Processed);
|
AddUsersIfInteresting(I, L, Processed);
|
||||||
|
|
||||||
// If we have nothing to do, return.
|
// If we have nothing to do, return.
|
||||||
if (IVUsesByStride.empty()) return;
|
if (IVUsesByStride.empty()) return false;
|
||||||
|
|
||||||
// Optimize induction variables. Some indvar uses can be transformed to use
|
// Optimize induction variables. Some indvar uses can be transformed to use
|
||||||
// strides that will be needed for other purposes. A common example of this
|
// strides that will be needed for other purposes. A common example of this
|
||||||
@@ -1368,5 +1359,5 @@ void LoopStrengthReduce::runOnLoop(Loop *L) {
|
|||||||
CastedPointers.clear();
|
CastedPointers.clear();
|
||||||
IVUsesByStride.clear();
|
IVUsesByStride.clear();
|
||||||
StrideOrder.clear();
|
StrideOrder.clear();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user