60 Size *=
C->getZExtValue();
70 return cast<CallBase>(getInstruction())->
op_end() - 1;
81 return "both values to select must have same type";
84 return "select values cannot have token type";
89 return "vector select condition element type must be i1";
92 return "selected values for vector select must be vectors";
94 return "vector select requires selected vectors to have " 95 "the same vector length as select condition";
97 return "select condition must be i1 or <n x i1>";
106 PHINode::PHINode(
const PHINode &PN)
118 Value *Removed = getIncomingValue(Idx);
126 std::copy(block_begin() + Idx + 1, block_end(), block_begin() + Idx);
129 Op<-1>().
set(
nullptr);
145 void PHINode::growOperands() {
147 unsigned NumOps = e + e / 2;
148 if (NumOps < 2) NumOps = 2;
150 ReservedSpace = NumOps;
158 Value *ConstantValue = getIncomingValue(0);
159 for (
unsigned i = 1,
e = getNumIncomingValues(); i !=
e; ++i)
160 if (getIncomingValue(i) != ConstantValue && getIncomingValue(i) !=
this) {
161 if (ConstantValue !=
this)
164 ConstantValue = getIncomingValue(i);
166 if (ConstantValue ==
this)
168 return ConstantValue;
177 Value *ConstantValue =
nullptr;
178 for (
unsigned i = 0,
e = getNumIncomingValues(); i !=
e; ++i) {
179 Value *Incoming = getIncomingValue(i);
180 if (Incoming !=
this && !isa<UndefValue>(Incoming)) {
181 if (ConstantValue && ConstantValue != Incoming)
183 ConstantValue = Incoming;
193 LandingPadInst::LandingPadInst(
Type *RetTy,
unsigned NumReservedValues,
195 :
Instruction(RetTy, Instruction::LandingPad,
nullptr, 0, InsertBefore) {
196 init(NumReservedValues, NameStr);
199 LandingPadInst::LandingPadInst(
Type *RetTy,
unsigned NumReservedValues,
201 :
Instruction(RetTy, Instruction::LandingPad,
nullptr, 0, InsertAtEnd) {
202 init(NumReservedValues, NameStr);
212 for (
unsigned I = 0,
E = ReservedSpace;
I !=
E; ++
I)
219 const Twine &NameStr,
221 return new LandingPadInst(RetTy, NumReservedClauses, NameStr, InsertBefore);
225 const Twine &NameStr,
227 return new LandingPadInst(RetTy, NumReservedClauses, NameStr, InsertAtEnd);
230 void LandingPadInst::init(
unsigned NumReservedValues,
const Twine &NameStr) {
231 ReservedSpace = NumReservedValues;
240 void LandingPadInst::growOperands(
unsigned Size) {
242 if (ReservedSpace >= e + Size)
return;
243 ReservedSpace = (
std::max(e, 1U) + Size / 2) * 2;
250 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
263 return cast<CallBrInst>(
this)->getNumIndirectDests() + 1;
267 const Value *V = getCalledValue();
268 if (isa<Function>(V) || isa<Constant>(V))
270 if (
const CallInst *CI = dyn_cast<CallInst>(
this))
271 if (CI->isInlineAsm())
279 if (
auto *CI = dyn_cast<CallInst>(
this))
280 return CI->isMustTailCall();
286 if (
auto *CI = dyn_cast<CallInst>(
this))
287 return CI->isTailCall();
293 return F->getIntrinsicID();
298 if (hasRetAttr(Attribute::NonNull))
303 getType()->getPointerAddressSpace()))
312 if (
Attrs.hasAttrSomewhere(Attribute::Returned, &Index) &&
Index)
315 if (
F->getAttributes().hasAttrSomewhere(Attribute::Returned, &Index) &&
334 assert(ArgNo < getNumArgOperands() &&
"Param index out of bounds!");
336 if (
Attrs.hasParamAttribute(ArgNo, Kind))
339 return F->getAttributes().hasParamAttribute(ArgNo, Kind);
349 bool CallBase::hasFnAttrOnCalledFunction(
StringRef Kind)
const {
357 const unsigned BeginIndex) {
359 for (
auto &
B : Bundles)
360 It =
std::copy(
B.input_begin(),
B.input_end(), It);
363 auto BI = Bundles.begin();
364 unsigned CurrentIndex = BeginIndex;
366 for (
auto &BOI : bundle_op_infos()) {
367 assert(BI != Bundles.end() &&
"Incorrect allocation?");
369 BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->getTag());
370 BOI.Begin = CurrentIndex;
371 BOI.End = CurrentIndex + BI->input_size();
372 CurrentIndex = BOI.End;
376 assert(BI == Bundles.end() &&
"Incorrect allocation?");
389 "NumOperands not set up?");
390 setCalledOperand(Func);
395 "Calling a function with bad signature!");
397 for (
unsigned i = 0; i != Args.
size(); ++i)
400 "Calling a function with a bad signature!");
405 auto It = populateBundleOperandInfos(Bundles, Args.
size());
415 setCalledOperand(Func);
426 init(Ty, Func, Name);
433 init(Ty, Func, Name);
436 CallInst::CallInst(
const CallInst &CI)
445 bundle_op_info_begin());
467 auto *ProfileData =
getMetadata(LLVMContext::MD_prof);
468 if (ProfileData ==
nullptr)
472 if (!ProfDataName || (!ProfDataName->getString().equals(
"branch_weights") &&
473 !ProfDataName->getString().equals(
"VP")))
477 LLVM_DEBUG(
dbgs() <<
"Attempting to update profile weights will result in " 478 "div by 0. Ignoring. Likely the function " 480 <<
" has 0 entry count, and contains call instructions " 481 "with non-zero prof info.");
487 Vals.
push_back(ProfileData->getOperand(0));
488 APInt APS(128, S), APT(128, T);
489 if (ProfDataName->getString().equals(
"branch_weights") &&
490 ProfileData->getNumOperands() > 0) {
492 APInt Val(128, mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1))
498 }
else if (ProfDataName->getString().equals(
"VP"))
499 for (
unsigned i = 1; i < ProfileData->getNumOperands(); i += 2) {
501 Vals.
push_back(ProfileData->getOperand(i));
504 mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(i + 1))
510 Val.udiv(APT).getLimitedValue())));
517 assert(val &&
"IsConstantOne does not work with nullptr val");
519 return CVal && CVal->
isOne();
528 assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) &&
529 "createMalloc needs either InsertBefore or InsertAtEnd");
537 else if (ArraySize->
getType() != IntPtrTy) {
548 AllocSize = ArraySize;
549 }
else if (
Constant *CO = dyn_cast<Constant>(ArraySize)) {
558 "mallocsize", InsertBefore);
561 "mallocsize", InsertAtEnd);
565 assert(AllocSize->
getType() == IntPtrTy &&
"malloc arg is wrong size");
568 Module *M = BB->getParent()->getParent();
581 if (Result->
getType() != AllocPtrType)
583 Result =
new BitCastInst(MCall, AllocPtrType, Name, InsertBefore);
587 if (Result->
getType() != AllocPtrType) {
590 Result =
new BitCastInst(MCall, AllocPtrType, Name);
594 if (
Function *
F = dyn_cast<Function>(MallocFunc.getCallee())) {
596 if (!
F->returnDoesNotAlias())
597 F->setReturnDoesNotAlias();
615 return createMalloc(InsertBefore,
nullptr, IntPtrTy, AllocTy, AllocSize,
616 ArraySize,
None, MallocF, Name);
624 return createMalloc(InsertBefore,
nullptr, IntPtrTy, AllocTy, AllocSize,
625 ArraySize, OpB, MallocF, Name);
640 return createMalloc(
nullptr, InsertAtEnd, IntPtrTy, AllocTy, AllocSize,
641 ArraySize,
None, MallocF, Name);
648 return createMalloc(
nullptr, InsertAtEnd, IntPtrTy, AllocTy, AllocSize,
649 ArraySize, OpB, MallocF, Name);
656 assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) &&
657 "createFree needs either InsertBefore or InsertAtEnd");
659 "Can not free something of nonpointer type!");
662 Module *M = BB->getParent()->getParent();
671 if (Source->
getType() != IntPtrTy)
672 PtrCast =
new BitCastInst(Source, IntPtrTy,
"", InsertBefore);
675 if (Source->
getType() != IntPtrTy)
676 PtrCast =
new BitCastInst(Source, IntPtrTy,
"", InsertAtEnd);
680 if (
Function *
F = dyn_cast<Function>(FreeFunc.getCallee()))
693 return createFree(Source, Bundles, InsertBefore,
nullptr);
701 assert(FreeCall &&
"CreateFree did not create a CallInst");
708 assert(FreeCall &&
"CreateFree did not create a CallInst");
719 const Twine &NameStr) {
723 ComputeNumOperands(Args.
size(), CountBundleInputs(Bundles)) &&
724 "NumOperands not set up?");
725 setNormalDest(IfNormal);
726 setUnwindDest(IfException);
727 setCalledOperand(Fn);
732 "Invoking a function with bad signature");
734 for (
unsigned i = 0,
e = Args.
size(); i !=
e; i++)
737 "Invoking a function with a bad signature!");
742 auto It = populateBundleOperandInfos(Bundles, Args.
size());
756 bundle_op_info_begin());
776 return cast<LandingPadInst>(getUnwindDest()->getFirstNonPHI());
787 const Twine &NameStr) {
791 ComputeNumOperands(Args.
size(), IndirectDests.
size(),
792 CountBundleInputs(Bundles)) &&
793 "NumOperands not set up?");
794 NumIndirectDests = IndirectDests.
size();
795 setDefaultDest(Fallthrough);
796 for (
unsigned i = 0; i != NumIndirectDests; ++i)
797 setIndirectDest(i, IndirectDests[i]);
798 setCalledOperand(Fn);
803 "Calling a function with bad signature");
805 for (
unsigned i = 0,
e = Args.
size(); i !=
e; i++)
808 "Calling a function with a bad signature!");
813 auto It = populateBundleOperandInfos(Bundles, Args.
size());
820 void CallBrInst::updateArgBlockAddresses(
unsigned i,
BasicBlock *
B) {
821 assert(getNumIndirectDests() > i &&
"IndirectDest # out of range for callbr");
825 for (
unsigned ArgNo = 0,
e = getNumArgOperands(); ArgNo !=
e; ++ArgNo)
826 if (dyn_cast<BlockAddress>(getArgOperand(ArgNo)) == Old)
827 setArgOperand(ArgNo, New);
838 bundle_op_info_begin());
840 NumIndirectDests = CBI.NumIndirectDests;
856 NewCBI->NumIndirectDests = CBI->NumIndirectDests;
869 Op<0>() = RI.
Op<0>();
900 Op<0>() = RI.
Op<0>();
925 Op<0>() = CRI.
Op<0>();
927 Op<1>() = CRI.
Op<1>();
930 void CleanupReturnInst::init(
Value *CleanupPad,
BasicBlock *UnwindBB) {
934 Op<0>() = CleanupPad;
939 CleanupReturnInst::CleanupReturnInst(
Value *CleanupPad,
BasicBlock *UnwindBB,
942 Instruction::CleanupRet,
944 Values, InsertBefore) {
945 init(CleanupPad, UnwindBB);
948 CleanupReturnInst::CleanupReturnInst(
Value *CleanupPad,
BasicBlock *UnwindBB,
951 Instruction::CleanupRet,
953 Values, InsertAtEnd) {
954 init(CleanupPad, UnwindBB);
968 Op<0>() = CRI.
Op<0>();
969 Op<1>() = CRI.
Op<1>();
992 CatchSwitchInst::CatchSwitchInst(
Value *ParentPad,
BasicBlock *UnwindDest,
993 unsigned NumReservedValues,
994 const Twine &NameStr,
1000 init(ParentPad, UnwindDest, NumReservedValues + 1);
1004 CatchSwitchInst::CatchSwitchInst(
Value *ParentPad,
BasicBlock *UnwindDest,
1005 unsigned NumReservedValues,
1010 ++NumReservedValues;
1011 init(ParentPad, UnwindDest, NumReservedValues + 1);
1022 for (
unsigned I = 1,
E = ReservedSpace;
I !=
E; ++
I)
1027 unsigned NumReservedValues) {
1028 assert(ParentPad && NumReservedValues);
1030 ReservedSpace = NumReservedValues;
1034 Op<0>() = ParentPad;
1037 setUnwindDest(UnwindDest);
1043 void CatchSwitchInst::growOperands(
unsigned Size) {
1045 assert(NumOperands >= 1);
1046 if (ReservedSpace >= NumOperands + Size)
1048 ReservedSpace = (NumOperands + Size / 2) * 2;
1055 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
1063 for (
Use *CurDst = HI.
getCurrent(); CurDst != EndDst; ++CurDst)
1064 *CurDst = *(CurDst + 1);
1075 const Twine &NameStr) {
1078 setParentPad(ParentPad);
1097 init(ParentPad, Args, NameStr);
1106 init(ParentPad, Args, NameStr);
1125 void BranchInst::AssertOK() {
1126 if (isConditional())
1128 "May only branch on boolean predicates!");
1135 assert(IfTrue &&
"Branch destination may not be null!");
1155 assert(IfTrue &&
"Branch destination may not be null!");
1175 Op<-1>() = BI.
Op<-1>();
1178 Op<-3>() = BI.
Op<-3>();
1179 Op<-2>() = BI.
Op<-2>();
1185 assert(isConditional() &&
1186 "Cannot swap successors of an unconditional branch");
1202 assert(!isa<BasicBlock>(Amt) &&
1203 "Passed basic block into allocation size parameter! Use other ctor");
1205 "Allocation array size is not an integer!");
1212 :
AllocaInst(Ty, AddrSpace, nullptr, Name, InsertBefore) {}
1216 :
AllocaInst(Ty, AddrSpace, nullptr, Name, InsertAtEnd) {}
1220 :
AllocaInst(Ty, AddrSpace, ArraySize,
None, Name, InsertBefore) {
1225 :
AllocaInst(Ty, AddrSpace, ArraySize,
None, Name, InsertAtEnd) {}
1251 "Alignment is greater than MaximumAlignment!");
1256 "Alignment representation error!");
1263 return !CI->isOne();
1283 void LoadInst::AssertOK() {
1285 "Ptr must have pointer type.");
1287 "Alignment required for atomic load");
1300 :
LoadInst(Ty, Ptr, Name, isVolatile,
None, InsertBef) {}
1304 :
LoadInst(Ty, Ptr, Name, isVolatile,
None, InsertAE) {}
1309 SyncScope::
System, InsertBef) {}
1314 SyncScope::
System, InsertAE) {}
1320 assert(Ty == cast<PointerType>(Ptr->
getType())->getElementType());
1332 assert(Ty == cast<PointerType>(Ptr->
getType())->getElementType());
1342 "Alignment is greater than MaximumAlignment!");
1345 assert(
getAlign() == Align &&
"Alignment representation error!");
1352 void StoreInst::AssertOK() {
1355 "Ptr must have pointer type!");
1358 &&
"Ptr must be a pointer to Val type!");
1360 "Alignment required for atomic store");
1380 SyncScope::
System, InsertBefore) {}
1385 SyncScope::
System, InsertAtEnd) {}
1417 "Alignment is greater than MaximumAlignment!");
1419 (
encode(Alignment) << 1));
1420 assert(
getAlign() == Alignment &&
"Alignment representation error!");
1434 setSuccessOrdering(SuccessOrdering);
1435 setFailureOrdering(FailureOrdering);
1439 "All operands must be non-null!");
1441 "Ptr must have pointer type!");
1444 &&
"Ptr must be a pointer to Cmp type!");
1447 &&
"Ptr must be a pointer to NewVal type!");
1449 "AtomicCmpXchg instructions must be atomic!");
1451 "AtomicCmpXchg instructions must be atomic!");
1453 "AtomicCmpXchg failure argument shall be no stronger than the success " 1457 "AtomicCmpXchg failure ordering cannot include release semantics");
1469 Init(Ptr, Cmp, NewVal, SuccessOrdering, FailureOrdering, SSID);
1481 Init(Ptr, Cmp, NewVal, SuccessOrdering, FailureOrdering, SSID);
1494 setOrdering(Ordering);
1498 "All operands must be non-null!");
1500 "Ptr must have pointer type!");
1503 &&
"Ptr must be a pointer to Val type!");
1505 "AtomicRMW instructions must be atomic!");
1516 Init(Operation, Ptr, Val, Ordering, SSID);
1527 Init(Operation, Ptr, Val, Ordering, SSID);
1559 return "<invalid operation>";
1590 const Twine &Name) {
1592 "NumOperands not initialized?");
1603 SourceElementType(GEPI.SourceElementType),
1604 ResultElementType(GEPI.ResultElementType) {
1618 template <
typename IndexTy>
1621 if (IdxList.
empty())
1629 unsigned CurIdx = 1;
1630 for (; CurIdx != IdxList.
size(); ++CurIdx) {
1633 IndexTy
Index = IdxList[CurIdx];
1637 return CurIdx == IdxList.
size() ? Agg :
nullptr;
1659 if (!CI->isZero())
return false;
1679 cast<GEPOperator>(
this)->setIsInBounds(B);
1683 return cast<GEPOperator>(
this)->isInBounds();
1689 return cast<GEPOperator>(
this)->accumulateConstantOffset(DL, Offset);
1703 assert(isValidOperands(Val, Index) &&
1704 "Invalid extractelement instruction operands!");
1710 ExtractElementInst::ExtractElementInst(
Value *Val,
Value *Index,
1717 assert(isValidOperands(Val, Index) &&
1718 "Invalid extractelement instruction operands!");
1735 InsertElementInst::InsertElementInst(
Value *Vec,
Value *Elt,
Value *Index,
1741 assert(isValidOperands(Vec, Elt, Index) &&
1742 "Invalid insertelement instruction operands!");
1749 InsertElementInst::InsertElementInst(
Value *Vec,
Value *Elt,
Value *Index,
1755 assert(isValidOperands(Vec, Elt, Index) &&
1756 "Invalid insertelement instruction operands!");
1765 const Value *Index) {
1769 if (Elt->
getType() != cast<VectorType>(Vec->
getType())->getElementType())
1791 "Invalid shuffle vector instruction operands!");
1808 "Invalid shuffle vector instruction operands!");
1821 for (
int i = 0; i != NumMaskElts; ++i) {
1823 if (MaskElt == -1) {
1827 assert(MaskElt >= 0 && MaskElt < 2 * NumOpElts &&
"Out-of-range mask");
1828 MaskElt = (MaskElt < NumOpElts) ? MaskElt + NumOpElts : MaskElt - NumOpElts;
1832 Op<0>().
swap(Op<1>());
1843 if (!MaskTy || !MaskTy->getElementType()->isIntegerTy(32))
1847 if (isa<UndefValue>(Mask) || isa<ConstantAggregateZero>(
Mask))
1850 if (
const auto *MV = dyn_cast<ConstantVector>(Mask)) {
1851 unsigned V1Size = cast<VectorType>(V1->
getType())->getNumElements();
1852 for (
Value *
Op : MV->operands()) {
1853 if (
auto *CI = dyn_cast<ConstantInt>(
Op)) {
1854 if (CI->uge(V1Size*2))
1856 }
else if (!isa<UndefValue>(
Op)) {
1863 if (
const auto *CDS = dyn_cast<ConstantDataSequential>(Mask)) {
1864 unsigned V1Size = cast<VectorType>(V1->
getType())->getNumElements();
1865 for (
unsigned i = 0,
e = MaskTy->getNumElements(); i !=
e; ++i)
1866 if (CDS->getElementAsInteger(i) >= V1Size*2)
1875 if (
const auto *CE = dyn_cast<ConstantExpr>(Mask))
1876 if (CE->getOpcode() == Instruction::UserOp1)
1883 assert(i < Mask->
getType()->getVectorNumElements() &&
"Index out of range");
1884 if (
auto *CDS = dyn_cast<ConstantDataSequential>(Mask))
1885 return CDS->getElementAsInteger(i);
1887 if (isa<UndefValue>(C))
1889 return cast<ConstantInt>(
C)->getZExtValue();
1896 if (
auto *CDS = dyn_cast<ConstantDataSequential>(Mask)) {
1897 for (
unsigned i = 0; i != NumElts; ++i)
1898 Result.
push_back(CDS->getElementAsInteger(i));
1901 for (
unsigned i = 0; i != NumElts; ++i) {
1903 Result.
push_back(isa<UndefValue>(C) ? -1 :
1904 cast<ConstantInt>(C)->getZExtValue());
1909 assert(!Mask.
empty() &&
"Shuffle mask must contain elements");
1910 bool UsesLHS =
false;
1911 bool UsesRHS =
false;
1912 for (
int i = 0, NumMaskElts = Mask.
size(); i < NumMaskElts; ++i) {
1915 assert(Mask[i] >= 0 && Mask[i] < (NumOpElts * 2) &&
1916 "Out-of-bounds shuffle mask element");
1917 UsesLHS |= (Mask[i] < NumOpElts);
1918 UsesRHS |= (Mask[i] >= NumOpElts);
1919 if (UsesLHS && UsesRHS)
1922 assert((UsesLHS ^ UsesRHS) &&
"Should have selected from exactly 1 source");
1935 for (
int i = 0, NumMaskElts = Mask.
size(); i < NumMaskElts; ++i) {
1938 if (Mask[i] != i && Mask[i] != (NumOpElts + i))
1953 for (
int i = 0, NumElts = Mask.
size(); i < NumElts; ++i) {
1956 if (Mask[i] != (NumElts - 1 - i) && Mask[i] != (NumElts + NumElts - 1 - i))
1965 for (
int i = 0, NumElts = Mask.
size(); i < NumElts; ++i) {
1968 if (Mask[i] != 0 && Mask[i] != NumElts)
1978 for (
int i = 0, NumElts = Mask.
size(); i < NumElts; ++i) {
1981 if (Mask[i] != i && Mask[i] != (NumElts + i))
1995 int NumElts = Mask.
size();
2000 if (Mask[0] != 0 && Mask[0] != 1)
2005 if ((Mask[1] - Mask[0]) != NumElts)
2010 for (
int i = 2; i < NumElts; ++i) {
2011 int MaskEltVal = Mask[i];
2012 if (MaskEltVal == -1)
2014 int MaskEltPrevVal = Mask[i - 2];
2015 if (MaskEltVal - MaskEltPrevVal != 2)
2022 int NumSrcElts,
int &Index) {
2028 if (NumSrcElts <= (
int)Mask.
size())
2033 for (
int i = 0,
e = Mask.
size(); i !=
e; ++i) {
2037 int Offset = (M % NumSrcElts) - i;
2038 if (0 <= SubIndex && SubIndex != Offset)
2043 if (0 <= SubIndex && SubIndex + (
int)Mask.
size() <= NumSrcElts) {
2053 if (NumMaskElts <= NumOpElts)
2062 for (
int i = NumOpElts; i < NumMaskElts; ++i)
2072 if (NumMaskElts >= NumOpElts)
2080 if (isa<UndefValue>(Op<0>()) || isa<UndefValue>(Op<1>()))
2085 if (NumMaskElts != NumOpElts * 2)
2100 const Twine &Name) {
2107 assert(!Idxs.
empty() &&
"InsertValueInst must have at least one index");
2110 Val->
getType() &&
"Inserted value must match indexed type!");
2114 Indices.append(Idxs.
begin(), Idxs.
end());
2121 Indices(IVI.Indices) {
2136 assert(!Idxs.
empty() &&
"ExtractValueInst must have at least one index");
2138 Indices.append(Idxs.
begin(), Idxs.
end());
2144 Indices(EVI.Indices) {
2156 for (
unsigned Index : Idxs) {
2163 if (
ArrayType *AT = dyn_cast<ArrayType>(Agg)) {
2164 if (Index >= AT->getNumElements())
2166 }
else if (
StructType *
ST = dyn_cast<StructType>(Agg)) {
2167 if (Index >=
ST->getNumElements())
2174 Agg = cast<CompositeType>(Agg)->getTypeAtIndex(Index);
2176 return const_cast<Type*
>(Agg);
2215 void UnaryOperator::AssertOK() {
2222 "Unary operation should return same type as operand!");
2224 "Tried to create a floating-point operation on a " 2225 "non-floating-point type!");
2262 void BinaryOperator::AssertOK() {
2264 (void)LHS; (void)RHS;
2266 "Binary operator operand types must match!");
2272 "Arithmetic operation should return same type as operands!");
2274 "Tried to create an integer operation on a non-integer type!");
2276 case FAdd:
case FSub:
2279 "Arithmetic operation should return same type as operands!");
2281 "Tried to create a floating-point operation on a " 2282 "non-floating-point type!");
2287 "Arithmetic operation should return same type as operands!");
2289 "Incorrect operand type (not integer) for S/UDIV");
2293 "Arithmetic operation should return same type as operands!");
2295 "Incorrect operand type (not floating point) for FDIV");
2300 "Arithmetic operation should return same type as operands!");
2302 "Incorrect operand type (not integer) for S/UREM");
2306 "Arithmetic operation should return same type as operands!");
2308 "Incorrect operand type (not floating point) for FREM");
2314 "Shift operation should return same type as operands!");
2316 "Tried to create a shift operation on a non-integral type!");
2321 "Logical operation should return same type as operands!");
2323 "Tried to create a logical operation on a non-integral type!");
2334 "Cannot create binary operator with two operands of differing type!");
2365 return BinaryOperator::CreateNSWSub(zero, Op, Name, InsertBefore);
2371 return BinaryOperator::CreateNSWSub(zero, Op, Name, InsertAtEnd);
2377 return BinaryOperator::CreateNUWSub(zero, Op, Name, InsertBefore);
2383 return BinaryOperator::CreateNUWSub(zero, Op, Name, InsertAtEnd);
2421 Op<0>().
swap(Op<1>());
2431 cast<Instruction>(
this)->
getMetadata(LLVMContext::MD_fpmath);
2445 default:
return false;
2446 case Instruction::ZExt:
2447 case Instruction::SExt:
2448 case Instruction::Trunc:
2450 case Instruction::BitCast:
2458 if (
getOpcode() != Instruction::BitCast)
2487 case Instruction::Trunc:
2488 case Instruction::ZExt:
2489 case Instruction::SExt:
2490 case Instruction::FPTrunc:
2491 case Instruction::FPExt:
2492 case Instruction::UIToFP:
2493 case Instruction::SIToFP:
2494 case Instruction::FPToUI:
2495 case Instruction::FPToSI:
2496 case Instruction::AddrSpaceCast:
2499 case Instruction::BitCast:
2501 case Instruction::PtrToInt:
2504 case Instruction::IntToPtr:
2525 Type *DstIntPtrTy) {
2556 const unsigned numCastOps =
2557 Instruction::CastOpsEnd - Instruction::CastOpsBegin;
2558 static const uint8_t CastResults[numCastOps][numCastOps] = {
2564 { 1, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0},
2565 { 8, 1, 9,99,99, 2,17,99,99,99, 2, 3, 0},
2566 { 8, 0, 1,99,99, 0, 2,99,99,99, 0, 3, 0},
2567 { 0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0},
2568 { 0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0},
2569 { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0},
2570 { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0},
2571 { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0},
2572 { 99,99,99, 2, 2,99,99, 8, 2,99,99, 4, 0},
2573 { 1, 0, 0,99,99, 0, 0,99,99,99, 7, 3, 0},
2574 { 99,99,99,99,99,99,99,99,99,11,99,15, 0},
2575 { 5, 5, 5, 6, 6, 5, 5, 6, 6,16, 5, 1,14},
2576 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13,12},
2583 bool IsFirstBitcast = (firstOp == Instruction::BitCast);
2584 bool IsSecondBitcast = (secondOp == Instruction::BitCast);
2585 bool AreBothBitcasts = IsFirstBitcast && IsSecondBitcast;
2588 if ((IsFirstBitcast && isa<VectorType>(SrcTy) != isa<VectorType>(MidTy)) ||
2589 (IsSecondBitcast && isa<VectorType>(MidTy) != isa<VectorType>(DstTy)))
2590 if (!AreBothBitcasts)
2593 int ElimCase = CastResults[firstOp-Instruction::CastOpsBegin]
2594 [secondOp-Instruction::CastOpsBegin];
2641 return Instruction::BitCast;
2644 if (!SrcIntPtrTy || DstIntPtrTy != SrcIntPtrTy)
2647 if (MidSize >= PtrSize)
2648 return Instruction::BitCast;
2657 if (SrcSize == DstSize)
2658 return Instruction::BitCast;
2659 else if (SrcSize < DstSize)
2665 return Instruction::ZExt;
2673 if (SrcSize <= PtrSize && SrcSize == DstSize)
2674 return Instruction::BitCast;
2681 return Instruction::AddrSpaceCast;
2682 return Instruction::BitCast;
2693 "Illegal addrspacecast, bitcast sequence!");
2701 return Instruction::AddrSpaceCast;
2712 "Illegal inttoptr, bitcast sequence!");
2724 "Illegal bitcast, ptrtoint sequence!");
2729 return Instruction::UIToFP;
2741 assert(castIsValid(op, S, Ty) &&
"Invalid cast!");
2744 case Trunc:
return new TruncInst (S, Ty, Name, InsertBefore);
2745 case ZExt:
return new ZExtInst (S, Ty, Name, InsertBefore);
2746 case SExt:
return new SExtInst (S, Ty, Name, InsertBefore);
2747 case FPTrunc:
return new FPTruncInst (S, Ty, Name, InsertBefore);
2748 case FPExt:
return new FPExtInst (S, Ty, Name, InsertBefore);
2749 case UIToFP:
return new UIToFPInst (S, Ty, Name, InsertBefore);
2750 case SIToFP:
return new SIToFPInst (S, Ty, Name, InsertBefore);
2751 case FPToUI:
return new FPToUIInst (S, Ty, Name, InsertBefore);
2752 case FPToSI:
return new FPToSIInst (S, Ty, Name, InsertBefore);
2753 case PtrToInt:
return new PtrToIntInst (S, Ty, Name, InsertBefore);
2754 case IntToPtr:
return new IntToPtrInst (S, Ty, Name, InsertBefore);
2755 case BitCast:
return new BitCastInst (S, Ty, Name, InsertBefore);
2763 assert(castIsValid(op, S, Ty) &&
"Invalid cast!");
2766 case Trunc:
return new TruncInst (S, Ty, Name, InsertAtEnd);
2767 case ZExt:
return new ZExtInst (S, Ty, Name, InsertAtEnd);
2768 case SExt:
return new SExtInst (S, Ty, Name, InsertAtEnd);
2769 case FPTrunc:
return new FPTruncInst (S, Ty, Name, InsertAtEnd);
2770 case FPExt:
return new FPExtInst (S, Ty, Name, InsertAtEnd);
2771 case UIToFP:
return new UIToFPInst (S, Ty, Name, InsertAtEnd);
2772 case SIToFP:
return new SIToFPInst (S, Ty, Name, InsertAtEnd);
2773 case FPToUI:
return new FPToUIInst (S, Ty, Name, InsertAtEnd);
2774 case FPToSI:
return new FPToSIInst (S, Ty, Name, InsertAtEnd);
2775 case PtrToInt:
return new PtrToIntInst (S, Ty, Name, InsertAtEnd);
2776 case IntToPtr:
return new IntToPtrInst (S, Ty, Name, InsertAtEnd);
2777 case BitCast:
return new BitCastInst (S, Ty, Name, InsertAtEnd);
2787 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2788 return Create(Instruction::ZExt, S, Ty, Name, InsertBefore);
2795 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2796 return Create(Instruction::ZExt, S, Ty, Name, InsertAtEnd);
2803 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2804 return Create(Instruction::SExt, S, Ty, Name, InsertBefore);
2811 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2812 return Create(Instruction::SExt, S, Ty, Name, InsertAtEnd);
2819 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2820 return Create(Instruction::Trunc, S, Ty, Name, InsertBefore);
2827 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2828 return Create(Instruction::Trunc, S, Ty, Name, InsertAtEnd);
2843 return Create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd);
2845 return CreatePointerBitCastOrAddrSpaceCast(S, Ty, Name, InsertAtEnd);
2861 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
2863 return CreatePointerBitCastOrAddrSpaceCast(S, Ty, Name, InsertBefore);
2874 return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertAtEnd);
2876 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2887 return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertBefore);
2889 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2896 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
2898 return Create(Instruction::IntToPtr, S, Ty, Name, InsertBefore);
2900 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2904 bool isSigned,
const Twine &Name,
2907 "Invalid integer cast");
2911 (SrcBits == DstBits ? Instruction::BitCast :
2912 (SrcBits > DstBits ? Instruction::Trunc :
2913 (isSigned ? Instruction::SExt : Instruction::ZExt)));
2914 return Create(opcode, C, Ty, Name, InsertBefore);
2918 bool isSigned,
const Twine &Name,
2925 (SrcBits == DstBits ? Instruction::BitCast :
2926 (SrcBits > DstBits ? Instruction::Trunc :
2927 (isSigned ? Instruction::SExt : Instruction::ZExt)));
2928 return Create(opcode, C, Ty, Name, InsertAtEnd);
2939 (SrcBits == DstBits ? Instruction::BitCast :
2940 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
2941 return Create(opcode, C, Ty, Name, InsertBefore);
2952 (SrcBits == DstBits ? Instruction::BitCast :
2953 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
2954 return Create(opcode, C, Ty, Name, InsertAtEnd);
2963 if (SrcTy == DestTy)
2966 if (
VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy))
2967 if (
VectorType *DestVecTy = dyn_cast<VectorType>(DestTy))
2968 if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) {
2970 SrcTy = SrcVecTy->getElementType();
2971 DestTy = DestVecTy->getElementType();
2985 return DestBits == SrcBits;
2995 return DestBits == SrcBits;
3000 return DestBits == SrcBits;
3008 return DestBits == SrcBits;
3018 if (SrcTy == DestTy)
3021 if (
VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy)) {
3022 if (
VectorType *DestVecTy = dyn_cast<VectorType>(DestTy)) {
3023 if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {
3025 SrcTy = SrcVecTy->getElementType();
3026 DestTy = DestVecTy->getElementType();
3031 if (
PointerType *DestPtrTy = dyn_cast<PointerType>(DestTy)) {
3032 if (
PointerType *SrcPtrTy = dyn_cast<PointerType>(SrcTy)) {
3033 return SrcPtrTy->getAddressSpace() == DestPtrTy->getAddressSpace();
3045 if (SrcBits != DestBits)
3057 if (
auto *PtrTy = dyn_cast<PointerType>(SrcTy))
3058 if (
auto *IntTy = dyn_cast<IntegerType>(DestTy))
3061 if (
auto *PtrTy = dyn_cast<PointerType>(DestTy))
3062 if (
auto *IntTy = dyn_cast<IntegerType>(SrcTy))
3066 return isBitCastable(SrcTy, DestTy);
3078 const Value *Src,
bool SrcIsSigned,
Type *DestTy,
bool DestIsSigned) {
3082 "Only first class types are castable!");
3084 if (SrcTy == DestTy)
3088 if (
VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy))
3089 if (
VectorType *DestVecTy = dyn_cast<VectorType>(DestTy))
3090 if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) {
3093 SrcTy = SrcVecTy->getElementType();
3094 DestTy = DestVecTy->getElementType();
3104 if (DestBits < SrcBits)
3106 else if (DestBits > SrcBits) {
3120 assert(DestBits == SrcBits &&
3121 "Casting vector to integer of different width");
3125 "Casting from a value that is not first-class type");
3135 if (DestBits < SrcBits) {
3137 }
else if (DestBits > SrcBits) {
3143 assert(DestBits == SrcBits &&
3144 "Casting vector to floating point of different width");
3149 assert(DestBits == SrcBits &&
3150 "Illegal cast to vector (wrong type or size)");
3155 return AddrSpaceCast;
3163 assert(DestBits == SrcBits &&
"Casting vector of wrong width to X86_MMX");
3196 cast<VectorType>(SrcTy)->getNumElements() : 0;
3198 cast<VectorType>(DstTy)->getNumElements() : 0;
3202 default:
return false;
3203 case Instruction::Trunc:
3205 SrcLength == DstLength && SrcBitSize > DstBitSize;
3206 case Instruction::ZExt:
3208 SrcLength == DstLength && SrcBitSize < DstBitSize;
3209 case Instruction::SExt:
3211 SrcLength == DstLength && SrcBitSize < DstBitSize;
3212 case Instruction::FPTrunc:
3214 SrcLength == DstLength && SrcBitSize > DstBitSize;
3215 case Instruction::FPExt:
3217 SrcLength == DstLength && SrcBitSize < DstBitSize;
3218 case Instruction::UIToFP:
3219 case Instruction::SIToFP:
3221 SrcLength == DstLength;
3222 case Instruction::FPToUI:
3223 case Instruction::FPToSI:
3225 SrcLength == DstLength;
3226 case Instruction::PtrToInt:
3227 if (isa<VectorType>(SrcTy) != isa<VectorType>(DstTy))
3229 if (
VectorType *VT = dyn_cast<VectorType>(SrcTy))
3230 if (VT->getNumElements() != cast<VectorType>(DstTy)->getNumElements())
3233 case Instruction::IntToPtr:
3234 if (isa<VectorType>(SrcTy) != isa<VectorType>(DstTy))
3236 if (
VectorType *VT = dyn_cast<VectorType>(SrcTy))
3237 if (VT->getNumElements() != cast<VectorType>(DstTy)->getNumElements())
3240 case Instruction::BitCast: {
3246 if (!SrcPtrTy != !DstPtrTy)
3261 if (SrcVecTy && DstVecTy)
3262 return (SrcVecTy->
getNumElements() == DstVecTy->getNumElements());
3266 return DstVecTy->getNumElements() == 1;
3270 case Instruction::AddrSpaceCast: {
3282 if (
VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy)) {
3283 if (
VectorType *DstVecTy = dyn_cast<VectorType>(DstTy))
3284 return (SrcVecTy->getNumElements() == DstVecTy->getNumElements());
3296 ) :
CastInst(Ty, Trunc, S, Name, InsertBefore) {
3302 ) :
CastInst(Ty, Trunc, S, Name, InsertAtEnd) {
3308 ) :
CastInst(Ty, ZExt, S, Name, InsertBefore) {
3314 ) :
CastInst(Ty, ZExt, S, Name, InsertAtEnd) {
3319 ) :
CastInst(Ty, SExt, S, Name, InsertBefore) {
3325 ) :
CastInst(Ty, SExt, S, Name, InsertAtEnd) {
3331 ) :
CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
3337 ) :
CastInst(Ty, FPTrunc, S, Name, InsertAtEnd) {
3343 ) :
CastInst(Ty, FPExt, S, Name, InsertBefore) {
3349 ) :
CastInst(Ty, FPExt, S, Name, InsertAtEnd) {
3355 ) :
CastInst(Ty, UIToFP, S, Name, InsertBefore) {
3361 ) :
CastInst(Ty, UIToFP, S, Name, InsertAtEnd) {
3367 ) :
CastInst(Ty, SIToFP, S, Name, InsertBefore) {
3373 ) :
CastInst(Ty, SIToFP, S, Name, InsertAtEnd) {
3379 ) :
CastInst(Ty, FPToUI, S, Name, InsertBefore) {
3385 ) :
CastInst(Ty, FPToUI, S, Name, InsertAtEnd) {
3391 ) :
CastInst(Ty, FPToSI, S, Name, InsertBefore) {
3397 ) :
CastInst(Ty, FPToSI, S, Name, InsertAtEnd) {
3403 ) :
CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
3409 ) :
CastInst(Ty, PtrToInt, S, Name, InsertAtEnd) {
3415 ) :
CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
3421 ) :
CastInst(Ty, IntToPtr, S, Name, InsertAtEnd) {
3427 ) :
CastInst(Ty, BitCast, S, Name, InsertBefore) {
3433 ) :
CastInst(Ty, BitCast, S, Name, InsertAtEnd) {
3439 ) :
CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {
3445 ) :
CastInst(Ty, AddrSpaceCast, S, Name, InsertAtEnd) {
3483 if (Op == Instruction::ICmp) {
3503 if (Op == Instruction::ICmp) {
3512 if (
ICmpInst *IC = dyn_cast<ICmpInst>(
this))
3519 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(
this))
3520 return IC->isCommutative();
3525 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(
this))
3526 return IC->isEquality();
3565 default:
return "unknown";
3684 default:
return pred;
3706 switch (predicate) {
3707 default:
return false;
3714 switch (predicate) {
3715 default:
return false;
3722 switch (predicate) {
3723 default:
return false;
3731 switch (predicate) {
3732 default:
return false;
3741 default:
return false;
3751 default:
return false;
3789 assert(Value && Default && NumReserved);
3790 ReservedSpace = NumReserved;
3802 SwitchInst::SwitchInst(Value *Value,
BasicBlock *Default,
unsigned NumCases,
3805 nullptr, 0, InsertBefore) {
3806 init(Value, Default, 2+NumCases*2);
3813 SwitchInst::SwitchInst(Value *Value,
BasicBlock *Default,
unsigned NumCases,
3816 nullptr, 0, InsertAtEnd) {
3817 init(Value, Default, 2+NumCases*2);
3828 OL[i+1] = InOL[i+1];
3836 unsigned NewCaseIdx = getNumCases();
3838 if (OpNo+2 > ReservedSpace)
3841 assert(OpNo+1 < ReservedSpace &&
"Growing didn't work!");
3851 unsigned idx = I->getCaseIndex();
3859 if (2 + (idx + 1) * 2 != NumOps) {
3860 OL[2 + idx * 2] = OL[NumOps - 2];
3861 OL[2 + idx * 2 + 1] = OL[NumOps - 1];
3865 OL[NumOps-2].
set(
nullptr);
3866 OL[NumOps-2+1].
set(
nullptr);
3869 return CaseIt(
this, idx);
3875 void SwitchInst::growOperands() {
3877 unsigned NumOps = e*3;
3879 ReservedSpace = NumOps;
3886 if (
auto *MDName = dyn_cast<MDString>(ProfileData->getOperand(0)))
3887 if (MDName->getString() ==
"branch_weights")
3893 assert(Changed &&
"called only if metadata has changed");
3899 "num of prof branch_weights must accord with num of successors");
3904 if (AllZeroes || Weights.getValue().size() < 2)
3911 MDNode *ProfileData = getProfBranchWeightsMD(SI);
3917 "not correspond to number of succesors");
3926 this->Weights = std::move(Weights);
3933 "num of prof branch_weights must accord with num of successors");
3938 Weights.getValue()[I->getCaseIndex() + 1] = Weights.getValue().back();
3939 Weights.getValue().pop_back();
3949 if (!Weights && W && *W) {
3953 }
else if (Weights) {
3955 Weights.getValue().push_back(W ? *W : 0);
3959 "num of prof branch_weights must accord with num of successors");
3975 return Weights.getValue()[idx];
3987 auto &OldW = Weights.getValue()[idx];
3998 if (
MDNode *ProfileData = getProfBranchWeightsMD(SI))
4000 return mdconst::extract<ConstantInt>(ProfileData->getOperand(idx + 1))
4011 void IndirectBrInst::init(Value *
Address,
unsigned NumDests) {
4013 "Address of indirectbr must be a pointer");
4014 ReservedSpace = 1+NumDests;
4025 void IndirectBrInst::growOperands() {
4027 unsigned NumOps = e*2;
4029 ReservedSpace = NumOps;
4033 IndirectBrInst::IndirectBrInst(Value *Address,
unsigned NumCases,
4036 Instruction::IndirectBr,
nullptr, 0, InsertBefore) {
4037 init(Address, NumCases);
4040 IndirectBrInst::IndirectBrInst(Value *Address,
unsigned NumCases,
4043 Instruction::IndirectBr,
nullptr, 0, InsertAtEnd) {
4044 init(Address, NumCases);
4062 if (OpNo+1 > ReservedSpace)
4065 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
4079 OL[idx+1] = OL[NumOps-1];
4082 OL[NumOps-1].
set(
nullptr);
4118 return Create(
getOpcode(), Op<0>(), Op<1>());
4161 getSuccessOrdering(), getFailureOrdering(),
4171 getOrdering(), getSyncScopeID());
4233 if (hasOperandBundles()) {
4234 unsigned DescriptorBytes = getNumOperandBundles() *
sizeof(
BundleOpInfo);
4281 if (hasOperandBundles()) {
4282 unsigned DescriptorBytes = getNumOperandBundles() *
sizeof(
BundleOpInfo);
4289 if (hasOperandBundles()) {
4290 unsigned DescriptorBytes = getNumOperandBundles() *
sizeof(
BundleOpInfo);
bool isIdentityWithExtract() const
Return true if this shuffle extracts the first N elements of exactly one source vector.
Return a value (possibly void), from a function.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
A parsed version of the target data layout string in and methods for querying it. ...
This class is the base class for the comparison instructions.
MDNode * buildProfBranchWeightsMD()
FuncletPadInst * cloneImpl() const
static IntegerType * getInt1Ty(LLVMContext &C)
StoreInst * cloneImpl() const
uint64_t getZExtValue() const
Get zero extended value.
*p = old <signed v ? old : v
static bool IsConstantOne(Value *val)
IsConstantOne - Return true only if val is constant int 1.
FreezeInst * cloneImpl() const
Clone an identical FreezeInst.
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Atomic ordering constants.
This class represents lattice values for constants.
BinaryOps getOpcode() const
unsigned getSubclassDataFromInstruction() const
void swapSuccessors()
Swap the successors of this branch instruction.
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
Type * getParamType(unsigned i) const
Parameter type accessors.
static bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
IndirectBrInst * cloneImpl() const
ConstantAsMetadata * createConstant(Constant *C)
Return the given constant as metadata.
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
A Module instance is used to store all the information related to an LLVM module. ...
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
An instruction for ordering other memory operations.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
An instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Function * getCaller()
Helper to get the caller (the parent function).
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
bool isIntegerCast() const
There are several places where we need to know if a cast instruction only deals with integer source a...
BitCastInst * cloneImpl() const
Clone an identical BitCastInst.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
This class represents zero extension of integer types.
void push_back(const T &Elt)
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Add an entry to the switch instruction.
AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="", Instruction *InsertBefore=nullptr)
ShuffleVectorInst * cloneImpl() const
This class represents a function call, abstracting a target machine's calling convention.
bool isIdentityWithPadding() const
Return true if this shuffle lengthens exactly one source vector with undefs in the high elements...
Value * getCondition() const
*p = old <unsigned v ? old : v
float convertToFloat() const
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
0 1 0 0 True if ordered and less than
FenceInst * cloneImpl() const
void removeHandler(handler_iterator HI)
*p = old >unsigned v ? old : v
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)
LLVMContext & getContext() const
All values hold a context through their type.
1 1 1 0 True if unordered or not equal
static CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
static bool isOrdered(Predicate predicate)
Determine if the predicate is an ordered operation.
SIToFPInst * cloneImpl() const
Clone an identical SIToFPInst.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
CatchSwitchInst * cloneImpl() const
const MDOperand & getOperand(unsigned I) const
FenceInst(LLVMContext &C, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, Instruction *InsertBefore=nullptr)
This class represents a sign extension of integer types.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
static IntegerType * getInt64Ty(LLVMContext &C)
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
static bool isReverseMask(ArrayRef< int > Mask)
Return true if this shuffle mask swaps the order of elements from exactly one source vector...
bool isVectorTy() const
True if this is an instance of VectorType.
InsertElementInst * cloneImpl() const
static Instruction * CreateFree(Value *Source, Instruction *InsertBefore)
Generate the IR for a call to the builtin free function.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this store instruction.
CaseWeightOpt getSuccessorWeight(unsigned idx)
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
*p = old >signed v ? old : v
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock *> IndirectDests, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
bool isIndirectCall() const
Return true if the callsite is an indirect call.
bool isReturnNonNull() const
Return true if the return value is known to be not null.
LLVMContext & getContext() const
Get the context in which this basic block lives.
static LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
ICmpInst * cloneImpl() const
Clone an identical ICmpInst.
bool isTailCall() const
Tests if this call site is marked as a tail call.
void setVolatile(bool V)
Specify whether this is a volatile RMW or not.
static bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op...
block_iterator block_end()
bool hasRetAttr(Attribute::AttrKind Kind) const
Determine whether the return value has the given attribute.
Predicate getSignedPredicate()
For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert.
CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS, Value *RHS, const Twine &Name="", Instruction *InsertBefore=nullptr, Instruction *FlagsSource=nullptr)
bool indexValid(const Value *V) const
bool swapOperands()
Exchange the two operands to this instruction.
AllocaInst * cloneImpl() const
SwitchInst * cloneImpl() const
1 0 0 1 True if unordered or equal
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this load instruction.
static bool isImpliedFalseByMatchingCmp(Predicate Pred1, Predicate Pred2)
Determine if Pred1 implies Pred2 is false when two compares have matching operands.
MaybeAlign getAlign() const
The address of a basic block.
Constant * getMask() const
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)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
bool isVolatile() const
Return true if this is a load from a volatile memory location.
This class represents a conversion between pointers from one address space to another.
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy)
This method can be used to determine if a cast from S to DstTy using Opcode op is valid or not...
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
Used to keep track of an operand bundle.
This class represents the LLVM 'select' instruction.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
Type * getPointerElementType() const
IntToPtrInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
This is the base class for all instructions that perform data casts.
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
PointerType * getType() const
Overload to return most specific pointer type.
CatchReturnInst * cloneImpl() const
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
bool isStrongerThan(AtomicOrdering ao, AtomicOrdering other)
Returns true if ao is stronger than other as defined by the AtomicOrdering lattice, which is based on C++'s definition.
TailCallKind getTailCallKind() const
PtrToIntInst * cloneImpl() const
Clone an identical PtrToIntInst.
bool isCommutative() const
This is just a convenience that dispatches to the subclasses.
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
bundle_op_iterator bundle_op_info_end()
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
A Use represents the edge between a Value definition and its users.
void growHungoffUses(unsigned N, bool IsPhi=false)
Grow the number of hung off uses.
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
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.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static bool isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2)
Determine if Pred1 implies Pred2 is true when two compares have matching operands.
UIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
0 1 0 1 True if ordered and less than or equal
This file contains the simple types necessary to represent the attributes associated with functions a...
unsigned getNumSubclassExtraOperandsDynamic() const
Get the number of extra operands for instructions that don't have a fixed number of extra operands...
void setName(const Twine &Name)
Change the name of the value.
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
static const unsigned MaximumAlignment
block_iterator block_begin()
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
This class represents a cast from a pointer to an integer.
AtomicOrdering
Atomic ordering for LLVM's memory model.
static bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
void addHandler(BasicBlock *Dest)
Add an entry to the switch instruction...
static StringRef getOperationName(BinOp Op)
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
Class to represent function types.
static bool isIdentityMask(ArrayRef< int > Mask)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
Type * getType() const
All values are typed, get the type of this value.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
LandingPadInst * getLandingPadInst() const
Get the landingpad instruction from the landing pad block (the unwind destination).
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
bool isSwiftError() const
Return true if this value is a swifterror value.
unsigned getNumSuccessors() const
Class to represent array types.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
This instruction compares its operands according to the predicate given to the constructor.
AddrSpaceCastInst * cloneImpl() const
Clone an identical AddrSpaceCastInst.
UnreachableInst * cloneImpl() const
LandingPadInst * cloneImpl() const
This class represents a no-op cast from one type to another.
static Instruction * createFree(Value *Source, ArrayRef< OperandBundleDef > Bundles, Instruction *InsertBefore, BasicBlock *InsertAtEnd)
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
static CmpInst * Create(OtherOps Op, Predicate predicate, Value *S1, Value *S2, const Twine &Name="", Instruction *InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
SIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
FPToSIInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
An instruction for storing to memory.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
This class represents a cast from floating point to signed integer.
Value * getParentPad() const
LoadInst * cloneImpl() const
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
static MDNode * getProfBranchWeightsMD(const SwitchInst &SI)
This class represents a truncation of integer types.
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Value * getOperand(unsigned i) const
Class to represent pointers.
TruncInst * cloneImpl() const
Clone an identical TruncInst.
static bool isExtractSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is an extract subvector mask.
FPTruncInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I)
Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight...
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
static bool isSingleSourceMaskImpl(ArrayRef< int > Mask, int NumOpElts)
static Type * getIndexedTypeInternal(Type *Agg, ArrayRef< IndexTy > IdxList)
getIndexedType - Returns the type of the element that would be accessed with a gep instruction with t...
bool isVoidTy() const
Return true if this is 'void'.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
ReturnInst * cloneImpl() const
initializer< Ty > init(const Ty &Val)
This instruction inserts a single (scalar) element into a VectorType value.
const Use * getOperandList() const
static BinaryOperator * CreateNSWNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
MaybeAlign getAlign() const
Return the alignment of the access that is being performed.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
op_iterator populateBundleOperandInfos(ArrayRef< OperandBundleDef > Bundles, const unsigned BeginIndex)
Populate the BundleOpInfo instances and the Use& vector from Bundles.
void setSuccessorWeight(unsigned idx, CaseWeightOpt W)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Value * getCalledValue() const
LLVM Basic Block Representation.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
The instances of the Type class are immutable: once they are created, they are never changed...
static bool isNoopCast(Instruction::CastOps Opcode, Type *SrcTy, Type *DstTy, const DataLayout &DL)
A no-op cast is one that can be effected without changing any bits.
This is an important class for using LLVM in a threaded context.
UnreachableInst(LLVMContext &C, Instruction *InsertBefore=nullptr)
Conditional or Unconditional Branch instruction.
PowerPC Reduce CR logical Operation
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this store instruction.
size_t size() const
size - Get the array size.
This function has undefined behavior.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Resume the propagation of an exception.
PHINode * cloneImpl() const
static StringRef getPredicateName(Predicate P)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
SelectInst * cloneImpl() const
bool isPointerTy() const
True if this is an instance of PointerType.
Indirect Branch Instruction.
FunctionType * getFunctionType() const
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
ConstantFP - Floating Point Values [float, double].
BasicBlock * getDefaultDest() const
static bool isBitCastable(Type *SrcTy, Type *DestTy)
Check whether a bitcast between these types is valid.
static Type * getVoidTy(LLVMContext &C)
UIToFPInst * cloneImpl() const
Clone an identical UIToFPInst.
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
void setCallingConv(CallingConv::ID CC)
void addClause(Constant *ClauseVal)
Add a catch or filter clause to the landing pad.
BinaryOperator * cloneImpl() const
0 1 1 1 True if ordered (no nans)
static CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast or an AddrSpaceCast cast instruction.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
bool isX86_MMXTy() const
Return true if this is X86 MMX.
static bool isZeroEltSplatMask(ArrayRef< int > Mask)
Return true if this shuffle mask chooses all elements with the same value as the first element of exa...
FPExtInst * cloneImpl() const
Clone an identical FPExtInst.
AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, AtomicOrdering Ordering, SyncScope::ID SSID, Instruction *InsertBefore=nullptr)
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
void setTailCallKind(TailCallKind TCK)
CaseIt removeCase(CaseIt I)
This method removes the specified case and its successor from the switch instruction.
VAArgInst * cloneImpl() const
bool hasConstantOrUndefValue() const
Whether the specified PHI node always merges together the same value, assuming undefs are equal to a ...
This class represents a cast from an integer to a pointer.
static Constant * getAllOnesValue(Type *Ty)
1 1 1 1 Always true (always folded)
NUW NUW NUW NUW Exact static Exact BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const Twine &NameStr="", Instruction *InsertBefor=nullptr)
void setTailCall(bool isTC=true)
BranchInst * cloneImpl() const
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
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.
const Value * getArraySize() const
Get the number of elements allocated.
static UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
static bool isSelectMask(ArrayRef< int > Mask)
Return true if this shuffle mask chooses elements from its source vectors without lane crossings...
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)
Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the...
static int getMaskValue(const Constant *Mask, unsigned Elt)
Return the shuffle mask value for the specified element of the mask.
1 1 0 1 True if unordered, less than, or equal
void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
void swapOperands()
This is just a convenience that dispatches to the subclasses.
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
UnaryOperator(UnaryOps iType, Value *S, Type *Ty, const Twine &Name, Instruction *InsertBefore)
LLVMContextImpl *const pImpl
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
Synchronized with respect to all concurrently executing threads.
Value * getParentPad() const
Convenience accessors.
Optional< uint64_t > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
static BinaryOperator * CreateNUWNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
TruncInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
const APFloat & getValueAPF() const
static Instruction * createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize, ArrayRef< OperandBundleDef > OpB, Function *MallocF, const Twine &Name)
0 0 1 0 True if ordered and greater than
CallBrInst * cloneImpl() const
BasicBlock * getNormalDest() const
InsertValueInst * cloneImpl() const
Value * hasConstantValue() const
If the specified PHI node always merges together the same value, return the value, otherwise return null.
static BinaryOperator * CreateFNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
const InstListType & getInstList() const
Return the underlying instruction list container.
void commute()
Swap the first 2 operands and adjust the mask to preserve the semantics of the instruction.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
static CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt, BitCast, or Trunc for int -> int casts.
unsigned getNumOperands() const
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
This is the shared class of boolean and integer constants.
UnaryOperator * cloneImpl() const
Align max(MaybeAlign Lhs, Align Rhs)
bool hasUnwindDest() const
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
AddrSpaceCastInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
1 1 0 0 True if unordered or less than
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
static bool isCastable(Type *SrcTy, Type *DestTy)
Check whether it is valid to call getCastOpcode for these types.
void setAlignment(MaybeAlign Alignment)
This class represents a freeze function that returns random concrete value if an operand is either a ...
bool isAggregateType() const
Return true if the type is an aggregate type.
BasicBlock * getUnwindDest() const
Type * getReturnType() const
AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID, Instruction *InsertBefore=nullptr)
This class represents a cast from floating point to unsigned integer.
static CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
static bool isTransposeMask(ArrayRef< int > Mask)
Return true if this shuffle mask is a transpose mask.
static unsigned isEliminableCastPair(Instruction::CastOps firstOpcode, Instruction::CastOps secondOpcode, Type *SrcTy, Type *MidTy, Type *DstTy, Type *SrcIntPtrTy, Type *MidIntPtrTy, Type *DstIntPtrTy)
Determine how a pair of casts can be eliminated, if they can be at all.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
SExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
IntToPtrInst * cloneImpl() const
Clone an identical IntToPtrInst.
FreezeInst(Value *S, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
AttributeList getAttributes() const
Return the parameter attributes for this call.
static const Function * getCalledFunction(const Value *V, bool LookThroughBitCast, bool &IsNoBuiltin)
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
SymbolTableList< Instruction >::iterator eraseFromParent()
Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch t...
bool isCommutative() const
Return true if the instruction is commutative:
void setAlignment(MaybeAlign Align)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
CleanupReturnInst * cloneImpl() const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned getVectorNumElements() const
bool isTrueWhenEqual() const
This is just a convenience.
Class to represent vector types.
void setVolatile(bool V)
Specify whether this is a volatile store or not.
Class for arbitrary precision integers.
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, Instruction *InsertBefore)
bool isFalseWhenEqual() const
This is just a convenience.
void push_back(pointer val)
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
void setWeak(bool IsWeak)
SmallVector< BasicBlock *, 16 > getIndirectDests() const
ZExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
BitCastInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
AtomicCmpXchgInst * cloneImpl() const
Common super class of ArrayType, StructType and VectorType.
bool isNonIntegralPointerType(PointerType *PT) const
void setSwiftError(bool V)
Specify whether this alloca is used to represent a swifterror.
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:
LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
GetElementPtrInst * cloneImpl() const
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
BasicBlock * getDefaultDest() const
List that automatically updates parent links and symbol tables.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
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...
static IntegerType * getInt32Ty(LLVMContext &C)
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
static CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a Trunc or BitCast cast instruction.
UnaryOps getOpcode() const
ZExtInst * cloneImpl() const
Clone an identical ZExtInst.
unsigned greater or equal
AttributeList Attrs
parameter attributes for callable
static bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
bool isTokenTy() const
Return true if this is 'token'.
CallingConv::ID getCallingConv() const
uint64_t getKnownMinSize() const
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
float getFPAccuracy() const
Get the maximum error permitted by this operation in ULPs.
static bool isIdentityMaskImpl(ArrayRef< int > Mask, int NumOpElts)
StringRef getName() const
Return a constant reference to the value's name.
const Function * getParent() const
Return the enclosing method, or null if none.
void setValue(ConstantInt *V)
Sets the new value for current case.
static Instruction::CastOps getCastOpcode(const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
Returns the opcode necessary to cast Val into Ty using usual casting rules.
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Value * getReturnedArgOperand() const
If one of the arguments has the 'returned' attribute, returns its operand value.
static Constant * getZeroValueForNegation(Type *Ty)
Floating point negation must be implemented with f(x) = -0.0 - x.
This class represents a cast unsigned integer to floating point.
FCmpInst * cloneImpl() const
Clone an identical FCmpInst.
0 1 1 0 True if ordered and operands are unequal
AtomicRMWInst * cloneImpl() const
void setAlignment(MaybeAlign Alignment)
FPToSIInst * cloneImpl() const
Clone an identical FPToSIInst.
Compile-time customization of User operands.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this cmpxchg instruction.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
TypeSize getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
1 0 1 0 True if unordered or greater than
void addDestination(BasicBlock *Dest)
Add a destination.
Instruction(const Instruction &)=delete
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
static CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a SExt or BitCast cast instruction.
This class represents a cast from signed integer to floating point.
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SExtInst * cloneImpl() const
Clone an identical SExtInst.
const BasicBlock & front() const
SmallVector< int, 16 > getShuffleMask() const
bool isConcat() const
Return true if this shuffle concatenates its 2 source vectors.
This class represents a truncation of floating point types.
BasicBlock * getUnwindDest() const
0 0 0 1 True if ordered and equal
LLVM Value Representation.
bool isEquality() const
This is just a convenience that dispatches to the subclasses.
FPExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
1 0 1 1 True if unordered, greater than, or equal
static bool isSingleSourceMask(ArrayRef< int > Mask)
Return true if this shuffle mask chooses elements from exactly one source vector. ...
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
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.
static Value * getAISize(LLVMContext &Context, Value *Amt)
ResumeInst * cloneImpl() const
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore)
bundle_op_iterator bundle_op_info_begin()
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
FPTruncInst * cloneImpl() const
Clone an identical FPTruncInst.
void setSuccessor(BasicBlock *S)
Sets the new successor for current case.
StringRef - Represent a constant reference to a string, i.e.
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
static bool isVolatile(Instruction *Inst)
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size...
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
unsigned getNumOperands() const
Return number of MDNode operands.
static BinaryOperator * CreateMul(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
This class represents an extension of floating point types.
OutputIt copy(R &&Range, OutputIt Out)
0 0 1 1 True if ordered and greater than or equal
void setVolatile(bool V)
Specify whether this is a volatile load or not.
Predicate getUnsignedPredicate() const
For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
VectorType * getType() const
Overload to return most specific vector type.
void removeDestination(unsigned i)
This method removes the specified successor from the indirectbr instruction.
static Constant * get(ArrayRef< Constant *> V)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
CallInst * cloneImpl() const
bool isLosslessCast() const
A lossless cast is one that does not alter the basic value.
0 0 0 0 Always false (always folded)
bool empty() const
empty - Check if the array is empty.
InvokeInst * cloneImpl() const
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
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...
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
FPToUIInst * cloneImpl() const
Clone an identical FPToUIInst.
static const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null...