LLVM 24.0.0git
IRBuilder.h
Go to the documentation of this file.
1//===- llvm/IRBuilder.h - Builder for LLVM Instructions ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the IRBuilder class, which is used as a convenient way
10// to create LLVM instructions with a consistent and simplified interface.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_IRBUILDER_H
15#define LLVM_IR_IRBUILDER_H
16
17#include "llvm-c/Types.h"
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/STLExtras.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/Twine.h"
22#include "llvm/IR/BasicBlock.h"
23#include "llvm/IR/Constant.h"
25#include "llvm/IR/Constants.h"
26#include "llvm/IR/DataLayout.h"
27#include "llvm/IR/DebugLoc.h"
29#include "llvm/IR/FPEnv.h"
30#include "llvm/IR/Function.h"
32#include "llvm/IR/InstrTypes.h"
33#include "llvm/IR/Instruction.h"
35#include "llvm/IR/Intrinsics.h"
36#include "llvm/IR/LLVMContext.h"
37#include "llvm/IR/Operator.h"
38#include "llvm/IR/Type.h"
39#include "llvm/IR/Value.h"
40#include "llvm/IR/ValueHandle.h"
45#include <cassert>
46#include <cstdint>
47#include <functional>
48#include <optional>
49#include <utility>
50
51namespace llvm {
52
53class APInt;
54class Use;
55
56/// This provides the default implementation of the IRBuilder
57/// 'InsertHelper' method that is called whenever an instruction is created by
58/// IRBuilder and needs to be inserted.
59///
60/// By default, this inserts the instruction at the insertion point.
62public:
64
65 virtual void InsertHelper(Instruction *I, const Twine &Name,
66 BasicBlock::iterator InsertPt) const {
67 if (InsertPt.isValid())
68 I->insertInto(InsertPt.getNodeParent(), InsertPt);
69 I->setName(Name);
70 }
71};
72
73/// Provides an 'InsertHelper' that calls a user-provided callback after
74/// performing the default insertion.
76 std::function<void(Instruction *)> Callback;
77
78public:
80
81 IRBuilderCallbackInserter(std::function<void(Instruction *)> Callback)
82 : Callback(std::move(Callback)) {}
83
84 void InsertHelper(Instruction *I, const Twine &Name,
85 BasicBlock::iterator InsertPt) const override {
87 Callback(I);
88 }
89};
90
91/// This provides a helper for copying FMF from an instruction or setting
92/// specified flags.
93class FMFSource {
94 std::optional<FastMathFlags> FMF;
95
96public:
97 FMFSource() = default;
99 if (Source)
100 FMF = Source->getFastMathFlags();
101 }
102 FMFSource(FastMathFlags FMF) : FMF(FMF) {}
104 return FMF.value_or(Default);
105 }
106 /// Intersect the FMF from two instructions.
111};
112
113/// Common base class shared among various IRBuilders.
115 /// The DebugLoc that will be applied to instructions inserted by this
116 /// builder.
117 DebugLoc StoredDL;
118
119protected:
125
128
129 bool IsFPConstrained = false;
132
134
135public:
141
142 /// Insert and return the specified instruction.
143 template<typename InstTy>
144 InstTy *Insert(InstTy *I, const Twine &Name = "") const {
145 Inserter.InsertHelper(I, Name, InsertPt);
147 return I;
148 }
149
150 /// No-op overload to handle constants.
151 Constant *Insert(Constant *C, const Twine& = "") const {
152 return C;
153 }
154
155 Value *Insert(Value *V, const Twine &Name = "") const {
157 return Insert(I, Name);
159 return V;
160 }
161
162 //===--------------------------------------------------------------------===//
163 // Builder configuration methods
164 //===--------------------------------------------------------------------===//
165
166 /// Clear the insertion point: created instructions will not be
167 /// inserted into a block.
169 BB = nullptr;
171 }
172
173 BasicBlock *GetInsertBlock() const { return BB; }
175 LLVMContext &getContext() const { return Context; }
176
177 /// This specifies that created instructions should be appended to the
178 /// end of the specified block.
180 BB = TheBB;
181 InsertPt = BB->end();
182 }
183
184 /// This specifies that created instructions should be inserted before
185 /// the specified instruction.
187 BB = I->getParent();
188 InsertPt = I->getIterator();
189 assert(InsertPt != BB->end() && "Can't read debug loc from end()");
190 SetCurrentDebugLocation(I->getStableDebugLoc());
191 }
192
193 /// This specifies that created instructions should be inserted at the
194 /// specified point.
196 BB = TheBB;
197 InsertPt = IP;
198 if (IP != TheBB->end())
199 SetCurrentDebugLocation(IP->getStableDebugLoc());
200 }
201
202 /// This specifies that created instructions should be inserted at
203 /// the specified point, but also requires that \p IP is dereferencable.
205 BB = IP->getParent();
206 InsertPt = IP;
207 SetCurrentDebugLocation(IP->getStableDebugLoc());
208 }
209
210 /// This specifies that created instructions should inserted at the beginning
211 /// end of the specified function, but after already existing static alloca
212 /// instructions that are at the start.
214 BB = &F->getEntryBlock();
215 InsertPt = BB->getFirstNonPHIOrDbgOrAlloca();
216 }
217
218 /// Set location information used by debugging information.
220 // For !dbg metadata attachments, we use DebugLoc instead of the raw MDNode
221 // to include optional introspection data for use in Debugify.
222 StoredDL = L;
223 }
224
225 /// Set location information used by debugging information.
227 // For !dbg metadata attachments, we use DebugLoc instead of the raw MDNode
228 // to include optional introspection data for use in Debugify.
229 StoredDL = std::move(L);
230 }
231
232 /// Get location information used by debugging information.
234
235 /// If this builder has a current debug location, set it on the
236 /// specified instruction.
238
239 /// Get the return type of the current function that we're emitting
240 /// into.
242
243 /// InsertPoint - A saved insertion point.
245 BasicBlock *Block = nullptr;
247
248 public:
249 /// Creates a new insertion point which doesn't point to anything.
250 InsertPoint() = default;
251
252 /// Creates a new insertion point at the given location.
254 : Block(InsertBlock), Point(InsertPoint) {}
255
256 /// Returns true if this insert point is set.
257 bool isSet() const { return (Block != nullptr); }
258
259 BasicBlock *getBlock() const { return Block; }
260 BasicBlock::iterator getPoint() const { return Point; }
261 };
262
263 /// Returns the current insert point.
266 }
267
268 /// Returns the current insert point, clearing it in the process.
274
275 /// Sets the current insert point to a previously-saved location.
277 if (IP.isSet())
278 SetInsertPoint(IP.getBlock(), IP.getPoint());
279 else
281 }
282
283 /// Get the floating point math metadata being used.
285
286 /// Get the flags to be applied to created floating point ops
288
290
291 /// Clear the fast-math flags.
292 void clearFastMathFlags() { FMF.clear(); }
293
294 /// Set the floating point math metadata to be used.
295 void setDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; }
296
297 /// Set the fast-math flags to be used with generated fp-math operators
298 void setFastMathFlags(FastMathFlags NewFMF) { FMF = NewFMF; }
299
300 /// Enable/Disable use of constrained floating point math. When
301 /// enabled the CreateF<op>() calls instead create constrained
302 /// floating point intrinsic calls. Fast math flags are unaffected
303 /// by this setting.
304 void setIsFPConstrained(bool IsCon) { IsFPConstrained = IsCon; }
305
306 /// Query for the use of constrained floating point math
308
309 /// Set the exception handling to be used with constrained floating point
311#ifndef NDEBUG
312 std::optional<StringRef> ExceptStr =
314 assert(ExceptStr && "Garbage strict exception behavior!");
315#endif
316 DefaultConstrainedExcept = NewExcept;
317 }
318
319 /// Set the rounding mode handling to be used with constrained floating point
321#ifndef NDEBUG
322 std::optional<StringRef> RoundingStr =
323 convertRoundingModeToStr(NewRounding);
324 assert(RoundingStr && "Garbage strict rounding mode!");
325#endif
326 DefaultConstrainedRounding = NewRounding;
327 }
328
329 /// Get the exception handling used with constrained floating point
333
334 /// Get the rounding mode handling used with constrained floating point
338
340 assert(BB && "Must have a basic block to set any function attributes!");
341
342 Function *F = BB->getParent();
343 if (!F->hasFnAttribute(Attribute::StrictFP)) {
344 F->addFnAttr(Attribute::StrictFP);
345 }
346 }
347
349 I->addFnAttr(Attribute::StrictFP);
350 }
351
355
356 //===--------------------------------------------------------------------===//
357 // RAII helpers.
358 //===--------------------------------------------------------------------===//
359
360 // RAII object that stores the current insertion point and restores it
361 // when the object is destroyed. This includes the debug location.
363 IRBuilderBase &Builder;
366 DebugLoc DbgLoc;
367
368 public:
370 : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
371 DbgLoc(B.getCurrentDebugLocation()) {}
372
375
377 Builder.restoreIP(InsertPoint(Block, Point));
378 Builder.SetCurrentDebugLocation(DbgLoc);
379 }
380 };
381
382 // RAII object that stores the current fast math settings and restores
383 // them when the object is destroyed.
385 IRBuilderBase &Builder;
386 FastMathFlags FMF;
387 MDNode *FPMathTag;
388 bool IsFPConstrained;
389 fp::ExceptionBehavior DefaultConstrainedExcept;
390 RoundingMode DefaultConstrainedRounding;
391
392 public:
394 : Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag),
395 IsFPConstrained(B.IsFPConstrained),
396 DefaultConstrainedExcept(B.DefaultConstrainedExcept),
397 DefaultConstrainedRounding(B.DefaultConstrainedRounding) {}
398
401
403 Builder.FMF = FMF;
404 Builder.DefaultFPMathTag = FPMathTag;
405 Builder.IsFPConstrained = IsFPConstrained;
406 Builder.DefaultConstrainedExcept = DefaultConstrainedExcept;
407 Builder.DefaultConstrainedRounding = DefaultConstrainedRounding;
408 }
409 };
410
411 // RAII object that stores the current default operand bundles and restores
412 // them when the object is destroyed.
414 IRBuilderBase &Builder;
415 ArrayRef<OperandBundleDef> DefaultOperandBundles;
416
417 public:
419 : Builder(B), DefaultOperandBundles(B.DefaultOperandBundles) {}
420
423
425 Builder.DefaultOperandBundles = DefaultOperandBundles;
426 }
427 };
428
429
430 //===--------------------------------------------------------------------===//
431 // Miscellaneous creation methods.
432 //===--------------------------------------------------------------------===//
433
434 /// Make a new global variable with initializer type i8*
435 ///
436 /// Make a new global variable with an initializer that has array of i8 type
437 /// filled in with the null terminated string value specified. The new global
438 /// variable will be marked mergable with any others of the same contents. If
439 /// Name is specified, it is the name of the global variable created.
440 ///
441 /// If no module is given via \p M, it is take from the insertion point basic
442 /// block.
444 const Twine &Name = "",
445 unsigned AddressSpace = 0,
446 Module *M = nullptr,
447 bool AddNull = true);
448
449 /// Get a constant value representing either true or false.
451 return ConstantInt::get(getInt1Ty(), V);
452 }
453
454 /// Get the constant value for i1 true.
458
459 /// Get the constant value for i1 false.
463
464 /// Get a constant 8-bit value.
466 return ConstantInt::get(getInt8Ty(), C);
467 }
468
469 /// Get a constant 16-bit value.
471 return ConstantInt::get(getInt16Ty(), C);
472 }
473
474 /// Get a constant 32-bit value.
476 return ConstantInt::get(getInt32Ty(), C);
477 }
478
479 /// Get a constant 64-bit value.
481 return ConstantInt::get(getInt64Ty(), C);
482 }
483
484 /// Get a constant N-bit value, zero extended from a 64-bit value.
486 return ConstantInt::get(getIntNTy(N), C);
487 }
488
489 /// Get a constant integer value.
491 return ConstantInt::get(Context, AI);
492 }
493
494 //===--------------------------------------------------------------------===//
495 // Type creation methods
496 //===--------------------------------------------------------------------===//
497
498 /// Fetch the type representing an 8-bit byte.
500
501 /// Fetch the type representing a 16-bit byte.
503
504 /// Fetch the type representing a 32-bit byte.
506
507 /// Fetch the type representing a 64-bit byte.
509
510 /// Fetch the type representing a 128-bit byte.
512
513 /// Fetch the type representing an N-bit byte.
515
516 /// Fetch the type representing a single bit
520
521 /// Fetch the type representing an 8-bit integer.
525
526 /// Fetch the type representing a 16-bit integer.
530
531 /// Fetch the type representing a 32-bit integer.
535
536 /// Fetch the type representing a 64-bit integer.
540
541 /// Fetch the type representing a 128-bit integer.
543
544 /// Fetch the type representing an N-bit integer.
546 return Type::getIntNTy(Context, N);
547 }
548
549 /// Fetch the type representing a 16-bit floating point value.
551 return Type::getHalfTy(Context);
552 }
553
554 /// Fetch the type representing a 16-bit brain floating point value.
557 }
558
559 /// Fetch the type representing a 32-bit floating point value.
562 }
563
564 /// Fetch the type representing a 64-bit floating point value.
567 }
568
569 /// Fetch the type representing void.
571 return Type::getVoidTy(Context);
572 }
573
574 /// Fetch the type representing a pointer.
575 PointerType *getPtrTy(unsigned AddrSpace = 0) {
576 return PointerType::get(Context, AddrSpace);
577 }
578
579 /// Fetch the type of a byte with size at least as big as that of a
580 /// pointer in the given address space.
581 ByteType *getBytePtrTy(const DataLayout &DL, unsigned AddrSpace = 0) {
582 return DL.getBytePtrType(Context, AddrSpace);
583 }
584
585 /// Fetch the type of an integer with size at least as big as that of a
586 /// pointer in the given address space.
587 IntegerType *getIntPtrTy(const DataLayout &DL, unsigned AddrSpace = 0) {
588 return DL.getIntPtrType(Context, AddrSpace);
589 }
590
591 /// Fetch the type of an integer that should be used to index GEP operations
592 /// within AddressSpace.
593 IntegerType *getIndexTy(const DataLayout &DL, unsigned AddrSpace) {
594 return DL.getIndexType(Context, AddrSpace);
595 }
596
597 //===--------------------------------------------------------------------===//
598 // Intrinsic creation methods
599 //===--------------------------------------------------------------------===//
600
601 /// Create and insert a memset to the specified pointer and the
602 /// specified value.
603 ///
604 /// If the pointer isn't an i8*, it will be converted. If alias metadata is
605 /// specified, it will be added to the instruction.
607 MaybeAlign Align, bool isVolatile = false,
608 const AAMDNodes &AAInfo = AAMDNodes()) {
609 return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile, AAInfo);
610 }
611
613 MaybeAlign Align, bool isVolatile = false,
614 const AAMDNodes &AAInfo = AAMDNodes());
615
617 Value *Val, Value *Size,
618 bool IsVolatile = false,
619 const AAMDNodes &AAInfo = AAMDNodes());
620
621 /// Create and insert an element unordered-atomic memset of the region of
622 /// memory starting at the given pointer to the given value.
623 ///
624 /// If the pointer isn't an i8*, it will be converted. If alias metadata is
625 /// specified, it will be added to the instruction.
626 CallInst *
628 Align Alignment, uint32_t ElementSize,
629 const AAMDNodes &AAInfo = AAMDNodes()) {
631 Ptr, Val, getInt64(Size), Align(Alignment), ElementSize, AAInfo);
632 }
633
635 Value *ArraySize,
637 Function *MallocF = nullptr,
638 const Twine &Name = "");
639
640 /// CreateMalloc - Generate the IR for a call to malloc:
641 /// 1. Compute the malloc call's argument as AllocSize, possibly multiplied
642 /// by the array size if the array size is not constant 1.
643 /// 2. Call malloc with that argument.
645 Value *ArraySize, Function *MallocF = nullptr,
646 const Twine &Name = "");
647 /// Generate the IR for a call to the builtin free function.
649 ArrayRef<OperandBundleDef> Bundles = {});
650
651 LLVM_ABI CallInst *
652 CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, Value *Size,
653 Align Alignment, uint32_t ElementSize,
654 const AAMDNodes &AAInfo = AAMDNodes());
655
656 /// Create and insert a memcpy between the specified pointers.
657 ///
658 /// If the pointers aren't i8*, they will be converted. If alias metadata is
659 /// specified, it will be added to the instruction.
660 /// and noalias tags.
662 MaybeAlign SrcAlign, uint64_t Size,
663 bool isVolatile = false,
664 const AAMDNodes &AAInfo = AAMDNodes()) {
665 return CreateMemCpy(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
666 isVolatile, AAInfo);
667 }
668
671 Value *Src, MaybeAlign SrcAlign, Value *Size,
672 bool isVolatile = false,
673 const AAMDNodes &AAInfo = AAMDNodes());
674
676 MaybeAlign SrcAlign, Value *Size,
677 bool isVolatile = false,
678 const AAMDNodes &AAInfo = AAMDNodes()) {
679 return CreateMemTransferInst(Intrinsic::memcpy, Dst, DstAlign, Src,
680 SrcAlign, Size, isVolatile, AAInfo);
681 }
682
684 MaybeAlign SrcAlign, Value *Size,
685 bool isVolatile = false,
686 const AAMDNodes &AAInfo = AAMDNodes()) {
687 return CreateMemTransferInst(Intrinsic::memcpy_inline, Dst, DstAlign, Src,
688 SrcAlign, Size, isVolatile, AAInfo);
689 }
690
691 /// Create and insert an element unordered-atomic memcpy between the
692 /// specified pointers.
693 ///
694 /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers,
695 /// respectively.
696 ///
697 /// If the pointers aren't i8*, they will be converted. If alias metadata is
698 /// specified, it will be added to the instruction.
700 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
701 uint32_t ElementSize, const AAMDNodes &AAInfo = AAMDNodes());
702
704 MaybeAlign SrcAlign, uint64_t Size,
705 bool isVolatile = false,
706 const AAMDNodes &AAInfo = AAMDNodes()) {
707 return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
708 isVolatile, AAInfo);
709 }
710
712 MaybeAlign SrcAlign, Value *Size,
713 bool isVolatile = false,
714 const AAMDNodes &AAInfo = AAMDNodes()) {
715 return CreateMemTransferInst(Intrinsic::memmove, Dst, DstAlign, Src,
716 SrcAlign, Size, isVolatile, AAInfo);
717 }
718
719 /// \brief Create and insert an element unordered-atomic memmove between the
720 /// specified pointers.
721 ///
722 /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers,
723 /// respectively.
724 ///
725 /// If the pointers aren't i8*, they will be converted. If alias metadata is
726 /// specified, it will be added to the instruction.
728 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
729 uint32_t ElementSize, const AAMDNodes &AAInfo = AAMDNodes());
730
731private:
732 Value *getReductionIntrinsic(Intrinsic::ID ID, Value *Src);
733
734public:
735 /// Create a sequential vector fadd reduction intrinsic of the source vector.
736 /// The first parameter is a scalar accumulator value. An unordered reduction
737 /// can be created by adding the reassoc fast-math flag to the resulting
738 /// sequential reduction.
740
741 /// Create a sequential vector fmul reduction intrinsic of the source vector.
742 /// The first parameter is a scalar accumulator value. An unordered reduction
743 /// can be created by adding the reassoc fast-math flag to the resulting
744 /// sequential reduction.
746
747 /// Create a vector int add reduction intrinsic of the source vector.
749
750 /// Create a vector int mul reduction intrinsic of the source vector.
752
753 /// Create a vector int AND reduction intrinsic of the source vector.
755
756 /// Create a vector int OR reduction intrinsic of the source vector.
758
759 /// Create a vector int XOR reduction intrinsic of the source vector.
761
762 /// Create a vector integer max reduction intrinsic of the source
763 /// vector.
764 LLVM_ABI Value *CreateIntMaxReduce(Value *Src, bool IsSigned = false);
765
766 /// Create a vector integer min reduction intrinsic of the source
767 /// vector.
768 LLVM_ABI Value *CreateIntMinReduce(Value *Src, bool IsSigned = false);
769
770 /// Create a vector float max reduction intrinsic of the source
771 /// vector.
773
774 /// Create a vector float min reduction intrinsic of the source
775 /// vector.
777
778 /// Create a vector float maximum reduction intrinsic of the source
779 /// vector. This variant follows the NaN and signed zero semantic of
780 /// llvm.maximum intrinsic.
782
783 /// Create a vector float minimum reduction intrinsic of the source
784 /// vector. This variant follows the NaN and signed zero semantic of
785 /// llvm.minimum intrinsic.
787
788 /// Create a vector float maximum reduction intrinsic of the source
789 /// vector. This variant follows the NaN and signed zero semantic of
790 /// llvm.maximumnum intrinsic.
792
793 /// Create a vector float minimum reduction intrinsic of the source
794 /// vector. This variant follows the NaN and signed zero semantic of
795 /// llvm.minimumnum intrinsic.
797
798 /// Create a lifetime.start intrinsic.
800
801 /// Create a lifetime.end intrinsic.
803
804 /// Create a call to invariant.start intrinsic.
805 ///
806 /// If the pointer isn't i8* it will be converted.
808 ConstantInt *Size = nullptr);
809
810 /// Create a call to llvm.threadlocal.address intrinsic.
812
813 /// Create a call to Masked Load intrinsic
814 LLVM_ABI CallInst *CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment,
815 Value *Mask, Value *PassThru = nullptr,
816 const Twine &Name = "");
817
818 /// Create a call to Masked Store intrinsic
819 LLVM_ABI CallInst *CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment,
820 Value *Mask);
821
822 /// Create a call to Masked Gather intrinsic
823 LLVM_ABI CallInst *CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment,
824 Value *Mask = nullptr,
825 Value *PassThru = nullptr,
826 const Twine &Name = "");
827
828 /// Create a call to Masked Scatter intrinsic
830 Align Alignment,
831 Value *Mask = nullptr);
832
833 /// Create a call to Masked Expand Load intrinsic
836 Value *Mask = nullptr,
837 Value *PassThru = nullptr,
838 const Twine &Name = "");
839
840 /// Create a call to Masked Compress Store intrinsic
843 Value *Mask = nullptr);
844
845 /// Return an all true boolean vector (mask) with \p NumElts lanes.
850
851 /// Create an assume intrinsic call that allows the optimizer to
852 /// assume that the provided condition will be true.
854
855 /// Create an assume intrinsic call that allows the optimizer to
856 /// assume that the provided operand bundles hold.
858
859 /// Create a llvm.experimental.noalias.scope.decl intrinsic call.
865
866 /// Create a call to the experimental.gc.statepoint intrinsic to
867 /// start a new statepoint sequence.
869 uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee,
870 ArrayRef<Value *> CallArgs, std::optional<ArrayRef<Value *>> DeoptArgs,
871 ArrayRef<Value *> GCArgs, const Twine &Name = "");
872
873 /// Create a call to the experimental.gc.statepoint intrinsic to
874 /// start a new statepoint sequence.
876 CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes,
877 FunctionCallee ActualCallee, uint32_t Flags,
878 ArrayRef<Value *> CallArgs,
879 std::optional<ArrayRef<Use>> TransitionArgs,
880 std::optional<ArrayRef<Use>> DeoptArgs,
881 ArrayRef<Value *> GCArgs, const Twine &Name = "");
882
883 /// Conveninence function for the common case when CallArgs are filled
884 /// in using ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be
885 /// .get()'ed to get the Value pointer.
887 CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes,
888 FunctionCallee ActualCallee, ArrayRef<Use> CallArgs,
889 std::optional<ArrayRef<Value *>> DeoptArgs,
890 ArrayRef<Value *> GCArgs, const Twine &Name = "");
891
892 /// Create an invoke to the experimental.gc.statepoint intrinsic to
893 /// start a new statepoint sequence.
896 FunctionCallee ActualInvokee, BasicBlock *NormalDest,
897 BasicBlock *UnwindDest, ArrayRef<Value *> InvokeArgs,
898 std::optional<ArrayRef<Value *>> DeoptArgs,
899 ArrayRef<Value *> GCArgs, const Twine &Name = "");
900
901 /// Create an invoke to the experimental.gc.statepoint intrinsic to
902 /// start a new statepoint sequence.
904 uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee,
905 BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags,
906 ArrayRef<Value *> InvokeArgs, std::optional<ArrayRef<Use>> TransitionArgs,
907 std::optional<ArrayRef<Use>> DeoptArgs, ArrayRef<Value *> GCArgs,
908 const Twine &Name = "");
909
910 // Convenience function for the common case when CallArgs are filled in using
911 // ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be .get()'ed to
912 // get the Value *.
915 FunctionCallee ActualInvokee, BasicBlock *NormalDest,
916 BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs,
917 std::optional<ArrayRef<Value *>> DeoptArgs,
918 ArrayRef<Value *> GCArgs, const Twine &Name = "");
919
920 /// Create a call to the experimental.gc.result intrinsic to extract
921 /// the result from a call wrapped in a statepoint.
922 LLVM_ABI CallInst *CreateGCResult(Instruction *Statepoint, Type *ResultType,
923 const Twine &Name = "");
924
925 /// Create a call to the experimental.gc.relocate intrinsics to
926 /// project the relocated value of one pointer from the statepoint.
927 LLVM_ABI CallInst *CreateGCRelocate(Instruction *Statepoint, int BaseOffset,
928 int DerivedOffset, Type *ResultType,
929 const Twine &Name = "");
930
931 /// Create a call to the experimental.gc.pointer.base intrinsic to get the
932 /// base pointer for the specified derived pointer.
934 const Twine &Name = "");
935
936 /// Create a call to the experimental.gc.get.pointer.offset intrinsic to get
937 /// the offset of the specified derived pointer from its base.
939 const Twine &Name = "");
940
941 /// Create a call to llvm.vscale.<Ty>().
942 Value *CreateVScale(Type *Ty, const Twine &Name = "") {
943 return CreateIntrinsic(Intrinsic::vscale, {Ty}, {}, {}, Name);
944 }
945
946 /// Create an expression which evaluates to the number of elements in \p EC
947 /// at runtime. This can result in poison if type \p Ty is not big enough to
948 /// hold the value.
950
951 /// Create an expression which evaluates to the number of units in \p Size
952 /// at runtime. This works for both units of bits and bytes. This can result
953 /// in poison if type \p Ty is not big enough to hold the value.
955
956 /// Get allocation size of an alloca as a runtime Value* (handles both static
957 /// and dynamic allocas and vscale factor).
959
960 /// Creates a vector of type \p DstType with the linear sequence <0, 1, ...>
961 LLVM_ABI Value *CreateStepVector(Type *DstType, const Twine &Name = "");
962
963 /// Create a call to intrinsic \p ID with 1 operand which is mangled on its
964 /// type.
966 FMFSource FMFSource = {},
967 const Twine &Name = "");
968
969 /// Create a call to intrinsic \p ID with 2 operands which is mangled on the
970 /// first type.
972 Value *RHS, FMFSource FMFSource = {},
973 const Twine &Name = "");
974
975 /// Create a call to intrinsic \p ID with \p Args, mangled using
976 /// \p OverloadTypes. If \p FMFSource is provided, copy fast-math-flags from
977 /// that instruction to the intrinsic. It is guaranteed not to fold.
979 Intrinsic::ID ID, ArrayRef<Type *> OverloadTypes, ArrayRef<Value *> Args,
980 FMFSource FMFSource = {}, const Twine &Name = "",
981 ArrayRef<OperandBundleDef> OpBundles = {});
982
983 /// Create a call to intrinsic \p ID with \p RetTy and \p Args. If
984 /// \p FMFSource is provided, copy fast-math-flags from that instruction to
985 /// the intrinsic. It is guaranteed not to fold.
987 Intrinsic::ID ID,
989 FMFSource FMFSource = {},
990 const Twine &Name = "");
991
992 /// Create a call to non-overloaded intrinsic \p ID with \p Args. If
993 /// \p FMFSource is provided, copy fast-math-flags from that instruction to
994 /// the intrinsic. It is guranteed not to fold.
997 FMFSource FMFSource = {},
998 const Twine &Name = "") {
999 return CreateIntrinsicWithoutFolding(ID, /*Types=*/{}, Args, FMFSource,
1000 Name);
1001 }
1002
1003 /// Variant to create a possibly constant-folded intrinsic. An optional \p
1004 /// SetFn is called if the intrinsic doesn't fold, and can be used to set
1005 /// things like attributes.
1007 Intrinsic::ID ID, ArrayRef<Type *> OverloadTypes, ArrayRef<Value *> Args,
1008 FMFSource FMFSource = {}, const Twine &Name = "",
1009 ArrayRef<OperandBundleDef> OpBundles = {},
1010 function_ref<void(CallInst *)> SetFn = [](CallInst *) {});
1011
1012 /// Variant to create a possibly constant-folded intrinsic. An optional \p
1013 /// SetFn is called if the intrinsic doesn't fold, and can be used to set
1014 /// things like attributes.
1016 Type *RetTy, Intrinsic::ID ID, ArrayRef<Value *> Args,
1017 FMFSource FMFSource = {}, const Twine &Name = "",
1018 function_ref<void(CallInst *)> SetFn = [](CallInst *) {});
1019
1020 /// Variant to create a possibly constant-folded intrinsic. An optional \p
1021 /// SetFn is called if the intrinsic doesn't fold, and can be used to set
1022 /// things like attributes.
1025 const Twine &Name = "",
1026 function_ref<void(CallInst *)> SetFn = [](CallInst *) {}) {
1027 return CreateIntrinsic(ID, /*Types=*/{}, Args, FMFSource, Name, {}, SetFn);
1028 }
1029
1030 /// Create call to the fabs intrinsic.
1032 const Twine &Name = "") {
1033 return CreateUnaryIntrinsic(Intrinsic::fabs, V, FMFSource, Name);
1034 }
1035
1036 /// Create call to the minnum intrinsic.
1038 const Twine &Name = "") {
1039 if (IsFPConstrained) {
1041 Intrinsic::experimental_constrained_minnum, LHS, RHS, FMFSource,
1042 Name);
1043 }
1044
1045 return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, FMFSource, Name);
1046 }
1047
1048 /// Create call to the maxnum intrinsic.
1050 const Twine &Name = "") {
1051 if (IsFPConstrained) {
1053 Intrinsic::experimental_constrained_maxnum, LHS, RHS, FMFSource,
1054 Name);
1055 }
1056
1057 return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, FMFSource, Name);
1058 }
1059
1060 /// Create call to the minimum intrinsic.
1061 Value *CreateMinimum(Value *LHS, Value *RHS, const Twine &Name = "") {
1062 return CreateBinaryIntrinsic(Intrinsic::minimum, LHS, RHS, nullptr, Name);
1063 }
1064
1065 /// Create call to the maximum intrinsic.
1066 Value *CreateMaximum(Value *LHS, Value *RHS, const Twine &Name = "") {
1067 return CreateBinaryIntrinsic(Intrinsic::maximum, LHS, RHS, nullptr, Name);
1068 }
1069
1070 /// Create call to the minimumnum intrinsic.
1071 Value *CreateMinimumNum(Value *LHS, Value *RHS, const Twine &Name = "") {
1072 return CreateBinaryIntrinsic(Intrinsic::minimumnum, LHS, RHS, nullptr,
1073 Name);
1074 }
1075
1076 /// Create call to the maximum intrinsic.
1077 Value *CreateMaximumNum(Value *LHS, Value *RHS, const Twine &Name = "") {
1078 return CreateBinaryIntrinsic(Intrinsic::maximumnum, LHS, RHS, nullptr,
1079 Name);
1080 }
1081
1082 /// Create call to the copysign intrinsic.
1084 const Twine &Name = "") {
1085 return CreateBinaryIntrinsic(Intrinsic::copysign, LHS, RHS, FMFSource,
1086 Name);
1087 }
1088
1089 /// Create call to the ldexp intrinsic.
1091 const Twine &Name = "") {
1092 assert(!IsFPConstrained && "TODO: Support strictfp");
1093 return CreateIntrinsic(Intrinsic::ldexp, {Src->getType(), Exp->getType()},
1094 {Src, Exp}, FMFSource, Name);
1095 }
1096
1097 /// Create call to the fma intrinsic.
1098 Value *CreateFMA(Value *Factor1, Value *Factor2, Value *Summand,
1099 FMFSource FMFSource = {}, const Twine &Name = "") {
1100 if (IsFPConstrained) {
1102 Intrinsic::experimental_constrained_fma, {Factor1->getType()},
1103 {Factor1, Factor2, Summand}, FMFSource, Name);
1104 }
1105
1106 return CreateIntrinsic(Intrinsic::fma, {Factor1->getType()},
1107 {Factor1, Factor2, Summand}, FMFSource, Name);
1108 }
1109
1110 /// Create a call to the arithmetic_fence intrinsic.
1112 const Twine &Name = "") {
1113 return CreateIntrinsic(Intrinsic::arithmetic_fence, DstType, Val, nullptr,
1114 Name);
1115 }
1116
1117 /// Create a call to the vector.extract intrinsic.
1118 Value *CreateExtractVector(Type *DstType, Value *SrcVec, Value *Idx,
1119 const Twine &Name = "") {
1120 return CreateIntrinsic(Intrinsic::vector_extract,
1121 {DstType, SrcVec->getType()}, {SrcVec, Idx}, nullptr,
1122 Name);
1123 }
1124
1125 /// Create a call to the vector.extract intrinsic.
1127 const Twine &Name = "") {
1128 return CreateExtractVector(DstType, SrcVec, getInt64(Idx), Name);
1129 }
1130
1131 /// Create a call to the vector.insert intrinsic.
1132 Value *CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec,
1133 Value *Idx, const Twine &Name = "") {
1134 return CreateIntrinsic(Intrinsic::vector_insert,
1135 {DstType, SubVec->getType()}, {SrcVec, SubVec, Idx},
1136 nullptr, Name);
1137 }
1138
1139 /// Create a call to the vector.extract intrinsic.
1140 Value *CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec,
1141 uint64_t Idx, const Twine &Name = "") {
1142 return CreateInsertVector(DstType, SrcVec, SubVec, getInt64(Idx), Name);
1143 }
1144
1145 /// Create a call to llvm.stacksave
1146 CallInst *CreateStackSave(const Twine &Name = "") {
1147 const DataLayout &DL = BB->getDataLayout();
1148 return CreateIntrinsicWithoutFolding(Intrinsic::stacksave,
1149 {DL.getAllocaPtrType(Context)}, {},
1150 nullptr, Name);
1151 }
1152
1153 /// Create a call to llvm.stackrestore
1154 CallInst *CreateStackRestore(Value *Ptr, const Twine &Name = "") {
1156 Intrinsic::stackrestore, {Ptr->getType()}, {Ptr}, nullptr, Name);
1157 }
1158
1159 /// Create a call to llvm.experimental_cttz_elts
1161 bool ZeroIsPoison = true,
1162 const Twine &Name = "") {
1163 return CreateIntrinsic(Intrinsic::experimental_cttz_elts,
1164 {ResTy, Mask->getType()},
1165 {Mask, getInt1(ZeroIsPoison)}, nullptr, Name);
1166 }
1167
1168private:
1169 /// Create a call to a masked intrinsic with given Id.
1170 CallInst *CreateMaskedIntrinsic(Intrinsic::ID Id, ArrayRef<Value *> Ops,
1171 ArrayRef<Type *> OverloadedTypes,
1172 const Twine &Name = "");
1173
1174 //===--------------------------------------------------------------------===//
1175 // Instruction creation methods: Terminators
1176 //===--------------------------------------------------------------------===//
1177
1178private:
1179 /// Helper to add branch weight and unpredictable metadata onto an
1180 /// instruction.
1181 /// \returns The annotated instruction.
1182 template <typename InstTy>
1183 InstTy *addBranchMetadata(InstTy *I, MDNode *Weights, MDNode *Unpredictable) {
1184 if (Weights)
1185 I->setMetadata(LLVMContext::MD_prof, Weights);
1186 if (Unpredictable)
1187 I->setMetadata(LLVMContext::MD_unpredictable, Unpredictable);
1188 return I;
1189 }
1190
1191public:
1192 /// Create a 'ret void' instruction.
1196
1197 /// Create a 'ret <val>' instruction.
1201
1202 /// Create a sequence of N insertvalue instructions, with one Value from the
1203 /// RetVals array each, that build a aggregate return value one value at a
1204 /// time, and a ret instruction to return the resulting aggregate value.
1205 ///
1206 /// This is a convenience function for code that uses aggregate return values
1207 /// as a vehicle for having multiple return values.
1210 for (size_t i = 0, N = RetVals.size(); i != N; ++i)
1211 V = CreateInsertValue(V, RetVals[i], i, "mrv");
1212 return Insert(ReturnInst::Create(Context, V));
1213 }
1214
1215 /// Create an unconditional 'br label X' instruction.
1217 return Insert(UncondBrInst::Create(Dest));
1218 }
1219
1220 /// Create a conditional 'br Cond, TrueDest, FalseDest'
1221 /// instruction.
1223 MDNode *BranchWeights = nullptr,
1224 MDNode *Unpredictable = nullptr) {
1225 return Insert(addBranchMetadata(CondBrInst::Create(Cond, True, False),
1226 BranchWeights, Unpredictable));
1227 }
1228
1229 /// Create a conditional 'br Cond, TrueDest, FalseDest'
1230 /// instruction. Copy branch meta data if available.
1232 Instruction *MDSrc) {
1233 CondBrInst *Br = CondBrInst::Create(Cond, True, False);
1234 if (MDSrc) {
1235 unsigned WL[4] = {LLVMContext::MD_prof, LLVMContext::MD_unpredictable,
1236 LLVMContext::MD_make_implicit, LLVMContext::MD_dbg};
1237 Br->copyMetadata(*MDSrc, WL);
1238 }
1239 return Insert(Br);
1240 }
1241
1242 /// Create a switch instruction with the specified value, default dest,
1243 /// and with a hint for the number of cases that will be added (for efficient
1244 /// allocation).
1245 SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10,
1246 MDNode *BranchWeights = nullptr,
1247 MDNode *Unpredictable = nullptr) {
1248 return Insert(addBranchMetadata(SwitchInst::Create(V, Dest, NumCases),
1249 BranchWeights, Unpredictable));
1250 }
1251
1252 /// Create an indirect branch instruction with the specified address
1253 /// operand, with an optional hint for the number of destinations that will be
1254 /// added (for efficient allocation).
1255 IndirectBrInst *CreateIndirectBr(Value *Addr, unsigned NumDests = 10) {
1256 return Insert(IndirectBrInst::Create(Addr, NumDests));
1257 }
1258
1259 /// Create an invoke instruction.
1261 BasicBlock *NormalDest, BasicBlock *UnwindDest,
1262 ArrayRef<Value *> Args,
1264 const Twine &Name = "") {
1265 InvokeInst *II =
1266 InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, OpBundles);
1267 if (IsFPConstrained)
1269 return Insert(II, Name);
1270 }
1272 BasicBlock *NormalDest, BasicBlock *UnwindDest,
1273 ArrayRef<Value *> Args = {},
1274 const Twine &Name = "") {
1275 InvokeInst *II =
1276 InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
1277 if (IsFPConstrained)
1279 return Insert(II, Name);
1280 }
1281
1283 BasicBlock *UnwindDest, ArrayRef<Value *> Args,
1285 const Twine &Name = "") {
1286 return CreateInvoke(Callee.getFunctionType(), Callee.getCallee(),
1287 NormalDest, UnwindDest, Args, OpBundles, Name);
1288 }
1289
1291 BasicBlock *UnwindDest, ArrayRef<Value *> Args = {},
1292 const Twine &Name = "") {
1293 return CreateInvoke(Callee.getFunctionType(), Callee.getCallee(),
1294 NormalDest, UnwindDest, Args, Name);
1295 }
1296
1297 /// \brief Create a callbr instruction.
1299 BasicBlock *DefaultDest,
1300 ArrayRef<BasicBlock *> IndirectDests,
1301 ArrayRef<Value *> Args = {},
1302 const Twine &Name = "") {
1303 return Insert(CallBrInst::Create(Ty, Callee, DefaultDest, IndirectDests,
1304 Args), Name);
1305 }
1307 BasicBlock *DefaultDest,
1308 ArrayRef<BasicBlock *> IndirectDests,
1309 ArrayRef<Value *> Args,
1311 const Twine &Name = "") {
1312 return Insert(
1313 CallBrInst::Create(Ty, Callee, DefaultDest, IndirectDests, Args,
1314 OpBundles), Name);
1315 }
1316
1318 ArrayRef<BasicBlock *> IndirectDests,
1319 ArrayRef<Value *> Args = {},
1320 const Twine &Name = "") {
1321 return CreateCallBr(Callee.getFunctionType(), Callee.getCallee(),
1322 DefaultDest, IndirectDests, Args, Name);
1323 }
1325 ArrayRef<BasicBlock *> IndirectDests,
1326 ArrayRef<Value *> Args,
1328 const Twine &Name = "") {
1329 return CreateCallBr(Callee.getFunctionType(), Callee.getCallee(),
1330 DefaultDest, IndirectDests, Args, Name);
1331 }
1332
1334 return Insert(ResumeInst::Create(Exn));
1335 }
1336
1338 BasicBlock *UnwindBB = nullptr) {
1339 return Insert(CleanupReturnInst::Create(CleanupPad, UnwindBB));
1340 }
1341
1343 unsigned NumHandlers,
1344 const Twine &Name = "") {
1345 return Insert(CatchSwitchInst::Create(ParentPad, UnwindBB, NumHandlers),
1346 Name);
1347 }
1348
1350 const Twine &Name = "") {
1351 return Insert(CatchPadInst::Create(ParentPad, Args), Name);
1352 }
1353
1355 ArrayRef<Value *> Args = {},
1356 const Twine &Name = "") {
1357 return Insert(CleanupPadInst::Create(ParentPad, Args), Name);
1358 }
1359
1363
1367
1368 //===--------------------------------------------------------------------===//
1369 // Instruction creation methods: Binary Operators
1370 //===--------------------------------------------------------------------===//
1371private:
1372 BinaryOperator *CreateInsertNUWNSWBinOp(BinaryOperator::BinaryOps Opc,
1373 Value *LHS, Value *RHS,
1374 const Twine &Name,
1375 bool HasNUW, bool HasNSW) {
1377 if (HasNUW) BO->setHasNoUnsignedWrap();
1378 if (HasNSW) BO->setHasNoSignedWrap();
1379 return BO;
1380 }
1381
1382 Instruction *setFPAttrs(Instruction *I, MDNode *FPMD,
1383 FastMathFlags FMF) const {
1384 if (!FPMD)
1385 FPMD = DefaultFPMathTag;
1386 if (FPMD)
1387 I->setMetadata(LLVMContext::MD_fpmath, FPMD);
1388 I->setFastMathFlags(FMF);
1389 return I;
1390 }
1391
1392 Value *getConstrainedFPRounding(std::optional<RoundingMode> Rounding) {
1394
1395 if (Rounding)
1396 UseRounding = *Rounding;
1397
1398 std::optional<StringRef> RoundingStr =
1399 convertRoundingModeToStr(UseRounding);
1400 assert(RoundingStr && "Garbage strict rounding mode!");
1401 auto *RoundingMDS = MDString::get(Context, *RoundingStr);
1402
1403 return MetadataAsValue::get(Context, RoundingMDS);
1404 }
1405
1406 Value *getConstrainedFPExcept(std::optional<fp::ExceptionBehavior> Except) {
1407 std::optional<StringRef> ExceptStr = convertExceptionBehaviorToStr(
1408 Except.value_or(DefaultConstrainedExcept));
1409 assert(ExceptStr && "Garbage strict exception behavior!");
1410 auto *ExceptMDS = MDString::get(Context, *ExceptStr);
1411
1412 return MetadataAsValue::get(Context, ExceptMDS);
1413 }
1414
1415 Value *getConstrainedFPPredicate(CmpInst::Predicate Predicate) {
1416 assert(CmpInst::isFPPredicate(Predicate) &&
1417 Predicate != CmpInst::FCMP_FALSE &&
1418 Predicate != CmpInst::FCMP_TRUE &&
1419 "Invalid constrained FP comparison predicate!");
1420
1421 StringRef PredicateStr = CmpInst::getPredicateName(Predicate);
1422 auto *PredicateMDS = MDString::get(Context, PredicateStr);
1423
1424 return MetadataAsValue::get(Context, PredicateMDS);
1425 }
1426
1427public:
1428 Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "",
1429 bool HasNUW = false, bool HasNSW = false) {
1430 if (Value *V =
1431 Folder.FoldNoWrapBinOp(Instruction::Add, LHS, RHS, HasNUW, HasNSW))
1432 return V;
1433 return CreateInsertNUWNSWBinOp(Instruction::Add, LHS, RHS, Name, HasNUW,
1434 HasNSW);
1435 }
1436
1437 Value *CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name = "") {
1438 return CreateAdd(LHS, RHS, Name, false, true);
1439 }
1440
1441 Value *CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name = "") {
1442 return CreateAdd(LHS, RHS, Name, true, false);
1443 }
1444
1445 Value *CreateSub(Value *LHS, Value *RHS, const Twine &Name = "",
1446 bool HasNUW = false, bool HasNSW = false) {
1447 if (Value *V =
1448 Folder.FoldNoWrapBinOp(Instruction::Sub, LHS, RHS, HasNUW, HasNSW))
1449 return V;
1450 return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name, HasNUW,
1451 HasNSW);
1452 }
1453
1454 Value *CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name = "") {
1455 return CreateSub(LHS, RHS, Name, false, true);
1456 }
1457
1458 Value *CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name = "") {
1459 return CreateSub(LHS, RHS, Name, true, false);
1460 }
1461
1462 Value *CreateMul(Value *LHS, Value *RHS, const Twine &Name = "",
1463 bool HasNUW = false, bool HasNSW = false) {
1464 if (Value *V =
1465 Folder.FoldNoWrapBinOp(Instruction::Mul, LHS, RHS, HasNUW, HasNSW))
1466 return V;
1467 return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name, HasNUW,
1468 HasNSW);
1469 }
1470
1471 Value *CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name = "") {
1472 return CreateMul(LHS, RHS, Name, false, true);
1473 }
1474
1475 Value *CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name = "") {
1476 return CreateMul(LHS, RHS, Name, true, false);
1477 }
1478
1479 Value *CreateUDiv(Value *LHS, Value *RHS, const Twine &Name = "",
1480 bool isExact = false) {
1481 if (Value *V = Folder.FoldExactBinOp(Instruction::UDiv, LHS, RHS, isExact))
1482 return V;
1483 if (!isExact)
1484 return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
1485 return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
1486 }
1487
1488 Value *CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
1489 return CreateUDiv(LHS, RHS, Name, true);
1490 }
1491
1492 Value *CreateSDiv(Value *LHS, Value *RHS, const Twine &Name = "",
1493 bool isExact = false) {
1494 if (Value *V = Folder.FoldExactBinOp(Instruction::SDiv, LHS, RHS, isExact))
1495 return V;
1496 if (!isExact)
1497 return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
1498 return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
1499 }
1500
1501 Value *CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
1502 return CreateSDiv(LHS, RHS, Name, true);
1503 }
1504
1505 Value *CreateURem(Value *LHS, Value *RHS, const Twine &Name = "") {
1506 if (Value *V = Folder.FoldBinOp(Instruction::URem, LHS, RHS))
1507 return V;
1508 return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
1509 }
1510
1511 Value *CreateSRem(Value *LHS, Value *RHS, const Twine &Name = "") {
1512 if (Value *V = Folder.FoldBinOp(Instruction::SRem, LHS, RHS))
1513 return V;
1514 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
1515 }
1516
1517 Value *CreateShl(Value *LHS, Value *RHS, const Twine &Name = "",
1518 bool HasNUW = false, bool HasNSW = false) {
1519 if (Value *V =
1520 Folder.FoldNoWrapBinOp(Instruction::Shl, LHS, RHS, HasNUW, HasNSW))
1521 return V;
1522 return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
1523 HasNUW, HasNSW);
1524 }
1525
1526 Value *CreateShl(Value *LHS, const APInt &RHS, const Twine &Name = "",
1527 bool HasNUW = false, bool HasNSW = false) {
1528 return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1529 HasNUW, HasNSW);
1530 }
1531
1532 Value *CreateShl(Value *LHS, uint64_t RHS, const Twine &Name = "",
1533 bool HasNUW = false, bool HasNSW = false) {
1534 return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1535 HasNUW, HasNSW);
1536 }
1537
1538 Value *CreateLShr(Value *LHS, Value *RHS, const Twine &Name = "",
1539 bool isExact = false) {
1540 if (Value *V = Folder.FoldExactBinOp(Instruction::LShr, LHS, RHS, isExact))
1541 return V;
1542 if (!isExact)
1543 return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
1544 return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
1545 }
1546
1547 Value *CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1548 bool isExact = false) {
1549 return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1550 }
1551
1553 bool isExact = false) {
1554 return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1555 }
1556
1557 Value *CreateAShr(Value *LHS, Value *RHS, const Twine &Name = "",
1558 bool isExact = false) {
1559 if (Value *V = Folder.FoldExactBinOp(Instruction::AShr, LHS, RHS, isExact))
1560 return V;
1561 if (!isExact)
1562 return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
1563 return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
1564 }
1565
1566 Value *CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1567 bool isExact = false) {
1568 return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1569 }
1570
1572 bool isExact = false) {
1573 return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1574 }
1575
1576 Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") {
1577 if (auto *V = Folder.FoldBinOp(Instruction::And, LHS, RHS))
1578 return V;
1579 return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
1580 }
1581
1582 Value *CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1583 return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1584 }
1585
1586 Value *CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1587 return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1588 }
1589
1591 assert(!Ops.empty());
1592 Value *Accum = Ops[0];
1593 for (unsigned i = 1; i < Ops.size(); i++)
1594 Accum = CreateAnd(Accum, Ops[i]);
1595 return Accum;
1596 }
1597
1598 Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "",
1599 bool IsDisjoint = false) {
1600 if (auto *V = Folder.FoldBinOp(Instruction::Or, LHS, RHS))
1601 return V;
1602 return Insert(
1603 IsDisjoint ? BinaryOperator::CreateDisjoint(Instruction::Or, LHS, RHS)
1604 : BinaryOperator::CreateOr(LHS, RHS),
1605 Name);
1606 }
1607
1608 Value *CreateOr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1609 return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1610 }
1611
1612 Value *CreateOr(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1613 return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1614 }
1615
1617 assert(!Ops.empty());
1618 Value *Accum = Ops[0];
1619 for (unsigned i = 1; i < Ops.size(); i++)
1620 Accum = CreateOr(Accum, Ops[i]);
1621 return Accum;
1622 }
1623
1624 Value *CreateDisjointOr(Value *LHS, Value *RHS, const Twine &Name = "") {
1625 return CreateOr(LHS, RHS, Name, true);
1626 }
1627
1628 Value *CreateXor(Value *LHS, Value *RHS, const Twine &Name = "") {
1629 if (Value *V = Folder.FoldBinOp(Instruction::Xor, LHS, RHS))
1630 return V;
1631 return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
1632 }
1633
1634 Value *CreateXor(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1635 return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1636 }
1637
1638 Value *CreateXor(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1639 return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1640 }
1641
1642 Value *CreateFAdd(Value *L, Value *R, const Twine &Name = "",
1643 MDNode *FPMD = nullptr) {
1644 return CreateFAddFMF(L, R, {}, Name, FPMD);
1645 }
1646
1648 const Twine &Name = "", MDNode *FPMD = nullptr) {
1649 if (IsFPConstrained)
1650 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fadd,
1651 L, R, FMFSource, Name, FPMD);
1652
1653 if (Value *V =
1654 Folder.FoldBinOpFMF(Instruction::FAdd, L, R, FMFSource.get(FMF)))
1655 return V;
1656 Instruction *I =
1657 setFPAttrs(BinaryOperator::CreateFAdd(L, R), FPMD, FMFSource.get(FMF));
1658 return Insert(I, Name);
1659 }
1660
1661 Value *CreateFSub(Value *L, Value *R, const Twine &Name = "",
1662 MDNode *FPMD = nullptr) {
1663 return CreateFSubFMF(L, R, {}, Name, FPMD);
1664 }
1665
1667 const Twine &Name = "", MDNode *FPMD = nullptr) {
1668 if (IsFPConstrained)
1669 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fsub,
1670 L, R, FMFSource, Name, FPMD);
1671
1672 if (Value *V =
1673 Folder.FoldBinOpFMF(Instruction::FSub, L, R, FMFSource.get(FMF)))
1674 return V;
1675 Instruction *I =
1676 setFPAttrs(BinaryOperator::CreateFSub(L, R), FPMD, FMFSource.get(FMF));
1677 return Insert(I, Name);
1678 }
1679
1680 Value *CreateFMul(Value *L, Value *R, const Twine &Name = "",
1681 MDNode *FPMD = nullptr) {
1682 return CreateFMulFMF(L, R, {}, Name, FPMD);
1683 }
1684
1686 const Twine &Name = "", MDNode *FPMD = nullptr) {
1687 if (IsFPConstrained)
1688 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fmul,
1689 L, R, FMFSource, Name, FPMD);
1690
1691 if (Value *V =
1692 Folder.FoldBinOpFMF(Instruction::FMul, L, R, FMFSource.get(FMF)))
1693 return V;
1694 Instruction *I =
1695 setFPAttrs(BinaryOperator::CreateFMul(L, R), FPMD, FMFSource.get(FMF));
1696 return Insert(I, Name);
1697 }
1698
1699 Value *CreateFDiv(Value *L, Value *R, const Twine &Name = "",
1700 MDNode *FPMD = nullptr) {
1701 return CreateFDivFMF(L, R, {}, Name, FPMD);
1702 }
1703
1705 const Twine &Name = "", MDNode *FPMD = nullptr) {
1706 if (IsFPConstrained)
1707 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fdiv,
1708 L, R, FMFSource, Name, FPMD);
1709
1710 if (Value *V =
1711 Folder.FoldBinOpFMF(Instruction::FDiv, L, R, FMFSource.get(FMF)))
1712 return V;
1713 Instruction *I =
1714 setFPAttrs(BinaryOperator::CreateFDiv(L, R), FPMD, FMFSource.get(FMF));
1715 return Insert(I, Name);
1716 }
1717
1718 Value *CreateFRem(Value *L, Value *R, const Twine &Name = "",
1719 MDNode *FPMD = nullptr) {
1720 return CreateFRemFMF(L, R, {}, Name, FPMD);
1721 }
1722
1724 const Twine &Name = "", MDNode *FPMD = nullptr) {
1725 if (IsFPConstrained)
1726 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_frem,
1727 L, R, FMFSource, Name, FPMD);
1728
1729 if (Value *V =
1730 Folder.FoldBinOpFMF(Instruction::FRem, L, R, FMFSource.get(FMF)))
1731 return V;
1732 Instruction *I =
1733 setFPAttrs(BinaryOperator::CreateFRem(L, R), FPMD, FMFSource.get(FMF));
1734 return Insert(I, Name);
1735 }
1736
1738 Value *LHS, Value *RHS, const Twine &Name = "",
1739 MDNode *FPMathTag = nullptr) {
1740 return CreateBinOpFMF(Opc, LHS, RHS, {}, Name, FPMathTag);
1741 }
1742
1744 FMFSource FMFSource, const Twine &Name = "",
1745 MDNode *FPMathTag = nullptr) {
1746 if (Value *V = Folder.FoldBinOp(Opc, LHS, RHS))
1747 return V;
1749 if (isa<FPMathOperator>(BinOp))
1750 setFPAttrs(BinOp, FPMathTag, FMFSource.get(FMF));
1751 return Insert(BinOp, Name);
1752 }
1753
1755 bool IsNUW, bool IsNSW, const Twine &Name = "") {
1756 if (Value *V = Folder.FoldNoWrapBinOp(Opc, LHS, RHS, IsNUW, IsNSW))
1757 return V;
1759 if (IsNUW)
1760 BinOp->setHasNoUnsignedWrap(IsNUW);
1761 if (IsNSW)
1762 BinOp->setHasNoSignedWrap(IsNSW);
1763 return Insert(BinOp, Name);
1764 }
1765
1767 bool IsExact, const Twine &Name = "") {
1768 if (Value *V = Folder.FoldExactBinOp(Opc, LHS, RHS, IsExact))
1769 return V;
1771 if (IsExact)
1772 BinOp->setIsExact(IsExact);
1773 return Insert(BinOp, Name);
1774 }
1775
1776 Value *CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name = "",
1777 Instruction *MDFrom = nullptr) {
1778 assert(Cond2->getType()->isIntOrIntVectorTy(1));
1779 return CreateSelect(Cond1, Cond2,
1780 ConstantInt::getNullValue(Cond2->getType()), Name,
1781 MDFrom);
1782 }
1783
1784 Value *CreateLogicalOr(Value *Cond1, Value *Cond2, const Twine &Name = "",
1785 Instruction *MDFrom = nullptr) {
1786 assert(Cond2->getType()->isIntOrIntVectorTy(1));
1787 return CreateSelect(Cond1, ConstantInt::getAllOnesValue(Cond2->getType()),
1788 Cond2, Name, MDFrom);
1789 }
1790
1792 const Twine &Name = "",
1793 Instruction *MDFrom = nullptr) {
1794 switch (Opc) {
1795 case Instruction::And:
1796 return CreateLogicalAnd(Cond1, Cond2, Name, MDFrom);
1797 case Instruction::Or:
1798 return CreateLogicalOr(Cond1, Cond2, Name, MDFrom);
1799 default:
1800 break;
1801 }
1802 llvm_unreachable("Not a logical operation.");
1803 }
1804
1805 // NOTE: this is sequential, non-commutative, ordered reduction!
1807 assert(!Ops.empty());
1808 Value *Accum = Ops[0];
1809 for (unsigned i = 1; i < Ops.size(); i++)
1810 Accum = CreateLogicalOr(Accum, Ops[i]);
1811 return Accum;
1812 }
1813
1814 /// This function is like @ref CreateIntrinsic for constrained fp
1815 /// intrinsics. It sets the rounding mode and exception behavior of
1816 /// the created intrinsic call according to \p Rounding and \p
1817 /// Except and it sets \p FPMathTag as the 'fpmath' metadata, using
1818 /// defaults if a value equals nullopt/null.
1821 FMFSource FMFSource, const Twine &Name, MDNode *FPMathTag = nullptr,
1822 std::optional<RoundingMode> Rounding = std::nullopt,
1823 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1824
1826 Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource = {},
1827 const Twine &Name = "", MDNode *FPMathTag = nullptr,
1828 std::optional<RoundingMode> Rounding = std::nullopt,
1829 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1830
1832 Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource = {},
1833 const Twine &Name = "", MDNode *FPMathTag = nullptr,
1834 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1835
1836 Value *CreateNeg(Value *V, const Twine &Name = "", bool HasNSW = false) {
1837 return CreateSub(Constant::getNullValue(V->getType()), V, Name,
1838 /*HasNUW=*/0, HasNSW);
1839 }
1840
1841 Value *CreateNSWNeg(Value *V, const Twine &Name = "") {
1842 return CreateNeg(V, Name, /*HasNSW=*/true);
1843 }
1844
1845 Value *CreateFNeg(Value *V, const Twine &Name = "",
1846 MDNode *FPMathTag = nullptr) {
1847 return CreateFNegFMF(V, {}, Name, FPMathTag);
1848 }
1849
1851 MDNode *FPMathTag = nullptr) {
1852 if (Value *Res =
1853 Folder.FoldUnOpFMF(Instruction::FNeg, V, FMFSource.get(FMF)))
1854 return Res;
1855 return Insert(
1856 setFPAttrs(UnaryOperator::CreateFNeg(V), FPMathTag, FMFSource.get(FMF)),
1857 Name);
1858 }
1859
1860 Value *CreateNot(Value *V, const Twine &Name = "") {
1861 return CreateXor(V, Constant::getAllOnesValue(V->getType()), Name);
1862 }
1863
1865 Value *V, const Twine &Name = "",
1866 MDNode *FPMathTag = nullptr) {
1867 return CreateUnOpFMF(Opc, V, {}, Name, FPMathTag);
1868 }
1869
1871 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
1872 if (Value *Res = Folder.FoldUnOpFMF(Opc, V, FMFSource.get(FMF)))
1873 return Res;
1875 if (isa<FPMathOperator>(UnOp))
1876 setFPAttrs(UnOp, FPMathTag, FMFSource.get(FMF));
1877 return Insert(UnOp, Name);
1878 }
1879
1880 /// Create either a UnaryOperator or BinaryOperator depending on \p Opc.
1881 /// Correct number of operands must be passed accordingly.
1883 const Twine &Name = "",
1884 MDNode *FPMathTag = nullptr);
1885
1886 //===--------------------------------------------------------------------===//
1887 // Instruction creation methods: Memory Instructions
1888 //===--------------------------------------------------------------------===//
1889
1890 AllocaInst *CreateAlloca(Type *Ty, unsigned AddrSpace,
1891 Value *ArraySize = nullptr, const Twine &Name = "") {
1892 const DataLayout &DL = BB->getDataLayout();
1893 Align AllocaAlign = DL.getPrefTypeAlign(Ty);
1894 return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
1895 }
1896
1897 AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = nullptr,
1898 const Twine &Name = "") {
1899 const DataLayout &DL = BB->getDataLayout();
1900 Align AllocaAlign = DL.getPrefTypeAlign(Ty);
1901 unsigned AddrSpace = DL.getAllocaAddrSpace();
1902 return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
1903 }
1904
1906 const DataLayout &DL = BB->getDataLayout();
1907 PointerType *PtrTy = DL.getAllocaPtrType(Context);
1908 auto *Output = CreateIntrinsicWithoutFolding(Intrinsic::structured_alloca,
1909 {PtrTy}, {}, {}, Name);
1910 Output->addRetAttr(
1911 Attribute::get(getContext(), Attribute::ElementType, BaseType));
1912 return Output;
1913 }
1914
1915 /// Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of
1916 /// converting the string to 'bool' for the isVolatile parameter.
1917 LoadInst *CreateLoad(Type *Ty, Value *Ptr, const char *Name) {
1918 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), Name);
1919 }
1920
1921 LoadInst *CreateLoad(Type *Ty, Value *Ptr, const Twine &Name = "") {
1922 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), Name);
1923 }
1924
1925 LoadInst *CreateLoad(Type *Ty, Value *Ptr, bool isVolatile,
1926 const Twine &Name = "") {
1927 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), isVolatile, Name);
1928 }
1929
1931 const LoadStoreInstProperties &Props,
1932 const Twine &Name = "") {
1933 return Insert(new LoadInst(Ty, Ptr, Twine(), Props), Name);
1934 }
1935
1936 StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) {
1937 return CreateAlignedStore(Val, Ptr, MaybeAlign(), isVolatile);
1938 }
1939
1941 const LoadStoreInstProperties &Props) {
1942 return Insert(new StoreInst(Val, Ptr, Props));
1943 }
1944
1946 const char *Name) {
1947 return CreateAlignedLoad(Ty, Ptr, Align, /*isVolatile*/false, Name);
1948 }
1949
1951 const Twine &Name = "") {
1952 return CreateAlignedLoad(Ty, Ptr, Align, /*isVolatile*/false, Name);
1953 }
1954
1956 bool isVolatile, const Twine &Name = "") {
1957 if (!Align) {
1958 const DataLayout &DL = BB->getDataLayout();
1959 Align = DL.getABITypeAlign(Ty);
1960 }
1961 return Insert(new LoadInst(Ty, Ptr, Twine(), isVolatile, *Align), Name);
1962 }
1963
1965 bool isVolatile = false) {
1966 if (!Align) {
1967 const DataLayout &DL = BB->getDataLayout();
1968 Align = DL.getABITypeAlign(Val->getType());
1969 }
1970 return Insert(new StoreInst(Val, Ptr, isVolatile, *Align));
1971 }
1974 const Twine &Name = "") {
1975 return Insert(new FenceInst(Context, Ordering, SSID), Name);
1976 }
1977
1980 AtomicOrdering SuccessOrdering,
1981 AtomicOrdering FailureOrdering,
1983 if (!Align) {
1984 const DataLayout &DL = BB->getDataLayout();
1985 Align = llvm::Align(DL.getTypeStoreSize(New->getType()));
1986 }
1987
1988 return Insert(new AtomicCmpXchgInst(Ptr, Cmp, New, *Align, SuccessOrdering,
1989 FailureOrdering, SSID));
1990 }
1991
1993 Value *Val, MaybeAlign Align,
1994 AtomicOrdering Ordering,
1996 bool Elementwise = false) {
1997 if (!Align) {
1998 const DataLayout &DL = BB->getDataLayout();
1999 Align = llvm::Align(DL.getTypeStoreSize(Val->getType()));
2000 }
2001
2002 return Insert(
2003 new AtomicRMWInst(Op, Ptr, Val, *Align, Ordering, SSID, Elementwise));
2004 }
2005
2007 ArrayRef<Value *> Indices,
2008 const Twine &Name = "") {
2010 Args.push_back(PtrBase);
2011 llvm::append_range(Args, Indices);
2012
2013 return CreateIntrinsic(
2014 Intrinsic::structured_gep, {PtrBase->getType()}, Args, {}, Name, {},
2015 [&](CallInst *Output) {
2016 Output->addParamAttr(
2017 0,
2018 Attribute::get(getContext(), Attribute::ElementType, BaseType));
2019 });
2020 }
2021
2023 const Twine &Name = "",
2025 if (auto *V = Folder.FoldGEP(BB->getDataLayout(), Ty, Ptr, IdxList, NW))
2026 return V;
2027 return Insert(GetElementPtrInst::Create(Ty, Ptr, IdxList, NW), Name);
2028 }
2029
2031 const Twine &Name = "") {
2032 return CreateGEP(Ty, Ptr, IdxList, Name, GEPNoWrapFlags::inBounds());
2033 }
2034
2035 Value *CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0,
2036 const Twine &Name = "") {
2037 Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Idx0);
2038 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::none());
2039 }
2040
2041 Value *CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0,
2042 const Twine &Name = "") {
2043 Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Idx0);
2044 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::inBounds());
2045 }
2046
2047 Value *CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1,
2048 const Twine &Name = "",
2050 Value *Idxs[] = {
2051 ConstantInt::get(Type::getInt32Ty(Context), Idx0),
2052 ConstantInt::get(Type::getInt32Ty(Context), Idx1)
2053 };
2054 return CreateGEP(Ty, Ptr, Idxs, Name, NWFlags);
2055 }
2056
2057 Value *CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0,
2058 unsigned Idx1, const Twine &Name = "") {
2059 Value *Idxs[] = {
2060 ConstantInt::get(Type::getInt32Ty(Context), Idx0),
2061 ConstantInt::get(Type::getInt32Ty(Context), Idx1)
2062 };
2063 return CreateGEP(Ty, Ptr, Idxs, Name, GEPNoWrapFlags::inBounds());
2064 }
2065
2067 const Twine &Name = "") {
2068 Value *Idx = ConstantInt::get(Type::getInt64Ty(Context), Idx0);
2069 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::none());
2070 }
2071
2073 const Twine &Name = "") {
2074 Value *Idx = ConstantInt::get(Type::getInt64Ty(Context), Idx0);
2075 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::inBounds());
2076 }
2077
2079 const Twine &Name = "") {
2080 Value *Idxs[] = {
2081 ConstantInt::get(Type::getInt64Ty(Context), Idx0),
2082 ConstantInt::get(Type::getInt64Ty(Context), Idx1)
2083 };
2084 return CreateGEP(Ty, Ptr, Idxs, Name, GEPNoWrapFlags::none());
2085 }
2086
2088 uint64_t Idx1, const Twine &Name = "") {
2089 Value *Idxs[] = {
2090 ConstantInt::get(Type::getInt64Ty(Context), Idx0),
2091 ConstantInt::get(Type::getInt64Ty(Context), Idx1)
2092 };
2093 return CreateGEP(Ty, Ptr, Idxs, Name, GEPNoWrapFlags::inBounds());
2094 }
2095
2096 Value *CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx,
2097 const Twine &Name = "") {
2098 GEPNoWrapFlags NWFlags =
2100 return CreateConstGEP2_32(Ty, Ptr, 0, Idx, Name, NWFlags);
2101 }
2102
2103 Value *CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name = "",
2105 return CreateGEP(getInt8Ty(), Ptr, Offset, Name, NW);
2106 }
2107
2109 const Twine &Name = "") {
2110 return CreateGEP(getInt8Ty(), Ptr, Offset, Name,
2112 }
2113
2114 //===--------------------------------------------------------------------===//
2115 // Instruction creation methods: Cast/Conversion Operators
2116 //===--------------------------------------------------------------------===//
2117
2118 Value *CreateTrunc(Value *V, Type *DestTy, const Twine &Name = "",
2119 bool IsNUW = false, bool IsNSW = false) {
2120 if (V->getType() == DestTy)
2121 return V;
2122 if (Value *Folded = Folder.FoldCast(Instruction::Trunc, V, DestTy))
2123 return Folded;
2124 Instruction *I = CastInst::Create(Instruction::Trunc, V, DestTy);
2125 if (IsNUW)
2126 I->setHasNoUnsignedWrap();
2127 if (IsNSW)
2128 I->setHasNoSignedWrap();
2129 return Insert(I, Name);
2130 }
2131
2132 Value *CreateZExt(Value *V, Type *DestTy, const Twine &Name = "",
2133 bool IsNonNeg = false) {
2134 if (V->getType() == DestTy)
2135 return V;
2136 if (Value *Folded = Folder.FoldCast(Instruction::ZExt, V, DestTy))
2137 return Folded;
2138 Instruction *I = Insert(new ZExtInst(V, DestTy), Name);
2139 if (IsNonNeg)
2140 I->setNonNeg();
2141 return I;
2142 }
2143
2144 Value *CreateSExt(Value *V, Type *DestTy, const Twine &Name = "") {
2145 return CreateCast(Instruction::SExt, V, DestTy, Name);
2146 }
2147
2148 /// Create a ZExt or Trunc from the integer value V to DestTy. Return
2149 /// the value untouched if the type of V is already DestTy.
2151 const Twine &Name = "") {
2152 assert(V->getType()->isIntOrIntVectorTy() &&
2153 DestTy->isIntOrIntVectorTy() &&
2154 "Can only zero extend/truncate integers!");
2155 Type *VTy = V->getType();
2156 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2157 return CreateZExt(V, DestTy, Name);
2158 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2159 return CreateTrunc(V, DestTy, Name);
2160 return V;
2161 }
2162
2163 /// Create a SExt or Trunc from the integer value V to DestTy. Return
2164 /// the value untouched if the type of V is already DestTy.
2166 const Twine &Name = "") {
2167 assert(V->getType()->isIntOrIntVectorTy() &&
2168 DestTy->isIntOrIntVectorTy() &&
2169 "Can only sign extend/truncate integers!");
2170 Type *VTy = V->getType();
2171 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2172 return CreateSExt(V, DestTy, Name);
2173 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2174 return CreateTrunc(V, DestTy, Name);
2175 return V;
2176 }
2177
2178 Value *CreateFPToUI(Value *V, Type *DestTy, const Twine &Name = "") {
2179 if (IsFPConstrained)
2180 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptoui,
2181 V, DestTy, nullptr, Name);
2182 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
2183 }
2184
2185 Value *CreateFPToSI(Value *V, Type *DestTy, const Twine &Name = "") {
2186 if (IsFPConstrained)
2187 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptosi,
2188 V, DestTy, nullptr, Name);
2189 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
2190 }
2191
2192 Value *CreateUIToFP(Value *V, Type *DestTy, const Twine &Name = "",
2193 bool IsNonNeg = false, MDNode *FPMathTag = nullptr) {
2194 if (IsFPConstrained)
2195 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_uitofp,
2196 V, DestTy, nullptr, Name);
2197 Value *Val = CreateCast(Instruction::UIToFP, V, DestTy, Name, FPMathTag);
2198 if (auto *I = dyn_cast<Instruction>(Val))
2199 if (IsNonNeg)
2200 I->setNonNeg();
2201 return Val;
2202 }
2203
2204 Value *CreateSIToFP(Value *V, Type *DestTy, const Twine &Name = "",
2205 MDNode *FPMathTag = nullptr) {
2206 if (IsFPConstrained)
2207 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_sitofp,
2208 V, DestTy, nullptr, Name);
2209 return CreateCast(Instruction::SIToFP, V, DestTy, Name, FPMathTag);
2210 }
2211
2212 Value *CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name = "",
2213 MDNode *FPMathTag = nullptr) {
2214 return CreateFPTruncFMF(V, DestTy, {}, Name, FPMathTag);
2215 }
2216
2218 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2219 if (IsFPConstrained)
2221 Intrinsic::experimental_constrained_fptrunc, V, DestTy, FMFSource,
2222 Name, FPMathTag);
2223 return CreateCast(Instruction::FPTrunc, V, DestTy, Name, FPMathTag,
2224 FMFSource);
2225 }
2226
2227 Value *CreateFPExt(Value *V, Type *DestTy, const Twine &Name = "",
2228 MDNode *FPMathTag = nullptr) {
2229 return CreateFPExtFMF(V, DestTy, {}, Name, FPMathTag);
2230 }
2231
2233 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2234 if (IsFPConstrained)
2235 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fpext,
2236 V, DestTy, FMFSource, Name, FPMathTag);
2237 return CreateCast(Instruction::FPExt, V, DestTy, Name, FPMathTag,
2238 FMFSource);
2239 }
2240 Value *CreatePtrToAddr(Value *V, const Twine &Name = "") {
2241 return CreateCast(Instruction::PtrToAddr, V,
2242 BB->getDataLayout().getAddressType(V->getType()), Name);
2243 }
2245 const Twine &Name = "") {
2246 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
2247 }
2248
2250 const Twine &Name = "") {
2251 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
2252 }
2253
2255 const Twine &Name = "") {
2256 return CreateCast(Instruction::BitCast, V, DestTy, Name);
2257 }
2258
2259 Value *CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name = "",
2260 bool IsNonNull = false) {
2261 if (V->getType() == DestTy)
2262 return V;
2263 if (Value *Folded = Folder.FoldCast(Instruction::AddrSpaceCast, V, DestTy))
2264 return Folded;
2265 Instruction *I = Insert(new AddrSpaceCastInst(V, DestTy), Name);
2266 if (IsNonNull)
2267 cast<AddrSpaceCastInst>(I)->setNonNull();
2268 return I;
2269 }
2270
2271 Value *CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2272 Instruction::CastOps CastOp =
2273 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2274 ? Instruction::BitCast
2275 : Instruction::ZExt;
2276 return CreateCast(CastOp, V, DestTy, Name);
2277 }
2278
2279 Value *CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2280 Instruction::CastOps CastOp =
2281 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2282 ? Instruction::BitCast
2283 : Instruction::SExt;
2284 return CreateCast(CastOp, V, DestTy, Name);
2285 }
2286
2287 Value *CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2288 Instruction::CastOps CastOp =
2289 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2290 ? Instruction::BitCast
2291 : Instruction::Trunc;
2292 return CreateCast(CastOp, V, DestTy, Name);
2293 }
2294
2296 const Twine &Name = "", MDNode *FPMathTag = nullptr,
2297 FMFSource FMFSource = {}) {
2298 if (V->getType() == DestTy)
2299 return V;
2300 if (Value *Folded = Folder.FoldCast(Op, V, DestTy))
2301 return Folded;
2302 Instruction *Cast = CastInst::Create(Op, V, DestTy);
2303 if (isa<FPMathOperator>(Cast))
2304 setFPAttrs(Cast, FPMathTag, FMFSource.get(FMF));
2305 return Insert(Cast, Name);
2306 }
2307
2309 const Twine &Name = "") {
2310 if (V->getType() == DestTy)
2311 return V;
2312 if (auto *VC = dyn_cast<Constant>(V))
2313 return Insert(Folder.CreatePointerCast(VC, DestTy), Name);
2314 return Insert(CastInst::CreatePointerCast(V, DestTy), Name);
2315 }
2316
2317 // With opaque pointers enabled, this can be substituted with
2318 // CreateAddrSpaceCast.
2319 // TODO: Replace uses of this method and remove the method itself.
2321 const Twine &Name = "") {
2322 if (V->getType() == DestTy)
2323 return V;
2324
2325 if (auto *VC = dyn_cast<Constant>(V)) {
2326 return Insert(Folder.CreatePointerBitCastOrAddrSpaceCast(VC, DestTy),
2327 Name);
2328 }
2329
2331 Name);
2332 }
2333
2335 const Twine &Name = "") {
2336 Instruction::CastOps CastOp =
2337 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2338 ? Instruction::Trunc
2339 : (isSigned ? Instruction::SExt : Instruction::ZExt);
2340 return CreateCast(CastOp, V, DestTy, Name);
2341 }
2342
2344 const Twine &Name = "") {
2345 if (V->getType() == DestTy)
2346 return V;
2347 if (V->getType()->isPtrOrPtrVectorTy() && DestTy->isIntOrIntVectorTy())
2348 return CreatePtrToInt(V, DestTy, Name);
2349 if (V->getType()->isIntOrIntVectorTy() && DestTy->isPtrOrPtrVectorTy())
2350 return CreateIntToPtr(V, DestTy, Name);
2351
2352 return CreateBitCast(V, DestTy, Name);
2353 }
2354
2355 Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "",
2356 MDNode *FPMathTag = nullptr) {
2357 Instruction::CastOps CastOp =
2358 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2359 ? Instruction::FPTrunc
2360 : Instruction::FPExt;
2361 return CreateCast(CastOp, V, DestTy, Name, FPMathTag);
2362 }
2363
2365 Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource = {},
2366 const Twine &Name = "", MDNode *FPMathTag = nullptr,
2367 std::optional<RoundingMode> Rounding = std::nullopt,
2368 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2369
2370 // Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
2371 // compile time error, instead of converting the string to bool for the
2372 // isSigned parameter.
2373 Value *CreateIntCast(Value *, Type *, const char *) = delete;
2374
2375 /// Cast between aggregate types that must have identical structure but may
2376 /// differ in their leaf types. The leaf values are recursively extracted,
2377 /// casted, and then reinserted into a value of type DestTy. The leaf types
2378 /// must be castable using a bitcast or ptrcast, because signedness is
2379 /// not specified.
2381
2382 /// Create a chain of casts to convert V to NewTy, preserving the bit pattern
2383 /// of V. This may involve multiple casts (e.g., ptr -> i64 -> <2 x i32>).
2384 /// The created cast instructions are inserted into the current basic block.
2385 /// If no casts are needed, V is returned.
2387 Type *NewTy);
2388
2389 //===--------------------------------------------------------------------===//
2390 // Instruction creation methods: Compare Instructions
2391 //===--------------------------------------------------------------------===//
2392
2393 Value *CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name = "") {
2394 return CreateICmp(ICmpInst::ICMP_EQ, LHS, RHS, Name);
2395 }
2396
2397 Value *CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name = "") {
2398 return CreateICmp(ICmpInst::ICMP_NE, LHS, RHS, Name);
2399 }
2400
2401 Value *CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name = "") {
2402 return CreateICmp(ICmpInst::ICMP_UGT, LHS, RHS, Name);
2403 }
2404
2405 Value *CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name = "") {
2406 return CreateICmp(ICmpInst::ICMP_UGE, LHS, RHS, Name);
2407 }
2408
2409 Value *CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name = "") {
2410 return CreateICmp(ICmpInst::ICMP_ULT, LHS, RHS, Name);
2411 }
2412
2413 Value *CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name = "") {
2414 return CreateICmp(ICmpInst::ICMP_ULE, LHS, RHS, Name);
2415 }
2416
2417 Value *CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name = "") {
2418 return CreateICmp(ICmpInst::ICMP_SGT, LHS, RHS, Name);
2419 }
2420
2421 Value *CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name = "") {
2422 return CreateICmp(ICmpInst::ICMP_SGE, LHS, RHS, Name);
2423 }
2424
2425 Value *CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name = "") {
2426 return CreateICmp(ICmpInst::ICMP_SLT, LHS, RHS, Name);
2427 }
2428
2429 Value *CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name = "") {
2430 return CreateICmp(ICmpInst::ICMP_SLE, LHS, RHS, Name);
2431 }
2432
2433 Value *CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name = "",
2434 MDNode *FPMathTag = nullptr) {
2435 return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name, FPMathTag);
2436 }
2437
2438 Value *CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name = "",
2439 MDNode *FPMathTag = nullptr) {
2440 return CreateFCmp(FCmpInst::FCMP_OGT, LHS, RHS, Name, FPMathTag);
2441 }
2442
2443 Value *CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name = "",
2444 MDNode *FPMathTag = nullptr) {
2445 return CreateFCmp(FCmpInst::FCMP_OGE, LHS, RHS, Name, FPMathTag);
2446 }
2447
2448 Value *CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name = "",
2449 MDNode *FPMathTag = nullptr) {
2450 return CreateFCmp(FCmpInst::FCMP_OLT, LHS, RHS, Name, FPMathTag);
2451 }
2452
2453 Value *CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name = "",
2454 MDNode *FPMathTag = nullptr) {
2455 return CreateFCmp(FCmpInst::FCMP_OLE, LHS, RHS, Name, FPMathTag);
2456 }
2457
2458 Value *CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name = "",
2459 MDNode *FPMathTag = nullptr) {
2460 return CreateFCmp(FCmpInst::FCMP_ONE, LHS, RHS, Name, FPMathTag);
2461 }
2462
2463 Value *CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name = "",
2464 MDNode *FPMathTag = nullptr) {
2465 return CreateFCmp(FCmpInst::FCMP_ORD, LHS, RHS, Name, FPMathTag);
2466 }
2467
2468 Value *CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name = "",
2469 MDNode *FPMathTag = nullptr) {
2470 return CreateFCmp(FCmpInst::FCMP_UNO, LHS, RHS, Name, FPMathTag);
2471 }
2472
2473 Value *CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name = "",
2474 MDNode *FPMathTag = nullptr) {
2475 return CreateFCmp(FCmpInst::FCMP_UEQ, LHS, RHS, Name, FPMathTag);
2476 }
2477
2478 Value *CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name = "",
2479 MDNode *FPMathTag = nullptr) {
2480 return CreateFCmp(FCmpInst::FCMP_UGT, LHS, RHS, Name, FPMathTag);
2481 }
2482
2483 Value *CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name = "",
2484 MDNode *FPMathTag = nullptr) {
2485 return CreateFCmp(FCmpInst::FCMP_UGE, LHS, RHS, Name, FPMathTag);
2486 }
2487
2488 Value *CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name = "",
2489 MDNode *FPMathTag = nullptr) {
2490 return CreateFCmp(FCmpInst::FCMP_ULT, LHS, RHS, Name, FPMathTag);
2491 }
2492
2493 Value *CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name = "",
2494 MDNode *FPMathTag = nullptr) {
2495 return CreateFCmp(FCmpInst::FCMP_ULE, LHS, RHS, Name, FPMathTag);
2496 }
2497
2498 Value *CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name = "",
2499 MDNode *FPMathTag = nullptr) {
2500 return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name, FPMathTag);
2501 }
2502
2504 const Twine &Name = "") {
2505 if (auto *V = Folder.FoldCmp(P, LHS, RHS))
2506 return V;
2507 return Insert(new ICmpInst(P, LHS, RHS), Name);
2508 }
2509
2510 // Create a quiet floating-point comparison (i.e. one that raises an FP
2511 // exception only in the case where an input is a signaling NaN).
2512 // Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2514 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2515 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, {}, false);
2516 }
2517
2518 // Create a quiet floating-point comparison (i.e. one that raises an FP
2519 // exception only in the case where an input is a signaling NaN).
2520 // Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2522 FMFSource FMFSource, const Twine &Name = "",
2523 MDNode *FPMathTag = nullptr) {
2524 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, FMFSource, false);
2525 }
2526
2528 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2529 return CmpInst::isFPPredicate(Pred)
2530 ? CreateFCmp(Pred, LHS, RHS, Name, FPMathTag)
2531 : CreateICmp(Pred, LHS, RHS, Name);
2532 }
2533
2534 // Create a signaling floating-point comparison (i.e. one that raises an FP
2535 // exception whenever an input is any NaN, signaling or quiet).
2536 // Note that this differs from CreateFCmp only if IsFPConstrained is true.
2538 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2539 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, {}, true);
2540 }
2541
2542private:
2543 // Helper routine to create either a signaling or a quiet FP comparison.
2544 LLVM_ABI Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS,
2545 const Twine &Name, MDNode *FPMathTag,
2546 FMFSource FMFSource, bool IsSignaling);
2547
2548public:
2551 const Twine &Name = "",
2552 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2553
2554 //===--------------------------------------------------------------------===//
2555 // Instruction creation methods: Other Instructions
2556 //===--------------------------------------------------------------------===//
2557
2558 PHINode *CreatePHI(Type *Ty, unsigned NumReservedValues,
2559 const Twine &Name = "") {
2560 PHINode *Phi = PHINode::Create(Ty, NumReservedValues);
2561 if (isa<FPMathOperator>(Phi))
2562 setFPAttrs(Phi, nullptr /* MDNode* */, FMF);
2563 return Insert(Phi, Name);
2564 }
2565
2566private:
2567 CallInst *createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
2568 const Twine &Name = "", FMFSource FMFSource = {},
2569 ArrayRef<OperandBundleDef> OpBundles = {});
2570
2571public:
2573 ArrayRef<Value *> Args = {}, const Twine &Name = "",
2574 MDNode *FPMathTag = nullptr) {
2575 CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
2576 if (IsFPConstrained)
2578 if (isa<FPMathOperator>(CI))
2579 setFPAttrs(CI, FPMathTag, FMF);
2580 return Insert(CI, Name);
2581 }
2582
2584 FMFSource FMFSource, const Twine &Name = "",
2585 MDNode *FPMathTag = nullptr) {
2586 return CreateCall(FTy, Callee, Args, DefaultOperandBundles, FMFSource, Name,
2587 FPMathTag);
2588 }
2589
2592 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2593 CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
2594 if (IsFPConstrained)
2596 if (isa<FPMathOperator>(CI))
2597 setFPAttrs(CI, FPMathTag, FMF);
2598 return Insert(CI, Name);
2599 }
2600
2603 FMFSource FMFSource, const Twine &Name = "",
2604 MDNode *FPMathTag = nullptr) {
2605 CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
2606 if (IsFPConstrained)
2608 if (isa<FPMathOperator>(CI))
2609 setFPAttrs(CI, FPMathTag, FMFSource.get(FMF));
2610 return Insert(CI, Name);
2611 }
2612
2614 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2615 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args, Name,
2616 FPMathTag);
2617 }
2618
2620 FMFSource FMFSource, const Twine &Name = "",
2621 MDNode *FPMathTag = nullptr) {
2622 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2623 FMFSource, Name, FPMathTag);
2624 }
2625
2628 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2629 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2630 OpBundles, Name, FPMathTag);
2631 }
2632
2635 FMFSource FMFSource, const Twine &Name = "",
2636 MDNode *FPMathTag = nullptr) {
2637 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2638 OpBundles, FMFSource, Name, FPMathTag);
2639 }
2640
2642 Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "",
2643 std::optional<RoundingMode> Rounding = std::nullopt,
2644 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2645
2647 Value *False,
2649 const Twine &Name = "");
2650
2652 Value *False,
2655 const Twine &Name = "");
2656
2657 LLVM_ABI Value *CreateSelect(Value *C, Value *True, Value *False,
2658 const Twine &Name = "",
2659 Instruction *MDFrom = nullptr);
2660 LLVM_ABI Value *CreateSelectFMF(Value *C, Value *True, Value *False,
2661 FMFSource FMFSource, const Twine &Name = "",
2662 Instruction *MDFrom = nullptr);
2663
2664 VAArgInst *CreateVAArg(Value *List, Type *Ty, const Twine &Name = "") {
2665 return Insert(new VAArgInst(List, Ty), Name);
2666 }
2667
2669 const Twine &Name = "") {
2670 if (Value *V = Folder.FoldExtractElement(Vec, Idx))
2671 return V;
2672 return Insert(ExtractElementInst::Create(Vec, Idx), Name);
2673 }
2674
2676 const Twine &Name = "") {
2677 return CreateExtractElement(Vec, getInt64(Idx), Name);
2678 }
2679
2680 Value *CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx,
2681 const Twine &Name = "") {
2682 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2683 }
2684
2686 const Twine &Name = "") {
2687 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2688 }
2689
2691 const Twine &Name = "") {
2692 if (Value *V = Folder.FoldInsertElement(Vec, NewElt, Idx))
2693 return V;
2694 return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
2695 }
2696
2698 const Twine &Name = "") {
2699 return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
2700 }
2701
2703 const Twine &Name = "") {
2704 SmallVector<int, 16> IntMask;
2706 return CreateShuffleVector(V1, V2, IntMask, Name);
2707 }
2708
2709 /// See class ShuffleVectorInst for a description of the mask representation.
2711 const Twine &Name = "") {
2712 if (Value *V = Folder.FoldShuffleVector(V1, V2, Mask))
2713 return V;
2714 return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
2715 }
2716
2717 /// Create a unary shuffle. The second vector operand of the IR instruction
2718 /// is poison.
2720 const Twine &Name = "") {
2721 return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name);
2722 }
2723
2725 const Twine &Name = "");
2726
2728 const Twine &Name = "") {
2729 if (auto *V = Folder.FoldExtractValue(Agg, Idxs))
2730 return V;
2731 return Insert(ExtractValueInst::Create(Agg, Idxs), Name);
2732 }
2733
2735 const Twine &Name = "") {
2736 if (auto *V = Folder.FoldInsertValue(Agg, Val, Idxs))
2737 return V;
2738 return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name);
2739 }
2740
2741 LandingPadInst *CreateLandingPad(Type *Ty, unsigned NumClauses,
2742 const Twine &Name = "") {
2743 return Insert(LandingPadInst::Create(Ty, NumClauses), Name);
2744 }
2745
2746 Value *CreateFreeze(Value *V, const Twine &Name = "") {
2747 return Insert(new FreezeInst(V), Name);
2748 }
2749
2751 const Twine &Name = "") {
2752 if (Value *V = Folder.FoldBitInsert(Base, Val, Offset))
2753 return V;
2754 return Insert(BitInsertInst::Create(Base, Val, Offset), Name);
2755 }
2756
2758 const Twine &Name = "") {
2759 if (Value *V = Folder.FoldBitExtract(Ty, Src, Offset))
2760 return V;
2761 return Insert(BitExtractInst::Create(Ty, Src, Offset), Name);
2762 }
2763
2764 //===--------------------------------------------------------------------===//
2765 // Utility creation methods
2766 //===--------------------------------------------------------------------===//
2767
2768 /// Return a boolean value testing if \p Arg == 0.
2769 Value *CreateIsNull(Value *Arg, const Twine &Name = "") {
2770 return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()), Name);
2771 }
2772
2773 /// Return a boolean value testing if \p Arg != 0.
2774 Value *CreateIsNotNull(Value *Arg, const Twine &Name = "") {
2775 return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()), Name);
2776 }
2777
2778 /// Return a boolean value testing if \p Arg < 0.
2779 Value *CreateIsNeg(Value *Arg, const Twine &Name = "") {
2780 return CreateICmpSLT(Arg, ConstantInt::getNullValue(Arg->getType()), Name);
2781 }
2782
2783 /// Return a boolean value testing if \p Arg > -1.
2784 Value *CreateIsNotNeg(Value *Arg, const Twine &Name = "") {
2786 Name);
2787 }
2788
2789 /// Return the difference between two pointer values. The returned value
2790 /// type is the address type of the pointers.
2791 LLVM_ABI Value *CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name = "",
2792 bool IsNUW = false);
2793
2794 /// Return the difference between two pointer values, dividing out the size
2795 /// of the pointed-to objects. The returned value type is the address type
2796 /// of the pointers.
2797 ///
2798 /// This is intended to implement C-style pointer subtraction. As such, the
2799 /// pointers must be appropriately aligned for their element types and
2800 /// pointing into the same object.
2802 const Twine &Name = "");
2803
2804 /// Create a launder.invariant.group intrinsic call. If Ptr type is
2805 /// different from pointer to i8, it's casted to pointer to i8 in the same
2806 /// address space before call and casted back to Ptr type after call.
2808
2809 /// Return a vector value that contains the vector V reversed
2810 LLVM_ABI Value *CreateVectorReverse(Value *V, const Twine &Name = "");
2811
2812 /// Create a vector.splice.left intrinsic call, or a shufflevector that
2813 /// produces the same result if the result type is a fixed-length vector and
2814 /// \p Offset is a constant.
2816 const Twine &Name = "");
2817
2819 const Twine &Name = "") {
2820 return CreateVectorSpliceLeft(V1, V2, getInt32(Offset), Name);
2821 }
2822
2823 /// Create a vector.splice.right intrinsic call, or a shufflevector that
2824 /// produces the same result if the result type is a fixed-length vector and
2825 /// \p Offset is a constant.
2827 const Twine &Name = "");
2828
2830 const Twine &Name = "") {
2831 return CreateVectorSpliceRight(V1, V2, getInt32(Offset), Name);
2832 }
2833
2834 /// Return a vector value that contains \arg V broadcasted to \p
2835 /// NumElts elements.
2836 LLVM_ABI Value *CreateVectorSplat(unsigned NumElts, Value *V,
2837 const Twine &Name = "");
2838
2839 /// Return a vector value that contains \arg V broadcasted to \p
2840 /// EC elements.
2842 const Twine &Name = "");
2843
2845 unsigned Dimension,
2846 unsigned LastIndex,
2847 MDNode *DbgInfo);
2848
2850 unsigned FieldIndex,
2851 MDNode *DbgInfo);
2852
2854 unsigned Index,
2855 unsigned FieldIndex,
2856 MDNode *DbgInfo);
2857
2858 LLVM_ABI Value *createIsFPClass(Value *FPNum, unsigned Test);
2859
2860private:
2861 /// Helper function that creates an assume intrinsic call that
2862 /// represents an alignment assumption on the provided pointer \p PtrValue
2863 /// with offset \p OffsetValue and alignment value \p AlignValue.
2864 CallInst *CreateAlignmentAssumptionHelper(const DataLayout &DL,
2865 Value *PtrValue, Value *AlignValue,
2866 Value *OffsetValue);
2867
2868public:
2869 /// Create an assume intrinsic call that represents an alignment
2870 /// assumption on the provided pointer.
2871 ///
2872 /// An optional offset can be provided, and if it is provided, the offset
2873 /// must be subtracted from the provided pointer to get the pointer with the
2874 /// specified alignment.
2876 Value *PtrValue,
2877 uint64_t Alignment,
2878 Value *OffsetValue = nullptr);
2879
2880 /// Create an assume intrinsic call that represents an alignment
2881 /// assumption on the provided pointer.
2882 ///
2883 /// An optional offset can be provided, and if it is provided, the offset
2884 /// must be subtracted from the provided pointer to get the pointer with the
2885 /// specified alignment.
2886 ///
2887 /// This overload handles the condition where the Alignment is dependent
2888 /// on an existing value rather than a static value.
2890 Value *PtrValue,
2891 Value *Alignment,
2892 Value *OffsetValue = nullptr);
2893
2894 /// Create an assume intrinsic call that represents a dereferencable
2895 /// assumption on the provided pointer.
2897 Value *SizeValue);
2898
2899 /// Create an assume intrinsic call that represents a nonnull assumption on
2900 /// the provided pointer.
2902};
2903
2904/// This provides a uniform API for creating instructions and inserting
2905/// them into a basic block: either at the end of a BasicBlock, or at a specific
2906/// iterator location in a block.
2907///
2908/// Note that the builder does not expose the full generality of LLVM
2909/// instructions. For access to extra instruction properties, use the mutators
2910/// (e.g. setVolatile) on the instructions after they have been
2911/// created. Convenience state exists to specify fast-math flags and fp-math
2912/// tags.
2913///
2914/// The first template argument specifies a class to use for creating constants.
2915/// This defaults to creating minimally folded constants. The second template
2916/// argument allows clients to specify custom insertion hooks that are called on
2917/// every newly created insertion.
2918template <typename FolderTy = ConstantFolder,
2919 typename InserterTy = IRBuilderDefaultInserter>
2920class IRBuilder : public IRBuilderBase {
2921private:
2922 FolderTy Folder;
2923 InserterTy Inserter;
2924
2925public:
2926 IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter)
2927 : IRBuilderBase(C, this->Folder, this->Inserter), Folder(Folder),
2928 Inserter(Inserter) {}
2929
2930 IRBuilder(LLVMContext &C, FolderTy Folder)
2931 : IRBuilderBase(C, this->Folder, this->Inserter), Folder(Folder) {}
2932
2934 : IRBuilderBase(C, this->Folder, this->Inserter) {}
2935
2936 explicit IRBuilder(BasicBlock *TheBB, FolderTy Folder)
2937 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter),
2938 Folder(Folder) {
2939 SetInsertPoint(TheBB);
2940 }
2941
2942 explicit IRBuilder(BasicBlock *TheBB)
2943 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter) {
2944 SetInsertPoint(TheBB);
2945 }
2946
2948 : IRBuilderBase(IP->getContext(), this->Folder, this->Inserter) {
2949 SetInsertPoint(IP);
2950 }
2951
2952 IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder)
2953 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter),
2954 Folder(Folder) {
2955 SetInsertPoint(TheBB, IP);
2956 }
2957
2959 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter) {
2960 SetInsertPoint(TheBB, IP);
2961 }
2962
2963 /// Avoid copying the full IRBuilder. Prefer using InsertPointGuard
2964 /// or FastMathFlagGuard instead.
2965 IRBuilder(const IRBuilder &) = delete;
2966
2967 InserterTy &getInserter() { return Inserter; }
2968 const InserterTy &getInserter() const { return Inserter; }
2969};
2970
2971template <typename FolderTy, typename InserterTy>
2972IRBuilder(LLVMContext &, FolderTy, InserterTy)
2975template <typename FolderTy>
2979template <typename FolderTy>
2982
2983// Create wrappers for C Binding types (see CBindingWrapping.h).
2985
2986} // end namespace llvm
2987
2988#endif // LLVM_IR_IRBUILDER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_ABI
Definition Compiler.h:215
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isSigned(unsigned Opcode)
This file contains the declarations of entities that describe floating point environment and related ...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
uint64_t IntrinsicInst * II
#define P(N)
const SmallVectorImpl< MachineOperand > & Cond
static unsigned getFastMathFlags(const MachineInstr &I, const SPIRVSubtarget &ST)
This file contains some templates that are useful if you are working with the STL at all.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
static const char PassName[]
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition APInt.h:78
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
Value handle that asserts if the Value is deleted.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
iterator end()
Definition BasicBlock.h:459
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
static BinaryOperator * CreateDisjoint(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
Definition InstrTypes.h:459
static BitExtractInst * Create(Type *Ty, Value *Src, Value *Offset, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static BitInsertInst * Create(Value *Base, Value *Val, Value *Offset, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Class to represent byte types.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
void addRetAttr(Attribute::AttrKind Kind)
Adds the attribute to the return value.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static LLVM_ABI CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast or an AddrSpaceCast cast instruction.
static LLVM_ABI CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore=nullptr)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Definition InstrTypes.h:743
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
Definition InstrTypes.h:757
@ ICMP_SLT
signed less than
Definition InstrTypes.h:769
@ ICMP_SLE
signed less or equal
Definition InstrTypes.h:770
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Definition InstrTypes.h:746
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
Definition InstrTypes.h:755
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
Definition InstrTypes.h:744
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
Definition InstrTypes.h:745
@ ICMP_UGE
unsigned greater or equal
Definition InstrTypes.h:764
@ ICMP_UGT
unsigned greater than
Definition InstrTypes.h:763
@ ICMP_SGT
signed greater than
Definition InstrTypes.h:767
@ FCMP_ULT
1 1 0 0 True if unordered or less than
Definition InstrTypes.h:754
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
Definition InstrTypes.h:748
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
Definition InstrTypes.h:751
@ ICMP_ULT
unsigned less than
Definition InstrTypes.h:765
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
Definition InstrTypes.h:752
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
Definition InstrTypes.h:747
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
Definition InstrTypes.h:749
@ ICMP_NE
not equal
Definition InstrTypes.h:762
@ ICMP_SGE
signed greater or equal
Definition InstrTypes.h:768
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Definition InstrTypes.h:756
@ ICMP_ULE
unsigned less or equal
Definition InstrTypes.h:766
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Definition InstrTypes.h:753
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
Definition InstrTypes.h:742
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition InstrTypes.h:750
bool isFPPredicate() const
Definition InstrTypes.h:845
static LLVM_ABI StringRef getPredicateName(Predicate P)
Conditional Branch instruction.
static CondBrInst * Create(Value *Cond, BasicBlock *IfTrue, BasicBlock *IfFalse, InsertPosition InsertBefore=nullptr)
This is the shared class of boolean and integer constants.
Definition Constants.h:87
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
This is an important base class in LLVM.
Definition Constant.h:43
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
A debug info location.
Definition DebugLoc.h:126
static ExtractElementInst * Create(Value *Vec, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static ExtractValueInst * Create(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
This provides a helper for copying FMF from an instruction or setting specified flags.
Definition IRBuilder.h:93
FMFSource(Instruction *Source)
Definition IRBuilder.h:98
FMFSource()=default
FastMathFlags get(FastMathFlags Default) const
Definition IRBuilder.h:103
FMFSource(FastMathFlags FMF)
Definition IRBuilder.h:102
static FMFSource intersect(Value *A, Value *B)
Intersect the FMF from two instructions.
Definition IRBuilder.h:107
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:23
An instruction for ordering other memory operations.
This class represents a freeze function that returns random concrete value if an operand is either a ...
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Class to represent function types.
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
static GEPNoWrapFlags noUnsignedWrap()
static GEPNoWrapFlags none()
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
This instruction compares its operands according to the predicate given to the constructor.
FastMathFlagGuard(const FastMathFlagGuard &)=delete
FastMathFlagGuard & operator=(const FastMathFlagGuard &)=delete
InsertPointGuard & operator=(const InsertPointGuard &)=delete
InsertPointGuard(const InsertPointGuard &)=delete
InsertPoint - A saved insertion point.
Definition IRBuilder.h:244
InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
Creates a new insertion point at the given location.
Definition IRBuilder.h:253
BasicBlock * getBlock() const
Definition IRBuilder.h:259
InsertPoint()=default
Creates a new insertion point which doesn't point to anything.
bool isSet() const
Returns true if this insert point is set.
Definition IRBuilder.h:257
BasicBlock::iterator getPoint() const
Definition IRBuilder.h:260
OperandBundlesGuard(const OperandBundlesGuard &)=delete
OperandBundlesGuard & operator=(const OperandBundlesGuard &)=delete
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1501
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2271
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2458
Value * CreateLdexp(Value *Src, Value *Exp, FMFSource FMFSource={}, const Twine &Name="")
Create call to the ldexp intrinsic.
Definition IRBuilder.h:1090
void SetCurrentDebugLocation(DebugLoc &&L)
Set location information used by debugging information.
Definition IRBuilder.h:226
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Definition IRBuilder.h:450
Value * CreateExtractVector(Type *DstType, Value *SrcVec, uint64_t Idx, const Twine &Name="")
Create a call to the vector.extract intrinsic.
Definition IRBuilder.h:1126
Value * CreateFCmpS(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2537
BasicBlock * BB
Definition IRBuilder.h:120
LLVM_ABI CallInst * CreateIntrinsicWithoutFolding(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={})
Create a call to intrinsic ID with Args, mangled using OverloadTypes.
Value * CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1475
CleanupPadInst * CreateCleanupPad(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &Name="")
Definition IRBuilder.h:1354
LLVM_ABI Value * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
Value * CreateFSubFMF(Value *L, Value *R, FMFSource FMFSource, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1666
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2409
Value * CreateFPTruncFMF(Value *V, Type *DestTy, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2217
Value * CreateConstGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition IRBuilder.h:2066
LLVM_ABI Value * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNull=false)
Definition IRBuilder.h:2259
RoundingMode DefaultConstrainedRounding
Definition IRBuilder.h:131
LLVM_ABI Value * CreateLaunderInvariantGroup(Value *Ptr)
Create a launder.invariant.group intrinsic call.
LLVM_ABI Value * CreateSelectFMFWithUnknownProfile(Value *C, Value *True, Value *False, FMFSource FMFSource, StringRef PassName, const Twine &Name="")
Value * CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2483
CallInst * CreateStructuredAlloca(Type *BaseType, const Twine &Name="")
Definition IRBuilder.h:1905
Value * CreateInsertElement(Type *VecTy, Value *NewElt, uint64_t Idx, const Twine &Name="")
Definition IRBuilder.h:2685
Value * CreateSRem(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1511
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const Twine &Name="")
Definition IRBuilder.h:1950
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const LoadStoreInstProperties &Props, const Twine &Name="")
Definition IRBuilder.h:1930
Value * CreateFSub(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1661
LLVM_ABI Value * CreateFPMinReduce(Value *Src)
Create a vector float min reduction intrinsic of the source vector.
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2513
CatchPadInst * CreateCatchPad(Value *ParentPad, ArrayRef< Value * > Args, const Twine &Name="")
Definition IRBuilder.h:1349
LLVM_ABI CallInst * CreateConstrainedFPUnroundedBinOp(Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
Definition IRBuilder.h:2680
Value * CreateVectorSpliceLeft(Value *V1, Value *V2, uint32_t Offset, const Twine &Name="")
Definition IRBuilder.h:2818
Value * CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1552
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID=SyncScope::System)
Definition IRBuilder.h:1979
LLVM_ABI CallInst * CreateThreadLocalAddress(Value *Ptr)
Create a call to llvm.threadlocal.address intrinsic.
Value * CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition IRBuilder.h:2035
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
Definition IRBuilder.h:1890
void setDefaultOperandBundles(ArrayRef< OperandBundleDef > OpBundles)
Definition IRBuilder.h:352
Value * CreateBitExtract(Type *Ty, Value *Src, Value *Offset, const Twine &Name="")
Definition IRBuilder.h:2757
CallInst * CreateStackSave(const Twine &Name="")
Create a call to llvm.stacksave.
Definition IRBuilder.h:1146
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition IRBuilder.h:1282
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Definition IRBuilder.h:517
LLVM_ABI CallInst * CreateMaskedCompressStore(Value *Val, Value *Ptr, MaybeAlign Align, Value *Mask=nullptr)
Create a call to Masked Compress Store intrinsic.
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition IRBuilder.h:2734
Value * CreateAnd(ArrayRef< Value * > Ops)
Definition IRBuilder.h:1590
IndirectBrInst * CreateIndirectBr(Value *Addr, unsigned NumDests=10)
Create an indirect branch instruction with the specified address operand, with an optional hint for t...
Definition IRBuilder.h:1255
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition IRBuilder.h:1582
void setDefaultFPMathTag(MDNode *FPMathTag)
Set the floating point math metadata to be used.
Definition IRBuilder.h:295
LLVM_ABI Value * CreateAllocationSize(Type *DestTy, AllocaInst *AI)
Get allocation size of an alloca as a runtime Value* (handles both static and dynamic allocas and vsc...
LLVM_ABI Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
Definition IRBuilder.cpp:60
ByteType * getByteNTy(unsigned N)
Fetch the type representing an N-bit byte.
Definition IRBuilder.h:514
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2626
LLVM_ABI CallInst * CreateGCGetPointerBase(Value *DerivedPtr, const Twine &Name="")
Create a call to the experimental.gc.pointer.base intrinsic to get the base pointer for the specified...
Value * CreateFDiv(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1699
LLVM_ABI CallInst * CreateLifetimeStart(Value *Ptr)
Create a lifetime.start intrinsic.
Value * CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1547
void clearFastMathFlags()
Clear the fast-math flags.
Definition IRBuilder.h:292
LLVM_ABI CallInst * CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee, ArrayRef< Value * > CallArgs, std::optional< ArrayRef< Value * > > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create a call to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
LLVM_ABI CallInst * CreateNonnullAssumption(Value *PtrValue)
Create an assume intrinsic call that represents a nonnull assumption on the provided pointer.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, bool isVolatile, const Twine &Name="")
Definition IRBuilder.h:1925
Value * CreateLogicalOr(ArrayRef< Value * > Ops)
Definition IRBuilder.h:1806
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Definition IRBuilder.h:2668
LLVM_ABI Value * CreateFPMaximumNumReduce(Value *Src)
Create a vector float maximum reduction intrinsic of the source vector.
IntegerType * getIntNTy(unsigned N)
Fetch the type representing an N-bit integer.
Definition IRBuilder.h:545
LLVM_ABI Value * CreateFPMaximumReduce(Value *Src)
Create a vector float maximum reduction intrinsic of the source vector.
void setDefaultConstrainedExcept(fp::ExceptionBehavior NewExcept)
Set the exception handling to be used with constrained floating point.
Definition IRBuilder.h:310
Value * CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2417
LLVM_ABI Value * CreateVectorSpliceRight(Value *V1, Value *V2, Value *Offset, const Twine &Name="")
Create a vector.splice.right intrinsic call, or a shufflevector that produces the same result if the ...
LLVM_ABI CallInst * CreateLifetimeEnd(Value *Ptr)
Create a lifetime.end intrinsic.
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const char *Name)
Definition IRBuilder.h:1945
Value * CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2463
Value * CreateStructuredGEP(Type *BaseType, Value *PtrBase, ArrayRef< Value * > Indices, const Twine &Name="")
Definition IRBuilder.h:2006
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
Definition IRBuilder.h:565
Value * CreateNoWrapBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool IsNUW, bool IsNSW, const Twine &Name="")
Definition IRBuilder.h:1754
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
Definition IRBuilder.h:2150
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert a memcpy between the specified pointers.
Definition IRBuilder.h:661
CondBrInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
Definition IRBuilder.h:1222
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1642
UnreachableInst * CreateUnreachable()
Definition IRBuilder.h:1364
Value * CreateBitInsert(Value *Base, Value *Val, Value *Offset, const Twine &Name="")
Definition IRBuilder.h:2750
LLVM_ABI CallInst * CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, const Twine &Name="", std::optional< fp::ExceptionBehavior > Except=std::nullopt)
LLVM_ABI Value * CreateSelectFMF(Value *C, Value *True, Value *False, FMFSource FMFSource, const Twine &Name="", Instruction *MDFrom=nullptr)
Value * CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2212
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2308
LLVM_ABI Value * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
void setDefaultConstrainedRounding(RoundingMode NewRounding)
Set the rounding mode handling to be used with constrained floating point.
Definition IRBuilder.h:320
Value * CreatePtrToAddr(Value *V, const Twine &Name="")
Definition IRBuilder.h:2240
LLVM_ABI Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Value * CreateFRem(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1718
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition IRBuilder.h:2727
Value * CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition IRBuilder.h:1586
ConstantInt * getTrue()
Get the constant value for i1 true.
Definition IRBuilder.h:455
StoreInst * CreateStore(Value *Val, Value *Ptr, const LoadStoreInstProperties &Props)
Definition IRBuilder.h:1940
Value * Insert(Value *V, const Twine &Name="") const
Definition IRBuilder.h:155
LandingPadInst * CreateLandingPad(Type *Ty, unsigned NumClauses, const Twine &Name="")
Definition IRBuilder.h:2741
Value * CreateFPExtFMF(Value *V, Type *DestTy, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2232
Value * CreateMaximum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maximum intrinsic.
Definition IRBuilder.h:1066
LLVM_ABI Value * CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, unsigned Index, unsigned FieldIndex, MDNode *DbgInfo)
LLVM_ABI CallInst * CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2421
LLVM_ABI CallInst * CreateConstrainedFPCall(Function *Callee, ArrayRef< Value * > Args, const Twine &Name="", std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
LLVM_ABI Value * CreateFPMinimumNumReduce(Value *Src)
Create a vector float minimum reduction intrinsic of the source vector.
LLVMContext & Context
Definition IRBuilder.h:122
LLVM_ABI Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Create an invoke instruction.
Definition IRBuilder.h:1260
LLVM_ABI CallInst * CreateMalloc(Type *IntPtrTy, Value *AllocSize, Value *ArraySize, ArrayRef< OperandBundleDef > OpB, Function *MallocF=nullptr, const Twine &Name="")
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2601
RoundingMode getDefaultConstrainedRounding()
Get the rounding mode handling used with constrained floating point.
Definition IRBuilder.h:335
LLVM_ABI Value * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
Value * CreateFPToUI(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2178
Value * CreateVectorSpliceRight(Value *V1, Value *V2, uint32_t Offset, const Twine &Name="")
Definition IRBuilder.h:2829
Value * CreateConstGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition IRBuilder.h:2078
Value * CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2498
BasicBlock::iterator GetInsertPoint() const
Definition IRBuilder.h:174
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
Definition IRBuilder.h:2096
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
Definition IRBuilder.h:1972
IntegerType * getIndexTy(const DataLayout &DL, unsigned AddrSpace)
Fetch the type of an integer that should be used to index GEP operations within AddressSpace.
Definition IRBuilder.h:593
CallBrInst * CreateCallBr(FunctionCallee Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition IRBuilder.h:1324
LLVM_ABI CallInst * CreateGCGetPointerOffset(Value *DerivedPtr, const Twine &Name="")
Create a call to the experimental.gc.get.pointer.offset intrinsic to get the offset of the specified ...
fp::ExceptionBehavior getDefaultConstrainedExcept()
Get the exception handling used with constrained floating point.
Definition IRBuilder.h:330
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2144
Value * CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2279
Value * CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2478
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2249
Value * CreateFreeze(Value *V, const Twine &Name="")
Definition IRBuilder.h:2746
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2633
void SetCurrentDebugLocation(const DebugLoc &L)
Set location information used by debugging information.
Definition IRBuilder.h:219
BasicBlock::iterator InsertPt
Definition IRBuilder.h:121
ReturnInst * CreateAggregateRet(ArrayRef< Value * > RetVals)
Create a sequence of N insertvalue instructions, with one Value from the RetVals array each,...
Definition IRBuilder.h:1208
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args={}, const Twine &Name="")
Create a callbr instruction.
Definition IRBuilder.h:1298
LLVM_ABI CallInst * CreateConstrainedFPBinOp(Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1538
IntegerType * getIntPtrTy(const DataLayout &DL, unsigned AddrSpace=0)
Fetch the type of an integer with size at least as big as that of a pointer in the given address spac...
Definition IRBuilder.h:587
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition IRBuilder.h:532
Value * CreateExtractVector(Type *DstType, Value *SrcVec, Value *Idx, const Twine &Name="")
Create a call to the vector.extract intrinsic.
Definition IRBuilder.h:1118
Value * CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition IRBuilder.h:2041
LLVM_ABI Value * CreateAggregateCast(Value *V, Type *DestTy)
Cast between aggregate types that must have identical structure but may differ in their leaf types.
Definition IRBuilder.cpp:73
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
Definition IRBuilder.h:465
Value * CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Definition IRBuilder.h:2103
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr, FMFSource FMFSource={})
Definition IRBuilder.h:2295
Value * CreateIsNotNeg(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg > -1.
Definition IRBuilder.h:2784
CatchReturnInst * CreateCatchRet(CatchPadInst *CatchPad, BasicBlock *BB)
Definition IRBuilder.h:1360
CleanupReturnInst * CreateCleanupRet(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB=nullptr)
Definition IRBuilder.h:1337
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
Definition IRBuilder.h:1198
LLVM_ABI CallInst * CreateAssumption(Value *Cond)
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
Value * CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1437
bool getIsFPConstrained()
Query for the use of constrained floating point math.
Definition IRBuilder.h:307
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false, MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2192
Value * CreateVScale(Type *Ty, const Twine &Name="")
Create a call to llvm.vscale.<Ty>().
Definition IRBuilder.h:942
Value * CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1571
BasicBlock * GetInsertBlock() const
Definition IRBuilder.h:173
Type * getHalfTy()
Fetch the type representing a 16-bit floating point value.
Definition IRBuilder.h:550
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
Definition IRBuilder.h:298
Value * CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2448
void SetInsertPointPastAllocas(Function *F)
This specifies that created instructions should inserted at the beginning end of the specified functi...
Definition IRBuilder.h:213
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
Definition IRBuilder.h:537
Value * CreateInBoundsGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Definition IRBuilder.h:2030
Value * CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1471
InsertPoint saveAndClearIP()
Returns the current insert point, clearing it in the process.
Definition IRBuilder.h:269
Value * CreateOr(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition IRBuilder.h:1608
LLVM_ABI CallInst * CreateElementUnorderedAtomicMemMove(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert an element unordered-atomic memmove between the specified pointers.
Value * CreatePointerBitCastOrAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2320
LLVM_ABI Value * CreateVectorReverse(Value *V, const Twine &Name="")
Return a vector value that contains the vector V reversed.
Value * CreateShuffleVector(Value *V, ArrayRef< int > Mask, const Twine &Name="")
Create a unary shuffle.
Definition IRBuilder.h:2719
Value * CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1566
Value * CreateUDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1479
Value * CreateFAbs(Value *V, FMFSource FMFSource={}, const Twine &Name="")
Create call to the fabs intrinsic.
Definition IRBuilder.h:1031
Value * CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2493
FastMathFlags FMF
Definition IRBuilder.h:127
LLVM_ABI Value * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
LLVM_ABI Value * CreateBitPreservingCastChain(const DataLayout &DL, Value *V, Type *NewTy)
Create a chain of casts to convert V to NewTy, preserving the bit pattern of V.
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2397
Value * CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1441
IntegerType * getInt16Ty()
Fetch the type representing a 16-bit integer.
Definition IRBuilder.h:527
Value * CreateFCmpFMF(CmpInst::Predicate P, Value *LHS, Value *RHS, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2521
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Definition IRBuilder.h:2022
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Definition IRBuilder.h:480
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Definition IRBuilder.h:703
CatchSwitchInst * CreateCatchSwitch(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, const Twine &Name="")
Definition IRBuilder.h:1342
LLVM_ABI Value * CreateVectorSpliceLeft(Value *V1, Value *V2, Value *Offset, const Twine &Name="")
Create a vector.splice.left intrinsic call, or a shufflevector that produces the same result if the r...
Value * getAllOnesMask(ElementCount NumElts)
Return an all true boolean vector (mask) with NumElts lanes.
Definition IRBuilder.h:846
LLVM_ABI Value * CreateFPMaxReduce(Value *Src)
Create a vector float max reduction intrinsic of the source vector.
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1864
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNSW=false)
Definition IRBuilder.h:1836
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const Twine &Name="")
Definition IRBuilder.h:1921
UncondBrInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
Definition IRBuilder.h:1216
InsertPoint saveIP() const
Returns the current insert point.
Definition IRBuilder.h:264
Value * CreateArithmeticFence(Value *Val, Type *DstType, const Twine &Name="")
Create a call to the arithmetic_fence intrinsic.
Definition IRBuilder.h:1111
Value * CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition IRBuilder.h:1776
void SetInsertPoint(BasicBlock::iterator IP)
This specifies that created instructions should be inserted at the specified point,...
Definition IRBuilder.h:204
Value * CreateInsertElement(Value *Vec, Value *NewElt, uint64_t Idx, const Twine &Name="")
Definition IRBuilder.h:2697
Value * CreateShl(Value *LHS, uint64_t RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1532
LLVM_ABI Value * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type.
Value * CreateShuffleVector(Value *V1, Value *V2, ArrayRef< int > Mask, const Twine &Name="")
See class ShuffleVectorInst for a description of the mask representation.
Definition IRBuilder.h:2710
LLVM_ABI Value * createIsFPClass(Value *FPNum, unsigned Test)
LLVM_ABI Value * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
Value * CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2453
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition IRBuilder.h:475
LLVM_ABI CallInst * CreateFree(Value *Source, ArrayRef< OperandBundleDef > Bundles={})
Generate the IR for a call to the builtin free function.
Value * CreateMaxNum(Value *LHS, Value *RHS, FMFSource FMFSource={}, const Twine &Name="")
Create call to the maxnum intrinsic.
Definition IRBuilder.h:1049
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2343
Value * CreateCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2527
Value * CreateLogicalOp(Instruction::BinaryOps Opc, Value *Cond1, Value *Cond2, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition IRBuilder.h:1791
const IRBuilderDefaultInserter & Inserter
Definition IRBuilder.h:124
Value * CreateFPCast(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2355
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2429
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Definition IRBuilder.h:2558
LLVM_ABI Value * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2590
CondBrInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, Instruction *MDSrc)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
Definition IRBuilder.h:1231
Value * CreateNot(Value *V, const Twine &Name="")
Definition IRBuilder.h:1860
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...
Definition IRBuilder.h:1245
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2393
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Definition IRBuilder.h:144
Value * CreateBinOpFMF(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1743
Value * CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2473
LLVM_ABI Value * CreateFPMinimumReduce(Value *Src)
Create a vector float minimum reduction intrinsic of the source vector.
void setIsFPConstrained(bool IsCon)
Enable/Disable use of constrained floating point math.
Definition IRBuilder.h:304
LLVM_ABI DebugLoc getCurrentDebugLocation() const
Get location information used by debugging information.
Definition IRBuilder.cpp:65
Value * CreateMinimum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the minimum intrinsic.
Definition IRBuilder.h:1061
IntegerType * getInt128Ty()
Fetch the type representing a 128-bit integer.
Definition IRBuilder.h:542
Value * CreateCountTrailingZeroElems(Type *ResTy, Value *Mask, bool ZeroIsPoison=true, const Twine &Name="")
Create a call to llvm.experimental_cttz_elts.
Definition IRBuilder.h:1160
Value * CreateIsNeg(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg < 0.
Definition IRBuilder.h:2779
Constant * Insert(Constant *C, const Twine &="") const
No-op overload to handle constants.
Definition IRBuilder.h:151
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1445
Value * CreateFMA(Value *Factor1, Value *Factor2, Value *Summand, FMFSource FMFSource={}, const Twine &Name="")
Create call to the fma intrinsic.
Definition IRBuilder.h:1098
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2254
ByteType * getByte128Ty()
Fetch the type representing a 128-bit byte.
Definition IRBuilder.h:511
ConstantInt * getIntN(unsigned N, uint64_t C)
Get a constant N-bit value, zero extended from a 64-bit value.
Definition IRBuilder.h:485
Value * CreateDisjointOr(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1624
ByteType * getByte16Ty()
Fetch the type representing a 16-bit byte.
Definition IRBuilder.h:502
Value * CreateCopySign(Value *LHS, Value *RHS, FMFSource FMFSource={}, const Twine &Name="")
Create call to the copysign intrinsic.
Definition IRBuilder.h:1083
LLVM_ABI Value * CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name="", bool IsNUW=false)
Return the difference between two pointer values.
Value * CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2401
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
Definition IRBuilder.h:1917
Value * CreateUnOpFMF(Instruction::UnaryOps Opc, Value *V, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1870
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, Align Alignment, uint32_t ElementSize, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
Definition IRBuilder.h:627
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1517
FastMathFlags getFastMathFlags() const
Get the flags to be applied to created floating point ops.
Definition IRBuilder.h:287
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign Align, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert a memset to the specified pointer and the specified value.
Definition IRBuilder.h:606
LLVM_ABI Value * CreateNAryOp(unsigned Opc, ArrayRef< Value * > Ops, const Twine &Name="", MDNode *FPMathTag=nullptr)
Create either a UnaryOperator or BinaryOperator depending on Opc.
Value * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", function_ref< void(CallInst *)> SetFn=[](CallInst *) {})
Variant to create a possibly constant-folded intrinsic.
Definition IRBuilder.h:1023
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)
Definition IRBuilder.h:2132
LLVM_ABI CallInst * CreateConstrainedFPIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource, const Twine &Name, MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
This function is like CreateIntrinsic for constrained fp intrinsics.
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Definition IRBuilder.h:2702
LLVMContext & getContext() const
Definition IRBuilder.h:175
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2433
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1576
FastMathFlags & getFastMathFlags()
Definition IRBuilder.h:289
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
Definition IRBuilder.h:1193
ByteType * getByte32Ty()
Fetch the type representing a 32-bit byte.
Definition IRBuilder.h:505
LLVM_ABI Value * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={}, function_ref< void(CallInst *)> SetFn=[](CallInst *) {})
Variant to create a possibly constant-folded intrinsic.
Value * CreateMaximumNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maximum intrinsic.
Definition IRBuilder.h:1077
Value * CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1454
Value * CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Definition IRBuilder.h:2057
Value * CreateConstInBoundsGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition IRBuilder.h:2087
Value * CreateMinNum(Value *LHS, Value *RHS, FMFSource FMFSource={}, const Twine &Name="")
Create call to the minnum intrinsic.
Definition IRBuilder.h:1037
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args={}, const Twine &Name="")
Definition IRBuilder.h:1290
LLVM_ABI Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Definition IRBuilder.h:1936
LLVM_ABI Value * CreateSelectWithUnknownProfile(Value *C, Value *True, Value *False, StringRef PassName, const Twine &Name="")
LLVM_ABI CallInst * CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, Value *Mask)
Create a call to Masked Store intrinsic.
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1428
Value * CreateExactBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool IsExact, const Twine &Name="")
Definition IRBuilder.h:1766
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2244
Value * CreateSDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1492
ConstantInt * getFalse()
Get the constant value for i1 false.
Definition IRBuilder.h:460
VAArgInst * CreateVAArg(Value *List, Type *Ty, const Twine &Name="")
Definition IRBuilder.h:2664
Value * CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1488
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
Definition IRBuilder.h:560
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg != 0.
Definition IRBuilder.h:2774
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP)
This specifies that created instructions should be inserted at the specified point.
Definition IRBuilder.h:195
Instruction * CreateNoAliasScopeDeclaration(MDNode *ScopeTag)
Definition IRBuilder.h:861
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2572
Value * CreateShl(Value *LHS, const APInt &RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1526
ByteType * getBytePtrTy(const DataLayout &DL, unsigned AddrSpace=0)
Fetch the type of a byte with size at least as big as that of a pointer in the given address space.
Definition IRBuilder.h:581
LLVM_ABI 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 ...
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="", bool IsNUW=false, bool IsNSW=false)
Definition IRBuilder.h:2118
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Definition IRBuilder.h:575
LLVM_ABI CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, uint64_t Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer.
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1737
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
Definition IRBuilder.h:2690
Value * CreateConstInBoundsGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition IRBuilder.h:2072
fp::ExceptionBehavior DefaultConstrainedExcept
Definition IRBuilder.h:130
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
Definition IRBuilder.h:168
CallBrInst * CreateCallBr(FunctionCallee Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args={}, const Twine &Name="")
Definition IRBuilder.h:1317
ByteType * getByte8Ty()
Fetch the type representing an 8-bit byte.
Definition IRBuilder.h:499
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2425
ConstantInt * getInt16(uint16_t C)
Get a constant 16-bit value.
Definition IRBuilder.h:470
MDNode * DefaultFPMathTag
Definition IRBuilder.h:126
LLVM_ABI Value * CreateTypeSize(Type *Ty, TypeSize Size)
Create an expression which evaluates to the number of units in Size at runtime.
ArrayRef< OperandBundleDef > DefaultOperandBundles
Definition IRBuilder.h:133
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition IRBuilder.h:1306
LLVM_ABI CallInst * CreateDereferenceableAssumption(Value *PtrValue, Value *SizeValue)
Create an assume intrinsic call that represents a dereferencable assumption on the provided pointer.
CallInst * CreateIntrinsicWithoutFolding(Intrinsic::ID ID, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to non-overloaded intrinsic ID with Args.
Definition IRBuilder.h:995
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2405
MDNode * getDefaultFPMathTag() const
Get the floating point math metadata being used.
Definition IRBuilder.h:284
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Definition IRBuilder.h:2334
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2468
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
Definition IRBuilder.h:276
Value * CreateIsNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg == 0.
Definition IRBuilder.h:2769
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Definition IRBuilder.h:675
Value * CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2438
CallInst * CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Definition IRBuilder.h:683
CallInst * CreateStackRestore(Value *Ptr, const Twine &Name="")
Create a call to llvm.stackrestore.
Definition IRBuilder.h:1154
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Definition IRBuilder.h:179
Type * getVoidTy()
Fetch the type representing void.
Definition IRBuilder.h:570
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args={}, const Twine &Name="")
Definition IRBuilder.h:1271
LLVM_ABI CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert an element unordered-atomic memcpy between the specified pointers.
Value * CreateOr(ArrayRef< Value * > Ops)
Definition IRBuilder.h:1616
Value * CreateFAddFMF(Value *L, Value *R, FMFSource FMFSource, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1647
IRBuilderBase(LLVMContext &context, const IRBuilderFolder &Folder, const IRBuilderDefaultInserter &Inserter)
Definition IRBuilder.h:136
Value * CreateLogicalOr(Value *Cond1, Value *Cond2, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition IRBuilder.h:1784
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="")
Definition IRBuilder.h:1897
Value * CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="", GEPNoWrapFlags NWFlags=GEPNoWrapFlags::none())
Definition IRBuilder.h:2047
Value * CreateExtractElement(Value *Vec, uint64_t Idx, const Twine &Name="")
Definition IRBuilder.h:2675
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)
Definition IRBuilder.h:1964
Value * CreateOr(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition IRBuilder.h:1612
void setConstrainedFPCallAttr(CallBase *I)
Definition IRBuilder.h:348
Value * CreateMinimumNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the minimumnum intrinsic.
Definition IRBuilder.h:1071
LLVM_ABI Value * CreateFAddReduce(Value *Acc, Value *Src)
Create a sequential vector fadd reduction intrinsic of the source vector.
LLVM_ABI InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > InvokeArgs, std::optional< ArrayRef< Value * > > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create an invoke to the experimental.gc.statepoint intrinsic to start a new statepoint sequence.
ByteType * getByte64Ty()
Fetch the type representing a 64-bit byte.
Definition IRBuilder.h:508
LLVM_ABI CallInst * CreateMaskedExpandLoad(Type *Ty, Value *Ptr, MaybeAlign Align, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Expand Load intrinsic.
const IRBuilderFolder & Folder
Definition IRBuilder.h:123
Value * CreateInBoundsPtrAdd(Value *Ptr, Value *Offset, const Twine &Name="")
Definition IRBuilder.h:2108
Value * CreateIntCast(Value *, Type *, const char *)=delete
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2227
LLVM_ABI CallInst * CreateMemTransferInst(Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI Value * CreateVectorInterleave(ArrayRef< Value * > Ops, const Twine &Name="")
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1557
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2613
Value * CreateFNegFMF(Value *V, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1850
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1628
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2619
Value * CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2287
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2413
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2204
LLVM_ABI Value * CreateFMulReduce(Value *Acc, Value *Src)
Create a sequential vector fmul reduction intrinsic of the source vector.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2503
LLVM_ABI CallInst * CreateMemSetInline(Value *Dst, MaybeAlign DstAlign, Value *Val, Value *Size, bool IsVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Value * CreateFMul(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1680
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, bool isVolatile, const Twine &Name="")
Definition IRBuilder.h:1955
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1845
void setConstrainedFPFunctionAttr()
Definition IRBuilder.h:339
LLVM_ABI void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
Definition IRBuilder.cpp:66
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="", bool IsDisjoint=false)
Definition IRBuilder.h:1598
void SetInsertPoint(Instruction *I)
This specifies that created instructions should be inserted before the specified instruction.
Definition IRBuilder.h:186
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Definition IRBuilder.h:522
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
Definition IRBuilder.h:490
LLVM_ABI 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...
Value * CreateFDivFMF(Value *L, Value *R, FMFSource FMFSource, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1704
Value * CreateURem(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1505
LLVM_ABI Value * CreateStepVector(Type *DstType, const Twine &Name="")
Creates a vector of type DstType with the linear sequence <0, 1, ...>
LLVM_ABI Value * CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, unsigned Dimension, unsigned LastIndex, MDNode *DbgInfo)
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
Definition IRBuilder.h:2165
ResumeInst * CreateResume(Value *Exn)
Definition IRBuilder.h:1333
Value * CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec, Value *Idx, const Twine &Name="")
Create a call to the vector.insert intrinsic.
Definition IRBuilder.h:1132
Type * getBFloatTy()
Fetch the type representing a 16-bit brain floating point value.
Definition IRBuilder.h:555
Value * CreateFMulFMF(Value *L, Value *R, FMFSource FMFSource, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1685
Value * CreateXor(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition IRBuilder.h:1634
LLVM_ABI CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1462
Value * CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec, uint64_t Idx, const Twine &Name="")
Create a call to the vector.extract intrinsic.
Definition IRBuilder.h:1140
LLVM_ABI Instruction * CreateNoAliasScopeDeclaration(Value *Scope)
Create a llvm.experimental.noalias.scope.decl intrinsic call.
LLVM_ABI CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
Value * CreateFRemFMF(Value *L, Value *R, FMFSource FMFSource, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1723
Value * CreateXor(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition IRBuilder.h:1638
LLVM_ABI Value * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *Op, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, bool Elementwise=false)
Definition IRBuilder.h:1992
LLVM_ABI GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0, Module *M=nullptr, bool AddNull=true)
Make a new global variable with initializer type i8*.
Definition IRBuilder.cpp:45
Value * CreateNSWNeg(Value *V, const Twine &Name="")
Definition IRBuilder.h:1841
LLVM_ABI Value * CreateElementCount(Type *Ty, ElementCount EC)
Create an expression which evaluates to the number of elements in EC at runtime.
Value * CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2443
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Definition IRBuilder.h:711
LLVM_ABI CallInst * CreateConstrainedFPCast(Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource={}, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
LLVM_ABI CallInst * CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
Value * CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1458
Value * CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2488
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2185
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2583
IRBuilderCallbackInserter(std::function< void(Instruction *)> Callback)
Definition IRBuilder.h:81
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock::iterator InsertPt) const override
Definition IRBuilder.h:84
This provides the default implementation of the IRBuilder 'InsertHelper' method that is called whenev...
Definition IRBuilder.h:61
virtual void InsertHelper(Instruction *I, const Twine &Name, BasicBlock::iterator InsertPt) const
Definition IRBuilder.h:65
IRBuilderFolder - Interface for constant folding in IRBuilder.
virtual Value * FoldCast(Instruction::CastOps Op, Value *V, Type *DestTy) const =0
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2920
IRBuilder(const IRBuilder &)=delete
Avoid copying the full IRBuilder.
IRBuilder(BasicBlock *TheBB)
Definition IRBuilder.h:2942
IRBuilder(Instruction *IP)
Definition IRBuilder.h:2947
IRBuilder(BasicBlock *TheBB, FolderTy Folder)
Definition IRBuilder.h:2936
IRBuilder(LLVMContext &C, FolderTy Folder)
Definition IRBuilder.h:2930
InserterTy & getInserter()
Definition IRBuilder.h:2967
IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter)
Definition IRBuilder.h:2926
IRBuilder(LLVMContext &C)
Definition IRBuilder.h:2933
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder)
Definition IRBuilder.h:2952
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP)
Definition IRBuilder.h:2958
const InserterTy & getInserter() const
Definition IRBuilder.h:2968
Indirect Branch Instruction.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, InsertPosition InsertBefore=nullptr)
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
Class to represent integer types.
Invoke instruction.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
The landingpad instruction holds all of the information necessary to generate correct exception handl...
static LLVM_ABI LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
An instruction for reading from memory.
Metadata node.
Definition Metadata.h:1092
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:602
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:107
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Class to represent pointers.
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
Definition Type.cpp:887
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Resume the propagation of an exception.
static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)
Return a value (possibly void), from a function.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
This instruction constructs a fixed permutation of two input vectors.
ArrayRef< int > getShuffleMask() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Multiway switch.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI ByteType * getByte16Ty(LLVMContext &C)
Definition Type.cpp:287
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:300
static LLVM_ABI IntegerType * getInt128Ty(LLVMContext &C)
Definition Type.cpp:301
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:299
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition Type.h:258
static LLVM_ABI ByteType * getByte32Ty(LLVMContext &C)
Definition Type.cpp:288
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:272
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:297
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
Definition Type.cpp:298
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:222
static LLVM_ABI ByteType * getByte8Ty(LLVMContext &C)
Definition Type.cpp:286
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:296
static LLVM_ABI ByteType * getByte128Ty(LLVMContext &C)
Definition Type.cpp:290
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition Type.h:280
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:303
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:277
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:276
static LLVM_ABI ByteType * getByteNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:292
static LLVM_ABI ByteType * getByte64Ty(LLVMContext &C)
Definition Type.cpp:289
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
Definition Type.cpp:275
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:274
static LLVM_ABI UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
Unconditional Branch instruction.
static UncondBrInst * Create(BasicBlock *Target, InsertPosition InsertBefore=nullptr)
This function has undefined behavior.
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
Base class of all SIMD vector types.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
This class represents zero extension of integer types.
An efficient, type-erasing, non-owning reference to a callable.
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
Definition Types.h:110
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Rounding
Possible values of current rounding mode, which is specified in bits 23:22 of FPCR.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ System
Synchronized with respect to all concurrently executing threads.
Definition LLVMContext.h:58
ExceptionBehavior
Exception behavior used for floating point operations.
Definition FPEnv.h:39
@ ebStrict
This corresponds to "fpexcept.strict".
Definition FPEnv.h:42
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI std::optional< StringRef > convertRoundingModeToStr(RoundingMode)
For any RoundingMode enumerator, returns a string valid as input in constrained intrinsic rounding mo...
Definition FPEnv.cpp:39
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition STLExtras.h:2224
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
LLVM_ABI std::optional< StringRef > convertExceptionBehaviorToStr(fp::ExceptionBehavior)
For any ExceptionBehavior enumerator, returns a string valid as input in constrained intrinsic except...
Definition FPEnv.cpp:68
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
AtomicOrdering
Atomic ordering for LLVM's memory model.
IntPtrTy
Definition InstrProf.h:82
DWARFExpression::Operation Op
RoundingMode
Rounding mode.
@ Dynamic
Denotes mode unknown at compile time.
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
@ Default
The result value is uniform if and only if all operands are uniform.
Definition Uniformity.h:20
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:785
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
A structure representing the properties of a load or store instruction.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:106