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");
1202 return Insert(ReturnInst::Create(Context, V));
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 return CreateGEP(getInt8Ty(), Ptr, Offset, Name, NW);
2095 }
2096
2098 const Twine &Name = "") {
2099 return CreateGEP(getInt8Ty(), Ptr, Offset, Name,
2101 }
2102
2103 //===--------------------------------------------------------------------===//
2104 // Instruction creation methods: Cast/Conversion Operators
2105 //===--------------------------------------------------------------------===//
2106
2107 Value *CreateTrunc(Value *V, Type *DestTy, const Twine &Name = "",
2108 bool IsNUW = false, bool IsNSW = false) {
2109 if (V->getType() == DestTy)
2110 return V;
2111 if (Value *Folded = Folder.FoldCast(Instruction::Trunc, V, DestTy))
2112 return Folded;
2113 Instruction *I = CastInst::Create(Instruction::Trunc, V, DestTy);
2114 if (IsNUW)
2115 I->setHasNoUnsignedWrap();
2116 if (IsNSW)
2117 I->setHasNoSignedWrap();
2118 return Insert(I, Name);
2119 }
2120
2121 Value *CreateZExt(Value *V, Type *DestTy, const Twine &Name = "",
2122 bool IsNonNeg = false) {
2123 if (V->getType() == DestTy)
2124 return V;
2125 if (Value *Folded = Folder.FoldCast(Instruction::ZExt, V, DestTy))
2126 return Folded;
2127 Instruction *I = Insert(new ZExtInst(V, DestTy), Name);
2128 if (IsNonNeg)
2129 I->setNonNeg();
2130 return I;
2131 }
2132
2133 Value *CreateSExt(Value *V, Type *DestTy, const Twine &Name = "") {
2134 return CreateCast(Instruction::SExt, V, DestTy, Name);
2135 }
2136
2137 /// Create a ZExt or Trunc from the integer value V to DestTy. Return
2138 /// the value untouched if the type of V is already DestTy.
2140 const Twine &Name = "") {
2141 assert(V->getType()->isIntOrIntVectorTy() &&
2142 DestTy->isIntOrIntVectorTy() &&
2143 "Can only zero extend/truncate integers!");
2144 Type *VTy = V->getType();
2145 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2146 return CreateZExt(V, DestTy, Name);
2147 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2148 return CreateTrunc(V, DestTy, Name);
2149 return V;
2150 }
2151
2152 /// Create a SExt or Trunc from the integer value V to DestTy. Return
2153 /// the value untouched if the type of V is already DestTy.
2155 const Twine &Name = "") {
2156 assert(V->getType()->isIntOrIntVectorTy() &&
2157 DestTy->isIntOrIntVectorTy() &&
2158 "Can only sign extend/truncate integers!");
2159 Type *VTy = V->getType();
2160 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2161 return CreateSExt(V, DestTy, Name);
2162 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2163 return CreateTrunc(V, DestTy, Name);
2164 return V;
2165 }
2166
2167 Value *CreateFPToUI(Value *V, Type *DestTy, const Twine &Name = "") {
2168 if (IsFPConstrained)
2169 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptoui,
2170 V, DestTy, nullptr, Name);
2171 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
2172 }
2173
2174 Value *CreateFPToSI(Value *V, Type *DestTy, const Twine &Name = "") {
2175 if (IsFPConstrained)
2176 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptosi,
2177 V, DestTy, nullptr, Name);
2178 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
2179 }
2180
2181 Value *CreateUIToFP(Value *V, Type *DestTy, const Twine &Name = "",
2182 bool IsNonNeg = false, MDNode *FPMathTag = nullptr) {
2183 if (IsFPConstrained)
2184 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_uitofp,
2185 V, DestTy, nullptr, Name);
2186 Value *Val = CreateCast(Instruction::UIToFP, V, DestTy, Name, FPMathTag);
2187 if (auto *I = dyn_cast<Instruction>(Val))
2188 if (IsNonNeg)
2189 I->setNonNeg();
2190 return Val;
2191 }
2192
2193 Value *CreateSIToFP(Value *V, Type *DestTy, const Twine &Name = "",
2194 MDNode *FPMathTag = nullptr) {
2195 if (IsFPConstrained)
2196 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_sitofp,
2197 V, DestTy, nullptr, Name);
2198 return CreateCast(Instruction::SIToFP, V, DestTy, Name, FPMathTag);
2199 }
2200
2201 Value *CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name = "",
2202 MDNode *FPMathTag = nullptr) {
2203 return CreateFPTruncFMF(V, DestTy, {}, Name, FPMathTag);
2204 }
2205
2207 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2208 if (IsFPConstrained)
2210 Intrinsic::experimental_constrained_fptrunc, V, DestTy, FMFSource,
2211 Name, FPMathTag);
2212 return CreateCast(Instruction::FPTrunc, V, DestTy, Name, FPMathTag,
2213 FMFSource);
2214 }
2215
2216 Value *CreateFPExt(Value *V, Type *DestTy, const Twine &Name = "",
2217 MDNode *FPMathTag = nullptr) {
2218 return CreateFPExtFMF(V, DestTy, {}, Name, FPMathTag);
2219 }
2220
2222 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2223 if (IsFPConstrained)
2224 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fpext,
2225 V, DestTy, FMFSource, Name, FPMathTag);
2226 return CreateCast(Instruction::FPExt, V, DestTy, Name, FPMathTag,
2227 FMFSource);
2228 }
2229 Value *CreatePtrToAddr(Value *V, const Twine &Name = "") {
2230 return CreateCast(Instruction::PtrToAddr, V,
2231 getDataLayout().getAddressType(V->getType()), Name);
2232 }
2234 const Twine &Name = "") {
2235 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
2236 }
2237
2239 const Twine &Name = "") {
2240 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
2241 }
2242
2244 const Twine &Name = "") {
2245 return CreateCast(Instruction::BitCast, V, DestTy, Name);
2246 }
2247
2248 Value *CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name = "",
2249 bool IsNonNull = false) {
2250 if (V->getType() == DestTy)
2251 return V;
2252 if (Value *Folded = Folder.FoldCast(Instruction::AddrSpaceCast, V, DestTy))
2253 return Folded;
2254 Instruction *I = Insert(new AddrSpaceCastInst(V, DestTy), Name);
2255 if (IsNonNull)
2256 cast<AddrSpaceCastInst>(I)->setNonNull();
2257 return I;
2258 }
2259
2260 Value *CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2261 Instruction::CastOps CastOp =
2262 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2263 ? Instruction::BitCast
2264 : Instruction::ZExt;
2265 return CreateCast(CastOp, V, DestTy, Name);
2266 }
2267
2268 Value *CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2269 Instruction::CastOps CastOp =
2270 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2271 ? Instruction::BitCast
2272 : Instruction::SExt;
2273 return CreateCast(CastOp, V, DestTy, Name);
2274 }
2275
2276 Value *CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2277 Instruction::CastOps CastOp =
2278 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2279 ? Instruction::BitCast
2280 : Instruction::Trunc;
2281 return CreateCast(CastOp, V, DestTy, Name);
2282 }
2283
2285 const Twine &Name = "", MDNode *FPMathTag = nullptr,
2286 FMFSource FMFSource = {}) {
2287 if (V->getType() == DestTy)
2288 return V;
2289 if (Value *Folded = Folder.FoldCast(Op, V, DestTy))
2290 return Folded;
2291 Instruction *Cast = CastInst::Create(Op, V, DestTy);
2292 if (isa<FPMathOperator>(Cast))
2293 setFPAttrs(Cast, FPMathTag, FMFSource.get(FMF));
2294 return Insert(Cast, Name);
2295 }
2296
2298 const Twine &Name = "") {
2299 if (V->getType() == DestTy)
2300 return V;
2301 if (auto *VC = dyn_cast<Constant>(V))
2302 return Insert(Folder.CreatePointerCast(VC, DestTy), Name);
2303 return Insert(CastInst::CreatePointerCast(V, DestTy), Name);
2304 }
2305
2306 // With opaque pointers enabled, this can be substituted with
2307 // CreateAddrSpaceCast.
2308 // TODO: Replace uses of this method and remove the method itself.
2310 const Twine &Name = "") {
2311 if (V->getType() == DestTy)
2312 return V;
2313
2314 if (auto *VC = dyn_cast<Constant>(V)) {
2315 return Insert(Folder.CreatePointerBitCastOrAddrSpaceCast(VC, DestTy),
2316 Name);
2317 }
2318
2320 Name);
2321 }
2322
2324 const Twine &Name = "") {
2325 Instruction::CastOps CastOp =
2326 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2327 ? Instruction::Trunc
2328 : (isSigned ? Instruction::SExt : Instruction::ZExt);
2329 return CreateCast(CastOp, V, DestTy, Name);
2330 }
2331
2333 const Twine &Name = "") {
2334 if (V->getType() == DestTy)
2335 return V;
2336 if (V->getType()->isPtrOrPtrVectorTy() && DestTy->isIntOrIntVectorTy())
2337 return CreatePtrToInt(V, DestTy, Name);
2338 if (V->getType()->isIntOrIntVectorTy() && DestTy->isPtrOrPtrVectorTy())
2339 return CreateIntToPtr(V, DestTy, Name);
2340
2341 return CreateBitCast(V, DestTy, Name);
2342 }
2343
2344 Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "",
2345 MDNode *FPMathTag = nullptr) {
2346 Instruction::CastOps CastOp =
2347 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2348 ? Instruction::FPTrunc
2349 : Instruction::FPExt;
2350 return CreateCast(CastOp, V, DestTy, Name, FPMathTag);
2351 }
2352
2354 Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource = {},
2355 const Twine &Name = "", MDNode *FPMathTag = nullptr,
2356 std::optional<RoundingMode> Rounding = std::nullopt,
2357 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2358
2359 // Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
2360 // compile time error, instead of converting the string to bool for the
2361 // isSigned parameter.
2362 Value *CreateIntCast(Value *, Type *, const char *) = delete;
2363
2364 /// Cast between aggregate types that must have identical structure but may
2365 /// differ in their leaf types. The leaf values are recursively extracted,
2366 /// casted, and then reinserted into a value of type DestTy. The leaf types
2367 /// must be castable using a bitcast or ptrcast, because signedness is
2368 /// not specified.
2370
2371 /// Create a chain of casts to convert V to NewTy, preserving the bit pattern
2372 /// of V. This may involve multiple casts (e.g., ptr -> i64 -> <2 x i32>).
2373 /// The created cast instructions are inserted into the current basic block.
2374 /// If no casts are needed, V is returned.
2376 Type *NewTy);
2377
2378 //===--------------------------------------------------------------------===//
2379 // Instruction creation methods: Compare Instructions
2380 //===--------------------------------------------------------------------===//
2381
2382 Value *CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name = "") {
2383 return CreateICmp(ICmpInst::ICMP_EQ, LHS, RHS, Name);
2384 }
2385
2386 Value *CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name = "") {
2387 return CreateICmp(ICmpInst::ICMP_NE, LHS, RHS, Name);
2388 }
2389
2390 Value *CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name = "") {
2391 return CreateICmp(ICmpInst::ICMP_UGT, LHS, RHS, Name);
2392 }
2393
2394 Value *CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name = "") {
2395 return CreateICmp(ICmpInst::ICMP_UGE, LHS, RHS, Name);
2396 }
2397
2398 Value *CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name = "") {
2399 return CreateICmp(ICmpInst::ICMP_ULT, LHS, RHS, Name);
2400 }
2401
2402 Value *CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name = "") {
2403 return CreateICmp(ICmpInst::ICMP_ULE, LHS, RHS, Name);
2404 }
2405
2406 Value *CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name = "") {
2407 return CreateICmp(ICmpInst::ICMP_SGT, LHS, RHS, Name);
2408 }
2409
2410 Value *CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name = "") {
2411 return CreateICmp(ICmpInst::ICMP_SGE, LHS, RHS, Name);
2412 }
2413
2414 Value *CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name = "") {
2415 return CreateICmp(ICmpInst::ICMP_SLT, LHS, RHS, Name);
2416 }
2417
2418 Value *CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name = "") {
2419 return CreateICmp(ICmpInst::ICMP_SLE, LHS, RHS, Name);
2420 }
2421
2422 Value *CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name = "",
2423 MDNode *FPMathTag = nullptr) {
2424 return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name, FPMathTag);
2425 }
2426
2427 Value *CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name = "",
2428 MDNode *FPMathTag = nullptr) {
2429 return CreateFCmp(FCmpInst::FCMP_OGT, LHS, RHS, Name, FPMathTag);
2430 }
2431
2432 Value *CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name = "",
2433 MDNode *FPMathTag = nullptr) {
2434 return CreateFCmp(FCmpInst::FCMP_OGE, LHS, RHS, Name, FPMathTag);
2435 }
2436
2437 Value *CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name = "",
2438 MDNode *FPMathTag = nullptr) {
2439 return CreateFCmp(FCmpInst::FCMP_OLT, LHS, RHS, Name, FPMathTag);
2440 }
2441
2442 Value *CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name = "",
2443 MDNode *FPMathTag = nullptr) {
2444 return CreateFCmp(FCmpInst::FCMP_OLE, LHS, RHS, Name, FPMathTag);
2445 }
2446
2447 Value *CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name = "",
2448 MDNode *FPMathTag = nullptr) {
2449 return CreateFCmp(FCmpInst::FCMP_ONE, LHS, RHS, Name, FPMathTag);
2450 }
2451
2452 Value *CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name = "",
2453 MDNode *FPMathTag = nullptr) {
2454 return CreateFCmp(FCmpInst::FCMP_ORD, LHS, RHS, Name, FPMathTag);
2455 }
2456
2457 Value *CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name = "",
2458 MDNode *FPMathTag = nullptr) {
2459 return CreateFCmp(FCmpInst::FCMP_UNO, LHS, RHS, Name, FPMathTag);
2460 }
2461
2462 Value *CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name = "",
2463 MDNode *FPMathTag = nullptr) {
2464 return CreateFCmp(FCmpInst::FCMP_UEQ, LHS, RHS, Name, FPMathTag);
2465 }
2466
2467 Value *CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name = "",
2468 MDNode *FPMathTag = nullptr) {
2469 return CreateFCmp(FCmpInst::FCMP_UGT, LHS, RHS, Name, FPMathTag);
2470 }
2471
2472 Value *CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name = "",
2473 MDNode *FPMathTag = nullptr) {
2474 return CreateFCmp(FCmpInst::FCMP_UGE, LHS, RHS, Name, FPMathTag);
2475 }
2476
2477 Value *CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name = "",
2478 MDNode *FPMathTag = nullptr) {
2479 return CreateFCmp(FCmpInst::FCMP_ULT, LHS, RHS, Name, FPMathTag);
2480 }
2481
2482 Value *CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name = "",
2483 MDNode *FPMathTag = nullptr) {
2484 return CreateFCmp(FCmpInst::FCMP_ULE, LHS, RHS, Name, FPMathTag);
2485 }
2486
2487 Value *CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name = "",
2488 MDNode *FPMathTag = nullptr) {
2489 return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name, FPMathTag);
2490 }
2491
2493 const Twine &Name = "") {
2494 if (auto *V = Folder.FoldCmp(P, LHS, RHS))
2495 return V;
2496 return Insert(new ICmpInst(P, LHS, RHS), Name);
2497 }
2498
2499 // Create a quiet floating-point comparison (i.e. one that raises an FP
2500 // exception only in the case where an input is a signaling NaN).
2501 // Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2503 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2504 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, {}, false);
2505 }
2506
2507 // Create a quiet floating-point comparison (i.e. one that raises an FP
2508 // exception only in the case where an input is a signaling NaN).
2509 // Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2511 FMFSource FMFSource, const Twine &Name = "",
2512 MDNode *FPMathTag = nullptr) {
2513 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, FMFSource, false);
2514 }
2515
2517 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2518 return CmpInst::isFPPredicate(Pred)
2519 ? CreateFCmp(Pred, LHS, RHS, Name, FPMathTag)
2520 : CreateICmp(Pred, LHS, RHS, Name);
2521 }
2522
2523 // Create a signaling floating-point comparison (i.e. one that raises an FP
2524 // exception whenever an input is any NaN, signaling or quiet).
2525 // Note that this differs from CreateFCmp only if IsFPConstrained is true.
2527 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2528 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, {}, true);
2529 }
2530
2531private:
2532 // Helper routine to create either a signaling or a quiet FP comparison.
2533 LLVM_ABI Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS,
2534 const Twine &Name, MDNode *FPMathTag,
2535 FMFSource FMFSource, bool IsSignaling);
2536
2537public:
2540 const Twine &Name = "",
2541 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2542
2543 //===--------------------------------------------------------------------===//
2544 // Instruction creation methods: Other Instructions
2545 //===--------------------------------------------------------------------===//
2546
2547 PHINode *CreatePHI(Type *Ty, unsigned NumReservedValues,
2548 const Twine &Name = "") {
2549 PHINode *Phi = PHINode::Create(Ty, NumReservedValues);
2550 if (isa<FPMathOperator>(Phi))
2551 setFPAttrs(Phi, nullptr /* MDNode* */, FMF);
2552 return Insert(Phi, Name);
2553 }
2554
2555private:
2556 CallInst *createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
2557 const Twine &Name = "", FMFSource FMFSource = {},
2558 ArrayRef<OperandBundleDef> OpBundles = {});
2559
2560public:
2562 ArrayRef<Value *> Args = {}, const Twine &Name = "",
2563 MDNode *FPMathTag = nullptr) {
2564 CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
2565 if (IsFPConstrained)
2567 if (isa<FPMathOperator>(CI))
2568 setFPAttrs(CI, FPMathTag, FMF);
2569 return Insert(CI, Name);
2570 }
2571
2573 FMFSource FMFSource, const Twine &Name = "",
2574 MDNode *FPMathTag = nullptr) {
2575 return CreateCall(FTy, Callee, Args, DefaultOperandBundles, FMFSource, Name,
2576 FPMathTag);
2577 }
2578
2581 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2582 CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
2583 if (IsFPConstrained)
2585 if (isa<FPMathOperator>(CI))
2586 setFPAttrs(CI, FPMathTag, FMF);
2587 return Insert(CI, Name);
2588 }
2589
2592 FMFSource FMFSource, const Twine &Name = "",
2593 MDNode *FPMathTag = nullptr) {
2594 CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
2595 if (IsFPConstrained)
2597 if (isa<FPMathOperator>(CI))
2598 setFPAttrs(CI, FPMathTag, FMFSource.get(FMF));
2599 return Insert(CI, Name);
2600 }
2601
2603 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2604 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args, Name,
2605 FPMathTag);
2606 }
2607
2609 FMFSource FMFSource, const Twine &Name = "",
2610 MDNode *FPMathTag = nullptr) {
2611 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2612 FMFSource, Name, FPMathTag);
2613 }
2614
2617 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2618 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2619 OpBundles, Name, FPMathTag);
2620 }
2621
2624 FMFSource FMFSource, const Twine &Name = "",
2625 MDNode *FPMathTag = nullptr) {
2626 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2627 OpBundles, FMFSource, Name, FPMathTag);
2628 }
2629
2631 Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "",
2632 std::optional<RoundingMode> Rounding = std::nullopt,
2633 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2634
2636 Value *False,
2638 const Twine &Name = "");
2639
2641 Value *False,
2644 const Twine &Name = "");
2645
2647 const Twine &Name = "",
2648 Instruction *MDFrom = nullptr);
2650 FMFSource FMFSource, const Twine &Name = "",
2651 Instruction *MDFrom = nullptr);
2652
2653 VAArgInst *CreateVAArg(Value *List, Type *Ty, const Twine &Name = "") {
2654 return Insert(new VAArgInst(List, Ty), Name);
2655 }
2656
2658 const Twine &Name = "") {
2659 if (Value *V = Folder.FoldExtractElement(Vec, Idx))
2660 return V;
2661 return Insert(ExtractElementInst::Create(Vec, Idx), Name);
2662 }
2663
2665 const Twine &Name = "") {
2666 return CreateExtractElement(Vec, getInt64(Idx), Name);
2667 }
2668
2669 Value *CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx,
2670 const Twine &Name = "") {
2671 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2672 }
2673
2675 const Twine &Name = "") {
2676 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2677 }
2678
2680 const Twine &Name = "") {
2681 if (Value *V = Folder.FoldInsertElement(Vec, NewElt, Idx))
2682 return V;
2683 return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
2684 }
2685
2687 const Twine &Name = "") {
2688 return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
2689 }
2690
2692 const Twine &Name = "") {
2693 SmallVector<int, 16> IntMask;
2695 return CreateShuffleVector(V1, V2, IntMask, Name);
2696 }
2697
2698 /// See class ShuffleVectorInst for a description of the mask representation.
2700 const Twine &Name = "") {
2701 if (Value *V = Folder.FoldShuffleVector(V1, V2, Mask))
2702 return V;
2703 return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
2704 }
2705
2706 /// Create a unary shuffle. The second vector operand of the IR instruction
2707 /// is poison.
2709 const Twine &Name = "") {
2710 return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name);
2711 }
2712
2714 const Twine &Name = "");
2715
2717 const Twine &Name = "") {
2718 if (auto *V = Folder.FoldExtractValue(Agg, Idxs))
2719 return V;
2720 return Insert(ExtractValueInst::Create(Agg, Idxs), Name);
2721 }
2722
2724 const Twine &Name = "") {
2725 if (auto *V = Folder.FoldInsertValue(Agg, Val, Idxs))
2726 return V;
2727 return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name);
2728 }
2729
2730 LandingPadInst *CreateLandingPad(Type *Ty, unsigned NumClauses,
2731 const Twine &Name = "") {
2732 return Insert(LandingPadInst::Create(Ty, NumClauses), Name);
2733 }
2734
2735 Value *CreateFreeze(Value *V, const Twine &Name = "") {
2736 return Insert(new FreezeInst(V), Name);
2737 }
2738
2740 const Twine &Name = "") {
2741 if (Value *V = Folder.FoldBitInsert(Base, Val, Offset))
2742 return V;
2743 return Insert(BitInsertInst::Create(Base, Val, Offset), Name);
2744 }
2745
2747 const Twine &Name = "") {
2748 if (Value *V = Folder.FoldBitExtract(Ty, Src, Offset))
2749 return V;
2750 return Insert(BitExtractInst::Create(Ty, Src, Offset), Name);
2751 }
2752
2753 //===--------------------------------------------------------------------===//
2754 // Utility creation methods
2755 //===--------------------------------------------------------------------===//
2756
2757 /// Return a boolean value testing if \p Arg == 0.
2758 Value *CreateIsNull(Value *Arg, const Twine &Name = "") {
2759 return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()), Name);
2760 }
2761
2762 /// Return a boolean value testing if \p Arg != 0.
2763 Value *CreateIsNotNull(Value *Arg, const Twine &Name = "") {
2764 return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()), Name);
2765 }
2766
2767 /// Return a boolean value testing if \p Arg < 0.
2768 Value *CreateIsNeg(Value *Arg, const Twine &Name = "") {
2769 return CreateICmpSLT(Arg, ConstantInt::getNullValue(Arg->getType()), Name);
2770 }
2771
2772 /// Return a boolean value testing if \p Arg > -1.
2773 Value *CreateIsNotNeg(Value *Arg, const Twine &Name = "") {
2775 Name);
2776 }
2777
2778 /// Return the difference between two pointer values. The returned value
2779 /// type is the address type of the pointers.
2780 LLVM_ABI Value *CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name = "",
2781 bool IsNUW = false);
2782
2783 /// Return the difference between two pointer values, dividing out the size
2784 /// of the pointed-to objects. The returned value type is the address type
2785 /// of the pointers.
2786 ///
2787 /// This is intended to implement C-style pointer subtraction. As such, the
2788 /// pointers must be appropriately aligned for their element types and
2789 /// pointing into the same object.
2791 const Twine &Name = "");
2792
2793 /// Create a launder.invariant.group intrinsic call. If Ptr type is
2794 /// different from pointer to i8, it's casted to pointer to i8 in the same
2795 /// address space before call and casted back to Ptr type after call.
2797
2798 /// Return a vector value that contains the vector V reversed
2799 LLVM_ABI Value *CreateVectorReverse(Value *V, const Twine &Name = "");
2800
2801 /// Create a vector.splice.left intrinsic call, or a shufflevector that
2802 /// produces the same result if the result type is a fixed-length vector and
2803 /// \p Offset is a constant.
2805 const Twine &Name = "");
2806
2808 const Twine &Name = "") {
2809 return CreateVectorSpliceLeft(V1, V2, getInt32(Offset), Name);
2810 }
2811
2812 /// Create a vector.splice.right intrinsic call, or a shufflevector that
2813 /// produces the same result if the result type is a fixed-length vector and
2814 /// \p Offset is a constant.
2816 const Twine &Name = "");
2817
2819 const Twine &Name = "") {
2820 return CreateVectorSpliceRight(V1, V2, getInt32(Offset), Name);
2821 }
2822
2823 /// Return a vector value that contains \arg V broadcasted to \p
2824 /// NumElts elements.
2825 LLVM_ABI Value *CreateVectorSplat(unsigned NumElts, Value *V,
2826 const Twine &Name = "");
2827
2828 /// Return a vector value that contains \arg V broadcasted to \p
2829 /// EC elements.
2831 const Twine &Name = "");
2832
2834 unsigned Dimension,
2835 unsigned LastIndex,
2836 MDNode *DbgInfo);
2837
2839 unsigned FieldIndex,
2840 MDNode *DbgInfo);
2841
2843 unsigned Index,
2844 unsigned FieldIndex,
2845 MDNode *DbgInfo);
2846
2847 LLVM_ABI Value *createIsFPClass(Value *FPNum, unsigned Test);
2848
2849private:
2850 /// Helper function that creates an assume intrinsic call that
2851 /// represents an alignment assumption on the provided pointer \p PtrValue
2852 /// with offset \p OffsetValue and alignment value \p AlignValue.
2853 CallInst *CreateAlignmentAssumptionHelper(const DataLayout &DL,
2854 Value *PtrValue, Value *AlignValue,
2855 Value *OffsetValue);
2856
2857public:
2858 /// Create an assume intrinsic call that represents an alignment
2859 /// assumption on the provided pointer.
2860 ///
2861 /// An optional offset can be provided, and if it is provided, the offset
2862 /// must be subtracted from the provided pointer to get the pointer with the
2863 /// specified alignment.
2865 Value *PtrValue,
2866 uint64_t Alignment,
2867 Value *OffsetValue = nullptr);
2868
2869 /// Create an assume intrinsic call that represents an alignment
2870 /// assumption on the provided pointer.
2871 ///
2872 /// An optional offset can be provided, and if it is provided, the offset
2873 /// must be subtracted from the provided pointer to get the pointer with the
2874 /// specified alignment.
2875 ///
2876 /// This overload handles the condition where the Alignment is dependent
2877 /// on an existing value rather than a static value.
2879 Value *PtrValue,
2880 Value *Alignment,
2881 Value *OffsetValue = nullptr);
2882
2883 /// Create an assume intrinsic call that represents a dereferencable
2884 /// assumption on the provided pointer.
2886 Value *SizeValue);
2887
2888 /// Create an assume intrinsic call that represents a nonnull assumption on
2889 /// the provided pointer.
2891};
2892
2893/// This provides a uniform API for creating instructions and inserting
2894/// them into a basic block: either at the end of a BasicBlock, or at a specific
2895/// iterator location in a block.
2896///
2897/// Note that the builder does not expose the full generality of LLVM
2898/// instructions. For access to extra instruction properties, use the mutators
2899/// (e.g. setVolatile) on the instructions after they have been
2900/// created. Convenience state exists to specify fast-math flags and fp-math
2901/// tags.
2902///
2903/// The first template argument specifies a class to use for creating constants.
2904/// This defaults to creating minimally folded constants. The second template
2905/// argument allows clients to specify custom insertion hooks that are called on
2906/// every newly created insertion.
2907template <typename FolderTy = ConstantFolder,
2908 typename InserterTy = IRBuilderDefaultInserter>
2909class IRBuilder : public IRBuilderBase {
2910private:
2911 FolderTy Folder;
2912 InserterTy Inserter;
2913
2914 static void CallInsertHelper(const IRBuilderBase &IRB, Instruction *I,
2915 const Twine &Name,
2917 static_cast<const IRBuilder *>(&IRB)->Inserter.InsertHelper(I, Name,
2918 InsertPt);
2919 }
2920
2921public:
2922 [[deprecated("Use the overload taking Module instead")]]
2923 IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter)
2924 : IRBuilderBase(C, this->Folder, CallInsertHelper), Folder(Folder),
2925 Inserter(Inserter) {}
2926
2927 [[deprecated("Use the overload taking Module instead")]]
2928 IRBuilder(LLVMContext &C, FolderTy Folder)
2929 : IRBuilderBase(C, this->Folder, CallInsertHelper), Folder(Folder) {}
2930
2931 [[deprecated("Use the overload taking Module instead")]]
2933 : IRBuilderBase(C, this->Folder, CallInsertHelper) {}
2934
2935 IRBuilder(Module &M, FolderTy Folder, InserterTy Inserter)
2936 : IRBuilderBase(M.getContext(), this->Folder, CallInsertHelper),
2937 Folder(Folder), Inserter(Inserter) {}
2938
2939 IRBuilder(Module &M, FolderTy Folder)
2940 : IRBuilderBase(M.getContext(), this->Folder, CallInsertHelper),
2941 Folder(Folder) {}
2942
2943 explicit IRBuilder(Module &M)
2944 : IRBuilderBase(M.getContext(), this->Folder, CallInsertHelper) {}
2945
2946 explicit IRBuilder(BasicBlock *TheBB, FolderTy Folder)
2947 : IRBuilderBase(TheBB->getContext(), this->Folder, CallInsertHelper),
2948 Folder(Folder) {
2949 SetInsertPoint(TheBB);
2950 }
2951
2952 explicit IRBuilder(BasicBlock *TheBB)
2953 : IRBuilderBase(TheBB->getContext(), this->Folder, CallInsertHelper) {
2954 SetInsertPoint(TheBB);
2955 }
2956
2958 : IRBuilderBase(IP->getContext(), this->Folder, CallInsertHelper) {
2959 SetInsertPoint(IP);
2960 }
2961
2962 [[deprecated("Use the overload without BasicBlock argument instead")]]
2963 IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder)
2964 : IRBuilderBase(TheBB->getContext(), this->Folder, CallInsertHelper),
2965 Folder(Folder) {
2966 SetInsertPoint(IP);
2967 }
2968
2969 [[deprecated("Use the overload without BasicBlock argument instead")]]
2971 : IRBuilderBase(TheBB->getContext(), this->Folder, CallInsertHelper) {
2972 SetInsertPoint(IP);
2973 }
2974
2975 IRBuilder(BasicBlock::iterator IP, FolderTy Folder, InserterTy Inserter)
2976 : IRBuilderBase(IP.getNodeParent()->getContext(), this->Folder,
2977 CallInsertHelper),
2978 Folder(Folder), Inserter(Inserter) {
2979 SetInsertPoint(IP);
2980 }
2981
2982 IRBuilder(BasicBlock::iterator IP, FolderTy Folder)
2983 : IRBuilderBase(IP.getNodeParent()->getContext(), this->Folder,
2984 CallInsertHelper),
2985 Folder(Folder) {
2986 SetInsertPoint(IP);
2987 }
2988
2990 : IRBuilderBase(IP.getNodeParent()->getContext(), this->Folder,
2991 CallInsertHelper) {
2992 SetInsertPoint(IP);
2993 }
2994
2995 /// Avoid copying the full IRBuilder. Prefer using InsertPointGuard
2996 /// or FastMathFlagGuard instead.
2997 IRBuilder(const IRBuilder &) = delete;
2998
2999 InserterTy &getInserter() { return Inserter; }
3000 const InserterTy &getInserter() const { return Inserter; }
3001};
3002
3003template <typename FolderTy, typename InserterTy>
3004IRBuilder(LLVMContext &, FolderTy, InserterTy)
3007template <typename FolderTy, typename InserterTy>
3009template <typename FolderTy>
3012template <typename FolderTy>
3016template <typename FolderTy>
3019template <typename FolderTy, typename InserterTy>
3020IRBuilder(BasicBlock::iterator, FolderTy, InserterTy)
3022template <typename FolderTy>
3025
3026/// Unwrap C API builder reference.
3028
3029} // end namespace llvm
3030
3031#endif // LLVM_IR_IRBUILDER_H
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)
const SmallVectorImpl< MachineOperand > & Cond
static unsigned getFastMathFlags(const MachineInstr &I, const SPIRVSubtarget &ST)
This file contains some templates that are useful if you are working with the STL at all.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
static const char PassName[]
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition APInt.h:78
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
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...
void addRetAttr(Attribute::AttrKind Kind)
Adds the attribute to the return value.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static LLVM_ABI CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast or an AddrSpaceCast cast instruction.
static LLVM_ABI CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore=nullptr)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Definition InstrTypes.h:743
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
Definition InstrTypes.h:757
@ ICMP_SLT
signed less than
Definition InstrTypes.h:769
@ ICMP_SLE
signed less or equal
Definition InstrTypes.h:770
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Definition InstrTypes.h:746
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
Definition InstrTypes.h:755
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
Definition InstrTypes.h:744
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
Definition InstrTypes.h:745
@ ICMP_UGE
unsigned greater or equal
Definition InstrTypes.h:764
@ ICMP_UGT
unsigned greater than
Definition InstrTypes.h:763
@ ICMP_SGT
signed greater than
Definition InstrTypes.h:767
@ FCMP_ULT
1 1 0 0 True if unordered or less than
Definition InstrTypes.h:754
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
Definition InstrTypes.h:748
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
Definition InstrTypes.h:751
@ ICMP_ULT
unsigned less than
Definition InstrTypes.h:765
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
Definition InstrTypes.h:752
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
Definition InstrTypes.h:747
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
Definition InstrTypes.h:749
@ ICMP_NE
not equal
Definition InstrTypes.h:762
@ ICMP_SGE
signed greater or equal
Definition InstrTypes.h:768
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Definition InstrTypes.h:756
@ ICMP_ULE
unsigned less or equal
Definition InstrTypes.h:766
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Definition InstrTypes.h:753
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
Definition InstrTypes.h:742
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition InstrTypes.h:750
bool isFPPredicate() const
Definition InstrTypes.h:845
static LLVM_ABI StringRef getPredicateName(Predicate P)
Conditional Branch instruction.
static CondBrInst * Create(Value *Cond, BasicBlock *IfTrue, BasicBlock *IfFalse, InsertPosition InsertBefore=nullptr)
This is the shared class of boolean and integer constants.
Definition Constants.h:87
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
This is an important base class in LLVM.
Definition Constant.h: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
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:2260
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2447
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:2526
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:2398
Value * CreateFPTruncFMF(Value *V, Type *DestTy, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2206
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:2248
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:2472
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:2674
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:2502
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:2669
Value * CreateVectorSpliceLeft(Value *V1, Value *V2, uint32_t Offset, const Twine &Name="")
Definition IRBuilder.h:2807
Value * CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1542
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:2746
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:2723
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:2615
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:2657
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:2406
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:2452
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:2139
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:2739
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:2201
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2297
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:2229
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:2716
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 * Insert(Value *V, const Twine &Name="") const
Definition IRBuilder.h:158
LandingPadInst * CreateLandingPad(Type *Ty, unsigned NumClauses, const Twine &Name="")
Definition IRBuilder.h:2730
Value * CreateFPExtFMF(Value *V, Type *DestTy, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2221
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:2410
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:2590
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:2167
Value * CreateVectorSpliceRight(Value *V1, Value *V2, uint32_t Offset, const Twine &Name="")
Definition IRBuilder.h:2818
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:2487
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:2133
Value * CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2268
Value * CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2467
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2238
Value * CreateFreeze(Value *V, const Twine &Name="")
Definition IRBuilder.h:2735
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2622
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:2284
Value * CreateIsNotNeg(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg > -1.
Definition IRBuilder.h:2773
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:2181
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:2437
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:2309
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:2708
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:2482
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:2386
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:2510
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:2686
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:2699
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:2442
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:2332
Value * CreateCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2516
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:2344
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2418
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Definition IRBuilder.h:2547
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:2579
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:2382
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:2462
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:2768
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:2243
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:2390
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:2121
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:2691
LLVMContext & getContext() const
Definition IRBuilder.h:177
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2422
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:2233
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:2653
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:2763
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:2561
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:2107
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:2679
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:2414
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:2394
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:2323
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2457
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:2758
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:2427
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 * 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:2664
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:2097
Value * CreateIntCast(Value *, Type *, const char *)=delete
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2216
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:2602
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:2608
IRBuilderBase(const IRBuilderBase &)=delete
Value * CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2276
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2402
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2193
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:2492
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:2154
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:2432
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:2477
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2174
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2572
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:2909
IRBuilder(Module &M)
Definition IRBuilder.h:2943
IRBuilder(const IRBuilder &)=delete
Avoid copying the full IRBuilder.
IRBuilder(BasicBlock *TheBB)
Definition IRBuilder.h:2952
IRBuilder(Instruction *IP)
Definition IRBuilder.h:2957
IRBuilder(BasicBlock *TheBB, FolderTy Folder)
Definition IRBuilder.h:2946
IRBuilder(LLVMContext &C, FolderTy Folder)
Definition IRBuilder.h:2928
InserterTy & getInserter()
Definition IRBuilder.h:2999
IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter)
Definition IRBuilder.h:2923
IRBuilder(Module &M, FolderTy Folder)
Definition IRBuilder.h:2939
IRBuilder(LLVMContext &C)
Definition IRBuilder.h:2932
IRBuilder(BasicBlock::iterator IP, FolderTy Folder, InserterTy Inserter)
Definition IRBuilder.h:2975
IRBuilder(Module &M, FolderTy Folder, InserterTy Inserter)
Definition IRBuilder.h:2935
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder)
Definition IRBuilder.h:2963
IRBuilder(BasicBlock::iterator IP, FolderTy Folder)
Definition IRBuilder.h:2982
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP)
Definition IRBuilder.h:2970
IRBuilder(BasicBlock::iterator IP)
Definition IRBuilder.h:2989
const InserterTy & getInserter() const
Definition IRBuilder.h:3000
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:597
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:107
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Class to represent pointers.
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
Definition Type.cpp:887
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Resume the propagation of an exception.
static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)
Return a value (possibly void), from a function.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
This instruction constructs a fixed permutation of two input vectors.
ArrayRef< int > getShuffleMask() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Multiway switch.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI ByteType * getByte16Ty(LLVMContext &C)
Definition Type.cpp:287
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:300
static LLVM_ABI IntegerType * getInt128Ty(LLVMContext &C)
Definition Type.cpp:301
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:299
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition Type.h:258
static LLVM_ABI ByteType * getByte32Ty(LLVMContext &C)
Definition Type.cpp:288
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:272
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:297
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
Definition Type.cpp:298
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:222
static LLVM_ABI ByteType * getByte8Ty(LLVMContext &C)
Definition Type.cpp:286
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:296
static LLVM_ABI ByteType * getByte128Ty(LLVMContext &C)
Definition Type.cpp:290
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition Type.h:280
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:303
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:277
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:276
static LLVM_ABI ByteType * getByteNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:292
static LLVM_ABI ByteType * getByte64Ty(LLVMContext &C)
Definition Type.cpp:289
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
Definition Type.cpp:275
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:274
static LLVM_ABI UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
Unconditional Branch instruction.
static UncondBrInst * Create(BasicBlock *Target, InsertPosition InsertBefore=nullptr)
This function has undefined behavior.
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
Base class of all SIMD vector types.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
This class represents zero extension of integer types.
An efficient, type-erasing, non-owning reference to a callable.
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
Definition Types.h:110
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Rounding
Possible values of current rounding mode, which is specified in bits 23:22 of FPCR.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ System
Synchronized with respect to all concurrently executing threads.
Definition LLVMContext.h: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