16 #ifndef LLVM_IR_INSTRUCTIONS_H
17 #define LLVM_IR_INSTRUCTIONS_H
144 return (I->
getOpcode() == Instruction::Alloca);
147 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
153 void setInstructionSubclassData(
unsigned short D) {
187 NameStr, isVolatile, Align, InsertBefore) {}
189 unsigned Align,
Instruction *InsertBefore =
nullptr);
196 NameStr, isVolatile, Align, Order, SynchScope, InsertBefore) {}
242 ((
unsigned)Ordering << 7));
284 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
290 void setInstructionSubclassData(
unsigned short D) {
316 unsigned Align,
Instruction *InsertBefore =
nullptr);
329 void *
operator new(
size_t s) {
330 return User::operator
new(s, 2);
333 void *
operator new(size_t,
unsigned) =
delete;
363 ((
unsigned)Ordering << 7));
408 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
414 void setInstructionSubclassData(
unsigned short D) {
435 friend class Instruction;
444 Instruction *InsertBefore =
nullptr);
450 void *
operator new(
size_t s) {
451 return User::operator
new(s, 0);
454 void *
operator new(size_t,
unsigned) =
delete;
464 setInstructionSubclassData((getSubclassDataFromInstruction() & 1) |
465 ((
unsigned)Ordering << 1));
476 setInstructionSubclassData((getSubclassDataFromInstruction() & ~1) |
482 return I->
getOpcode() == Instruction::Fence;
485 return isa<Instruction>(V) && classof(cast<Instruction>(V));
491 void setInstructionSubclassData(
unsigned short D) {
528 void *
operator new(
size_t s) {
529 return User::operator
new(s, 3);
532 void *
operator new(size_t,
unsigned) =
delete;
564 "CmpXchg instructions can only be atomic.");
566 ((
unsigned)Ordering << 2));
571 "CmpXchg instructions can only be atomic.");
573 ((
unsigned)Ordering << 5));
624 switch (SuccessOrdering) {
640 return I->
getOpcode() == Instruction::AtomicCmpXchg;
643 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
649 void setInstructionSubclassData(
unsigned short D) {
672 friend class Instruction;
712 Instruction *InsertBefore =
nullptr);
718 void *
operator new(
size_t s) {
719 return User::operator
new(s, 2);
722 void *
operator new(size_t,
unsigned) =
delete;
725 return static_cast<BinOp>(getSubclassDataFromInstruction() >> 5);
729 unsigned short SubclassData = getSubclassDataFromInstruction();
730 setInstructionSubclassData((SubclassData & 31) |
737 return getSubclassDataFromInstruction() & 1;
743 setInstructionSubclassData((getSubclassDataFromInstruction() & ~1) |
753 "atomicrmw instructions can only be atomic.");
754 setInstructionSubclassData((getSubclassDataFromInstruction() & ~(7 << 2)) |
755 ((
unsigned)Ordering << 2));
762 setInstructionSubclassData((getSubclassDataFromInstruction() & ~2) |
768 return AtomicOrdering((getSubclassDataFromInstruction() >> 2) & 7);
791 return I->
getOpcode() == Instruction::AtomicRMW;
794 return isa<Instruction>(V) && classof(cast<Instruction>(V));
803 void setInstructionSubclassData(
unsigned short D) {
823 assert(Ty &&
"Invalid GetElementPtrInst indices for type!");
831 Type *SourceElementType;
832 Type *ResultElementType;
834 void anchor()
override;
859 const Twine &NameStr =
"",
870 NameStr, InsertBefore);
875 const Twine &NameStr,
886 NameStr, InsertAtEnd);
893 const Twine &NameStr =
"",
895 return CreateInBounds(
nullptr, Ptr, IdxList, NameStr, InsertBefore);
900 const Twine &NameStr =
"",
903 Create(PointeeType, Ptr, IdxList, NameStr, InsertBefore);
910 const Twine &NameStr,
912 return CreateInBounds(
nullptr, Ptr, IdxList, NameStr, InsertAtEnd);
917 const Twine &NameStr,
920 Create(PointeeType, Ptr, IdxList, NameStr, InsertAtEnd);
934 assert(ResultElementType ==
935 cast<PointerType>(
getType()->getScalarType())->getElementType());
936 return ResultElementType;
998 for (
Value *Index : IdxList)
999 if (Index->getType()->isVectorTy()) {
1000 unsigned NumElem = Index->getType()->getVectorNumElements();
1044 return (I->
getOpcode() == Instruction::GetElementPtr);
1047 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1056 GetElementPtrInst::GetElementPtrInst(
Type *PointeeType,
Value *
Ptr,
1058 const Twine &NameStr,
1060 :
Instruction(getGEPReturnType(PointeeType, Ptr, IdxList), GetElementPtr,
1062 Values, InsertBefore),
1063 SourceElementType(PointeeType),
1064 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1065 assert(ResultElementType ==
1066 cast<PointerType>(
getType()->getScalarType())->getElementType());
1067 init(Ptr, IdxList, NameStr);
1070 GetElementPtrInst::GetElementPtrInst(
Type *PointeeType, Value *Ptr,
1071 ArrayRef<Value *> IdxList,
unsigned Values,
1072 const Twine &NameStr,
1074 : Instruction(getGEPReturnType(PointeeType, Ptr, IdxList), GetElementPtr,
1075 OperandTraits<GetElementPtrInst>::op_end(this) - Values,
1076 Values, InsertAtEnd),
1077 SourceElementType(PointeeType),
1078 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1079 assert(ResultElementType ==
1080 cast<PointerType>(
getType()->getScalarType())->getElementType());
1081 init(Ptr, IdxList, NameStr);
1095 void anchor()
override;
1100 "Invalid ICmp predicate value");
1102 "Both operands to ICmp instruction are not of the same type!");
1105 getOperand(0)->
getType()->isPtrOrPtrVectorTy()) &&
1106 "Invalid operand types for ICmp instruction");
1123 const Twine &NameStr =
""
1124 ) : CmpInst(makeCmpResultType(LHS->
getType()),
1138 const Twine &NameStr =
""
1139 ) : CmpInst(makeCmpResultType(LHS->
getType()),
1152 const Twine &NameStr =
""
1153 ) : CmpInst(makeCmpResultType(LHS->
getType()),
1165 return getSignedPredicate(getPredicate());
1177 return getUnsignedPredicate(getPredicate());
1187 return P == ICMP_EQ || P == ICMP_NE;
1193 return isEquality(getPredicate());
1203 return !isEquality();
1209 return !isEquality(P);
1219 Op<0>().
swap(Op<1>());
1224 return I->
getOpcode() == Instruction::ICmp;
1227 return isa<Instruction>(V) && classof(cast<Instruction>(V));
1254 const Twine &NameStr =
""
1259 "Invalid FCmp predicate value");
1261 "Both operands to FCmp instruction are not of the same type!");
1264 "Invalid operand types for FCmp instruction");
1273 const Twine &NameStr =
""
1278 "Invalid FCmp predicate value");
1280 "Both operands to FCmp instruction are not of the same type!");
1283 "Invalid operand types for FCmp instruction");
1291 const Twine &NameStr =
""
1295 "Invalid FCmp predicate value");
1297 "Both operands to FCmp instruction are not of the same type!");
1300 "Invalid operand types for FCmp instruction");
1335 Op<0>().
swap(Op<1>());
1340 return I->
getOpcode() == Instruction::FCmp;
1343 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1364 inline CallInst(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
1365 ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr,
1366 Instruction *InsertBefore);
1369 ArrayRef<OperandBundleDef> Bundles, const Twine &NameStr,
1370 Instruction *InsertBefore)
1372 cast<PointerType>(Func->getType())->getElementType()),
1373 Func,
Args, Bundles, NameStr, InsertBefore) {}
1382 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr,
1385 explicit CallInst(
Value *
F,
const Twine &NameStr,
1391 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr) {
1392 init(cast<FunctionType>(
1393 cast<PointerType>(Func->getType())->getElementType()),
1394 Func, Args, Bundles, NameStr);
1396 void init(FunctionType *FTy,
Value *Func, ArrayRef<Value *> Args,
1397 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr);
1398 void init(
Value *Func,
const Twine &NameStr);
1413 const Twine &NameStr =
"",
1415 return Create(cast<FunctionType>(
1416 cast<PointerType>(Func->
getType())->getElementType()),
1417 Func, Args, Bundles, NameStr, InsertBefore);
1421 const Twine &NameStr,
1423 return Create(cast<FunctionType>(
1424 cast<PointerType>(Func->
getType())->getElementType()),
1425 Func, Args,
None, NameStr, InsertBefore);
1429 const Twine &NameStr,
1437 const Twine &NameStr =
"",
1439 const unsigned TotalOps =
1441 const unsigned DescriptorBytes = Bundles.size() *
sizeof(
BundleOpInfo);
1443 return new (TotalOps, DescriptorBytes)
1444 CallInst(Ty, Func, Args, Bundles, NameStr, InsertBefore);
1450 const unsigned TotalOps =
1454 return new (TotalOps, DescriptorBytes)
1455 CallInst(Func, Args, Bundles, NameStr, InsertAtEnd);
1466 return new(1)
CallInst(F, NameStr, InsertBefore);
1471 return new(1)
CallInst(F, NameStr, InsertAtEnd);
1491 Value *AllocSize,
Value *ArraySize =
nullptr,
1496 Value *AllocSize,
Value *ArraySize =
nullptr,
1501 Value *AllocSize,
Value *ArraySize =
nullptr,
1507 Value *AllocSize,
Value *ArraySize =
nullptr,
1628 auto ID =
static_cast<unsigned>(CC);
1663 assert(Kind != Attribute::NoBuiltin &&
1664 "Use CallInst::isNoBuiltin() to check for Attribute::NoBuiltin");
1665 return hasFnAttrImpl(Kind);
1670 return hasFnAttrImpl(Kind);
1728 return hasFnAttrImpl(Attribute::NoBuiltin) &&
1729 !hasFnAttrImpl(Attribute::Builtin);
1740 return hasFnAttr(Attribute::ReturnsTwice);
1773 return hasFnAttr(Attribute::ArgMemOnly);
1836 cast<FunctionType>(cast<PointerType>(Fn->
getType())->getElementType()),
1841 assert(FTy == cast<FunctionType>(
1842 cast<PointerType>(Fn->
getType())->getElementType()));
1848 return isa<InlineAsm>(
Op<-1>());
1856 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1860 template <
typename AttrKind>
bool hasFnAttrImpl(AttrKind
Kind)
const {
1876 void setInstructionSubclassData(
unsigned short D) {
1890 ->getElementType())->getReturnType(),
1892 (Args.size() + CountBundleInputs(Bundles) + 1),
1893 unsigned(Args.size() + CountBundleInputs(Bundles) + 1), InsertAtEnd) {
1894 init(Func, Args, Bundles, NameStr);
1897 CallInst::CallInst(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
1898 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr,
1899 Instruction *InsertBefore)
1900 : Instruction(Ty->getReturnType(), Instruction::
Call,
1901 OperandTraits<CallInst>::op_end(this) -
1902 (Args.size() + CountBundleInputs(Bundles) + 1),
1903 unsigned(Args.size() + CountBundleInputs(Bundles) + 1),
1905 init(Ty, Func, Args, Bundles, NameStr);
1921 Instruction *InsertBefore)
1923 &Op<0>(), 3, InsertBefore) {
1931 &Op<0>(), 3, InsertAtEnd) {
1937 assert(!areInvalidOperands(C, S1, S2) &&
"Invalid operands for select");
1945 friend class Instruction;
1951 const Twine &NameStr =
"",
1952 Instruction *InsertBefore =
nullptr,
1953 Instruction *MDFrom =
nullptr) {
1961 const Twine &NameStr,
1963 return new(3)
SelectInst(C, S1, S2, NameStr, InsertAtEnd);
1979 static const char *areInvalidOperands(
Value *Cond,
Value *True,
Value *False);
1993 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2020 : UnaryInstruction(Ty, VAArg, List, InsertBefore) {
2026 : UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
2039 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2064 const Twine &NameStr =
"",
2070 const Twine &NameStr,
2093 return I->
getOpcode() == Instruction::ExtractElement;
2096 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
2116 const Twine &NameStr =
"",
2117 Instruction *InsertBefore =
nullptr);
2123 friend class Instruction;
2129 const Twine &NameStr =
"",
2130 Instruction *InsertBefore =
nullptr) {
2135 const Twine &NameStr,
2142 static bool isValidOperands(
const Value *Vec,
const Value *NewElt,
2156 return I->
getOpcode() == Instruction::InsertElement;
2159 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2180 friend class Instruction;
2186 const Twine &NameStr =
"",
2187 Instruction *InsertBefor =
nullptr);
2192 void *
operator new(
size_t s) {
2193 return User::operator
new(s, 3);
2198 static bool isValidOperands(
const Value *V1,
const Value *
V2,
2211 return cast<Constant>(getOperand(2));
2221 return getMaskValue(getMask(), Elt);
2231 return getShuffleMask(getMask(), Result);
2236 getShuffleMask(Mask);
2242 return I->
getOpcode() == Instruction::ShuffleVector;
2245 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2273 const Twine &NameStr,
2280 void *
operator new(
size_t s) {
return User::operator
new(s, 1); }
2293 const Twine &NameStr =
"",
2301 const Twine &NameStr,
2320 return getOperand(0);
2323 return getOperand(0);
2334 return (
unsigned)Indices.
size();
2343 return I->
getOpcode() == Instruction::ExtractValue;
2346 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2350 ExtractValueInst::ExtractValueInst(Value *Agg,
2351 ArrayRef<unsigned> Idxs,
2352 const Twine &NameStr,
2353 Instruction *InsertBefore)
2355 ExtractValue, Agg, InsertBefore) {
2356 init(Idxs, NameStr);
2359 ExtractValueInst::ExtractValueInst(Value *Agg,
2360 ArrayRef<unsigned> Idxs,
2361 const Twine &NameStr,
2364 ExtractValue, Agg, InsertAtEnd) {
2365 init(Idxs, NameStr);
2386 const Twine &NameStr,
2395 const Twine &NameStr =
"",
2401 const Twine &NameStr);
2411 void *
operator new(
size_t s) {
2412 return User::operator
new(s, 2);
2415 void *
operator new(size_t,
unsigned) =
delete;
2419 const Twine &NameStr =
"",
2426 const Twine &NameStr,
2466 return (
unsigned)Indices.
size();
2475 return I->
getOpcode() == Instruction::InsertValue;
2478 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
2487 InsertValueInst::InsertValueInst(
Value *Agg,
2490 const Twine &NameStr,
2495 init(Agg, Val, Idxs, NameStr);
2498 InsertValueInst::InsertValueInst(Value *Agg,
2500 ArrayRef<unsigned> Idxs,
2501 const Twine &NameStr,
2503 : Instruction(Agg->
getType(), InsertValue,
2504 OperandTraits<InsertValueInst>::op_begin(this),
2506 init(Agg, Val, Idxs, NameStr);
2522 unsigned ReservedSpace;
2527 explicit PHINode(
Type *Ty,
unsigned NumReservedValues,
2528 const Twine &NameStr =
"",
2529 Instruction *InsertBefore =
nullptr)
2530 : Instruction(Ty, Instruction::PHI,
nullptr, 0, InsertBefore),
2531 ReservedSpace(NumReservedValues) {
2533 allocHungoffUses(ReservedSpace);
2538 : Instruction(Ty, Instruction::PHI,
nullptr, 0, InsertAtEnd),
2539 ReservedSpace(NumReservedValues) {
2541 allocHungoffUses(ReservedSpace);
2544 void *
operator new(
size_t s) {
2545 return User::operator
new(s);
2548 void anchor()
override;
2552 friend class Instruction;
2564 void *
operator new(size_t,
unsigned) =
delete;
2569 const Twine &NameStr =
"",
2570 Instruction *InsertBefore =
nullptr) {
2571 return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
2576 return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd);
2590 reinterpret_cast<Use::UserRef*
>(op_begin() + ReservedSpace);
2591 return reinterpret_cast<block_iterator
>(ref + 1);
2596 reinterpret_cast<const Use::UserRef*
>(op_begin() + ReservedSpace);
2597 return reinterpret_cast<const_block_iterator
>(ref + 1);
2601 return block_begin() + getNumOperands();
2605 return block_begin() + getNumOperands();
2609 return make_range(block_begin(), block_end());
2613 return make_range(block_begin(), block_end());
2627 return getOperand(i);
2630 assert(V &&
"PHI node got a null value!");
2632 "All operands to PHI node must be the same type as the PHI node!");
2645 return block_begin()[
i];
2652 assert(
this == U.
getUser() &&
"Iterator doesn't point to PHI's Uses?");
2653 return getIncomingBlock(
unsigned(&U - op_begin()));
2660 return getIncomingBlock(I.getUse());
2664 assert(BB &&
"PHI node got a null basic block!");
2665 block_begin()[
i] = BB;
2671 if (getNumOperands() == ReservedSpace)
2674 setNumHungOffUseOperands(getNumOperands() + 1);
2675 setIncomingValue(getNumOperands() - 1, V);
2676 setIncomingBlock(getNumOperands() - 1, BB);
2687 Value *removeIncomingValue(
unsigned Idx,
bool DeletePHIIfEmpty =
true);
2690 int Idx = getBasicBlockIndex(BB);
2691 assert(Idx >= 0 &&
"Invalid basic block argument to remove!");
2692 return removeIncomingValue(Idx, DeletePHIIfEmpty);
2699 for (
unsigned i = 0, e = getNumOperands();
i != e; ++
i)
2700 if (block_begin()[
i] == BB)
2706 int Idx = getBasicBlockIndex(BB);
2707 assert(Idx >= 0 &&
"Invalid basic block argument!");
2708 return getIncomingValue(Idx);
2713 Value *hasConstantValue()
const;
2718 bool hasConstantOrUndefValue()
const;
2722 return I->
getOpcode() == Instruction::PHI;
2725 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2729 void growOperands();
2753 unsigned ReservedSpace;
2762 const Twine &NameStr, Instruction *InsertBefore);
2767 void *
operator new(
size_t s) {
2768 return User::operator
new(s);
2771 void growOperands(
unsigned Size);
2772 void init(
unsigned NumReservedValues,
const Twine &NameStr);
2776 friend class Instruction;
2781 void *
operator new(size_t,
unsigned) =
delete;
2786 const Twine &NameStr =
"",
2787 Instruction *InsertBefore =
nullptr);
2797 bool isCleanup()
const {
return getSubclassDataFromInstruction() & 1; }
2801 setInstructionSubclassData((getSubclassDataFromInstruction() & ~1) |
2806 void addClause(
Constant *ClauseVal);
2811 return cast<Constant>(getOperandList()[Idx]);
2816 return !isa<ArrayType>(getOperandList()[Idx]->getType());
2821 return isa<ArrayType>(getOperandList()[Idx]->getType());
2833 return I->
getOpcode() == Instruction::LandingPad;
2836 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2885 return new(!!retVal)
ReturnInst(C, retVal, InsertBefore);
2890 return new(!!retVal)
ReturnInst(C, retVal, InsertAtEnd);
2902 return getNumOperands() != 0 ? getOperand(0) :
nullptr;
2912 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2916 BasicBlock *getSuccessorV(
unsigned idx)
const override;
2917 unsigned getNumSuccessorsV()
const override;
2918 void setSuccessorV(
unsigned idx,
BasicBlock *
B)
override;
2965 return new(1)
BranchInst(IfTrue, InsertBefore);
2970 return new(3)
BranchInst(IfTrue, IfFalse, Cond, InsertBefore);
2974 return new(1)
BranchInst(IfTrue, InsertAtEnd);
2979 return new(3)
BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd);
2989 assert(isConditional() &&
"Cannot get condition of an uncond branch!");
2994 assert(isConditional() &&
"Cannot set condition of unconditional branch!");
3001 assert(i < getNumSuccessors() &&
"Successor # out of range for Branch!");
3002 return cast_or_null<BasicBlock>((&
Op<-1>() - i)->get());
3006 assert(idx < getNumSuccessors() &&
"Successor # out of range for Branch!");
3007 *(&
Op<-1>() - idx) = NewSucc;
3015 void swapSuccessors();
3019 return (I->
getOpcode() == Instruction::Br);
3022 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3026 BasicBlock *getSuccessorV(
unsigned idx)
const override;
3027 unsigned getNumSuccessorsV()
const override;
3028 void setSuccessorV(
unsigned idx,
BasicBlock *
B)
override;
3045 unsigned ReservedSpace;
3068 void *
operator new(
size_t s) {
3069 return User::operator
new(s);
3072 void init(Value *Value,
BasicBlock *Default,
unsigned NumReserved);
3073 void growOperands();
3082 void *
operator new(size_t,
unsigned) =
delete;
3085 static const unsigned DefaultPseudoIndex =
static_cast<unsigned>(~0
L-1);
3087 template <
class SwitchInstTy,
class ConstantIntTy,
class BasicBlockTy>
3106 assert(SuccessorIndex < SI->getNumSuccessors() &&
3107 "Successor index # out of range!");
3108 return SuccessorIndex != 0 ?
3109 Self(SI, SuccessorIndex - 1) :
3110 Self(SI, DefaultPseudoIndex);
3115 assert(Index < SI->getNumCases() &&
"Index out the number of cases.");
3116 return reinterpret_cast<ConstantIntTy*
>(SI->
getOperand(2 + Index*2));
3121 assert((Index < SI->getNumCases() ||
3122 Index == DefaultPseudoIndex) &&
3123 "Index out the number of cases.");
3132 assert((Index == DefaultPseudoIndex || Index < SI->getNumCases()) &&
3133 "Index out the number of cases.");
3134 return Index != DefaultPseudoIndex ? Index + 1 : 0;
3154 "Index out the number of cases.");
3164 assert(RHS.
SI == SI &&
"Incompatible operators.");
3165 return RHS.
Index == Index;
3168 assert(RHS.
SI == SI &&
"Incompatible operators.");
3169 return RHS.
Index != Index;
3176 typedef CaseIteratorT<const SwitchInst, const ConstantInt, const BasicBlock>
3188 assert(Index < SI->getNumCases() &&
"Index out the number of cases.");
3189 SI->
setOperand(2 + Index*2, reinterpret_cast<Value*>(V));
3201 return new SwitchInst(Value, Default, NumCases, InsertBefore);
3205 unsigned NumCases,
BasicBlock *InsertAtEnd) {
3206 return new SwitchInst(Value, Default, NumCases, InsertAtEnd);
3217 return cast<BasicBlock>(getOperand(1));
3221 setOperand(1, reinterpret_cast<Value*>(DefaultCase));
3227 return getNumOperands()/2 - 1;
3245 return CaseIt(
this, getNumCases());
3270 return CaseIt(
this, DefaultPseudoIndex);
3281 for (
CaseIt i = case_begin(), e = case_end();
i != e; ++
i)
3282 if (
i.getCaseValue() ==
C)
3284 return case_default();
3288 if (
i.getCaseValue() ==
C)
3290 return case_default();
3296 if (BB == getDefaultDest())
return nullptr;
3299 for (
CaseIt i = case_begin(), e = case_end();
i != e; ++
i) {
3300 if (
i.getCaseSuccessor() == BB) {
3301 if (CI)
return nullptr;
3302 else CI =
i.getCaseValue();
3320 void removeCase(CaseIt
i);
3324 assert(idx < getNumSuccessors() &&
"Successor idx out of range for switch!");
3325 return cast<BasicBlock>(getOperand(idx*2+1));
3328 assert(idx < getNumSuccessors() &&
"Successor # out of range for switch!");
3329 setOperand(idx * 2 + 1, NewSucc);
3337 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3341 BasicBlock *getSuccessorV(
unsigned idx)
const override;
3342 unsigned getNumSuccessorsV()
const override;
3343 void setSuccessorV(
unsigned idx,
BasicBlock *
B)
override;
3360 unsigned ReservedSpace;
3379 void *
operator new(
size_t s) {
3380 return User::operator
new(s);
3383 void init(
Value *Address,
unsigned NumDests);
3384 void growOperands();
3393 void *
operator new(size_t,
unsigned) =
delete;
3427 void removeDestination(
unsigned i);
3431 return cast<BasicBlock>(getOperand(i+1));
3434 setOperand(i + 1, NewSucc);
3439 return I->
getOpcode() == Instruction::IndirectBr;
3442 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3446 BasicBlock *getSuccessorV(
unsigned idx)
const override;
3447 unsigned getNumSuccessorsV()
const override;
3448 void setSuccessorV(
unsigned idx,
BasicBlock *
B)
override;
3471 InvokeInst(const InvokeInst &BI);
3476 inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
3477 ArrayRef<Value *> Args, ArrayRef<OperandBundleDef> Bundles,
3478 unsigned Values, const Twine &NameStr,
3479 Instruction *InsertBefore)
3480 : InvokeInst(cast<FunctionType>(
3481 cast<PointerType>(Func->getType())->getElementType()),
3482 Func, IfNormal, IfException, Args, Bundles, Values, NameStr,
3494 unsigned Values,
const Twine &NameStr,
3497 bool hasDescriptor()
const {
return HasDescriptor; }
3500 ArrayRef<Value *> Args, ArrayRef<OperandBundleDef> Bundles,
3501 const Twine &NameStr) {
3502 init(cast<FunctionType>(
3503 cast<PointerType>(Func->getType())->getElementType()),
3504 Func, IfNormal, IfException, Args, Bundles, NameStr);
3508 BasicBlock *IfException, ArrayRef<Value *> Args,
3509 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr);
3515 InvokeInst *cloneImpl()
const;
3520 const Twine &NameStr,
3522 return Create(cast<FunctionType>(
3523 cast<PointerType>(Func->
getType())->getElementType()),
3524 Func, IfNormal, IfException, Args,
None, NameStr,
3531 const Twine &NameStr =
"",
3533 return Create(cast<FunctionType>(
3534 cast<PointerType>(Func->
getType())->getElementType()),
3535 Func, IfNormal, IfException, Args, Bundles, NameStr,
3541 const Twine &NameStr,
3544 return new (Values) InvokeInst(Ty, Func, IfNormal, IfException, Args,
None,
3545 Values, NameStr, InsertBefore);
3551 const Twine &NameStr =
"",
3553 unsigned Values =
unsigned(Args.
size()) + CountBundleInputs(Bundles) + 3;
3554 unsigned DescriptorBytes = Bundles.size() *
sizeof(BundleOpInfo);
3556 return new (Values, DescriptorBytes)
3557 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, Values,
3558 NameStr, InsertBefore);
3566 return new (Values) InvokeInst(Func, IfNormal, IfException, Args,
None,
3567 Values, NameStr, InsertAtEnd);
3573 unsigned Values =
unsigned(Args.
size()) + CountBundleInputs(Bundles) + 3;
3574 unsigned DescriptorBytes = Bundles.
size() *
sizeof(BundleOpInfo);
3576 return new (Values, DescriptorBytes)
3577 InvokeInst(Func, IfNormal, IfException, Args, Bundles, Values, NameStr,
3603 return getNumOperands() - getNumTotalBundleOperands() - 3;
3609 assert(i < getNumArgOperands() &&
"Out of bounds!");
3610 return getOperand(i);
3613 assert(i < getNumArgOperands() &&
"Out of bounds!");
3623 return op_end() - getNumTotalBundleOperands() - 3;
3637 return op_end() - getNumTotalBundleOperands() - 3;
3647 assert(i < getNumArgOperands() &&
"Out of bounds!");
3648 return getOperandUse(i);
3651 assert(i < getNumArgOperands() &&
"Out of bounds!");
3652 return getOperandUse(i);
3657 Value *getReturnedArgOperand()
const;
3662 return static_cast<CallingConv::ID>(getSubclassDataFromInstruction());
3665 auto ID =
static_cast<unsigned>(CC);
3667 setInstructionSubclassData(
ID);
3682 void addAttribute(
unsigned i,
Attribute Attr);
3688 void removeAttribute(
unsigned i,
StringRef Kind);
3691 void addDereferenceableAttr(
unsigned i, uint64_t Bytes);
3695 void addDereferenceableOrNullAttr(
unsigned i, uint64_t Bytes);
3699 assert(Kind != Attribute::NoBuiltin &&
3700 "Use CallInst::isNoBuiltin() to check for Attribute::NoBuiltin");
3701 return hasFnAttrImpl(Kind);
3706 return hasFnAttrImpl(Kind);
3740 return AttributeList.getParamAlignment(i);
3746 return AttributeList.getDereferenceableBytes(i);
3752 return AttributeList.getDereferenceableOrNullBytes(i);
3767 return hasFnAttrImpl(Attribute::NoBuiltin) &&
3768 !hasFnAttrImpl(Attribute::Builtin);
3772 bool isNoInline()
const {
return hasFnAttr(Attribute::NoInline); }
3779 return hasFnAttr(Attribute::ReadNone);
3804 return hasFnAttr(Attribute::ArgMemOnly);
3840 if (getNumArgOperands() == 0)
3844 return paramHasAttr(1, Attribute::StructRet);
3849 return AttributeList.hasAttrSomewhere(Attribute::ByVal);
3867 cast<FunctionType>(cast<PointerType>(Fn->
getType())->getElementType()),
3872 assert(FTy == cast<FunctionType>(
3873 cast<PointerType>(Fn->
getType())->getElementType()));
3879 return cast<BasicBlock>(
Op<-2>());
3882 return cast<BasicBlock>(
Op<-1>());
3885 Op<-2>() = reinterpret_cast<Value*>(B);
3888 Op<-1>() = reinterpret_cast<Value*>(B);
3896 assert(i < 2 &&
"Successor # out of range for invoke!");
3897 return i == 0 ? getNormalDest() : getUnwindDest();
3901 assert(idx < 2 &&
"Successor # out of range for invoke!");
3902 *(&
Op<-2>() + idx) =
reinterpret_cast<Value*
>(NewSucc);
3909 return (I->
getOpcode() == Instruction::Invoke);
3912 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3916 BasicBlock *getSuccessorV(
unsigned idx)
const override;
3917 unsigned getNumSuccessorsV()
const override;
3918 void setSuccessorV(
unsigned idx,
BasicBlock *
B)
override;
3920 template <
typename AttrKind>
bool hasFnAttrImpl(AttrKind Kind)
const {
3926 if (isFnAttrDisallowedByOpBundle(Kind))
3936 void setInstructionSubclassData(
unsigned short D) {
3949 : TerminatorInst(Ty->getReturnType(),
Instruction::Invoke,
3952 init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
3955 InvokeInst::InvokeInst(Value *Func,
BasicBlock *IfNormal,
3956 BasicBlock *IfException, ArrayRef<Value *> Args,
3957 ArrayRef<OperandBundleDef> Bundles,
unsigned Values,
3958 const Twine &NameStr,
BasicBlock *InsertAtEnd)
3961 ->getElementType())->getReturnType(),
3962 Instruction::Invoke, OperandTraits<InvokeInst>::op_end(this) - Values,
3963 Values, InsertAtEnd) {
3964 init(Func, IfNormal, IfException, Args, Bundles, NameStr);
4007 return I->
getOpcode() == Instruction::Resume;
4010 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4014 BasicBlock *getSuccessorV(
unsigned idx)
const override;
4015 unsigned getNumSuccessorsV()
const override;
4016 void setSuccessorV(
unsigned idx,
BasicBlock *
B)
override;
4032 unsigned ReservedSpace;
4044 unsigned NumHandlers,
const Twine &NameStr,
4052 unsigned NumHandlers,
const Twine &NameStr,
4056 void *
operator new(
size_t s) {
return User::operator
new(s); }
4059 void growOperands(
unsigned Size);
4068 void *
operator new(size_t,
unsigned) =
delete;
4071 unsigned NumHandlers,
4072 const Twine &NameStr =
"",
4074 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
4079 unsigned NumHandlers,
const Twine &NameStr,
4081 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
4096 if (hasUnwindDest())
4097 return cast<BasicBlock>(getOperand(1));
4103 setOperand(1, UnwindDest);
4109 if (hasUnwindDest())
4110 return getNumOperands() - 2;
4111 return getNumOperands() - 1;
4115 static BasicBlock *handler_helper(
Value *V) {
return cast<BasicBlock>(V); }
4116 static const BasicBlock *handler_helper(
const Value *V) {
4117 return cast<BasicBlock>(V);
4121 typedef std::pointer_to_unary_function<Value *, BasicBlock *>
DerefFnTy;
4124 typedef std::pointer_to_unary_function<const Value *, const BasicBlock *>
4131 op_iterator It = op_begin() + 1;
4132 if (hasUnwindDest())
4134 return handler_iterator(It, DerefFnTy(handler_helper));
4141 if (hasUnwindDest())
4143 return const_handler_iterator(It,
ConstDerefFnTy(handler_helper));
4149 return handler_iterator(op_end(), DerefFnTy(handler_helper));
4155 return const_handler_iterator(op_end(),
ConstDerefFnTy(handler_helper));
4160 return make_range(handler_begin(), handler_end());
4165 return make_range(handler_begin(), handler_end());
4174 void removeHandler(handler_iterator
HI);
4178 assert(Idx < getNumSuccessors() &&
4179 "Successor # out of range for catchswitch!");
4180 return cast<BasicBlock>(getOperand(Idx + 1));
4183 assert(Idx < getNumSuccessors() &&
4184 "Successor # out of range for catchswitch!");
4185 setOperand(Idx + 1, NewSucc);
4190 return I->
getOpcode() == Instruction::CatchSwitch;
4193 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4197 BasicBlock *getSuccessorV(
unsigned Idx)
const override;
4198 unsigned getNumSuccessorsV()
const override;
4199 void setSuccessorV(
unsigned Idx,
BasicBlock *
B)
override;
4213 unsigned Values,
const Twine &NameStr,
4215 : FuncletPadInst(Instruction::CleanupPad, ParentPad, Args, Values,
4216 NameStr, InsertBefore) {}
4218 unsigned Values,
const Twine &NameStr,
4220 : FuncletPadInst(Instruction::CleanupPad, ParentPad, Args, Values,
4221 NameStr, InsertAtEnd) {}
4225 const Twine &NameStr =
"",
4227 unsigned Values = 1 + Args.
size();
4234 unsigned Values = 1 + Args.
size();
4241 return I->
getOpcode() == Instruction::CleanupPad;
4244 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4254 unsigned Values,
const Twine &NameStr,
4256 :
FuncletPadInst(Instruction::CatchPad, CatchSwitch, Args, Values,
4257 NameStr, InsertBefore) {}
4259 unsigned Values,
const Twine &NameStr,
4261 :
FuncletPadInst(Instruction::CatchPad, CatchSwitch, Args, Values,
4262 NameStr, InsertAtEnd) {}
4266 const Twine &NameStr =
"",
4268 unsigned Values = 1 + Args.
size();
4270 CatchPadInst(CatchSwitch, Args, Values, NameStr, InsertBefore);
4275 unsigned Values = 1 + Args.
size();
4277 CatchPadInst(CatchSwitch, Args, Values, NameStr, InsertAtEnd);
4282 return cast<CatchSwitchInst>(
Op<-1>());
4286 Op<-1>() = CatchSwitch;
4291 return I->
getOpcode() == Instruction::CatchPad;
4294 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4355 return (I->
getOpcode() == Instruction::CatchRet);
4358 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4362 BasicBlock *getSuccessorV(
unsigned Idx)
const override;
4363 unsigned getNumSuccessorsV()
const override;
4364 void setSuccessorV(
unsigned Idx,
BasicBlock *
B)
override;
4398 unsigned Values = 1;
4408 unsigned Values = 1;
4423 return cast<CleanupPadInst>(Op<0>());
4427 Op<0>() = CleanupPad;
4433 return hasUnwindDest() ? cast<BasicBlock>(Op<1>()) :
nullptr;
4443 return (I->
getOpcode() == Instruction::CleanupRet);
4446 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4450 BasicBlock *getSuccessorV(
unsigned Idx)
const override;
4451 unsigned getNumSuccessorsV()
const override;
4452 void setSuccessorV(
unsigned Idx,
BasicBlock *
B)
override;
4456 void setInstructionSubclassData(
unsigned short D) {
4488 void *
operator new(
size_t s) {
4489 return User::operator
new(s, 0);
4492 void *
operator new(size_t,
unsigned) =
delete;
4498 return I->
getOpcode() == Instruction::Unreachable;
4501 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4505 BasicBlock *getSuccessorV(
unsigned idx)
const override;
4506 unsigned getNumSuccessorsV()
const override;
4507 void setSuccessorV(
unsigned idx,
BasicBlock *
B)
override;
4528 const Twine &NameStr =
"",
4536 const Twine &NameStr,
4545 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4567 const Twine &NameStr =
"",
4575 const Twine &NameStr,
4584 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4606 const Twine &NameStr =
"",
4614 const Twine &NameStr,
4623 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4645 const Twine &NameStr =
"",
4653 const Twine &NameStr,
4662 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4684 const Twine &NameStr =
"",
4692 const Twine &NameStr,
4701 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4723 const Twine &NameStr =
"",
4731 const Twine &NameStr,
4740 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4762 const Twine &NameStr =
"",
4770 const Twine &NameStr,
4779 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4801 const Twine &NameStr =
"",
4809 const Twine &NameStr,
4818 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4840 const Twine &NameStr =
"",
4848 const Twine &NameStr,
4857 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4875 const Twine &NameStr =
"",
4883 const Twine &NameStr,
4900 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4922 const Twine &NameStr =
"",
4930 const Twine &NameStr,
4951 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4973 const Twine &NameStr =
"",
4981 const Twine &NameStr,
4990 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5013 const Twine &NameStr =
"",
5021 const Twine &NameStr,
5030 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5061 #endif // LLVM_IR_INSTRUCTIONS_H
static unsigned getInsertedValueOperandIndex()
AttributeSet getAttributes() const
Return the parameter attributes for this call.
const Value * getAddress() const
iterator_range< const_handler_iterator > const_handler_range
const Use & getOperandUse(unsigned i) const
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
BasicBlock * getSuccessor(unsigned i) const
Return a value (possibly void), from a function.
The highest possible calling convention ID. Must be some 2^k - 1.
Value * getValueOperand()
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
bool hasStructRetAttr() const
Determine if the call returns a structure through first pointer argument.
AllocaInst(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="", Instruction *InsertBefore=nullptr)
static bool isEquality(Predicate Pred)
A parsed version of the target data layout string in and methods for querying it. ...
AtomicOrdering getFailureOrdering() const
Returns the ordering constraint on this cmpxchg.
Value * getPointerOperand()
unsigned getNumHandlers() const
return the number of 'handlers' in this catchswitch instruction, except the default handler ...
static bool classof(const Instruction *I)
CaseIt case_end()
Returns a read/write iterator that points one past the last in the SwitchInst.
This class is the base class for the comparison instructions.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
ConstantIntTy * getCaseValue()
Resolves case value for current case.
void getShuffleMask(SmallVectorImpl< int > &Result) const
Return the mask for this instruction as a vector of integers.
void setUnwindDest(BasicBlock *UnwindDest)
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
CatchPadInst * getCatchPad() const
Convenience accessors.
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Get the attribute of a given kind at a position.
*p = old <signed v ? old : v
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
Value * getAggregateOperand()
static bool classof(const Instruction *I)
iterator_range< handler_iterator > handler_range
static bool classof(const Instruction *I)
static bool classof(const Instruction *I)
Atomic ordering constants.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Type * getSourceElementType() const
static bool classof(const Value *V)
mapped_iterator< op_iterator, DerefFnTy > handler_iterator
bool isVolatile() const
Return true if this is a store to a volatile memory location.
SynchronizationScope getSynchScope() const
ArrayRef< unsigned > getIndices() const
AttributeSet getAttributes() const
Return the parameter attributes for this invoke.
void setCalledFunction(Value *Fn)
Set the function called.
void allocHungoffUses(unsigned N)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr, BasicBlock *InsertAtEnd)
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a invoke argument.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=nullptr)
void setOrdering(AtomicOrdering Ordering)
Set the ordering constraint on this RMW.
static bool classof(const Instruction *I)
void setAlignment(unsigned Align)
int getMaskValue(unsigned Elt) const
Return the shuffle mask value of this instruction for the given element index.
AtomicOrdering getSuccessOrdering() const
Returns the ordering constraint on this cmpxchg.
An instruction for ordering other memory operations.
unsigned getSuccessorIndex() const
Returns TerminatorInst's successor index for current case successor.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
PtrToIntInst * cloneImpl() const
Clone an identical PtrToIntInst.
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
iterator_range< const_op_iterator > arg_operands() const
Iteration adapter for range-for loops.
void setSynchScope(SynchronizationScope xthread)
Specify whether this fence orders other operations with respect to all concurrently executing threads...
This class represents zero extension of integer types.
unsigned getNumOperands() const
unsigned getNumSuccessors() const
bool hasFnAttr(StringRef Kind) const
Determine whether this call has the given attribute.
void setSuccessor(BasicBlock *S)
Sets the new successor for current case.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Value * getValue() const
Convenience accessor.
void setDoesNotReadMemory()
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Value * getPointerOperand()
Gets the pointer operand.
This class represents a function call, abstracting a target machine's calling convention.
static bool classof(const Value *V)
void setOrdering(AtomicOrdering Ordering)
Set the ordering constraint on this load.
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
static bool classof(const Value *V)
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
*p = old <unsigned v ? old : v
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
const_handler_range handlers() const
iteration adapter for range-for loops.
CaseIteratorT(SwitchInstTy *SI, unsigned CaseNum)
Initializes case iterator for given SwitchInst and for given case number.
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
*p = old >unsigned v ? old : v
Attribute getAttribute(unsigned i, StringRef Kind) const
Get the attribute of a given kind at a position.
This instruction constructs a fixed permutation of two input vectors.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
static bool classof(const Value *V)
static bool classof(const Value *V)
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
iterator_range< op_iterator > arg_operands()
Iteration adapter for range-for loops.
1 1 1 0 True if unordered or not equal
bool doesNotThrow() const
Determine if the call cannot unwind.
static bool classof(const Instruction *I)
static bool isEquality(Predicate P)
Return true if this predicate is either EQ or NE.
unsigned getNumIndices() const
void setSuccessor(unsigned i, BasicBlock *NewSucc)
void setSuccessor(BasicBlock *NewSucc)
Value * getNewValOperand()
unsigned getParamAlignment(unsigned Index) const
Return the alignment for the specified function parameter.
The two locations do not alias at all.
This class represents a sign extension of integer types.
An instruction for reading from memory.
static bool classof(const Value *V)
static bool classof(const Value *V)
CleanupPadInst * getCleanupPad() const
Convenience accessor.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
void setAddress(Value *V)
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB, BasicBlock *InsertAtEnd)
LoadInst(Value *Ptr, const char *NameStr=nullptr, bool isVolatile=false, Instruction *InsertBefore=nullptr)
CaseIt(SwitchInst *SI, unsigned CaseNum)
static Instruction * CreateFree(Value *Source, Instruction *InsertBefore)
Generate the IR for a call to the builtin free function.
static bool classof(const Value *V)
This defines the Use class.
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
handler_iterator handler_begin()
Returns an iterator that points to the first handler in CatchSwitchInst.
static bool classof(const Instruction *I)
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
SExtInst * cloneImpl() const
Clone an identical SExtInst.
static bool classof(const Instruction *I)
const Value * getPointerOperand() const
*p = old >signed v ? old : v
void setSynchScope(SynchronizationScope SynchScope)
Specify whether this cmpxchg is atomic and orders other operations with respect to all concurrently e...
unsigned getSrcAddressSpace() const
Returns the address space of the pointer operand.
bool doesNotReturn() const
Determine if the call cannot return.
unsigned getNumIndices() const
static bool classof(const Instruction *I)
Value * removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true)
ConstantInt * findCaseDest(BasicBlock *BB)
Finds the unique case value for a given successor.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd)
Constant * getMask() const
void setAttributes(AttributeSet Attrs)
Set the parameter attributes for this invoke.
FPExtInst * cloneImpl() const
Clone an identical FPExtInst.
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd)
void setVolatile(bool V)
Specify whether this is a volatile RMW or not.
block_iterator block_end()
static bool classof(const Instruction *I)
BasicBlock *const * const_block_iterator
void setCallingConv(CallingConv::ID CC)
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr, BasicBlock *InsertAtEnd)
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1...
bool isFnAttrDisallowedByOpBundle(StringRef S) const
Is the function attribute S disallowed by some operand bundle on this operand bundle user...
static bool classof(const Instruction *I)
1 0 0 1 True if unordered or equal
void setSynchScope(SynchronizationScope xthread)
Specify whether this load is ordered with respect to all concurrently executing threads, or only with respect to signal handlers executing in the same thread.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
static unsigned getOperandNumForIncomingValue(unsigned i)
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
bool isUnconditional() const
This class represents a conversion between pointers from one address space to another.
uint64_t getDereferenceableBytes(unsigned Index) const
Get the number of dereferenceable bytes (or zero if unknown).
static Value * getPointerOperand(Instruction &Inst)
unsigned getSubclassDataFromInstruction() const
This class represents the LLVM 'select' instruction.
IntToPtrInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
static bool classof(const Value *V)
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void setCleanupPad(CleanupPadInst *CleanupPad)
This is the base class for all instructions that perform data casts.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
CallInst * cloneImpl() const
static bool classof(const Instruction *I)
bool doesNotReturn() const
Determine if the call cannot return.
static bool classof(const Value *V)
A Use represents the edge between a Value definition and its users.
void setSynchScope(SynchronizationScope xthread)
Specify whether this store instruction is ordered with respect to all concurrently executing threads...
static bool classof(const Value *V)
void setOrdering(AtomicOrdering Ordering)
Set the ordering constraint on this fence.
bool onlyAccessesArgMemory() const
Determine if the call access memmory only using it's pointer arguments.
void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
PtrToIntInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
unsigned getNumArgOperands() const
Return the number of call arguments.
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
UIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
This file contains the simple types necessary to represent the attributes associated with functions a...
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
FCmpInst * cloneImpl() const
Clone an identical FCmpInst.
bool isCommutative() const
bool isMustTailCall() const
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
void setCalledFunction(FunctionType *FTy, Value *Fn)
FPToUIInst * cloneImpl() const
Clone an identical FPToUIInst.
Value * getPointerOperand()
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
block_iterator block_begin()
unsigned getNumSuccessors() const
BasicBlock * getDestination(unsigned i)
Return the specified destination.
iterator_range< ConstCaseIt > cases() const
Constant iteration adapter for range-for loops.
static bool classof(const Instruction *I)
SynchronizationScope getSynchScope() const
This class represents a cast from a pointer to an integer.
AtomicOrdering
Atomic ordering for LLVM's memory model.
bool doesNotThrow() const
Determine if the call cannot unwind.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
void setUnwindDest(BasicBlock *B)
Value * getPointerOperand()
UIToFPInst * cloneImpl() const
Clone an identical UIToFPInst.
const_op_iterator idx_end() const
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
AtomicOrdering getOrdering() const
Returns the ordering constraint on this RMW.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr, BasicBlock *InsertAtEnd)
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
static bool classof(const Instruction *I)
BitCastInst * cloneImpl() const
Clone an identical BitCastInst.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
VectorType * getType() const
Overload to return most specific vector type.
bool isNoInline() const
Return true if the call should not be inlined.
void setValue(ConstantInt *V)
Sets the new value for current case.
op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
void setNormalDest(BasicBlock *B)
bool doesNotAccessMemory() const
Determine if the call does not access memory.
void mutateFunctionType(FunctionType *FTy)
const unsigned * idx_iterator
CaseIteratorT< const SwitchInst, const ConstantInt, const BasicBlock > ConstCaseIt
CaseIt(const ParentTy &Src)
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, Instruction *InsertBefore=nullptr)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
This instruction compares its operands according to the predicate given to the constructor.
idx_iterator idx_end() const
BasicBlock * getSuccessor(unsigned i) const
static bool classof(const Value *V)
static bool classof(const Value *V)
This class represents a no-op cast from one type to another.
BasicBlock * getIncomingBlock(const Use &U) const
Return incoming basic block corresponding to an operand of the PHI.
StoreInst * cloneImpl() const
bool hasFnAttr(StringRef Kind) const
Determine whether this call has the given attribute.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Value * getInsertedValueOperand()
Used to keep track of an operand bundle.
unsigned getNumSuccessors() const
const Value * getInsertedValueOperand() const
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes.
SIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Predicate getUnsignedPredicate() const
For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
static bool classof(const Value *V)
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
FPToSIInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
void setInstructionSubclassData(unsigned short D)
An instruction for storing to memory.
This class represents a cast from floating point to signed integer.
const_handler_iterator handler_begin() const
Returns an iterator that points to the first handler in the CatchSwitchInst.
BasicBlock * getIncomingBlock(Value::const_user_iterator I) const
Return incoming basic block corresponding to value use iterator.
bool isNoTailCall() const
const Value * getPointerOperand() const
Gets the pointer operand.
static bool classof(const Value *V)
BasicBlock * getSuccessor() const
handler_range handlers()
iteration adapter for range-for loops.
ICmpInst(BasicBlock &InsertAtEnd, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-at-end semantics.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const Value *V)
Type * getScalarType() const LLVM_READONLY
If this is a vector type, return the element type, otherwise return 'this'.
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
bool cannotDuplicate() const
Determine if the invoke cannot be duplicated.
This class represents a truncation of integer types.
size_t size() const
size - Get the array size.
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
bool hasByValArgument() const
Determine if any call argument is an aggregate passed by value.
BasicBlock * getNormalDest() const
unsigned getNumSuccessors() const
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
Class to represent pointers.
void setAttributes(AttributeSet Attrs)
Set the parameter attributes for this call.
OtherOps getOpcode() const
unsigned getNumIncomingValues() const
Return the number of incoming edges.
FPTruncInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
void setUnwindDest(BasicBlock *NewDest)
SIToFPInst * cloneImpl() const
Clone an identical SIToFPInst.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
LoadInst * cloneImpl() const
static bool classof(const Instruction *I)
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
static bool classof(const Value *V)
static unsigned getPointerOperandIndex()
initializer< Ty > init(const Ty &Val)
This instruction inserts a single (scalar) element into a VectorType value.
void setParentPad(Value *ParentPad)
The landingpad instruction holds all of the information necessary to generate correct exception handl...
void setDoesNotAccessMemory()
VAArgInst(Value *List, Type *Ty, const Twine &NameStr, BasicBlock *InsertAtEnd)
unsigned getAlignment() const
Return the alignment of the access that is being performed.
Subclasses of this class are all able to terminate a basic block.
unsigned getCaseIndex() const
Returns number of current case.
SynchronizationScope getSynchScope() const
Returns whether this RMW is atomic between threads or only within a single thread.
static unsigned getAggregateOperandIndex()
LLVM Basic Block Representation.
iterator_range< idx_iterator > indices() const
PointerIntPair - This class implements a pair of a pointer and small integer.
The instances of the Type class are immutable: once they are created, they are never changed...
static unsigned getPointerOperandIndex()
This is an important class for using LLVM in a threaded context.
const_handler_iterator handler_end() const
Returns an iterator that points one past the last handler in the CatchSwitchInst. ...
Conditional or Unconditional Branch instruction.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isEquality() const
Return true if this predicate is either EQ or NE.
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
This function has undefined behavior.
This is an important base class in LLVM.
PointerType * getType() const
Overload to return most specific pointer type.
const Value * getCondition() const
Resume the propagation of an exception.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Value * getCompareOperand()
void setFailureOrdering(AtomicOrdering Ordering)
void setDoesNotReadMemory()
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
void setCalledFunction(FunctionType *FTy, Value *Fn)
Indirect Branch Instruction.
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static bool classof(const Value *V)
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr, BasicBlock *InsertAtEnd)
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
static unsigned getPointerOperandIndex()
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
static bool classof(const Value *V)
uint64_t getDereferenceableOrNullBytes(unsigned Index) const
Get the number of dereferenceable_or_null bytes (or zero if unknown).
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
This instruction compares its operands according to the predicate given to the constructor.
const Value * getValueOperand() const
bool unwindsToCaller() const
bool doesNotAccessMemory() const
Determine if the call does not access memory.
User * getUser() const
Returns the User that contains this Use.
Value * getOperand(unsigned i) const
0 1 1 1 True if ordered (no nans)
Value * getPointerOperand()
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static bool classof(const Value *V)
CatchSwitchInst * getCatchSwitch() const
Convenience accessors.
op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
iterator_range< block_iterator > blocks()
iterator_range< const_op_iterator > arg_operands() const
Iteration adapter for range-for loops.
Predicate getPredicate() const
Return the predicate for this instruction.
static bool classof(const Value *V)
static Type * getGEPReturnType(Type *ElTy, Value *Ptr, ArrayRef< Value * > IdxList)
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the data operand at index i has the attribute A.
void setTailCallKind(TailCallKind TCK)
void setSourceElementType(Type *Ty)
void setAlignment(unsigned Align)
This class represents a cast from an integer to a pointer.
1 1 1 1 Always true (always folded)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
CaseIteratorT< SwitchInstTy, ConstantIntTy, BasicBlockTy > Self
static bool classof(const Value *V)
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
Macro for generating in-class operand accessor declarations.
void setTailCall(bool isTC=true)
FunctionType * getFunctionType() const
std::pointer_to_unary_function< const Value *, const BasicBlock * > ConstDerefFnTy
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
FPToUIInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
Value(Type *Ty, unsigned scid)
bool unwindsToCaller() const
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, BasicBlock *InsertAtEnd)
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
static unsigned getIncomingValueNumForOperand(unsigned i)
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
bool isNoInline() const
Return true if the call should not be inlined.
const Value * getTrueValue() const
static Self fromSuccessorIndex(SwitchInstTy *SI, unsigned SuccessorIndex)
Initializes case iterator for given SwitchInst and for given TerminatorInst's successor index...
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
ConstCaseIt case_end() const
Returns a read-only iterator that points one past the last in the SwitchInst.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, Instruction *InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned Idx) const
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
unsigned getNumSuccessors() const
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
FunctionType * getFunctionType() const
bool isRelational() const
Return true if the predicate is relational (not EQ or NE).
bool operator!=(const Self &RHS) const
static bool classof(const Instruction *I)
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
BasicBlock * getSuccessor(unsigned i) const
Attribute getAttribute(unsigned i, StringRef Kind) const
Get the attribute of a given kind at a position.
static bool classof(const Value *V)
FCmpInst(Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with no-insertion semantics.
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
void setOnlyAccessesArgMemory()
static AtomicOrdering getStrongestFailureOrdering(AtomicOrdering SuccessOrdering)
Returns the strongest permitted ordering on failure, given the desired ordering on success...
bool hasByValArgument() const
Determine if any call argument is an aggregate passed by value.
TruncInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
BasicBlock * getUnwindDest() const
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr, BasicBlock *InsertAtEnd)
bool isConditional() const
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
BasicBlock * getUnwindDest() const
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
idx_iterator idx_begin() const
LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile=false, Instruction *InsertBefore=nullptr)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
static bool classof(const Instruction *I)
static bool classof(const Value *V)
BasicBlock * getUnwindDest() const
AtomicOrdering getOrdering() const
Returns the ordering effect of this store.
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
This is the shared class of boolean and integer constants.
static bool classof(const Instruction *I)
void setIncomingBlock(unsigned i, BasicBlock *BB)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static bool classof(const Instruction *I)
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
AtomicCmpXchgInst * cloneImpl() const
bool cannotDuplicate() const
Determine if the call cannot be duplicated.
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers...
static bool classof(const Instruction *I)
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=nullptr)
AddrSpaceCastInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
Type * checkGEPType(Type *Ty)
unsigned getDestAddressSpace() const
Returns the address space of the result.
bool doesNotAlias(unsigned n) const
Determine if the parameter or return value is marked with NoAlias attribute.
unsigned getNumSuccessors() const
const BasicBlock * getDestination(unsigned i) const
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
static bool classof(const Instruction *I)
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Use & getArgOperandUse(unsigned i)
ConstCaseIt case_begin() const
Returns a read-only iterator that points to the first case in the SwitchInst.
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size...
Type * getType() const
All values are typed, get the type of this value.
const Value * getCompareOperand() const
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
void mutateFunctionType(FunctionType *FTy)
const Value * getValOperand() const
LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore)
TailCallKind getTailCallKind() const
op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
bool isVolatile() const
Return true if this is a load from a volatile memory location.
This class represents a cast from floating point to unsigned integer.
Value * getCatchSwitchParentPad() const
Get the parentPad of this catchret's catchpad's catchswitch.
BasicBlockTy * getCaseSuccessor()
Resolves successor for current case.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
void setCannotDuplicate()
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
const Value * getAggregateOperand() const
static bool classof(const Instruction *I)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
SExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
bool isConvergent() const
Determine if the call is convergent.
ZExtInst * cloneImpl() const
Clone an identical ZExtInst.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
CaseIt findCaseValue(const ConstantInt *C)
Search all of the case values for the specified constant.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
BinOp getOperation() const
static bool classof(const Instruction *I)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
FCmpInst(BasicBlock &InsertAtEnd, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-at-end semantics.
void setOperand(unsigned i, Value *Val)
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
SynchronizationScope getSynchScope() const
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
A range adaptor for a pair of iterators.
Class to represent vector types.
BasicBlock ** block_iterator
void setVolatile(bool V)
Specify whether this is a volatile store or not.
Class for arbitrary precision integers.
static bool classof(const Instruction *I)
static bool classof(const Value *V)
static bool classof(const Value *V)
ConstCaseIt findCaseValue(const ConstantInt *C) const
const Value * getPointerOperand() const
Value * getReturnedArgOperand() const
If one of the arguments has the 'returned' attribute, return its operand value.
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Value * getIncomingValueForBlock(const BasicBlock *BB) const
void setWeak(bool IsWeak)
void setResultElementType(Type *Ty)
bool isCommutative() const
unsigned getVectorNumElements() const
static bool classof(const Value *V)
ZExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
static ReturnInst * Create(LLVMContext &C, BasicBlock *InsertAtEnd)
bool hasStructRetAttr() const
Determine if the call returns a structure through first pointer argument.
FCmpInst(Instruction *InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
static ResumeInst * Create(Value *Exn, BasicBlock *InsertAtEnd)
Value * getCondition() const
BitCastInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
bool isInlineAsm() const
Check if this call is an inline asm statement.
void setCondition(Value *V)
static CallInst * Create(Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
void setSwiftError(bool V)
Specify whether this alloca is used to represent a swifterror.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
static Instruction * CreateMalloc(Instruction *InsertBefore, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize=nullptr, Function *MallocF=nullptr, const Twine &Name="")
Generate the IR for a call to malloc:
unsigned getNumSuccessors() const
const Value * getNewValOperand() const
Value * getParentPad() const
AllocaInst * cloneImpl() const
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the type of the element that would be loaded with a load instruction with the specified param...
LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, unsigned Align, AtomicOrdering Order, SynchronizationScope SynchScope=CrossThread, Instruction *InsertBefore=nullptr)
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
static bool classof(const Value *V)
void setOrdering(AtomicOrdering Ordering)
Set the ordering constraint on this store.
ConstCaseIt case_default() const
void setCalledFunction(Value *Fn)
Set the function called.
bool isConvergent() const
Determine if the invoke is convergent.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th invoke argument.
BasicBlock * getSuccessor(unsigned idx) const
uint64_t getDereferenceableBytes(unsigned i) const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
user_iterator_impl< const User > const_user_iterator
Value * getCondition() const
Value * getPointerOperand()
Gets the pointer operand.
BasicBlock * getDefaultDest() const
void setTrueValue(Value *V)
void setArgOperand(unsigned i, Value *v)
void setDoesNotAccessMemory()
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
unsigned getNumSuccessors() const
void setCondition(Value *V)
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
CatchReturnInst * cloneImpl() const
const_op_iterator arg_end() const
Return the iterator pointing to the end of the argument list.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
void setOperation(BinOp Operation)
Value * getPointerOperand()
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
uint64_t getDereferenceableOrNullBytes(unsigned i) const
Extract the number of dereferenceable_or_null bytes for a call or parameter (0=unknown).
void setOnlyAccessesArgMemory()
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Get the attribute of a given kind at a position.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
static ReturnInst * Create(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
iterator_range< const_block_iterator > blocks() const
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
void setArgOperand(unsigned i, Value *v)
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
static bool classof(const Value *V)
This class represents a cast unsigned integer to floating point.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
static bool classof(const Value *V)
static bool classof(const Value *V)
0 1 1 0 True if ordered and operands are unequal
Compile-time customization of User operands.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static bool classof(const Value *V)
void setFalseValue(Value *V)
unsigned getNumSuccessors() const
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
VectorType * getType() const
Overload to return most specific vector type.
IntToPtrInst * cloneImpl() const
Clone an identical IntToPtrInst.
static unsigned getPointerOperandIndex()
void setOnlyReadsMemory()
CaseIt case_default()
Returns an iterator that points to the default case.
ICmpInst(Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with no-insertion semantics.
AttributeSet getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
const_op_iterator arg_begin() const
Return the iterator pointing to the beginning of the argument list.
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
bool hasUnwindDest() const
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
void setCatchSwitch(Value *CatchSwitch)
bool doesNotAlias(unsigned n) const
Determine if the parameter or return value is marked with NoAlias attribute.
static CallInst * Create(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd)
static Function * getCalledFunction(const Value *V, bool LookThroughBitCast, bool &IsNoBuiltin)
void reserveClauses(unsigned Size)
Grow the size of the operand list to accommodate the new number of clauses.
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
bool hasUnwindDest() const
static bool classof(const Value *V)
std::pointer_to_unary_function< Value *, BasicBlock * > DerefFnTy
static bool classof(const Value *V)
void setCondition(Value *V)
const_block_iterator block_begin() const
Use & getArgOperandUse(unsigned i)
iterator_range< op_iterator > arg_operands()
Iteration adapter for range-for loops.
static unsigned getPointerOperandIndex()
const Value * getPointerOperand() const
This class represents a cast from signed integer to floating point.
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
GetElementPtrInst * cloneImpl() const
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
handler_iterator handler_end()
Returns a read-only iterator that points one past the last handler in the CatchSwitchInst.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
This class represents a truncation of floating point types.
const Value * getPointerOperand() const
Gets the pointer operand.
const_op_iterator arg_begin() const
Return the iterator pointing to the beginning of the argument list.
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore=nullptr)
void setSuccessOrdering(AtomicOrdering Ordering)
Set the ordering constraint on this cmpxchg.
0 0 0 1 True if ordered and equal
LLVM Value Representation.
void setAlignment(unsigned Align)
FPExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
FPToSIInst * cloneImpl() const
Clone an identical FPToSIInst.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void setDefaultDest(BasicBlock *DefaultCase)
void setOnlyReadsMemory()
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, Instruction *InsertBefore=nullptr)
const Value * getArraySize() const
Get the number of elements allocated.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore)
void setCallingConv(CallingConv::ID CC)
bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const
Determine whether the call or the callee has the given attributes.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
void setSynchScope(SynchronizationScope SynchScope)
Specify whether this RMW orders other operations with respect to all concurrently executing threads...
static bool classof(const Instruction *I)
TruncInst * cloneImpl() const
Clone an identical TruncInst.
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
const Value * getFalseValue() const
StringRef - Represent a constant reference to a string, i.e.
const_block_iterator block_end() const
AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SynchronizationScope SynchScope, Instruction *InsertBefore=nullptr)
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
ICmpInst(Instruction *InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
mapped_iterator< const_op_iterator, ConstDerefFnTy > const_handler_iterator
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
static bool classof(const Value *V)
const_op_range incoming_values() const
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
void setIncomingValue(unsigned i, Value *V)
static bool classof(const Value *V)
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
op_range incoming_values()
This class represents an extension of floating point types.
bool isRelational() const
void setVolatile(bool V)
Specify whether this is a volatile load or not.
SynchronizationScope getSynchScope() const
Returns whether this cmpxchg is atomic between threads or only within a single thread.
const Value * getPointerOperand() const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
void setCannotDuplicate()
FPTruncInst * cloneImpl() const
Clone an identical FPTruncInst.
unsigned getNumArgOperands() const
Return the number of invoke arguments.
InsertValueInst * cloneImpl() const
Value * getPointerOperand()
unsigned getNumSuccessors() const
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
const Value * getPointerOperand() const
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Type * getResultElementType() const
static unsigned getPointerOperandIndex()
A mixin to add operand bundle functionality to llvm instruction classes.
const_op_iterator arg_end() const
Return the iterator pointing to the end of the argument list.
const_op_iterator idx_begin() const
SmallVector< int, 16 > getShuffleMask() const
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
0 0 0 0 Always false (always folded)
bool canReturnTwice() const
Return true if the call can return twice.
static bool classof(const Value *V)
AddrSpaceCastInst * cloneImpl() const
Clone an identical AddrSpaceCastInst.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, BasicBlock *InsertAtEnd)
an instruction to allocate memory on the stack
static bool classof(const Instruction *I)
This instruction inserts a struct field of array element value into an aggregate value.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
bool operator==(const Self &RHS) const
void setCatchPad(CatchPadInst *CatchPad)
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
static bool classof(const Instruction *I)
const Value * getPointerOperand() const
LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, unsigned Align, Instruction *InsertBefore=nullptr)
Predicate getSwappedPredicate(Predicate Opcode)
Assume the condition register is set by MI(a,b), return the predicate if we modify the instructions s...