14 #ifndef LLVM_IR_IRBUILDER_H 15 #define LLVM_IR_IRBUILDER_H 73 std::function<void(Instruction *)> Callback;
77 : Callback(
std::move(Callback)) {}
108 : Context(context), DefaultFPMathTag(FPMathTag), IsFPConstrained(
false),
109 DefaultConstrainedExcept(fp::
ebStrict),
110 DefaultConstrainedRounding(fp::
rmDynamic),
111 DefaultOperandBundles(OpBundles) {
112 ClearInsertionPoint();
134 InsertPt = BB->
end();
142 assert(InsertPt != BB->
end() &&
"Can't read debug loc from end()");
151 if (IP != TheBB->
end())
152 SetCurrentDebugLocation(IP->getDebugLoc());
170 Type *getCurrentFunctionReturnType()
const;
183 : Block(InsertBlock), Point(InsertPoint) {}
186 bool isSet()
const {
return (Block !=
nullptr); }
194 return InsertPoint(GetInsertBlock(), GetInsertPoint());
199 InsertPoint IP(GetInsertBlock(), GetInsertPoint());
200 ClearInsertionPoint();
209 ClearInsertionPoint();
238 DefaultConstrainedExcept = NewExcept;
243 DefaultConstrainedRounding = NewRounding;
248 return DefaultConstrainedExcept;
253 return DefaultConstrainedRounding;
257 assert(BB &&
"Must have a basic block to set any function attributes!");
284 : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
285 DbgLoc(B.getCurrentDebugLocation()) {}
305 : Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {}
455 MDNode *NoAliasTag =
nullptr) {
456 return CreateMemSet(Ptr, Val, getInt64(Size), Align,
isVolatile,
457 TBAATag, ScopeTag, NoAliasTag);
462 MDNode *ScopeTag =
nullptr,
463 MDNode *NoAliasTag =
nullptr);
474 CallInst *CreateElementUnorderedAtomicMemSet(
475 Value *Ptr,
Value *Val, uint64_t Size,
unsigned Alignment,
477 MDNode *ScopeTag =
nullptr,
MDNode *NoAliasTag =
nullptr),
478 "Use the version that takes Align instead of this one") {
479 return CreateElementUnorderedAtomicMemSet(Ptr, Val, getInt64(Size),
480 Align(Alignment), ElementSize,
481 TBAATag, ScopeTag, NoAliasTag);
485 uint64_t Size, Align Alignment,
487 MDNode *TBAATag =
nullptr,
488 MDNode *ScopeTag =
nullptr,
489 MDNode *NoAliasTag =
nullptr) {
490 return CreateElementUnorderedAtomicMemSet(Ptr, Val, getInt64(Size),
491 Align(Alignment), ElementSize,
492 TBAATag, ScopeTag, NoAliasTag);
498 CallInst *CreateElementUnorderedAtomicMemSet(
501 MDNode *ScopeTag =
nullptr,
MDNode *NoAliasTag =
nullptr),
502 "Use the version that takes Align instead of this one") {
503 return CreateElementUnorderedAtomicMemSet(Ptr, Val, Size,
Align(Alignment),
504 ElementSize, TBAATag, ScopeTag,
509 Value *Size, Align Alignment,
511 MDNode *TBAATag =
nullptr,
512 MDNode *ScopeTag =
nullptr,
513 MDNode *NoAliasTag =
nullptr);
524 unsigned SrcAlign, uint64_t Size,
526 MDNode *TBAAStructTag =
nullptr,
527 MDNode *ScopeTag =
nullptr,
528 MDNode *NoAliasTag =
nullptr),
529 "Use the version that takes MaybeAlign instead") {
531 getInt64(Size),
isVolatile, TBAATag, TBAAStructTag,
532 ScopeTag, NoAliasTag);
538 MDNode *TBAAStructTag =
nullptr,
539 MDNode *ScopeTag =
nullptr,
540 MDNode *NoAliasTag =
nullptr) {
541 return CreateMemCpy(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
550 unsigned SrcAlign,
Value *Size,
552 MDNode *TBAAStructTag =
nullptr,
553 MDNode *ScopeTag =
nullptr,
554 MDNode *NoAliasTag =
nullptr),
555 "Use the version that takes MaybeAlign instead");
559 MDNode *TBAAStructTag =
nullptr,
560 MDNode *ScopeTag =
nullptr,
561 MDNode *NoAliasTag =
nullptr);
572 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
574 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
575 MDNode *NoAliasTag =
nullptr) {
576 return CreateElementUnorderedAtomicMemCpy(
577 Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag,
578 TBAAStructTag, ScopeTag, NoAliasTag);
581 CallInst *CreateElementUnorderedAtomicMemCpy(
582 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
Value *Size,
584 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
585 MDNode *NoAliasTag =
nullptr);
597 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
599 MDNode *ScopeTag =
nullptr,
MDNode *NoAliasTag =
nullptr),
600 "Use the version that takes MaybeAlign") {
602 getInt64(Size),
isVolatile, TBAATag, ScopeTag,
608 MDNode *ScopeTag =
nullptr,
609 MDNode *NoAliasTag =
nullptr) {
610 return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
617 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
619 MDNode *ScopeTag =
nullptr,
MDNode *NoAliasTag =
nullptr),
620 "Use the version that takes MaybeAlign") {
622 Size,
isVolatile, TBAATag, ScopeTag, NoAliasTag);
627 MDNode *ScopeTag =
nullptr,
628 MDNode *NoAliasTag =
nullptr);
640 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
642 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
643 MDNode *NoAliasTag =
nullptr) {
644 return CreateElementUnorderedAtomicMemMove(
645 Dst, DstAlign, Src, SrcAlign, getInt64(Size), ElementSize, TBAATag,
646 TBAAStructTag, ScopeTag, NoAliasTag);
649 CallInst *CreateElementUnorderedAtomicMemMove(
650 Value *Dst,
unsigned DstAlign,
Value *Src,
unsigned SrcAlign,
Value *Size,
652 MDNode *TBAAStructTag =
nullptr,
MDNode *ScopeTag =
nullptr,
653 MDNode *NoAliasTag =
nullptr);
680 CallInst *CreateIntMaxReduce(
Value *Src,
bool IsSigned =
false);
684 CallInst *CreateIntMinReduce(
Value *Src,
bool IsSigned =
false);
719 Value *Mask =
nullptr,
720 Value *PassThru =
nullptr,
725 Value *Mask =
nullptr);
762 CreateGCStatepointInvoke(uint64_t ID,
uint32_t NumPatchBytes,
781 CreateGCStatepointInvoke(uint64_t ID,
uint32_t NumPatchBytes,
871 MDNode *FPMathTag =
nullptr,
882 :
IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
883 SetInsertPoint(TheBB);
889 SetInsertPoint(TheBB);
899 MDNode *FPMathTag =
nullptr,
901 :
IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
902 SetInsertPoint(TheBB, IP);
906 MDNode *FPMathTag =
nullptr,
909 SetInsertPoint(TheBB, IP);
916 template<
typename InstTy>
919 this->SetInstDebugLocation(I);
936 template <
typename InstTy>
937 InstTy *addBranchMetadata(InstTy *
I,
MDNode *Weights,
MDNode *Unpredictable) {
939 I->setMetadata(LLVMContext::MD_prof, Weights);
941 I->setMetadata(LLVMContext::MD_unpredictable, Unpredictable);
965 for (
unsigned i = 0; i !=
N; ++i)
966 V = CreateInsertValue(V, retVals[i], i,
"mrv");
978 MDNode *BranchWeights =
nullptr,
979 MDNode *Unpredictable =
nullptr) {
981 BranchWeights, Unpredictable));
990 unsigned WL[4] = {LLVMContext::MD_prof, LLVMContext::MD_unpredictable,
991 LLVMContext::MD_make_implicit, LLVMContext::MD_dbg};
1001 MDNode *BranchWeights =
nullptr,
1002 MDNode *Unpredictable =
nullptr) {
1004 BranchWeights, Unpredictable));
1037 NormalDest, UnwindDest,
Args, OpBundles,
Name);
1045 NormalDest, UnwindDest,
Args,
Name);
1053 return CreateInvoke(
1055 cast<PointerType>(Callee->
getType())->getElementType()),
1056 Callee, NormalDest, UnwindDest, Args, OpBundles,
Name);
1064 return CreateInvoke(
1066 cast<PointerType>(Callee->
getType())->getElementType()),
1067 Callee, NormalDest, UnwindDest,
Args,
Name);
1095 DefaultDest, IndirectDests,
Args,
Name);
1103 DefaultDest, IndirectDests,
Args,
Name);
1116 unsigned NumHandlers,
1148 bool HasNUW,
bool HasNSW) {
1158 FPMD = DefaultFPMathTag;
1169 return (LC && RC) ? Insert(Folder.CreateBinOp(Opc, LC, RC),
Name) :
nullptr;
1179 assert(RoundingStr.
hasValue() &&
"Garbage strict rounding mode!");
1192 assert(ExceptStr.
hasValue() &&
"Garbage strict exception behavior!");
1202 "Invalid constrained FP comparison predicate!");
1212 bool HasNUW =
false,
bool HasNSW =
false) {
1213 if (
auto *LC = dyn_cast<Constant>(LHS))
1214 if (
auto *RC = dyn_cast<Constant>(RHS))
1215 return Insert(Folder.CreateAdd(LC, RC, HasNUW, HasNSW),
Name);
1221 return CreateAdd(LHS, RHS, Name,
false,
true);
1225 return CreateAdd(LHS, RHS, Name,
true,
false);
1229 bool HasNUW =
false,
bool HasNSW =
false) {
1230 if (
auto *LC = dyn_cast<Constant>(LHS))
1231 if (
auto *RC = dyn_cast<Constant>(RHS))
1232 return Insert(Folder.CreateSub(LC, RC, HasNUW, HasNSW),
Name);
1233 return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name,
1238 return CreateSub(LHS, RHS, Name,
false,
true);
1242 return CreateSub(LHS, RHS, Name,
true,
false);
1246 bool HasNUW =
false,
bool HasNSW =
false) {
1247 if (
auto *LC = dyn_cast<Constant>(LHS))
1248 if (
auto *RC = dyn_cast<Constant>(RHS))
1249 return Insert(Folder.CreateMul(LC, RC, HasNUW, HasNSW),
Name);
1250 return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name,
1255 return CreateMul(LHS, RHS, Name,
false,
true);
1259 return CreateMul(LHS, RHS, Name,
true,
false);
1263 bool isExact =
false) {
1264 if (
auto *LC = dyn_cast<Constant>(LHS))
1265 if (
auto *RC = dyn_cast<Constant>(RHS))
1266 return Insert(Folder.CreateUDiv(LC, RC, isExact),
Name);
1268 return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
1269 return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
1273 return CreateUDiv(LHS, RHS, Name,
true);
1277 bool isExact =
false) {
1278 if (
auto *LC = dyn_cast<Constant>(LHS))
1279 if (
auto *RC = dyn_cast<Constant>(RHS))
1280 return Insert(Folder.CreateSDiv(LC, RC, isExact),
Name);
1282 return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
1283 return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
1287 return CreateSDiv(LHS, RHS, Name,
true);
1292 return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
1297 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
1301 bool HasNUW =
false,
bool HasNSW =
false) {
1302 if (
auto *LC = dyn_cast<Constant>(LHS))
1303 if (
auto *RC = dyn_cast<Constant>(RHS))
1304 return Insert(Folder.CreateShl(LC, RC, HasNUW, HasNSW),
Name);
1305 return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
1310 bool HasNUW =
false,
bool HasNSW =
false) {
1316 bool HasNUW =
false,
bool HasNSW =
false) {
1322 bool isExact =
false) {
1323 if (
auto *LC = dyn_cast<Constant>(LHS))
1324 if (
auto *RC = dyn_cast<Constant>(RHS))
1325 return Insert(Folder.CreateLShr(LC, RC, isExact),
Name);
1327 return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
1328 return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
1332 bool isExact =
false) {
1337 bool isExact =
false) {
1342 bool isExact =
false) {
1343 if (
auto *LC = dyn_cast<Constant>(LHS))
1344 if (
auto *RC = dyn_cast<Constant>(RHS))
1345 return Insert(Folder.CreateAShr(LC, RC, isExact),
Name);
1347 return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
1348 return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
1352 bool isExact =
false) {
1357 bool isExact =
false) {
1362 if (
auto *RC = dyn_cast<Constant>(RHS)) {
1363 if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isMinusOne())
1365 if (
auto *LC = dyn_cast<Constant>(LHS))
1366 return Insert(Folder.CreateAnd(LC, RC),
Name);
1368 return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
1381 Value *Accum = Ops[0];
1382 for (
unsigned i = 1; i < Ops.
size(); i++)
1383 Accum = CreateAnd(Accum, Ops[i]);
1388 if (
auto *RC = dyn_cast<Constant>(RHS)) {
1389 if (RC->isNullValue())
1391 if (
auto *LC = dyn_cast<Constant>(LHS))
1392 return Insert(Folder.CreateOr(LC, RC),
Name);
1394 return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
1407 Value *Accum = Ops[0];
1408 for (
unsigned i = 1; i < Ops.
size(); i++)
1409 Accum = CreateOr(Accum, Ops[i]);
1415 return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
1427 MDNode *FPMD =
nullptr) {
1428 if (IsFPConstrained)
1429 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fadd,
1430 L, R,
nullptr, Name, FPMD);
1433 Instruction *I = setFPAttrs(BinaryOperator::CreateFAdd(L, R), FPMD, FMF);
1434 return Insert(I, Name);
1440 const Twine &Name =
"") {
1441 if (IsFPConstrained)
1442 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fadd,
1443 L, R, FMFSource, Name);
1446 Instruction *I = setFPAttrs(BinaryOperator::CreateFAdd(L, R),
nullptr,
1448 return Insert(I, Name);
1452 MDNode *FPMD =
nullptr) {
1453 if (IsFPConstrained)
1454 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fsub,
1455 L, R,
nullptr, Name, FPMD);
1458 Instruction *I = setFPAttrs(BinaryOperator::CreateFSub(L, R), FPMD, FMF);
1459 return Insert(I, Name);
1465 const Twine &Name =
"") {
1466 if (IsFPConstrained)
1467 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fsub,
1468 L, R, FMFSource, Name);
1471 Instruction *I = setFPAttrs(BinaryOperator::CreateFSub(L, R),
nullptr,
1473 return Insert(I, Name);
1477 MDNode *FPMD =
nullptr) {
1478 if (IsFPConstrained)
1479 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fmul,
1480 L, R,
nullptr, Name, FPMD);
1483 Instruction *I = setFPAttrs(BinaryOperator::CreateFMul(L, R), FPMD, FMF);
1484 return Insert(I, Name);
1490 const Twine &Name =
"") {
1491 if (IsFPConstrained)
1492 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fmul,
1493 L, R, FMFSource, Name);
1496 Instruction *I = setFPAttrs(BinaryOperator::CreateFMul(L, R),
nullptr,
1498 return Insert(I, Name);
1502 MDNode *FPMD =
nullptr) {
1503 if (IsFPConstrained)
1504 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fdiv,
1505 L, R,
nullptr, Name, FPMD);
1508 Instruction *I = setFPAttrs(BinaryOperator::CreateFDiv(L, R), FPMD, FMF);
1509 return Insert(I, Name);
1515 const Twine &Name =
"") {
1516 if (IsFPConstrained)
1517 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fdiv,
1518 L, R, FMFSource, Name);
1521 Instruction *I = setFPAttrs(BinaryOperator::CreateFDiv(L, R),
nullptr,
1523 return Insert(I, Name);
1527 MDNode *FPMD =
nullptr) {
1528 if (IsFPConstrained)
1529 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_frem,
1530 L, R,
nullptr, Name, FPMD);
1533 Instruction *I = setFPAttrs(BinaryOperator::CreateFRem(L, R), FPMD, FMF);
1534 return Insert(I, Name);
1540 const Twine &Name =
"") {
1541 if (IsFPConstrained)
1542 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_frem,
1543 L, R, FMFSource, Name);
1546 Instruction *I = setFPAttrs(BinaryOperator::CreateFRem(L, R),
nullptr,
1548 return Insert(I, Name);
1553 MDNode *FPMathTag =
nullptr) {
1556 if (isa<FPMathOperator>(BinOp))
1557 setFPAttrs(BinOp, FPMathTag, FMF);
1558 return Insert(BinOp, Name);
1563 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr,
1566 Value *RoundingV = getConstrainedFPRounding(Rounding);
1567 Value *ExceptV = getConstrainedFPExcept(Except);
1571 UseFMF = FMFSource->getFastMathFlags();
1574 {L, R, RoundingV, ExceptV},
nullptr,
Name);
1575 setConstrainedFPCallAttr(C);
1576 setFPAttrs(C, FPMathTag, UseFMF);
1581 bool HasNUW =
false,
bool HasNSW =
false) {
1582 if (
auto *
VC = dyn_cast<Constant>(V))
1583 return Insert(Folder.CreateNeg(
VC, HasNUW, HasNSW),
Name);
1585 if (HasNUW) BO->setHasNoUnsignedWrap();
1586 if (HasNSW) BO->setHasNoSignedWrap();
1599 MDNode *FPMathTag =
nullptr) {
1600 if (
auto *
VC = dyn_cast<Constant>(V))
1601 return Insert(Folder.CreateFNeg(
VC),
Name);
1602 return Insert(setFPAttrs(UnaryOperator::CreateFNeg(V), FPMathTag, FMF),
1609 const Twine &Name =
"") {
1610 if (
auto *
VC = dyn_cast<Constant>(V))
1611 return Insert(Folder.CreateFNeg(
VC),
Name);
1612 return Insert(setFPAttrs(UnaryOperator::CreateFNeg(V),
nullptr,
1618 if (
auto *
VC = dyn_cast<Constant>(V))
1619 return Insert(Folder.CreateNot(
VC),
Name);
1625 MDNode *FPMathTag =
nullptr) {
1626 if (
auto *
VC = dyn_cast<Constant>(V))
1627 return Insert(Folder.CreateUnOp(Opc,
VC),
Name);
1629 if (isa<FPMathOperator>(UnOp))
1630 setFPAttrs(UnOp, FPMathTag, FMF);
1631 return Insert(UnOp, Name);
1637 const Twine &Name =
"",
1638 MDNode *FPMathTag =
nullptr) {
1640 assert(Ops.
size() == 2 &&
"Invalid number of operands!");
1641 return CreateBinOp(static_cast<Instruction::BinaryOps>(Opc),
1642 Ops[0], Ops[1], Name, FPMathTag);
1645 assert(Ops.
size() == 1 &&
"Invalid number of operands!");
1646 return CreateUnOp(static_cast<Instruction::UnaryOps>(Opc),
1647 Ops[0], Name, FPMathTag);
1657 Value *ArraySize =
nullptr,
const Twine &Name =
"") {
1658 return Insert(
new AllocaInst(Ty, AddrSpace, ArraySize), Name);
1662 const Twine &Name =
"") {
1670 return Insert(
new LoadInst(Ty, Ptr), Name);
1674 return Insert(
new LoadInst(Ty, Ptr), Name);
1678 const Twine &Name =
"") {
1679 return Insert(
new LoadInst(Ty, Ptr,
Twine(), isVolatile), Name);
1709 return CreateAlignedLoad(Ty, Ptr,
MaybeAlign(Align), Name);
1713 LoadInst *LI = CreateLoad(Ty, Ptr, Name);
1720 const Twine &Name =
"") {
1721 return CreateAlignedLoad(Ty, Ptr,
MaybeAlign(Align), Name);
1724 const Twine &Name =
"") {
1725 LoadInst *LI = CreateLoad(Ty, Ptr, Name);
1733 return CreateAlignedLoad(Ty, Ptr,
MaybeAlign(Align), isVolatile, Name);
1737 LoadInst *LI = CreateLoad(Ty, Ptr, isVolatile, Name);
1749 const Twine &Name =
"") {
1755 const Twine &Name =
"") {
1766 const Twine &Name =
"") {
1772 const Twine &Name =
"") {
1785 return CreateAlignedStore(Val, Ptr, Align ? Align->value() : 0,
isVolatile);
1789 const Twine &Name =
"") {
1790 return Insert(
new FenceInst(Context, Ordering, SSID), Name);
1799 FailureOrdering, SSID));
1805 return Insert(
new AtomicRMWInst(Op, Ptr, Val, Ordering, SSID));
1809 const Twine &Name =
"") {
1810 return CreateGEP(
nullptr, Ptr, IdxList, Name);
1814 const Twine &Name =
"") {
1815 if (
auto *PC = dyn_cast<Constant>(Ptr)) {
1818 for (i = 0, e = IdxList.
size(); i !=
e; ++i)
1819 if (!isa<Constant>(IdxList[i]))
1822 return Insert(Folder.CreateGetElementPtr(Ty, PC, IdxList),
Name);
1828 const Twine &Name =
"") {
1829 return CreateInBoundsGEP(
nullptr, Ptr, IdxList, Name);
1833 const Twine &Name =
"") {
1834 if (
auto *PC = dyn_cast<Constant>(Ptr)) {
1837 for (i = 0, e = IdxList.
size(); i !=
e; ++i)
1838 if (!isa<Constant>(IdxList[i]))
1841 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IdxList),
1848 return CreateGEP(
nullptr, Ptr, Idx, Name);
1852 if (
auto *PC = dyn_cast<Constant>(Ptr))
1853 if (
auto *IC = dyn_cast<Constant>(Idx))
1854 return Insert(Folder.CreateGetElementPtr(Ty, PC, IC),
Name);
1859 const Twine &Name =
"") {
1860 if (
auto *PC = dyn_cast<Constant>(Ptr))
1861 if (
auto *IC = dyn_cast<Constant>(Idx))
1862 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IC),
Name);
1867 return CreateConstGEP1_32(
nullptr, Ptr, Idx0, Name);
1871 const Twine &Name =
"") {
1874 if (
auto *PC = dyn_cast<Constant>(Ptr))
1875 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idx),
Name);
1881 const Twine &Name =
"") {
1884 if (
auto *PC = dyn_cast<Constant>(Ptr))
1885 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idx),
Name);
1891 const Twine &Name =
"") {
1897 if (
auto *PC = dyn_cast<Constant>(Ptr))
1898 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idxs),
Name);
1904 unsigned Idx1,
const Twine &Name =
"") {
1910 if (
auto *PC = dyn_cast<Constant>(Ptr))
1911 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idxs),
Name);
1917 const Twine &Name =
"") {
1920 if (
auto *PC = dyn_cast<Constant>(Ptr))
1921 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idx),
Name);
1927 return CreateConstGEP1_64(
nullptr, Ptr, Idx0, Name);
1931 const Twine &Name =
"") {
1934 if (
auto *PC = dyn_cast<Constant>(Ptr))
1935 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idx),
Name);
1941 const Twine &Name =
"") {
1942 return CreateConstInBoundsGEP1_64(
nullptr, Ptr, Idx0, Name);
1946 const Twine &Name =
"") {
1952 if (
auto *PC = dyn_cast<Constant>(Ptr))
1953 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idxs),
Name);
1959 const Twine &Name =
"") {
1960 return CreateConstGEP2_64(
nullptr, Ptr, Idx0, Idx1, Name);
1964 uint64_t Idx1,
const Twine &Name =
"") {
1970 if (
auto *PC = dyn_cast<Constant>(Ptr))
1971 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idxs),
Name);
1977 const Twine &Name =
"") {
1978 return CreateConstInBoundsGEP2_64(
nullptr, Ptr, Idx0, Idx1, Name);
1982 const Twine &Name =
"") {
1983 return CreateConstInBoundsGEP2_32(Ty, Ptr, 0, Idx, Name);
1987 return CreateConstInBoundsGEP2_32(
nullptr, Ptr, 0, Idx, Name);
1996 Constant *Indices[] = {Zero, Zero};
2006 return CreateCast(Instruction::Trunc, V, DestTy, Name);
2010 return CreateCast(Instruction::ZExt, V, DestTy, Name);
2014 return CreateCast(Instruction::SExt, V, DestTy, Name);
2020 const Twine &Name =
"") {
2023 "Can only zero extend/truncate integers!");
2026 return CreateZExt(V, DestTy, Name);
2028 return CreateTrunc(V, DestTy, Name);
2035 const Twine &Name =
"") {
2038 "Can only sign extend/truncate integers!");
2041 return CreateSExt(V, DestTy, Name);
2043 return CreateTrunc(V, DestTy, Name);
2048 if (IsFPConstrained)
2049 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptoui,
2050 V, DestTy,
nullptr, Name);
2051 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
2055 if (IsFPConstrained)
2056 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptosi,
2057 V, DestTy,
nullptr, Name);
2058 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
2062 if (IsFPConstrained)
2063 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_uitofp,
2064 V, DestTy,
nullptr, Name);
2065 return CreateCast(Instruction::UIToFP, V, DestTy, Name);
2069 if (IsFPConstrained)
2070 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_sitofp,
2071 V, DestTy,
nullptr, Name);
2072 return CreateCast(Instruction::SIToFP, V, DestTy, Name);
2076 const Twine &Name =
"") {
2077 if (IsFPConstrained)
2078 return CreateConstrainedFPCast(
2079 Intrinsic::experimental_constrained_fptrunc, V, DestTy,
nullptr,
2081 return CreateCast(Instruction::FPTrunc, V, DestTy, Name);
2085 if (IsFPConstrained)
2086 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fpext,
2087 V, DestTy,
nullptr, Name);
2088 return CreateCast(Instruction::FPExt, V, DestTy, Name);
2092 const Twine &Name =
"") {
2093 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
2097 const Twine &Name =
"") {
2098 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
2102 const Twine &Name =
"") {
2103 return CreateCast(Instruction::BitCast, V, DestTy, Name);
2107 const Twine &Name =
"") {
2108 return CreateCast(Instruction::AddrSpaceCast, V, DestTy, Name);
2112 const Twine &Name =
"") {
2115 if (
auto *
VC = dyn_cast<Constant>(V))
2116 return Insert(Folder.CreateZExtOrBitCast(
VC, DestTy),
Name);
2121 const Twine &Name =
"") {
2124 if (
auto *
VC = dyn_cast<Constant>(V))
2125 return Insert(Folder.CreateSExtOrBitCast(
VC, DestTy),
Name);
2130 const Twine &Name =
"") {
2133 if (
auto *
VC = dyn_cast<Constant>(V))
2134 return Insert(Folder.CreateTruncOrBitCast(
VC, DestTy),
Name);
2139 const Twine &Name =
"") {
2142 if (
auto *
VC = dyn_cast<Constant>(V))
2143 return Insert(Folder.CreateCast(Op,
VC, DestTy),
Name);
2148 const Twine &Name =
"") {
2151 if (
auto *
VC = dyn_cast<Constant>(V))
2152 return Insert(Folder.CreatePointerCast(
VC, DestTy),
Name);
2157 const Twine &Name =
"") {
2161 if (
auto *
VC = dyn_cast<Constant>(V)) {
2162 return Insert(Folder.CreatePointerBitCastOrAddrSpaceCast(
VC, DestTy),
2171 const Twine &Name =
"") {
2174 if (
auto *
VC = dyn_cast<Constant>(V))
2175 return Insert(Folder.CreateIntCast(
VC, DestTy, isSigned),
Name);
2180 const Twine &Name =
"") {
2184 return CreatePtrToInt(V, DestTy, Name);
2186 return CreateIntToPtr(V, DestTy, Name);
2188 return CreateBitCast(V, DestTy, Name);
2194 if (
auto *
VC = dyn_cast<Constant>(V))
2195 return Insert(Folder.CreateFPCast(
VC, DestTy),
Name);
2202 MDNode *FPMathTag =
nullptr,
2205 Value *ExceptV = getConstrainedFPExcept(Except);
2209 UseFMF = FMFSource->getFastMathFlags();
2212 bool HasRoundingMD =
false;
2216 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ 2217 case Intrinsic::INTRINSIC: \ 2218 HasRoundingMD = ROUND_MODE; \ 2220 #include "llvm/IR/ConstrainedOps.def" 2222 if (HasRoundingMD) {
2223 Value *RoundingV = getConstrainedFPRounding(Rounding);
2224 C = CreateIntrinsic(ID, {DestTy, V->
getType()}, {V, RoundingV, ExceptV},
2227 C = CreateIntrinsic(ID, {DestTy, V->
getType()}, {V, ExceptV},
nullptr,
2230 setConstrainedFPCallAttr(C);
2232 if (isa<FPMathOperator>(C))
2233 setFPAttrs(C, FPMathTag, UseFMF);
2287 MDNode *FPMathTag =
nullptr) {
2292 MDNode *FPMathTag =
nullptr) {
2297 MDNode *FPMathTag =
nullptr) {
2302 MDNode *FPMathTag =
nullptr) {
2307 MDNode *FPMathTag =
nullptr) {
2312 MDNode *FPMathTag =
nullptr) {
2317 MDNode *FPMathTag =
nullptr) {
2322 MDNode *FPMathTag =
nullptr) {
2327 MDNode *FPMathTag =
nullptr) {
2332 MDNode *FPMathTag =
nullptr) {
2337 MDNode *FPMathTag =
nullptr) {
2342 MDNode *FPMathTag =
nullptr) {
2347 MDNode *FPMathTag =
nullptr) {
2352 MDNode *FPMathTag =
nullptr) {
2357 const Twine &Name =
"") {
2358 if (
auto *LC = dyn_cast<Constant>(LHS))
2359 if (
auto *RC = dyn_cast<Constant>(RHS))
2360 return Insert(Folder.CreateICmp(P, LC, RC),
Name);
2361 return Insert(
new ICmpInst(P, LHS, RHS), Name);
2368 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2369 if (IsFPConstrained)
2370 return CreateConstrainedFPCmp(Intrinsic::experimental_constrained_fcmp,
2373 if (
auto *LC = dyn_cast<Constant>(LHS))
2374 if (
auto *RC = dyn_cast<Constant>(RHS))
2375 return Insert(Folder.CreateFCmp(P, LC, RC),
Name);
2376 return Insert(setFPAttrs(
new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
2383 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2384 if (IsFPConstrained)
2385 return CreateConstrainedFPCmp(Intrinsic::experimental_constrained_fcmps,
2388 if (
auto *LC = dyn_cast<Constant>(LHS))
2389 if (
auto *RC = dyn_cast<Constant>(RHS))
2390 return Insert(Folder.CreateFCmp(P, LC, RC),
Name);
2391 return Insert(setFPAttrs(
new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
2396 const Twine &Name =
"",
2398 Value *PredicateV = getConstrainedFPPredicate(P);
2399 Value *ExceptV = getConstrainedFPExcept(Except);
2402 {L, R, PredicateV, ExceptV},
nullptr,
Name);
2403 setConstrainedFPCallAttr(C);
2412 const Twine &Name =
"") {
2414 if (isa<FPMathOperator>(Phi))
2415 setFPAttrs(Phi,
nullptr , FMF);
2416 return Insert(Phi, Name);
2421 MDNode *FPMathTag =
nullptr) {
2423 if (IsFPConstrained)
2424 setConstrainedFPCallAttr(CI);
2425 if (isa<FPMathOperator>(CI))
2426 setFPAttrs(CI, FPMathTag, FMF);
2427 return Insert(CI, Name);
2432 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2434 if (IsFPConstrained)
2435 setConstrainedFPCallAttr(CI);
2436 if (isa<FPMathOperator>(CI))
2437 setFPAttrs(CI, FPMathTag, FMF);
2438 return Insert(CI, Name);
2442 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2449 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2451 OpBundles,
Name, FPMathTag);
2456 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2459 Args, Name, FPMathTag);
2465 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
2468 Args, OpBundles, Name, FPMathTag);
2477 for (
auto *OneArg : Args)
2479 bool HasRoundingMD =
false;
2483 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ 2484 case Intrinsic::INTRINSIC: \ 2485 HasRoundingMD = ROUND_MODE; \ 2487 #include "llvm/IR/ConstrainedOps.def" 2490 UseArgs.
push_back(getConstrainedFPRounding(Rounding));
2491 UseArgs.
push_back(getConstrainedFPExcept(Except));
2493 CallInst *C = CreateCall(Callee, UseArgs, Name);
2494 setConstrainedFPCallAttr(C);
2500 if (
auto *CC = dyn_cast<Constant>(C))
2501 if (
auto *TC = dyn_cast<Constant>(True))
2502 if (
auto *
FC = dyn_cast<Constant>(False))
2503 return Insert(Folder.CreateSelect(CC, TC,
FC),
Name);
2507 MDNode *Prof = MDFrom->getMetadata(LLVMContext::MD_prof);
2508 MDNode *Unpred = MDFrom->getMetadata(LLVMContext::MD_unpredictable);
2509 Sel = addBranchMetadata(Sel, Prof, Unpred);
2511 if (isa<FPMathOperator>(Sel))
2512 setFPAttrs(Sel,
nullptr , FMF);
2513 return Insert(Sel, Name);
2517 return Insert(
new VAArgInst(List, Ty), Name);
2521 const Twine &Name =
"") {
2522 if (
auto *
VC = dyn_cast<Constant>(Vec))
2523 if (
auto *IC = dyn_cast<Constant>(Idx))
2524 return Insert(Folder.CreateExtractElement(
VC, IC),
Name);
2529 const Twine &Name =
"") {
2530 return CreateExtractElement(Vec, getInt64(Idx), Name);
2534 const Twine &Name =
"") {
2535 if (
auto *
VC = dyn_cast<Constant>(Vec))
2536 if (
auto *
NC = dyn_cast<Constant>(NewElt))
2537 if (
auto *IC = dyn_cast<Constant>(Idx))
2538 return Insert(Folder.CreateInsertElement(
VC,
NC, IC),
Name);
2543 const Twine &Name =
"") {
2544 return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
2548 const Twine &Name =
"") {
2549 if (
auto *V1C = dyn_cast<Constant>(V1))
2550 if (
auto *V2C = dyn_cast<Constant>(V2))
2551 if (
auto *MC = dyn_cast<Constant>(Mask))
2552 return Insert(Folder.CreateShuffleVector(V1C, V2C, MC),
Name);
2557 const Twine &Name =
"") {
2559 return CreateShuffleVector(V1, V2, Mask, Name);
2564 const Twine &Name =
"") {
2565 if (
auto *AggC = dyn_cast<Constant>(Agg))
2566 return Insert(Folder.CreateExtractValue(AggC, Idxs),
Name);
2572 const Twine &Name =
"") {
2573 if (
auto *AggC = dyn_cast<Constant>(Agg))
2574 if (
auto *ValC = dyn_cast<Constant>(Val))
2575 return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs),
Name);
2580 const Twine &Name =
"") {
2612 "Pointer subtraction operand types must match!");
2613 auto *ArgType = cast<PointerType>(LHS->
getType());
2616 Value *Difference = CreateSub(LHS_int, RHS_int);
2617 return CreateExactSDiv(Difference,
2627 "launder.invariant.group only applies to pointers.");
2629 auto *PtrType = Ptr->
getType();
2630 auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace());
2631 if (PtrType != Int8PtrTy)
2632 Ptr = CreateBitCast(Ptr, Int8PtrTy);
2635 M, Intrinsic::launder_invariant_group, {Int8PtrTy});
2640 "LaunderInvariantGroup should take and return the same type");
2642 CallInst *Fn = CreateCall(FnLaunderInvariantGroup, {Ptr});
2644 if (PtrType != Int8PtrTy)
2645 return CreateBitCast(Fn, PtrType);
2654 "strip.invariant.group only applies to pointers.");
2657 auto *PtrType = Ptr->
getType();
2658 auto *Int8PtrTy = getInt8PtrTy(PtrType->getPointerAddressSpace());
2659 if (PtrType != Int8PtrTy)
2660 Ptr = CreateBitCast(Ptr, Int8PtrTy);
2663 M, Intrinsic::strip_invariant_group, {Int8PtrTy});
2668 "StripInvariantGroup should take and return the same type");
2670 CallInst *Fn = CreateCall(FnStripInvariantGroup, {Ptr});
2672 if (PtrType != Int8PtrTy)
2673 return CreateBitCast(Fn, PtrType);
2680 assert(NumElts > 0 &&
"Cannot splat to an empty vector!");
2683 Type *I32Ty = getInt32Ty();
2686 Name +
".splatinsert");
2690 return CreateShuffleVector(V, Undef, Zeros, Name +
".splat");
2696 const Twine &Name) {
2697 auto *IntTy = cast<IntegerType>(From->
getType());
2700 "Element extends past full value");
2701 uint64_t ShAmt = 8 *
Offset;
2707 V = CreateLShr(V, ShAmt, Name +
".shift");
2710 "Cannot extract to a larger integer!");
2711 if (ExtractedTy != IntTy) {
2712 V = CreateTrunc(V, ExtractedTy, Name +
".trunc");
2718 unsigned Dimension,
unsigned LastIndex,
2721 "Invalid Base ptr type for preserve.array.access.index.");
2724 Value *LastIndexV = getInt32(LastIndex);
2727 for (
unsigned I = 0; I < Dimension; ++
I)
2736 M, Intrinsic::preserve_array_access_index, {ResultType,
BaseType});
2738 Value *DimV = getInt32(Dimension);
2740 CreateCall(FnPreserveArrayAccessIndex, {Base, DimV, LastIndexV});
2742 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
2750 "Invalid Base ptr type for preserve.union.access.index.");
2757 Value *DIIndex = getInt32(FieldIndex);
2759 CreateCall(FnPreserveUnionAccessIndex, {Base, DIIndex});
2761 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
2767 unsigned Index,
unsigned FieldIndex,
2770 "Invalid Base ptr type for preserve.struct.access.index.");
2773 Value *GEPIndex = getInt32(Index);
2780 M, Intrinsic::preserve_struct_access_index, {ResultType,
BaseType});
2782 Value *DIIndex = getInt32(FieldIndex);
2783 CallInst *Fn = CreateCall(FnPreserveStructAccessIndex,
2784 {Base, GEPIndex, DIIndex});
2786 Fn->
setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
2800 Value *PtrIntValue = CreatePtrToInt(PtrValue, IntPtrTy,
"ptrint");
2803 bool IsOffsetZero =
false;
2804 if (
const auto *CI = dyn_cast<ConstantInt>(OffsetValue))
2805 IsOffsetZero = CI->isZero();
2807 if (!IsOffsetZero) {
2808 if (OffsetValue->
getType() != IntPtrTy)
2809 OffsetValue = CreateIntCast(OffsetValue, IntPtrTy,
true,
2811 PtrIntValue = CreateSub(PtrIntValue, OffsetValue,
"offsetptr");
2816 Value *MaskedPtr = CreateAnd(PtrIntValue, Mask,
"maskedptr");
2817 Value *InvCond = CreateICmpEQ(MaskedPtr, Zero,
"maskcond");
2819 *TheCheck = InvCond;
2821 return CreateAssumption(InvCond);
2836 Value *OffsetValue =
nullptr,
2837 Value **TheCheck =
nullptr) {
2839 "trying to create an alignment assumption on a non-pointer?");
2840 assert(Alignment != 0 &&
"Invalid Alignment");
2841 auto *PtrTy = cast<PointerType>(PtrValue->
getType());
2842 Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
2845 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
2846 OffsetValue, TheCheck);
2863 Value *OffsetValue =
nullptr,
2864 Value **TheCheck =
nullptr) {
2866 "trying to create an alignment assumption on a non-pointer?");
2867 auto *PtrTy = cast<PointerType>(PtrValue->
getType());
2868 Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
2870 if (Alignment->
getType() != IntPtrTy)
2871 Alignment = CreateIntCast(Alignment, IntPtrTy,
false,
2876 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
2877 OffsetValue, TheCheck);
2886 #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="")
bool isFPPredicate() const
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="")
void setConstrainedFPFunctionAttr()
Common base class shared among various IRBuilders.
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.
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.
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock *> IndirectDests, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
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.
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.
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 MDString * get(LLVMContext &Context, StringRef Str)
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Value * CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool isSet() const
Returns true if this insert point is set.
ExceptionBehavior
Exception behavior used for floating point operations.
LoadInst * CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name="")
void push_back(const T &Elt)
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.
Value * CreateFreeze(Value *V, const Twine &Name="")
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 setConstrainedFPCallAttr(CallInst *I)
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)
RoundingMode
Rounding mode used for floating point operations.
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
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
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 * CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, unsigned Index, unsigned FieldIndex, MDNode *DbgInfo)
Value * CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
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.
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
LLVM_READONLY APFloat maximum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2018 maximum semantics.
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
Value * CreateShuffleVector(Value *V1, Value *V2, ArrayRef< uint32_t > IntMask, const Twine &Name="")
static IntegerType * getInt16Ty(LLVMContext &C)
CallInst * CreateConstrainedFPCast(Intrinsic::ID ID, Value *V, Type *DestTy, Instruction *FMFSource=nullptr, const Twine &Name="", MDNode *FPMathTag=nullptr, Optional< fp::RoundingMode > Rounding=None, Optional< fp::ExceptionBehavior > Except=None)
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock *> IndirectDests, ArrayRef< Value *> Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
Value * CreateFNegFMF(Value *V, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
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)
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, 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
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
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.
Value * CreateAnd(ArrayRef< Value *> Ops)
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.
LLVM_READONLY APFloat minimum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2018 minimum semantics.
LLVM_ATTRIBUTE_DEPRECATED(CallInst *CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Alignment, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr), "Use the version that takes Align instead of this one")
FIXME: Remove this function once transition to Align is over.
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.
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.
CallInst * CreateConstrainedFPBinOp(Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource=nullptr, const Twine &Name="", MDNode *FPMathTag=nullptr, Optional< fp::RoundingMode > Rounding=None, Optional< fp::ExceptionBehavior > Except=None)
CallBrInst * CreateCallBr(FunctionCallee Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock *> IndirectDests, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
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.
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Value * CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name="")
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
void setDefaultConstrainedExcept(fp::ExceptionBehavior NewExcept)
Set the exception handling to be used with constrained floating point.
BasicBlock * GetInsertBlock() const
const T & getValue() const LLVM_LVALUE_FUNCTION
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.
fp::RoundingMode DefaultConstrainedRounding
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)
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const Twine &Name="")
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateNAryOp(unsigned Opc, ArrayRef< Value *> Ops, const Twine &Name="", MDNode *FPMathTag=nullptr)
Create either a UnaryOperator or BinaryOperator depending on Opc.
IndirectBrInst * CreateIndirectBr(Value *Addr, unsigned NumDests=10)
Create an indirect branch instruction with the specified address operand, with an optional hint for t...
LLVM_ATTRIBUTE_DEPRECATED(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), "Use the version that takes MaybeAlign")
Create and insert a memmove between the specified pointers.
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.
CallBrInst * CreateCallBr(FunctionCallee Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock *> IndirectDests, ArrayRef< Value *> Args=None, const Twine &Name="")
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...
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.
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, bool isVolatile, const Twine &Name="")
The instances of the Type class are immutable: once they are created, they are never changed...
LLVM_ATTRIBUTE_DEPRECATED(CallInst *CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Alignment, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr), "Use the version that takes Align instead of this one")
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
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()
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)
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 * CreateOr(ArrayRef< Value *> Ops)
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)
static StringRef getPredicateName(Predicate P)
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="")
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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="")
FIXME: Remove this function once transition to Align is over.
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="")
FIXME: Remove this function once transition to Align is over.
self_iterator getIterator()
CallInst * CreateConstrainedFPCall(Function *Callee, ArrayRef< Value *> Args, const Twine &Name="", Optional< fp::RoundingMode > Rounding=None, Optional< fp::ExceptionBehavior > Except=None)
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)
Constant * Insert(Constant *C, const Twine &="") const
No-op overload to handle constants.
Optional< StringRef > ExceptionBehaviorToStr(fp::ExceptionBehavior)
For any ExceptionBehavior enumerator, returns a string valid as input in constrained intrinsic except...
1 1 1 1 Always true (always folded)
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.
static UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
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.
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
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
#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.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
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)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Value * CreateSRem(Value *LHS, Value *RHS, const Twine &Name="")
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
Value * CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Synchronized with respect to all concurrently executing threads.
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="")
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
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
#define LLVM_ATTRIBUTE_DEPRECATED(decl, message)
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 * CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, unsigned Dimension, unsigned LastIndex, MDNode *DbgInfo)
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...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
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="")
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
1 1 0 0 True if unordered or less than
Module.h This file contains the declarations for the Module class.
fp::ExceptionBehavior DefaultConstrainedExcept
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
void setAlignment(MaybeAlign Alignment)
This class represents a freeze function that returns random concrete value if an operand is either a ...
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="")
This corresponds to "fpround.dynamic".
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="")
fp::ExceptionBehavior getDefaultConstrainedExcept()
Get the exception handling used with constrained floating point.
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...
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock *> IndirectDests, ArrayRef< Value *> Args=None, const Twine &Name="")
Create a callbr instruction.
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.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
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="")
CallInst * CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, const Twine &Name="", Optional< fp::ExceptionBehavior > Except=None)
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...
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, Align Alignment, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
LLVM_ATTRIBUTE_DEPRECATED(CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, Value *Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr), "Use the version that takes MaybeAlign")
FIXME: Remove this function once transition to Align is over.
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)
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.
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
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.
LoadInst * CreateAlignedLoad(Value *Ptr, MaybeAlign Align, bool isVolatile, const Twine &Name="")
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 VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
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.
const Function * getParent() const
Return the enclosing method, or null if none.
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="")
Optional< StringRef > RoundingModeToStr(fp::RoundingMode)
For any RoundingMode enumerator, returns a string valid as input in constrained intrinsic rounding mo...
void setAlignment(MaybeAlign Alignment)
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
FunctionType * getFunctionType()
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)
void setIsFPConstrained(bool IsCon)
Enable/Disable use of constrained floating point math.
LoadInst * CreateAlignedLoad(Value *Ptr, MaybeAlign Align, const char *Name)
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
1 0 1 0 True if unordered or greater than
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const char *Name)
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...
LoadInst * CreateAlignedLoad(Value *Ptr, MaybeAlign Align, const Twine &Name="")
LLVM_ATTRIBUTE_DEPRECATED(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), "Use the version that takes MaybeAlign instead")
Create and insert a memcpy between the specified pointers.
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.
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
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 Constant * foldConstant(Instruction::UnaryOps Opcode, Value *&Op, const SimplifyQuery &Q)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore=nullptr)
0 0 0 1 True if ordered and equal
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
This corresponds to "fpexcept.strict".
1 0 1 1 True if unordered, greater than, or equal
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.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
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="")
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
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="")
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value *> Args=None, 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="")
fp::RoundingMode getDefaultConstrainedRounding()
Get the rounding mode handling used with constrained floating point.
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFCmpS(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
static Type * getGEPReturnType(Type *ElTy, Value *Ptr, ArrayRef< Value *> IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers...
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)
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
Value * CreateOr(Value *LHS, const APInt &RHS, const Twine &Name="")
0 0 0 0 Always false (always folded)
bool empty() const
empty - Check if the array is empty.
void setDefaultConstrainedRounding(fp::RoundingMode NewRounding)
Set the rounding mode handling to be used with constrained floating point.
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)
bool getIsFPConstrained()
Query for the use of constrained floating point math.
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign 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.
Value * CreateStructGEP(Value *Ptr, unsigned Idx, const Twine &Name="")