15 #ifndef LLVM_IR_IRBUILDER_H
16 #define LLVM_IR_IRBUILDER_H
38 template <
bool preserveNames = true>
93 assert(I !=
BB->
end() &&
"Can't read debug loc from end()");
108 if (
PHINode *Phi = dyn_cast<PHINode>(UseInst)) {
109 BasicBlock *PredBB = Phi->getIncomingBlock(U);
110 assert(U != PredBB->
getTerminator() &&
"critical edge not split");
147 : Block(InsertBlock), Point(InsertPoint) {}
150 bool isSet()
const {
return (Block != 0); }
354 bool isVolatile =
false,
MDNode *TBAATag = 0) {
359 bool isVolatile =
false,
MDNode *TBAATag = 0);
366 bool isVolatile =
false,
MDNode *TBAATag = 0,
367 MDNode *TBAAStructTag = 0) {
373 bool isVolatile =
false,
MDNode *TBAATag = 0,
374 MDNode *TBAAStructTag = 0);
382 bool isVolatile =
false,
MDNode *TBAATag = 0) {
387 bool isVolatile =
false,
MDNode *TBAATag = 0);
419 template<
bool preserveNames =
true,
typename T = ConstantFolder,
420 typename Inserter = IRBuilderDefaultInserter<preserveNames> >
474 template<
typename InstTy>
493 template <
typename InstTy>
494 InstTy *addBranchWeights(InstTy *
I,
MDNode *Weights) {
520 for (
unsigned i = 0; i !=
N; ++i)
533 MDNode *BranchWeights = 0) {
542 MDNode *BranchWeights = 0) {
570 Value *Args[] = { Arg1, Arg2, Arg3 };
597 bool HasNUW,
bool HasNSW) {
604 Instruction *AddFPMathAttributes(Instruction *I,
606 FastMathFlags
FMF)
const {
611 I->setFastMathFlags(FMF);
616 bool HasNUW =
false,
bool HasNSW =
false) {
617 if (
Constant *LC = dyn_cast<Constant>(LHS))
618 if (
Constant *RC = dyn_cast<Constant>(RHS))
619 return Insert(Folder.CreateAdd(LC, RC, HasNUW, HasNSW),
Name);
620 return CreateInsertNUWNSWBinOp(Instruction::Add, LHS, RHS, Name,
624 return CreateAdd(LHS, RHS, Name,
false,
true);
627 return CreateAdd(LHS, RHS, Name,
true,
false);
631 if (
Constant *LC = dyn_cast<Constant>(LHS))
632 if (
Constant *RC = dyn_cast<Constant>(RHS))
633 return Insert(Folder.CreateFAdd(LC, RC),
Name);
634 return Insert(AddFPMathAttributes(BinaryOperator::CreateFAdd(LHS, RHS),
635 FPMathTag, FMF), Name);
638 bool HasNUW =
false,
bool HasNSW =
false) {
639 if (
Constant *LC = dyn_cast<Constant>(LHS))
640 if (
Constant *RC = dyn_cast<Constant>(RHS))
641 return Insert(Folder.CreateSub(LC, RC),
Name);
642 return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name,
646 return CreateSub(LHS, RHS, Name,
false,
true);
649 return CreateSub(LHS, RHS, Name,
true,
false);
653 if (
Constant *LC = dyn_cast<Constant>(LHS))
654 if (
Constant *RC = dyn_cast<Constant>(RHS))
655 return Insert(Folder.CreateFSub(LC, RC),
Name);
656 return Insert(AddFPMathAttributes(BinaryOperator::CreateFSub(LHS, RHS),
657 FPMathTag, FMF), Name);
660 bool HasNUW =
false,
bool HasNSW =
false) {
661 if (
Constant *LC = dyn_cast<Constant>(LHS))
662 if (
Constant *RC = dyn_cast<Constant>(RHS))
663 return Insert(Folder.CreateMul(LC, RC),
Name);
664 return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name,
668 return CreateMul(LHS, RHS, Name,
false,
true);
671 return CreateMul(LHS, RHS, Name,
true,
false);
675 if (
Constant *LC = dyn_cast<Constant>(LHS))
676 if (
Constant *RC = dyn_cast<Constant>(RHS))
677 return Insert(Folder.CreateFMul(LC, RC),
Name);
678 return Insert(AddFPMathAttributes(BinaryOperator::CreateFMul(LHS, RHS),
679 FPMathTag, FMF), Name);
682 bool isExact =
false) {
683 if (
Constant *LC = dyn_cast<Constant>(LHS))
684 if (
Constant *RC = dyn_cast<Constant>(RHS))
685 return Insert(Folder.CreateUDiv(LC, RC, isExact),
Name);
687 return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
688 return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
694 bool isExact =
false) {
695 if (
Constant *LC = dyn_cast<Constant>(LHS))
696 if (
Constant *RC = dyn_cast<Constant>(RHS))
697 return Insert(Folder.CreateSDiv(LC, RC, isExact),
Name);
699 return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
700 return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
707 if (
Constant *LC = dyn_cast<Constant>(LHS))
708 if (
Constant *RC = dyn_cast<Constant>(RHS))
709 return Insert(Folder.CreateFDiv(LC, RC),
Name);
710 return Insert(AddFPMathAttributes(BinaryOperator::CreateFDiv(LHS, RHS),
711 FPMathTag, FMF), Name);
714 if (
Constant *LC = dyn_cast<Constant>(LHS))
715 if (
Constant *RC = dyn_cast<Constant>(RHS))
716 return Insert(Folder.CreateURem(LC, RC),
Name);
717 return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
720 if (
Constant *LC = dyn_cast<Constant>(LHS))
721 if (
Constant *RC = dyn_cast<Constant>(RHS))
722 return Insert(Folder.CreateSRem(LC, RC),
Name);
723 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
727 if (
Constant *LC = dyn_cast<Constant>(LHS))
728 if (
Constant *RC = dyn_cast<Constant>(RHS))
729 return Insert(Folder.CreateFRem(LC, RC),
Name);
730 return Insert(AddFPMathAttributes(BinaryOperator::CreateFRem(LHS, RHS),
731 FPMathTag, FMF), Name);
735 bool HasNUW =
false,
bool HasNSW =
false) {
736 if (
Constant *LC = dyn_cast<Constant>(LHS))
737 if (
Constant *RC = dyn_cast<Constant>(RHS))
738 return Insert(Folder.CreateShl(LC, RC, HasNUW, HasNSW),
Name);
739 return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
743 bool HasNUW =
false,
bool HasNSW =
false) {
748 bool HasNUW =
false,
bool HasNSW =
false) {
754 bool isExact =
false) {
755 if (
Constant *LC = dyn_cast<Constant>(LHS))
756 if (
Constant *RC = dyn_cast<Constant>(RHS))
757 return Insert(Folder.CreateLShr(LC, RC, isExact),
Name);
759 return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
760 return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
763 bool isExact =
false) {
767 bool isExact =
false) {
772 bool isExact =
false) {
773 if (
Constant *LC = dyn_cast<Constant>(LHS))
774 if (
Constant *RC = dyn_cast<Constant>(RHS))
775 return Insert(Folder.CreateAShr(LC, RC, isExact),
Name);
777 return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
778 return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
781 bool isExact =
false) {
785 bool isExact =
false) {
790 if (
Constant *RC = dyn_cast<Constant>(RHS)) {
791 if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isAllOnesValue())
793 if (
Constant *LC = dyn_cast<Constant>(LHS))
794 return Insert(Folder.CreateAnd(LC, RC),
Name);
796 return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
806 if (
Constant *RC = dyn_cast<Constant>(RHS)) {
807 if (RC->isNullValue())
809 if (
Constant *LC = dyn_cast<Constant>(LHS))
812 return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
822 if (
Constant *LC = dyn_cast<Constant>(LHS))
823 if (
Constant *RC = dyn_cast<Constant>(RHS))
824 return Insert(Folder.CreateXor(LC, RC),
Name);
825 return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
836 if (
Constant *LC = dyn_cast<Constant>(LHS))
837 if (
Constant *RC = dyn_cast<Constant>(RHS))
838 return Insert(Folder.CreateBinOp(Opc, LC, RC),
Name);
843 bool HasNUW =
false,
bool HasNSW =
false) {
845 return Insert(Folder.CreateNeg(
VC, HasNUW, HasNSW),
Name);
847 if (HasNUW) BO->setHasNoUnsignedWrap();
848 if (HasNSW) BO->setHasNoSignedWrap();
861 FPMathTag, FMF), Name);
874 const Twine &Name =
"") {
900 const Twine &Name =
"") {
906 const Twine &Name =
"") {
912 bool isVolatile =
false) {
932 const Twine &Name =
"") {
933 if (
Constant *PC = dyn_cast<Constant>(Ptr)) {
936 for (i = 0, e = IdxList.
size(); i != e; ++i)
937 if (!isa<Constant>(IdxList[i]))
940 return Insert(Folder.CreateGetElementPtr(PC, IdxList),
Name);
945 const Twine &Name =
"") {
946 if (
Constant *PC = dyn_cast<Constant>(Ptr)) {
949 for (i = 0, e = IdxList.
size(); i != e; ++i)
950 if (!isa<Constant>(IdxList[i]))
953 return Insert(Folder.CreateInBoundsGetElementPtr(PC, IdxList),
Name);
958 if (
Constant *PC = dyn_cast<Constant>(Ptr))
959 if (
Constant *IC = dyn_cast<Constant>(Idx))
960 return Insert(Folder.CreateGetElementPtr(PC, IC),
Name);
964 if (
Constant *PC = dyn_cast<Constant>(Ptr))
965 if (
Constant *IC = dyn_cast<Constant>(Idx))
966 return Insert(Folder.CreateInBoundsGetElementPtr(PC, IC),
Name);
972 if (
Constant *PC = dyn_cast<Constant>(Ptr))
973 return Insert(Folder.CreateGetElementPtr(PC, Idx),
Name);
978 const Twine &Name =
"") {
981 if (
Constant *PC = dyn_cast<Constant>(Ptr))
982 return Insert(Folder.CreateInBoundsGetElementPtr(PC, Idx),
Name);
987 const Twine &Name =
"") {
993 if (
Constant *PC = dyn_cast<Constant>(Ptr))
994 return Insert(Folder.CreateGetElementPtr(PC, Idxs),
Name);
999 const Twine &Name =
"") {
1005 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1006 return Insert(Folder.CreateInBoundsGetElementPtr(PC, Idxs),
Name);
1013 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1014 return Insert(Folder.CreateGetElementPtr(PC, Idx),
Name);
1019 const Twine &Name =
"") {
1022 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1023 return Insert(Folder.CreateInBoundsGetElementPtr(PC, Idx),
Name);
1028 const Twine &Name =
"") {
1034 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1035 return Insert(Folder.CreateGetElementPtr(PC, Idxs),
Name);
1040 const Twine &Name =
"") {
1046 if (
Constant *PC = dyn_cast<Constant>(Ptr))
1047 return Insert(Folder.CreateInBoundsGetElementPtr(PC, Idxs),
Name);
1060 Value *Args[] = { zero, zero };
1069 return CreateCast(Instruction::Trunc, V, DestTy, Name);
1072 return CreateCast(Instruction::ZExt, V, DestTy, Name);
1075 return CreateCast(Instruction::SExt, V, DestTy, Name);
1080 const Twine &Name =
"") {
1083 "Can only zero extend/truncate integers!");
1094 const Twine &Name =
"") {
1097 "Can only sign extend/truncate integers!");
1106 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
1109 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
1112 return CreateCast(Instruction::UIToFP, V, DestTy, Name);
1115 return CreateCast(Instruction::SIToFP, V, DestTy, Name);
1118 const Twine &Name =
"") {
1119 return CreateCast(Instruction::FPTrunc, V, DestTy, Name);
1122 return CreateCast(Instruction::FPExt, V, DestTy, Name);
1125 const Twine &Name =
"") {
1126 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
1129 const Twine &Name =
"") {
1130 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
1133 const Twine &Name =
"") {
1134 return CreateCast(Instruction::BitCast, V, DestTy, Name);
1137 const Twine &Name =
"") {
1138 return CreateCast(Instruction::AddrSpaceCast, V, DestTy, Name);
1141 const Twine &Name =
"") {
1145 return Insert(Folder.CreateZExtOrBitCast(
VC, DestTy),
Name);
1149 const Twine &Name =
"") {
1153 return Insert(Folder.CreateSExtOrBitCast(
VC, DestTy),
Name);
1157 const Twine &Name =
"") {
1161 return Insert(Folder.CreateTruncOrBitCast(
VC, DestTy),
Name);
1165 const Twine &Name =
"") {
1169 return Insert(Folder.CreateCast(Op,
VC, DestTy),
Name);
1173 const Twine &Name =
"") {
1177 return Insert(Folder.CreatePointerCast(
VC, DestTy),
Name);
1181 const Twine &Name =
"") {
1185 return Insert(Folder.CreateIntCast(
VC, DestTy, isSigned),
Name);
1195 if (V->getType() == DestTy)
1281 const Twine &Name =
"") {
1282 if (
Constant *LC = dyn_cast<Constant>(LHS))
1283 if (
Constant *RC = dyn_cast<Constant>(RHS))
1284 return Insert(Folder.CreateICmp(P, LC, RC),
Name);
1288 const Twine &Name =
"") {
1289 if (
Constant *LC = dyn_cast<Constant>(LHS))
1290 if (
Constant *RC = dyn_cast<Constant>(RHS))
1291 return Insert(Folder.CreateFCmp(P, LC, RC),
Name);
1300 const Twine &Name =
"") {
1311 const Twine &Name =
"") {
1312 Value *Args[] = { Arg1, Arg2 };
1316 const Twine &Name =
"") {
1317 Value *Args[] = { Arg1, Arg2, Arg3 };
1322 Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };
1327 Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 };
1332 const Twine &Name =
"") {
1337 const Twine &Name =
"") {
1338 if (
Constant *CC = dyn_cast<Constant>(C))
1339 if (
Constant *TC = dyn_cast<Constant>(True))
1340 if (
Constant *
FC = dyn_cast<Constant>(False))
1350 const Twine &Name =
"") {
1352 if (
Constant *IC = dyn_cast<Constant>(Idx))
1353 return Insert(Folder.CreateExtractElement(
VC, IC),
Name);
1358 const Twine &Name =
"") {
1360 if (
Constant *
NC = dyn_cast<Constant>(NewElt))
1361 if (
Constant *IC = dyn_cast<Constant>(Idx))
1367 const Twine &Name =
"") {
1368 if (
Constant *V1C = dyn_cast<Constant>(V1))
1369 if (
Constant *V2C = dyn_cast<Constant>(V2))
1370 if (
Constant *MC = dyn_cast<Constant>(Mask))
1371 return Insert(Folder.CreateShuffleVector(V1C, V2C, MC),
Name);
1377 const Twine &Name =
"") {
1378 if (
Constant *AggC = dyn_cast<Constant>(Agg))
1379 return Insert(Folder.CreateExtractValue(AggC, Idxs),
Name);
1385 const Twine &Name =
"") {
1386 if (
Constant *AggC = dyn_cast<Constant>(Agg))
1387 if (
Constant *ValC = dyn_cast<Constant>(Val))
1388 return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs),
Name);
1393 const Twine &Name =
"") {
1421 "Pointer subtraction operand types must match!");
1434 assert(NumElts > 0 &&
"Cannot splat to an empty vector!");
1440 Name +
".splatinsert");
IntegerType * getInt16Ty()
Fetch the type representing a 16-bit integer.
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Common base class shared among various IRBuilders.
Value * CreateGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Value * CreateNUWNeg(Value *V, const Twine &Name="")
LoadInst * CreateLoad(Value *Ptr, const Twine &Name="")
static ConstantInt * getFalse(LLVMContext &Context)
SwitchInst * CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases=10, MDNode *BranchWeights=0)
Create a switch instruction with the specified value, default dest, and with a hint for the number of...
void setHasNoSignedWrap(bool b=true)
Value * CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
Value * CreateFAdd(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=0)
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
BasicBlock::iterator GetInsertPoint() const
LoadInst * CreateLoad(Value *Ptr, const char *Name)
void SetCurrentDebugLocation(const DebugLoc &L)
Set location information used by debugging information.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy. Return the value untouched if the type of ...
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
unsigned getScalarSizeInBits()
VAArgInst * CreateVAArg(Value *List, Type *Ty, const Twine &Name="")
Value * CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=0)
ReturnInst * CreateAggregateRet(Value *const *retVals, unsigned N)
Create a sequence of N insertvalue instructions, with one Value from the retVals array each...
static ConstantAggregateZero * get(Type *Ty)
Value * CreateSRem(Value *LHS, Value *RHS, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP)
This specifies that created instructions should be inserted at the specified point.
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
0 1 0 0 True if ordered and less than
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
1 1 1 0 True if unordered or not equal
Value * CreateFPCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name="")
MDNode - a tuple of other values.
Value * CreateConstGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Value * CreateGEP(Value *Ptr, Value *Idx, const Twine &Name="")
static IntegerType * getInt64Ty(LLVMContext &C)
IRBuilder(Use &U, MDNode *FPMathTag=0)
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
static IndirectBrInst * Create(Value *Address, unsigned NumDests, Instruction *InsertBefore=0)
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag=0)
static IntegerType * getInt16Ty(LLVMContext &C)
Value * CreateFSub(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=0)
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Value * CreateOr(Value *LHS, const APInt &RHS, const Twine &Name="")
void setDebugLoc(const DebugLoc &Loc)
setDebugLoc - Set the debug location information for this instruction.
CallInst * CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, Value *Arg4, Value *Arg5, const Twine &Name="")
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, bool isVolatile, const Twine &Name="")
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=0)
Create a lifetime.end intrinsic.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
LoopInfoBase< BlockT, LoopT > * LI
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
static Constant * getNullValue(Type *Ty)
Value * CreateConstInBoundsGEP1_32(Value *Ptr, unsigned Idx0, const Twine &Name="")
Value * CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
1 0 0 1 True if unordered or equal
Value * CreateFMul(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=0)
CallInst * CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=0)
Create and insert a memmove between the specified pointers.
CallInst * CreateCall(Value *Callee, Value *Arg, const Twine &Name="")
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
bool isUnknown() const
isUnknown - Return true if this is an unknown location.
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
static Type * getFloatTy(LLVMContext &C)
Value * CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
void setHasNoUnsignedWrap(bool b=true)
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="")
static CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create a Trunc or BitCast cast instruction.
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=0)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
llvm::BasicBlock * getBlock() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=0)
0 1 0 1 True if ordered and less than or equal
Value * CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name="")
IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag=0)
void setName(const Twine &Name)
Value * CreateFRem(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=0)
Value * CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name="")
ConstantInt * getInt16(uint16_t C)
Get a constant 16-bit value.
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=0, const Twine &Name="")
Type * getVoidTy()
Fetch the type representing void.
IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag=0)
static Constant * getSizeOf(Type *Ty)
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
InvokeInst * CreateInvoke3(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, Value *Arg1, Value *Arg2, Value *Arg3, const Twine &Name="")
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
void SetFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
InsertPoint saveIP() const
Returns the current insert point.
CallInst * CreateCall(Value *Callee, ArrayRef< Value * > Args, const Twine &Name="")
FenceInst * CreateFence(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
UnreachableInst * CreateUnreachable()
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
Represents a floating point comparison operator.
static LandingPadInst * Create(Type *RetTy, Value *PersonalityFn, unsigned NumReservedClauses, const Twine &NameStr="", Instruction *InsertBefore=0)
Value * CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name="")
CallInst * CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, Value *Arg4, const Twine &Name="")
MDNode * getDefaultFPMathTag() const
Get the floating point math metadata being used.
Value * CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const Twine &Name="")
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Value * CreateShl(Value *LHS, const APInt &RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
size_t size() const
size - Get the array size.
Value * CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Value * CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateNSWNeg(Value *V, const Twine &Name="")
IRBuilderBase(LLVMContext &context, MDNode *FPMathTag=0)
void SetInsertPoint(Use &U)
Find the nearest point that dominates this use, and specify that created instructions should be inser...
LoadInst * CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name="")
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Construct any of the CastInst subclasses.
Value * CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
InsertPoint saveAndClearIP()
Returns the current insert point, clearing it in the process.
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
Value * CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name="")
bool isIntOrIntVectorTy() const
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
Value * CreateGlobalStringPtr(StringRef Str, const Twine &Name="")
Same as CreateGlobalString, but return a pointer with "i8*" type instead of a pointer to array of i8...
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="")
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, Value *Arg1, const Twine &Name="")
Value * CreateConstInBoundsGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name="")
Value * CreateShl(Value *LHS, uint64_t RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=0)
InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
Creates a new insertion point at the given location.
LLVM Basic Block Representation.
ConstantInt * getTrue()
Get the constant value for i1 true.
Value * CreateNot(Value *V, const Twine &Name="")
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
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 * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
LLVM Constant Representation.
Value * CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
IRBuilder(LLVMContext &C, MDNode *FPMathTag=0)
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=0)
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const Twine &Name="")
static CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
const DebugLoc & getDebugLoc() const
getDebugLoc - Return the debug location for this node as a DebugLoc.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=0)
static Type * getVoidTy(LLVMContext &C)
const InstListType & getInstList() const
Return the underlying instruction list container.
Represent an integer comparison operator.
iterator insert(iterator where, NodeTy *New)
NUW NUW NUW NUW Exact static Exact BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
0 1 1 1 True if ordered (no nans)
DebugLoc getCurrentDebugLocation() const
Get location information used by debugging information.
void clearFastMathFlags()
Clear the fast-math flags.
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="")
Integer representation type.
Value * CreateOr(Value *LHS, uint64_t RHS, const Twine &Name="")
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 or a PtrToInt cast instruction.
Value * CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name="")
Value * CreateStructGEP(Value *Ptr, unsigned Idx, const Twine &Name="")
Value * CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name="")
void setAlignment(unsigned Align)
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...
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create a ZExt or BitCast cast instruction.
InsertPointGuard(IRBuilderBase &B)
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
static UndefValue * get(Type *T)
void SetInsertPoint(Instruction *I)
This specifies that created instructions should be inserted before the specified instruction.
LLVMContext & getContext() const
IndirectBrInst * CreateIndirectBr(Value *Addr, unsigned NumDests=10)
Create an indirect branch instruction with the specified address operand, with an optional hint for t...
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.
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name)
1 1 0 1 True if unordered, less than, or equal
Value * CreateFPToUI(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=0)
IntegerType * getIntPtrTy(const DataLayout *DL, unsigned AddrSpace=0)
Fetch the type representing a pointer to an integer value.
Value * CreateXor(Value *LHS, const APInt &RHS, const Twine &Name="")
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=0)
static CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create a SExt or BitCast cast instruction.
This provides the default implementation of the IRBuilder 'InsertHelper' method that is called whenev...
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
0 0 1 0 True if ordered and greater than
bool isNamePreserving() const
Return true if this builder is configured to actually add the requested names to IR created through i...
Value * CreateInBoundsGEP(Value *Ptr, Value *Idx, const Twine &Name="")
Value * CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Class for constant integers.
Value * CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name="")
InsertPoint - A saved insertion point.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
1 1 0 0 True if unordered or less than
FastMathFlagGuard(IRBuilderBase &B)
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name="")
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
BasicBlock * GetInsertBlock() const
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
static GetElementPtrInst * Create(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=0)
static ConstantInt * getTrue(LLVMContext &Context)
#define LLVM_DELETED_FUNCTION
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateURem(Value *LHS, Value *RHS, const Twine &Name="")
Class for arbitrary precision integers.
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 * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="")
Value * CreateFDiv(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=0)
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
static CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", Instruction *InsertBefore=0)
Create a ZExt, BitCast, or Trunc for int -> int casts.
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
Value * CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const
void clear()
Set all the flags to false.
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
ConstantInt * getFalse()
Get the constant value for i1 false.
MDNode * DefaultFPMathTag
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=0)
LandingPadInst * CreateLandingPad(Type *Ty, Value *PersFn, unsigned NumClauses, const Twine &Name="")
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Value * CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name="")
IRBuilder(LLVMContext &C, const T &F, const Inserter &I=Inserter(), MDNode *FPMathTag=0)
Constant * Insert(Constant *C, const Twine &="") const
No-op overload to handle constants.
Value * CreateConstInBoundsGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy. Return the value untouched if the type of ...
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
static IntegerType * getInt32Ty(LLVMContext &C)
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
unsigned greater or equal
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name="")
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
0 1 1 0 True if ordered and operands are unequal
const T & getFolder()
Get the constant folder being used.
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=0)
Create and insert a memset to the specified pointer and the specified value.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=0)
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateXor(Value *LHS, uint64_t RHS, const Twine &Name="")
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
Value * CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name="")
1 0 1 0 True if unordered or greater than
static ReturnInst * Create(LLVMContext &C, Value *retVal=0, Instruction *InsertBefore=0)
IRBuilder(Instruction *IP, MDNode *FPMathTag=0)
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, const Twine &Name="")
Create an invoke instruction.
CallInst * CreateCall2(Value *Callee, Value *Arg1, Value *Arg2, const Twine &Name="")
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateIsNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is null.
llvm::BasicBlock::iterator getPoint() const
0 0 0 1 True if ordered and equal
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
LLVM Value Representation.
void setAlignment(unsigned Align)
1 0 1 1 True if unordered, greater than, or equal
CallInst * CreateCall(Value *Callee, const Twine &Name="")
static VectorType * get(Type *ElementType, unsigned NumElements)
CallInst * CreateLifetimeStart(Value *Ptr, ConstantInt *Size=0)
Create a lifetime.start intrinsic.
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
FastMathFlags getFastMathFlags() const
Get the flags to be applied to created floating point ops.
bool isSet() const
Returns true if this insert point is set.
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
InsertPoint()
Creates a new insertion point which doesn't point to anything.
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
struct LLVMOpaqueBuilder * LLVMBuilderRef
Convenience struct for specifying and reasoning about fast-math flags.
Value * CreateGlobalString(StringRef Str, const Twine &Name="")
Make a new global variable with initializer type i8*.
Value * CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name="")
static BinaryOperator * CreateFNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=0)
InvokeInst * CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, const Twine &Name="")
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T &F, MDNode *FPMathTag=0)
Value * CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name="")
0 0 1 1 True if ordered and greater than or equal
Value * CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
ResumeInst * CreateResume(Value *Exn)
static IntegerType * getInt8Ty(LLVMContext &C)
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=0)
BasicBlock::iterator InsertPt
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=0)
const BasicBlock * getParent() const
CallInst * CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=0, MDNode *TBAAStructTag=0)
Create and insert a memcpy between the specified pointers.
Value * CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
CallInst * CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, const Twine &Name="")
void SetDefaultFPMathTag(MDNode *FPMathTag)
Set the floating point math metadata to be used.