summaryrefslogtreecommitdiffstats
path: root/polly/lib
diff options
context:
space:
mode:
authorJohannes Doerfert <jdoerfert@codeaurora.org>2014-08-07 17:14:54 +0000
committerJohannes Doerfert <jdoerfert@codeaurora.org>2014-08-07 17:14:54 +0000
commit2ef3f4fd2378c6b1f6acbb18a9332d58f3d8b2cc (patch)
treedf92903527f0cd5247b25fbc2b9f6e3adfff843c /polly/lib
parentcadc603e9154e607fa090b2f07ecc16465d36ebb (diff)
downloadbcm5719-llvm-2ef3f4fd2378c6b1f6acbb18a9332d58f3d8b2cc.tar.gz
bcm5719-llvm-2ef3f4fd2378c6b1f6acbb18a9332d58f3d8b2cc.zip
Make used analysis passes explicit
Use the explicit analysis if possible, only for splitBlock we will continue to use the Pass * argument. This change allows us to remove the getAnalysis calls from the code generation. llvm-svn: 215121
Diffstat (limited to 'polly/lib')
-rw-r--r--polly/lib/CodeGen/BlockGenerators.cpp21
-rw-r--r--polly/lib/CodeGen/IslCodeGeneration.cpp25
-rw-r--r--polly/lib/CodeGen/LoopGenerators.cpp8
3 files changed, 29 insertions, 25 deletions
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index 66d90d9cff5..52c8ce02bc7 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -67,10 +67,11 @@ bool polly::canSynthesize(const Instruction *I, const llvm::LoopInfo *LI,
}
BlockGenerator::BlockGenerator(PollyIRBuilder &B, ScopStmt &Stmt, Pass *P,
+ LoopInfo &LI, ScalarEvolution &SE,
isl_ast_build *Build,
IslExprBuilder *ExprBuilder)
- : Builder(B), Statement(Stmt), P(P), SE(P->getAnalysis<ScalarEvolution>()),
- Build(Build), ExprBuilder(ExprBuilder) {}
+ : Builder(B), Statement(Stmt), P(P), LI(LI), SE(SE), Build(Build),
+ ExprBuilder(ExprBuilder) {}
Value *BlockGenerator::lookupAvailableValue(const Value *Old, ValueMapT &BBMap,
ValueMapT &GlobalMap) const {
@@ -209,7 +210,7 @@ Value *BlockGenerator::generateLocationAccessed(const Instruction *Inst,
}
Loop *BlockGenerator::getLoopForInst(const llvm::Instruction *Inst) {
- return P->getAnalysis<LoopInfo>().getLoopFor(Inst->getParent());
+ return LI.getLoopFor(Inst->getParent());
}
Value *BlockGenerator::generateScalarLoad(const LoadInst *Load,
@@ -282,14 +283,12 @@ void BlockGenerator::copyBB(ValueMapT &GlobalMap, LoopToScevMapT &LTS) {
copyInstruction(&Inst, BBMap, GlobalMap, LTS);
}
-VectorBlockGenerator::VectorBlockGenerator(PollyIRBuilder &B,
- VectorValueMapT &GlobalMaps,
- std::vector<LoopToScevMapT> &VLTS,
- ScopStmt &Stmt,
- __isl_keep isl_map *Schedule,
- Pass *P)
- : BlockGenerator(B, Stmt, P, nullptr, nullptr), GlobalMaps(GlobalMaps),
- VLTS(VLTS), Schedule(Schedule) {
+VectorBlockGenerator::VectorBlockGenerator(
+ PollyIRBuilder &B, VectorValueMapT &GlobalMaps,
+ std::vector<LoopToScevMapT> &VLTS, ScopStmt &Stmt,
+ __isl_keep isl_map *Schedule, Pass *P, LoopInfo &LI, ScalarEvolution &SE)
+ : BlockGenerator(B, Stmt, P, LI, SE, nullptr, nullptr),
+ GlobalMaps(GlobalMaps), VLTS(VLTS), Schedule(Schedule) {
assert(GlobalMaps.size() > 1 && "Only one vector lane found");
assert(Schedule && "No statement domain provided");
}
diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp
index 361ef8ac5a5..71ca0089aed 100644
--- a/polly/lib/CodeGen/IslCodeGeneration.cpp
+++ b/polly/lib/CodeGen/IslCodeGeneration.cpp
@@ -58,9 +58,10 @@ using namespace llvm;
class IslNodeBuilder {
public:
- IslNodeBuilder(PollyIRBuilder &Builder, LoopAnnotator &Annotator, Pass *P)
+ IslNodeBuilder(PollyIRBuilder &Builder, LoopAnnotator &Annotator, Pass *P,
+ LoopInfo &LI, ScalarEvolution &SE, DominatorTree &DT)
: Builder(Builder), Annotator(Annotator), ExprBuilder(Builder, IDToValue),
- P(P) {}
+ P(P), LI(LI), SE(SE), DT(DT) {}
/// @brief Add the mappings from array id's to array llvm::Value's.
void addMemoryAccesses(Scop &S);
@@ -73,6 +74,9 @@ private:
LoopAnnotator &Annotator;
IslExprBuilder ExprBuilder;
Pass *P;
+ LoopInfo &LI;
+ ScalarEvolution &SE;
+ DominatorTree &DT;
// This maps an isl_id* to the Value* it has in the generated program. For now
// on, the only isl_ids that are stored here are the newly calculated loop
@@ -239,7 +243,7 @@ void IslNodeBuilder::createUserVector(__isl_take isl_ast_node *User,
isl_map *S = isl_map_from_union_map(Schedule);
createSubstitutionsVector(Expr, Stmt, VectorMap, VLTS, IVS, IteratorID);
- VectorBlockGenerator::generate(Builder, *Stmt, VectorMap, VLTS, S, P);
+ VectorBlockGenerator::generate(Builder, *Stmt, VectorMap, VLTS, S, P, LI, SE);
isl_map_free(S);
isl_id_free(Id);
@@ -350,8 +354,8 @@ void IslNodeBuilder::createForSequential(__isl_take isl_ast_node *For) {
if (MaxType != ValueInc->getType())
ValueInc = Builder.CreateSExt(ValueInc, MaxType);
- IV = createLoop(ValueLB, ValueUB, ValueInc, Builder, P, ExitBlock, Predicate,
- &Annotator, Parallel);
+ IV = createLoop(ValueLB, ValueUB, ValueInc, Builder, P, LI, DT, ExitBlock,
+ Predicate, &Annotator, Parallel);
IDToValue[IteratorID] = IV;
create(Body);
@@ -395,12 +399,10 @@ void IslNodeBuilder::createIf(__isl_take isl_ast_node *If) {
BasicBlock *ThenBB = BasicBlock::Create(Context, "polly.then", F);
BasicBlock *ElseBB = BasicBlock::Create(Context, "polly.else", F);
- DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
DT.addNewBlock(ThenBB, CondBB);
DT.addNewBlock(ElseBB, CondBB);
DT.changeImmediateDominator(MergeBB, CondBB);
- LoopInfo &LI = P->getAnalysis<LoopInfo>();
Loop *L = LI.getLoopFor(CondBB);
if (L) {
L->addBasicBlockToLoop(ThenBB, LI.getBase());
@@ -490,7 +492,7 @@ void IslNodeBuilder::createUser(__isl_take isl_ast_node *User) {
Stmt = (ScopStmt *)isl_id_get_user(Id);
createSubstitutions(Expr, Stmt, VMap, LTS);
- BlockGenerator::generate(Builder, *Stmt, VMap, LTS, P,
+ BlockGenerator::generate(Builder, *Stmt, VMap, LTS, P, LI, SE,
IslAstInfo::getBuild(User), &ExprBuilder);
isl_ast_node_free(User);
@@ -529,7 +531,7 @@ void IslNodeBuilder::create(__isl_take isl_ast_node *Node) {
}
void IslNodeBuilder::addParameters(__isl_take isl_set *Context) {
- SCEVExpander Rewriter(P->getAnalysis<ScalarEvolution>(), "polly");
+ SCEVExpander Rewriter(SE, "polly");
for (unsigned i = 0; i < isl_set_dim(Context, isl_dim_param); ++i) {
isl_id *Id;
@@ -567,7 +569,10 @@ public:
IslCodeGeneration() : ScopPass(ID) {}
bool runOnScop(Scop &S) {
+ LoopInfo &LI = getAnalysis<LoopInfo>();
IslAstInfo &AstInfo = getAnalysis<IslAstInfo>();
+ ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
+ DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
assert(!S.getRegion().isTopLevelRegion() &&
"Top level regions are not supported");
@@ -581,7 +586,7 @@ public:
polly::IRInserter(Annotator));
Builder.SetInsertPoint(StartBlock->begin());
- IslNodeBuilder NodeBuilder(Builder, Annotator, this);
+ IslNodeBuilder NodeBuilder(Builder, Annotator, this, LI, SE, DT);
Builder.SetInsertPoint(StartBlock->getSinglePredecessor()->begin());
NodeBuilder.addMemoryAccesses(S);
diff --git a/polly/lib/CodeGen/LoopGenerators.cpp b/polly/lib/CodeGen/LoopGenerators.cpp
index 432960d2b85..4eaaac0bc6d 100644
--- a/polly/lib/CodeGen/LoopGenerators.cpp
+++ b/polly/lib/CodeGen/LoopGenerators.cpp
@@ -47,11 +47,10 @@ using namespace polly;
// TODO: We currently always create the GuardBB. If we can prove the loop is
// always executed at least once, we can get rid of this branch.
Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
- PollyIRBuilder &Builder, Pass *P, BasicBlock *&ExitBB,
+ PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
+ DominatorTree &DT, BasicBlock *&ExitBB,
ICmpInst::Predicate Predicate,
LoopAnnotator *Annotator, bool Parallel) {
- DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- LoopInfo &LI = P->getAnalysis<LoopInfo>();
Function *F = Builder.GetInsertBlock()->getParent();
LLVMContext &Context = F->getContext();
@@ -321,7 +320,8 @@ Value *OMPGenerator::createSubfunction(Value *Stride, Value *StructData,
Builder.CreateBr(CheckNextBB);
Builder.SetInsertPoint(--Builder.GetInsertPoint());
- IV = createLoop(LowerBound, UpperBound, Stride, Builder, P, AfterBB,
+ LoopInfo &LI = P->getAnalysis<LoopInfo>();
+ IV = createLoop(LowerBound, UpperBound, Stride, Builder, P, LI, DT, AfterBB,
ICmpInst::ICMP_SLE);
BasicBlock::iterator LoopBody = Builder.GetInsertPoint();
OpenPOWER on IntegriCloud