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