ReservedSpace = NumReservedValues;
NumOperands = 1;
OperandList = allocHungoffUses(ReservedSpace);
- OperandList[0] = PersFn;
+ Op<0>() = PersFn;
setName(NameStr);
setCleanup(false);
}
CallInst::~CallInst() {
}
-void CallInst::init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr) {
+void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args,
+ const Twine &NameStr) {
+ this->FTy = FTy;
assert(NumOperands == Args.size() + 1 && "NumOperands not set up?");
Op<-1>() = Func;
#ifndef NDEBUG
- FunctionType *FTy =
- cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
-
assert((Args.size() == FTy->getNumParams() ||
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) &&
"Calling a function with bad signature!");
}
void CallInst::init(Value *Func, const Twine &NameStr) {
+ FTy =
+ cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
assert(NumOperands == 1 && "NumOperands not set up?");
Op<-1>() = Func;
-#ifndef NDEBUG
- FunctionType *FTy =
- cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
-
assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
-#endif
setName(NameStr);
}
}
CallInst::CallInst(const CallInst &CI)
- : Instruction(CI.getType(), Instruction::Call,
- OperandTraits<CallInst>::op_end(this) - CI.getNumOperands(),
- CI.getNumOperands()) {
- setAttributes(CI.getAttributes());
+ : Instruction(CI.getType(), Instruction::Call,
+ OperandTraits<CallInst>::op_end(this) - CI.getNumOperands(),
+ CI.getNumOperands()),
+ AttributeList(CI.AttributeList), FTy(CI.FTy) {
setTailCallKind(CI.getTailCallKind());
setCallingConv(CI.getCallingConv());
// InvokeInst Implementation
//===----------------------------------------------------------------------===//
-void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
- ArrayRef<Value *> Args, const Twine &NameStr) {
+void InvokeInst::init(FunctionType *FTy, Value *Fn, BasicBlock *IfNormal,
+ BasicBlock *IfException, ArrayRef<Value *> Args,
+ const Twine &NameStr) {
+ this->FTy = FTy;
+
assert(NumOperands == 3 + Args.size() && "NumOperands not set up?");
Op<-3>() = Fn;
Op<-2>() = IfNormal;
Op<-1>() = IfException;
#ifndef NDEBUG
- FunctionType *FTy =
- cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
-
assert(((Args.size() == FTy->getNumParams()) ||
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) &&
"Invoking a function with bad signature");
}
InvokeInst::InvokeInst(const InvokeInst &II)
- : TerminatorInst(II.getType(), Instruction::Invoke,
- OperandTraits<InvokeInst>::op_end(this)
- - II.getNumOperands(),
- II.getNumOperands()) {
- setAttributes(II.getAttributes());
+ : TerminatorInst(II.getType(), Instruction::Invoke,
+ OperandTraits<InvokeInst>::op_end(this) -
+ II.getNumOperands(),
+ II.getNumOperands()),
+ AttributeList(II.AttributeList), FTy(II.FTy) {
setCallingConv(II.getCallingConv());
std::copy(II.op_begin(), II.op_end(), op_begin());
SubclassOptionalData = II.SubclassOptionalData;
AllocaInst::AllocaInst(Type *Ty, Value *ArraySize, unsigned Align,
const Twine &Name, Instruction *InsertBefore)
- : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
- getAISize(Ty->getContext(), ArraySize), InsertBefore) {
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
+ getAISize(Ty->getContext(), ArraySize), InsertBefore),
+ AllocatedType(Ty) {
setAlignment(Align);
assert(!Ty->isVoidTy() && "Cannot allocate void!");
setName(Name);
AllocaInst::AllocaInst(Type *Ty, Value *ArraySize, unsigned Align,
const Twine &Name, BasicBlock *InsertAtEnd)
- : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
- getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
+ getAISize(Ty->getContext(), ArraySize), InsertAtEnd),
+ AllocatedType(Ty) {
setAlignment(Align);
assert(!Ty->isVoidTy() && "Cannot allocate void!");
setName(Name);
return true;
}
-Type *AllocaInst::getAllocatedType() const {
- return getType()->getElementType();
-}
-
/// isStaticAlloca - Return true if this alloca is in the entry block of the
/// function and is a constant size. If so, the code generator will fold it
/// into the prolog/epilog code, so it is basically free.
LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE)
: LoadInst(Ptr, Name, /*isVolatile=*/false, InsertAE) {}
-LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
+LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
Instruction *InsertBef)
- : LoadInst(Ptr, Name, isVolatile, /*Align=*/0, InsertBef) {}
+ : LoadInst(Ty, Ptr, Name, isVolatile, /*Align=*/0, InsertBef) {}
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
BasicBlock *InsertAE)
: LoadInst(Ptr, Name, isVolatile, /*Align=*/0, InsertAE) {}
-LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
+LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
unsigned Align, Instruction *InsertBef)
- : LoadInst(Ptr, Name, isVolatile, Align, NotAtomic, CrossThread,
+ : LoadInst(Ty, Ptr, Name, isVolatile, Align, NotAtomic, CrossThread,
InsertBef) {}
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
unsigned Align, AtomicOrdering Order,
SynchronizationScope SynchScope, Instruction *InsertBef)
: UnaryInstruction(Ty, Load, Ptr, InsertBef) {
+ assert(Ty == cast<PointerType>(Ptr->getType())->getElementType());
setVolatile(isVolatile);
setAlignment(Align);
setAtomic(Order, SynchScope);
if (Name && Name[0]) setName(Name);
}
-LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
+LoadInst::LoadInst(Type *Ty, Value *Ptr, const char *Name, bool isVolatile,
Instruction *InsertBef)
-: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
- Load, Ptr, InsertBef) {
+ : UnaryInstruction(Ty, Load, Ptr, InsertBef) {
+ assert(Ty == cast<PointerType>(Ptr->getType())->getElementType());
setVolatile(isVolatile);
setAlignment(0);
setAtomic(NotAtomic);
void GetElementPtrInst::init(Value *Ptr, ArrayRef<Value *> IdxList,
const Twine &Name) {
assert(NumOperands == 1 + IdxList.size() && "NumOperands not initialized?");
- OperandList[0] = Ptr;
+ Op<0>() = Ptr;
std::copy(IdxList.begin(), IdxList.end(), op_begin() + 1);
setName(Name);
}
GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
- : Instruction(GEPI.getType(), GetElementPtr,
- OperandTraits<GetElementPtrInst>::op_end(this)
- - GEPI.getNumOperands(),
- GEPI.getNumOperands()) {
+ : Instruction(GEPI.getType(), GetElementPtr,
+ OperandTraits<GetElementPtrInst>::op_end(this) -
+ GEPI.getNumOperands(),
+ GEPI.getNumOperands()),
+ SourceElementType(GEPI.SourceElementType),
+ ResultElementType(GEPI.ResultElementType) {
std::copy(GEPI.op_begin(), GEPI.op_end(), op_begin());
SubclassOptionalData = GEPI.SubclassOptionalData;
}
// N X X U S F F N X N 2 V V |
// C T T I I P P C T T P T T -+
{ 1, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // Trunc -+
- { 8, 1, 9,99,99, 2, 0,99,99,99, 2, 3, 0}, // ZExt |
+ { 8, 1, 9,99,99, 2,17,99,99,99, 2, 3, 0}, // ZExt |
{ 8, 0, 1,99,99, 0, 2,99,99,99, 0, 3, 0}, // SExt |
{ 0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // FPToUI |
{ 0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0}, // FPToSI |
{ 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0}, // UIToFP +- firstOp
{ 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0}, // SIToFP |
- { 99,99,99, 0, 0,99,99, 1, 0,99,99, 4, 0}, // FPTrunc |
+ { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0}, // FPTrunc |
{ 99,99,99, 2, 2,99,99,10, 2,99,99, 4, 0}, // FPExt |
{ 1, 0, 0,99,99, 0, 0,99,99,99, 7, 3, 0}, // PtrToInt |
{ 99,99,99,99,99,99,99,99,99,11,99,15, 0}, // IntToPtr |
"Illegal bitcast, ptrtoint sequence!");
// Allowed, use second cast's opcode
return secondOp;
+ case 17:
+ // (sitofp (zext x)) -> (uitofp x)
+ return Instruction::UIToFP;
case 99:
// Cast combination can't happen (error in input). This is for all cases
// where the MidTy is not the same for the two cast instructions.
NumOperands = 2;
OperandList = allocHungoffUses(ReservedSpace);
- OperandList[0] = Value;
- OperandList[1] = Default;
+ Op<0>() = Value;
+ Op<1>() = Default;
}
/// SwitchInst ctor - Create a new switch instruction, specifying a value to
NumOperands = 1;
OperandList = allocHungoffUses(ReservedSpace);
- OperandList[0] = Address;
+ Op<0>() = Address;
}