Changeset View
Changeset View
Standalone View
Standalone View
lib/IR/Instructions.cpp
Show First 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// CallInst Implementation | // CallInst Implementation | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
CallInst::~CallInst() { | CallInst::~CallInst() { | ||||
} | } | ||||
void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args, | void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args, | ||||
ArrayRef<OperandBundleSetDef> Bundles, | |||||
const Twine &NameStr) { | const Twine &NameStr) { | ||||
this->FTy = FTy; | 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; | Op<-1>() = Func; | ||||
#ifndef NDEBUG | #ifndef NDEBUG | ||||
assert((Args.size() == FTy->getNumParams() || | assert((Args.size() == FTy->getNumParams() || | ||||
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) && | (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && | ||||
"Calling a function with bad signature!"); | "Calling a function with bad signature!"); | ||||
for (unsigned i = 0; i != Args.size(); ++i) | for (unsigned i = 0; i != Args.size(); ++i) | ||||
assert((i >= FTy->getNumParams() || | assert((i >= FTy->getNumParams() || | ||||
FTy->getParamType(i) == Args[i]->getType()) && | FTy->getParamType(i) == Args[i]->getType()) && | ||||
"Calling a function with a bad signature!"); | "Calling a function with a bad signature!"); | ||||
#endif | #endif | ||||
std::copy(Args.begin(), Args.end(), op_begin()); | auto It = std::copy(Args.begin(), Args.end(), op_begin()); | ||||
for (auto &B : Bundles) | |||||
It = std::copy(B.Inputs.begin(), B.Inputs.end(), It); | |||||
assert((It + 1) == op_end() && "Incorrect counting?"); | |||||
populateBundleOperandInfos(Bundles, Args.size()); | |||||
setName(NameStr); | setName(NameStr); | ||||
} | } | ||||
void CallInst::init(Value *Func, const Twine &NameStr) { | void CallInst::init(Value *Func, const Twine &NameStr) { | ||||
FTy = | FTy = | ||||
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); | cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); | ||||
assert(getNumOperands() == 1 && "NumOperands not set up?"); | assert(getNumOperands() == 1 && "NumOperands not set up?"); | ||||
Op<-1>() = Func; | Op<-1>() = Func; | ||||
Show All 25 Lines | |||||
CallInst::CallInst(const CallInst &CI) | CallInst::CallInst(const CallInst &CI) | ||||
: Instruction(CI.getType(), Instruction::Call, | : Instruction(CI.getType(), Instruction::Call, | ||||
OperandTraits<CallInst>::op_end(this) - CI.getNumOperands(), | OperandTraits<CallInst>::op_end(this) - CI.getNumOperands(), | ||||
CI.getNumOperands()), | CI.getNumOperands()), | ||||
AttributeList(CI.AttributeList), FTy(CI.FTy) { | AttributeList(CI.AttributeList), FTy(CI.FTy) { | ||||
setTailCallKind(CI.getTailCallKind()); | setTailCallKind(CI.getTailCallKind()); | ||||
setCallingConv(CI.getCallingConv()); | setCallingConv(CI.getCallingConv()); | ||||
std::copy(CI.op_begin(), CI.op_end(), op_begin()); | 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; | SubclassOptionalData = CI.SubclassOptionalData; | ||||
} | } | ||||
void CallInst::addAttribute(unsigned i, Attribute::AttrKind attr) { | void CallInst::addAttribute(unsigned i, Attribute::AttrKind attr) { | ||||
AttributeSet PAL = getAttributes(); | AttributeSet PAL = getAttributes(); | ||||
PAL = PAL.addAttribute(getContext(), i, attr); | PAL = PAL.addAttribute(getContext(), i, attr); | ||||
setAttributes(PAL); | setAttributes(PAL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// InvokeInst Implementation | // InvokeInst Implementation | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
void InvokeInst::init(FunctionType *FTy, Value *Fn, BasicBlock *IfNormal, | void InvokeInst::init(FunctionType *FTy, Value *Fn, BasicBlock *IfNormal, | ||||
BasicBlock *IfException, ArrayRef<Value *> Args, | BasicBlock *IfException, ArrayRef<Value *> Args, | ||||
ArrayRef<OperandBundleSetDef> Bundles, | |||||
const Twine &NameStr) { | const Twine &NameStr) { | ||||
this->FTy = FTy; | 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<-3>() = Fn; | ||||
Op<-2>() = IfNormal; | Op<-2>() = IfNormal; | ||||
Op<-1>() = IfException; | Op<-1>() = IfException; | ||||
#ifndef NDEBUG | #ifndef NDEBUG | ||||
assert(((Args.size() == FTy->getNumParams()) || | assert(((Args.size() == FTy->getNumParams()) || | ||||
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) && | (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && | ||||
"Invoking a function with bad signature"); | "Invoking a function with bad signature"); | ||||
for (unsigned i = 0, e = Args.size(); i != e; i++) | for (unsigned i = 0, e = Args.size(); i != e; i++) | ||||
assert((i >= FTy->getNumParams() || | assert((i >= FTy->getNumParams() || | ||||
FTy->getParamType(i) == Args[i]->getType()) && | FTy->getParamType(i) == Args[i]->getType()) && | ||||
"Invoking a function with a bad signature!"); | "Invoking a function with a bad signature!"); | ||||
#endif | #endif | ||||
std::copy(Args.begin(), Args.end(), op_begin()); | auto It = std::copy(Args.begin(), Args.end(), op_begin()); | ||||
for (auto &B : Bundles) | |||||
It = std::copy(B.Inputs.begin(), B.Inputs.end(), It); | |||||
assert((It + 3) == op_end() && "Incorrect counting?"); | |||||
populateBundleOperandInfos(Bundles, Args.size()); | |||||
setName(NameStr); | setName(NameStr); | ||||
} | } | ||||
InvokeInst::InvokeInst(const InvokeInst &II) | InvokeInst::InvokeInst(const InvokeInst &II) | ||||
: TerminatorInst(II.getType(), Instruction::Invoke, | : TerminatorInst(II.getType(), Instruction::Invoke, | ||||
OperandTraits<InvokeInst>::op_end(this) - | OperandTraits<InvokeInst>::op_end(this) - | ||||
II.getNumOperands(), | II.getNumOperands(), | ||||
II.getNumOperands()), | II.getNumOperands()), | ||||
AttributeList(II.AttributeList), FTy(II.FTy) { | AttributeList(II.AttributeList), FTy(II.FTy) { | ||||
setCallingConv(II.getCallingConv()); | setCallingConv(II.getCallingConv()); | ||||
std::copy(II.op_begin(), II.op_end(), op_begin()); | 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; | SubclassOptionalData = II.SubclassOptionalData; | ||||
} | } | ||||
BasicBlock *InvokeInst::getSuccessorV(unsigned idx) const { | BasicBlock *InvokeInst::getSuccessorV(unsigned idx) const { | ||||
return getSuccessor(idx); | return getSuccessor(idx); | ||||
} | } | ||||
unsigned InvokeInst::getNumSuccessorsV() const { | unsigned InvokeInst::getNumSuccessorsV() const { | ||||
return getNumSuccessors(); | return getNumSuccessors(); | ||||
▲ Show 20 Lines • Show All 3,392 Lines • Show Last 20 Lines |