From fb018d153cbf12fd2a4a278cbf7614b9a2e2835e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 15 Feb 2011 00:14:06 +0000 Subject: [PATCH] update for ConstantVector API change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125538 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBuiltin.cpp | 19 +++++++++---------- lib/CodeGen/CGExpr.cpp | 16 +++++++--------- lib/CodeGen/CGExprConstant.cpp | 2 +- lib/CodeGen/CGExprScalar.cpp | 18 +++++++++--------- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 87572d68c6..5eeb605f18 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1061,7 +1061,7 @@ static const llvm::VectorType *GetNeonType(LLVMContext &C, unsigned type, Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C) { unsigned nElts = cast(V->getType())->getNumElements(); SmallVector Indices(nElts, C); - Value* SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); + Value* SV = llvm::ConstantVector::get(Indices); return Builder.CreateShuffleVector(V, V, SV, "lane"); } @@ -1087,7 +1087,7 @@ Value *CodeGenFunction::EmitNeonShiftVector(Value *V, const llvm::Type *Ty, const llvm::VectorType *VTy = cast(Ty); llvm::Constant *C = ConstantInt::get(VTy->getElementType(), neg ? -SV : SV); SmallVector CV(VTy->getNumElements(), C); - return llvm::ConstantVector::get(CV.begin(), CV.size()); + return llvm::ConstantVector::get(CV); } /// GetPointeeAlignment - Given an expression with a pointer type, find the @@ -1261,15 +1261,14 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, } case ARM::BI__builtin_neon_vext_v: case ARM::BI__builtin_neon_vextq_v: { - ConstantInt *C = dyn_cast(Ops[2]); - int CV = C->getSExtValue(); + int CV = cast(Ops[2])->getSExtValue(); SmallVector Indices; for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) Indices.push_back(ConstantInt::get(Int32Ty, i+CV)); Ops[0] = Builder.CreateBitCast(Ops[0], Ty); Ops[1] = Builder.CreateBitCast(Ops[1], Ty); - Value* SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); + Value *SV = llvm::ConstantVector::get(Indices); return Builder.CreateShuffleVector(Ops[0], Ops[1], SV, "vext"); } case ARM::BI__builtin_neon_vget_lane_i8: @@ -1756,7 +1755,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, Indices.push_back(ConstantInt::get(Int32Ty, i+e+vi)); } Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi); - SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); + SV = llvm::ConstantVector::get(Indices); SV = Builder.CreateShuffleVector(Ops[1], Ops[2], SV, "vtrn"); SV = Builder.CreateStore(SV, Addr); } @@ -1775,7 +1774,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, Indices.push_back(ConstantInt::get(Int32Ty, 2*i+vi)); Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi); - SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); + SV = llvm::ConstantVector::get(Indices); SV = Builder.CreateShuffleVector(Ops[1], Ops[2], SV, "vuzp"); SV = Builder.CreateStore(SV, Addr); } @@ -1795,7 +1794,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, Indices.push_back(ConstantInt::get(Int32Ty, ((i + vi*e) >> 1)+e)); } Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi); - SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); + SV = llvm::ConstantVector::get(Indices); SV = Builder.CreateShuffleVector(Ops[1], Ops[2], SV, "vzip"); SV = Builder.CreateStore(SV, Addr); } @@ -2032,7 +2031,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, for (unsigned i = 0; i != 8; ++i) Indices.push_back(llvm::ConstantInt::get(Int32Ty, shiftVal + i)); - Value* SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); + Value* SV = llvm::ConstantVector::get(Indices); return Builder.CreateShuffleVector(Ops[1], Ops[0], SV, "palignr"); } @@ -2063,7 +2062,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, for (unsigned i = 0; i != 16; ++i) Indices.push_back(llvm::ConstantInt::get(Int32Ty, shiftVal + i)); - Value* SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); + Value* SV = llvm::ConstantVector::get(Indices); return Builder.CreateShuffleVector(Ops[1], Ops[0], SV, "palignr"); } diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index e8ac813870..9e3ed62731 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -792,9 +792,8 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV, Mask.push_back(llvm::ConstantInt::get(Int32Ty, InIdx)); } - llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size()); - Vec = Builder.CreateShuffleVector(Vec, - llvm::UndefValue::get(Vec->getType()), + llvm::Value *MaskV = llvm::ConstantVector::get(Mask); + Vec = Builder.CreateShuffleVector(Vec, llvm::UndefValue::get(Vec->getType()), MaskV, "tmp"); return RValue::get(Vec); } @@ -997,7 +996,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, Mask[InIdx] = llvm::ConstantInt::get(Int32Ty, i); } - llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size()); + llvm::Value *MaskV = llvm::ConstantVector::get(Mask); Vec = Builder.CreateShuffleVector(SrcVal, llvm::UndefValue::get(Vec->getType()), MaskV, "tmp"); @@ -1012,8 +1011,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, ExtMask.push_back(llvm::ConstantInt::get(Int32Ty, i)); for (; i != NumDstElts; ++i) ExtMask.push_back(llvm::UndefValue::get(Int32Ty)); - llvm::Value *ExtMaskV = llvm::ConstantVector::get(&ExtMask[0], - ExtMask.size()); + llvm::Value *ExtMaskV = llvm::ConstantVector::get(ExtMask); llvm::Value *ExtSrcVal = Builder.CreateShuffleVector(SrcVal, llvm::UndefValue::get(SrcVal->getType()), @@ -1028,7 +1026,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, unsigned Idx = getAccessedFieldNo(i, Elts); Mask[Idx] = llvm::ConstantInt::get(Int32Ty, i+NumDstElts); } - llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size()); + llvm::Value *MaskV = llvm::ConstantVector::get(Mask); Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV, "tmp"); } else { // We should never shorten the vector @@ -1482,7 +1480,7 @@ llvm::Constant *GenerateConstantVector(llvm::LLVMContext &VMContext, for (unsigned i = 0, e = Elts.size(); i != e; ++i) CElts.push_back(llvm::ConstantInt::get(Int32Ty, Elts[i])); - return llvm::ConstantVector::get(&CElts[0], CElts.size()); + return llvm::ConstantVector::get(CElts); } LValue CodeGenFunction:: @@ -1535,7 +1533,7 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) { else CElts.push_back(cast(BaseElts->getOperand(Indices[i]))); } - llvm::Constant *CV = llvm::ConstantVector::get(&CElts[0], CElts.size()); + llvm::Constant *CV = llvm::ConstantVector::get(CElts); return LValue::MakeExtVectorElt(Base.getExtVectorAddr(), CV, Base.getVRQualifiers()); } diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index c569b37b94..d4d9c92838 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -914,7 +914,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, else Inits.push_back(llvm::ConstantFP::get(VMContext, Elt.getFloat())); } - return llvm::ConstantVector::get(&Inits[0], Inits.size()); + return llvm::ConstantVector::get(Inits); } } } diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index e309e36604..bd54549940 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -582,10 +582,10 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, // Splat the element across to all elements llvm::SmallVector Args; unsigned NumElements = cast(DstTy)->getNumElements(); - for (unsigned i = 0; i < NumElements; i++) + for (unsigned i = 0; i != NumElements; ++i) Args.push_back(llvm::ConstantInt::get(CGF.Int32Ty, 0)); - llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], NumElements); + llvm::Constant *Mask = llvm::ConstantVector::get(Args); llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat"); return Yay; } @@ -684,7 +684,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { concat.push_back(llvm::ConstantInt::get(CGF.Int32Ty, 2*i+1)); } - Value* CV = llvm::ConstantVector::get(concat.begin(), concat.size()); + Value* CV = llvm::ConstantVector::get(concat); LHS = Builder.CreateShuffleVector(LHS, RHS, CV, "concat"); LHSElts *= 2; } else { @@ -710,7 +710,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { for (unsigned i = 0, e = MTy->getNumElements(); i != e; ++i) MaskV.push_back(EltMask); - Value* MaskBits = llvm::ConstantVector::get(MaskV.begin(), MaskV.size()); + Value* MaskBits = llvm::ConstantVector::get(MaskV); Mask = Builder.CreateAnd(Mask, MaskBits, "mask"); // newv = undef @@ -762,7 +762,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { indices.push_back(C); } - Value* SV = llvm::ConstantVector::get(indices.begin(), indices.size()); + Value *SV = llvm::ConstantVector::get(indices); return Builder.CreateShuffleVector(V1, V2, SV, "shuffle"); } Value *ScalarExprEmitter::VisitMemberExpr(MemberExpr *E) { @@ -882,7 +882,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { VIsUndefShuffle = false; } if (!Args.empty()) { - llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], ResElts); + llvm::Constant *Mask = llvm::ConstantVector::get(Args); V = Builder.CreateShuffleVector(LHS, RHS, Mask); ++CurIdx; continue; @@ -937,7 +937,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { Args.push_back(llvm::ConstantInt::get(CGF.Int32Ty, j)); for (unsigned j = InitElts; j != ResElts; ++j) Args.push_back(llvm::UndefValue::get(CGF.Int32Ty)); - llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], ResElts); + llvm::Constant *Mask = llvm::ConstantVector::get(Args); Init = Builder.CreateShuffleVector(Init, llvm::UndefValue::get(VVT), Mask, "vext"); @@ -954,7 +954,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { // merging subsequent shuffles into this one. if (CurIdx == 0) std::swap(V, Init); - llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], ResElts); + llvm::Constant *Mask = llvm::ConstantVector::get(Args); V = Builder.CreateShuffleVector(V, Init, Mask, "vecinit"); VIsUndefShuffle = isa(Init); CurIdx += InitElts; @@ -1167,7 +1167,7 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { for (unsigned i = 0; i < NumElements; i++) Args.push_back(Zero); - llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], NumElements); + llvm::Constant *Mask = llvm::ConstantVector::get(Args); llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat"); return Yay; } -- 2.40.0