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