mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-24 05:09:34 +00:00
Add convenient overloads for CreateInsertElement and CreateExtractElement methods in IRBuilder
Summary: This pathc add convenient overloads for CreateInsertElement and CreateExtractElement methods in IRBuilder where vector index can be uint64_t instead of Value*. Test Plan: Unit test included. Reviewers: majnemer Reviewed By: majnemer Subscribers: majnemer, llvm-commits Differential Revision: http://reviews.llvm.org/D9347 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236214 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
83f2b45ec5
commit
ef0d2a6e01
@ -1499,6 +1499,11 @@ public:
|
||||
return Insert(ExtractElementInst::Create(Vec, Idx), Name);
|
||||
}
|
||||
|
||||
Value *CreateExtractElement(Value *Vec, uint64_t Idx,
|
||||
const Twine &Name = "") {
|
||||
return CreateExtractElement(Vec, getInt64(Idx), Name);
|
||||
}
|
||||
|
||||
Value *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx,
|
||||
const Twine &Name = "") {
|
||||
if (Constant *VC = dyn_cast<Constant>(Vec))
|
||||
@ -1508,6 +1513,11 @@ public:
|
||||
return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
|
||||
}
|
||||
|
||||
Value *CreateInsertElement(Value *Vec, Value *NewElt, uint64_t Idx,
|
||||
const Twine &Name = "") {
|
||||
return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
|
||||
}
|
||||
|
||||
Value *CreateShuffleVector(Value *V1, Value *V2, Value *Mask,
|
||||
const Twine &Name = "") {
|
||||
if (Constant *V1C = dyn_cast<Constant>(V1))
|
||||
|
@ -306,5 +306,20 @@ TEST_F(IRBuilderTest, DIBuilder) {
|
||||
EXPECT_TRUE(verifyModule(*M));
|
||||
}
|
||||
|
||||
TEST_F(IRBuilderTest, InsertExtractElement) {
|
||||
IRBuilder<> Builder(BB);
|
||||
|
||||
auto VecTy = VectorType::get(Builder.getInt64Ty(), 4);
|
||||
auto Elt1 = Builder.getInt64(-1);
|
||||
auto Elt2 = Builder.getInt64(-2);
|
||||
Value *Vec = UndefValue::get(VecTy);
|
||||
Vec = Builder.CreateInsertElement(Vec, Elt1, Builder.getInt8(1));
|
||||
Vec = Builder.CreateInsertElement(Vec, Elt2, 2);
|
||||
auto X1 = Builder.CreateExtractElement(Vec, 1);
|
||||
auto X2 = Builder.CreateExtractElement(Vec, Builder.getInt32(2));
|
||||
EXPECT_EQ(Elt1, X1);
|
||||
EXPECT_EQ(Elt2, X2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user