Add insertelement/extractelement helper ctors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30750 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-10-05 06:24:58 +00:00
parent 1907a7b37b
commit 06a248c238
2 changed files with 61 additions and 0 deletions

View File

@ -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.

View File

@ -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()))