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 *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 AllocSize, possibly multiplied
644 /// by the array size if the array size is not constant 1.
645 /// 2. Call malloc with that argument.
647 Value *ArraySize, Function *MallocF = nullptr,
648 const Twine &Name = "");
649 /// Generate the IR for a call to the builtin free function.
651 ArrayRef<OperandBundleDef> Bundles = {});
652
653 LLVM_ABI CallInst *
654 CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, Value *Size,
655 Align Alignment, uint32_t ElementSize,
656 const AAMDNodes &AAInfo = AAMDNodes());
657
658 /// Create and insert a memcpy between the specified pointers.
659 ///
660 /// If the pointers aren't i8*, they will be converted. If alias metadata is
661 /// specified, it will be added to the instruction.
662 /// and noalias tags.
664 MaybeAlign SrcAlign, uint64_t Size,
665 bool isVolatile = false,
666 const AAMDNodes &AAInfo = AAMDNodes()) {
667 return CreateMemCpy(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
668 isVolatile, AAInfo);
669 }
670
673 Value *Src, MaybeAlign SrcAlign, Value *Size,
674 bool isVolatile = false,
675 const AAMDNodes &AAInfo = AAMDNodes());
676
678 MaybeAlign SrcAlign, Value *Size,
679 bool isVolatile = false,
680 const AAMDNodes &AAInfo = AAMDNodes()) {
681 return CreateMemTransferInst(Intrinsic::memcpy, Dst, DstAlign, Src,
682 SrcAlign, Size, isVolatile, AAInfo);
683 }
684
686 MaybeAlign SrcAlign, Value *Size,
687 bool isVolatile = false,
688 const AAMDNodes &AAInfo = AAMDNodes()) {
689 return CreateMemTransferInst(Intrinsic::memcpy_inline, Dst, DstAlign, Src,
690 SrcAlign, Size, isVolatile, AAInfo);
691 }
692
693 /// Create and insert an element unordered-atomic memcpy between the
694 /// specified pointers.
695 ///
696 /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers,
697 /// respectively.
698 ///
699 /// If the pointers aren't i8*, they will be converted. If alias metadata is
700 /// specified, it will be added to the instruction.
702 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
703 uint32_t ElementSize, const AAMDNodes &AAInfo = AAMDNodes());
704
706 MaybeAlign SrcAlign, uint64_t Size,
707 bool isVolatile = false,
708 const AAMDNodes &AAInfo = AAMDNodes()) {
709 return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
710 isVolatile, AAInfo);
711 }
712
714 MaybeAlign SrcAlign, Value *Size,
715 bool isVolatile = false,
716 const AAMDNodes &AAInfo = AAMDNodes()) {
717 return CreateMemTransferInst(Intrinsic::memmove, Dst, DstAlign, Src,
718 SrcAlign, Size, isVolatile, AAInfo);
719 }
720
721 /// \brief Create and insert an element unordered-atomic memmove between the
722 /// specified pointers.
723 ///
724 /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers,
725 /// respectively.
726 ///
727 /// If the pointers aren't i8*, they will be converted. If alias metadata is
728 /// specified, it will be added to the instruction.
730 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
731 uint32_t ElementSize, const AAMDNodes &AAInfo = AAMDNodes());
732
733private:
734 Value *getReductionIntrinsic(Intrinsic::ID ID, Value *Src);
735
736public:
737 /// Create a sequential vector fadd reduction intrinsic of the source vector.
738 /// The first parameter is a scalar accumulator value. An unordered reduction
739 /// can be created by adding the reassoc fast-math flag to the resulting
740 /// sequential reduction.
742
743 /// Create a sequential vector fmul reduction intrinsic of the source vector.
744 /// The first parameter is a scalar accumulator value. An unordered reduction
745 /// can be created by adding the reassoc fast-math flag to the resulting
746 /// sequential reduction.
748
749 /// Create a vector int add reduction intrinsic of the source vector.
751
752 /// Create a vector int mul reduction intrinsic of the source vector.
754
755 /// Create a vector int AND reduction intrinsic of the source vector.
757
758 /// Create a vector int OR reduction intrinsic of the source vector.
760
761 /// Create a vector int XOR reduction intrinsic of the source vector.
763
764 /// Create a vector integer max reduction intrinsic of the source
765 /// vector.
766 LLVM_ABI Value *CreateIntMaxReduce(Value *Src, bool IsSigned = false);
767
768 /// Create a vector integer min reduction intrinsic of the source
769 /// vector.
770 LLVM_ABI Value *CreateIntMinReduce(Value *Src, bool IsSigned = false);
771
772 /// Create a vector float max reduction intrinsic of the source
773 /// vector.
775
776 /// Create a vector float min reduction intrinsic of the source
777 /// vector.
779
780 /// Create a vector float maximum reduction intrinsic of the source
781 /// vector. This variant follows the NaN and signed zero semantic of
782 /// llvm.maximum intrinsic.
784
785 /// Create a vector float minimum reduction intrinsic of the source
786 /// vector. This variant follows the NaN and signed zero semantic of
787 /// llvm.minimum intrinsic.
789
790 /// Create a vector float maximum reduction intrinsic of the source
791 /// vector. This variant follows the NaN and signed zero semantic of
792 /// llvm.maximumnum intrinsic.
794
795 /// Create a vector float minimum reduction intrinsic of the source
796 /// vector. This variant follows the NaN and signed zero semantic of
797 /// llvm.minimumnum intrinsic.
799
800 /// Create a lifetime.start intrinsic.
802
803 /// Create a lifetime.end intrinsic.
805
806 /// Create a call to invariant.start intrinsic.
807 ///
808 /// If the pointer isn't i8* it will be converted.
810 ConstantInt *Size = nullptr);
811
812 /// Create a call to llvm.threadlocal.address intrinsic.
814
815 /// Create a call to Masked Load intrinsic
816 LLVM_ABI CallInst *CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment,
817 Value *Mask, Value *PassThru = nullptr,
818 const Twine &Name = "");
819
820 /// Create a call to Masked Store intrinsic
821 LLVM_ABI CallInst *CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment,
822 Value *Mask);
823
824 /// Create a call to Masked Gather intrinsic
825 LLVM_ABI CallInst *CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment,
826 Value *Mask = nullptr,
827 Value *PassThru = nullptr,
828 const Twine &Name = "");
829
830 /// Create a call to Masked Scatter intrinsic
832 Align Alignment,
833 Value *Mask = nullptr);
834
835 /// Create a call to Masked Expand Load intrinsic
838 Value *Mask = nullptr,
839 Value *PassThru = nullptr,
840 const Twine &Name = "");
841
842 /// Create a call to Masked Compress Store intrinsic
845 Value *Mask = nullptr);
846
847 /// Return an all true boolean vector (mask) with \p NumElts lanes.
852
853 /// Create an assume intrinsic call that allows the optimizer to
854 /// assume that the provided condition will be true.
856
857 /// Create an assume intrinsic call that allows the optimizer to
858 /// assume that the provided operand bundles hold.
860
861 /// Create a llvm.experimental.noalias.scope.decl intrinsic call.
867
868 /// Create a call to the experimental.gc.statepoint intrinsic to
869 /// start a new statepoint sequence.
871 uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualCallee,
872 ArrayRef<Value *> CallArgs, std::optional<ArrayRef<Value *>> DeoptArgs,
873 ArrayRef<Value *> GCArgs, const Twine &Name = "");
874
875 /// Create a call to the experimental.gc.statepoint intrinsic to
876 /// start a new statepoint sequence.
878 CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes,
879 FunctionCallee ActualCallee, uint32_t Flags,
880 ArrayRef<Value *> CallArgs,
881 std::optional<ArrayRef<Use>> TransitionArgs,
882 std::optional<ArrayRef<Use>> DeoptArgs,
883 ArrayRef<Value *> GCArgs, const Twine &Name = "");
884
885 /// Conveninence function for the common case when CallArgs are filled
886 /// in using ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be
887 /// .get()'ed to get the Value pointer.
889 CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes,
890 FunctionCallee ActualCallee, ArrayRef<Use> CallArgs,
891 std::optional<ArrayRef<Value *>> DeoptArgs,
892 ArrayRef<Value *> GCArgs, const Twine &Name = "");
893
894 /// Create an invoke to the experimental.gc.statepoint intrinsic to
895 /// start a new statepoint sequence.
898 FunctionCallee ActualInvokee, BasicBlock *NormalDest,
899 BasicBlock *UnwindDest, ArrayRef<Value *> InvokeArgs,
900 std::optional<ArrayRef<Value *>> DeoptArgs,
901 ArrayRef<Value *> GCArgs, const Twine &Name = "");
902
903 /// Create an invoke to the experimental.gc.statepoint intrinsic to
904 /// start a new statepoint sequence.
906 uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee,
907 BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags,
908 ArrayRef<Value *> InvokeArgs, std::optional<ArrayRef<Use>> TransitionArgs,
909 std::optional<ArrayRef<Use>> DeoptArgs, ArrayRef<Value *> GCArgs,
910 const Twine &Name = "");
911
912 // Convenience function for the common case when CallArgs are filled in using
913 // ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be .get()'ed to
914 // get the Value *.
917 FunctionCallee ActualInvokee, BasicBlock *NormalDest,
918 BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs,
919 std::optional<ArrayRef<Value *>> DeoptArgs,
920 ArrayRef<Value *> GCArgs, const Twine &Name = "");
921
922 /// Create a call to the experimental.gc.result intrinsic to extract
923 /// the result from a call wrapped in a statepoint.
924 LLVM_ABI CallInst *CreateGCResult(Instruction *Statepoint, Type *ResultType,
925 const Twine &Name = "");
926
927 /// Create a call to the experimental.gc.relocate intrinsics to
928 /// project the relocated value of one pointer from the statepoint.
929 LLVM_ABI CallInst *CreateGCRelocate(Instruction *Statepoint, int BaseOffset,
930 int DerivedOffset, Type *ResultType,
931 const Twine &Name = "");
932
933 /// Create a call to the experimental.gc.pointer.base intrinsic to get the
934 /// base pointer for the specified derived pointer.
936 const Twine &Name = "");
937
938 /// Create a call to the experimental.gc.get.pointer.offset intrinsic to get
939 /// the offset of the specified derived pointer from its base.
941 const Twine &Name = "");
942
943 /// Create a call to llvm.vscale.<Ty>().
944 Value *CreateVScale(Type *Ty, const Twine &Name = "") {
945 return CreateIntrinsic(Intrinsic::vscale, {Ty}, {}, {}, Name);
946 }
947
948 /// Create an expression which evaluates to the number of elements in \p EC
949 /// at runtime. This can result in poison if type \p Ty is not big enough to
950 /// hold the value.
952
953 /// Create an expression which evaluates to the number of units in \p Size
954 /// at runtime. This works for both units of bits and bytes. This can result
955 /// in poison if type \p Ty is not big enough to hold the value.
957
958 /// Get allocation size of an alloca as a runtime Value* (handles both static
959 /// and dynamic allocas and vscale factor).
961
962 /// Creates a vector of type \p DstType with the linear sequence <0, 1, ...>
963 LLVM_ABI Value *CreateStepVector(Type *DstType, const Twine &Name = "");
964
965 /// Create a call to intrinsic \p ID with 1 operand which is mangled on its
966 /// type.
968 FMFSource FMFSource = {},
969 const Twine &Name = "");
970
971 /// Create a call to intrinsic \p ID with 2 operands which is mangled on the
972 /// first type.
974 Value *RHS, FMFSource FMFSource = {},
975 const Twine &Name = "");
976
977 /// Create a call to intrinsic \p ID with \p Args, mangled using
978 /// \p OverloadTypes. If \p FMFSource is provided, copy fast-math-flags from
979 /// that instruction to the intrinsic. It is guaranteed not to fold.
981 Intrinsic::ID ID, ArrayRef<Type *> OverloadTypes, ArrayRef<Value *> Args,
982 FMFSource FMFSource = {}, const Twine &Name = "",
983 ArrayRef<OperandBundleDef> OpBundles = {});
984
985 /// Create a call to intrinsic \p ID with \p RetTy and \p Args. If
986 /// \p FMFSource is provided, copy fast-math-flags from that instruction to
987 /// the intrinsic. It is guaranteed not to fold.
989 Intrinsic::ID ID,
991 FMFSource FMFSource = {},
992 const Twine &Name = "");
993
994 /// Create a call to non-overloaded intrinsic \p ID with \p Args. If
995 /// \p FMFSource is provided, copy fast-math-flags from that instruction to
996 /// the intrinsic. It is guranteed not to fold.
999 FMFSource FMFSource = {},
1000 const Twine &Name = "") {
1001 return CreateIntrinsicWithoutFolding(ID, /*Types=*/{}, Args, FMFSource,
1002 Name);
1003 }
1004
1005 /// Variant to create a possibly constant-folded intrinsic. An optional \p
1006 /// SetFn is called if the intrinsic doesn't fold, and can be used to set
1007 /// things like attributes.
1009 Intrinsic::ID ID, ArrayRef<Type *> OverloadTypes, ArrayRef<Value *> Args,
1010 FMFSource FMFSource = {}, const Twine &Name = "",
1011 ArrayRef<OperandBundleDef> OpBundles = {},
1012 function_ref<void(CallInst *)> SetFn = [](CallInst *) {});
1013
1014 /// Variant to create a possibly constant-folded intrinsic. An optional \p
1015 /// SetFn is called if the intrinsic doesn't fold, and can be used to set
1016 /// things like attributes.
1018 Type *RetTy, Intrinsic::ID ID, ArrayRef<Value *> Args,
1019 FMFSource FMFSource = {}, const Twine &Name = "",
1020 function_ref<void(CallInst *)> SetFn = [](CallInst *) {});
1021
1022 /// Variant to create a possibly constant-folded intrinsic. An optional \p
1023 /// SetFn is called if the intrinsic doesn't fold, and can be used to set
1024 /// things like attributes.
1027 const Twine &Name = "",
1028 function_ref<void(CallInst *)> SetFn = [](CallInst *) {}) {
1029 return CreateIntrinsic(ID, /*Types=*/{}, Args, FMFSource, Name, {}, SetFn);
1030 }
1031
1032 /// Create call to the fabs intrinsic.
1034 const Twine &Name = "") {
1035 return CreateUnaryIntrinsic(Intrinsic::fabs, V, FMFSource, Name);
1036 }
1037
1038 /// Create call to the minnum intrinsic.
1040 const Twine &Name = "") {
1041 if (IsFPConstrained) {
1043 Intrinsic::experimental_constrained_minnum, LHS, RHS, FMFSource,
1044 Name);
1045 }
1046
1047 return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, FMFSource, Name);
1048 }
1049
1050 /// Create call to the maxnum intrinsic.
1052 const Twine &Name = "") {
1053 if (IsFPConstrained) {
1055 Intrinsic::experimental_constrained_maxnum, LHS, RHS, FMFSource,
1056 Name);
1057 }
1058
1059 return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, FMFSource, Name);
1060 }
1061
1062 /// Create call to the minimum intrinsic.
1063 Value *CreateMinimum(Value *LHS, Value *RHS, const Twine &Name = "") {
1064 return CreateBinaryIntrinsic(Intrinsic::minimum, LHS, RHS, nullptr, Name);
1065 }
1066
1067 /// Create call to the maximum intrinsic.
1068 Value *CreateMaximum(Value *LHS, Value *RHS, const Twine &Name = "") {
1069 return CreateBinaryIntrinsic(Intrinsic::maximum, LHS, RHS, nullptr, Name);
1070 }
1071
1072 /// Create call to the minimumnum intrinsic.
1073 Value *CreateMinimumNum(Value *LHS, Value *RHS, const Twine &Name = "") {
1074 return CreateBinaryIntrinsic(Intrinsic::minimumnum, LHS, RHS, nullptr,
1075 Name);
1076 }
1077
1078 /// Create call to the maximum intrinsic.
1079 Value *CreateMaximumNum(Value *LHS, Value *RHS, const Twine &Name = "") {
1080 return CreateBinaryIntrinsic(Intrinsic::maximumnum, LHS, RHS, nullptr,
1081 Name);
1082 }
1083
1084 /// Create call to the copysign intrinsic.
1086 const Twine &Name = "") {
1087 return CreateBinaryIntrinsic(Intrinsic::copysign, LHS, RHS, FMFSource,
1088 Name);
1089 }
1090
1091 /// Create call to the ldexp intrinsic.
1093 const Twine &Name = "") {
1094 assert(!IsFPConstrained && "TODO: Support strictfp");
1095 return CreateIntrinsic(Intrinsic::ldexp, {Src->getType(), Exp->getType()},
1096 {Src, Exp}, FMFSource, Name);
1097 }
1098
1099 /// Create call to the fma intrinsic.
1100 Value *CreateFMA(Value *Factor1, Value *Factor2, Value *Summand,
1101 FMFSource FMFSource = {}, const Twine &Name = "") {
1102 if (IsFPConstrained) {
1104 Intrinsic::experimental_constrained_fma, {Factor1->getType()},
1105 {Factor1, Factor2, Summand}, FMFSource, Name);
1106 }
1107
1108 return CreateIntrinsic(Intrinsic::fma, {Factor1->getType()},
1109 {Factor1, Factor2, Summand}, FMFSource, Name);
1110 }
1111
1112 /// Create a call to the arithmetic_fence intrinsic.
1114 const Twine &Name = "") {
1115 return CreateIntrinsic(Intrinsic::arithmetic_fence, DstType, Val, nullptr,
1116 Name);
1117 }
1118
1119 /// Create a call to the vector.extract intrinsic.
1120 Value *CreateExtractVector(Type *DstType, Value *SrcVec, Value *Idx,
1121 const Twine &Name = "") {
1122 return CreateIntrinsic(Intrinsic::vector_extract,
1123 {DstType, SrcVec->getType()}, {SrcVec, Idx}, nullptr,
1124 Name);
1125 }
1126
1127 /// Create a call to the vector.extract intrinsic.
1129 const Twine &Name = "") {
1130 return CreateExtractVector(DstType, SrcVec, getInt64(Idx), Name);
1131 }
1132
1133 /// Create a call to the vector.insert intrinsic.
1134 Value *CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec,
1135 Value *Idx, const Twine &Name = "") {
1136 return CreateIntrinsic(Intrinsic::vector_insert,
1137 {DstType, SubVec->getType()}, {SrcVec, SubVec, Idx},
1138 nullptr, Name);
1139 }
1140
1141 /// Create a call to the vector.extract intrinsic.
1142 Value *CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec,
1143 uint64_t Idx, const Twine &Name = "") {
1144 return CreateInsertVector(DstType, SrcVec, SubVec, getInt64(Idx), Name);
1145 }
1146
1147 /// Create a call to llvm.stacksave
1148 CallInst *CreateStackSave(const Twine &Name = "") {
1149 const DataLayout &DL = BB->getDataLayout();
1150 return CreateIntrinsicWithoutFolding(Intrinsic::stacksave,
1151 {DL.getAllocaPtrType(Context)}, {},
1152 nullptr, Name);
1153 }
1154
1155 /// Create a call to llvm.stackrestore
1156 CallInst *CreateStackRestore(Value *Ptr, const Twine &Name = "") {
1158 Intrinsic::stackrestore, {Ptr->getType()}, {Ptr}, nullptr, Name);
1159 }
1160
1161 /// Create a call to llvm.experimental_cttz_elts
1163 bool ZeroIsPoison = true,
1164 const Twine &Name = "") {
1165 return CreateIntrinsic(Intrinsic::experimental_cttz_elts,
1166 {ResTy, Mask->getType()},
1167 {Mask, getInt1(ZeroIsPoison)}, nullptr, Name);
1168 }
1169
1170private:
1171 /// Create a call to a masked intrinsic with given Id.
1172 CallInst *CreateMaskedIntrinsic(Intrinsic::ID Id, ArrayRef<Value *> Ops,
1173 ArrayRef<Type *> OverloadedTypes,
1174 const Twine &Name = "");
1175
1176 //===--------------------------------------------------------------------===//
1177 // Instruction creation methods: Terminators
1178 //===--------------------------------------------------------------------===//
1179
1180private:
1181 /// Helper to add branch weight and unpredictable metadata onto an
1182 /// instruction.
1183 /// \returns The annotated instruction.
1184 template <typename InstTy>
1185 InstTy *addBranchMetadata(InstTy *I, MDNode *Weights, MDNode *Unpredictable) {
1186 if (Weights)
1187 I->setMetadata(LLVMContext::MD_prof, Weights);
1188 if (Unpredictable)
1189 I->setMetadata(LLVMContext::MD_unpredictable, Unpredictable);
1190 return I;
1191 }
1192
1193public:
1194 /// Create a 'ret void' instruction.
1198
1199 /// Create a 'ret <val>' instruction.
1203
1204 /// Create a sequence of N insertvalue instructions, with one Value from the
1205 /// RetVals array each, that build a aggregate return value one value at a
1206 /// time, and a ret instruction to return the resulting aggregate value.
1207 ///
1208 /// This is a convenience function for code that uses aggregate return values
1209 /// as a vehicle for having multiple return values.
1212 for (size_t i = 0, N = RetVals.size(); i != N; ++i)
1213 V = CreateInsertValue(V, RetVals[i], i, "mrv");
1214 return Insert(ReturnInst::Create(Context, V));
1215 }
1216
1217 /// Create an unconditional 'br label X' instruction.
1219 return Insert(UncondBrInst::Create(Dest));
1220 }
1221
1222 /// Create a conditional 'br Cond, TrueDest, FalseDest'
1223 /// instruction.
1225 MDNode *BranchWeights = nullptr,
1226 MDNode *Unpredictable = nullptr) {
1227 return Insert(addBranchMetadata(CondBrInst::Create(Cond, True, False),
1228 BranchWeights, Unpredictable));
1229 }
1230
1231 /// Create a conditional 'br Cond, TrueDest, FalseDest'
1232 /// instruction. Copy branch meta data if available.
1234 Instruction *MDSrc) {
1235 CondBrInst *Br = CondBrInst::Create(Cond, True, False);
1236 if (MDSrc) {
1237 unsigned WL[4] = {LLVMContext::MD_prof, LLVMContext::MD_unpredictable,
1238 LLVMContext::MD_make_implicit, LLVMContext::MD_dbg};
1239 Br->copyMetadata(*MDSrc, WL);
1240 }
1241 return Insert(Br);
1242 }
1243
1244 /// Create a switch instruction with the specified value, default dest,
1245 /// and with a hint for the number of cases that will be added (for efficient
1246 /// allocation).
1247 SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10,
1248 MDNode *BranchWeights = nullptr,
1249 MDNode *Unpredictable = nullptr) {
1250 return Insert(addBranchMetadata(SwitchInst::Create(V, Dest, NumCases),
1251 BranchWeights, Unpredictable));
1252 }
1253
1254 /// Create an indirect branch instruction with the specified address
1255 /// operand, with an optional hint for the number of destinations that will be
1256 /// added (for efficient allocation).
1257 IndirectBrInst *CreateIndirectBr(Value *Addr, unsigned NumDests = 10) {
1258 return Insert(IndirectBrInst::Create(Addr, NumDests));
1259 }
1260
1261 /// Create an invoke instruction.
1263 BasicBlock *NormalDest, BasicBlock *UnwindDest,
1264 ArrayRef<Value *> Args,
1266 const Twine &Name = "") {
1267 InvokeInst *II =
1268 InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, OpBundles);
1269 if (IsFPConstrained)
1271 return Insert(II, Name);
1272 }
1274 BasicBlock *NormalDest, BasicBlock *UnwindDest,
1275 ArrayRef<Value *> Args = {},
1276 const Twine &Name = "") {
1277 InvokeInst *II =
1278 InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
1279 if (IsFPConstrained)
1281 return Insert(II, Name);
1282 }
1283
1285 BasicBlock *UnwindDest, ArrayRef<Value *> Args,
1287 const Twine &Name = "") {
1288 return CreateInvoke(Callee.getFunctionType(), Callee.getCallee(),
1289 NormalDest, UnwindDest, Args, OpBundles, Name);
1290 }
1291
1293 BasicBlock *UnwindDest, ArrayRef<Value *> Args = {},
1294 const Twine &Name = "") {
1295 return CreateInvoke(Callee.getFunctionType(), Callee.getCallee(),
1296 NormalDest, UnwindDest, Args, Name);
1297 }
1298
1299 /// \brief Create a callbr instruction.
1301 BasicBlock *DefaultDest,
1302 ArrayRef<BasicBlock *> IndirectDests,
1303 ArrayRef<Value *> Args = {},
1304 const Twine &Name = "") {
1305 return Insert(CallBrInst::Create(Ty, Callee, DefaultDest, IndirectDests,
1306 Args), Name);
1307 }
1309 BasicBlock *DefaultDest,
1310 ArrayRef<BasicBlock *> IndirectDests,
1311 ArrayRef<Value *> Args,
1313 const Twine &Name = "") {
1314 return Insert(
1315 CallBrInst::Create(Ty, Callee, DefaultDest, IndirectDests, Args,
1316 OpBundles), Name);
1317 }
1318
1320 ArrayRef<BasicBlock *> IndirectDests,
1321 ArrayRef<Value *> Args = {},
1322 const Twine &Name = "") {
1323 return CreateCallBr(Callee.getFunctionType(), Callee.getCallee(),
1324 DefaultDest, IndirectDests, Args, Name);
1325 }
1327 ArrayRef<BasicBlock *> IndirectDests,
1328 ArrayRef<Value *> Args,
1330 const Twine &Name = "") {
1331 return CreateCallBr(Callee.getFunctionType(), Callee.getCallee(),
1332 DefaultDest, IndirectDests, Args, Name);
1333 }
1334
1336 return Insert(ResumeInst::Create(Exn));
1337 }
1338
1340 BasicBlock *UnwindBB = nullptr) {
1341 return Insert(CleanupReturnInst::Create(CleanupPad, UnwindBB));
1342 }
1343
1345 unsigned NumHandlers,
1346 const Twine &Name = "") {
1347 return Insert(CatchSwitchInst::Create(ParentPad, UnwindBB, NumHandlers),
1348 Name);
1349 }
1350
1352 const Twine &Name = "") {
1353 return Insert(CatchPadInst::Create(ParentPad, Args), Name);
1354 }
1355
1357 ArrayRef<Value *> Args = {},
1358 const Twine &Name = "") {
1359 return Insert(CleanupPadInst::Create(ParentPad, Args), Name);
1360 }
1361
1365
1369
1370 //===--------------------------------------------------------------------===//
1371 // Instruction creation methods: Binary Operators
1372 //===--------------------------------------------------------------------===//
1373private:
1374 BinaryOperator *CreateInsertNUWNSWBinOp(BinaryOperator::BinaryOps Opc,
1375 Value *LHS, Value *RHS,
1376 const Twine &Name,
1377 bool HasNUW, bool HasNSW) {
1379 if (HasNUW) BO->setHasNoUnsignedWrap();
1380 if (HasNSW) BO->setHasNoSignedWrap();
1381 return BO;
1382 }
1383
1384 Instruction *setFPAttrs(Instruction *I, MDNode *FPMD,
1385 FastMathFlags FMF) const {
1386 if (!FPMD)
1387 FPMD = DefaultFPMathTag;
1388 if (FPMD)
1389 I->setMetadata(LLVMContext::MD_fpmath, FPMD);
1390 I->setFastMathFlags(FMF);
1391 return I;
1392 }
1393
1394 Value *getConstrainedFPRounding(std::optional<RoundingMode> Rounding) {
1396
1397 if (Rounding)
1398 UseRounding = *Rounding;
1399
1400 std::optional<StringRef> RoundingStr =
1401 convertRoundingModeToStr(UseRounding);
1402 assert(RoundingStr && "Garbage strict rounding mode!");
1403 auto *RoundingMDS = MDString::get(Context, *RoundingStr);
1404
1405 return MetadataAsValue::get(Context, RoundingMDS);
1406 }
1407
1408 Value *getConstrainedFPExcept(std::optional<fp::ExceptionBehavior> Except) {
1409 std::optional<StringRef> ExceptStr = convertExceptionBehaviorToStr(
1410 Except.value_or(DefaultConstrainedExcept));
1411 assert(ExceptStr && "Garbage strict exception behavior!");
1412 auto *ExceptMDS = MDString::get(Context, *ExceptStr);
1413
1414 return MetadataAsValue::get(Context, ExceptMDS);
1415 }
1416
1417 Value *getConstrainedFPPredicate(CmpInst::Predicate Predicate) {
1418 assert(CmpInst::isFPPredicate(Predicate) &&
1419 Predicate != CmpInst::FCMP_FALSE &&
1420 Predicate != CmpInst::FCMP_TRUE &&
1421 "Invalid constrained FP comparison predicate!");
1422
1423 StringRef PredicateStr = CmpInst::getPredicateName(Predicate);
1424 auto *PredicateMDS = MDString::get(Context, PredicateStr);
1425
1426 return MetadataAsValue::get(Context, PredicateMDS);
1427 }
1428
1429public:
1430 Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "",
1431 bool HasNUW = false, bool HasNSW = false) {
1432 if (Value *V =
1433 Folder.FoldNoWrapBinOp(Instruction::Add, LHS, RHS, HasNUW, HasNSW))
1434 return V;
1435 return CreateInsertNUWNSWBinOp(Instruction::Add, LHS, RHS, Name, HasNUW,
1436 HasNSW);
1437 }
1438
1439 Value *CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name = "") {
1440 return CreateAdd(LHS, RHS, Name, false, true);
1441 }
1442
1443 Value *CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name = "") {
1444 return CreateAdd(LHS, RHS, Name, true, false);
1445 }
1446
1447 Value *CreateSub(Value *LHS, Value *RHS, const Twine &Name = "",
1448 bool HasNUW = false, bool HasNSW = false) {
1449 if (Value *V =
1450 Folder.FoldNoWrapBinOp(Instruction::Sub, LHS, RHS, HasNUW, HasNSW))
1451 return V;
1452 return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name, HasNUW,
1453 HasNSW);
1454 }
1455
1456 Value *CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name = "") {
1457 return CreateSub(LHS, RHS, Name, false, true);
1458 }
1459
1460 Value *CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name = "") {
1461 return CreateSub(LHS, RHS, Name, true, false);
1462 }
1463
1464 Value *CreateMul(Value *LHS, Value *RHS, const Twine &Name = "",
1465 bool HasNUW = false, bool HasNSW = false) {
1466 if (Value *V =
1467 Folder.FoldNoWrapBinOp(Instruction::Mul, LHS, RHS, HasNUW, HasNSW))
1468 return V;
1469 return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name, HasNUW,
1470 HasNSW);
1471 }
1472
1473 Value *CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name = "") {
1474 return CreateMul(LHS, RHS, Name, false, true);
1475 }
1476
1477 Value *CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name = "") {
1478 return CreateMul(LHS, RHS, Name, true, false);
1479 }
1480
1481 Value *CreateUDiv(Value *LHS, Value *RHS, const Twine &Name = "",
1482 bool isExact = false) {
1483 if (Value *V = Folder.FoldExactBinOp(Instruction::UDiv, LHS, RHS, isExact))
1484 return V;
1485 if (!isExact)
1486 return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
1487 return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
1488 }
1489
1490 Value *CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
1491 return CreateUDiv(LHS, RHS, Name, true);
1492 }
1493
1494 Value *CreateSDiv(Value *LHS, Value *RHS, const Twine &Name = "",
1495 bool isExact = false) {
1496 if (Value *V = Folder.FoldExactBinOp(Instruction::SDiv, LHS, RHS, isExact))
1497 return V;
1498 if (!isExact)
1499 return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
1500 return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
1501 }
1502
1503 Value *CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
1504 return CreateSDiv(LHS, RHS, Name, true);
1505 }
1506
1507 Value *CreateURem(Value *LHS, Value *RHS, const Twine &Name = "") {
1508 if (Value *V = Folder.FoldBinOp(Instruction::URem, LHS, RHS))
1509 return V;
1510 return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
1511 }
1512
1513 Value *CreateSRem(Value *LHS, Value *RHS, const Twine &Name = "") {
1514 if (Value *V = Folder.FoldBinOp(Instruction::SRem, LHS, RHS))
1515 return V;
1516 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
1517 }
1518
1519 Value *CreateShl(Value *LHS, Value *RHS, const Twine &Name = "",
1520 bool HasNUW = false, bool HasNSW = false) {
1521 if (Value *V =
1522 Folder.FoldNoWrapBinOp(Instruction::Shl, LHS, RHS, HasNUW, HasNSW))
1523 return V;
1524 return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
1525 HasNUW, HasNSW);
1526 }
1527
1528 Value *CreateShl(Value *LHS, const APInt &RHS, const Twine &Name = "",
1529 bool HasNUW = false, bool HasNSW = false) {
1530 return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1531 HasNUW, HasNSW);
1532 }
1533
1534 Value *CreateShl(Value *LHS, uint64_t RHS, const Twine &Name = "",
1535 bool HasNUW = false, bool HasNSW = false) {
1536 return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1537 HasNUW, HasNSW);
1538 }
1539
1540 Value *CreateLShr(Value *LHS, Value *RHS, const Twine &Name = "",
1541 bool isExact = false) {
1542 if (Value *V = Folder.FoldExactBinOp(Instruction::LShr, LHS, RHS, isExact))
1543 return V;
1544 if (!isExact)
1545 return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
1546 return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
1547 }
1548
1549 Value *CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1550 bool isExact = false) {
1551 return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1552 }
1553
1555 bool isExact = false) {
1556 return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1557 }
1558
1559 Value *CreateAShr(Value *LHS, Value *RHS, const Twine &Name = "",
1560 bool isExact = false) {
1561 if (Value *V = Folder.FoldExactBinOp(Instruction::AShr, LHS, RHS, isExact))
1562 return V;
1563 if (!isExact)
1564 return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
1565 return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
1566 }
1567
1568 Value *CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1569 bool isExact = false) {
1570 return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1571 }
1572
1574 bool isExact = false) {
1575 return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1576 }
1577
1578 Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") {
1579 if (auto *V = Folder.FoldBinOp(Instruction::And, LHS, RHS))
1580 return V;
1581 return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
1582 }
1583
1584 Value *CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1585 return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1586 }
1587
1588 Value *CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1589 return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1590 }
1591
1593 assert(!Ops.empty());
1594 Value *Accum = Ops[0];
1595 for (unsigned i = 1; i < Ops.size(); i++)
1596 Accum = CreateAnd(Accum, Ops[i]);
1597 return Accum;
1598 }
1599
1600 Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "",
1601 bool IsDisjoint = false) {
1602 if (auto *V = Folder.FoldBinOp(Instruction::Or, LHS, RHS))
1603 return V;
1604 return Insert(
1605 IsDisjoint ? BinaryOperator::CreateDisjoint(Instruction::Or, LHS, RHS)
1606 : BinaryOperator::CreateOr(LHS, RHS),
1607 Name);
1608 }
1609
1610 Value *CreateOr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1611 return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1612 }
1613
1614 Value *CreateOr(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1615 return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1616 }
1617
1619 assert(!Ops.empty());
1620 Value *Accum = Ops[0];
1621 for (unsigned i = 1; i < Ops.size(); i++)
1622 Accum = CreateOr(Accum, Ops[i]);
1623 return Accum;
1624 }
1625
1626 Value *CreateDisjointOr(Value *LHS, Value *RHS, const Twine &Name = "") {
1627 return CreateOr(LHS, RHS, Name, true);
1628 }
1629
1630 Value *CreateXor(Value *LHS, Value *RHS, const Twine &Name = "") {
1631 if (Value *V = Folder.FoldBinOp(Instruction::Xor, LHS, RHS))
1632 return V;
1633 return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
1634 }
1635
1636 Value *CreateXor(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1637 return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1638 }
1639
1640 Value *CreateXor(Value *LHS, uint64_t RHS, const Twine &Name = "") {
1641 return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1642 }
1643
1644 Value *CreateFAdd(Value *L, Value *R, const Twine &Name = "",
1645 MDNode *FPMD = nullptr) {
1646 return CreateFAddFMF(L, R, {}, Name, FPMD);
1647 }
1648
1650 const Twine &Name = "", MDNode *FPMD = nullptr) {
1651 if (IsFPConstrained)
1652 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fadd,
1653 L, R, FMFSource, Name, FPMD);
1654
1655 if (Value *V =
1656 Folder.FoldBinOpFMF(Instruction::FAdd, L, R, FMFSource.get(FMF)))
1657 return V;
1658 Instruction *I =
1659 setFPAttrs(BinaryOperator::CreateFAdd(L, R), FPMD, FMFSource.get(FMF));
1660 return Insert(I, Name);
1661 }
1662
1663 Value *CreateFSub(Value *L, Value *R, const Twine &Name = "",
1664 MDNode *FPMD = nullptr) {
1665 return CreateFSubFMF(L, R, {}, Name, FPMD);
1666 }
1667
1669 const Twine &Name = "", MDNode *FPMD = nullptr) {
1670 if (IsFPConstrained)
1671 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fsub,
1672 L, R, FMFSource, Name, FPMD);
1673
1674 if (Value *V =
1675 Folder.FoldBinOpFMF(Instruction::FSub, L, R, FMFSource.get(FMF)))
1676 return V;
1677 Instruction *I =
1678 setFPAttrs(BinaryOperator::CreateFSub(L, R), FPMD, FMFSource.get(FMF));
1679 return Insert(I, Name);
1680 }
1681
1682 Value *CreateFMul(Value *L, Value *R, const Twine &Name = "",
1683 MDNode *FPMD = nullptr) {
1684 return CreateFMulFMF(L, R, {}, Name, FPMD);
1685 }
1686
1688 const Twine &Name = "", MDNode *FPMD = nullptr) {
1689 if (IsFPConstrained)
1690 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fmul,
1691 L, R, FMFSource, Name, FPMD);
1692
1693 if (Value *V =
1694 Folder.FoldBinOpFMF(Instruction::FMul, L, R, FMFSource.get(FMF)))
1695 return V;
1696 Instruction *I =
1697 setFPAttrs(BinaryOperator::CreateFMul(L, R), FPMD, FMFSource.get(FMF));
1698 return Insert(I, Name);
1699 }
1700
1701 Value *CreateFDiv(Value *L, Value *R, const Twine &Name = "",
1702 MDNode *FPMD = nullptr) {
1703 return CreateFDivFMF(L, R, {}, Name, FPMD);
1704 }
1705
1707 const Twine &Name = "", MDNode *FPMD = nullptr) {
1708 if (IsFPConstrained)
1709 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fdiv,
1710 L, R, FMFSource, Name, FPMD);
1711
1712 if (Value *V =
1713 Folder.FoldBinOpFMF(Instruction::FDiv, L, R, FMFSource.get(FMF)))
1714 return V;
1715 Instruction *I =
1716 setFPAttrs(BinaryOperator::CreateFDiv(L, R), FPMD, FMFSource.get(FMF));
1717 return Insert(I, Name);
1718 }
1719
1720 Value *CreateFRem(Value *L, Value *R, const Twine &Name = "",
1721 MDNode *FPMD = nullptr) {
1722 return CreateFRemFMF(L, R, {}, Name, FPMD);
1723 }
1724
1726 const Twine &Name = "", MDNode *FPMD = nullptr) {
1727 if (IsFPConstrained)
1728 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_frem,
1729 L, R, FMFSource, Name, FPMD);
1730
1731 if (Value *V =
1732 Folder.FoldBinOpFMF(Instruction::FRem, L, R, FMFSource.get(FMF)))
1733 return V;
1734 Instruction *I =
1735 setFPAttrs(BinaryOperator::CreateFRem(L, R), FPMD, FMFSource.get(FMF));
1736 return Insert(I, Name);
1737 }
1738
1740 Value *LHS, Value *RHS, const Twine &Name = "",
1741 MDNode *FPMathTag = nullptr) {
1742 return CreateBinOpFMF(Opc, LHS, RHS, {}, Name, FPMathTag);
1743 }
1744
1746 FMFSource FMFSource, const Twine &Name = "",
1747 MDNode *FPMathTag = nullptr) {
1748 if (Value *V = Folder.FoldBinOp(Opc, LHS, RHS))
1749 return V;
1751 if (isa<FPMathOperator>(BinOp))
1752 setFPAttrs(BinOp, FPMathTag, FMFSource.get(FMF));
1753 return Insert(BinOp, Name);
1754 }
1755
1757 bool IsNUW, bool IsNSW, const Twine &Name = "") {
1758 if (Value *V = Folder.FoldNoWrapBinOp(Opc, LHS, RHS, IsNUW, IsNSW))
1759 return V;
1761 if (IsNUW)
1762 BinOp->setHasNoUnsignedWrap(IsNUW);
1763 if (IsNSW)
1764 BinOp->setHasNoSignedWrap(IsNSW);
1765 return Insert(BinOp, Name);
1766 }
1767
1769 bool IsExact, const Twine &Name = "") {
1770 if (Value *V = Folder.FoldExactBinOp(Opc, LHS, RHS, IsExact))
1771 return V;
1773 if (IsExact)
1774 BinOp->setIsExact(IsExact);
1775 return Insert(BinOp, Name);
1776 }
1777
1778 Value *CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name = "",
1779 Instruction *MDFrom = nullptr) {
1780 assert(Cond2->getType()->isIntOrIntVectorTy(1));
1781 return CreateSelect(Cond1, Cond2,
1782 ConstantInt::getNullValue(Cond2->getType()), Name,
1783 MDFrom);
1784 }
1785
1786 Value *CreateLogicalOr(Value *Cond1, Value *Cond2, const Twine &Name = "",
1787 Instruction *MDFrom = nullptr) {
1788 assert(Cond2->getType()->isIntOrIntVectorTy(1));
1789 return CreateSelect(Cond1, ConstantInt::getAllOnesValue(Cond2->getType()),
1790 Cond2, Name, MDFrom);
1791 }
1792
1794 const Twine &Name = "",
1795 Instruction *MDFrom = nullptr) {
1796 switch (Opc) {
1797 case Instruction::And:
1798 return CreateLogicalAnd(Cond1, Cond2, Name, MDFrom);
1799 case Instruction::Or:
1800 return CreateLogicalOr(Cond1, Cond2, Name, MDFrom);
1801 default:
1802 break;
1803 }
1804 llvm_unreachable("Not a logical operation.");
1805 }
1806
1807 // NOTE: this is sequential, non-commutative, ordered reduction!
1809 assert(!Ops.empty());
1810 Value *Accum = Ops[0];
1811 for (unsigned i = 1; i < Ops.size(); i++)
1812 Accum = CreateLogicalOr(Accum, Ops[i]);
1813 return Accum;
1814 }
1815
1816 /// This function is like @ref CreateIntrinsic for constrained fp
1817 /// intrinsics. It sets the rounding mode and exception behavior of
1818 /// the created intrinsic call according to \p Rounding and \p
1819 /// Except and it sets \p FPMathTag as the 'fpmath' metadata, using
1820 /// defaults if a value equals nullopt/null.
1823 FMFSource FMFSource, const Twine &Name, MDNode *FPMathTag = nullptr,
1824 std::optional<RoundingMode> Rounding = std::nullopt,
1825 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1826
1828 Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource = {},
1829 const Twine &Name = "", MDNode *FPMathTag = nullptr,
1830 std::optional<RoundingMode> Rounding = std::nullopt,
1831 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1832
1834 Intrinsic::ID ID, Value *L, Value *R, FMFSource FMFSource = {},
1835 const Twine &Name = "", MDNode *FPMathTag = nullptr,
1836 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1837
1838 Value *CreateNeg(Value *V, const Twine &Name = "", bool HasNSW = false) {
1839 return CreateSub(Constant::getNullValue(V->getType()), V, Name,
1840 /*HasNUW=*/0, HasNSW);
1841 }
1842
1843 Value *CreateNSWNeg(Value *V, const Twine &Name = "") {
1844 return CreateNeg(V, Name, /*HasNSW=*/true);
1845 }
1846
1847 Value *CreateFNeg(Value *V, const Twine &Name = "",
1848 MDNode *FPMathTag = nullptr) {
1849 return CreateFNegFMF(V, {}, Name, FPMathTag);
1850 }
1851
1853 MDNode *FPMathTag = nullptr) {
1854 if (Value *Res =
1855 Folder.FoldUnOpFMF(Instruction::FNeg, V, FMFSource.get(FMF)))
1856 return Res;
1857 return Insert(
1858 setFPAttrs(UnaryOperator::CreateFNeg(V), FPMathTag, FMFSource.get(FMF)),
1859 Name);
1860 }
1861
1862 Value *CreateNot(Value *V, const Twine &Name = "") {
1863 return CreateXor(V, Constant::getAllOnesValue(V->getType()), Name);
1864 }
1865
1867 Value *V, const Twine &Name = "",
1868 MDNode *FPMathTag = nullptr) {
1869 if (Value *Res = Folder.FoldUnOpFMF(Opc, V, FMF))
1870 return Res;
1872 if (isa<FPMathOperator>(UnOp))
1873 setFPAttrs(UnOp, FPMathTag, FMF);
1874 return Insert(UnOp, Name);
1875 }
1876
1877 /// Create either a UnaryOperator or BinaryOperator depending on \p Opc.
1878 /// Correct number of operands must be passed accordingly.
1880 const Twine &Name = "",
1881 MDNode *FPMathTag = nullptr);
1882
1883 //===--------------------------------------------------------------------===//
1884 // Instruction creation methods: Memory Instructions
1885 //===--------------------------------------------------------------------===//
1886
1887 AllocaInst *CreateAlloca(Type *Ty, unsigned AddrSpace,
1888 Value *ArraySize = nullptr, const Twine &Name = "") {
1889 const DataLayout &DL = BB->getDataLayout();
1890 Align AllocaAlign = DL.getPrefTypeAlign(Ty);
1891 return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
1892 }
1893
1894 AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = nullptr,
1895 const Twine &Name = "") {
1896 const DataLayout &DL = BB->getDataLayout();
1897 Align AllocaAlign = DL.getPrefTypeAlign(Ty);
1898 unsigned AddrSpace = DL.getAllocaAddrSpace();
1899 return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
1900 }
1901
1903 const DataLayout &DL = BB->getDataLayout();
1904 PointerType *PtrTy = DL.getAllocaPtrType(Context);
1905 auto *Output = CreateIntrinsicWithoutFolding(Intrinsic::structured_alloca,
1906 {PtrTy}, {}, {}, Name);
1907 Output->addRetAttr(
1908 Attribute::get(getContext(), Attribute::ElementType, BaseType));
1909 return Output;
1910 }
1911
1912 /// Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of
1913 /// converting the string to 'bool' for the isVolatile parameter.
1914 LoadInst *CreateLoad(Type *Ty, Value *Ptr, const char *Name) {
1915 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), Name);
1916 }
1917
1918 LoadInst *CreateLoad(Type *Ty, Value *Ptr, const Twine &Name = "") {
1919 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), Name);
1920 }
1921
1922 LoadInst *CreateLoad(Type *Ty, Value *Ptr, bool isVolatile,
1923 const Twine &Name = "") {
1924 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), isVolatile, Name);
1925 }
1926
1928 const LoadStoreInstProperties &Props,
1929 const Twine &Name = "") {
1930 return Insert(new LoadInst(Ty, Ptr, Twine(), Props), Name);
1931 }
1932
1933 StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) {
1934 return CreateAlignedStore(Val, Ptr, MaybeAlign(), isVolatile);
1935 }
1936
1938 const LoadStoreInstProperties &Props) {
1939 return Insert(new StoreInst(Val, Ptr, Props));
1940 }
1941
1943 const char *Name) {
1944 return CreateAlignedLoad(Ty, Ptr, Align, /*isVolatile*/false, Name);
1945 }
1946
1948 const Twine &Name = "") {
1949 return CreateAlignedLoad(Ty, Ptr, Align, /*isVolatile*/false, Name);
1950 }
1951
1953 bool isVolatile, const Twine &Name = "") {
1954 if (!Align) {
1955 const DataLayout &DL = BB->getDataLayout();
1956 Align = DL.getABITypeAlign(Ty);
1957 }
1958 return Insert(new LoadInst(Ty, Ptr, Twine(), isVolatile, *Align), Name);
1959 }
1960
1962 bool isVolatile = false) {
1963 if (!Align) {
1964 const DataLayout &DL = BB->getDataLayout();
1965 Align = DL.getABITypeAlign(Val->getType());
1966 }
1967 return Insert(new StoreInst(Val, Ptr, isVolatile, *Align));
1968 }
1971 const Twine &Name = "") {
1972 return Insert(new FenceInst(Context, Ordering, SSID), Name);
1973 }
1974
1977 AtomicOrdering SuccessOrdering,
1978 AtomicOrdering FailureOrdering,
1980 if (!Align) {
1981 const DataLayout &DL = BB->getDataLayout();
1982 Align = llvm::Align(DL.getTypeStoreSize(New->getType()));
1983 }
1984
1985 return Insert(new AtomicCmpXchgInst(Ptr, Cmp, New, *Align, SuccessOrdering,
1986 FailureOrdering, SSID));
1987 }
1988
1990 Value *Val, MaybeAlign Align,
1991 AtomicOrdering Ordering,
1993 bool Elementwise = false) {
1994 if (!Align) {
1995 const DataLayout &DL = BB->getDataLayout();
1996 Align = llvm::Align(DL.getTypeStoreSize(Val->getType()));
1997 }
1998
1999 return Insert(
2000 new AtomicRMWInst(Op, Ptr, Val, *Align, Ordering, SSID, Elementwise));
2001 }
2002
2004 ArrayRef<Value *> Indices,
2005 const Twine &Name = "") {
2007 Args.push_back(PtrBase);
2008 llvm::append_range(Args, Indices);
2009
2010 return CreateIntrinsic(
2011 Intrinsic::structured_gep, {PtrBase->getType()}, Args, {}, Name, {},
2012 [&](CallInst *Output) {
2013 Output->addParamAttr(
2014 0,
2015 Attribute::get(getContext(), Attribute::ElementType, BaseType));
2016 });
2017 }
2018
2020 const Twine &Name = "",
2022 if (auto *V = Folder.FoldGEP(Ty, Ptr, IdxList, NW))
2023 return V;
2024 return Insert(GetElementPtrInst::Create(Ty, Ptr, IdxList, NW), Name);
2025 }
2026
2028 const Twine &Name = "") {
2029 return CreateGEP(Ty, Ptr, IdxList, Name, GEPNoWrapFlags::inBounds());
2030 }
2031
2032 Value *CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0,
2033 const Twine &Name = "") {
2034 Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Idx0);
2035 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::none());
2036 }
2037
2038 Value *CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0,
2039 const Twine &Name = "") {
2040 Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Idx0);
2041 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::inBounds());
2042 }
2043
2044 Value *CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1,
2045 const Twine &Name = "",
2047 Value *Idxs[] = {
2048 ConstantInt::get(Type::getInt32Ty(Context), Idx0),
2049 ConstantInt::get(Type::getInt32Ty(Context), Idx1)
2050 };
2051 return CreateGEP(Ty, Ptr, Idxs, Name, NWFlags);
2052 }
2053
2054 Value *CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0,
2055 unsigned Idx1, const Twine &Name = "") {
2056 Value *Idxs[] = {
2057 ConstantInt::get(Type::getInt32Ty(Context), Idx0),
2058 ConstantInt::get(Type::getInt32Ty(Context), Idx1)
2059 };
2060 return CreateGEP(Ty, Ptr, Idxs, Name, GEPNoWrapFlags::inBounds());
2061 }
2062
2064 const Twine &Name = "") {
2065 Value *Idx = ConstantInt::get(Type::getInt64Ty(Context), Idx0);
2066 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::none());
2067 }
2068
2070 const Twine &Name = "") {
2071 Value *Idx = ConstantInt::get(Type::getInt64Ty(Context), Idx0);
2072 return CreateGEP(Ty, Ptr, Idx, Name, GEPNoWrapFlags::inBounds());
2073 }
2074
2076 const Twine &Name = "") {
2077 Value *Idxs[] = {
2078 ConstantInt::get(Type::getInt64Ty(Context), Idx0),
2079 ConstantInt::get(Type::getInt64Ty(Context), Idx1)
2080 };
2081 return CreateGEP(Ty, Ptr, Idxs, Name, GEPNoWrapFlags::none());
2082 }
2083
2085 uint64_t Idx1, const Twine &Name = "") {
2086 Value *Idxs[] = {
2087 ConstantInt::get(Type::getInt64Ty(Context), Idx0),
2088 ConstantInt::get(Type::getInt64Ty(Context), Idx1)
2089 };
2090 return CreateGEP(Ty, Ptr, Idxs, Name, GEPNoWrapFlags::inBounds());
2091 }
2092
2093 Value *CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx,
2094 const Twine &Name = "") {
2095 GEPNoWrapFlags NWFlags =
2097 return CreateConstGEP2_32(Ty, Ptr, 0, Idx, Name, NWFlags);
2098 }
2099
2100 Value *CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name = "",
2102 return CreateGEP(getInt8Ty(), Ptr, Offset, Name, NW);
2103 }
2104
2106 const Twine &Name = "") {
2107 return CreateGEP(getInt8Ty(), Ptr, Offset, Name,
2109 }
2110
2111 //===--------------------------------------------------------------------===//
2112 // Instruction creation methods: Cast/Conversion Operators
2113 //===--------------------------------------------------------------------===//
2114
2115 Value *CreateTrunc(Value *V, Type *DestTy, const Twine &Name = "",
2116 bool IsNUW = false, bool IsNSW = false) {
2117 if (V->getType() == DestTy)
2118 return V;
2119 if (Value *Folded = Folder.FoldCast(Instruction::Trunc, V, DestTy))
2120 return Folded;
2121 Instruction *I = CastInst::Create(Instruction::Trunc, V, DestTy);
2122 if (IsNUW)
2123 I->setHasNoUnsignedWrap();
2124 if (IsNSW)
2125 I->setHasNoSignedWrap();
2126 return Insert(I, Name);
2127 }
2128
2129 Value *CreateZExt(Value *V, Type *DestTy, const Twine &Name = "",
2130 bool IsNonNeg = false) {
2131 if (V->getType() == DestTy)
2132 return V;
2133 if (Value *Folded = Folder.FoldCast(Instruction::ZExt, V, DestTy))
2134 return Folded;
2135 Instruction *I = Insert(new ZExtInst(V, DestTy), Name);
2136 if (IsNonNeg)
2137 I->setNonNeg();
2138 return I;
2139 }
2140
2141 Value *CreateSExt(Value *V, Type *DestTy, const Twine &Name = "") {
2142 return CreateCast(Instruction::SExt, V, DestTy, Name);
2143 }
2144
2145 /// Create a ZExt or Trunc from the integer value V to DestTy. Return
2146 /// the value untouched if the type of V is already DestTy.
2148 const Twine &Name = "") {
2149 assert(V->getType()->isIntOrIntVectorTy() &&
2150 DestTy->isIntOrIntVectorTy() &&
2151 "Can only zero extend/truncate integers!");
2152 Type *VTy = V->getType();
2153 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2154 return CreateZExt(V, DestTy, Name);
2155 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2156 return CreateTrunc(V, DestTy, Name);
2157 return V;
2158 }
2159
2160 /// Create a SExt or Trunc from the integer value V to DestTy. Return
2161 /// the value untouched if the type of V is already DestTy.
2163 const Twine &Name = "") {
2164 assert(V->getType()->isIntOrIntVectorTy() &&
2165 DestTy->isIntOrIntVectorTy() &&
2166 "Can only sign extend/truncate integers!");
2167 Type *VTy = V->getType();
2168 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2169 return CreateSExt(V, DestTy, Name);
2170 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2171 return CreateTrunc(V, DestTy, Name);
2172 return V;
2173 }
2174
2175 Value *CreateFPToUI(Value *V, Type *DestTy, const Twine &Name = "") {
2176 if (IsFPConstrained)
2177 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptoui,
2178 V, DestTy, nullptr, Name);
2179 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
2180 }
2181
2182 Value *CreateFPToSI(Value *V, Type *DestTy, const Twine &Name = "") {
2183 if (IsFPConstrained)
2184 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptosi,
2185 V, DestTy, nullptr, Name);
2186 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
2187 }
2188
2189 Value *CreateUIToFP(Value *V, Type *DestTy, const Twine &Name = "",
2190 bool IsNonNeg = false, MDNode *FPMathTag = nullptr) {
2191 if (IsFPConstrained)
2192 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_uitofp,
2193 V, DestTy, nullptr, Name);
2194 Value *Val = CreateCast(Instruction::UIToFP, V, DestTy, Name, FPMathTag);
2195 if (auto *I = dyn_cast<Instruction>(Val))
2196 if (IsNonNeg)
2197 I->setNonNeg();
2198 return Val;
2199 }
2200
2201 Value *CreateSIToFP(Value *V, Type *DestTy, const Twine &Name = "",
2202 MDNode *FPMathTag = nullptr) {
2203 if (IsFPConstrained)
2204 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_sitofp,
2205 V, DestTy, nullptr, Name);
2206 return CreateCast(Instruction::SIToFP, V, DestTy, Name, FPMathTag);
2207 }
2208
2209 Value *CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name = "",
2210 MDNode *FPMathTag = nullptr) {
2211 return CreateFPTruncFMF(V, DestTy, {}, Name, FPMathTag);
2212 }
2213
2215 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2216 if (IsFPConstrained)
2218 Intrinsic::experimental_constrained_fptrunc, V, DestTy, FMFSource,
2219 Name, FPMathTag);
2220 return CreateCast(Instruction::FPTrunc, V, DestTy, Name, FPMathTag,
2221 FMFSource);
2222 }
2223
2224 Value *CreateFPExt(Value *V, Type *DestTy, const Twine &Name = "",
2225 MDNode *FPMathTag = nullptr) {
2226 return CreateFPExtFMF(V, DestTy, {}, Name, FPMathTag);
2227 }
2228
2230 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2231 if (IsFPConstrained)
2232 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fpext,
2233 V, DestTy, FMFSource, Name, FPMathTag);
2234 return CreateCast(Instruction::FPExt, V, DestTy, Name, FPMathTag,
2235 FMFSource);
2236 }
2237 Value *CreatePtrToAddr(Value *V, const Twine &Name = "") {
2238 return CreateCast(Instruction::PtrToAddr, V,
2239 BB->getDataLayout().getAddressType(V->getType()), Name);
2240 }
2242 const Twine &Name = "") {
2243 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
2244 }
2245
2247 const Twine &Name = "") {
2248 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
2249 }
2250
2252 const Twine &Name = "") {
2253 return CreateCast(Instruction::BitCast, V, DestTy, Name);
2254 }
2255
2256 Value *CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name = "",
2257 bool IsNonNull = false) {
2258 if (V->getType() == DestTy)
2259 return V;
2260 if (Value *Folded = Folder.FoldCast(Instruction::AddrSpaceCast, V, DestTy))
2261 return Folded;
2262 Instruction *I = Insert(new AddrSpaceCastInst(V, DestTy), Name);
2263 if (IsNonNull)
2264 cast<AddrSpaceCastInst>(I)->setNonNull();
2265 return I;
2266 }
2267
2268 Value *CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2269 Instruction::CastOps CastOp =
2270 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2271 ? Instruction::BitCast
2272 : Instruction::ZExt;
2273 return CreateCast(CastOp, V, DestTy, Name);
2274 }
2275
2276 Value *CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2277 Instruction::CastOps CastOp =
2278 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2279 ? Instruction::BitCast
2280 : Instruction::SExt;
2281 return CreateCast(CastOp, V, DestTy, Name);
2282 }
2283
2284 Value *CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2285 Instruction::CastOps CastOp =
2286 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2287 ? Instruction::BitCast
2288 : Instruction::Trunc;
2289 return CreateCast(CastOp, V, DestTy, Name);
2290 }
2291
2293 const Twine &Name = "", MDNode *FPMathTag = nullptr,
2294 FMFSource FMFSource = {}) {
2295 if (V->getType() == DestTy)
2296 return V;
2297 if (Value *Folded = Folder.FoldCast(Op, V, DestTy))
2298 return Folded;
2299 Instruction *Cast = CastInst::Create(Op, V, DestTy);
2300 if (isa<FPMathOperator>(Cast))
2301 setFPAttrs(Cast, FPMathTag, FMFSource.get(FMF));
2302 return Insert(Cast, Name);
2303 }
2304
2306 const Twine &Name = "") {
2307 if (V->getType() == DestTy)
2308 return V;
2309 if (auto *VC = dyn_cast<Constant>(V))
2310 return Insert(Folder.CreatePointerCast(VC, DestTy), Name);
2311 return Insert(CastInst::CreatePointerCast(V, DestTy), Name);
2312 }
2313
2314 // With opaque pointers enabled, this can be substituted with
2315 // CreateAddrSpaceCast.
2316 // TODO: Replace uses of this method and remove the method itself.
2318 const Twine &Name = "") {
2319 if (V->getType() == DestTy)
2320 return V;
2321
2322 if (auto *VC = dyn_cast<Constant>(V)) {
2323 return Insert(Folder.CreatePointerBitCastOrAddrSpaceCast(VC, DestTy),
2324 Name);
2325 }
2326
2328 Name);
2329 }
2330
2332 const Twine &Name = "") {
2333 Instruction::CastOps CastOp =
2334 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2335 ? Instruction::Trunc
2336 : (isSigned ? Instruction::SExt : Instruction::ZExt);
2337 return CreateCast(CastOp, V, DestTy, Name);
2338 }
2339
2341 const Twine &Name = "") {
2342 if (V->getType() == DestTy)
2343 return V;
2344 if (V->getType()->isPtrOrPtrVectorTy() && DestTy->isIntOrIntVectorTy())
2345 return CreatePtrToInt(V, DestTy, Name);
2346 if (V->getType()->isIntOrIntVectorTy() && DestTy->isPtrOrPtrVectorTy())
2347 return CreateIntToPtr(V, DestTy, Name);
2348
2349 return CreateBitCast(V, DestTy, Name);
2350 }
2351
2352 Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "",
2353 MDNode *FPMathTag = nullptr) {
2354 Instruction::CastOps CastOp =
2355 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2356 ? Instruction::FPTrunc
2357 : Instruction::FPExt;
2358 return CreateCast(CastOp, V, DestTy, Name, FPMathTag);
2359 }
2360
2362 Intrinsic::ID ID, Value *V, Type *DestTy, FMFSource FMFSource = {},
2363 const Twine &Name = "", MDNode *FPMathTag = nullptr,
2364 std::optional<RoundingMode> Rounding = std::nullopt,
2365 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2366
2367 // Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
2368 // compile time error, instead of converting the string to bool for the
2369 // isSigned parameter.
2370 Value *CreateIntCast(Value *, Type *, const char *) = delete;
2371
2372 /// Cast between aggregate types that must have identical structure but may
2373 /// differ in their leaf types. The leaf values are recursively extracted,
2374 /// casted, and then reinserted into a value of type DestTy. The leaf types
2375 /// must be castable using a bitcast or ptrcast, because signedness is
2376 /// not specified.
2378
2379 /// Create a chain of casts to convert V to NewTy, preserving the bit pattern
2380 /// of V. This may involve multiple casts (e.g., ptr -> i64 -> <2 x i32>).
2381 /// The created cast instructions are inserted into the current basic block.
2382 /// If no casts are needed, V is returned.
2384 Type *NewTy);
2385
2386 //===--------------------------------------------------------------------===//
2387 // Instruction creation methods: Compare Instructions
2388 //===--------------------------------------------------------------------===//
2389
2390 Value *CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name = "") {
2391 return CreateICmp(ICmpInst::ICMP_EQ, LHS, RHS, Name);
2392 }
2393
2394 Value *CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name = "") {
2395 return CreateICmp(ICmpInst::ICMP_NE, LHS, RHS, Name);
2396 }
2397
2398 Value *CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name = "") {
2399 return CreateICmp(ICmpInst::ICMP_UGT, LHS, RHS, Name);
2400 }
2401
2402 Value *CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name = "") {
2403 return CreateICmp(ICmpInst::ICMP_UGE, LHS, RHS, Name);
2404 }
2405
2406 Value *CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name = "") {
2407 return CreateICmp(ICmpInst::ICMP_ULT, LHS, RHS, Name);
2408 }
2409
2410 Value *CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name = "") {
2411 return CreateICmp(ICmpInst::ICMP_ULE, LHS, RHS, Name);
2412 }
2413
2414 Value *CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name = "") {
2415 return CreateICmp(ICmpInst::ICMP_SGT, LHS, RHS, Name);
2416 }
2417
2418 Value *CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name = "") {
2419 return CreateICmp(ICmpInst::ICMP_SGE, LHS, RHS, Name);
2420 }
2421
2422 Value *CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name = "") {
2423 return CreateICmp(ICmpInst::ICMP_SLT, LHS, RHS, Name);
2424 }
2425
2426 Value *CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name = "") {
2427 return CreateICmp(ICmpInst::ICMP_SLE, LHS, RHS, Name);
2428 }
2429
2430 Value *CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name = "",
2431 MDNode *FPMathTag = nullptr) {
2432 return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name, FPMathTag);
2433 }
2434
2435 Value *CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name = "",
2436 MDNode *FPMathTag = nullptr) {
2437 return CreateFCmp(FCmpInst::FCMP_OGT, LHS, RHS, Name, FPMathTag);
2438 }
2439
2440 Value *CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name = "",
2441 MDNode *FPMathTag = nullptr) {
2442 return CreateFCmp(FCmpInst::FCMP_OGE, LHS, RHS, Name, FPMathTag);
2443 }
2444
2445 Value *CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name = "",
2446 MDNode *FPMathTag = nullptr) {
2447 return CreateFCmp(FCmpInst::FCMP_OLT, LHS, RHS, Name, FPMathTag);
2448 }
2449
2450 Value *CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name = "",
2451 MDNode *FPMathTag = nullptr) {
2452 return CreateFCmp(FCmpInst::FCMP_OLE, LHS, RHS, Name, FPMathTag);
2453 }
2454
2455 Value *CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name = "",
2456 MDNode *FPMathTag = nullptr) {
2457 return CreateFCmp(FCmpInst::FCMP_ONE, LHS, RHS, Name, FPMathTag);
2458 }
2459
2460 Value *CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name = "",
2461 MDNode *FPMathTag = nullptr) {
2462 return CreateFCmp(FCmpInst::FCMP_ORD, LHS, RHS, Name, FPMathTag);
2463 }
2464
2465 Value *CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name = "",
2466 MDNode *FPMathTag = nullptr) {
2467 return CreateFCmp(FCmpInst::FCMP_UNO, LHS, RHS, Name, FPMathTag);
2468 }
2469
2470 Value *CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name = "",
2471 MDNode *FPMathTag = nullptr) {
2472 return CreateFCmp(FCmpInst::FCMP_UEQ, LHS, RHS, Name, FPMathTag);
2473 }
2474
2475 Value *CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name = "",
2476 MDNode *FPMathTag = nullptr) {
2477 return CreateFCmp(FCmpInst::FCMP_UGT, LHS, RHS, Name, FPMathTag);
2478 }
2479
2480 Value *CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name = "",
2481 MDNode *FPMathTag = nullptr) {
2482 return CreateFCmp(FCmpInst::FCMP_UGE, LHS, RHS, Name, FPMathTag);
2483 }
2484
2485 Value *CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name = "",
2486 MDNode *FPMathTag = nullptr) {
2487 return CreateFCmp(FCmpInst::FCMP_ULT, LHS, RHS, Name, FPMathTag);
2488 }
2489
2490 Value *CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name = "",
2491 MDNode *FPMathTag = nullptr) {
2492 return CreateFCmp(FCmpInst::FCMP_ULE, LHS, RHS, Name, FPMathTag);
2493 }
2494
2495 Value *CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name = "",
2496 MDNode *FPMathTag = nullptr) {
2497 return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name, FPMathTag);
2498 }
2499
2501 const Twine &Name = "") {
2502 if (auto *V = Folder.FoldCmp(P, LHS, RHS))
2503 return V;
2504 return Insert(new ICmpInst(P, LHS, RHS), Name);
2505 }
2506
2507 // Create a quiet floating-point comparison (i.e. one that raises an FP
2508 // exception only in the case where an input is a signaling NaN).
2509 // Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2511 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2512 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, {}, false);
2513 }
2514
2515 // Create a quiet floating-point comparison (i.e. one that raises an FP
2516 // exception only in the case where an input is a signaling NaN).
2517 // Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2519 FMFSource FMFSource, const Twine &Name = "",
2520 MDNode *FPMathTag = nullptr) {
2521 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, FMFSource, false);
2522 }
2523
2525 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2526 return CmpInst::isFPPredicate(Pred)
2527 ? CreateFCmp(Pred, LHS, RHS, Name, FPMathTag)
2528 : CreateICmp(Pred, LHS, RHS, Name);
2529 }
2530
2531 // Create a signaling floating-point comparison (i.e. one that raises an FP
2532 // exception whenever an input is any NaN, signaling or quiet).
2533 // Note that this differs from CreateFCmp only if IsFPConstrained is true.
2535 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2536 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, {}, true);
2537 }
2538
2539private:
2540 // Helper routine to create either a signaling or a quiet FP comparison.
2541 LLVM_ABI Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS,
2542 const Twine &Name, MDNode *FPMathTag,
2543 FMFSource FMFSource, bool IsSignaling);
2544
2545public:
2548 const Twine &Name = "",
2549 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2550
2551 //===--------------------------------------------------------------------===//
2552 // Instruction creation methods: Other Instructions
2553 //===--------------------------------------------------------------------===//
2554
2555 PHINode *CreatePHI(Type *Ty, unsigned NumReservedValues,
2556 const Twine &Name = "") {
2557 PHINode *Phi = PHINode::Create(Ty, NumReservedValues);
2558 if (isa<FPMathOperator>(Phi))
2559 setFPAttrs(Phi, nullptr /* MDNode* */, FMF);
2560 return Insert(Phi, Name);
2561 }
2562
2563private:
2564 CallInst *createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
2565 const Twine &Name = "", FMFSource FMFSource = {},
2566 ArrayRef<OperandBundleDef> OpBundles = {});
2567
2568public:
2570 ArrayRef<Value *> Args = {}, const Twine &Name = "",
2571 MDNode *FPMathTag = nullptr) {
2572 CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
2573 if (IsFPConstrained)
2575 if (isa<FPMathOperator>(CI))
2576 setFPAttrs(CI, FPMathTag, FMF);
2577 return Insert(CI, Name);
2578 }
2579
2581 FMFSource FMFSource, const Twine &Name = "",
2582 MDNode *FPMathTag = nullptr) {
2583 return CreateCall(FTy, Callee, Args, DefaultOperandBundles, FMFSource, Name,
2584 FPMathTag);
2585 }
2586
2589 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2590 CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
2591 if (IsFPConstrained)
2593 if (isa<FPMathOperator>(CI))
2594 setFPAttrs(CI, FPMathTag, FMF);
2595 return Insert(CI, Name);
2596 }
2597
2600 FMFSource FMFSource, const Twine &Name = "",
2601 MDNode *FPMathTag = nullptr) {
2602 CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
2603 if (IsFPConstrained)
2605 if (isa<FPMathOperator>(CI))
2606 setFPAttrs(CI, FPMathTag, FMFSource.get(FMF));
2607 return Insert(CI, Name);
2608 }
2609
2611 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2612 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args, Name,
2613 FPMathTag);
2614 }
2615
2617 FMFSource FMFSource, const Twine &Name = "",
2618 MDNode *FPMathTag = nullptr) {
2619 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2620 FMFSource, Name, FPMathTag);
2621 }
2622
2625 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2626 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2627 OpBundles, Name, FPMathTag);
2628 }
2629
2632 FMFSource FMFSource, const Twine &Name = "",
2633 MDNode *FPMathTag = nullptr) {
2634 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2635 OpBundles, FMFSource, Name, FPMathTag);
2636 }
2637
2639 Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "",
2640 std::optional<RoundingMode> Rounding = std::nullopt,
2641 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2642
2644 Value *False,
2646 const Twine &Name = "");
2647
2649 Value *False,
2652 const Twine &Name = "");
2653
2654 LLVM_ABI Value *CreateSelect(Value *C, Value *True, Value *False,
2655 const Twine &Name = "",
2656 Instruction *MDFrom = nullptr);
2657 LLVM_ABI Value *CreateSelectFMF(Value *C, Value *True, Value *False,
2658 FMFSource FMFSource, const Twine &Name = "",
2659 Instruction *MDFrom = nullptr);
2660
2661 VAArgInst *CreateVAArg(Value *List, Type *Ty, const Twine &Name = "") {
2662 return Insert(new VAArgInst(List, Ty), Name);
2663 }
2664
2666 const Twine &Name = "") {
2667 if (Value *V = Folder.FoldExtractElement(Vec, Idx))
2668 return V;
2669 return Insert(ExtractElementInst::Create(Vec, Idx), Name);
2670 }
2671
2673 const Twine &Name = "") {
2674 return CreateExtractElement(Vec, getInt64(Idx), Name);
2675 }
2676
2677 Value *CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx,
2678 const Twine &Name = "") {
2679 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2680 }
2681
2683 const Twine &Name = "") {
2684 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2685 }
2686
2688 const Twine &Name = "") {
2689 if (Value *V = Folder.FoldInsertElement(Vec, NewElt, Idx))
2690 return V;
2691 return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
2692 }
2693
2695 const Twine &Name = "") {
2696 return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
2697 }
2698
2700 const Twine &Name = "") {
2701 SmallVector<int, 16> IntMask;
2703 return CreateShuffleVector(V1, V2, IntMask, Name);
2704 }
2705
2706 /// See class ShuffleVectorInst for a description of the mask representation.
2708 const Twine &Name = "") {
2709 if (Value *V = Folder.FoldShuffleVector(V1, V2, Mask))
2710 return V;
2711 return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
2712 }
2713
2714 /// Create a unary shuffle. The second vector operand of the IR instruction
2715 /// is poison.
2717 const Twine &Name = "") {
2718 return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name);
2719 }
2720
2722 const Twine &Name = "");
2723
2725 const Twine &Name = "") {
2726 if (auto *V = Folder.FoldExtractValue(Agg, Idxs))
2727 return V;
2728 return Insert(ExtractValueInst::Create(Agg, Idxs), Name);
2729 }
2730
2732 const Twine &Name = "") {
2733 if (auto *V = Folder.FoldInsertValue(Agg, Val, Idxs))
2734 return V;
2735 return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name);
2736 }
2737
2738 LandingPadInst *CreateLandingPad(Type *Ty, unsigned NumClauses,
2739 const Twine &Name = "") {
2740 return Insert(LandingPadInst::Create(Ty, NumClauses), Name);
2741 }
2742
2743 Value *CreateFreeze(Value *V, const Twine &Name = "") {
2744 return Insert(new FreezeInst(V), Name);
2745 }
2746
2747 //===--------------------------------------------------------------------===//
2748 // Utility creation methods
2749 //===--------------------------------------------------------------------===//
2750
2751 /// Return a boolean value testing if \p Arg == 0.
2752 Value *CreateIsNull(Value *Arg, const Twine &Name = "") {
2753 return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()), Name);
2754 }
2755
2756 /// Return a boolean value testing if \p Arg != 0.
2757 Value *CreateIsNotNull(Value *Arg, const Twine &Name = "") {
2758 return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()), Name);
2759 }
2760
2761 /// Return a boolean value testing if \p Arg < 0.
2762 Value *CreateIsNeg(Value *Arg, const Twine &Name = "") {
2763 return CreateICmpSLT(Arg, ConstantInt::getNullValue(Arg->getType()), Name);
2764 }
2765
2766 /// Return a boolean value testing if \p Arg > -1.
2767 Value *CreateIsNotNeg(Value *Arg, const Twine &Name = "") {
2769 Name);
2770 }
2771
2772 /// Return the difference between two pointer values. The returned value
2773 /// type is the address type of the pointers.
2774 LLVM_ABI Value *CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name = "",
2775 bool IsNUW = false);
2776
2777 /// Return the difference between two pointer values, dividing out the size
2778 /// of the pointed-to objects. The returned value type is the address type
2779 /// of the pointers.
2780 ///
2781 /// This is intended to implement C-style pointer subtraction. As such, the
2782 /// pointers must be appropriately aligned for their element types and
2783 /// pointing into the same object.
2785 const Twine &Name = "");
2786
2787 /// Create a launder.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 /// \brief Create a strip.invariant.group intrinsic call. If Ptr type is
2793 /// different from pointer to i8, it's casted to pointer to i8 in the same
2794 /// address space before call and casted back to Ptr type after call.
2796
2797 /// Return a vector value that contains the vector V reversed
2798 LLVM_ABI Value *CreateVectorReverse(Value *V, const Twine &Name = "");
2799
2800 /// Create a vector.splice.left intrinsic call, or a shufflevector that
2801 /// produces the same result if the result type is a fixed-length vector and
2802 /// \p Offset is a constant.
2804 const Twine &Name = "");
2805
2807 const Twine &Name = "") {
2808 return CreateVectorSpliceLeft(V1, V2, getInt32(Offset), Name);
2809 }
2810
2811 /// Create a vector.splice.right intrinsic call, or a shufflevector that
2812 /// produces the same result if the result type is a fixed-length vector and
2813 /// \p Offset is a constant.
2815 const Twine &Name = "");
2816
2818 const Twine &Name = "") {
2819 return CreateVectorSpliceRight(V1, V2, getInt32(Offset), Name);
2820 }
2821
2822 /// Return a vector value that contains \arg V broadcasted to \p
2823 /// NumElts elements.
2824 LLVM_ABI Value *CreateVectorSplat(unsigned NumElts, Value *V,
2825 const Twine &Name = "");
2826
2827 /// Return a vector value that contains \arg V broadcasted to \p
2828 /// EC elements.
2830 const Twine &Name = "");
2831
2833 unsigned Dimension,
2834 unsigned LastIndex,
2835 MDNode *DbgInfo);
2836
2838 unsigned FieldIndex,
2839 MDNode *DbgInfo);
2840
2842 unsigned Index,
2843 unsigned FieldIndex,
2844 MDNode *DbgInfo);
2845
2846 LLVM_ABI Value *createIsFPClass(Value *FPNum, unsigned Test);
2847
2848private:
2849 /// Helper function that creates an assume intrinsic call that
2850 /// represents an alignment assumption on the provided pointer \p PtrValue
2851 /// with offset \p OffsetValue and alignment value \p AlignValue.
2852 CallInst *CreateAlignmentAssumptionHelper(const DataLayout &DL,
2853 Value *PtrValue, Value *AlignValue,
2854 Value *OffsetValue);
2855
2856public:
2857 /// Create an assume intrinsic call that represents an alignment
2858 /// assumption on the provided pointer.
2859 ///
2860 /// An optional offset can be provided, and if it is provided, the offset
2861 /// must be subtracted from the provided pointer to get the pointer with the
2862 /// specified alignment.
2864 Value *PtrValue,
2865 uint64_t Alignment,
2866 Value *OffsetValue = nullptr);
2867
2868 /// Create an assume intrinsic call that represents an alignment
2869 /// assumption on the provided pointer.
2870 ///
2871 /// An optional offset can be provided, and if it is provided, the offset
2872 /// must be subtracted from the provided pointer to get the pointer with the
2873 /// specified alignment.
2874 ///
2875 /// This overload handles the condition where the Alignment is dependent
2876 /// on an existing value rather than a static value.
2878 Value *PtrValue,
2879 Value *Alignment,
2880 Value *OffsetValue = nullptr);
2881
2882 /// Create an assume intrinsic call that represents a dereferencable
2883 /// assumption on the provided pointer.
2885 Value *SizeValue);
2886
2887 /// Create an assume intrinsic call that represents a nonnull assumption on
2888 /// the provided pointer.
2890};
2891
2892/// This provides a uniform API for creating instructions and inserting
2893/// them into a basic block: either at the end of a BasicBlock, or at a specific
2894/// iterator location in a block.
2895///
2896/// Note that the builder does not expose the full generality of LLVM
2897/// instructions. For access to extra instruction properties, use the mutators
2898/// (e.g. setVolatile) on the instructions after they have been
2899/// created. Convenience state exists to specify fast-math flags and fp-math
2900/// tags.
2901///
2902/// The first template argument specifies a class to use for creating constants.
2903/// This defaults to creating minimally folded constants. The second template
2904/// argument allows clients to specify custom insertion hooks that are called on
2905/// every newly created insertion.
2906template <typename FolderTy = ConstantFolder,
2907 typename InserterTy = IRBuilderDefaultInserter>
2908class IRBuilder : public IRBuilderBase {
2909private:
2910 FolderTy Folder;
2911 InserterTy Inserter;
2912
2913public:
2914 IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter,
2915 MDNode *FPMathTag = nullptr,
2916 ArrayRef<OperandBundleDef> OpBundles = {})
2917 : IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles),
2919
2920 IRBuilder(LLVMContext &C, FolderTy Folder, MDNode *FPMathTag = nullptr,
2921 ArrayRef<OperandBundleDef> OpBundles = {})
2922 : IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles),
2923 Folder(Folder) {}
2924
2925 explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr,
2926 ArrayRef<OperandBundleDef> OpBundles = {})
2927 : IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles) {}
2928
2929 explicit IRBuilder(BasicBlock *TheBB, FolderTy Folder,
2930 MDNode *FPMathTag = nullptr,
2931 ArrayRef<OperandBundleDef> OpBundles = {})
2932 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2933 FPMathTag, OpBundles),
2934 Folder(Folder) {
2935 SetInsertPoint(TheBB);
2936 }
2937
2938 explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr,
2939 ArrayRef<OperandBundleDef> OpBundles = {})
2940 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2941 FPMathTag, OpBundles) {
2942 SetInsertPoint(TheBB);
2943 }
2944
2945 explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr,
2946 ArrayRef<OperandBundleDef> OpBundles = {})
2947 : IRBuilderBase(IP->getContext(), this->Folder, this->Inserter, FPMathTag,
2948 OpBundles) {
2949 SetInsertPoint(IP);
2950 }
2951
2952 IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder,
2953 MDNode *FPMathTag = nullptr,
2954 ArrayRef<OperandBundleDef> OpBundles = {})
2955 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2956 FPMathTag, OpBundles),
2957 Folder(Folder) {
2958 SetInsertPoint(TheBB, IP);
2959 }
2960
2962 MDNode *FPMathTag = nullptr,
2963 ArrayRef<OperandBundleDef> OpBundles = {})
2964 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2965 FPMathTag, OpBundles) {
2966 SetInsertPoint(TheBB, IP);
2967 }
2968
2969 /// Avoid copying the full IRBuilder. Prefer using InsertPointGuard
2970 /// or FastMathFlagGuard instead.
2971 IRBuilder(const IRBuilder &) = delete;
2972
2973 InserterTy &getInserter() { return Inserter; }
2974 const InserterTy &getInserter() const { return Inserter; }
2975};
2976
2977template <typename FolderTy, typename InserterTy>
2978IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *,
2981template <typename FolderTy>
2986template <typename FolderTy>
2991
2992
2993// Create wrappers for C Binding types (see CBindingWrapping.h).
2995
2996} // end namespace llvm
2997
2998#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
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
Value handle that asserts if the Value is deleted.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
iterator end()
Definition BasicBlock.h:459
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
static BinaryOperator * CreateDisjoint(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name="")
Definition InstrTypes.h:459
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:1503
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2268
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2455
Value * CreateLdexp(Value *Src, Value *Exp, FMFSource FMFSource={}, const Twine &Name="")
Create call to the ldexp intrinsic.
Definition IRBuilder.h:1092
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:1128
Value * CreateFCmpS(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2534
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:1477
CleanupPadInst * CreateCleanupPad(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &Name="")
Definition IRBuilder.h:1356
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:1668
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2406
Value * CreateFPTruncFMF(Value *V, Type *DestTy, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2214
Value * CreateConstGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition IRBuilder.h:2063
LLVM_ABI Value * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNull=false)
Definition IRBuilder.h:2256
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:2480
CallInst * CreateStructuredAlloca(Type *BaseType, const Twine &Name="")
Definition IRBuilder.h:1902
Value * CreateInsertElement(Type *VecTy, Value *NewElt, uint64_t Idx, const Twine &Name="")
Definition IRBuilder.h:2682
Value * CreateSRem(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1513
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const Twine &Name="")
Definition IRBuilder.h:1947
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const LoadStoreInstProperties &Props, const Twine &Name="")
Definition IRBuilder.h:1927
Value * CreateFSub(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1663
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:2510
CatchPadInst * CreateCatchPad(Value *ParentPad, ArrayRef< Value * > Args, const Twine &Name="")
Definition IRBuilder.h:1351
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:2677
Value * CreateVectorSpliceLeft(Value *V1, Value *V2, uint32_t Offset, const Twine &Name="")
Definition IRBuilder.h:2806
Value * CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1554
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID=SyncScope::System)
Definition IRBuilder.h:1976
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:2032
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
Definition IRBuilder.h:1887
void setDefaultOperandBundles(ArrayRef< OperandBundleDef > OpBundles)
Definition IRBuilder.h:354
CallInst * CreateStackSave(const Twine &Name="")
Create a call to llvm.stacksave.
Definition IRBuilder.h:1148
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition IRBuilder.h:1284
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:2731
Value * CreateAnd(ArrayRef< Value * > Ops)
Definition IRBuilder.h:1592
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:1257
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition IRBuilder.h:1584
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:2623
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:1701
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:1549
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:1922
Value * CreateLogicalOr(ArrayRef< Value * > Ops)
Definition IRBuilder.h:1808
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Definition IRBuilder.h:2665
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:2414
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:1942
Value * CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2460
Value * CreateStructuredGEP(Type *BaseType, Value *PtrBase, ArrayRef< Value * > Indices, const Twine &Name="")
Definition IRBuilder.h:2003
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:1756
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
Definition IRBuilder.h:2147
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:663
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:1224
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1644
UnreachableInst * CreateUnreachable()
Definition IRBuilder.h:1366
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:2209
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2305
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:2237
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:1720
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition IRBuilder.h:2724
Value * CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition IRBuilder.h:1588
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:1937
Value * Insert(Value *V, const Twine &Name="") const
Definition IRBuilder.h:157
LandingPadInst * CreateLandingPad(Type *Ty, unsigned NumClauses, const Twine &Name="")
Definition IRBuilder.h:2738
Value * CreateFPExtFMF(Value *V, Type *DestTy, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2229
Value * CreateMaximum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maximum intrinsic.
Definition IRBuilder.h:1068
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:2418
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:1262
LLVM_ABI CallInst * CreateMalloc(Type *IntPtrTy, Value *AllocSize, Value *ArraySize, ArrayRef< OperandBundleDef > OpB, Function *MallocF=nullptr, const Twine &Name="")
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2598
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:2175
Value * CreateVectorSpliceRight(Value *V1, Value *V2, uint32_t Offset, const Twine &Name="")
Definition IRBuilder.h:2817
Value * CreateConstGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition IRBuilder.h:2075
Value * CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2495
BasicBlock::iterator GetInsertPoint() const
Definition IRBuilder.h:176
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
Definition IRBuilder.h:2093
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
Definition IRBuilder.h:1969
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:1326
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:2141
Value * CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2276
Value * CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2475
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2246
Value * CreateFreeze(Value *V, const Twine &Name="")
Definition IRBuilder.h:2743
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2630
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:1210
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args={}, const Twine &Name="")
Create a callbr instruction.
Definition IRBuilder.h:1300
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:1540
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:1120
Value * CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition IRBuilder.h:2038
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:2100
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr, FMFSource FMFSource={})
Definition IRBuilder.h:2292
Value * CreateIsNotNeg(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg > -1.
Definition IRBuilder.h:2767
CatchReturnInst * CreateCatchRet(CatchPadInst *CatchPad, BasicBlock *BB)
Definition IRBuilder.h:1362
CleanupReturnInst * CreateCleanupRet(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB=nullptr)
Definition IRBuilder.h:1339
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
Definition IRBuilder.h:1200
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:1439
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:2189
Value * CreateVScale(Type *Ty, const Twine &Name="")
Create a call to llvm.vscale.<Ty>().
Definition IRBuilder.h:944
Value * CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1573
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:2445
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:2027
Value * CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1473
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:1610
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:2317
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:2716
Value * CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1568
Value * CreateUDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1481
Value * CreateFAbs(Value *V, FMFSource FMFSource={}, const Twine &Name="")
Create call to the fabs intrinsic.
Definition IRBuilder.h:1033
Value * CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2490
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:2394
Value * CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1443
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:2518
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Definition IRBuilder.h:2019
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:705
CatchSwitchInst * CreateCatchSwitch(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, const Twine &Name="")
Definition IRBuilder.h:1344
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:848
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:1866
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNSW=false)
Definition IRBuilder.h:1838
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const Twine &Name="")
Definition IRBuilder.h:1918
UncondBrInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
Definition IRBuilder.h:1218
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:1113
Value * CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition IRBuilder.h:1778
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:2694
Value * CreateShl(Value *LHS, uint64_t RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1534
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:2707
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:2450
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:1051
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2340
Value * CreateCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2524
Value * CreateLogicalOp(Instruction::BinaryOps Opc, Value *Cond1, Value *Cond2, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition IRBuilder.h:1793
const IRBuilderDefaultInserter & Inserter
Definition IRBuilder.h:124
Value * CreateFPCast(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2352
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2426
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Definition IRBuilder.h:2555
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:2587
CondBrInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, Instruction *MDSrc)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
Definition IRBuilder.h:1233
Value * CreateNot(Value *V, const Twine &Name="")
Definition IRBuilder.h:1862
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:1247
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2390
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:1745
Value * CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2470
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:1063
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:1162
Value * CreateIsNeg(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg < 0.
Definition IRBuilder.h:2762
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:1447
Value * CreateFMA(Value *Factor1, Value *Factor2, Value *Summand, FMFSource FMFSource={}, const Twine &Name="")
Create call to the fma intrinsic.
Definition IRBuilder.h:1100
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2251
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:1626
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:1085
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:2398
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:1914
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:1519
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:1025
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)
Definition IRBuilder.h:2129
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:2699
LLVMContext & getContext() const
Definition IRBuilder.h:177
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2430
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1578
FastMathFlags & getFastMathFlags()
Definition IRBuilder.h:291
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
Definition IRBuilder.h:1195
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:1079
Value * CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1456
Value * CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Definition IRBuilder.h:2054
Value * CreateConstInBoundsGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition IRBuilder.h:2084
Value * CreateMinNum(Value *LHS, Value *RHS, FMFSource FMFSource={}, const Twine &Name="")
Create call to the minnum intrinsic.
Definition IRBuilder.h:1039
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args={}, const Twine &Name="")
Definition IRBuilder.h:1292
LLVM_ABI Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Definition IRBuilder.h:1933
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:1430
Value * CreateExactBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool IsExact, const Twine &Name="")
Definition IRBuilder.h:1768
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2241
Value * CreateSDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition IRBuilder.h:1494
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:2661
Value * CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1490
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:2757
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:863
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2569
Value * CreateShl(Value *LHS, const APInt &RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition IRBuilder.h:1528
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:2115
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:1739
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
Definition IRBuilder.h:2687
Value * CreateConstInBoundsGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition IRBuilder.h:2069
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:1319
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:2422
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:1308
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:997
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2402
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:2331
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2465
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:2752
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Definition IRBuilder.h:677
Value * CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2435
CallInst * CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Definition IRBuilder.h:685
CallInst * CreateStackRestore(Value *Ptr, const Twine &Name="")
Create a call to llvm.stackrestore.
Definition IRBuilder.h:1156
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:1273
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:1618
Value * CreateFAddFMF(Value *L, Value *R, FMFSource FMFSource, const Twine &Name="", MDNode *FPMD=nullptr)
Definition IRBuilder.h:1649
Value * CreateLogicalOr(Value *Cond1, Value *Cond2, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition IRBuilder.h:1786
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="")
Definition IRBuilder.h:1894
Value * CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="", GEPNoWrapFlags NWFlags=GEPNoWrapFlags::none())
Definition IRBuilder.h:2044
Value * CreateExtractElement(Value *Vec, uint64_t Idx, const Twine &Name="")
Definition IRBuilder.h:2672
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)
Definition IRBuilder.h:1961
Value * CreateOr(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition IRBuilder.h:1614
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:1073
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:2105
Value * CreateIntCast(Value *, Type *, const char *)=delete
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2224
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:1559
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2610
Value * CreateFNegFMF(Value *V, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1852
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1630
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2616
Value * CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2284
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:2410
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2201
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:2500
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:1682
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, bool isVolatile, const Twine &Name="")
Definition IRBuilder.h:1952
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:1847
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:1600
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:1706
Value * CreateURem(Value *LHS, Value *RHS, const Twine &Name="")
Definition IRBuilder.h:1507
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:2162
ResumeInst * CreateResume(Value *Exn)
Definition IRBuilder.h:1335
Value * CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec, Value *Idx, const Twine &Name="")
Create a call to the vector.insert intrinsic.
Definition IRBuilder.h:1134
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:1687
Value * CreateXor(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition IRBuilder.h:1636
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:1464
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:1142
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:1725
Value * CreateXor(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition IRBuilder.h:1640
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:1989
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:1843
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:2440
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Definition IRBuilder.h:713
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:1460
Value * CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2485
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
Definition IRBuilder.h:2182
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition IRBuilder.h:2580
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:2908
IRBuilder(LLVMContext &C, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2925
IRBuilder(const IRBuilder &)=delete
Avoid copying the full IRBuilder.
IRBuilder(LLVMContext &C, FolderTy Folder, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2920
IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2914
InserterTy & getInserter()
Definition IRBuilder.h:2973
IRBuilder(Instruction *IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2945
IRBuilder(BasicBlock *TheBB, FolderTy Folder, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2929
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2952
const InserterTy & getInserter() const
Definition IRBuilder.h:2974
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2961
IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles={})
Definition IRBuilder.h:2938
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:1079
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:587
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:107
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Class to represent pointers.
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
Definition Type.cpp:887
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Resume the propagation of an exception.
static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)
Return a value (possibly void), from a function.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
This instruction constructs a fixed permutation of two input vectors.
ArrayRef< int > getShuffleMask() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Multiway switch.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI ByteType * getByte16Ty(LLVMContext &C)
Definition Type.cpp:287
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:300
static LLVM_ABI IntegerType * getInt128Ty(LLVMContext &C)
Definition Type.cpp:301
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:299
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition Type.h:258
static LLVM_ABI ByteType * getByte32Ty(LLVMContext &C)
Definition Type.cpp:288
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:272
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:297
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
Definition Type.cpp:298
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:222
static LLVM_ABI ByteType * getByte8Ty(LLVMContext &C)
Definition Type.cpp:286
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:296
static LLVM_ABI ByteType * getByte128Ty(LLVMContext &C)
Definition Type.cpp:290
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition Type.h:280
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:303
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:277
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:276
static LLVM_ABI ByteType * getByteNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:292
static LLVM_ABI ByteType * getByte64Ty(LLVMContext &C)
Definition Type.cpp:289
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
Definition Type.cpp:275
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:274
static LLVM_ABI UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
Unconditional Branch instruction.
static UncondBrInst * Create(BasicBlock *Target, InsertPosition InsertBefore=nullptr)
This function has undefined behavior.
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
Base class of all SIMD vector types.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
This class represents zero extension of integer types.
An efficient, type-erasing, non-owning reference to a callable.
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
Definition Types.h:110
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Rounding
Possible values of current rounding mode, which is specified in bits 23:22 of FPCR.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ System
Synchronized with respect to all concurrently executing threads.
Definition LLVMContext.h:58
ExceptionBehavior
Exception behavior used for floating point operations.
Definition FPEnv.h:39
@ ebStrict
This corresponds to "fpexcept.strict".
Definition FPEnv.h:42
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI std::optional< StringRef > convertRoundingModeToStr(RoundingMode)
For any RoundingMode enumerator, returns a string valid as input in constrained intrinsic rounding mo...
Definition FPEnv.cpp:39
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition STLExtras.h: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:772
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