Add more IR support for the new extractvalue and insertvalue

instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51461 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2008-05-23 00:36:11 +00:00
parent 4fa2a3f0ef
commit e4569943d9
3 changed files with 151 additions and 12 deletions

View File

@ -1689,8 +1689,42 @@ template <>
struct OperandTraits<ExtractValueInst> : VariadicOperandTraits<1> {
};
template<typename InputIterator>
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
const std::string &Name,
Instruction *InsertBefore)
: Instruction(checkType(getIndexedType(Agg->getType(), IdxBegin, IdxEnd)),
ExtractValue,
OperandTraits<ExtractValueInst>::op_end(this) - Values,
Values, InsertBefore) {
init(Agg, IdxBegin, IdxEnd, Name,
typename std::iterator_traits<InputIterator>::iterator_category());
}
template<typename InputIterator>
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
const std::string &Name,
BasicBlock *InsertAtEnd)
: Instruction(PointerType::get(checkType(
getIndexedType(Agg->getType(),
IdxBegin, IdxEnd)),
cast<PointerType>(Agg->getType())
->getAddressSpace()),
ExtractValue,
OperandTraits<ExtractValueInst>::op_end(this) - Values,
Values, InsertAtEnd) {
init(Agg, IdxBegin, IdxEnd, Name,
typename std::iterator_traits<InputIterator>::iterator_category());
}
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueInst, Value)
//===----------------------------------------------------------------------===//
// InsertValueInst Class
//===----------------------------------------------------------------------===//
@ -1840,6 +1874,44 @@ template <>
struct OperandTraits<InsertValueInst> : VariadicOperandTraits<2> {
};
template<typename InputIterator>
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
const std::string &Name,
Instruction *InsertBefore)
: Instruction(checkType(ExtractValueInst::getIndexedType(
Agg->getType(),
IdxBegin, IdxEnd)),
InsertValue,
OperandTraits<InsertValueInst>::op_end(this) - Values,
Values, InsertBefore) {
init(Agg, Val, IdxBegin, IdxEnd, Name,
typename std::iterator_traits<InputIterator>::iterator_category());
}
template<typename InputIterator>
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
const std::string &Name,
BasicBlock *InsertAtEnd)
: Instruction(PointerType::get(checkType(
ExtractValueInst::getIndexedType(
Val->getType(),
IdxBegin, IdxEnd)),
cast<PointerType>(Val->getType())
->getAddressSpace()),
InsertValue,
OperandTraits<InsertValueInst>::op_end(this) - Values,
Values, InsertAtEnd) {
init(Agg, Val, IdxBegin, IdxEnd, Name,
typename std::iterator_traits<InputIterator>::iterator_category());
}
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueInst, Value)
//===----------------------------------------------------------------------===//