#ifndef LLVM_INSTRUCTIONS_H
#define LLVM_INSTRUCTIONS_H
#include "llvm/InstrTypes.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Attributes.h"
#include "llvm/BasicBlock.h"
#include "llvm/ADT/SmallVector.h"
#include <iterator>
namespace llvm {
class ConstantInt;
class ConstantRange;
class APInt;
class AllocationInst : public UnaryInstruction {
protected:
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
const std::string &Name = "", Instruction *InsertBefore = 0);
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
const std::string &Name, BasicBlock *InsertAtEnd);
public:
virtual ~AllocationInst();
bool isArrayAllocation() const;
const Value *getArraySize() const { return getOperand(0); }
Value *getArraySize() { return getOperand(0); }
const PointerType *getType() const {
return reinterpret_cast<const PointerType*>(Instruction::getType());
}
const Type *getAllocatedType() const;
unsigned getAlignment() const { return (1u << SubclassData) >> 1; }
void setAlignment(unsigned Align);
virtual Instruction *clone() const = 0;
static inline bool classof(const AllocationInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Alloca ||
I->getOpcode() == Instruction::Malloc;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class MallocInst : public AllocationInst {
MallocInst(const MallocInst &MI);
public:
explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
const std::string &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertBefore) {}
MallocInst(const Type *Ty, Value *ArraySize, const std::string &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, const std::string &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {}
MallocInst(const Type *Ty, const std::string &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
const std::string &NameStr, BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertAtEnd) {}
MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
const std::string &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertBefore) {}
virtual MallocInst *clone() const;
static inline bool classof(const MallocInst *) { return true; }
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::Malloc);
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class AllocaInst : public AllocationInst {
AllocaInst(const AllocaInst &);
public:
explicit AllocaInst(const Type *Ty, Value *ArraySize = 0,
const std::string &NameStr = "",
Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty, Value *ArraySize, const std::string &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {}
AllocaInst(const Type *Ty, const std::string &NameStr,
Instruction *InsertBefore = 0)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty, const std::string &NameStr,
BasicBlock *InsertAtEnd)
: AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {}
AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
const std::string &NameStr = "", Instruction *InsertBefore = 0)
: AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertBefore) {}
AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
const std::string &NameStr, BasicBlock *InsertAtEnd)
: AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertAtEnd) {}
virtual AllocaInst *clone() const;
bool isStaticAlloca() const;
static inline bool classof(const AllocaInst *) { return true; }
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::Alloca);
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class FreeInst : public UnaryInstruction {
void AssertOK();
public:
explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
FreeInst(Value *Ptr, BasicBlock *InsertAfter);
virtual FreeInst *clone() const;
Value *getPointerOperand() { return getOperand(0); }
const Value *getPointerOperand() const { return getOperand(0); }
static inline bool classof(const FreeInst *) { return true; }
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::Free);
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class LoadInst : public UnaryInstruction {
LoadInst(const LoadInst &LI)
: UnaryInstruction(LI.getType(), Load, LI.getOperand(0)) {
setVolatile(LI.isVolatile());
setAlignment(LI.getAlignment());
#ifndef NDEBUG
AssertOK();
#endif
}
void AssertOK();
public:
LoadInst(Value *Ptr, const std::string &NameStr, Instruction *InsertBefore);
LoadInst(Value *Ptr, const std::string &NameStr, BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile = false,
Instruction *InsertBefore = 0);
LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
unsigned Align, Instruction *InsertBefore = 0);
LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const std::string &NameStr, bool isVolatile,
unsigned Align, BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
LoadInst(Value *Ptr, const char *NameStr, BasicBlock *InsertAtEnd);
explicit LoadInst(Value *Ptr, const char *NameStr = 0,
bool isVolatile = false, Instruction *InsertBefore = 0);
LoadInst(Value *Ptr, const char *NameStr, bool isVolatile,
BasicBlock *InsertAtEnd);
bool isVolatile() const { return SubclassData & 1; }
void setVolatile(bool V) {
SubclassData = (SubclassData & ~1) | (V ? 1 : 0);
}
virtual LoadInst *clone() const;
unsigned getAlignment() const {
return (1 << (SubclassData>>1)) >> 1;
}
void setAlignment(unsigned Align);
Value *getPointerOperand() { return getOperand(0); }
const Value *getPointerOperand() const { return getOperand(0); }
static unsigned getPointerOperandIndex() { return 0U; }
static inline bool classof(const LoadInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Load;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class StoreInst : public Instruction {
void *operator new(size_t, unsigned);
StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store,
&Op<0>(), 2) {
Op<0>() = SI.Op<0>();
Op<1>() = SI.Op<1>();
setVolatile(SI.isVolatile());
setAlignment(SI.getAlignment());
#ifndef NDEBUG
AssertOK();
#endif
}
void AssertOK();
public:
void *operator new(size_t s) {
return User::operator new(s, 2);
}
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
Instruction *InsertBefore = 0);
StoreInst(Value *Val, Value *Ptr, bool isVolatile,
unsigned Align, Instruction *InsertBefore = 0);
StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
StoreInst(Value *Val, Value *Ptr, bool isVolatile,
unsigned Align, BasicBlock *InsertAtEnd);
bool isVolatile() const { return SubclassData & 1; }
void setVolatile(bool V) {
SubclassData = (SubclassData & ~1) | (V ? 1 : 0);
}
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
unsigned getAlignment() const {
return (1 << (SubclassData>>1)) >> 1;
}
void setAlignment(unsigned Align);
virtual StoreInst *clone() const;
Value *getPointerOperand() { return getOperand(1); }
const Value *getPointerOperand() const { return getOperand(1); }
static unsigned getPointerOperandIndex() { return 1U; }
static inline bool classof(const StoreInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Store;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<StoreInst> : FixedNumOperandTraits<2> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(StoreInst, Value)
static inline const Type *checkType(const Type *Ty) {
assert(Ty && "Invalid GetElementPtrInst indices for type!");
return Ty;
}
class GetElementPtrInst : public Instruction {
GetElementPtrInst(const GetElementPtrInst &GEPI);
void init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
const std::string &NameStr);
void init(Value *Ptr, Value *Idx, const std::string &NameStr);
template<typename InputIterator>
void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr,
std::random_access_iterator_tag) {
unsigned NumIdx = static_cast<unsigned>(std::distance(IdxBegin, IdxEnd));
if (NumIdx > 0) {
init(Ptr, &*IdxBegin, NumIdx, NameStr); }
else {
init(Ptr, 0, NumIdx, NameStr);
}
}
template<typename InputIterator>
static const Type *getIndexedType(const Type *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd,
std::random_access_iterator_tag) {
unsigned NumIdx = static_cast<unsigned>(std::distance(IdxBegin, IdxEnd));
if (NumIdx > 0)
return getIndexedType(Ptr, &*IdxBegin, NumIdx);
else
return getIndexedType(Ptr, (Value *const*)0, NumIdx);
}
template<typename InputIterator>
inline GetElementPtrInst(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
const std::string &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
unsigned Values,
const std::string &NameStr, BasicBlock *InsertAtEnd);
GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &NameStr = "",
Instruction *InsertBefore = 0);
GetElementPtrInst(Value *Ptr, Value *Idx,
const std::string &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
typename std::iterator_traits<InputIterator>::difference_type Values =
1 + std::distance(IdxBegin, IdxEnd);
return new(Values)
GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Values, NameStr, InsertBefore);
}
template<typename InputIterator>
static GetElementPtrInst *Create(Value *Ptr,
InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
typename std::iterator_traits<InputIterator>::difference_type Values =
1 + std::distance(IdxBegin, IdxEnd);
return new(Values)
GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Values, NameStr, InsertAtEnd);
}
static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertBefore);
}
static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
}
virtual GetElementPtrInst *clone() const;
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
const PointerType *getType() const {
return reinterpret_cast<const PointerType*>(Instruction::getType());
}
template<typename InputIterator>
static const Type *getIndexedType(const Type *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd) {
return getIndexedType(Ptr, IdxBegin, IdxEnd,
typename std::iterator_traits<InputIterator>::
iterator_category());
}
static const Type *getIndexedType(const Type *Ptr,
Value* const *Idx, unsigned NumIdx);
static const Type *getIndexedType(const Type *Ptr,
uint64_t const *Idx, unsigned NumIdx);
static const Type *getIndexedType(const Type *Ptr, Value *Idx);
inline op_iterator idx_begin() { return op_begin()+1; }
inline const_op_iterator idx_begin() const { return op_begin()+1; }
inline op_iterator idx_end() { return op_end(); }
inline const_op_iterator idx_end() const { return op_end(); }
Value *getPointerOperand() {
return getOperand(0);
}
const Value *getPointerOperand() const {
return getOperand(0);
}
static unsigned getPointerOperandIndex() {
return 0U; }
const PointerType *getPointerOperandType() const {
return reinterpret_cast<const PointerType*>(getPointerOperand()->getType());
}
unsigned getNumIndices() const { return getNumOperands() - 1;
}
bool hasIndices() const {
return getNumOperands() > 1;
}
bool hasAllZeroIndices() const;
bool hasAllConstantIndices() const;
static inline bool classof(const GetElementPtrInst *) { return true; }
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::GetElementPtr);
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<GetElementPtrInst> : VariadicOperandTraits<1> {
};
template<typename InputIterator>
GetElementPtrInst::GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
const std::string &NameStr,
Instruction *InsertBefore)
: Instruction(PointerType::get(checkType(
getIndexedType(Ptr->getType(),
IdxBegin, IdxEnd)),
cast<PointerType>(Ptr->getType())
->getAddressSpace()),
GetElementPtr,
OperandTraits<GetElementPtrInst>::op_end(this) - Values,
Values, InsertBefore) {
init(Ptr, IdxBegin, IdxEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
template<typename InputIterator>
GetElementPtrInst::GetElementPtrInst(Value *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd,
unsigned Values,
const std::string &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(PointerType::get(checkType(
getIndexedType(Ptr->getType(),
IdxBegin, IdxEnd)),
cast<PointerType>(Ptr->getType())
->getAddressSpace()),
GetElementPtr,
OperandTraits<GetElementPtrInst>::op_end(this) - Values,
Values, InsertAtEnd) {
init(Ptr, IdxBegin, IdxEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrInst, Value)
class ICmpInst: public CmpInst {
public:
ICmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr = "", Instruction *InsertBefore = 0 ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
InsertBefore) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
pred <= CmpInst::LAST_ICMP_PREDICATE &&
"Invalid ICmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to ICmp instruction are not of the same type!");
assert((getOperand(0)->getType()->isIntOrIntVector() ||
isa<PointerType>(getOperand(0)->getType())) &&
"Invalid operand types for ICmp instruction");
}
ICmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr, BasicBlock *InsertAtEnd ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr,
InsertAtEnd) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
pred <= CmpInst::LAST_ICMP_PREDICATE &&
"Invalid ICmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to ICmp instruction are not of the same type!");
assert((getOperand(0)->getType()->isIntOrIntVector() ||
isa<PointerType>(getOperand(0)->getType())) &&
"Invalid operand types for ICmp instruction");
}
Predicate getSignedPredicate() const {
return getSignedPredicate(getPredicate());
}
static Predicate getSignedPredicate(Predicate pred);
Predicate getUnsignedPredicate() const {
return getUnsignedPredicate(getPredicate());
}
static Predicate getUnsignedPredicate(Predicate pred);
static bool isEquality(Predicate P) {
return P == ICMP_EQ || P == ICMP_NE;
}
bool isEquality() const {
return isEquality(getPredicate());
}
bool isCommutative() const { return isEquality(); }
bool isRelational() const {
return !isEquality();
}
static bool isRelational(Predicate P) {
return !isEquality(P);
}
bool isSignedPredicate() const { return isSignedPredicate(getPredicate()); }
static bool isSignedPredicate(Predicate pred);
static bool isTrueWhenEqual(ICmpInst::Predicate pred) {
return pred == ICmpInst::ICMP_EQ || pred == ICmpInst::ICMP_UGE ||
pred == ICmpInst::ICMP_SGE || pred == ICmpInst::ICMP_ULE ||
pred == ICmpInst::ICMP_SLE;
}
bool isTrueWhenEqual() {
return isTrueWhenEqual(getPredicate());
}
static ConstantRange makeConstantRange(Predicate pred, const APInt &C);
void swapOperands() {
SubclassData = getSwappedPredicate();
Op<0>().swap(Op<1>());
}
virtual ICmpInst *clone() const;
static inline bool classof(const ICmpInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::ICmp;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class FCmpInst: public CmpInst {
public:
FCmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr = "", Instruction *InsertBefore = 0 ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
InsertBefore) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
"Invalid FCmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to FCmp instruction are not of the same type!");
assert(getOperand(0)->getType()->isFPOrFPVector() &&
"Invalid operand types for FCmp instruction");
}
FCmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr, BasicBlock *InsertAtEnd ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
InsertAtEnd) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
"Invalid FCmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to FCmp instruction are not of the same type!");
assert(getOperand(0)->getType()->isFPOrFPVector() &&
"Invalid operand types for FCmp instruction");
}
bool isEquality() const {
return SubclassData == FCMP_OEQ || SubclassData == FCMP_ONE ||
SubclassData == FCMP_UEQ || SubclassData == FCMP_UNE;
}
bool isCommutative() const {
return isEquality() ||
SubclassData == FCMP_FALSE ||
SubclassData == FCMP_TRUE ||
SubclassData == FCMP_ORD ||
SubclassData == FCMP_UNO;
}
bool isRelational() const { return !isEquality(); }
void swapOperands() {
SubclassData = getSwappedPredicate();
Op<0>().swap(Op<1>());
}
virtual FCmpInst *clone() const;
static inline bool classof(const FCmpInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::FCmp;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class VICmpInst: public CmpInst {
public:
VICmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr = "", Instruction *InsertBefore = 0 ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr,
InsertBefore) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
pred <= CmpInst::LAST_ICMP_PREDICATE &&
"Invalid VICmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to VICmp instruction are not of the same type!");
}
VICmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr, BasicBlock *InsertAtEnd ) : CmpInst(LHS->getType(), Instruction::VICmp, pred, LHS, RHS, NameStr,
InsertAtEnd) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
pred <= CmpInst::LAST_ICMP_PREDICATE &&
"Invalid VICmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to VICmp instruction are not of the same type!");
}
Predicate getPredicate() const { return Predicate(SubclassData); }
virtual VICmpInst *clone() const;
static inline bool classof(const VICmpInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::VICmp;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class VFCmpInst: public CmpInst {
public:
VFCmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr = "", Instruction *InsertBefore = 0 ) : CmpInst(VectorType::getInteger(cast<VectorType>(LHS->getType())),
Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertBefore) {
assert(pred <= CmpInst::LAST_FCMP_PREDICATE &&
"Invalid VFCmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to VFCmp instruction are not of the same type!");
}
VFCmpInst(
Predicate pred, Value *LHS, Value *RHS, const std::string &NameStr, BasicBlock *InsertAtEnd ) : CmpInst(VectorType::getInteger(cast<VectorType>(LHS->getType())),
Instruction::VFCmp, pred, LHS, RHS, NameStr, InsertAtEnd) {
assert(pred <= CmpInst::LAST_FCMP_PREDICATE &&
"Invalid VFCmp predicate value");
assert(getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to VFCmp instruction are not of the same type!");
}
Predicate getPredicate() const { return Predicate(SubclassData); }
virtual VFCmpInst *clone() const;
static inline bool classof(const VFCmpInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::VFCmp;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class CallInst : public Instruction {
AttrListPtr AttributeList; CallInst(const CallInst &CI);
void init(Value *Func, Value* const *Params, unsigned NumParams);
void init(Value *Func, Value *Actual1, Value *Actual2);
void init(Value *Func, Value *Actual);
void init(Value *Func);
template<typename InputIterator>
void init(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr,
std::random_access_iterator_tag) {
unsigned NumArgs = (unsigned)std::distance(ArgBegin, ArgEnd);
init(Func, NumArgs ? &*ArgBegin : 0, NumArgs);
setName(NameStr);
}
template<typename InputIterator>
CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr, Instruction *InsertBefore);
template<typename InputIterator>
inline CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr, BasicBlock *InsertAtEnd);
CallInst(Value *F, Value *Actual, const std::string& NameStr,
Instruction *InsertBefore);
CallInst(Value *F, Value *Actual, const std::string& NameStr,
BasicBlock *InsertAtEnd);
explicit CallInst(Value *F, const std::string &NameStr,
Instruction *InsertBefore);
CallInst(Value *F, const std::string &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static CallInst *Create(Value *Func,
InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new((unsigned)(ArgEnd - ArgBegin + 1))
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertBefore);
}
template<typename InputIterator>
static CallInst *Create(Value *Func,
InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr, BasicBlock *InsertAtEnd) {
return new((unsigned)(ArgEnd - ArgBegin + 1))
CallInst(Func, ArgBegin, ArgEnd, NameStr, InsertAtEnd);
}
static CallInst *Create(Value *F, Value *Actual,
const std::string& NameStr = "",
Instruction *InsertBefore = 0) {
return new(2) CallInst(F, Actual, NameStr, InsertBefore);
}
static CallInst *Create(Value *F, Value *Actual, const std::string& NameStr,
BasicBlock *InsertAtEnd) {
return new(2) CallInst(F, Actual, NameStr, InsertAtEnd);
}
static CallInst *Create(Value *F, const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new(1) CallInst(F, NameStr, InsertBefore);
}
static CallInst *Create(Value *F, const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new(1) CallInst(F, NameStr, InsertAtEnd);
}
~CallInst();
bool isTailCall() const { return SubclassData & 1; }
void setTailCall(bool isTC = true) {
SubclassData = (SubclassData & ~1) | unsigned(isTC);
}
virtual CallInst *clone() const;
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
unsigned getCallingConv() const { return SubclassData >> 1; }
void setCallingConv(unsigned CC) {
SubclassData = (SubclassData & 1) | (CC << 1);
}
const AttrListPtr &getAttributes() const { return AttributeList; }
void setAttributes(const AttrListPtr &Attrs) { AttributeList = Attrs; }
void addAttribute(unsigned i, Attributes attr);
void removeAttribute(unsigned i, Attributes attr);
bool paramHasAttr(unsigned i, Attributes attr) const;
unsigned getParamAlignment(unsigned i) const {
return AttributeList.getParamAlignment(i);
}
bool doesNotAccessMemory() const {
return paramHasAttr(~0, Attribute::ReadNone);
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
else removeAttribute(~0, Attribute::ReadNone);
}
bool onlyReadsMemory() const {
return doesNotAccessMemory() || paramHasAttr(~0, Attribute::ReadOnly);
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone);
}
bool doesNotReturn() const {
return paramHasAttr(~0, Attribute::NoReturn);
}
void setDoesNotReturn(bool DoesNotReturn = true) {
if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
else removeAttribute(~0, Attribute::NoReturn);
}
bool doesNotThrow() const {
return paramHasAttr(~0, Attribute::NoUnwind);
}
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
else removeAttribute(~0, Attribute::NoUnwind);
}
bool hasStructRetAttr() const {
return paramHasAttr(1, Attribute::StructRet);
}
bool hasByValArgument() const {
return AttributeList.hasAttrSomewhere(Attribute::ByVal);
}
Function *getCalledFunction() const {
return dyn_cast<Function>(Op<0>());
}
const Value *getCalledValue() const { return Op<0>(); }
Value *getCalledValue() { return Op<0>(); }
static inline bool classof(const CallInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Call;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<CallInst> : VariadicOperandTraits<1> {
};
template<typename InputIterator>
CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr, BasicBlock *InsertAtEnd)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Call,
OperandTraits<CallInst>::op_end(this) - (ArgEnd - ArgBegin + 1),
(unsigned)(ArgEnd - ArgBegin + 1), InsertAtEnd) {
init(Func, ArgBegin, ArgEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
template<typename InputIterator>
CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr, Instruction *InsertBefore)
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Call,
OperandTraits<CallInst>::op_end(this) - (ArgEnd - ArgBegin + 1),
(unsigned)(ArgEnd - ArgBegin + 1), InsertBefore) {
init(Func, ArgBegin, ArgEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CallInst, Value)
class SelectInst : public Instruction {
void init(Value *C, Value *S1, Value *S2) {
assert(!areInvalidOperands(C, S1, S2) && "Invalid operands for select");
Op<0>() = C;
Op<1>() = S1;
Op<2>() = S2;
}
SelectInst(const SelectInst &SI)
: Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) {
init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>());
}
SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
Instruction *InsertBefore)
: Instruction(S1->getType(), Instruction::Select,
&Op<0>(), 3, InsertBefore) {
init(C, S1, S2);
setName(NameStr);
}
SelectInst(Value *C, Value *S1, Value *S2, const std::string &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(S1->getType(), Instruction::Select,
&Op<0>(), 3, InsertAtEnd) {
init(C, S1, S2);
setName(NameStr);
}
public:
static SelectInst *Create(Value *C, Value *S1, Value *S2,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new(3) SelectInst(C, S1, S2, NameStr, InsertBefore);
}
static SelectInst *Create(Value *C, Value *S1, Value *S2,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new(3) SelectInst(C, S1, S2, NameStr, InsertAtEnd);
}
Value *getCondition() const { return Op<0>(); }
Value *getTrueValue() const { return Op<1>(); }
Value *getFalseValue() const { return Op<2>(); }
static const char *areInvalidOperands(Value *Cond, Value *True, Value *False);
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
OtherOps getOpcode() const {
return static_cast<OtherOps>(Instruction::getOpcode());
}
virtual SelectInst *clone() const;
static inline bool classof(const SelectInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Select;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<SelectInst> : FixedNumOperandTraits<3> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectInst, Value)
class VAArgInst : public UnaryInstruction {
VAArgInst(const VAArgInst &VAA)
: UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
public:
VAArgInst(Value *List, const Type *Ty, const std::string &NameStr = "",
Instruction *InsertBefore = 0)
: UnaryInstruction(Ty, VAArg, List, InsertBefore) {
setName(NameStr);
}
VAArgInst(Value *List, const Type *Ty, const std::string &NameStr,
BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
setName(NameStr);
}
virtual VAArgInst *clone() const;
static inline bool classof(const VAArgInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == VAArg;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class ExtractElementInst : public Instruction {
ExtractElementInst(const ExtractElementInst &EE) :
Instruction(EE.getType(), ExtractElement, &Op<0>(), 2) {
Op<0>() = EE.Op<0>();
Op<1>() = EE.Op<1>();
}
public:
void *operator new(size_t s) {
return User::operator new(s, 2); }
ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr = "",
Instruction *InsertBefore = 0);
ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr = "",
Instruction *InsertBefore = 0);
ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr,
BasicBlock *InsertAtEnd);
ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr,
BasicBlock *InsertAtEnd);
static bool isValidOperands(const Value *Vec, const Value *Idx);
virtual ExtractElementInst *clone() const;
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
static inline bool classof(const ExtractElementInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::ExtractElement;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<ExtractElementInst> : FixedNumOperandTraits<2> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst, Value)
class InsertElementInst : public Instruction {
InsertElementInst(const InsertElementInst &IE);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
const std::string &NameStr = "",
Instruction *InsertBefore = 0);
InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
const std::string &NameStr = "",
Instruction *InsertBefore = 0);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
const std::string &NameStr, BasicBlock *InsertAtEnd);
InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
const std::string &NameStr, BasicBlock *InsertAtEnd);
public:
static InsertElementInst *Create(const InsertElementInst &IE) {
return new(IE.getNumOperands()) InsertElementInst(IE);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
}
static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd);
}
static bool isValidOperands(const Value *Vec, const Value *NewElt,
const Value *Idx);
virtual InsertElementInst *clone() const;
const VectorType *getType() const {
return reinterpret_cast<const VectorType*>(Instruction::getType());
}
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
static inline bool classof(const InsertElementInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::InsertElement;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<InsertElementInst> : FixedNumOperandTraits<3> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementInst, Value)
class ShuffleVectorInst : public Instruction {
ShuffleVectorInst(const ShuffleVectorInst &IE);
public:
void *operator new(size_t s) {
return User::operator new(s, 3);
}
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
const std::string &NameStr = "",
Instruction *InsertBefor = 0);
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
const std::string &NameStr, BasicBlock *InsertAtEnd);
static bool isValidOperands(const Value *V1, const Value *V2,
const Value *Mask);
virtual ShuffleVectorInst *clone() const;
const VectorType *getType() const {
return reinterpret_cast<const VectorType*>(Instruction::getType());
}
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
int getMaskValue(unsigned i) const;
static inline bool classof(const ShuffleVectorInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::ShuffleVector;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<ShuffleVectorInst> : FixedNumOperandTraits<3> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorInst, Value)
class ExtractValueInst : public UnaryInstruction {
SmallVector<unsigned, 4> Indices;
ExtractValueInst(const ExtractValueInst &EVI);
void init(const unsigned *Idx, unsigned NumIdx,
const std::string &NameStr);
void init(unsigned Idx, const std::string &NameStr);
template<typename InputIterator>
void init(InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr,
std::random_access_iterator_tag) {
unsigned NumIdx = static_cast<unsigned>(std::distance(IdxBegin, IdxEnd));
assert(NumIdx > 0 && "ExtractValueInst must have at least one index");
init(&*IdxBegin, NumIdx, NameStr); }
static const Type *getIndexedType(const Type *Agg,
const unsigned *Idx, unsigned NumIdx);
template<typename InputIterator>
static const Type *getIndexedType(const Type *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd,
std::random_access_iterator_tag) {
unsigned NumIdx = static_cast<unsigned>(std::distance(IdxBegin, IdxEnd));
if (NumIdx > 0)
return getIndexedType(Ptr, &*IdxBegin, NumIdx);
else
return getIndexedType(Ptr, (const unsigned *)0, NumIdx);
}
template<typename InputIterator>
inline ExtractValueInst(Value *Agg, InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline ExtractValueInst(Value *Agg,
InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr, BasicBlock *InsertAtEnd);
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,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new
ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertBefore);
}
template<typename InputIterator>
static ExtractValueInst *Create(Value *Agg,
InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new ExtractValueInst(Agg, IdxBegin, IdxEnd, NameStr, InsertAtEnd);
}
static ExtractValueInst *Create(Value *Agg, unsigned Idx,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
unsigned Idxs[1] = { Idx };
return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertBefore);
}
static ExtractValueInst *Create(Value *Agg, unsigned Idx,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Idxs[1] = { Idx };
return new ExtractValueInst(Agg, Idxs, Idxs + 1, NameStr, InsertAtEnd);
}
virtual ExtractValueInst *clone() const;
const PointerType *getType() const {
return reinterpret_cast<const PointerType*>(Instruction::getType());
}
template<typename InputIterator>
static const Type *getIndexedType(const Type *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd) {
return getIndexedType(Ptr, IdxBegin, IdxEnd,
typename std::iterator_traits<InputIterator>::
iterator_category());
}
static const Type *getIndexedType(const Type *Ptr, unsigned Idx);
typedef const unsigned* idx_iterator;
inline idx_iterator idx_begin() const { return Indices.begin(); }
inline idx_iterator idx_end() const { return Indices.end(); }
Value *getAggregateOperand() {
return getOperand(0);
}
const Value *getAggregateOperand() const {
return getOperand(0);
}
static unsigned getAggregateOperandIndex() {
return 0U; }
unsigned getNumIndices() const { return (unsigned)Indices.size();
}
bool hasIndices() const {
return true;
}
static inline bool classof(const ExtractValueInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::ExtractValue;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template<typename InputIterator>
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr,
Instruction *InsertBefore)
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
IdxBegin, IdxEnd)),
ExtractValue, Agg, InsertBefore) {
init(IdxBegin, IdxEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
template<typename InputIterator>
ExtractValueInst::ExtractValueInst(Value *Agg,
InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr,
BasicBlock *InsertAtEnd)
: UnaryInstruction(checkType(getIndexedType(Agg->getType(),
IdxBegin, IdxEnd)),
ExtractValue, Agg, InsertAtEnd) {
init(IdxBegin, IdxEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
class InsertValueInst : public Instruction {
SmallVector<unsigned, 4> Indices;
void *operator new(size_t, unsigned); InsertValueInst(const InsertValueInst &IVI);
void init(Value *Agg, Value *Val, const unsigned *Idx, unsigned NumIdx,
const std::string &NameStr);
void init(Value *Agg, Value *Val, unsigned Idx, const std::string &NameStr);
template<typename InputIterator>
void init(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr,
std::random_access_iterator_tag) {
unsigned NumIdx = static_cast<unsigned>(std::distance(IdxBegin, IdxEnd));
assert(NumIdx > 0 && "InsertValueInst must have at least one index");
init(Agg, Val, &*IdxBegin, NumIdx, NameStr); }
template<typename InputIterator>
inline InsertValueInst(Value *Agg, Value *Val, InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr,
Instruction *InsertBefore);
template<typename InputIterator>
inline InsertValueInst(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr, BasicBlock *InsertAtEnd);
InsertValueInst(Value *Agg, Value *Val,
unsigned Idx, const std::string &NameStr = "",
Instruction *InsertBefore = 0);
InsertValueInst(Value *Agg, Value *Val, unsigned Idx,
const std::string &NameStr, BasicBlock *InsertAtEnd);
public:
void *operator new(size_t s) {
return User::operator new(s, 2);
}
template<typename InputIterator>
static InsertValueInst *Create(Value *Agg, Value *Val, InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
NameStr, InsertBefore);
}
template<typename InputIterator>
static InsertValueInst *Create(Value *Agg, Value *Val,
InputIterator IdxBegin, InputIterator IdxEnd,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new InsertValueInst(Agg, Val, IdxBegin, IdxEnd,
NameStr, InsertAtEnd);
}
static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new InsertValueInst(Agg, Val, Idx, NameStr, InsertBefore);
}
static InsertValueInst *Create(Value *Agg, Value *Val, unsigned Idx,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new InsertValueInst(Agg, Val, Idx, NameStr, InsertAtEnd);
}
virtual InsertValueInst *clone() const;
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
const PointerType *getType() const {
return reinterpret_cast<const PointerType*>(Instruction::getType());
}
typedef const unsigned* idx_iterator;
inline idx_iterator idx_begin() const { return Indices.begin(); }
inline idx_iterator idx_end() const { return Indices.end(); }
Value *getAggregateOperand() {
return getOperand(0);
}
const Value *getAggregateOperand() const {
return getOperand(0);
}
static unsigned getAggregateOperandIndex() {
return 0U; }
Value *getInsertedValueOperand() {
return getOperand(1);
}
const Value *getInsertedValueOperand() const {
return getOperand(1);
}
static unsigned getInsertedValueOperandIndex() {
return 1U; }
unsigned getNumIndices() const { return (unsigned)Indices.size();
}
bool hasIndices() const {
return true;
}
static inline bool classof(const InsertValueInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::InsertValue;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
template <>
struct OperandTraits<InsertValueInst> : FixedNumOperandTraits<2> {
};
template<typename InputIterator>
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr,
Instruction *InsertBefore)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
2, InsertBefore) {
init(Agg, Val, IdxBegin, IdxEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
template<typename InputIterator>
InsertValueInst::InsertValueInst(Value *Agg,
Value *Val,
InputIterator IdxBegin,
InputIterator IdxEnd,
const std::string &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(Agg->getType(), InsertValue,
OperandTraits<InsertValueInst>::op_begin(this),
2, InsertAtEnd) {
init(Agg, Val, IdxBegin, IdxEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueInst, Value)
class PHINode : public Instruction {
void *operator new(size_t, unsigned); unsigned ReservedSpace;
PHINode(const PHINode &PN);
void *operator new(size_t s) {
return User::operator new(s, 0);
}
explicit PHINode(const Type *Ty, const std::string &NameStr = "",
Instruction *InsertBefore = 0)
: Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
ReservedSpace(0) {
setName(NameStr);
}
PHINode(const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd)
: Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
ReservedSpace(0) {
setName(NameStr);
}
public:
static PHINode *Create(const Type *Ty, const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
return new PHINode(Ty, NameStr, InsertBefore);
}
static PHINode *Create(const Type *Ty, const std::string &NameStr,
BasicBlock *InsertAtEnd) {
return new PHINode(Ty, NameStr, InsertAtEnd);
}
~PHINode();
void reserveOperandSpace(unsigned NumValues) {
resizeOperands(NumValues*2);
}
virtual PHINode *clone() const;
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
unsigned getNumIncomingValues() const { return getNumOperands()/2; }
Value *getIncomingValue(unsigned i) const {
assert(i*2 < getNumOperands() && "Invalid value number!");
return getOperand(i*2);
}
void setIncomingValue(unsigned i, Value *V) {
assert(i*2 < getNumOperands() && "Invalid value number!");
setOperand(i*2, V);
}
static unsigned getOperandNumForIncomingValue(unsigned i) {
return i*2;
}
static unsigned getIncomingValueNumForOperand(unsigned i) {
assert(i % 2 == 0 && "Invalid incoming-value operand index!");
return i/2;
}
template <typename U>
BasicBlock *getIncomingBlock(value_use_iterator<U> I) const {
assert(this == *I && "Iterator doesn't point to PHI's Uses?");
return static_cast<BasicBlock*>((&I.getUse() + 1)->get());
}
BasicBlock *getIncomingBlock(unsigned i) const {
return static_cast<BasicBlock*>(getOperand(i*2+1));
}
void setIncomingBlock(unsigned i, BasicBlock *BB) {
setOperand(i*2+1, BB);
}
static unsigned getOperandNumForIncomingBlock(unsigned i) {
return i*2+1;
}
static unsigned getIncomingBlockNumForOperand(unsigned i) {
assert(i % 2 == 1 && "Invalid incoming-block operand index!");
return i/2;
}
void addIncoming(Value *V, BasicBlock *BB) {
assert(V && "PHI node got a null value!");
assert(BB && "PHI node got a null basic block!");
assert(getType() == V->getType() &&
"All operands to PHI node must be the same type as the PHI node!");
unsigned OpNo = NumOperands;
if (OpNo+2 > ReservedSpace)
resizeOperands(0); NumOperands = OpNo+2;
OperandList[OpNo] = V;
OperandList[OpNo+1] = BB;
}
Value *removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty = true);
Value *removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true) {
int Idx = getBasicBlockIndex(BB);
assert(Idx >= 0 && "Invalid basic block argument to remove!");
return removeIncomingValue(Idx, DeletePHIIfEmpty);
}
int getBasicBlockIndex(const BasicBlock *BB) const {
Use *OL = OperandList;
for (unsigned i = 0, e = getNumOperands(); i != e; i += 2)
if (OL[i+1].get() == BB) return i/2;
return -1;
}
Value *getIncomingValueForBlock(const BasicBlock *BB) const {
return getIncomingValue(getBasicBlockIndex(BB));
}
Value *hasConstantValue(bool AllowNonDominatingInstruction = false) const;
static inline bool classof(const PHINode *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::PHI;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
void resizeOperands(unsigned NumOperands);
};
template <>
struct OperandTraits<PHINode> : HungoffOperandTraits<2> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(PHINode, Value)
class ReturnInst : public TerminatorInst {
ReturnInst(const ReturnInst &RI);
private:
explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
explicit ReturnInst(BasicBlock *InsertAtEnd);
public:
static ReturnInst* Create(Value *retVal = 0, Instruction *InsertBefore = 0) {
return new(!!retVal) ReturnInst(retVal, InsertBefore);
}
static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) {
return new(!!retVal) ReturnInst(retVal, InsertAtEnd);
}
static ReturnInst* Create(BasicBlock *InsertAtEnd) {
return new(0) ReturnInst(InsertAtEnd);
}
virtual ~ReturnInst();
virtual ReturnInst *clone() const;
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
Value *getReturnValue(unsigned n = 0) const {
return n < getNumOperands()
? getOperand(n)
: 0;
}
unsigned getNumSuccessors() const { return 0; }
static inline bool classof(const ReturnInst *) { return true; }
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::Ret);
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
template <>
struct OperandTraits<ReturnInst> : OptionalOperandTraits<> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value)
class BranchInst : public TerminatorInst {
BranchInst(const BranchInst &BI);
void AssertOK();
explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0);
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
Instruction *InsertBefore = 0);
BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd);
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
BasicBlock *InsertAtEnd);
public:
static BranchInst *Create(BasicBlock *IfTrue, Instruction *InsertBefore = 0) {
return new(1, true) BranchInst(IfTrue, InsertBefore);
}
static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse,
Value *Cond, Instruction *InsertBefore = 0) {
return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore);
}
static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) {
return new(1, true) BranchInst(IfTrue, InsertAtEnd);
}
static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse,
Value *Cond, BasicBlock *InsertAtEnd) {
return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd);
}
~BranchInst();
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
virtual BranchInst *clone() const;
bool isUnconditional() const { return getNumOperands() == 1; }
bool isConditional() const { return getNumOperands() == 3; }
Value *getCondition() const {
assert(isConditional() && "Cannot get condition of an uncond branch!");
return Op<-3>();
}
void setCondition(Value *V) {
assert(isConditional() && "Cannot set condition of unconditional branch!");
Op<-3>() = V;
}
void setUnconditionalDest(BasicBlock *Dest) {
Op<-1>() = Dest;
if (isConditional()) { Op<-2>() = 0;
Op<-3>() = 0;
NumOperands = 1;
OperandList = op_begin();
}
}
unsigned getNumSuccessors() const { return 1+isConditional(); }
BasicBlock *getSuccessor(unsigned i) const {
assert(i < getNumSuccessors() && "Successor # out of range for Branch!");
return cast_or_null<BasicBlock>((&Op<-1>() - i)->get());
}
void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < getNumSuccessors() && "Successor # out of range for Branch!");
*(&Op<-1>() - idx) = NewSucc;
}
static inline bool classof(const BranchInst *) { return true; }
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::Br);
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
template <>
struct OperandTraits<BranchInst> : VariadicOperandTraits<1> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value)
class SwitchInst : public TerminatorInst {
void *operator new(size_t, unsigned); unsigned ReservedSpace;
SwitchInst(const SwitchInst &RI);
void init(Value *Value, BasicBlock *Default, unsigned NumCases);
void resizeOperands(unsigned No);
void *operator new(size_t s) {
return User::operator new(s, 0);
}
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
Instruction *InsertBefore = 0);
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
BasicBlock *InsertAtEnd);
public:
static SwitchInst *Create(Value *Value, BasicBlock *Default,
unsigned NumCases, Instruction *InsertBefore = 0) {
return new SwitchInst(Value, Default, NumCases, InsertBefore);
}
static SwitchInst *Create(Value *Value, BasicBlock *Default,
unsigned NumCases, BasicBlock *InsertAtEnd) {
return new SwitchInst(Value, Default, NumCases, InsertAtEnd);
}
~SwitchInst();
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
Value *getCondition() const { return getOperand(0); }
void setCondition(Value *V) { setOperand(0, V); }
BasicBlock *getDefaultDest() const {
return cast<BasicBlock>(getOperand(1));
}
unsigned getNumCases() const {
return getNumOperands()/2;
}
ConstantInt *getCaseValue(unsigned i) {
assert(i && i < getNumCases() && "Illegal case value to get!");
return getSuccessorValue(i);
}
const ConstantInt *getCaseValue(unsigned i) const {
assert(i && i < getNumCases() && "Illegal case value to get!");
return getSuccessorValue(i);
}
unsigned findCaseValue(const ConstantInt *C) const {
for (unsigned i = 1, e = getNumCases(); i != e; ++i)
if (getCaseValue(i) == C)
return i;
return 0;
}
ConstantInt *findCaseDest(BasicBlock *BB) {
if (BB == getDefaultDest()) return NULL;
ConstantInt *CI = NULL;
for (unsigned i = 1, e = getNumCases(); i != e; ++i) {
if (getSuccessor(i) == BB) {
if (CI) return NULL; else CI = getCaseValue(i);
}
}
return CI;
}
void addCase(ConstantInt *OnVal, BasicBlock *Dest);
void removeCase(unsigned idx);
virtual SwitchInst *clone() const;
unsigned getNumSuccessors() const { return getNumOperands()/2; }
BasicBlock *getSuccessor(unsigned idx) const {
assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");
return cast<BasicBlock>(getOperand(idx*2+1));
}
void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < getNumSuccessors() && "Successor # out of range for switch!");
setOperand(idx*2+1, NewSucc);
}
ConstantInt *getSuccessorValue(unsigned idx) const {
assert(idx < getNumSuccessors() && "Successor # out of range!");
return reinterpret_cast<ConstantInt*>(getOperand(idx*2));
}
static inline bool classof(const SwitchInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Switch;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
template <>
struct OperandTraits<SwitchInst> : HungoffOperandTraits<2> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SwitchInst, Value)
class InvokeInst : public TerminatorInst {
AttrListPtr AttributeList;
InvokeInst(const InvokeInst &BI);
void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
Value* const *Args, unsigned NumArgs);
template<typename InputIterator>
void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr,
std::random_access_iterator_tag) {
unsigned NumArgs = (unsigned)std::distance(ArgBegin, ArgEnd);
init(Func, IfNormal, IfException, NumArgs ? &*ArgBegin : 0, NumArgs);
setName(NameStr);
}
template<typename InputIterator>
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
const std::string &NameStr, Instruction *InsertBefore);
template<typename InputIterator>
inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
const std::string &NameStr, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
static InvokeInst *Create(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr = "",
Instruction *InsertBefore = 0) {
unsigned Values(ArgEnd - ArgBegin + 3);
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
Values, NameStr, InsertBefore);
}
template<typename InputIterator>
static InvokeInst *Create(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Values(ArgEnd - ArgBegin + 3);
return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
Values, NameStr, InsertAtEnd);
}
virtual InvokeInst *clone() const;
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
unsigned getCallingConv() const { return SubclassData; }
void setCallingConv(unsigned CC) {
SubclassData = CC;
}
const AttrListPtr &getAttributes() const { return AttributeList; }
void setAttributes(const AttrListPtr &Attrs) { AttributeList = Attrs; }
void addAttribute(unsigned i, Attributes attr);
void removeAttribute(unsigned i, Attributes attr);
bool paramHasAttr(unsigned i, Attributes attr) const;
unsigned getParamAlignment(unsigned i) const {
return AttributeList.getParamAlignment(i);
}
bool doesNotAccessMemory() const {
return paramHasAttr(0, Attribute::ReadNone);
}
void setDoesNotAccessMemory(bool NotAccessMemory = true) {
if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
else removeAttribute(~0, Attribute::ReadNone);
}
bool onlyReadsMemory() const {
return doesNotAccessMemory() || paramHasAttr(~0, Attribute::ReadOnly);
}
void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone);
}
bool doesNotReturn() const {
return paramHasAttr(~0, Attribute::NoReturn);
}
void setDoesNotReturn(bool DoesNotReturn = true) {
if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
else removeAttribute(~0, Attribute::NoReturn);
}
bool doesNotThrow() const {
return paramHasAttr(~0, Attribute::NoUnwind);
}
void setDoesNotThrow(bool DoesNotThrow = true) {
if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
else removeAttribute(~0, Attribute::NoUnwind);
}
bool hasStructRetAttr() const {
return paramHasAttr(1, Attribute::StructRet);
}
bool hasByValArgument() const {
return AttributeList.hasAttrSomewhere(Attribute::ByVal);
}
Function *getCalledFunction() const {
return dyn_cast<Function>(getOperand(0));
}
const Value *getCalledValue() const { return getOperand(0); }
Value *getCalledValue() { return getOperand(0); }
BasicBlock *getNormalDest() const {
return cast<BasicBlock>(getOperand(1));
}
BasicBlock *getUnwindDest() const {
return cast<BasicBlock>(getOperand(2));
}
void setNormalDest(BasicBlock *B) {
setOperand(1, B);
}
void setUnwindDest(BasicBlock *B) {
setOperand(2, B);
}
BasicBlock *getSuccessor(unsigned i) const {
assert(i < 2 && "Successor # out of range for invoke!");
return i == 0 ? getNormalDest() : getUnwindDest();
}
void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < 2 && "Successor # out of range for invoke!");
setOperand(idx+1, NewSucc);
}
unsigned getNumSuccessors() const { return 2; }
static inline bool classof(const InvokeInst *) { return true; }
static inline bool classof(const Instruction *I) {
return (I->getOpcode() == Instruction::Invoke);
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
template <>
struct OperandTraits<InvokeInst> : VariadicOperandTraits<3> {
};
template<typename InputIterator>
InvokeInst::InvokeInst(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
const std::string &NameStr, Instruction *InsertBefore)
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Invoke,
OperandTraits<InvokeInst>::op_end(this) - Values,
Values, InsertBefore) {
init(Func, IfNormal, IfException, ArgBegin, ArgEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
template<typename InputIterator>
InvokeInst::InvokeInst(Value *Func,
BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
unsigned Values,
const std::string &NameStr, BasicBlock *InsertAtEnd)
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Invoke,
OperandTraits<InvokeInst>::op_end(this) - Values,
Values, InsertAtEnd) {
init(Func, IfNormal, IfException, ArgBegin, ArgEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InvokeInst, Value)
class UnwindInst : public TerminatorInst {
void *operator new(size_t, unsigned); public:
void *operator new(size_t s) {
return User::operator new(s, 0);
}
explicit UnwindInst(Instruction *InsertBefore = 0);
explicit UnwindInst(BasicBlock *InsertAtEnd);
virtual UnwindInst *clone() const;
unsigned getNumSuccessors() const { return 0; }
static inline bool classof(const UnwindInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Unwind;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
class UnreachableInst : public TerminatorInst {
void *operator new(size_t, unsigned); public:
void *operator new(size_t s) {
return User::operator new(s, 0);
}
explicit UnreachableInst(Instruction *InsertBefore = 0);
explicit UnreachableInst(BasicBlock *InsertAtEnd);
virtual UnreachableInst *clone() const;
unsigned getNumSuccessors() const { return 0; }
static inline bool classof(const UnreachableInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Instruction::Unreachable;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
class TruncInst : public CastInst {
TruncInst(const TruncInst &CI)
: CastInst(CI.getType(), Trunc, CI.getOperand(0)) {
}
public:
TruncInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
TruncInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const TruncInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Trunc;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class ZExtInst : public CastInst {
ZExtInst(const ZExtInst &CI)
: CastInst(CI.getType(), ZExt, CI.getOperand(0)) {
}
public:
ZExtInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
ZExtInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const ZExtInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == ZExt;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class SExtInst : public CastInst {
SExtInst(const SExtInst &CI)
: CastInst(CI.getType(), SExt, CI.getOperand(0)) {
}
public:
SExtInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
SExtInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const SExtInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == SExt;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class FPTruncInst : public CastInst {
FPTruncInst(const FPTruncInst &CI)
: CastInst(CI.getType(), FPTrunc, CI.getOperand(0)) {
}
public:
FPTruncInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
FPTruncInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const FPTruncInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == FPTrunc;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class FPExtInst : public CastInst {
FPExtInst(const FPExtInst &CI)
: CastInst(CI.getType(), FPExt, CI.getOperand(0)) {
}
public:
FPExtInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
FPExtInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const FPExtInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == FPExt;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class UIToFPInst : public CastInst {
UIToFPInst(const UIToFPInst &CI)
: CastInst(CI.getType(), UIToFP, CI.getOperand(0)) {
}
public:
UIToFPInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
UIToFPInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const UIToFPInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == UIToFP;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class SIToFPInst : public CastInst {
SIToFPInst(const SIToFPInst &CI)
: CastInst(CI.getType(), SIToFP, CI.getOperand(0)) {
}
public:
SIToFPInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
SIToFPInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const SIToFPInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == SIToFP;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class FPToUIInst : public CastInst {
FPToUIInst(const FPToUIInst &CI)
: CastInst(CI.getType(), FPToUI, CI.getOperand(0)) {
}
public:
FPToUIInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
FPToUIInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const FPToUIInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == FPToUI;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class FPToSIInst : public CastInst {
FPToSIInst(const FPToSIInst &CI)
: CastInst(CI.getType(), FPToSI, CI.getOperand(0)) {
}
public:
FPToSIInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
FPToSIInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const FPToSIInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == FPToSI;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class IntToPtrInst : public CastInst {
IntToPtrInst(const IntToPtrInst &CI)
: CastInst(CI.getType(), IntToPtr, CI.getOperand(0)) {
}
public:
IntToPtrInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
IntToPtrInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const IntToPtrInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == IntToPtr;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class PtrToIntInst : public CastInst {
PtrToIntInst(const PtrToIntInst &CI)
: CastInst(CI.getType(), PtrToInt, CI.getOperand(0)) {
}
public:
PtrToIntInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
PtrToIntInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const PtrToIntInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == PtrToInt;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
class BitCastInst : public CastInst {
BitCastInst(const BitCastInst &CI)
: CastInst(CI.getType(), BitCast, CI.getOperand(0)) {
}
public:
BitCastInst(
Value *S, const Type *Ty, const std::string &NameStr = "", Instruction *InsertBefore = 0 );
BitCastInst(
Value *S, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd );
virtual CastInst *clone() const;
static inline bool classof(const BitCastInst *) { return true; }
static inline bool classof(const Instruction *I) {
return I->getOpcode() == BitCast;
}
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
};
}
#endif