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