diff options
author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2014-09-10 14:50:23 +0000 |
---|---|---|
committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2014-09-10 14:50:23 +0000 |
commit | 3826224428197cdf8c2689c115476a9c25cccbd9 (patch) | |
tree | 0ef5df9fb92bb20e7dc4317559ca12088cb28233 /polly/lib/CodeGen/IslCodeGeneration.cpp | |
parent | 0244ee872efbd126d6e89dd8eb0d4c1b28a836bd (diff) | |
download | bcm5719-llvm-3826224428197cdf8c2689c115476a9c25cccbd9.tar.gz bcm5719-llvm-3826224428197cdf8c2689c115476a9c25cccbd9.zip |
[Refactor] Cleanup isl code generation
Summary:
+ Refactor the runtime check (RTC) build function
+ Added helper function to create an PollyIRBuilder
+ Change the simplify region function to create not
only unique entry and exit edges but also enfore that
the entry edge is unconditional
+ Cleaned the IslCodeGeneration runOnScop function:
- less post-creation changes of the created IR
+ Adjusted and added test cases
Reviewers: grosser, sebpop, simbuerg, dpeixott
Subscribers: llvm-commits, #polly
Differential Revision: http://reviews.llvm.org/D5076
llvm-svn: 217508
Diffstat (limited to 'polly/lib/CodeGen/IslCodeGeneration.cpp')
-rw-r--r-- | polly/lib/CodeGen/IslCodeGeneration.cpp | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp index f2ff3b10644..84b91ed65d5 100644 --- a/polly/lib/CodeGen/IslCodeGeneration.cpp +++ b/polly/lib/CodeGen/IslCodeGeneration.cpp @@ -566,41 +566,51 @@ public: IslCodeGeneration() : ScopPass(ID) {} + /// @name The analysis passes we need to generate code. + /// + ///{ + LoopInfo *LI; + IslAstInfo *AI; + DominatorTree *DT; + ScalarEvolution *SE; + ///} + + /// @brief The loop annotator to generate llvm.loop metadata. + LoopAnnotator Annotator; + + /// @brief Build the runtime condition. + /// + /// Build the condition that evaluates at run-time to true iff all + /// assumptions taken for the SCoP hold, and to false otherwise. + /// + /// @return A value evaluating to true/false if execution is save/unsafe. + Value *buildRTC(PollyIRBuilder &Builder, IslExprBuilder &ExprBuilder) { + Builder.SetInsertPoint(Builder.GetInsertBlock()->getTerminator()); + Value *RTC = ExprBuilder.create(AI->getRunCondition()); + return Builder.CreateIsNotNull(RTC); + } + bool runOnScop(Scop &S) { - LoopInfo &LI = getAnalysis<LoopInfo>(); - IslAstInfo &AstInfo = getAnalysis<IslAstInfo>(); - ScalarEvolution &SE = getAnalysis<ScalarEvolution>(); - DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); + LI = &getAnalysis<LoopInfo>(); + AI = &getAnalysis<IslAstInfo>(); + DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); + SE = &getAnalysis<ScalarEvolution>(); assert(!S.getRegion().isTopLevelRegion() && "Top level regions are not supported"); - simplifyRegion(&S, this); - - BasicBlock *StartBlock = executeScopConditionally(S, this); - isl_ast_node *Ast = AstInfo.getAst(); - LoopAnnotator Annotator; - PollyIRBuilder Builder(StartBlock->getContext(), llvm::ConstantFolder(), - polly::IRInserter(Annotator)); - Builder.SetInsertPoint(StartBlock->begin()); + BasicBlock *EnteringBB = simplifyRegion(&S, this); + PollyIRBuilder Builder = createPollyIRBuilder(EnteringBB, Annotator); - IslNodeBuilder NodeBuilder(Builder, Annotator, this, LI, SE, DT); - - Builder.SetInsertPoint(StartBlock->getSinglePredecessor()->begin()); + IslNodeBuilder NodeBuilder(Builder, Annotator, this, *LI, *SE, *DT); NodeBuilder.addMemoryAccesses(S); NodeBuilder.addParameters(S.getContext()); - // Build condition that evaluates at run-time if all assumptions taken - // for the scop hold. If we detect some assumptions do not hold, the - // original code is executed. - Value *V = NodeBuilder.getExprBuilder().create(AstInfo.getRunCondition()); - Value *Zero = ConstantInt::get(V->getType(), 0); - V = Builder.CreateICmp(CmpInst::ICMP_NE, Zero, V); - BasicBlock *PrevBB = StartBlock->getUniquePredecessor(); - BranchInst *Branch = dyn_cast<BranchInst>(PrevBB->getTerminator()); - Branch->setCondition(V); + + Value *RTC = buildRTC(Builder, NodeBuilder.getExprBuilder()); + BasicBlock *StartBlock = executeScopConditionally(S, this, RTC); Builder.SetInsertPoint(StartBlock->begin()); - NodeBuilder.create(Ast); + NodeBuilder.create(AI->getAst()); return true; } |