}
+
+
//===----------------------------------------------------------------------===//
// TerminatorInst Class
//===----------------------------------------------------------------------===//
: Instruction(Type::VoidTy, iType, Ops, NumOps, "", IAE) {
}
+// Out of line virtual method, so the vtable, etc has a home.
+TerminatorInst::~TerminatorInst() {
+}
+
+// Out of line virtual method, so the vtable, etc has a home.
+UnaryInstruction::~UnaryInstruction() {
+}
//===----------------------------------------------------------------------===//
static Value *getAISize(Value *Amt) {
if (!Amt)
- Amt = ConstantUInt::get(Type::UIntTy, 1);
- else
+ Amt = ConstantInt::get(Type::UIntTy, 1);
+ else {
+ assert(!isa<BasicBlock>(Amt) &&
+ "Passed basic block into allocation size parameter! Ue other ctor");
assert(Amt->getType() == Type::UIntTy &&
"Malloc/Allocation array size != UIntTy!");
+ }
return Amt;
}
assert(Ty != Type::VoidTy && "Cannot allocate void!");
}
+// Out of line virtual method, so the vtable, etc has a home.
+AllocationInst::~AllocationInst() {
+}
+
bool AllocationInst::isArrayAllocation() const {
- if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(getOperand(0)))
- return CUI->getValue() != 1;
+ if (ConstantInt *CUI = dyn_cast<ConstantInt>(getOperand(0)))
+ return CUI->getZExtValue() != 1;
return true;
}
// message on bad indexes for a gep instruction.
//
static inline const Type *checkType(const Type *Ty) {
- assert(Ty && "Invalid indices for type!");
+ assert(Ty && "Invalid GetElementPtrInst indices for type!");
return Ty;
}
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 = ConstantInt::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)
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 = ConstantInt::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;
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 = ConstantInt::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)
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 = ConstantInt::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()))
}
+//===----------------------------------------------------------------------===//
+// ShiftInst Class
+//===----------------------------------------------------------------------===//
+
+/// isLogicalShift - Return true if this is a logical shift left or a logical
+/// shift right.
+bool ShiftInst::isLogicalShift() const {
+ return getOpcode() == Instruction::Shl || getType()->isUnsigned();
+}
+
+//===----------------------------------------------------------------------===//
+// CastInst Class
+//===----------------------------------------------------------------------===//
+
+/// isTruncIntCast - Return true if this is a truncating integer cast
+/// instruction, e.g. a cast from long to uint.
+bool CastInst::isTruncIntCast() const {
+ // The dest type has to be integral, the input has to be integer.
+ if (!getType()->isIntegral() || !getOperand(0)->getType()->isInteger())
+ return false;
+
+ // Has to be large to smaller.
+ return getOperand(0)->getType()->getPrimitiveSizeInBits() >
+ getType()->getPrimitiveSizeInBits();
+}
+
+
//===----------------------------------------------------------------------===//
// SetCondInst Class
//===----------------------------------------------------------------------===//