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