[IR] Teach the ArrayRef<int> form of IRBuilder::CreateShuffleVector to use ConstantDataVector.

This will be used in a follow up commit to simplify code in clang that creates a ConstantDataVector and calls the other form.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271164 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2016-05-29 02:39:20 +00:00
parent 65123b902b
commit 159551729d
3 changed files with 7 additions and 5 deletions

View File

@ -725,6 +725,7 @@ public:
static Constant *get(LLVMContext &Context, ArrayRef<uint8_t> Elts);
static Constant *get(LLVMContext &Context, ArrayRef<uint16_t> Elts);
static Constant *get(LLVMContext &Context, ArrayRef<uint32_t> Elts);
static Constant *get(LLVMContext &Context, ArrayRef<int32_t> Elts);
static Constant *get(LLVMContext &Context, ArrayRef<uint64_t> Elts);
static Constant *get(LLVMContext &Context, ArrayRef<float> Elts);
static Constant *get(LLVMContext &Context, ArrayRef<double> Elts);

View File

@ -1648,11 +1648,7 @@ public:
Value *CreateShuffleVector(Value *V1, Value *V2, ArrayRef<int> IntMask,
const Twine &Name = "") {
size_t MaskSize = IntMask.size();
SmallVector<Constant*, 8> MaskVec(MaskSize);
for (size_t i = 0; i != MaskSize; ++i)
MaskVec[i] = getInt32(IntMask[i]);
Value *Mask = ConstantVector::get(MaskVec);
Value *Mask = ConstantDataVector::get(Context, IntMask);
return CreateShuffleVector(V1, V2, Mask, Name);
}

View File

@ -2500,6 +2500,11 @@ Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint32_t> Elts)
const char *Data = reinterpret_cast<const char *>(Elts.data());
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*4), Ty);
}
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<int32_t> Elts){
Type *Ty = VectorType::get(Type::getInt32Ty(Context), Elts.size());
const char *Data = reinterpret_cast<const char *>(Elts.data());
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*4), Ty);
}
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint64_t> Elts){
Type *Ty = VectorType::get(Type::getInt64Ty(Context), Elts.size());
const char *Data = reinterpret_cast<const char *>(Elts.data());