const char *SelectInst::areInvalidOperands(Value *Op0, Value *Op1, Value *Op2) {
if (Op1->getType() != Op2->getType())
return "both values to select must have same type";
-
+
+ if (Op1->getType()->isTokenTy())
+ return "select values cannot have token type";
+
if (VectorType *VT = dyn_cast<VectorType>(Op0->getType())) {
// Vector select.
if (VT->getElementType() != Type::getInt1Ty(Op0->getContext()))
}
void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args,
- const Twine &NameStr) {
+ ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr) {
this->FTy = FTy;
- assert(getNumOperands() == Args.size() + 1 && "NumOperands not set up?");
+ assert(getNumOperands() == Args.size() + CountBundleInputs(Bundles) + 1 &&
+ "NumOperands not set up?");
Op<-1>() = Func;
#ifndef NDEBUG
#endif
std::copy(Args.begin(), Args.end(), op_begin());
+
+ auto It = populateBundleOperandInfos(Bundles, Args.size());
+ (void)It;
+ assert(It + 1 == op_end() && "Should add up!");
+
setName(NameStr);
}
AttributeList(CI.AttributeList), FTy(CI.FTy) {
setTailCallKind(CI.getTailCallKind());
setCallingConv(CI.getCallingConv());
-
+
std::copy(CI.op_begin(), CI.op_end(), op_begin());
+ std::copy(CI.bundle_op_info_begin(), CI.bundle_op_info_end(),
+ bundle_op_info_begin());
SubclassOptionalData = CI.SubclassOptionalData;
}
void InvokeInst::init(FunctionType *FTy, Value *Fn, BasicBlock *IfNormal,
BasicBlock *IfException, ArrayRef<Value *> Args,
+ ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr) {
this->FTy = FTy;
- assert(getNumOperands() == 3 + Args.size() && "NumOperands not set up?");
+ assert(getNumOperands() == 3 + Args.size() + CountBundleInputs(Bundles) &&
+ "NumOperands not set up?");
Op<-3>() = Fn;
Op<-2>() = IfNormal;
Op<-1>() = IfException;
#endif
std::copy(Args.begin(), Args.end(), op_begin());
+
+ auto It = populateBundleOperandInfos(Bundles, Args.size());
+ (void)It;
+ assert(It + 3 == op_end() && "Should add up!");
+
setName(NameStr);
}
AttributeList(II.AttributeList), FTy(II.FTy) {
setCallingConv(II.getCallingConv());
std::copy(II.op_begin(), II.op_end(), op_begin());
+ std::copy(II.bundle_op_info_begin(), II.bundle_op_info_end(),
+ bundle_op_info_begin());
SubclassOptionalData = II.SubclassOptionalData;
}
bool InvokeInst::hasFnAttrImpl(Attribute::AttrKind A) const {
if (AttributeList.hasAttribute(AttributeSet::FunctionIndex, A))
return true;
+
+ // Operand bundles override attributes on the called function, but don't
+ // override attributes directly present on the invoke instruction.
+ if (isFnAttrDisallowedByOpBundle(A))
+ return false;
+
if (const Function *F = getCalledFunction())
return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
return false;
llvm_unreachable("ResumeInst has no successors!");
}
+//===----------------------------------------------------------------------===//
+// CleanupEndPadInst Implementation
+//===----------------------------------------------------------------------===//
+
+CleanupEndPadInst::CleanupEndPadInst(const CleanupEndPadInst &CEPI)
+ : TerminatorInst(CEPI.getType(), Instruction::CleanupEndPad,
+ OperandTraits<CleanupEndPadInst>::op_end(this) -
+ CEPI.getNumOperands(),
+ CEPI.getNumOperands()) {
+ setInstructionSubclassData(CEPI.getSubclassDataFromInstruction());
+ setCleanupPad(CEPI.getCleanupPad());
+ if (BasicBlock *UnwindDest = CEPI.getUnwindDest())
+ setUnwindDest(UnwindDest);
+}
+
+void CleanupEndPadInst::init(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB) {
+ setCleanupPad(CleanupPad);
+ if (UnwindBB) {
+ setInstructionSubclassData(getSubclassDataFromInstruction() | 1);
+ setUnwindDest(UnwindBB);
+ }
+}
+
+CleanupEndPadInst::CleanupEndPadInst(CleanupPadInst *CleanupPad,
+ BasicBlock *UnwindBB, unsigned Values,
+ Instruction *InsertBefore)
+ : TerminatorInst(Type::getVoidTy(CleanupPad->getContext()),
+ Instruction::CleanupEndPad,
+ OperandTraits<CleanupEndPadInst>::op_end(this) - Values,
+ Values, InsertBefore) {
+ init(CleanupPad, UnwindBB);
+}
+
+CleanupEndPadInst::CleanupEndPadInst(CleanupPadInst *CleanupPad,
+ BasicBlock *UnwindBB, unsigned Values,
+ BasicBlock *InsertAtEnd)
+ : TerminatorInst(Type::getVoidTy(CleanupPad->getContext()),
+ Instruction::CleanupEndPad,
+ OperandTraits<CleanupEndPadInst>::op_end(this) - Values,
+ Values, InsertAtEnd) {
+ init(CleanupPad, UnwindBB);
+}
+
+BasicBlock *CleanupEndPadInst::getSuccessorV(unsigned Idx) const {
+ assert(Idx == 0);
+ return getUnwindDest();
+}
+unsigned CleanupEndPadInst::getNumSuccessorsV() const {
+ return getNumSuccessors();
+}
+void CleanupEndPadInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
+ assert(Idx == 0);
+ setUnwindDest(B);
+}
+
//===----------------------------------------------------------------------===//
// CleanupReturnInst Implementation
//===----------------------------------------------------------------------===//
OperandTraits<CleanupReturnInst>::op_end(this) -
CRI.getNumOperands(),
CRI.getNumOperands()) {
- SubclassOptionalData = CRI.SubclassOptionalData;
setInstructionSubclassData(CRI.getSubclassDataFromInstruction());
- if (Value *RetVal = CRI.getReturnValue())
- setReturnValue(RetVal);
- if (BasicBlock *UnwindDest = CRI.getUnwindDest())
- setUnwindDest(UnwindDest);
+ Op<-1>() = CRI.Op<-1>();
+ if (CRI.hasUnwindDest())
+ Op<-2>() = CRI.Op<-2>();
}
-void CleanupReturnInst::init(Value *RetVal, BasicBlock *UnwindBB) {
- SubclassOptionalData = 0;
+void CleanupReturnInst::init(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB) {
if (UnwindBB)
setInstructionSubclassData(getSubclassDataFromInstruction() | 1);
- if (RetVal)
- setInstructionSubclassData(getSubclassDataFromInstruction() | 2);
+ Op<-1>() = CleanupPad;
if (UnwindBB)
- setUnwindDest(UnwindBB);
- if (RetVal)
- setReturnValue(RetVal);
+ Op<-2>() = UnwindBB;
}
-CleanupReturnInst::CleanupReturnInst(LLVMContext &C, Value *RetVal,
+CleanupReturnInst::CleanupReturnInst(CleanupPadInst *CleanupPad,
BasicBlock *UnwindBB, unsigned Values,
Instruction *InsertBefore)
- : TerminatorInst(Type::getVoidTy(C), Instruction::CleanupRet,
+ : TerminatorInst(Type::getVoidTy(CleanupPad->getContext()),
+ Instruction::CleanupRet,
OperandTraits<CleanupReturnInst>::op_end(this) - Values,
Values, InsertBefore) {
- init(RetVal, UnwindBB);
+ init(CleanupPad, UnwindBB);
}
-CleanupReturnInst::CleanupReturnInst(LLVMContext &C, Value *RetVal,
+CleanupReturnInst::CleanupReturnInst(CleanupPadInst *CleanupPad,
BasicBlock *UnwindBB, unsigned Values,
BasicBlock *InsertAtEnd)
- : TerminatorInst(Type::getVoidTy(C), Instruction::CleanupRet,
+ : TerminatorInst(Type::getVoidTy(CleanupPad->getContext()),
+ Instruction::CleanupRet,
OperandTraits<CleanupReturnInst>::op_end(this) - Values,
Values, InsertAtEnd) {
- init(RetVal, UnwindBB);
-}
-
-BasicBlock *CleanupReturnInst::getUnwindDest() const {
- if (hasUnwindDest())
- return cast<BasicBlock>(getOperand(getUnwindLabelOpIdx()));
- return nullptr;
-}
-void CleanupReturnInst::setUnwindDest(BasicBlock *NewDest) {
- assert(NewDest);
- setOperand(getUnwindLabelOpIdx(), NewDest);
+ init(CleanupPad, UnwindBB);
}
BasicBlock *CleanupReturnInst::getSuccessorV(unsigned Idx) const {
OperandTraits<CatchEndPadInst>::op_end(this) -
CRI.getNumOperands(),
CRI.getNumOperands()) {
- SubclassOptionalData = CRI.SubclassOptionalData;
setInstructionSubclassData(CRI.getSubclassDataFromInstruction());
if (BasicBlock *UnwindDest = CRI.getUnwindDest())
setUnwindDest(UnwindDest);
}
void CatchEndPadInst::init(BasicBlock *UnwindBB) {
- SubclassOptionalData = 0;
if (UnwindBB) {
setInstructionSubclassData(getSubclassDataFromInstruction() | 1);
setUnwindDest(UnwindBB);
//===----------------------------------------------------------------------===//
// CatchReturnInst Implementation
//===----------------------------------------------------------------------===//
+void CatchReturnInst::init(CatchPadInst *CatchPad, BasicBlock *BB) {
+ Op<0>() = CatchPad;
+ Op<1>() = BB;
+}
CatchReturnInst::CatchReturnInst(const CatchReturnInst &CRI)
: TerminatorInst(Type::getVoidTy(CRI.getContext()), Instruction::CatchRet,
- OperandTraits<CatchReturnInst>::op_end(this) -
- CRI.getNumOperands(),
- CRI.getNumOperands()) {
+ OperandTraits<CatchReturnInst>::op_begin(this), 2) {
Op<0>() = CRI.Op<0>();
+ Op<1>() = CRI.Op<1>();
}
-CatchReturnInst::CatchReturnInst(BasicBlock *BB, Instruction *InsertBefore)
+CatchReturnInst::CatchReturnInst(CatchPadInst *CatchPad, BasicBlock *BB,
+ Instruction *InsertBefore)
: TerminatorInst(Type::getVoidTy(BB->getContext()), Instruction::CatchRet,
- OperandTraits<CatchReturnInst>::op_begin(this), 1,
+ OperandTraits<CatchReturnInst>::op_begin(this), 2,
InsertBefore) {
- Op<0>() = BB;
+ init(CatchPad, BB);
}
-CatchReturnInst::CatchReturnInst(BasicBlock *BB, BasicBlock *InsertAtEnd)
+CatchReturnInst::CatchReturnInst(CatchPadInst *CatchPad, BasicBlock *BB,
+ BasicBlock *InsertAtEnd)
: TerminatorInst(Type::getVoidTy(BB->getContext()), Instruction::CatchRet,
- OperandTraits<CatchReturnInst>::op_begin(this), 1,
+ OperandTraits<CatchReturnInst>::op_begin(this), 2,
InsertAtEnd) {
- Op<0>() = BB;
+ init(CatchPad, BB);
}
BasicBlock *CatchReturnInst::getSuccessorV(unsigned Idx) const {
- assert(Idx == 0);
+ assert(Idx < getNumSuccessors() && "Successor # out of range for catchret!");
return getSuccessor();
}
unsigned CatchReturnInst::getNumSuccessorsV() const {
return getNumSuccessors();
}
void CatchReturnInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
- assert(Idx == 0);
+ assert(Idx < getNumSuccessors() && "Successor # out of range for catchret!");
setSuccessor(B);
}
std::copy(CPI.op_begin(), CPI.op_end(), op_begin());
}
-CatchPadInst::CatchPadInst(Type *RetTy, BasicBlock *IfNormal,
- BasicBlock *IfException, ArrayRef<Value *> Args,
- unsigned Values, const Twine &NameStr,
- Instruction *InsertBefore)
- : TerminatorInst(RetTy, Instruction::CatchPad,
+CatchPadInst::CatchPadInst(BasicBlock *IfNormal, BasicBlock *IfException,
+ ArrayRef<Value *> Args, unsigned Values,
+ const Twine &NameStr, Instruction *InsertBefore)
+ : TerminatorInst(Type::getTokenTy(IfNormal->getContext()),
+ Instruction::CatchPad,
OperandTraits<CatchPadInst>::op_end(this) - Values, Values,
InsertBefore) {
init(IfNormal, IfException, Args, NameStr);
}
-CatchPadInst::CatchPadInst(Type *RetTy, BasicBlock *IfNormal,
- BasicBlock *IfException, ArrayRef<Value *> Args,
- unsigned Values, const Twine &NameStr,
- BasicBlock *InsertAtEnd)
- : TerminatorInst(RetTy, Instruction::CatchPad,
+CatchPadInst::CatchPadInst(BasicBlock *IfNormal, BasicBlock *IfException,
+ ArrayRef<Value *> Args, unsigned Values,
+ const Twine &NameStr, BasicBlock *InsertAtEnd)
+ : TerminatorInst(Type::getTokenTy(IfNormal->getContext()),
+ Instruction::CatchPad,
OperandTraits<CatchPadInst>::op_end(this) - Values, Values,
InsertAtEnd) {
init(IfNormal, IfException, Args, NameStr);
// TerminatePadInst Implementation
//===----------------------------------------------------------------------===//
void TerminatePadInst::init(BasicBlock *BB, ArrayRef<Value *> Args) {
- SubclassOptionalData = 0;
if (BB)
setInstructionSubclassData(getSubclassDataFromInstruction() | 1);
if (BB)
OperandTraits<TerminatePadInst>::op_end(this) -
TPI.getNumOperands(),
TPI.getNumOperands()) {
- SubclassOptionalData = TPI.SubclassOptionalData;
setInstructionSubclassData(TPI.getSubclassDataFromInstruction());
std::copy(TPI.op_begin(), TPI.op_end(), op_begin());
}
std::copy(CPI.op_begin(), CPI.op_end(), op_begin());
}
-CleanupPadInst::CleanupPadInst(Type *RetTy, ArrayRef<Value *> Args,
+CleanupPadInst::CleanupPadInst(LLVMContext &C, ArrayRef<Value *> Args,
const Twine &NameStr, Instruction *InsertBefore)
- : Instruction(RetTy, Instruction::CleanupPad,
+ : Instruction(Type::getTokenTy(C), Instruction::CleanupPad,
OperandTraits<CleanupPadInst>::op_end(this) - Args.size(),
Args.size(), InsertBefore) {
init(Args, NameStr);
}
-CleanupPadInst::CleanupPadInst(Type *RetTy, ArrayRef<Value *> Args,
+CleanupPadInst::CleanupPadInst(LLVMContext &C, ArrayRef<Value *> Args,
const Twine &NameStr, BasicBlock *InsertAtEnd)
- : Instruction(RetTy, Instruction::CleanupPad,
+ : Instruction(Type::getTokenTy(C), Instruction::CleanupPad,
OperandTraits<CleanupPadInst>::op_end(this) - Args.size(),
Args.size(), InsertAtEnd) {
init(Args, NameStr);
}
}
+CmpInst::Predicate CmpInst::getSignedPredicate(Predicate pred) {
+ assert(CmpInst::isUnsigned(pred) && "Call only with signed predicates!");
+
+ switch (pred) {
+ default:
+ llvm_unreachable("Unknown predicate!");
+ case CmpInst::ICMP_ULT:
+ return CmpInst::ICMP_SLT;
+ case CmpInst::ICMP_ULE:
+ return CmpInst::ICMP_SLE;
+ case CmpInst::ICMP_UGT:
+ return CmpInst::ICMP_SGT;
+ case CmpInst::ICMP_UGE:
+ return CmpInst::ICMP_SGE;
+ }
+}
+
bool CmpInst::isUnsigned(unsigned short predicate) {
switch (predicate) {
default: return false;
ResumeInst *ResumeInst::cloneImpl() const { return new (1) ResumeInst(*this); }
+CleanupEndPadInst *CleanupEndPadInst::cloneImpl() const {
+ return new (getNumOperands()) CleanupEndPadInst(*this);
+}
+
CleanupReturnInst *CleanupReturnInst::cloneImpl() const {
return new (getNumOperands()) CleanupReturnInst(*this);
}
}
CatchReturnInst *CatchReturnInst::cloneImpl() const {
- return new (1) CatchReturnInst(*this);
+ return new (getNumOperands()) CatchReturnInst(*this);
}
CatchPadInst *CatchPadInst::cloneImpl() const {