> -----Original Message-----
> From: Beignet [mailto:[email protected]] On Behalf Of
> Pan Xiuli
> Sent: Thursday, December 24, 2015 4:25 PM
> To: [email protected]
> Cc: Pan, Xiuli <[email protected]>
> Subject: [Beignet] [PATCH] Backend: Refine new instruction with IRBuilder
> create
> 
> New instruction changes with the llvm version but the IRbuilder
> is more stables. So use IRBuilder create to make it can be built
> with more llvm version.
> 
> Signed-off-by: Pan Xiuli <[email protected]>
> ---
>  backend/src/llvm/llvm_scalarize.cpp | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/backend/src/llvm/llvm_scalarize.cpp
> b/backend/src/llvm/llvm_scalarize.cpp
> index b48ff81..0f84eea 100644
> --- a/backend/src/llvm/llvm_scalarize.cpp
> +++ b/backend/src/llvm/llvm_scalarize.cpp
> @@ -732,25 +732,25 @@ namespace gbe {
>          Value* foo = extr->getOperand(0);
>          Type* fooTy = foo->getType();
> 
> -        Instruction* Alloc;
> +        Value* Alloc;
>          if(vectorAlloca.find(foo) == vectorAlloca.end())
>          {
> -          Alloc = new AllocaInst(fooTy,0,"",extr->getParent()->begin());
> +          Alloc = new AllocaInst(fooTy, nullptr , "", 
> extr->getParent()->begin());
Please make sure all AllocaInst placed in a Function's entry basic block.
As we don't support dynamic stack allocation in OpenCL. Let's keep all 
AllocaInst in Entry block.
You can simply insert at the front of the entry block.
That would make the backend implementation simple.
And please also use IRbuilder instead of explicit AllocaInst constructor.

Thanks!
Ruiling
>            for (int i = 0; i < GetComponentCount(foo); ++i)
>            {
>              Value* foo_i = getComponent(i, foo);
>              assert(foo_i && "There is unhandled vector component");
>              Value* idxs_i[] = {ConstantInt::get(intTy,0), 
> ConstantInt::get(intTy,i)};
> -            Instruction* storePtr_i = GetElementPtrInst::Create(Alloc, 
> idxs_i, "",
> extr);
> -            new StoreInst(foo_i, storePtr_i, extr);
> +            Value* storePtr_i = builder->CreateGEP(Alloc, idxs_i);
> +            builder->CreateStore(foo_i, storePtr_i);
>            }
>            vectorAlloca[foo] = Alloc;
>          }
> -        else Alloc = dyn_cast<Instruction>(vectorAlloca[foo]);
> +        else Alloc = vectorAlloca[foo];
> 
>          Value* Idxs[] = {ConstantInt::get(intTy,0), extr->getOperand(1)};
> -        Instruction* getPtr = GetElementPtrInst::Create(Alloc, Idxs, "", 
> extr);
> -        Instruction* loadComp = new LoadInst(getPtr,"",extr);
> +        Value* getPtr = builder->CreateGEP(Alloc, Idxs);
> +        Value* loadComp = builder->CreateLoad(getPtr);
>          extr->replaceAllUsesWith(loadComp);
>          return true;
>      }
> --
> 2.1.4
> 
> _______________________________________________
> Beignet mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/beignet
_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to