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