15 #ifndef LLVM_IR_IRBUILDER_H
16 #define LLVM_IR_IRBUILDER_H
75 std::function<void(Instruction *)> Callback;
79 : Callback(std::move(Callback)) {}
147 if (IP != TheBB->
end())
179 : Block(InsertBlock), Point(InsertPoint) {}
182 bool isSet()
const {
return (Block !=
nullptr); }
407 MDNode *ScopeTag =
nullptr,
408 MDNode *NoAliasTag =
nullptr) {
410 TBAATag, ScopeTag, NoAliasTag);
415 MDNode *ScopeTag =
nullptr,
416 MDNode *NoAliasTag =
nullptr);
425 MDNode *TBAAStructTag =
nullptr,
426 MDNode *ScopeTag =
nullptr,
427 MDNode *NoAliasTag =
nullptr) {
429 TBAAStructTag, ScopeTag, NoAliasTag);
434 MDNode *TBAAStructTag =
nullptr,
435 MDNode *ScopeTag =
nullptr,
436 MDNode *NoAliasTag =
nullptr);
446 MDNode *TBAATag =
nullptr,
MDNode *TBAAStructTag =
nullptr,
447 MDNode *ScopeTag =
nullptr,
MDNode *NoAliasTag =
nullptr) {
449 Dst, Src,
getInt64(Size), ElementSize, TBAATag, TBAAStructTag, ScopeTag,
455 MDNode *TBAATag =
nullptr,
MDNode *TBAAStructTag =
nullptr,
456 MDNode *ScopeTag =
nullptr,
MDNode *NoAliasTag =
nullptr);
466 MDNode *ScopeTag =
nullptr,
467 MDNode *NoAliasTag =
nullptr) {
469 TBAATag, ScopeTag, NoAliasTag);
474 MDNode *ScopeTag =
nullptr,
475 MDNode *NoAliasTag =
nullptr);
542 Value *PassThru =
nullptr,
662 template <
typename T = ConstantFolder,
663 typename Inserter = IRBuilderDefaultInserter>
669 MDNode *FPMathTag =
nullptr,
697 MDNode *FPMathTag =
nullptr,
704 MDNode *FPMathTag =
nullptr,
714 template<
typename InstTy>
734 template <
typename InstTy>
735 InstTy *addBranchMetadata(InstTy *
I,
MDNode *Weights,
MDNode *Unpredictable) {
763 for (
unsigned i = 0; i !=
N; ++i)
776 MDNode *BranchWeights =
nullptr,
777 MDNode *Unpredictable =
nullptr) {
779 BranchWeights, Unpredictable));
799 MDNode *BranchWeights =
nullptr,
800 MDNode *Unpredictable =
nullptr) {
802 BranchWeights, Unpredictable));
838 unsigned NumHandlers,
870 bool HasNUW,
bool HasNSW) {
877 Instruction *AddFPMathAttributes(Instruction *I,
879 FastMathFlags
FMF)
const {
884 I->setFastMathFlags(FMF);
890 bool HasNUW =
false,
bool HasNSW =
false) {
891 if (
Constant *LC = dyn_cast<Constant>(LHS))
892 if (
Constant *RC = dyn_cast<Constant>(RHS))
893 return Insert(Folder.CreateAdd(LC, RC, HasNUW, HasNSW),
Name);
898 return CreateAdd(LHS, RHS, Name,
false,
true);
901 return CreateAdd(LHS, RHS, Name,
true,
false);
904 MDNode *FPMathTag =
nullptr) {
905 if (
Constant *LC = dyn_cast<Constant>(LHS))
906 if (
Constant *RC = dyn_cast<Constant>(RHS))
907 return Insert(Folder.CreateFAdd(LC, RC),
Name);
908 return Insert(AddFPMathAttributes(BinaryOperator::CreateFAdd(LHS, RHS),
909 FPMathTag, FMF), Name);
912 bool HasNUW =
false,
bool HasNSW =
false) {
913 if (
Constant *LC = dyn_cast<Constant>(LHS))
914 if (
Constant *RC = dyn_cast<Constant>(RHS))
915 return Insert(Folder.CreateSub(LC, RC, HasNUW, HasNSW),
Name);
916 return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name,
920 return CreateSub(LHS, RHS, Name,
false,
true);
923 return CreateSub(LHS, RHS, Name,
true,
false);
926 MDNode *FPMathTag =
nullptr) {
927 if (
Constant *LC = dyn_cast<Constant>(LHS))
928 if (
Constant *RC = dyn_cast<Constant>(RHS))
929 return Insert(Folder.CreateFSub(LC, RC),
Name);
930 return Insert(AddFPMathAttributes(BinaryOperator::CreateFSub(LHS, RHS),
931 FPMathTag, FMF), Name);
934 bool HasNUW =
false,
bool HasNSW =
false) {
935 if (
Constant *LC = dyn_cast<Constant>(LHS))
936 if (
Constant *RC = dyn_cast<Constant>(RHS))
937 return Insert(Folder.CreateMul(LC, RC, HasNUW, HasNSW),
Name);
938 return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name,
942 return CreateMul(LHS, RHS, Name,
false,
true);
945 return CreateMul(LHS, RHS, Name,
true,
false);
948 MDNode *FPMathTag =
nullptr) {
949 if (
Constant *LC = dyn_cast<Constant>(LHS))
950 if (
Constant *RC = dyn_cast<Constant>(RHS))
951 return Insert(Folder.CreateFMul(LC, RC),
Name);
952 return Insert(AddFPMathAttributes(BinaryOperator::CreateFMul(LHS, RHS),
953 FPMathTag, FMF), Name);
956 bool isExact =
false) {
957 if (
Constant *LC = dyn_cast<Constant>(LHS))
958 if (
Constant *RC = dyn_cast<Constant>(RHS))
959 return Insert(Folder.CreateUDiv(LC, RC, isExact),
Name);
961 return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
962 return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
968 bool isExact =
false) {
969 if (
Constant *LC = dyn_cast<Constant>(LHS))
970 if (
Constant *RC = dyn_cast<Constant>(RHS))
971 return Insert(Folder.CreateSDiv(LC, RC, isExact),
Name);
973 return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
974 return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
980 MDNode *FPMathTag =
nullptr) {
981 if (
Constant *LC = dyn_cast<Constant>(LHS))
982 if (
Constant *RC = dyn_cast<Constant>(RHS))
983 return Insert(Folder.CreateFDiv(LC, RC),
Name);
984 return Insert(AddFPMathAttributes(BinaryOperator::CreateFDiv(LHS, RHS),
985 FPMathTag, FMF), Name);
988 if (
Constant *LC = dyn_cast<Constant>(LHS))
989 if (
Constant *RC = dyn_cast<Constant>(RHS))
990 return Insert(Folder.CreateURem(LC, RC),
Name);
991 return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
994 if (
Constant *LC = dyn_cast<Constant>(LHS))
995 if (
Constant *RC = dyn_cast<Constant>(RHS))
996 return Insert(Folder.CreateSRem(LC, RC),
Name);
997 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
1000 MDNode *FPMathTag =
nullptr) {
1001 if (
Constant *LC = dyn_cast<Constant>(LHS))
1002 if (
Constant *RC = dyn_cast<Constant>(RHS))
1003 return Insert(Folder.CreateFRem(LC, RC),
Name);
1004 return Insert(AddFPMathAttributes(BinaryOperator::CreateFRem(LHS, RHS),
1005 FPMathTag, FMF), Name);
1009 bool HasNUW =
false,
bool HasNSW =
false) {
1010 if (
Constant *LC = dyn_cast<Constant>(LHS))
1011 if (
Constant *RC = dyn_cast<Constant>(RHS))
1012 return Insert(Folder.CreateShl(LC, RC, HasNUW, HasNSW),
Name);
1013 return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
1017 bool HasNUW =
false,
bool HasNSW =
false) {
1022 bool HasNUW =
false,
bool HasNSW =
false) {
1028 bool isExact =
false) {
1029 if (
Constant *LC = dyn_cast<Constant>(LHS))
1030 if (
Constant *RC = dyn_cast<Constant>(RHS))
1031 return Insert(Folder.CreateLShr(LC, RC, isExact),
Name);
1033 return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
1034 return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
1037 bool isExact =
false) {
1041 bool isExact =
false) {
1046 bool isExact =
false) {
1047 if (
Constant *LC = dyn_cast<Constant>(LHS))
1048 if (
Constant *RC = dyn_cast<Constant>(RHS))
1049 return Insert(Folder.CreateAShr(LC, RC, isExact),
Name);
1051 return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
1052 return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
1055 bool isExact =
false) {
1059 bool isExact =
false) {
1064 if (
Constant *RC = dyn_cast<Constant>(RHS)) {
1065 if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isMinusOne())
1067 if (
Constant *LC = dyn_cast<Constant>(LHS))
1068 return Insert(Folder.CreateAnd(LC, RC),
Name);
1070 return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
1080 if (
Constant *RC = dyn_cast<Constant>(RHS)) {
1081 if (RC->isNullValue())
1083 if (
Constant *LC = dyn_cast<Constant>(LHS))
1084 return Insert(Folder.CreateOr(LC, RC),
Name);
1086 return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
1096 if (
Constant *LC = dyn_cast<Constant>(LHS))
1097 if (
Constant *RC = dyn_cast<Constant>(RHS))
1098 return Insert(Folder.CreateXor(LC, RC),
Name);
1099 return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
1110 MDNode *FPMathTag =
nullptr) {
1111 if (
Constant *LC = dyn_cast<Constant>(LHS))
1112 if (
Constant *RC = dyn_cast<Constant>(RHS))
1113 return Insert(Folder.CreateBinOp(Opc, LC, RC),
Name);
1115 if (isa<FPMathOperator>(BinOp))
1116 BinOp = AddFPMathAttributes(BinOp, FPMathTag, FMF);
1117 return Insert(BinOp, Name);
1121 bool HasNUW =
false,
bool HasNSW =
false) {
1123 return Insert(Folder.CreateNeg(
VC, HasNUW, HasNSW),
Name);
1125 if (HasNUW) BO->setHasNoUnsignedWrap();
1126 if (HasNSW) BO->setHasNoSignedWrap();
1136 MDNode *FPMathTag =
nullptr) {
1140 FPMathTag, FMF), Name);
1153 Value *ArraySize =
nullptr,
const Twine &Name =
"") {
1158 const Twine &Name =
"") {
1188 const Twine &Name =
"") {
1194 const Twine &Name =
"") {
1207 const Twine &Name =
"") {
1216 FailureOrdering, SSID));
1224 const Twine &Name =
"") {
1225 return CreateGEP(
nullptr, Ptr, IdxList, Name);
1228 const Twine &Name =
"") {
1229 if (
Constant *PC = dyn_cast<Constant>(Ptr)) {
1232 for (i = 0, e = IdxList.
size(); i != e; ++i)
1233 if (!isa<Constant>(IdxList[i]))
1236 return Insert(Folder.CreateGetElementPtr(Ty, PC, IdxList),
Name);
1241 const Twine &Name =
"") {
1245 const Twine &Name =
"") {
1246 if (
Constant *PC = dyn_cast<Constant>(Ptr)) {
1249 for (i = 0, e = IdxList.
size(); i != e; ++i)
1250 if (!isa<Constant>(IdxList[i]))
1253 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IdxList),
1259 return CreateGEP(
nullptr, Ptr, Idx, Name);
1262 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1263 if (
Constant *IC = dyn_cast<Constant>(Idx))
1264 return Insert(Folder.CreateGetElementPtr(Ty, PC, IC),
Name);
1268 const Twine &Name =
"") {
1269 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1270 if (
Constant *IC = dyn_cast<Constant>(Idx))
1271 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IC),
Name);
1278 const Twine &Name =
"") {
1281 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1282 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idx),
Name);
1287 const Twine &Name =
"") {
1290 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1291 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idx),
Name);
1296 const Twine &Name =
"") {
1302 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1303 return Insert(Folder.CreateGetElementPtr(Ty, PC, Idxs),
Name);
1308 unsigned Idx1,
const Twine &Name =
"") {
1314 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1315 return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, Idxs),
Name);
1322 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1323 return Insert(Folder.CreateGetElementPtr(
nullptr, PC, Idx),
Name);
1328 const Twine &Name =
"") {
1331 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1332 return Insert(Folder.CreateInBoundsGetElementPtr(
nullptr, PC, Idx),
Name);
1337 const Twine &Name =
"") {
1343 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1344 return Insert(Folder.CreateGetElementPtr(
nullptr, PC, Idxs),
Name);
1349 const Twine &Name =
"") {
1355 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1356 return Insert(Folder.CreateInBoundsGetElementPtr(
nullptr, PC, Idxs),
1362 const Twine &Name =
"") {
1381 return CreateCast(Instruction::Trunc, V, DestTy, Name);
1384 return CreateCast(Instruction::ZExt, V, DestTy, Name);
1387 return CreateCast(Instruction::SExt, V, DestTy, Name);
1392 const Twine &Name =
"") {
1395 "Can only zero extend/truncate integers!");
1406 const Twine &Name =
"") {
1409 "Can only sign extend/truncate integers!");
1418 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
1421 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
1424 return CreateCast(Instruction::UIToFP, V, DestTy, Name);
1427 return CreateCast(Instruction::SIToFP, V, DestTy, Name);
1430 const Twine &Name =
"") {
1431 return CreateCast(Instruction::FPTrunc, V, DestTy, Name);
1434 return CreateCast(Instruction::FPExt, V, DestTy, Name);
1437 const Twine &Name =
"") {
1438 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
1441 const Twine &Name =
"") {
1442 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
1445 const Twine &Name =
"") {
1446 return CreateCast(Instruction::BitCast, V, DestTy, Name);
1449 const Twine &Name =
"") {
1450 return CreateCast(Instruction::AddrSpaceCast, V, DestTy, Name);
1453 const Twine &Name =
"") {
1457 return Insert(Folder.CreateZExtOrBitCast(
VC, DestTy),
Name);
1461 const Twine &Name =
"") {
1465 return Insert(Folder.CreateSExtOrBitCast(
VC, DestTy),
Name);
1469 const Twine &Name =
"") {
1473 return Insert(Folder.CreateTruncOrBitCast(
VC, DestTy),
Name);
1477 const Twine &Name =
"") {
1481 return Insert(Folder.CreateCast(Op,
VC, DestTy),
Name);
1485 const Twine &Name =
"") {
1489 return Insert(Folder.CreatePointerCast(
VC, DestTy),
Name);
1494 const Twine &Name =
"") {
1499 return Insert(Folder.CreatePointerBitCastOrAddrSpaceCast(
VC, DestTy),
1508 const Twine &Name =
"") {
1512 return Insert(Folder.CreateIntCast(
VC, DestTy, isSigned),
Name);
1517 const Twine &Name =
"") {
1578 MDNode *FPMathTag =
nullptr) {
1582 MDNode *FPMathTag =
nullptr) {
1586 MDNode *FPMathTag =
nullptr) {
1590 MDNode *FPMathTag =
nullptr) {
1594 MDNode *FPMathTag =
nullptr) {
1598 MDNode *FPMathTag =
nullptr) {
1602 MDNode *FPMathTag =
nullptr) {
1606 MDNode *FPMathTag =
nullptr) {
1610 MDNode *FPMathTag =
nullptr) {
1614 MDNode *FPMathTag =
nullptr) {
1618 MDNode *FPMathTag =
nullptr) {
1622 MDNode *FPMathTag =
nullptr) {
1626 MDNode *FPMathTag =
nullptr) {
1630 MDNode *FPMathTag =
nullptr) {
1635 const Twine &Name =
"") {
1636 if (
Constant *LC = dyn_cast<Constant>(LHS))
1637 if (
Constant *RC = dyn_cast<Constant>(RHS))
1638 return Insert(Folder.CreateICmp(P, LC, RC),
Name);
1642 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
1643 if (
Constant *LC = dyn_cast<Constant>(LHS))
1644 if (
Constant *RC = dyn_cast<Constant>(RHS))
1645 return Insert(Folder.CreateFCmp(P, LC, RC),
Name);
1647 FPMathTag, FMF), Name);
1655 const Twine &Name =
"") {
1660 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
1668 MDNode *FPMathTag =
nullptr) {
1670 if (isa<FPMathOperator>(CI))
1671 CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
1677 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
1679 if (isa<FPMathOperator>(CI))
1680 CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
1685 const Twine &Name =
"",
MDNode *FPMathTag =
nullptr) {
1691 if (
Constant *CC = dyn_cast<Constant>(C))
1692 if (
Constant *TC = dyn_cast<Constant>(True))
1693 if (
Constant *
FC = dyn_cast<Constant>(False))
1700 Sel = addBranchMetadata(Sel, Prof, Unpred);
1702 return Insert(Sel, Name);
1710 const Twine &Name =
"") {
1712 if (
Constant *IC = dyn_cast<Constant>(Idx))
1713 return Insert(Folder.CreateExtractElement(
VC, IC),
Name);
1718 const Twine &Name =
"") {
1723 const Twine &Name =
"") {
1725 if (
Constant *
NC = dyn_cast<Constant>(NewElt))
1726 if (
Constant *IC = dyn_cast<Constant>(Idx))
1732 const Twine &Name =
"") {
1737 const Twine &Name =
"") {
1738 if (
Constant *V1C = dyn_cast<Constant>(V1))
1739 if (
Constant *V2C = dyn_cast<Constant>(V2))
1740 if (
Constant *MC = dyn_cast<Constant>(Mask))
1741 return Insert(Folder.CreateShuffleVector(V1C, V2C, MC),
Name);
1746 const Twine &Name =
"") {
1753 const Twine &Name =
"") {
1754 if (
Constant *AggC = dyn_cast<Constant>(Agg))
1755 return Insert(Folder.CreateExtractValue(AggC, Idxs),
Name);
1761 const Twine &Name =
"") {
1762 if (
Constant *AggC = dyn_cast<Constant>(Agg))
1763 if (
Constant *ValC = dyn_cast<Constant>(Val))
1764 return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs),
Name);
1769 const Twine &Name =
"") {
1797 "Pointer subtraction operand types must match!");
1814 Intrinsic::invariant_group_barrier);
1817 assert(ArgumentAndReturnType ==
1819 "InvariantGroupBarrier should take and return the same type");
1822 bool PtrTypeConversionNeeded = PtrType != ArgumentAndReturnType;
1823 if (PtrTypeConversionNeeded)
1828 if (PtrTypeConversionNeeded)
1836 assert(NumElts > 0 &&
"Cannot splat to an empty vector!");
1842 Name +
".splatinsert");
1852 const Twine &Name) {
1856 "Element extends past full value");
1857 uint64_t ShAmt = 8 *
Offset;
1866 "Cannot extract to a larger integer!");
1867 if (ExtractedTy != IntTy) {
1880 Value *OffsetValue) {
1884 bool IsOffsetZero =
false;
1885 if (
ConstantInt *CI = dyn_cast<ConstantInt>(OffsetValue))
1886 IsOffsetZero = CI->isZero();
1888 if (!IsOffsetZero) {
1889 if (OffsetValue->
getType() != IntPtrTy)
1892 PtrIntValue =
CreateSub(PtrIntValue, OffsetValue,
"offsetptr");
1897 Value *MaskedPtr =
CreateAnd(PtrIntValue, Mask,
"maskedptr");
1898 Value *InvCond =
CreateICmpEQ(MaskedPtr, Zero,
"maskcond");
1911 Value *OffsetValue =
nullptr) {
1913 "trying to create an alignment assumption on a non-pointer?");
1918 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
1933 Value *OffsetValue =
nullptr) {
1935 "trying to create an alignment assumption on a non-pointer?");
1939 if (Alignment->
getType() != IntPtrTy)
1945 Value *PositiveMask =
1950 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
1960 #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="")
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. ...
static ConstantInt * getFalse(LLVMContext &Context)
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="")
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
BasicBlock::iterator GetInsertPoint() const
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="")
CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
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.
Value * CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
A Module instance is used to store all the information related to an LLVM module. ...
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=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.
Value * CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
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.
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
CallInst * CreateGCRelocate(Instruction *Statepoint, int BaseOffset, int DerivedOffset, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.relocate intrinsics to project the relocated value of one pointe...
Type * getValueType() const
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="")
BasicBlock * getBlock() const
IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
0 1 0 0 True if ordered and less than
FastMathFlagGuard & operator=(const FastMathFlagGuard &)=delete
InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > InvokeArgs, ArrayRef< Value * > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
brief Create an invoke to the experimental.gc.statepoint intrinsic to start a new statepoint sequence...
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)
Constant * Insert(Constant *C, const Twine &="") const
No-op overload to handle constants.
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
1 1 1 0 True if unordered or not equal
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args=None, const Twine &Name="")
Create an invoke instruction.
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
const Function * getParent() const
Return the enclosing method, or null if none.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
CatchPadInst * CreateCatchPad(Value *ParentPad, ArrayRef< Value * > Args, 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.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
An instruction for reading from memory.
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
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="")
Type * getElementType() const
Value * CreateShuffleVector(Value *V1, Value *V2, ArrayRef< uint32_t > IntMask, const Twine &Name="")
static IntegerType * getInt16Ty(LLVMContext &C)
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, Value *Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer...
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 * 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 * CreateFSub(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateOr(Value *LHS, uint64_t RHS, const Twine &Name="")
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="")
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)
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
This class represents the LLVM 'select' instruction.
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.
CallInst * CreateCall(Function *Callee, ArrayRef< Value * > Args, const Twine &Name="", MDNode *FPMathTag=nullptr)
CallInst * CreateFAddReduce(Value *Acc, Value *Src)
Create a vector fadd reduction intrinsic of the source vector.
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
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, unsigned Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer...
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.
CallInst * CreateMaskedGather(Value *Ptrs, unsigned Align, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
Type * getVoidTy()
Fetch the type representing void.
AtomicOrdering
Atomic ordering for LLVM's memory model.
CatchReturnInst * CreateCatchRet(CatchPadInst *CatchPad, BasicBlock *BB)
CallInst * CreateFPMinReduce(Value *Src, bool NoNaN=false)
Create a vector float min reduction intrinsic of the source vector.
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.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
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.
InsertPoint saveIP() const
Returns the current insert point.
BasicBlock::iterator getPoint() const
Value * 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...
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
This instruction compares its operands according to the predicate given to the constructor.
CallInst * CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
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)...
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID=SyncScope::System)
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
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.
MDNode * getDefaultFPMathTag() const
Get the floating point math metadata being used.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
IRBuilder(LLVMContext &C, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=None)
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
size_t size() const
size - Get the array size.
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="")
CallInst * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
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(Value *Ptr, const char *Name)
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Type * getParamType(unsigned i) const
Parameter type accessors.
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...
IntegerType * getInt128Ty()
Fetch the type representing a 128-bit integer.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
InsertPointGuard & operator=(const InsertPointGuard &)=delete
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
InsertPoint()=default
Creates a new insertion point which doesn't point to anything.
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...
This is an important class for using LLVM in a threaded context.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
ConstantInt * getTrue()
Get the constant value for i1 true.
UnreachableInst * CreateUnreachable()
Conditional or Unconditional Branch instruction.
CleanupPadInst * CreateCleanupPad(Value *ParentPad, ArrayRef< Value * > Args=None, const Twine &Name="")
This function has undefined behavior.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
This is an important base class in LLVM.
Resume the propagation of an exception.
Value * CreateShl(Value *LHS, const APInt &RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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)
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Value * CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
CallInst * CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, ArrayRef< Value * > CallArgs, ArrayRef< Value * > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create a call to the experimental.gc.statepoint intrinsic to start a new statepoint sequence...
unsigned getAllocaAddrSpace() const
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
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="")
const InstListType & getInstList() const
Return the underlying instruction list container.
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)
Value * CreateFRem(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, const Twine &Name="", MDNode *FPMathTag=nullptr)
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.
void clearFastMathFlags()
Clear the fast-math flags.
Value * CreateICmpEQ(Value *LHS, Value *RHS, 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)
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.
LLVMContext & getContext() const
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.
Value * CreateInvariantGroupBarrier(Value *Ptr)
Create an invariant.group.barrier intrinsic call, that stops optimizer to propagate equality using in...
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.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
1 1 0 1 True if unordered, less than, or equal
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="")
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
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="")
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
This provides the default implementation of the IRBuilder 'InsertHelper' method that is called whenev...
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &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...
Value * CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
0 0 1 0 True if ordered and greater than
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.end intrinsic.
static BinaryOperator * CreateFNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
static Type * getHalfTy(LLVMContext &C)
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.
Synchronized with respect to all concurrently executing threads.
Iterator for intrusive lists based on ilist_node.
CallInst * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
Value * CreateFAdd(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
This is the shared class of boolean and integer constants.
ResumeInst * CreateResume(Value *Exn)
InsertPoint - A saved insertion point.
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
CallInst * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Make a new global variable with initializer type i8*.
CallInst * CreateAssumption(Value *Cond)
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
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...
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Value * CreateNUWNeg(Value *V, const Twine &Name="")
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
1 1 0 0 True if unordered or less than
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
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)
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, unsigned Align, Value *Mask)
Create a call to Masked Store intrinsic.
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)
BasicBlock * GetInsertBlock() const
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
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...
CallInst * CreateFMulReduce(Value *Acc, Value *Src)
Create a vector fmul reduction intrinsic of the source vector.
CallInst * CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
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.
ArrayRef< OperandBundleDef > DefaultOperandBundles
Value * CreateFPCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name="")
Value * CreateGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Class for arbitrary precision integers.
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="")
const DebugLoc & getCurrentDebugLocation() const
Get location information used by debugging information.
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="")
void clear()
Set all the flags to false.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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="")
static std::vector< std::string > Flags
Value * CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name="")
CallInst * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
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="")
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
CallInst * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
Provides an 'InsertHelper' that calls a user-provided callback after performing the default insertion...
CallInst * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type. ...
CallInst * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
iterator insert(iterator where, pointer New)
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
CallInst * CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align, 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 IntegerType * getInt32Ty(LLVMContext &C)
Value * CreateInBoundsGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
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.
unsigned greater or equal
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
CleanupReturnInst * CreateCleanupRet(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB=nullptr)
CallInst * CreateGCResult(Instruction *Statepoint, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.result intrinsic to extract the result from a call wrapped in a ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
CallInst * CreateCall(Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
0 1 1 0 True if ordered and operands are unequal
Value * CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
CallInst * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
void setDefaultFPMathTag(MDNode *FPMathTag)
Set the floating point math metadata to be used.
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
1 0 1 0 True if unordered or greater than
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="")
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nsw 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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, unsigned Align, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
ReturnInst * CreateAggregateRet(Value *const *retVals, unsigned N)
Create a sequence of N insertvalue instructions, with one Value from the retVals array each...
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
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
void setAlignment(unsigned Align)
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.
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.
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 setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
FastMathFlags getFastMathFlags() const
Get the flags to be applied to created floating point ops.
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
bool isSet() const
Returns true if this insert point is set.
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
Value * CreateFDiv(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
print Print MemDeps of function
CallInst * CreateLifetimeStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.start intrinsic.
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)
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...
CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, Value *Src, 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.
CallInst * CreateFPMaxReduce(Value *Src, bool NoNaN=false)
Create a vector float max reduction intrinsic of the source vector.
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.
Value * CreateFMul(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
CallInst * CreateCall(Value *Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
0 0 1 1 True if ordered and greater than or equal
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
static IntegerType * getInt8Ty(LLVMContext &C)
BasicBlock::iterator InsertPt
const BasicBlock * getParent() const
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="")
an instruction to allocate memory on the stack
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
Value * CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)