[llvm-commits] [polly] r155349 - in /polly/trunk: include/polly/LoopGenerators.h lib/CodeGen/CodeGeneration.cpp lib/CodeGen/LoopGenerators.cpp
Hongbin Zheng
etherzhhb at gmail.com
Mon Apr 23 06:03:56 PDT 2012
Author: ether
Date: Mon Apr 23 08:03:56 2012
New Revision: 155349
URL: http://llvm.org/viewvc/llvm-project?rev=155349&view=rev
Log:
Refactor: Pass the argument 'IRBuilder' and 'AfterBlock' of function 'createLoop' by
reference, so that we do not need to type an extra '&' operator when calling the function.
Modified:
polly/trunk/include/polly/LoopGenerators.h
polly/trunk/lib/CodeGen/CodeGeneration.cpp
polly/trunk/lib/CodeGen/LoopGenerators.cpp
Modified: polly/trunk/include/polly/LoopGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/LoopGenerators.h?rev=155349&r1=155348&r2=155349&view=diff
==============================================================================
--- polly/trunk/include/polly/LoopGenerators.h (original)
+++ polly/trunk/include/polly/LoopGenerators.h Mon Apr 23 08:03:56 2012
@@ -36,8 +36,10 @@
/// @param Builder The builder used to create the loop.
/// @param P A pointer to the pass that uses this function. It is used
/// to update analysis information.
+///
+/// @return Value* The newly created induction variable for this loop.
Value *createLoop(Value *LowerBound, Value *UpperBound, Value *Stride,
- IRBuilder<> *Builder, Pass *P, BasicBlock **AfterBlock);
+ IRBuilder<> &Builder, Pass *P, BasicBlock *&AfterBlock);
class OMPGenerator {
public:
Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=155349&r1=155348&r2=155349&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Mon Apr 23 08:03:56 2012
@@ -1231,7 +1231,7 @@
UpperBound = ExpGen.codegen(f->UB, IntPtrTy);
Stride = Builder.getInt(APInt_from_MPZ(f->stride));
- IV = createLoop(LowerBound, UpperBound, Stride, &Builder, P, &AfterBB);
+ IV = createLoop(LowerBound, UpperBound, Stride, Builder, P, AfterBB);
// Add loop iv to symbols.
ClastVars[f->iterator] = IV;
Modified: polly/trunk/lib/CodeGen/LoopGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/LoopGenerators.cpp?rev=155349&r1=155348&r2=155349&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/LoopGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/LoopGenerators.cpp Mon Apr 23 08:03:56 2012
@@ -21,23 +21,25 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
using namespace llvm;
+using namespace polly;
-Value *createLoop(Value *LB, Value *UB, Value *Stride,
- IRBuilder<> *Builder, Pass *P, BasicBlock **AfterBlock) {
+Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
+ IRBuilder<> &Builder, Pass *P,
+ BasicBlock *&AfterBlock) {
DominatorTree &DT = P->getAnalysis<DominatorTree>();
- Function *F = Builder->GetInsertBlock()->getParent();
+ Function *F = Builder.GetInsertBlock()->getParent();
LLVMContext &Context = F->getContext();
- BasicBlock *PreheaderBB = Builder->GetInsertBlock();
+ BasicBlock *PreheaderBB = Builder.GetInsertBlock();
BasicBlock *HeaderBB = BasicBlock::Create(Context, "polly.loop_header", F);
BasicBlock *BodyBB = BasicBlock::Create(Context, "polly.loop_body", F);
- BasicBlock *AfterBB = SplitBlock(PreheaderBB, Builder->GetInsertPoint()++, P);
+ BasicBlock *AfterBB = SplitBlock(PreheaderBB, Builder.GetInsertPoint()++, P);
AfterBB->setName("polly.loop_after");
PreheaderBB->getTerminator()->setSuccessor(0, HeaderBB);
DT.addNewBlock(HeaderBB, PreheaderBB);
- Builder->SetInsertPoint(HeaderBB);
+ Builder.SetInsertPoint(HeaderBB);
// Use the type of upper and lower bound.
assert(LB->getType() == UB->getType()
@@ -47,26 +49,26 @@
assert(LoopIVType && "UB is not integer?");
// IV
- PHINode *IV = Builder->CreatePHI(LoopIVType, 2, "polly.loopiv");
+ PHINode *IV = Builder.CreatePHI(LoopIVType, 2, "polly.loopiv");
IV->addIncoming(LB, PreheaderBB);
- Stride = Builder->CreateZExtOrBitCast(Stride, LoopIVType);
- Value *IncrementedIV = Builder->CreateAdd(IV, Stride, "polly.next_loopiv");
+ Stride = Builder.CreateZExtOrBitCast(Stride, LoopIVType);
+ Value *IncrementedIV = Builder.CreateAdd(IV, Stride, "polly.next_loopiv");
// Exit condition.
Value *CMP;
- CMP = Builder->CreateICmpSLE(IV, UB);
+ CMP = Builder.CreateICmpSLE(IV, UB);
- Builder->CreateCondBr(CMP, BodyBB, AfterBB);
+ Builder.CreateCondBr(CMP, BodyBB, AfterBB);
DT.addNewBlock(BodyBB, HeaderBB);
- Builder->SetInsertPoint(BodyBB);
- Builder->CreateBr(HeaderBB);
+ Builder.SetInsertPoint(BodyBB);
+ Builder.CreateBr(HeaderBB);
IV->addIncoming(IncrementedIV, BodyBB);
DT.changeImmediateDominator(AfterBB, HeaderBB);
- Builder->SetInsertPoint(BodyBB->begin());
- *AfterBlock = AfterBB;
+ Builder.SetInsertPoint(BodyBB->begin());
+ AfterBlock = AfterBB;
return IV;
}
@@ -284,7 +286,7 @@
Builder.CreateBr(CheckNextBB);
Builder.SetInsertPoint(--Builder.GetInsertPoint());
- IV = createLoop(LowerBound, UpperBound, Stride, &Builder, P, &AfterBB);
+ IV = createLoop(LowerBound, UpperBound, Stride, Builder, P, AfterBB);
BasicBlock::iterator LoopBody = Builder.GetInsertPoint();
Builder.SetInsertPoint(AfterBB->begin());
More information about the llvm-commits
mailing list