forked from OSchip/llvm-project
make ExtractValueInst derived from UnaryInstruction
llvm-svn: 52061
This commit is contained in:
parent
fd1e32b1f3
commit
21ba184b27
|
@ -118,6 +118,7 @@ public:
|
|||
I->getOpcode() == Instruction::Load ||
|
||||
I->getOpcode() == Instruction::VAArg ||
|
||||
I->getOpcode() == Instruction::GetResult ||
|
||||
I->getOpcode() == Instruction::ExtractValue ||
|
||||
(I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
|
||||
}
|
||||
static inline bool classof(const Value *V) {
|
||||
|
|
|
@ -1453,7 +1453,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorInst, Value)
|
|||
/// ExtractValueInst - This instruction extracts a struct member or array
|
||||
/// element value from an aggregate value.
|
||||
///
|
||||
class ExtractValueInst : public Instruction {
|
||||
class ExtractValueInst : public UnaryInstruction {
|
||||
SmallVector<unsigned, 4> Indices;
|
||||
|
||||
ExtractValueInst(const ExtractValueInst &EVI);
|
||||
|
@ -1526,12 +1526,13 @@ class ExtractValueInst : public Instruction {
|
|||
Instruction *InsertBefore = 0);
|
||||
ExtractValueInst(Value *Agg, unsigned Idx,
|
||||
const std::string &Name, BasicBlock *InsertAtEnd);
|
||||
public:
|
||||
|
||||
// allocate space for exactly one operand
|
||||
void *operator new(size_t s) {
|
||||
return User::operator new(s, 1);
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename InputIterator>
|
||||
static ExtractValueInst *Create(Value *Agg, InputIterator IdxBegin,
|
||||
InputIterator IdxEnd,
|
||||
|
@ -1564,9 +1565,6 @@ public:
|
|||
|
||||
virtual ExtractValueInst *clone() const;
|
||||
|
||||
/// Transparently provide more efficient getOperand methods.
|
||||
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
||||
|
||||
// getType - Overload to return most specific pointer type...
|
||||
const PointerType *getType() const {
|
||||
return reinterpret_cast<const PointerType*>(Instruction::getType());
|
||||
|
@ -1619,20 +1617,15 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct OperandTraits<ExtractValueInst> : FixedNumOperandTraits<1> {
|
||||
};
|
||||
|
||||
template<typename InputIterator>
|
||||
ExtractValueInst::ExtractValueInst(Value *Agg,
|
||||
InputIterator IdxBegin,
|
||||
InputIterator IdxEnd,
|
||||
const std::string &Name,
|
||||
Instruction *InsertBefore)
|
||||
: Instruction(checkType(getIndexedType(Agg->getType(), IdxBegin, IdxEnd)),
|
||||
ExtractValue,
|
||||
OperandTraits<ExtractValueInst>::op_begin(this),
|
||||
1, InsertBefore) {
|
||||
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
|
||||
IdxBegin, IdxEnd)),
|
||||
ExtractValue, Agg, InsertBefore) {
|
||||
init(Agg, IdxBegin, IdxEnd, Name,
|
||||
typename std::iterator_traits<InputIterator>::iterator_category());
|
||||
}
|
||||
|
@ -1642,16 +1635,13 @@ ExtractValueInst::ExtractValueInst(Value *Agg,
|
|||
InputIterator IdxEnd,
|
||||
const std::string &Name,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: Instruction(checkType(getIndexedType(Agg->getType(), IdxBegin, IdxEnd)),
|
||||
ExtractValue,
|
||||
OperandTraits<ExtractValueInst>::op_begin(this),
|
||||
1, InsertAtEnd) {
|
||||
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
|
||||
IdxBegin, IdxEnd)),
|
||||
ExtractValue, Agg, InsertAtEnd) {
|
||||
init(Agg, IdxBegin, IdxEnd, Name,
|
||||
typename std::iterator_traits<InputIterator>::iterator_category());
|
||||
}
|
||||
|
||||
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueInst, Value)
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// InsertValueInst Class
|
||||
|
|
|
@ -999,7 +999,8 @@ static unsigned retrieveAddrSpace(const Value *Val) {
|
|||
return cast<PointerType>(Val->getType())->getAddressSpace();
|
||||
}
|
||||
|
||||
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx, const std::string &Name) {
|
||||
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
|
||||
const std::string &Name) {
|
||||
assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
|
||||
Use *OL = OperandList;
|
||||
OL[0] = Ptr;
|
||||
|
@ -1411,7 +1412,8 @@ InsertValueInst::InsertValueInst(Value *Agg,
|
|||
// ExtractValueInst Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void ExtractValueInst::init(Value *Agg, const unsigned *Idx, unsigned NumIdx, const std::string &Name) {
|
||||
void ExtractValueInst::init(Value *Agg, const unsigned *Idx, unsigned NumIdx,
|
||||
const std::string &Name) {
|
||||
assert(NumOperands == 1 && "NumOperands not initialized?");
|
||||
Op<0>() = Agg;
|
||||
|
||||
|
@ -1428,8 +1430,7 @@ void ExtractValueInst::init(Value *Agg, unsigned Idx, const std::string &Name) {
|
|||
}
|
||||
|
||||
ExtractValueInst::ExtractValueInst(const ExtractValueInst &EVI)
|
||||
: Instruction(reinterpret_cast<const Type*>(EVI.getType()), ExtractValue,
|
||||
OperandTraits<ExtractValueInst>::op_begin(this), 1),
|
||||
: UnaryInstruction(EVI.getType(), ExtractValue, EVI.getOperand(0)),
|
||||
Indices(EVI.Indices) {
|
||||
}
|
||||
|
||||
|
@ -1464,10 +1465,8 @@ ExtractValueInst::ExtractValueInst(Value *Agg,
|
|||
unsigned Idx,
|
||||
const std::string &Name,
|
||||
BasicBlock *InsertAtEnd)
|
||||
: Instruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
|
||||
ExtractValue,
|
||||
OperandTraits<ExtractValueInst>::op_begin(this),
|
||||
1, InsertAtEnd) {
|
||||
: UnaryInstruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
|
||||
ExtractValue, Agg, InsertAtEnd) {
|
||||
init(Agg, Idx, Name);
|
||||
}
|
||||
|
||||
|
@ -1475,10 +1474,8 @@ ExtractValueInst::ExtractValueInst(Value *Agg,
|
|||
unsigned Idx,
|
||||
const std::string &Name,
|
||||
Instruction *InsertBefore)
|
||||
: Instruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
|
||||
ExtractValue,
|
||||
OperandTraits<ExtractValueInst>::op_begin(this),
|
||||
1, InsertBefore) {
|
||||
: UnaryInstruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
|
||||
ExtractValue, Agg, InsertBefore) {
|
||||
init(Agg, Idx, Name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue