aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-05 06:24:58 +0000
committerChris Lattner <sabre@nondot.org>2006-10-05 06:24:58 +0000
commit06a248c2385b997932689ed1312a1a6b1d814c3c (patch)
treeae144e15e2168e5d608c311ceb54f02efc2ad656
parent1907a7b37b867d015d49601ce65476ed7aaeceb0 (diff)
Add insertelement/extractelement helper ctors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30750 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Instructions.h8
-rw-r--r--lib/VMCore/Instructions.cpp53
2 files changed, 61 insertions, 0 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 4983dfaa75..38a3dde628 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -775,8 +775,12 @@ class ExtractElementInst : public Instruction {
public:
ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name = "",
Instruction *InsertBefore = 0);
+ ExtractElementInst(Value *Vec, unsigned Idx, const std::string &Name = "",
+ Instruction *InsertBefore = 0);
ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name,
BasicBlock *InsertAtEnd);
+ ExtractElementInst(Value *Vec, unsigned Idx, const std::string &Name,
+ BasicBlock *InsertAtEnd);
/// isValidOperands - Return true if an extractelement instruction can be
/// formed with the specified operands.
@@ -820,8 +824,12 @@ class InsertElementInst : public Instruction {
public:
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
const std::string &Name = "",Instruction *InsertBefore = 0);
+ InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
+ const std::string &Name = "",Instruction *InsertBefore = 0);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
const std::string &Name, BasicBlock *InsertAtEnd);
+ InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
+ const std::string &Name, BasicBlock *InsertAtEnd);
/// isValidOperands - Return true if an insertelement instruction can be
/// formed with the specified operands.
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 8f3633a66b..60fce0e492 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -844,6 +844,19 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
Ops[1].init(Index, this);
}
+ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
+ const std::string &Name,
+ Instruction *InsertBef)
+ : Instruction(cast<PackedType>(Val->getType())->getElementType(),
+ ExtractElement, Ops, 2, Name, InsertBef) {
+ Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+ assert(isValidOperands(Val, Index) &&
+ "Invalid extractelement instruction operands!");
+ Ops[0].init(Val, this);
+ Ops[1].init(Index, this);
+}
+
+
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
const std::string &Name,
BasicBlock *InsertAE)
@@ -856,6 +869,20 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
Ops[1].init(Index, this);
}
+ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
+ const std::string &Name,
+ BasicBlock *InsertAE)
+ : Instruction(cast<PackedType>(Val->getType())->getElementType(),
+ ExtractElement, Ops, 2, Name, InsertAE) {
+ Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+ assert(isValidOperands(Val, Index) &&
+ "Invalid extractelement instruction operands!");
+
+ Ops[0].init(Val, this);
+ Ops[1].init(Index, this);
+}
+
+
bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
if (!isa<PackedType>(Val->getType()) || Index->getType() != Type::UIntTy)
return false;
@@ -884,6 +911,19 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
Ops[2].init(Index, this);
}
+InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
+ const std::string &Name,
+ Instruction *InsertBef)
+ : Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertBef) {
+ Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+ assert(isValidOperands(Vec, Elt, Index) &&
+ "Invalid insertelement instruction operands!");
+ Ops[0].init(Vec, this);
+ Ops[1].init(Elt, this);
+ Ops[2].init(Index, this);
+}
+
+
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
const std::string &Name,
BasicBlock *InsertAE)
@@ -896,6 +936,19 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
Ops[2].init(Index, this);
}
+InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
+ const std::string &Name,
+ BasicBlock *InsertAE)
+: Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertAE) {
+ Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+ assert(isValidOperands(Vec, Elt, Index) &&
+ "Invalid insertelement instruction operands!");
+
+ Ops[0].init(Vec, this);
+ Ops[1].init(Elt, this);
+ Ops[2].init(Index, this);
+}
+
bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt,
const Value *Index) {
if (!isa<PackedType>(Vec->getType()))