diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 4983dfaa75e..38a3dde6285 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 8f3633a66b5..60fce0e4925 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(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(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(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(Vec->getType()))