15 #ifndef LLVM_IR_IRBUILDER_H 16 #define LLVM_IR_IRBUILDER_H 74 std::function<void(Instruction *)> Callback;
78 : Callback(
std::move(Callback)) {}
105 : Context(context), DefaultFPMathTag(FPMathTag),
106 DefaultOperandBundles(OpBundles) {
107 ClearInsertionPoint();
129 InsertPt = BB->
end();
137 assert(InsertPt != BB->
end() &&
"Can't read debug loc from end()");
146 if (IP != TheBB->
end())
147 SetCurrentDebugLocation(IP->getDebugLoc());
165 Type *getCurrentFunctionReturnType()
const;
178 : Block(InsertBlock), Point(InsertPoint) {}
181 bool isSet()
const {
return (Block !=
nullptr); }
189 return InsertPoint(GetInsertBlock(), GetInsertPoint());
194 InsertPoint IP(GetInsertBlock(), GetInsertPoint());
195 ClearInsertionPoint();
204 ClearInsertionPoint();
236 : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
237 DbgLoc(B.getCurrentDebugLocation()) {}
257 : Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
406 MDNode *ScopeTag =
nullptr,
407 MDNode *NoAliasTag =
nullptr) {
408 return CreateMemSet(Ptr, Val, getInt64(Size), Align,
isVolatile,
409 TBAATag, ScopeTag, NoAliasTag);
414 MDNode *ScopeTag =
nullptr,
415 MDNode *NoAliasTag =
nullptr);
424 uint64_t Size,
unsigned Align,
426 MDNode *TBAATag =
nullptr,
427 MDNode *ScopeTag =
nullptr,
428 MDNode *NoAliasTag =
nullptr) {
429 return CreateElementUnorderedAtomicMemSet(Ptr, Val, getInt64(Size), Align,
430 ElementSize, TBAATag, ScopeTag,
435 Value *Size,
unsigned Align,
437 MDNode *TBAATag =
nullptr,
438 MDNode *ScopeTag =
nullptr,
439 MDNode *NoAliasTag =
nullptr);
447 unsigned SrcAlign, uint64_t Size,
449 MDNode *TBAAStructTag =
nullptr,
450 MDNode *ScopeTag =
nullptr,
451 MDNode *NoAliasTag =
nullptr) {
452 return CreateMemCpy(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
458 unsigned SrcAlign,
Value *Size,
460 MDNode *TBAAStructTag =
nullptr,
461 MDNode *ScopeTag =
nullptr,
462 MDNode *NoAliasTag =
nullptr);
473 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
475 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
476 MDNode *NoAliasTag =
nullptr) {
477 return CreateElementUnorderedAtomicMemCpy(
478 Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag,
479 TBAAStructTag, ScopeTag, NoAliasTag);
482 CallInst *CreateElementUnorderedAtomicMemCpy(
483 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
Value *Size,
485 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
486 MDNode *NoAliasTag =
nullptr);
497 MDNode *NoAliasTag =
nullptr) {
498 return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
isVolatile,
499 TBAATag, ScopeTag, NoAliasTag);
504 MDNode *ScopeTag =
nullptr,
505 MDNode *NoAliasTag =
nullptr);
517 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
519 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
520 MDNode *NoAliasTag =
nullptr) {
521 return CreateElementUnorderedAtomicMemMove(
522 Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag,
523 TBAAStructTag, ScopeTag, NoAliasTag);
526 CallInst *CreateElementUnorderedAtomicMemMove(
527 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
Value *Size,
529 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
530 MDNode *NoAliasTag =
nullptr);
557 CallInst *CreateIntMaxReduce(
Value *Src,
bool IsSigned =
false);
561 CallInst *CreateIntMinReduce(
Value *Src,
bool IsSigned =
false);
596 Value *Mask =
nullptr,
597 Value *PassThru =
nullptr,
602 Value *Mask =
nullptr);
639 CreateGCStatepointInvoke(uint64_t ID,
uint32_t NumPatchBytes,
658 CreateGCStatepointInvoke(uint64_t ID,
uint32_t NumPatchBytes,
748 MDNode *FPMathTag =
nullptr,
759 :
IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
760 SetInsertPoint(TheBB);
766 SetInsertPoint(TheBB);
776 MDNode *FPMathTag =
nullptr,
778 :
IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
779 SetInsertPoint(TheBB, IP);
783 MDNode *FPMathTag =
nullptr,
786 SetInsertPoint(TheBB, IP);
793 template<
typename InstTy>
796 this->SetInstDebugLocation(I);
813 template <
typename InstTy>
814 InstTy *addBranchMetadata(InstTy *
I,
MDNode *Weights,
MDNode *Unpredictable) {
842 for (
unsigned i = 0; i !=
N; ++i)
843 V = CreateInsertValue(V, retVals[i], i,
"mrv");
855 MDNode *BranchWeights =
nullptr,
856 MDNode *Unpredictable =
nullptr) {
858 BranchWeights, Unpredictable));
878 MDNode *BranchWeights =
nullptr,
879 MDNode *Unpredictable =
nullptr) {
881 BranchWeights, Unpredictable));
932 cast<PointerType>(Callee->
getType())->getElementType()),
933 Callee, NormalDest, UnwindDest, Args, OpBundles,
Name);
943 cast<PointerType>(Callee->
getType())->getElementType()),
944 Callee, NormalDest, UnwindDest,
Args,
Name);
957 unsigned NumHandlers,
989 bool HasNUW,
bool HasNSW) {
999 FPMD = DefaultFPMathTag;
1007 Value *R,
const Twine &Name =
nullptr)
const {
1010 return (LC && RC) ? Insert(Folder.CreateBinOp(Opc, LC, RC),
Name) :
nullptr;
1015 bool HasNUW =
false,
bool HasNSW =
false) {
1016 if (
auto *LC = dyn_cast<Constant>(LHS))
1017 if (
auto *RC = dyn_cast<Constant>(RHS))
1018 return Insert(Folder.CreateAdd(LC, RC, HasNUW, HasNSW),
Name);
1024 return CreateAdd(LHS, RHS, Name,
false,
true);
1028 return CreateAdd(LHS, RHS, Name,
true,
false);
1032 bool HasNUW =
false,
bool HasNSW =
false) {
1033 if (
auto *LC = dyn_cast<Constant>(LHS))
1034 if (
auto *RC = dyn_cast<Constant>(RHS))
1035 return Insert(Folder.CreateSub(LC, RC, HasNUW, HasNSW),
Name);
1036 return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name,
1041 return CreateSub(LHS, RHS, Name,
false,
true);
1045 return CreateSub(LHS, RHS, Name,
true,
false);
1049 bool HasNUW =
false,
bool HasNSW =
false) {
1050 if (
auto *LC = dyn_cast<Constant>(LHS))
1051 if (
auto *RC = dyn_cast<Constant>(RHS))
1052 return Insert(Folder.CreateMul(LC, RC, HasNUW, HasNSW),
Name);
1053 return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name,
1058 return CreateMul(LHS, RHS, Name,
false,
true);
1062 return CreateMul(LHS, RHS, Name,
true,
false);
1066 bool isExact =
false) {
1067 if (
auto *LC = dyn_cast<Constant>(LHS))
1068 if (
auto *RC = dyn_cast<Constant>(RHS))
1069 return Insert(Folder.CreateUDiv(LC, RC, isExact),
Name);
1071 return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
1072 return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
1076 return CreateUDiv(LHS, RHS, Name,
true);
1080 bool isExact =
false) {
1081 if (
auto *LC = dyn_cast<Constant>(LHS))
1082 if (
auto *RC = dyn_cast<Constant>(RHS))
1083 return Insert(Folder.CreateSDiv(LC, RC, isExact),
Name);
1085 return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
1086 return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
1090 return CreateSDiv(LHS, RHS, Name,
true);
1094 if (
Value *V = foldConstant(Instruction::URem, LHS, RHS, Name))
return V;
1095 return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
1099 if (
Value *V = foldConstant(Instruction::SRem, LHS, RHS, Name))
return V;
1100 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
1104 bool HasNUW =
false,
bool HasNSW =
false) {
1105 if (
auto *LC = dyn_cast<Constant>(LHS))
1106 if (
auto *RC = dyn_cast<Constant>(RHS))
1107 return Insert(Folder.CreateShl(LC, RC, HasNUW, HasNSW),
Name);
1108 return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
1113 bool HasNUW =
false,
bool HasNSW =
false) {
1119 bool HasNUW =
false,
bool HasNSW =
false) {
1125 bool isExact =
false) {
1126 if (
auto *LC = dyn_cast<Constant>(LHS))
1127 if (
auto *RC = dyn_cast<Constant>(RHS))
1128 return Insert(Folder.CreateLShr(LC, RC, isExact),
Name);
1130 return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
1131 return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
1135 bool isExact =
false) {
1140 bool isExact =
false) {
1145 bool isExact =
false) {
1146 if (
auto *LC = dyn_cast<Constant>(LHS))
1147 if (
auto *RC = dyn_cast<Constant>(RHS))
1148 return Insert(Folder.CreateAShr(LC, RC, isExact),
Name);
1150 return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
1151 return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
1155 bool isExact =
false) {
1160 bool isExact =
false) {
1165 if (
auto *RC = dyn_cast<Constant>(RHS)) {
1166 if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isMinusOne())
1168 if (
auto *LC = dyn_cast<Constant>(LHS))
1169 return Insert(Folder.CreateAnd(LC, RC),
Name);
1171 return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
1183 if (
auto *RC = dyn_cast<Constant>(RHS)) {
1184 if (RC->isNullValue())
1186 if (
auto *LC = dyn_cast<Constant>(LHS))
1187 return Insert(Folder.CreateOr(LC, RC),
Name);
1189 return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
1201 if (
Value *V = foldConstant(Instruction::Xor, LHS, RHS, Name))
return V;
1202 return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
1214 MDNode *FPMD =
nullptr) {
1215 if (
Value *V = foldConstant(Instruction::FAdd, L, R, Name))
return V;
1216 Instruction *I = setFPAttrs(BinaryOperator::CreateFAdd(L, R), FPMD, FMF);
1217 return Insert(I, Name);
1223 const Twine &Name =
"") {
1224 if (
Value *V = foldConstant(Instruction::FAdd, L, R, Name))
return V;
1225 Instruction *I = setFPAttrs(BinaryOperator::CreateFAdd(L, R),
nullptr,
1227 return Insert(I, Name);
1231 MDNode *FPMD =
nullptr) {
1232 if (
Value *V = foldConstant(Instruction::FSub, L, R, Name))
return V;
1233 Instruction *I = setFPAttrs(BinaryOperator::CreateFSub(L, R), FPMD, FMF);
1234 return Insert(I, Name);
1240 const Twine &Name =
"") {
1241 if (
Value *V = foldConstant(Instruction::FSub, L, R, Name))
return V;
1242 Instruction *I = setFPAttrs(BinaryOperator::CreateFSub(L, R),
nullptr,
1244 return Insert(I, Name);
1248 MDNode *FPMD =
nullptr) {
1249 if (
Value *V = foldConstant(Instruction::FMul, L, R, Name))
return V;
1250 Instruction *I = setFPAttrs(BinaryOperator::CreateFMul(L, R), FPMD, FMF);
1251 return Insert(I, Name);
1257 const Twine &Name =
"") {
1258 if (
Value *V = foldConstant(Instruction::FMul, L, R, Name))
return V;
1259 Instruction *I = setFPAttrs(BinaryOperator::CreateFMul(L, R),
nullptr,
1261 return Insert(I, Name);
1265 MDNode *FPMD =
nullptr) {
1266 if (
Value *V = foldConstant(Instruction::FDiv, L, R, Name))
return V;
1267 Instruction *I = setFPAttrs(BinaryOperator::CreateFDiv(L, R), FPMD, FMF);
1268 return Insert(I, Name);
1274 const Twine &Name =
"") {
1275 if (
Value *V = foldConstant(Instruction::FDiv, L, R, Name))
return V;
1276 Instruction *I = setFPAttrs(BinaryOperator::CreateFDiv(L, R),
nullptr,
1278 return Insert(I, Name);
1282 MDNode *FPMD =
nullptr) {
1283 if (
Value *V = foldConstant(Instruction::FRem, L, R, Name))
return V;
1284 Instruction *I = setFPAttrs(BinaryOperator::CreateFRem(L, R), FPMD, FMF);
1285 return Insert(I, Name);
1291 const Twine &Name =
"") {
1292 if (
Value *V = foldConstant(Instruction::FRem, L, R, Name))
return V;
1293 Instruction *I = setFPAttrs(BinaryOperator::CreateFRem(L, R),
nullptr,
1295 return Insert(I, Name);
1300 MDNode *FPMathTag =
nullptr) {
1301 if (
Value *V = foldConstant(Opc, LHS, RHS, Name))
return V;
1303 if (isa<FPMathOperator>(BinOp))
1304 BinOp = setFPAttrs(BinOp, FPMathTag, FMF);
1305 return Insert(BinOp, Name);
1309 bool HasNUW =
false,
bool HasNSW =
false) {
1310 if (
auto *
VC = dyn_cast<Constant>(V))
1311 return Insert(Folder.CreateNeg(
VC, HasNUW, HasNSW),
Name);
1313 if (HasNUW) BO->setHasNoUnsignedWrap();
1314 if (HasNSW) BO->setHasNoSignedWrap();
1327 MDNode *FPMathTag =
nullptr) {
1328 if (
auto *
VC = dyn_cast<Constant>(V))
1329 return Insert(Folder.CreateFNeg(
VC),
Name);
1335 if (
auto *
VC = dyn_cast<Constant>(V))
1336 return Insert(Folder.CreateNot(
VC),
Name);
1345 Value *ArraySize =
nullptr,
const Twine &Name =
"") {
1346 return Insert(
new AllocaInst(Ty, AddrSpace, ArraySize), Name);
1350 const Twine &Name =
"") {
1351 const DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
1358 return Insert(
new LoadInst(Ty, Ptr), Name);
1362 return Insert(
new LoadInst(Ty, Ptr), Name);
1366 const Twine &Name =
"") {
1367 return Insert(
new LoadInst(Ty, Ptr,
Twine(), isVolatile), Name);
1395 LoadInst *LI = CreateLoad(Ty, Ptr, Name);
1400 const Twine &Name =
"") {
1401 LoadInst *LI = CreateLoad(Ty, Ptr, Name);
1407 LoadInst *LI = CreateLoad(Ty, Ptr, isVolatile, Name);
1419 const Twine &Name =
"") {
1425 const Twine &Name =
"") {
1439 const Twine &Name =
"") {
1449 FailureOrdering, SSID));
1455 return Insert(
new AtomicRMWInst(Op, Ptr, Val, Ordering, SSID));
1459 const Twine &Name =
"") {
1460 return CreateGEP(
nullptr, Ptr, IdxList, Name);
1464 const Twine &Name =
"") {
1465 if (
auto *PC = dyn_cast<Constant>(Ptr)) {
1468 for (i = 0, e = IdxList.
size(); i != e; ++i)
1469 if (!isa<Constant>(IdxList[i]))
1472 return Insert(Folder.CreateGetElementPtr(Ty, PC, IdxList),
Name);
1478 const Twine &Name =
"") {
1479 return CreateInBoundsGEP(
nullptr, Ptr, IdxList, Name);
1483 const Twine &Name =
"") {
1484 if (
auto *PC = dyn_cast<Constant>(Ptr)) {
1487 for (i = 0, e = IdxList.
size(); i != e; ++i)
1488 if (!isa<Constant>(IdxList[i]))
1491 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IdxList),
1498 return CreateGEP(
nullptr, Ptr, Idx, Name);
1502 if (
auto *PC = dyn_cast<Constant>(Ptr))
1503 if (
auto *IC = dyn_cast<Constant>(Idx))
1504 return Insert(Folder.CreateGetElementPtr(Ty, PC, IC),
Name);
1509 const Twine &Name =
"") {
1510 if (
auto *PC = dyn_cast<Constant>(Ptr))
1511 if (
auto *IC = dyn_cast<Constant>(Idx))
1512 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IC),
Name);
1517 return CreateConstGEP1_32(
nullptr, Ptr, Idx0, Name);
1521 const Twine &Name =
"") {
1524 if (
auto *PC = dyn_cast<Constant>(Ptr))
1525 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idx),
Name);
1531 const Twine &Name =
"") {
1534 if (
auto *PC = dyn_cast<Constant>(Ptr))
1535 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idx),
Name);
1541 const Twine &Name =
"") {
1547 if (
auto *PC = dyn_cast<Constant>(Ptr))
1548 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idxs),
Name);
1554 unsigned Idx1,
const Twine &Name =
"") {
1560 if (
auto *PC = dyn_cast<Constant>(Ptr))
1561 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idxs),
Name);
1567 const Twine &Name =
"") {
1570 if (
auto *PC = dyn_cast<Constant>(Ptr))
1571 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idx),
Name);
1577 return CreateConstGEP1_64(
nullptr, Ptr, Idx0, Name);
1581 const Twine &Name =
"") {
1584 if (
auto *PC = dyn_cast<Constant>(Ptr))
1585 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idx),
Name);
1591 const Twine &Name =
"") {
1592 return CreateConstInBoundsGEP1_64(
nullptr, Ptr, Idx0, Name);
1596 const Twine &Name =
"") {
1602 if (
auto *PC = dyn_cast<Constant>(Ptr))
1603 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idxs),
Name);
1609 const Twine &Name =
"") {
1610 return CreateConstGEP2_64(
nullptr, Ptr, Idx0, Idx1, Name);
1614 uint64_t Idx1,
const Twine &Name =
"") {
1620 if (
auto *PC = dyn_cast<Constant>(Ptr))
1621 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idxs),
Name);
1627 const Twine &Name =
"") {
1628 return CreateConstInBoundsGEP2_64(
nullptr, Ptr, Idx0, Idx1, Name);
1632 const Twine &Name =
"") {
1633 return CreateConstInBoundsGEP2_32(Ty, Ptr, 0, Idx, Name);
1637 return CreateConstInBoundsGEP2_32(
nullptr, Ptr, 0, Idx, Name);
1646 Constant *Indices[] = {Zero, Zero};
1656 return CreateCast(Instruction::Trunc, V, DestTy, Name);
1660 return CreateCast(Instruction::ZExt, V, DestTy, Name);
1664 return CreateCast(Instruction::SExt, V, DestTy, Name);
1670 const Twine &Name =
"") {
1673 "Can only zero extend/truncate integers!");
1676 return CreateZExt(V, DestTy, Name);
1678 return CreateTrunc(V, DestTy, Name);
1685 const Twine &Name =
"") {
1688 "Can only sign extend/truncate integers!");
1691 return CreateSExt(V, DestTy, Name);
1693 return CreateTrunc(V, DestTy, Name);
1698 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
1702 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
1706 return CreateCast(Instruction::UIToFP, V, DestTy, Name);
1710 return CreateCast(Instruction::SIToFP, V, DestTy, Name);
1714 const Twine &Name =
"") {
1715 return CreateCast(Instruction::FPTrunc, V, DestTy, Name);
1719 return CreateCast(Instruction::FPExt, V, DestTy, Name);
1723 const Twine &Name =
"") {
1724 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
1728 const Twine &Name =
"") {
1729 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
1733 const Twine &Name =
"") {
1734 return CreateCast(Instruction::BitCast, V, DestTy, Name);
1738 const Twine &Name =
"") {
1739 return CreateCast(Instruction::AddrSpaceCast, V, DestTy, Name);
1743 const Twine &Name =
"") {
1746 if (
auto *
VC = dyn_cast<Constant>(V))
1747 return Insert(Folder.CreateZExtOrBitCast(
VC, DestTy),
Name);
1752 const Twine &Name =
"") {
1755 if (
auto *
VC = dyn_cast<Constant>(V))
1756 return Insert(Folder.CreateSExtOrBitCast(
VC, DestTy),
Name);
1761 const Twine &Name =
"") {
1764 if (
auto *
VC = dyn_cast<Constant>(V))
1765 return Insert(Folder.CreateTruncOrBitCast(
VC, DestTy),
Name);
1770 const Twine &Name =
"") {
1773 if (
auto *
VC = dyn_cast<Constant>(V))
1774 return Insert(Folder.CreateCast(Op,
VC, DestTy),
Name);
1779 const Twine &Name =
"") {
1782 if (
auto *
VC = dyn_cast<Constant>(V))
1783 return Insert(Folder.CreatePointerCast(
VC, DestTy),
Name);
1788 const Twine &Name =
"") {
1792 if (
auto *
VC = dyn_cast<Constant>(V)) {
1793 return Insert(Folder.CreatePointerBitCastOrAddrSpaceCast(
VC, DestTy),
1802 const Twine &Name =
"") {
1805 if (
auto *
VC = dyn_cast<Constant>(V))
1806 return Insert(Folder.CreateIntCast(
VC, DestTy, isSigned),
Name);
1811 const Twine &Name =
"") {
1815 return CreatePtrToInt(V, DestTy, Name);
1817 return CreateIntToPtr(V, DestTy, Name);
1819 return CreateBitCast(V, DestTy, Name);
1825 if (
auto *
VC = dyn_cast<Constant>(V))
1826 return Insert(Folder.CreateFPCast(
VC, DestTy),
Name);
1880 MDNode *FPMathTag =
nullptr) {
1885 MDNode *FPMathTag =
nullptr) {
1890 MDNode *FPMathTag =
nullptr) {
1895 MDNode *FPMathTag =
nullptr) {
1900 MDNode *FPMathTag =
nullptr) {
1905 MDNode *FPMathTag =
nullptr) {
1910 MDNode *FPMathTag =
nullptr) {
1915 MDNode *FPMathTag =
nullptr) {
1920 MDNode *FPMathTag =
nullptr) {
1925 MDNode *FPMathTag =
nullptr) {
1930 MDNode *FPMathTag =
nullptr) {
1935 MDNode *FPMathTag =
nullptr) {
1940 MDNode *FPMathTag =
nullptr) {
1945 MDNode *FPMathTag =
nullptr) {
1950 const Twine &Name =
"") {
1951 if (
auto *LC = dyn_cast<Constant>(LHS))
1952 if (
auto *RC = dyn_cast<Constant>(RHS))
1953 return Insert(Folder.CreateICmp(P, LC, RC),
Name);
1954 return Insert(
new ICmpInst(P, LHS, RHS), Name);
1958 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
1959 if (
auto *LC = dyn_cast<Constant>(LHS))
1960 if (
auto *RC = dyn_cast<Constant>(RHS))
1961 return Insert(Folder.CreateFCmp(P, LC, RC),
Name);
1962 return Insert(setFPAttrs(
new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
1970 const Twine &Name =
"") {
1976 MDNode *FPMathTag =
nullptr) {
1978 if (isa<FPMathOperator>(CI))
1979 CI = cast<CallInst>(setFPAttrs(CI, FPMathTag, FMF));
1980 return Insert(CI, Name);
1985 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
1987 if (isa<FPMathOperator>(CI))
1988 CI = cast<CallInst>(setFPAttrs(CI, FPMathTag, FMF));
1989 return Insert(CI, Name);
1993 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
1999 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2006 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2009 Args, Name, FPMathTag);
2015 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2018 Args, OpBundles, Name, FPMathTag);
2023 if (
auto *CC = dyn_cast<Constant>(C))
2024 if (
auto *TC = dyn_cast<Constant>(True))
2025 if (
auto *
FC = dyn_cast<Constant>(False))
2026 return Insert(Folder.CreateSelect(CC, TC,
FC),
Name);
2032 Sel = addBranchMetadata(Sel, Prof, Unpred);
2034 return Insert(Sel, Name);
2038 return Insert(
new VAArgInst(List, Ty), Name);
2042 const Twine &Name =
"") {
2043 if (
auto *
VC = dyn_cast<Constant>(Vec))
2044 if (
auto *IC = dyn_cast<Constant>(Idx))
2045 return Insert(Folder.CreateExtractElement(
VC, IC),
Name);
2050 const Twine &Name =
"") {
2051 return CreateExtractElement(Vec, getInt64(Idx), Name);
2055 const Twine &Name =
"") {
2056 if (
auto *
VC = dyn_cast<Constant>(Vec))
2057 if (
auto *
NC = dyn_cast<Constant>(NewElt))
2058 if (
auto *IC = dyn_cast<Constant>(Idx))
2059 return Insert(Folder.CreateInsertElement(
VC,
NC, IC),
Name);
2064 const Twine &Name =
"") {
2065 return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
2069 const Twine &Name =
"") {
2070 if (
auto *V1C = dyn_cast<Constant>(V1))
2071 if (
auto *V2C = dyn_cast<Constant>(V2))
2072 if (
auto *MC = dyn_cast<Constant>(Mask))
2073 return Insert(Folder.CreateShuffleVector(V1C, V2C, MC),
Name);
2078 const Twine &Name =
"") {
2080 return CreateShuffleVector(V1, V2, Mask, Name);
2085 const Twine &Name =
"") {
2086 if (
auto *AggC = dyn_cast<Constant>(Agg))
2087 return Insert(Folder.CreateExtractValue(AggC, Idxs),
Name);
2093 const Twine &Name =
"") {
2094 if (
auto *AggC = dyn_cast<Constant>(Agg))
2095 if (
auto *ValC = dyn_cast<Constant>(Val))
2096 return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs),
Name);
2101 const Twine &Name =
"") {
2129 "Pointer subtraction operand types must match!");
2130 auto *ArgType = cast<PointerType>(LHS->
getType());
2133 Value *Difference = CreateSub(LHS_int, RHS_int);
2134 return CreateExactSDiv(Difference,
2144 "launder.invariant.group only applies to pointers.");
2146 auto *PtrType = Ptr->
getType();
2147 auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace());
2148 if (PtrType != Int8PtrTy)
2149 Ptr = CreateBitCast(Ptr, Int8PtrTy);
2150 Module *M = BB->getParent()->getParent();
2157 "LaunderInvariantGroup should take and return the same type");
2159 CallInst *Fn = CreateCall(FnLaunderInvariantGroup, {Ptr});
2161 if (PtrType != Int8PtrTy)
2162 return CreateBitCast(Fn, PtrType);
2171 "strip.invariant.group only applies to pointers.");
2174 auto *PtrType = Ptr->
getType();
2175 auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace());
2176 if (PtrType != Int8PtrTy)
2177 Ptr = CreateBitCast(Ptr, Int8PtrTy);
2178 Module *M = BB->getParent()->getParent();
2185 "StripInvariantGroup should take and return the same type");
2187 CallInst *Fn = CreateCall(FnStripInvariantGroup, {Ptr});
2189 if (PtrType != Int8PtrTy)
2190 return CreateBitCast(Fn, PtrType);
2197 assert(NumElts > 0 &&
"Cannot splat to an empty vector!");
2200 Type *I32Ty = getInt32Ty();
2203 Name +
".splatinsert");
2207 return CreateShuffleVector(V, Undef, Zeros, Name +
".splat");
2213 const Twine &Name) {
2214 auto *IntTy = cast<IntegerType>(From->
getType());
2217 "Element extends past full value");
2218 uint64_t ShAmt = 8 *
Offset;
2224 V = CreateLShr(V, ShAmt, Name +
".shift");
2227 "Cannot extract to a larger integer!");
2228 if (ExtractedTy != IntTy) {
2229 V = CreateTrunc(V, ExtractedTy, Name +
".trunc");
2243 Value *PtrIntValue = CreatePtrToInt(PtrValue, IntPtrTy,
"ptrint");
2246 bool IsOffsetZero =
false;
2247 if (
const auto *CI = dyn_cast<ConstantInt>(OffsetValue))
2248 IsOffsetZero = CI->isZero();
2250 if (!IsOffsetZero) {
2251 if (OffsetValue->
getType() != IntPtrTy)
2252 OffsetValue = CreateIntCast(OffsetValue, IntPtrTy,
true,
2254 PtrIntValue = CreateSub(PtrIntValue, OffsetValue,
"offsetptr");
2259 Value *MaskedPtr = CreateAnd(PtrIntValue, Mask,
"maskedptr");
2260 Value *InvCond = CreateICmpEQ(MaskedPtr, Zero,
"maskcond");
2262 *TheCheck = InvCond;
2264 return CreateAssumption(InvCond);
2279 Value *OffsetValue =
nullptr,
2280 Value **TheCheck =
nullptr) {
2282 "trying to create an alignment assumption on a non-pointer?");
2283 auto *PtrTy = cast<PointerType>(PtrValue->
getType());
2284 Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
2287 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
2288 OffsetValue, TheCheck);
2305 Value *OffsetValue =
nullptr,
2306 Value **TheCheck =
nullptr) {
2308 "trying to create an alignment assumption on a non-pointer?");
2309 auto *PtrTy = cast<PointerType>(PtrValue->
getType());
2310 Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
2312 if (Alignment->
getType() != IntPtrTy)
2313 Alignment = CreateIntCast(Alignment, IntPtrTy,
true,
2318 Value *PositiveMask =
2320 Value *Mask = CreateSelect(IsPositive, PositiveMask,
2323 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
2324 OffsetValue, TheCheck);
2333 #endif // LLVM_IR_IRBUILDER_H IntegerType * getInt16Ty()
Fetch the type representing a 16-bit integer.
Value * CreateInsertElement(Value *Vec, Value *NewElt, uint64_t Idx, const Twine &Name="")
Value * CreateNSWNeg(Value *V, const Twine &Name="")
Value * CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Common base class shared among various IRBuilders.
CallInst * CreateCall(Function *Callee, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
Return a value (possibly void), from a function.
Value * CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Value * CreateInBoundsGEP(Type *Ty, Value *Ptr, Value *Idx, const Twine &Name="")
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static ConstantInt * getFalse(LLVMContext &Context)
Value * CreateConstGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const Twine &Name="")
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T &F, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
FastMathFlags getFastMathFlags() const
Get the flags to be applied to created floating point ops.
InvokeInst * CreateInvoke(Function *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args=None, const Twine &Name="")
LLVMContext & getContext() const
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
Atomic ordering constants.
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
This class represents lattice values for constants.
Value * CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name="")
Type * getParamType(unsigned i) const
Parameter type accessors.
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
A Module instance is used to store all the information related to an LLVM module. ...
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, unsigned Align, const char *Name)
Provided to resolve 'CreateAlignedLoad(Ptr, Align, "...")' correctly, instead of converting the strin...
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=nullptr)
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
An instruction for ordering other memory operations.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
CallInst * CreateElementUnorderedAtomicMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memmove between the specified pointers.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Value * CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool isSet() const
Returns true if this insert point is set.
LoadInst * CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name="")
Value * CreateShl(Value *LHS, uint64_t RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static ConstantAggregateZero * get(Type *Ty)
Value * CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateExtractInteger(const DataLayout &DL, Value *From, IntegerType *ExtractedTy, uint64_t Offset, const Twine &Name)
Return a value that has been extracted from a larger integer type.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
This class represents a function call, abstracting a target machine's calling convention.
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP)
This specifies that created instructions should be inserted at the specified point.
Value * CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
0 1 0 0 True if ordered and less than
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)
1 1 1 0 True if unordered or not equal
Value * CreateFRemFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.
An instruction for reading from memory.
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
static IntegerType * getInt64Ty(LLVMContext &C)
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateShuffleVector(Value *V1, Value *V2, ArrayRef< uint32_t > IntMask, const Twine &Name="")
static IntegerType * getInt16Ty(LLVMContext &C)
InvokeInst * CreateInvoke(Function *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
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...
Value * CreateLaunderInvariantGroup(Value *Ptr)
Create a launder.invariant.group intrinsic call.
Value * CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name="")
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
Value * CreateNot(Value *V, const Twine &Name="")
Value * CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
1 0 0 1 True if unordered or equal
Value * CreateOr(Value *LHS, uint64_t RHS, const Twine &Name="")
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="")
unsigned getAllocaAddrSpace() 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)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Value * CreateFRem(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
This class represents the LLVM 'select' instruction.
Type * getPointerElementType() const
Value * CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name="")
Return the i64 difference between two pointer values, dividing out the size of the pointed-to objects...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Value * CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
static Type * getFloatTy(LLVMContext &C)
LoadInst * CreateLoad(Value *Ptr, const Twine &Name="")
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
CleanupPadInst * CreateCleanupPad(Value *ParentPad, ArrayRef< Value *> Args=None, const Twine &Name="")
Value * CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
IntegerType * getIntPtrTy(const DataLayout &DL, unsigned AddrSpace=0)
Fetch the type representing a pointer to an integer value.
0 1 0 1 True if ordered and less than or equal
Value * CreateFAddFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
const DebugLoc & getCurrentDebugLocation() const
Get location information used by debugging information.
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
void setName(const Twine &Name)
Change the name of the value.
CallInst * CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
Value * CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name="")
ConstantInt * getInt16(uint16_t C)
Get a constant 16-bit value.
Type * getVoidTy()
Fetch the type representing void.
AtomicOrdering
Atomic ordering for LLVM's memory model.
CatchReturnInst * CreateCatchRet(CatchPadInst *CatchPad, BasicBlock *BB)
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
static Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
Class to represent function types.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Type * getType() const
All values are typed, get the type of this value.
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
Value * CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name="")
BinOp
This enumeration lists the possible modifications atomicrmw can make.
BasicBlock * GetInsertBlock() const
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, unsigned Alignment, Value *OffsetValue=nullptr, Value **TheCheck=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer...
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
This instruction compares its operands according to the predicate given to the constructor.
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
ConstantFolder - Create constants with minimum, target independent, folding.
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID=SyncScope::System)
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
An instruction for storing to memory.
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
IRBuilder(LLVMContext &C, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
Value * CreateXor(Value *LHS, const APInt &RHS, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
ConstantInt * getIntN(unsigned N, uint64_t C)
Get a constant N-bit value, zero extended or truncated from a 64-bit value.
Class to represent pointers.
Type * getHalfTy()
Fetch the type representing a 16-bit floating point value.
CallInst * CreateMinNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the minnum intrinsic.
Value * CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
IndirectBrInst * CreateIndirectBr(Value *Addr, unsigned NumDests=10)
Create an indirect branch instruction with the specified address operand, with an optional hint for t...
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
InsertPoint saveAndClearIP()
Returns the current insert point, clearing it in the process.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, bool isVolatile, const Twine &Name="")
LoadInst * CreateLoad(Value *Ptr, const char *Name)
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...
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
Type * getReturnType() const
Returns the type of the ret val.
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
static IntegerType * getInt128Ty(LLVMContext &C)
The landingpad instruction holds all of the information necessary to generate correct exception handl...
CallInst * CreateCall(Function *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
IntegerType * getInt128Ty()
Fetch the type representing a 128-bit integer.
Value * CreateFMul(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
Creates a new insertion point at the given location.
IRBuilder(Instruction *IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Value * CreateConstInBoundsGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
This is an important class for using LLVM in a threaded context.
ConstantInt * getTrue()
Get the constant value for i1 true.
UnreachableInst * CreateUnreachable()
Conditional or Unconditional Branch instruction.
MDNode * getDefaultFPMathTag() const
Get the floating point math metadata being used.
size_t size() const
size - Get the array size.
This function has undefined behavior.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
This is an important base class in LLVM.
InsertPoint saveIP() const
Returns the current insert point.
Resume the propagation of an exception.
Value * CreateShl(Value *LHS, const APInt &RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Value * CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Indirect Branch Instruction.
Value * CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Value * CreateFPToUI(Value *V, Type *DestTy, const Twine &Name="")
CallInst * CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maxnum intrinsic.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const Twine &Name="")
static Type * getVoidTy(LLVMContext &C)
CatchSwitchInst * CreateCatchSwitch(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, const Twine &Name="")
Value * CreateFSubFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Value * CreateFDivFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
VAArgInst * CreateVAArg(Value *List, Type *Ty, const Twine &Name="")
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, Value *Alignment, Value *OffsetValue=nullptr, Value **TheCheck=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer...
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
A specialization of it's base class for read-write access to a gc.statepoint.
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.
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, unsigned Align, const Twine &Name="")
void clearFastMathFlags()
Clear the fast-math flags.
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, unsigned Align, bool isVolatile, const Twine &Name="")
self_iterator getIterator()
Class to represent integer types.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
IntegerType * getIntNTy(unsigned N)
Fetch the type representing an N-bit integer.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, bool isVolatile, const Twine &Name="")
IRBuilderCallbackInserter(std::function< void(Instruction *)> Callback)
void setAlignment(unsigned Align)
Constant * Insert(Constant *C, const Twine &="") const
No-op overload to handle constants.
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
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...
InsertPointGuard(IRBuilderBase &B)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Value * CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
void SetInsertPoint(Instruction *I)
This specifies that created instructions should be inserted before the specified instruction.
const T & getFolder()
Get the constant folder being used.
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
1 1 0 1 True if unordered, less than, or equal
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
static IndirectBrInst * Create(Value *Address, unsigned NumDests, Instruction *InsertBefore=nullptr)
Value * CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Value * CreateSRem(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name="")
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Create an invoke instruction.
This provides the default implementation of the IRBuilder 'InsertHelper' method that is called whenev...
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Value * CreateGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Value * CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
0 0 1 0 True if ordered and greater than
static BinaryOperator * CreateFNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
static Type * getHalfTy(LLVMContext &C)
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 setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
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.
This is the shared class of boolean and integer constants.
ResumeInst * CreateResume(Value *Exn)
BlockVerifier::State From
InsertPoint - A saved insertion point.
CallInst * CreateMinimum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the minimum intrinsic.
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value *> Args=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=nullptr)
Value * CreateIsNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is null.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Value * CreateNUWNeg(Value *V, const Twine &Name="")
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
1 1 0 0 True if unordered or less than
Module.h This file contains the declarations for the Module class.
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
FastMathFlagGuard(IRBuilderBase &B)
IRBuilderBase(LLVMContext &context, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Value * CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
static CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
Value * CreateExtractElement(Value *Vec, uint64_t Idx, const Twine &Name="")
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
CallInst * CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
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.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
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...
Value * CreateConstInBoundsGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name="")
Value * CreateURem(Value *LHS, Value *RHS, const Twine &Name="")
static ConstantInt * getTrue(LLVMContext &Context)
Value handle that asserts if the Value is deleted.
Constant * CreateGlobalStringPtr(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Same as CreateGlobalString, but return a pointer with "i8*" type instead of a pointer to array of i8...
ArrayRef< OperandBundleDef > DefaultOperandBundles
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Value * CreateFPCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name="")
Class for arbitrary precision integers.
BasicBlock::iterator getPoint() const
CallInst * CreateMaximum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maximum intrinsic.
Value * CreateGEP(Value *Ptr, Value *Idx, const Twine &Name="")
Value * CreateSDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Value * CreateUDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Value * CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name="")
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.
Value * CreatePointerBitCastOrAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
InstListType::iterator iterator
Instruction iterators...
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value *> Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
amdgpu Simplify well known AMD library false Value Value * Arg
ConstantInt * getFalse()
Get the constant value for i1 false.
MDNode * DefaultFPMathTag
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const Twine &Name="")
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
SwitchInst * CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases=10, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a switch instruction with the specified value, default dest, and with a hint for the number of...
Value * CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name="")
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
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 ...
Value * CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateGEP(Type *Ty, Value *Ptr, Value *Idx, const Twine &Name="")
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Provides an 'InsertHelper' that calls a user-provided callback after performing the default insertion...
iterator insert(iterator where, pointer New)
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
static IntegerType * getInt32Ty(LLVMContext &C)
Value * CreateXor(Value *LHS, uint64_t RHS, const Twine &Name="")
static CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a Trunc or BitCast cast instruction.
CatchPadInst * CreateCatchPad(Value *ParentPad, ArrayRef< Value *> Args, const Twine &Name="")
unsigned greater or equal
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
Value * CreateConstGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant *> IdxList)
Create an "inbounds" getelementptr.
CleanupReturnInst * CreateCleanupRet(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB=nullptr)
Value * CreateFSub(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateInBoundsGEP(Type *Ty, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
0 1 1 0 True if ordered and operands are unequal
Value * CreateStripInvariantGroup(Value *Ptr)
Create a strip.invariant.group intrinsic call.
Value * CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
void setDefaultFPMathTag(MDNode *FPMathTag)
Set the floating point math metadata to be used.
static BinaryOperator * CreateNeg(Value *S1, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
1 0 1 0 True if unordered or greater than
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const
LandingPadInst * CreateLandingPad(Type *Ty, unsigned NumClauses, const Twine &Name="")
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateFDiv(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag...
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
static CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a SExt or BitCast cast instruction.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
ReturnInst * CreateAggregateRet(Value *const *retVals, unsigned N)
Create a sequence of N insertvalue instructions, with one Value from the retVals array each...
Value * CreateFMulFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore=nullptr)
0 0 0 1 True if ordered and equal
LLVM Value Representation.
void setAlignment(unsigned Align)
1 0 1 1 True if unordered, greater than, or equal
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, Instruction *MDSrc)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
Synchronized with respect to all concurrently executing threads.
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, Instruction *InsertBefore=nullptr)
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.
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
BasicBlock::iterator GetInsertPoint() const
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
print Print MemDeps of function
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
Value * CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name="")
static bool isVolatile(Instruction *Inst)
CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memcpy between the specified pointers.
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
IRBuilder(LLVMContext &C, const T &F, Inserter I=Inserter(), MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
static BinaryOperator * CreateMul(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
BasicBlock * getBlock() const
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args=None, const Twine &Name="")
0 0 1 1 True if ordered and greater than or equal
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args=None, const Twine &Name="")
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
static IntegerType * getInt8Ty(LLVMContext &C)
BasicBlock::iterator InsertPt
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateOr(Value *LHS, const APInt &RHS, const Twine &Name="")
Value * CreateConstInBoundsGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
Value * CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateStructGEP(Value *Ptr, unsigned Idx, const Twine &Name="")