[llvm] r271164 - [IR] Teach the ArrayRef<int> form of IRBuilder::CreateShuffleVector to use ConstantDataVector.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat May 28 19:39:20 PDT 2016
Author: ctopper
Date: Sat May 28 21:39:20 2016
New Revision: 271164
URL: http://llvm.org/viewvc/llvm-project?rev=271164&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/IR/Constants.h
llvm/trunk/include/llvm/IR/IRBuilder.h
llvm/trunk/lib/IR/Constants.cpp
Modified: llvm/trunk/include/llvm/IR/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Constants.h?rev=271164&r1=271163&r2=271164&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Constants.h (original)
+++ llvm/trunk/include/llvm/IR/Constants.h Sat May 28 21:39:20 2016
@@ -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);
Modified: llvm/trunk/include/llvm/IR/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRBuilder.h?rev=271164&r1=271163&r2=271164&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/IRBuilder.h Sat May 28 21:39:20 2016
@@ -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);
}
Modified: llvm/trunk/lib/IR/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Constants.cpp?rev=271164&r1=271163&r2=271164&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Constants.cpp (original)
+++ llvm/trunk/lib/IR/Constants.cpp Sat May 28 21:39:20 2016
@@ -2500,6 +2500,11 @@ Constant *ConstantDataVector::get(LLVMCo
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());
More information about the llvm-commits
mailing list