16#include "llvm/Analysis/LoopInfo.h"
17#include "llvm/Analysis/RegionInfo.h"
18#include "llvm/Transforms/Utils/BasicBlockUtils.h"
31static BasicBlock *
splitEdge(BasicBlock *Prev, BasicBlock *Succ,
32 const char *Suffix, DominatorTree *DT,
33 LoopInfo *LI, RegionInfo *RI) {
50 BasicBlock *MiddleBlock = SplitBlockPredecessors(
51 Succ, ArrayRef<BasicBlock *>(Prev), Suffix, DT, LI);
54 Region *PrevRegion = RI->getRegionFor(Prev);
55 Region *SuccRegion = RI->getRegionFor(Succ);
56 if (PrevRegion->contains(MiddleBlock)) {
57 RI->setRegionFor(MiddleBlock, PrevRegion);
59 RI->setRegionFor(MiddleBlock, SuccRegion);
77std::pair<polly::BBPair, BranchInst *>
79 RegionInfo &RI, LoopInfo &LI) {
80 Region &R =
S.getRegion();
96 BasicBlock *EnteringBB =
S.getEnteringBlock();
97 BasicBlock *EntryBB =
S.getEntry();
98 assert(EnteringBB &&
"Must be a simple region");
99 BasicBlock *SplitBlock =
100 splitEdge(EnteringBB, EntryBB,
".split_new_and_old", &DT, &LI, &RI);
101 SplitBlock->setName(
"polly.split_new_and_old");
108 Region *PrevRegion = RI.getRegionFor(EnteringBB);
109 while (PrevRegion->getExit() == EntryBB) {
110 PrevRegion->replaceExit(SplitBlock);
111 PrevRegion = PrevRegion->getParent();
113 RI.setRegionFor(SplitBlock, PrevRegion);
116 BasicBlock *ExitingBB =
S.getExitingBlock();
117 BasicBlock *ExitBB =
S.getExit();
118 assert(ExitingBB &&
"Must be a simple region");
119 BasicBlock *MergeBlock =
120 splitEdge(ExitingBB, ExitBB,
".merge_new_and_old", &DT, &LI, &RI);
121 MergeBlock->setName(
"polly.merge_new_and_old");
124 R.replaceExitRecursive(MergeBlock);
125 RI.setRegionFor(MergeBlock, R.getParent());
142 Function *F = SplitBlock->getParent();
143 BasicBlock *StartBlock =
144 BasicBlock::Create(F->getContext(),
"polly.start", F);
145 BasicBlock *ExitingBlock =
146 BasicBlock::Create(F->getContext(),
"polly.exiting", F);
147 SplitBlock->getTerminator()->eraseFromParent();
148 Builder.SetInsertPoint(SplitBlock);
149 BranchInst *CondBr = Builder.CreateCondBr(RTC, StartBlock,
S.getEntry());
151 if (Loop *L = LI.getLoopFor(SplitBlock)) {
152 L->addBasicBlockToLoop(StartBlock, LI);
153 L->addBasicBlockToLoop(ExitingBlock, LI);
155 DT.addNewBlock(StartBlock, SplitBlock);
156 DT.addNewBlock(ExitingBlock, StartBlock);
157 RI.setRegionFor(StartBlock, RI.getRegionFor(SplitBlock));
158 RI.setRegionFor(ExitingBlock, RI.getRegionFor(SplitBlock));
175 Builder.SetInsertPoint(StartBlock);
176 Builder.CreateBr(ExitingBlock);
177 DT.changeImmediateDominator(ExitingBlock, StartBlock);
180 Builder.SetInsertPoint(ExitingBlock);
181 Builder.CreateBr(MergeBlock);
182 DT.changeImmediateDominator(MergeBlock, SplitBlock);
200 splitEdge(SplitBlock, EntryBB,
".pre_entry_bb", &DT, &LI, &RI);
218 return std::make_pair(std::make_pair(StartBlock, ExitingBlock), CondBr);
polly dump Polly Dump Function
static BasicBlock * splitEdge(BasicBlock *Prev, BasicBlock *Succ, const char *Suffix, DominatorTree *DT, LoopInfo *LI, RegionInfo *RI)
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
std::pair< BBPair, llvm::BranchInst * > executeScopConditionally(Scop &S, llvm::Value *RTC, llvm::DominatorTree &DT, llvm::RegionInfo &RI, llvm::LoopInfo &LI)
Execute a Scop conditionally wrt RTC.
llvm::IRBuilder< llvm::ConstantFolder, IRInserter > PollyIRBuilder