diff options
| author | Johannes Doerfert <doerfert@uni-saarland.de> | 2014-08-12 18:35:54 +0000 |
|---|---|---|
| committer | Johannes Doerfert <doerfert@uni-saarland.de> | 2014-08-12 18:35:54 +0000 |
| commit | 9744c4af1618d3232b7ff5b4d04d39501f4ff079 (patch) | |
| tree | 27df8183e1c70c2781c05f86c1329f71df498e86 /polly/lib/CodeGen/IslCodeGeneration.cpp | |
| parent | d57db6e877d89af25979a633f237c8e542b5f6ce (diff) | |
| download | bcm5719-llvm-9744c4af1618d3232b7ff5b4d04d39501f4ff079.tar.gz bcm5719-llvm-9744c4af1618d3232b7ff5b4d04d39501f4ff079.zip | |
[Refactor] Cleanup runtime code generation
+ Use regexp in two test case.
+ Refactor the runtime condition build function
llvm-svn: 215466
Diffstat (limited to 'polly/lib/CodeGen/IslCodeGeneration.cpp')
| -rw-r--r-- | polly/lib/CodeGen/IslCodeGeneration.cpp | 67 |
1 files changed, 42 insertions, 25 deletions
diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp index 71ca0089aed..9cf8bf89faa 100644 --- a/polly/lib/CodeGen/IslCodeGeneration.cpp +++ b/polly/lib/CodeGen/IslCodeGeneration.cpp @@ -568,41 +568,58 @@ public: IslCodeGeneration() : ScopPass(ID) {} + /// @name The analysis passes we need to generate code. + /// + ///{ + LoopInfo *LI; + IslAstInfo *AI; + DominatorTree *DT; + ScalarEvolution *SE; + ///} + + /// @brief The loop anotator to generate llvm.loop metadata. + LoopAnnotator Annotator; + + /// @brief Build the delinearization runtime condition. + /// + /// Build the condition that evaluates at run-time to true iff all + /// delinearization assumptions taken for the SCoP hold, and to zero + /// otherwise. + /// + /// @return A value evaluating to true/false if delinarization is save/unsave. + 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); + PollyIRBuilder Builder = + createPollyIRBuilder(S.getRegionEntry(), Annotator); - 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()); - - 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); + + simplifyRegion(&S, this); + Builder.SetInsertPoint( + S.getRegion().getEnteringBlock()->getFirstInsertionPt()); + + Value *RTC = buildRTC(Builder, NodeBuilder.getExprBuilder()); + BasicBlock *StartBlock = executeScopConditionally(S, this, RTC); Builder.SetInsertPoint(StartBlock->begin()); - NodeBuilder.create(Ast); + NodeBuilder.create(AI->getAst()); + + DEBUG(StartBlock->getParent()->dump()); return true; } |

