From: Nate Begeman Date: Fri, 6 Aug 2010 01:24:57 +0000 (+0000) Subject: vdup_lane was missing X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd480ad90ff4c144084805761d2dfa52ee9e1c92;p=clang vdup_lane was missing git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110420 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/arm_neon.td b/include/clang/Basic/arm_neon.td index b42755ca72..fa6ebb756c 100644 --- a/include/clang/Basic/arm_neon.td +++ b/include/clang/Basic/arm_neon.td @@ -64,6 +64,7 @@ class WInst : Inst {} // u: unsigned integer (int/float args) // f: float (int args) // d: default +// g: default, ignore 'Q' size modifier. // w: double width elements, same num elts // n: double width elements, half num elts // h: half width elements, double num elts @@ -239,6 +240,7 @@ def VCREATE: Inst<"dl", "csihfUcUsUiUlPcPsl", OP_CAST>; // E.3.19 Set all lanes to same value def VDUP_N : Inst<"ds", "UcUsUicsiPcPsfQUcQUsQUiQcQsQiQPcQPsQflUlQlQUl", OP_DUP>; def VMOV_N : Inst<"ds", "UcUsUicsiPcPsfQUcQUsQUiQcQsQiQPcQPsQflUlQlQUl", OP_DUP>; +def VDUP_LANE : WInst<"dgi", "UcUsUicsiPcPsfQUcQUsQUiQcQsQiQPcQPsQflUlQlQUl">; //////////////////////////////////////////////////////////////////////////////// // E.3.20 Combining vectors diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 666be7421f..d59131d1de 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1012,8 +1012,10 @@ const llvm::VectorType *GetNeonType(LLVMContext &C, unsigned type, bool q) { return 0; } -Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C) { +Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C, bool widen) { unsigned nElts = cast(V->getType())->getNumElements(); + if (widen) + nElts <<= 1; SmallVector Indices(nElts, C); Value* SV = llvm::ConstantVector::get(Indices.begin(), Indices.size()); return Builder.CreateShuffleVector(V, V, SV, "lane"); @@ -1201,6 +1203,12 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, Function *F = CGM.getIntrinsic(Int, Tys, 2); return EmitNeonCall(F, Ops, "vcvt_n"); } + case ARM::BI__builtin_neon_vdup_lane_v: + Ops[0] = Builder.CreateBitCast(Ops[0], Ty); + return EmitNeonSplat(Ops[0], cast(Ops[1])); + case ARM::BI__builtin_neon_vdupq_lane_v: + Ops[0] = Builder.CreateBitCast(Ops[0], Ty); + return EmitNeonSplat(Ops[0], cast(Ops[1]), true); case ARM::BI__builtin_neon_vext_v: case ARM::BI__builtin_neon_vextq_v: { ConstantInt *C = dyn_cast(Ops[2]); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index a72cc0fd2b..5934da0ef9 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1437,7 +1437,8 @@ public: llvm::SmallVectorImpl &O, const char *name, bool splat = false, unsigned shift = 0, bool rightshift = false); - llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx); + llvm::Value *EmitNeonSplat(llvm::Value *V, llvm::Constant *Idx, + bool widen = false); llvm::Value *EmitNeonShiftVector(llvm::Value *V, const llvm::Type *Ty, bool negateForRightShift);