LLVM 18.0.0git
IRBuilder.h
Go to the documentation of this file.
1//===- llvm/IRBuilder.h - Builder for LLVM Instructions ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the IRBuilder class, which is used as a convenient way
10// to create LLVM instructions with a consistent and simplified interface.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_IRBUILDER_H
15#define LLVM_IR_IRBUILDER_H
16
17#include "llvm-c/Types.h"
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/STLExtras.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/Twine.h"
22#include "llvm/IR/BasicBlock.h"
23#include "llvm/IR/Constant.h"
25#include "llvm/IR/Constants.h"
26#include "llvm/IR/DataLayout.h"
27#include "llvm/IR/DebugLoc.h"
29#include "llvm/IR/FPEnv.h"
30#include "llvm/IR/Function.h"
32#include "llvm/IR/InstrTypes.h"
33#include "llvm/IR/Instruction.h"
35#include "llvm/IR/Intrinsics.h"
36#include "llvm/IR/LLVMContext.h"
37#include "llvm/IR/Module.h"
38#include "llvm/IR/Operator.h"
39#include "llvm/IR/Type.h"
40#include "llvm/IR/Value.h"
41#include "llvm/IR/ValueHandle.h"
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 *BB,
67 BasicBlock::iterator InsertPt) const {
68 if (BB)
69 I->insertInto(BB, InsertPt);
70 I->setName(Name);
71 }
72};
73
74/// Provides an 'InsertHelper' that calls a user-provided callback after
75/// performing the default insertion.
77 std::function<void(Instruction *)> Callback;
78
79public:
81
82 IRBuilderCallbackInserter(std::function<void(Instruction *)> Callback)
83 : Callback(std::move(Callback)) {}
84
86 BasicBlock *BB,
87 BasicBlock::iterator InsertPt) const override {
89 Callback(I);
90 }
91};
92
93/// Common base class shared among various IRBuilders.
95 /// Pairs of (metadata kind, MDNode *) that should be added to all newly
96 /// created instructions, like !dbg metadata.
98
99 /// Add or update the an entry (Kind, MD) to MetadataToCopy, if \p MD is not
100 /// null. If \p MD is null, remove the entry with \p Kind.
101 void AddOrRemoveMetadataToCopy(unsigned Kind, MDNode *MD) {
102 if (!MD) {
103 erase_if(MetadataToCopy, [Kind](const std::pair<unsigned, MDNode *> &KV) {
104 return KV.first == Kind;
105 });
106 return;
107 }
108
109 for (auto &KV : MetadataToCopy)
110 if (KV.first == Kind) {
111 KV.second = MD;
112 return;
113 }
114
115 MetadataToCopy.emplace_back(Kind, MD);
116 }
117
118protected:
124
127
128 bool IsFPConstrained = false;
131
133
134public:
136 const IRBuilderDefaultInserter &Inserter, MDNode *FPMathTag,
138 : Context(context), Folder(Folder), Inserter(Inserter),
139 DefaultFPMathTag(FPMathTag), DefaultOperandBundles(OpBundles) {
141 }
142
143 /// Insert and return the specified instruction.
144 template<typename InstTy>
145 InstTy *Insert(InstTy *I, const Twine &Name = "") const {
148 return I;
149 }
150
151 /// No-op overload to handle constants.
152 Constant *Insert(Constant *C, const Twine& = "") const {
153 return C;
154 }
155
156 Value *Insert(Value *V, const Twine &Name = "") const {
157 if (Instruction *I = dyn_cast<Instruction>(V))
158 return Insert(I, Name);
159 assert(isa<Constant>(V));
160 return V;
161 }
162
163 //===--------------------------------------------------------------------===//
164 // Builder configuration methods
165 //===--------------------------------------------------------------------===//
166
167 /// Clear the insertion point: created instructions will not be
168 /// inserted into a block.
170 BB = nullptr;
172 }
173
174 BasicBlock *GetInsertBlock() const { return BB; }
176 LLVMContext &getContext() const { return Context; }
177
178 /// This specifies that created instructions should be appended to the
179 /// end of the specified block.
181 BB = TheBB;
182 InsertPt = BB->end();
183 }
184
185 /// This specifies that created instructions should be inserted before
186 /// the specified instruction.
188 BB = I->getParent();
189 InsertPt = I->getIterator();
190 assert(InsertPt != BB->end() && "Can't read debug loc from end()");
191 SetCurrentDebugLocation(I->getStableDebugLoc());
192 }
193
194 /// This specifies that created instructions should be inserted at the
195 /// specified point.
197 BB = TheBB;
198 InsertPt = IP;
199 if (IP != TheBB->end())
200 SetCurrentDebugLocation(IP->getStableDebugLoc());
201 }
202
203 /// This specifies that created instructions should inserted at the beginning
204 /// end of the specified function, but after already existing static alloca
205 /// instructions that are at the start.
207 BB = &F->getEntryBlock();
209 }
210
211 /// Set location information used by debugging information.
213 AddOrRemoveMetadataToCopy(LLVMContext::MD_dbg, L.getAsMDNode());
214 }
215
216 /// Collect metadata with IDs \p MetadataKinds from \p Src which should be
217 /// added to all created instructions. Entries present in MedataDataToCopy but
218 /// not on \p Src will be dropped from MetadataToCopy.
220 ArrayRef<unsigned> MetadataKinds) {
221 for (unsigned K : MetadataKinds)
222 AddOrRemoveMetadataToCopy(K, Src->getMetadata(K));
223 }
224
225 /// Get location information used by debugging information.
227
228 /// If this builder has a current debug location, set it on the
229 /// specified instruction.
231
232 /// Add all entries in MetadataToCopy to \p I.
234 for (const auto &KV : MetadataToCopy)
235 I->setMetadata(KV.first, KV.second);
236 }
237
238 /// Get the return type of the current function that we're emitting
239 /// into.
241
242 /// InsertPoint - A saved insertion point.
244 BasicBlock *Block = nullptr;
246
247 public:
248 /// Creates a new insertion point which doesn't point to anything.
249 InsertPoint() = default;
250
251 /// Creates a new insertion point at the given location.
253 : Block(InsertBlock), Point(InsertPoint) {}
254
255 /// Returns true if this insert point is set.
256 bool isSet() const { return (Block != nullptr); }
257
258 BasicBlock *getBlock() const { return Block; }
259 BasicBlock::iterator getPoint() const { return Point; }
260 };
261
262 /// Returns the current insert point.
265 }
266
267 /// Returns the current insert point, clearing it in the process.
271 return IP;
272 }
273
274 /// Sets the current insert point to a previously-saved location.
276 if (IP.isSet())
277 SetInsertPoint(IP.getBlock(), IP.getPoint());
278 else
280 }
281
282 /// Get the floating point math metadata being used.
284
285 /// Get the flags to be applied to created floating point ops
287
289
290 /// Clear the fast-math flags.
292
293 /// Set the floating point math metadata to be used.
294 void setDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; }
295
296 /// Set the fast-math flags to be used with generated fp-math operators
297 void setFastMathFlags(FastMathFlags NewFMF) { FMF = NewFMF; }
298
299 /// Enable/Disable use of constrained floating point math. When
300 /// enabled the CreateF<op>() calls instead create constrained
301 /// floating point intrinsic calls. Fast math flags are unaffected
302 /// by this setting.
303 void setIsFPConstrained(bool IsCon) { IsFPConstrained = IsCon; }
304
305 /// Query for the use of constrained floating point math
307
308 /// Set the exception handling to be used with constrained floating point
310#ifndef NDEBUG
311 std::optional<StringRef> ExceptStr =
313 assert(ExceptStr && "Garbage strict exception behavior!");
314#endif
315 DefaultConstrainedExcept = NewExcept;
316 }
317
318 /// Set the rounding mode handling to be used with constrained floating point
320#ifndef NDEBUG
321 std::optional<StringRef> RoundingStr =
322 convertRoundingModeToStr(NewRounding);
323 assert(RoundingStr && "Garbage strict rounding mode!");
324#endif
325 DefaultConstrainedRounding = NewRounding;
326 }
327
328 /// Get the exception handling used with constrained floating point
331 }
332
333 /// Get the rounding mode handling used with constrained floating point
336 }
337
339 assert(BB && "Must have a basic block to set any function attributes!");
340
341 Function *F = BB->getParent();
342 if (!F->hasFnAttribute(Attribute::StrictFP)) {
343 F->addFnAttr(Attribute::StrictFP);
344 }
345 }
346
348 I->addFnAttr(Attribute::StrictFP);
349 }
350
352 DefaultOperandBundles = OpBundles;
353 }
354
355 //===--------------------------------------------------------------------===//
356 // RAII helpers.
357 //===--------------------------------------------------------------------===//
358
359 // RAII object that stores the current insertion point and restores it
360 // when the object is destroyed. This includes the debug location.
362 IRBuilderBase &Builder;
365 DebugLoc DbgLoc;
366
367 public:
369 : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
370 DbgLoc(B.getCurrentDebugLocation()) {}
371
374
376 Builder.restoreIP(InsertPoint(Block, Point));
377 Builder.SetCurrentDebugLocation(DbgLoc);
378 }
379 };
380
381 // RAII object that stores the current fast math settings and restores
382 // them when the object is destroyed.
384 IRBuilderBase &Builder;
385 FastMathFlags FMF;
386 MDNode *FPMathTag;
387 bool IsFPConstrained;
388 fp::ExceptionBehavior DefaultConstrainedExcept;
389 RoundingMode DefaultConstrainedRounding;
390
391 public:
393 : Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag),
394 IsFPConstrained(B.IsFPConstrained),
395 DefaultConstrainedExcept(B.DefaultConstrainedExcept),
396 DefaultConstrainedRounding(B.DefaultConstrainedRounding) {}
397
400
402 Builder.FMF = FMF;
403 Builder.DefaultFPMathTag = FPMathTag;
404 Builder.IsFPConstrained = IsFPConstrained;
405 Builder.DefaultConstrainedExcept = DefaultConstrainedExcept;
406 Builder.DefaultConstrainedRounding = DefaultConstrainedRounding;
407 }
408 };
409
410 // RAII object that stores the current default operand bundles and restores
411 // them when the object is destroyed.
413 IRBuilderBase &Builder;
414 ArrayRef<OperandBundleDef> DefaultOperandBundles;
415
416 public:
418 : Builder(B), DefaultOperandBundles(B.DefaultOperandBundles) {}
419
422
424 Builder.DefaultOperandBundles = DefaultOperandBundles;
425 }
426 };
427
428
429 //===--------------------------------------------------------------------===//
430 // Miscellaneous creation methods.
431 //===--------------------------------------------------------------------===//
432
433 /// Make a new global variable with initializer type i8*
434 ///
435 /// Make a new global variable with an initializer that has array of i8 type
436 /// filled in with the null terminated string value specified. The new global
437 /// variable will be marked mergable with any others of the same contents. If
438 /// Name is specified, it is the name of the global variable created.
439 ///
440 /// If no module is given via \p M, it is take from the insertion point basic
441 /// block.
443 unsigned AddressSpace = 0,
444 Module *M = nullptr);
445
446 /// Get a constant value representing either true or false.
448 return ConstantInt::get(getInt1Ty(), V);
449 }
450
451 /// Get the constant value for i1 true.
454 }
455
456 /// Get the constant value for i1 false.
459 }
460
461 /// Get a constant 8-bit value.
463 return ConstantInt::get(getInt8Ty(), C);
464 }
465
466 /// Get a constant 16-bit value.
468 return ConstantInt::get(getInt16Ty(), C);
469 }
470
471 /// Get a constant 32-bit value.
473 return ConstantInt::get(getInt32Ty(), C);
474 }
475
476 /// Get a constant 64-bit value.
478 return ConstantInt::get(getInt64Ty(), C);
479 }
480
481 /// Get a constant N-bit value, zero extended or truncated from
482 /// a 64-bit value.
484 return ConstantInt::get(getIntNTy(N), C);
485 }
486
487 /// Get a constant integer value.
489 return ConstantInt::get(Context, AI);
490 }
491
492 //===--------------------------------------------------------------------===//
493 // Type creation methods
494 //===--------------------------------------------------------------------===//
495
496 /// Fetch the type representing a single bit
498 return Type::getInt1Ty(Context);
499 }
500
501 /// Fetch the type representing an 8-bit integer.
503 return Type::getInt8Ty(Context);
504 }
505
506 /// Fetch the type representing a 16-bit integer.
509 }
510
511 /// Fetch the type representing a 32-bit integer.
514 }
515
516 /// Fetch the type representing a 64-bit integer.
519 }
520
521 /// Fetch the type representing a 128-bit integer.
523
524 /// Fetch the type representing an N-bit integer.
526 return Type::getIntNTy(Context, N);
527 }
528
529 /// Fetch the type representing a 16-bit floating point value.
531 return Type::getHalfTy(Context);
532 }
533
534 /// Fetch the type representing a 16-bit brain floating point value.
537 }
538
539 /// Fetch the type representing a 32-bit floating point value.
542 }
543
544 /// Fetch the type representing a 64-bit floating point value.
547 }
548
549 /// Fetch the type representing void.
551 return Type::getVoidTy(Context);
552 }
553
554 /// Fetch the type representing a pointer.
555 PointerType *getPtrTy(unsigned AddrSpace = 0) {
556 return PointerType::get(Context, AddrSpace);
557 }
558
559 /// Fetch the type representing a pointer to an 8-bit integer value.
560 PointerType *getInt8PtrTy(unsigned AddrSpace = 0) {
561 return getPtrTy(AddrSpace);
562 }
563
564 /// Fetch the type of an integer with size at least as big as that of a
565 /// pointer in the given address space.
566 IntegerType *getIntPtrTy(const DataLayout &DL, unsigned AddrSpace = 0) {
567 return DL.getIntPtrType(Context, AddrSpace);
568 }
569
570 /// Fetch the type of an integer that should be used to index GEP operations
571 /// within AddressSpace.
572 IntegerType *getIndexTy(const DataLayout &DL, unsigned AddrSpace) {
573 return DL.getIndexType(Context, AddrSpace);
574 }
575
576 //===--------------------------------------------------------------------===//
577 // Intrinsic creation methods
578 //===--------------------------------------------------------------------===//
579
580 /// Create and insert a memset to the specified pointer and the
581 /// specified value.
582 ///
583 /// If the pointer isn't an i8*, it will be converted. If a TBAA tag is
584 /// specified, it will be added to the instruction. Likewise with alias.scope
585 /// and noalias tags.
587 MaybeAlign Align, bool isVolatile = false,
588 MDNode *TBAATag = nullptr, MDNode *ScopeTag = nullptr,
589 MDNode *NoAliasTag = nullptr) {
590 return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile,
591 TBAATag, ScopeTag, NoAliasTag);
592 }
593
595 bool isVolatile = false, MDNode *TBAATag = nullptr,
596 MDNode *ScopeTag = nullptr,
597 MDNode *NoAliasTag = nullptr);
598
599 CallInst *CreateMemSetInline(Value *Dst, MaybeAlign DstAlign, Value *Val,
600 Value *Size, bool IsVolatile = false,
601 MDNode *TBAATag = nullptr,
602 MDNode *ScopeTag = nullptr,
603 MDNode *NoAliasTag = nullptr);
604
605 /// Create and insert an element unordered-atomic memset of the region of
606 /// memory starting at the given pointer to the given value.
607 ///
608 /// If the pointer isn't an i8*, it will be converted. If a TBAA tag is
609 /// specified, it will be added to the instruction. Likewise with alias.scope
610 /// and noalias tags.
612 uint64_t Size, Align Alignment,
613 uint32_t ElementSize,
614 MDNode *TBAATag = nullptr,
615 MDNode *ScopeTag = nullptr,
616 MDNode *NoAliasTag = nullptr) {
618 Align(Alignment), ElementSize,
619 TBAATag, ScopeTag, NoAliasTag);
620 }
621
622 CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy, Value *AllocSize,
623 Value *ArraySize, ArrayRef<OperandBundleDef> OpB,
624 Function *MallocF = nullptr, const Twine &Name = "");
625
626 /// CreateMalloc - Generate the IR for a call to malloc:
627 /// 1. Compute the malloc call's argument as the specified type's size,
628 /// possibly multiplied by the array size if the array size is not
629 /// constant 1.
630 /// 2. Call malloc with that argument.
631 CallInst *CreateMalloc(Type *IntPtrTy, Type *AllocTy, Value *AllocSize,
632 Value *ArraySize, Function *MallocF = nullptr,
633 const Twine &Name = "");
634 /// Generate the IR for a call to the builtin free function.
635 CallInst *CreateFree(Value *Source,
636 ArrayRef<OperandBundleDef> Bundles = std::nullopt);
637
639 Value *Size, Align Alignment,
640 uint32_t ElementSize,
641 MDNode *TBAATag = nullptr,
642 MDNode *ScopeTag = nullptr,
643 MDNode *NoAliasTag = nullptr);
644
645 /// Create and insert a memcpy between the specified pointers.
646 ///
647 /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
648 /// specified, it will be added to the instruction. Likewise with alias.scope
649 /// and noalias tags.
651 MaybeAlign SrcAlign, uint64_t Size,
652 bool isVolatile = false, MDNode *TBAATag = nullptr,
653 MDNode *TBAAStructTag = nullptr,
654 MDNode *ScopeTag = nullptr,
655 MDNode *NoAliasTag = nullptr) {
656 return CreateMemCpy(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
657 isVolatile, TBAATag, TBAAStructTag, ScopeTag,
658 NoAliasTag);
659 }
660
662 Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src,
663 MaybeAlign SrcAlign, Value *Size, bool isVolatile = false,
664 MDNode *TBAATag = nullptr, MDNode *TBAAStructTag = nullptr,
665 MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr);
666
668 MaybeAlign SrcAlign, Value *Size,
669 bool isVolatile = false, MDNode *TBAATag = nullptr,
670 MDNode *TBAAStructTag = nullptr,
671 MDNode *ScopeTag = nullptr,
672 MDNode *NoAliasTag = nullptr) {
673 return CreateMemTransferInst(Intrinsic::memcpy, Dst, DstAlign, Src,
674 SrcAlign, Size, isVolatile, TBAATag,
675 TBAAStructTag, ScopeTag, NoAliasTag);
676 }
677
678 CallInst *
680 MaybeAlign SrcAlign, Value *Size, bool isVolatile = false,
681 MDNode *TBAATag = nullptr, MDNode *TBAAStructTag = nullptr,
682 MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr) {
683 return CreateMemTransferInst(Intrinsic::memcpy_inline, Dst, DstAlign, Src,
684 SrcAlign, Size, isVolatile, TBAATag,
685 TBAAStructTag, ScopeTag, NoAliasTag);
686 }
687
688 /// Create and insert an element unordered-atomic memcpy between the
689 /// specified pointers.
690 ///
691 /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers, respectively.
692 ///
693 /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
694 /// specified, it will be added to the instruction. Likewise with alias.scope
695 /// and noalias tags.
697 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
698 uint32_t ElementSize, MDNode *TBAATag = nullptr,
699 MDNode *TBAAStructTag = nullptr, MDNode *ScopeTag = nullptr,
700 MDNode *NoAliasTag = nullptr);
701
703 MaybeAlign SrcAlign, uint64_t Size,
704 bool isVolatile = false, MDNode *TBAATag = nullptr,
705 MDNode *ScopeTag = nullptr,
706 MDNode *NoAliasTag = nullptr) {
707 return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size),
708 isVolatile, TBAATag, ScopeTag, NoAliasTag);
709 }
710
712 MaybeAlign SrcAlign, Value *Size,
713 bool isVolatile = false, MDNode *TBAATag = nullptr,
714 MDNode *ScopeTag = nullptr,
715 MDNode *NoAliasTag = nullptr) {
716 return CreateMemTransferInst(Intrinsic::memmove, Dst, DstAlign, Src,
717 SrcAlign, Size, isVolatile, TBAATag,
718 /*TBAAStructTag=*/nullptr, ScopeTag,
719 NoAliasTag);
720 }
721
722 /// \brief Create and insert an element unordered-atomic memmove between the
723 /// specified pointers.
724 ///
725 /// DstAlign/SrcAlign are the alignments of the Dst/Src pointers,
726 /// respectively.
727 ///
728 /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
729 /// specified, it will be added to the instruction. Likewise with alias.scope
730 /// and noalias tags.
732 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
733 uint32_t ElementSize, MDNode *TBAATag = nullptr,
734 MDNode *TBAAStructTag = nullptr, MDNode *ScopeTag = nullptr,
735 MDNode *NoAliasTag = nullptr);
736
737private:
738 CallInst *getReductionIntrinsic(Intrinsic::ID ID, Value *Src);
739
740public:
741 /// Create a sequential vector fadd reduction intrinsic of the source vector.
742 /// The first parameter is a scalar accumulator value. An unordered reduction
743 /// can be created by adding the reassoc fast-math flag to the resulting
744 /// sequential reduction.
746
747 /// Create a sequential vector fmul reduction intrinsic of the source vector.
748 /// The first parameter is a scalar accumulator value. An unordered reduction
749 /// can be created by adding the reassoc fast-math flag to the resulting
750 /// sequential reduction.
752
753 /// Create a vector int add reduction intrinsic of the source vector.
755
756 /// Create a vector int mul reduction intrinsic of the source vector.
758
759 /// Create a vector int AND reduction intrinsic of the source vector.
761
762 /// Create a vector int OR reduction intrinsic of the source vector.
764
765 /// Create a vector int XOR reduction intrinsic of the source vector.
767
768 /// Create a vector integer max reduction intrinsic of the source
769 /// vector.
770 CallInst *CreateIntMaxReduce(Value *Src, bool IsSigned = false);
771
772 /// Create a vector integer min reduction intrinsic of the source
773 /// vector.
774 CallInst *CreateIntMinReduce(Value *Src, bool IsSigned = false);
775
776 /// Create a vector float max reduction intrinsic of the source
777 /// vector.
779
780 /// Create a vector float min reduction intrinsic of the source
781 /// vector.
783
784 /// Create a vector float maximum reduction intrinsic of the source
785 /// vector. This variant follows the NaN and signed zero semantic of
786 /// llvm.maximum intrinsic.
788
789 /// Create a vector float minimum reduction intrinsic of the source
790 /// vector. This variant follows the NaN and signed zero semantic of
791 /// llvm.minimum intrinsic.
793
794 /// Create a lifetime.start intrinsic.
795 ///
796 /// If the pointer isn't i8* it will be converted.
798
799 /// Create a lifetime.end intrinsic.
800 ///
801 /// If the pointer isn't i8* it will be converted.
803
804 /// Create a call to invariant.start intrinsic.
805 ///
806 /// If the pointer isn't i8* it will be converted.
808
809 /// Create a call to llvm.threadlocal.address intrinsic.
811
812 /// Create a call to Masked Load intrinsic
813 CallInst *CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask,
814 Value *PassThru = nullptr, const Twine &Name = "");
815
816 /// Create a call to Masked Store intrinsic
817 CallInst *CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment,
818 Value *Mask);
819
820 /// Create a call to Masked Gather intrinsic
821 CallInst *CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment,
822 Value *Mask = nullptr, Value *PassThru = nullptr,
823 const Twine &Name = "");
824
825 /// Create a call to Masked Scatter intrinsic
826 CallInst *CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment,
827 Value *Mask = nullptr);
828
829 /// Create a call to Masked Expand Load intrinsic
830 CallInst *CreateMaskedExpandLoad(Type *Ty, Value *Ptr, Value *Mask = nullptr,
831 Value *PassThru = nullptr,
832 const Twine &Name = "");
833
834 /// Create a call to Masked Compress Store intrinsic
836 Value *Mask = nullptr);
837
838 /// Return an all true boolean vector (mask) with \p NumElts lanes.
841 return Constant::getAllOnesValue(VTy);
842 }
843
844 /// Create an assume intrinsic call that allows the optimizer to
845 /// assume that the provided condition will be true.
846 ///
847 /// The optional argument \p OpBundles specifies operand bundles that are
848 /// added to the call instruction.
849 CallInst *
851 ArrayRef<OperandBundleDef> OpBundles = std::nullopt);
852
853 /// Create a llvm.experimental.noalias.scope.decl intrinsic call.
857 MetadataAsValue::get(Context, ScopeTag));
858 }
859
860 /// Create a call to the experimental.gc.statepoint intrinsic to
861 /// start a new statepoint sequence.
863 FunctionCallee ActualCallee,
864 ArrayRef<Value *> CallArgs,
865 std::optional<ArrayRef<Value *>> DeoptArgs,
866 ArrayRef<Value *> GCArgs,
867 const Twine &Name = "");
868
869 /// Create a call to the experimental.gc.statepoint intrinsic to
870 /// start a new statepoint sequence.
872 FunctionCallee ActualCallee, uint32_t Flags,
873 ArrayRef<Value *> CallArgs,
874 std::optional<ArrayRef<Use>> TransitionArgs,
875 std::optional<ArrayRef<Use>> DeoptArgs,
876 ArrayRef<Value *> GCArgs,
877 const Twine &Name = "");
878
879 /// Conveninence function for the common case when CallArgs are filled
880 /// in using ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be
881 /// .get()'ed to get the Value pointer.
883 FunctionCallee ActualCallee,
884 ArrayRef<Use> CallArgs,
885 std::optional<ArrayRef<Value *>> DeoptArgs,
886 ArrayRef<Value *> GCArgs,
887 const Twine &Name = "");
888
889 /// Create an invoke to the experimental.gc.statepoint intrinsic to
890 /// start a new statepoint sequence.
891 InvokeInst *
893 FunctionCallee ActualInvokee, BasicBlock *NormalDest,
894 BasicBlock *UnwindDest, ArrayRef<Value *> InvokeArgs,
895 std::optional<ArrayRef<Value *>> DeoptArgs,
896 ArrayRef<Value *> GCArgs, const Twine &Name = "");
897
898 /// Create an invoke to the experimental.gc.statepoint intrinsic to
899 /// start a new statepoint sequence.
901 uint64_t ID, uint32_t NumPatchBytes, FunctionCallee ActualInvokee,
902 BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags,
903 ArrayRef<Value *> InvokeArgs, std::optional<ArrayRef<Use>> TransitionArgs,
904 std::optional<ArrayRef<Use>> DeoptArgs, ArrayRef<Value *> GCArgs,
905 const Twine &Name = "");
906
907 // Convenience function for the common case when CallArgs are filled in using
908 // ArrayRef(CS.arg_begin(), CS.arg_end()); Use needs to be .get()'ed to
909 // get the Value *.
910 InvokeInst *
912 FunctionCallee ActualInvokee, BasicBlock *NormalDest,
913 BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs,
914 std::optional<ArrayRef<Value *>> DeoptArgs,
915 ArrayRef<Value *> GCArgs, const Twine &Name = "");
916
917 /// Create a call to the experimental.gc.result intrinsic to extract
918 /// the result from a call wrapped in a statepoint.
920 Type *ResultType,
921 const Twine &Name = "");
922
923 /// Create a call to the experimental.gc.relocate intrinsics to
924 /// project the relocated value of one pointer from the statepoint.
926 int BaseOffset,
927 int DerivedOffset,
928 Type *ResultType,
929 const Twine &Name = "");
930
931 /// Create a call to the experimental.gc.pointer.base intrinsic to get the
932 /// base pointer for the specified derived pointer.
933 CallInst *CreateGCGetPointerBase(Value *DerivedPtr, const Twine &Name = "");
934
935 /// Create a call to the experimental.gc.get.pointer.offset intrinsic to get
936 /// the offset of the specified derived pointer from its base.
937 CallInst *CreateGCGetPointerOffset(Value *DerivedPtr, const Twine &Name = "");
938
939 /// Create a call to llvm.vscale, multiplied by \p Scaling. The type of VScale
940 /// will be the same type as that of \p Scaling.
941 Value *CreateVScale(Constant *Scaling, const Twine &Name = "");
942
943 /// Create an expression which evaluates to the number of elements in \p EC
944 /// at runtime.
946
947 /// Create an expression which evaluates to the number of units in \p Size
948 /// at runtime. This works for both units of bits and bytes.
950
951 /// Creates a vector of type \p DstType with the linear sequence <0, 1, ...>
952 Value *CreateStepVector(Type *DstType, const Twine &Name = "");
953
954 /// Create a call to intrinsic \p ID with 1 operand which is mangled on its
955 /// type.
957 Instruction *FMFSource = nullptr,
958 const Twine &Name = "");
959
960 /// Create a call to intrinsic \p ID with 2 operands which is mangled on the
961 /// first type.
963 Instruction *FMFSource = nullptr,
964 const Twine &Name = "");
965
966 /// Create a call to intrinsic \p ID with \p Args, mangled using \p Types. If
967 /// \p FMFSource is provided, copy fast-math-flags from that instruction to
968 /// the intrinsic.
971 Instruction *FMFSource = nullptr,
972 const Twine &Name = "");
973
974 /// Create a call to intrinsic \p ID with \p RetTy and \p Args. If
975 /// \p FMFSource is provided, copy fast-math-flags from that instruction to
976 /// the intrinsic.
979 Instruction *FMFSource = nullptr,
980 const Twine &Name = "");
981
982 /// Create call to the minnum intrinsic.
984 if (IsFPConstrained) {
986 Intrinsic::experimental_constrained_minnum, LHS, RHS, nullptr, Name);
987 }
988
989 return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, nullptr, Name);
990 }
991
992 /// Create call to the maxnum intrinsic.
994 if (IsFPConstrained) {
996 Intrinsic::experimental_constrained_maxnum, LHS, RHS, nullptr, Name);
997 }
998
999 return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, nullptr, Name);
1000 }
1001
1002 /// Create call to the minimum intrinsic.
1004 return CreateBinaryIntrinsic(Intrinsic::minimum, LHS, RHS, nullptr, Name);
1005 }
1006
1007 /// Create call to the maximum intrinsic.
1009 return CreateBinaryIntrinsic(Intrinsic::maximum, LHS, RHS, nullptr, Name);
1010 }
1011
1012 /// Create call to the copysign intrinsic.
1014 Instruction *FMFSource = nullptr,
1015 const Twine &Name = "") {
1016 return CreateBinaryIntrinsic(Intrinsic::copysign, LHS, RHS, FMFSource,
1017 Name);
1018 }
1019
1020 /// Create a call to the arithmetic_fence intrinsic.
1022 const Twine &Name = "") {
1023 return CreateIntrinsic(Intrinsic::arithmetic_fence, DstType, Val, nullptr,
1024 Name);
1025 }
1026
1027 /// Create a call to the vector.extract intrinsic.
1029 const Twine &Name = "") {
1030 return CreateIntrinsic(Intrinsic::vector_extract,
1031 {DstType, SrcVec->getType()}, {SrcVec, Idx}, nullptr,
1032 Name);
1033 }
1034
1035 /// Create a call to the vector.insert intrinsic.
1036 CallInst *CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec,
1037 Value *Idx, const Twine &Name = "") {
1038 return CreateIntrinsic(Intrinsic::vector_insert,
1039 {DstType, SubVec->getType()}, {SrcVec, SubVec, Idx},
1040 nullptr, Name);
1041 }
1042
1043 /// Create a call to llvm.stacksave
1045 const DataLayout &DL = BB->getModule()->getDataLayout();
1046 return CreateIntrinsic(Intrinsic::stacksave, {DL.getAllocaPtrType(Context)},
1047 {}, nullptr, Name);
1048 }
1049
1050 /// Create a call to llvm.stackrestore
1052 return CreateIntrinsic(Intrinsic::stackrestore, {Ptr->getType()}, {Ptr},
1053 nullptr, Name);
1054 }
1055
1056private:
1057 /// Create a call to a masked intrinsic with given Id.
1058 CallInst *CreateMaskedIntrinsic(Intrinsic::ID Id, ArrayRef<Value *> Ops,
1059 ArrayRef<Type *> OverloadedTypes,
1060 const Twine &Name = "");
1061
1062 //===--------------------------------------------------------------------===//
1063 // Instruction creation methods: Terminators
1064 //===--------------------------------------------------------------------===//
1065
1066private:
1067 /// Helper to add branch weight and unpredictable metadata onto an
1068 /// instruction.
1069 /// \returns The annotated instruction.
1070 template <typename InstTy>
1071 InstTy *addBranchMetadata(InstTy *I, MDNode *Weights, MDNode *Unpredictable) {
1072 if (Weights)
1073 I->setMetadata(LLVMContext::MD_prof, Weights);
1074 if (Unpredictable)
1075 I->setMetadata(LLVMContext::MD_unpredictable, Unpredictable);
1076 return I;
1077 }
1078
1079public:
1080 /// Create a 'ret void' instruction.
1083 }
1084
1085 /// Create a 'ret <val>' instruction.
1087 return Insert(ReturnInst::Create(Context, V));
1088 }
1089
1090 /// Create a sequence of N insertvalue instructions,
1091 /// with one Value from the retVals array each, that build a aggregate
1092 /// return value one value at a time, and a ret instruction to return
1093 /// the resulting aggregate value.
1094 ///
1095 /// This is a convenience function for code that uses aggregate return values
1096 /// as a vehicle for having multiple return values.
1097 ReturnInst *CreateAggregateRet(Value *const *retVals, unsigned N) {
1099 for (unsigned i = 0; i != N; ++i)
1100 V = CreateInsertValue(V, retVals[i], i, "mrv");
1101 return Insert(ReturnInst::Create(Context, V));
1102 }
1103
1104 /// Create an unconditional 'br label X' instruction.
1106 return Insert(BranchInst::Create(Dest));
1107 }
1108
1109 /// Create a conditional 'br Cond, TrueDest, FalseDest'
1110 /// instruction.
1112 MDNode *BranchWeights = nullptr,
1113 MDNode *Unpredictable = nullptr) {
1114 return Insert(addBranchMetadata(BranchInst::Create(True, False, Cond),
1115 BranchWeights, Unpredictable));
1116 }
1117
1118 /// Create a conditional 'br Cond, TrueDest, FalseDest'
1119 /// instruction. Copy branch meta data if available.
1121 Instruction *MDSrc) {
1122 BranchInst *Br = BranchInst::Create(True, False, Cond);
1123 if (MDSrc) {
1124 unsigned WL[4] = {LLVMContext::MD_prof, LLVMContext::MD_unpredictable,
1125 LLVMContext::MD_make_implicit, LLVMContext::MD_dbg};
1126 Br->copyMetadata(*MDSrc, WL);
1127 }
1128 return Insert(Br);
1129 }
1130
1131 /// Create a switch instruction with the specified value, default dest,
1132 /// and with a hint for the number of cases that will be added (for efficient
1133 /// allocation).
1134 SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10,
1135 MDNode *BranchWeights = nullptr,
1136 MDNode *Unpredictable = nullptr) {
1137 return Insert(addBranchMetadata(SwitchInst::Create(V, Dest, NumCases),
1138 BranchWeights, Unpredictable));
1139 }
1140
1141 /// Create an indirect branch instruction with the specified address
1142 /// operand, with an optional hint for the number of destinations that will be
1143 /// added (for efficient allocation).
1144 IndirectBrInst *CreateIndirectBr(Value *Addr, unsigned NumDests = 10) {
1145 return Insert(IndirectBrInst::Create(Addr, NumDests));
1146 }
1147
1148 /// Create an invoke instruction.
1150 BasicBlock *NormalDest, BasicBlock *UnwindDest,
1151 ArrayRef<Value *> Args,
1153 const Twine &Name = "") {
1154 InvokeInst *II =
1155 InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, OpBundles);
1156 if (IsFPConstrained)
1158 return Insert(II, Name);
1159 }
1161 BasicBlock *NormalDest, BasicBlock *UnwindDest,
1162 ArrayRef<Value *> Args = std::nullopt,
1163 const Twine &Name = "") {
1164 InvokeInst *II =
1165 InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
1166 if (IsFPConstrained)
1168 return Insert(II, Name);
1169 }
1170
1172 BasicBlock *UnwindDest, ArrayRef<Value *> Args,
1174 const Twine &Name = "") {
1175 return CreateInvoke(Callee.getFunctionType(), Callee.getCallee(),
1176 NormalDest, UnwindDest, Args, OpBundles, Name);
1177 }
1178
1180 BasicBlock *UnwindDest,
1181 ArrayRef<Value *> Args = std::nullopt,
1182 const Twine &Name = "") {
1183 return CreateInvoke(Callee.getFunctionType(), Callee.getCallee(),
1184 NormalDest, UnwindDest, Args, Name);
1185 }
1186
1187 /// \brief Create a callbr instruction.
1189 BasicBlock *DefaultDest,
1190 ArrayRef<BasicBlock *> IndirectDests,
1191 ArrayRef<Value *> Args = std::nullopt,
1192 const Twine &Name = "") {
1193 return Insert(CallBrInst::Create(Ty, Callee, DefaultDest, IndirectDests,
1194 Args), Name);
1195 }
1197 BasicBlock *DefaultDest,
1198 ArrayRef<BasicBlock *> IndirectDests,
1199 ArrayRef<Value *> Args,
1201 const Twine &Name = "") {
1202 return Insert(
1203 CallBrInst::Create(Ty, Callee, DefaultDest, IndirectDests, Args,
1204 OpBundles), Name);
1205 }
1206
1208 ArrayRef<BasicBlock *> IndirectDests,
1209 ArrayRef<Value *> Args = std::nullopt,
1210 const Twine &Name = "") {
1211 return CreateCallBr(Callee.getFunctionType(), Callee.getCallee(),
1212 DefaultDest, IndirectDests, Args, Name);
1213 }
1215 ArrayRef<BasicBlock *> IndirectDests,
1216 ArrayRef<Value *> Args,
1218 const Twine &Name = "") {
1219 return CreateCallBr(Callee.getFunctionType(), Callee.getCallee(),
1220 DefaultDest, IndirectDests, Args, Name);
1221 }
1222
1224 return Insert(ResumeInst::Create(Exn));
1225 }
1226
1228 BasicBlock *UnwindBB = nullptr) {
1229 return Insert(CleanupReturnInst::Create(CleanupPad, UnwindBB));
1230 }
1231
1233 unsigned NumHandlers,
1234 const Twine &Name = "") {
1235 return Insert(CatchSwitchInst::Create(ParentPad, UnwindBB, NumHandlers),
1236 Name);
1237 }
1238
1240 const Twine &Name = "") {
1241 return Insert(CatchPadInst::Create(ParentPad, Args), Name);
1242 }
1243
1245 ArrayRef<Value *> Args = std::nullopt,
1246 const Twine &Name = "") {
1247 return Insert(CleanupPadInst::Create(ParentPad, Args), Name);
1248 }
1249
1251 return Insert(CatchReturnInst::Create(CatchPad, BB));
1252 }
1253
1255 return Insert(new UnreachableInst(Context));
1256 }
1257
1258 //===--------------------------------------------------------------------===//
1259 // Instruction creation methods: Binary Operators
1260 //===--------------------------------------------------------------------===//
1261private:
1262 BinaryOperator *CreateInsertNUWNSWBinOp(BinaryOperator::BinaryOps Opc,
1263 Value *LHS, Value *RHS,
1264 const Twine &Name,
1265 bool HasNUW, bool HasNSW) {
1267 if (HasNUW) BO->setHasNoUnsignedWrap();
1268 if (HasNSW) BO->setHasNoSignedWrap();
1269 return BO;
1270 }
1271
1272 Instruction *setFPAttrs(Instruction *I, MDNode *FPMD,
1273 FastMathFlags FMF) const {
1274 if (!FPMD)
1275 FPMD = DefaultFPMathTag;
1276 if (FPMD)
1277 I->setMetadata(LLVMContext::MD_fpmath, FPMD);
1278 I->setFastMathFlags(FMF);
1279 return I;
1280 }
1281
1282 Value *getConstrainedFPRounding(std::optional<RoundingMode> Rounding) {
1284
1285 if (Rounding)
1286 UseRounding = *Rounding;
1287
1288 std::optional<StringRef> RoundingStr =
1289 convertRoundingModeToStr(UseRounding);
1290 assert(RoundingStr && "Garbage strict rounding mode!");
1291 auto *RoundingMDS = MDString::get(Context, *RoundingStr);
1292
1293 return MetadataAsValue::get(Context, RoundingMDS);
1294 }
1295
1296 Value *getConstrainedFPExcept(std::optional<fp::ExceptionBehavior> Except) {
1297 std::optional<StringRef> ExceptStr = convertExceptionBehaviorToStr(
1298 Except.value_or(DefaultConstrainedExcept));
1299 assert(ExceptStr && "Garbage strict exception behavior!");
1300 auto *ExceptMDS = MDString::get(Context, *ExceptStr);
1301
1302 return MetadataAsValue::get(Context, ExceptMDS);
1303 }
1304
1305 Value *getConstrainedFPPredicate(CmpInst::Predicate Predicate) {
1306 assert(CmpInst::isFPPredicate(Predicate) &&
1307 Predicate != CmpInst::FCMP_FALSE &&
1308 Predicate != CmpInst::FCMP_TRUE &&
1309 "Invalid constrained FP comparison predicate!");
1310
1311 StringRef PredicateStr = CmpInst::getPredicateName(Predicate);
1312 auto *PredicateMDS = MDString::get(Context, PredicateStr);
1313
1314 return MetadataAsValue::get(Context, PredicateMDS);
1315 }
1316
1317public:
1319 bool HasNUW = false, bool HasNSW = false) {
1320 if (Value *V =
1321 Folder.FoldNoWrapBinOp(Instruction::Add, LHS, RHS, HasNUW, HasNSW))
1322 return V;
1323 return CreateInsertNUWNSWBinOp(Instruction::Add, LHS, RHS, Name, HasNUW,
1324 HasNSW);
1325 }
1326
1328 return CreateAdd(LHS, RHS, Name, false, true);
1329 }
1330
1332 return CreateAdd(LHS, RHS, Name, true, false);
1333 }
1334
1336 bool HasNUW = false, bool HasNSW = false) {
1337 if (Value *V =
1338 Folder.FoldNoWrapBinOp(Instruction::Sub, LHS, RHS, HasNUW, HasNSW))
1339 return V;
1340 return CreateInsertNUWNSWBinOp(Instruction::Sub, LHS, RHS, Name, HasNUW,
1341 HasNSW);
1342 }
1343
1345 return CreateSub(LHS, RHS, Name, false, true);
1346 }
1347
1349 return CreateSub(LHS, RHS, Name, true, false);
1350 }
1351
1353 bool HasNUW = false, bool HasNSW = false) {
1354 if (Value *V =
1355 Folder.FoldNoWrapBinOp(Instruction::Mul, LHS, RHS, HasNUW, HasNSW))
1356 return V;
1357 return CreateInsertNUWNSWBinOp(Instruction::Mul, LHS, RHS, Name, HasNUW,
1358 HasNSW);
1359 }
1360
1362 return CreateMul(LHS, RHS, Name, false, true);
1363 }
1364
1366 return CreateMul(LHS, RHS, Name, true, false);
1367 }
1368
1370 bool isExact = false) {
1371 if (Value *V = Folder.FoldExactBinOp(Instruction::UDiv, LHS, RHS, isExact))
1372 return V;
1373 if (!isExact)
1374 return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
1375 return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
1376 }
1377
1379 return CreateUDiv(LHS, RHS, Name, true);
1380 }
1381
1383 bool isExact = false) {
1384 if (Value *V = Folder.FoldExactBinOp(Instruction::SDiv, LHS, RHS, isExact))
1385 return V;
1386 if (!isExact)
1387 return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
1388 return Insert(BinaryOperator::CreateExactSDiv(LHS, RHS), Name);
1389 }
1390
1392 return CreateSDiv(LHS, RHS, Name, true);
1393 }
1394
1396 if (Value *V = Folder.FoldBinOp(Instruction::URem, LHS, RHS))
1397 return V;
1398 return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
1399 }
1400
1402 if (Value *V = Folder.FoldBinOp(Instruction::SRem, LHS, RHS))
1403 return V;
1404 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
1405 }
1406
1408 bool HasNUW = false, bool HasNSW = false) {
1409 if (Value *V =
1410 Folder.FoldNoWrapBinOp(Instruction::Shl, LHS, RHS, HasNUW, HasNSW))
1411 return V;
1412 return CreateInsertNUWNSWBinOp(Instruction::Shl, LHS, RHS, Name,
1413 HasNUW, HasNSW);
1414 }
1415
1416 Value *CreateShl(Value *LHS, const APInt &RHS, const Twine &Name = "",
1417 bool HasNUW = false, bool HasNSW = false) {
1418 return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1419 HasNUW, HasNSW);
1420 }
1421
1423 bool HasNUW = false, bool HasNSW = false) {
1424 return CreateShl(LHS, ConstantInt::get(LHS->getType(), RHS), Name,
1425 HasNUW, HasNSW);
1426 }
1427
1429 bool isExact = false) {
1430 if (Value *V = Folder.FoldExactBinOp(Instruction::LShr, LHS, RHS, isExact))
1431 return V;
1432 if (!isExact)
1433 return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
1434 return Insert(BinaryOperator::CreateExactLShr(LHS, RHS), Name);
1435 }
1436
1437 Value *CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1438 bool isExact = false) {
1439 return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1440 }
1441
1443 bool isExact = false) {
1444 return CreateLShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1445 }
1446
1448 bool isExact = false) {
1449 if (Value *V = Folder.FoldExactBinOp(Instruction::AShr, LHS, RHS, isExact))
1450 return V;
1451 if (!isExact)
1452 return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
1453 return Insert(BinaryOperator::CreateExactAShr(LHS, RHS), Name);
1454 }
1455
1456 Value *CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name = "",
1457 bool isExact = false) {
1458 return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1459 }
1460
1462 bool isExact = false) {
1463 return CreateAShr(LHS, ConstantInt::get(LHS->getType(), RHS), Name,isExact);
1464 }
1465
1467 if (auto *V = Folder.FoldBinOp(Instruction::And, LHS, RHS))
1468 return V;
1469 return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
1470 }
1471
1472 Value *CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1473 return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1474 }
1475
1477 return CreateAnd(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1478 }
1479
1481 assert(!Ops.empty());
1482 Value *Accum = Ops[0];
1483 for (unsigned i = 1; i < Ops.size(); i++)
1484 Accum = CreateAnd(Accum, Ops[i]);
1485 return Accum;
1486 }
1487
1489 if (auto *V = Folder.FoldBinOp(Instruction::Or, LHS, RHS))
1490 return V;
1491 return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
1492 }
1493
1494 Value *CreateOr(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1495 return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1496 }
1497
1499 return CreateOr(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1500 }
1501
1503 assert(!Ops.empty());
1504 Value *Accum = Ops[0];
1505 for (unsigned i = 1; i < Ops.size(); i++)
1506 Accum = CreateOr(Accum, Ops[i]);
1507 return Accum;
1508 }
1509
1511 if (Value *V = Folder.FoldBinOp(Instruction::Xor, LHS, RHS))
1512 return V;
1513 return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
1514 }
1515
1516 Value *CreateXor(Value *LHS, const APInt &RHS, const Twine &Name = "") {
1517 return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1518 }
1519
1521 return CreateXor(LHS, ConstantInt::get(LHS->getType(), RHS), Name);
1522 }
1523
1524 Value *CreateFAdd(Value *L, Value *R, const Twine &Name = "",
1525 MDNode *FPMD = nullptr) {
1526 if (IsFPConstrained)
1527 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fadd,
1528 L, R, nullptr, Name, FPMD);
1529
1530 if (Value *V = Folder.FoldBinOpFMF(Instruction::FAdd, L, R, FMF))
1531 return V;
1532 Instruction *I = setFPAttrs(BinaryOperator::CreateFAdd(L, R), FPMD, FMF);
1533 return Insert(I, Name);
1534 }
1535
1536 /// Copy fast-math-flags from an instruction rather than using the builder's
1537 /// default FMF.
1539 const Twine &Name = "") {
1540 if (IsFPConstrained)
1541 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fadd,
1542 L, R, FMFSource, Name);
1543
1544 FastMathFlags FMF = FMFSource->getFastMathFlags();
1545 if (Value *V = Folder.FoldBinOpFMF(Instruction::FAdd, L, R, FMF))
1546 return V;
1547 Instruction *I = setFPAttrs(BinaryOperator::CreateFAdd(L, R), nullptr, FMF);
1548 return Insert(I, Name);
1549 }
1550
1551 Value *CreateFSub(Value *L, Value *R, const Twine &Name = "",
1552 MDNode *FPMD = nullptr) {
1553 if (IsFPConstrained)
1554 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fsub,
1555 L, R, nullptr, Name, FPMD);
1556
1557 if (Value *V = Folder.FoldBinOpFMF(Instruction::FSub, L, R, FMF))
1558 return V;
1559 Instruction *I = setFPAttrs(BinaryOperator::CreateFSub(L, R), FPMD, FMF);
1560 return Insert(I, Name);
1561 }
1562
1563 /// Copy fast-math-flags from an instruction rather than using the builder's
1564 /// default FMF.
1566 const Twine &Name = "") {
1567 if (IsFPConstrained)
1568 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fsub,
1569 L, R, FMFSource, Name);
1570
1571 FastMathFlags FMF = FMFSource->getFastMathFlags();
1572 if (Value *V = Folder.FoldBinOpFMF(Instruction::FSub, L, R, FMF))
1573 return V;
1574 Instruction *I = setFPAttrs(BinaryOperator::CreateFSub(L, R), nullptr, FMF);
1575 return Insert(I, Name);
1576 }
1577
1578 Value *CreateFMul(Value *L, Value *R, const Twine &Name = "",
1579 MDNode *FPMD = nullptr) {
1580 if (IsFPConstrained)
1581 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fmul,
1582 L, R, nullptr, Name, FPMD);
1583
1584 if (Value *V = Folder.FoldBinOpFMF(Instruction::FMul, L, R, FMF))
1585 return V;
1586 Instruction *I = setFPAttrs(BinaryOperator::CreateFMul(L, R), FPMD, FMF);
1587 return Insert(I, Name);
1588 }
1589
1590 /// Copy fast-math-flags from an instruction rather than using the builder's
1591 /// default FMF.
1593 const Twine &Name = "") {
1594 if (IsFPConstrained)
1595 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fmul,
1596 L, R, FMFSource, Name);
1597
1598 FastMathFlags FMF = FMFSource->getFastMathFlags();
1599 if (Value *V = Folder.FoldBinOpFMF(Instruction::FMul, L, R, FMF))
1600 return V;
1601 Instruction *I = setFPAttrs(BinaryOperator::CreateFMul(L, R), nullptr, FMF);
1602 return Insert(I, Name);
1603 }
1604
1605 Value *CreateFDiv(Value *L, Value *R, const Twine &Name = "",
1606 MDNode *FPMD = nullptr) {
1607 if (IsFPConstrained)
1608 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fdiv,
1609 L, R, nullptr, Name, FPMD);
1610
1611 if (Value *V = Folder.FoldBinOpFMF(Instruction::FDiv, L, R, FMF))
1612 return V;
1613 Instruction *I = setFPAttrs(BinaryOperator::CreateFDiv(L, R), FPMD, FMF);
1614 return Insert(I, Name);
1615 }
1616
1617 /// Copy fast-math-flags from an instruction rather than using the builder's
1618 /// default FMF.
1620 const Twine &Name = "") {
1621 if (IsFPConstrained)
1622 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_fdiv,
1623 L, R, FMFSource, Name);
1624
1625 FastMathFlags FMF = FMFSource->getFastMathFlags();
1626 if (Value *V = Folder.FoldBinOpFMF(Instruction::FDiv, L, R, FMF))
1627 return V;
1628 Instruction *I = setFPAttrs(BinaryOperator::CreateFDiv(L, R), nullptr, FMF);
1629 return Insert(I, Name);
1630 }
1631
1632 Value *CreateFRem(Value *L, Value *R, const Twine &Name = "",
1633 MDNode *FPMD = nullptr) {
1634 if (IsFPConstrained)
1635 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_frem,
1636 L, R, nullptr, Name, FPMD);
1637
1638 if (Value *V = Folder.FoldBinOpFMF(Instruction::FRem, L, R, FMF)) return V;
1639 Instruction *I = setFPAttrs(BinaryOperator::CreateFRem(L, R), FPMD, FMF);
1640 return Insert(I, Name);
1641 }
1642
1643 /// Copy fast-math-flags from an instruction rather than using the builder's
1644 /// default FMF.
1646 const Twine &Name = "") {
1647 if (IsFPConstrained)
1648 return CreateConstrainedFPBinOp(Intrinsic::experimental_constrained_frem,
1649 L, R, FMFSource, Name);
1650
1651 FastMathFlags FMF = FMFSource->getFastMathFlags();
1652 if (Value *V = Folder.FoldBinOpFMF(Instruction::FRem, L, R, FMF)) return V;
1653 Instruction *I = setFPAttrs(BinaryOperator::CreateFRem(L, R), nullptr, FMF);
1654 return Insert(I, Name);
1655 }
1656
1658 Value *LHS, Value *RHS, const Twine &Name = "",
1659 MDNode *FPMathTag = nullptr) {
1660 if (Value *V = Folder.FoldBinOp(Opc, LHS, RHS)) return V;
1661 Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
1662 if (isa<FPMathOperator>(BinOp))
1663 setFPAttrs(BinOp, FPMathTag, FMF);
1664 return Insert(BinOp, Name);
1665 }
1666
1667 Value *CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name = "") {
1668 assert(Cond2->getType()->isIntOrIntVectorTy(1));
1669 return CreateSelect(Cond1, Cond2,
1671 }
1672
1673 Value *CreateLogicalOr(Value *Cond1, Value *Cond2, const Twine &Name = "") {
1674 assert(Cond2->getType()->isIntOrIntVectorTy(1));
1675 return CreateSelect(Cond1, ConstantInt::getAllOnesValue(Cond2->getType()),
1676 Cond2, Name);
1677 }
1678
1680 const Twine &Name = "") {
1681 switch (Opc) {
1682 case Instruction::And:
1683 return CreateLogicalAnd(Cond1, Cond2, Name);
1684 case Instruction::Or:
1685 return CreateLogicalOr(Cond1, Cond2, Name);
1686 default:
1687 break;
1688 }
1689 llvm_unreachable("Not a logical operation.");
1690 }
1691
1692 // NOTE: this is sequential, non-commutative, ordered reduction!
1694 assert(!Ops.empty());
1695 Value *Accum = Ops[0];
1696 for (unsigned i = 1; i < Ops.size(); i++)
1697 Accum = CreateLogicalOr(Accum, Ops[i]);
1698 return Accum;
1699 }
1700
1702 Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource = nullptr,
1703 const Twine &Name = "", MDNode *FPMathTag = nullptr,
1704 std::optional<RoundingMode> Rounding = std::nullopt,
1705 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1706
1708 Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource = nullptr,
1709 const Twine &Name = "", MDNode *FPMathTag = nullptr,
1710 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
1711
1712 Value *CreateNeg(Value *V, const Twine &Name = "", bool HasNUW = false,
1713 bool HasNSW = false) {
1714 return CreateSub(Constant::getNullValue(V->getType()), V, Name, HasNUW,
1715 HasNSW);
1716 }
1717
1718 Value *CreateNSWNeg(Value *V, const Twine &Name = "") {
1719 return CreateNeg(V, Name, false, true);
1720 }
1721
1722 Value *CreateNUWNeg(Value *V, const Twine &Name = "") {
1723 return CreateNeg(V, Name, true, false);
1724 }
1725
1726 Value *CreateFNeg(Value *V, const Twine &Name = "",
1727 MDNode *FPMathTag = nullptr) {
1728 if (Value *Res = Folder.FoldUnOpFMF(Instruction::FNeg, V, FMF))
1729 return Res;
1730 return Insert(setFPAttrs(UnaryOperator::CreateFNeg(V), FPMathTag, FMF),
1731 Name);
1732 }
1733
1734 /// Copy fast-math-flags from an instruction rather than using the builder's
1735 /// default FMF.
1737 const Twine &Name = "") {
1738 FastMathFlags FMF = FMFSource->getFastMathFlags();
1739 if (Value *Res = Folder.FoldUnOpFMF(Instruction::FNeg, V, FMF))
1740 return Res;
1741 return Insert(setFPAttrs(UnaryOperator::CreateFNeg(V), nullptr, FMF),
1742 Name);
1743 }
1744
1745 Value *CreateNot(Value *V, const Twine &Name = "") {
1746 return CreateXor(V, Constant::getAllOnesValue(V->getType()), Name);
1747 }
1748
1750 Value *V, const Twine &Name = "",
1751 MDNode *FPMathTag = nullptr) {
1752 if (Value *Res = Folder.FoldUnOpFMF(Opc, V, FMF))
1753 return Res;
1754 Instruction *UnOp = UnaryOperator::Create(Opc, V);
1755 if (isa<FPMathOperator>(UnOp))
1756 setFPAttrs(UnOp, FPMathTag, FMF);
1757 return Insert(UnOp, Name);
1758 }
1759
1760 /// Create either a UnaryOperator or BinaryOperator depending on \p Opc.
1761 /// Correct number of operands must be passed accordingly.
1762 Value *CreateNAryOp(unsigned Opc, ArrayRef<Value *> Ops,
1763 const Twine &Name = "", MDNode *FPMathTag = nullptr);
1764
1765 //===--------------------------------------------------------------------===//
1766 // Instruction creation methods: Memory Instructions
1767 //===--------------------------------------------------------------------===//
1768
1769 AllocaInst *CreateAlloca(Type *Ty, unsigned AddrSpace,
1770 Value *ArraySize = nullptr, const Twine &Name = "") {
1771 const DataLayout &DL = BB->getModule()->getDataLayout();
1772 Align AllocaAlign = DL.getPrefTypeAlign(Ty);
1773 return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
1774 }
1775
1776 AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = nullptr,
1777 const Twine &Name = "") {
1778 const DataLayout &DL = BB->getModule()->getDataLayout();
1779 Align AllocaAlign = DL.getPrefTypeAlign(Ty);
1780 unsigned AddrSpace = DL.getAllocaAddrSpace();
1781 return Insert(new AllocaInst(Ty, AddrSpace, ArraySize, AllocaAlign), Name);
1782 }
1783
1784 /// Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of
1785 /// converting the string to 'bool' for the isVolatile parameter.
1786 LoadInst *CreateLoad(Type *Ty, Value *Ptr, const char *Name) {
1787 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), Name);
1788 }
1789
1790 LoadInst *CreateLoad(Type *Ty, Value *Ptr, const Twine &Name = "") {
1791 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), Name);
1792 }
1793
1794 LoadInst *CreateLoad(Type *Ty, Value *Ptr, bool isVolatile,
1795 const Twine &Name = "") {
1796 return CreateAlignedLoad(Ty, Ptr, MaybeAlign(), isVolatile, Name);
1797 }
1798
1799 StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) {
1800 return CreateAlignedStore(Val, Ptr, MaybeAlign(), isVolatile);
1801 }
1802
1804 const char *Name) {
1805 return CreateAlignedLoad(Ty, Ptr, Align, /*isVolatile*/false, Name);
1806 }
1807
1809 const Twine &Name = "") {
1810 return CreateAlignedLoad(Ty, Ptr, Align, /*isVolatile*/false, Name);
1811 }
1812
1814 bool isVolatile, const Twine &Name = "") {
1815 if (!Align) {
1816 const DataLayout &DL = BB->getModule()->getDataLayout();
1817 Align = DL.getABITypeAlign(Ty);
1818 }
1819 return Insert(new LoadInst(Ty, Ptr, Twine(), isVolatile, *Align), Name);
1820 }
1821
1823 bool isVolatile = false) {
1824 if (!Align) {
1825 const DataLayout &DL = BB->getModule()->getDataLayout();
1826 Align = DL.getABITypeAlign(Val->getType());
1827 }
1828 return Insert(new StoreInst(Val, Ptr, isVolatile, *Align));
1829 }
1832 const Twine &Name = "") {
1833 return Insert(new FenceInst(Context, Ordering, SSID), Name);
1834 }
1835
1838 AtomicOrdering SuccessOrdering,
1839 AtomicOrdering FailureOrdering,
1841 if (!Align) {
1842 const DataLayout &DL = BB->getModule()->getDataLayout();
1843 Align = llvm::Align(DL.getTypeStoreSize(New->getType()));
1844 }
1845
1846 return Insert(new AtomicCmpXchgInst(Ptr, Cmp, New, *Align, SuccessOrdering,
1847 FailureOrdering, SSID));
1848 }
1849
1851 Value *Val, MaybeAlign Align,
1852 AtomicOrdering Ordering,
1854 if (!Align) {
1855 const DataLayout &DL = BB->getModule()->getDataLayout();
1856 Align = llvm::Align(DL.getTypeStoreSize(Val->getType()));
1857 }
1858
1859 return Insert(new AtomicRMWInst(Op, Ptr, Val, *Align, Ordering, SSID));
1860 }
1861
1863 const Twine &Name = "", bool IsInBounds = false) {
1864 if (auto *V = Folder.FoldGEP(Ty, Ptr, IdxList, IsInBounds))
1865 return V;
1866 return Insert(IsInBounds
1868 : GetElementPtrInst::Create(Ty, Ptr, IdxList),
1869 Name);
1870 }
1871
1873 const Twine &Name = "") {
1874 return CreateGEP(Ty, Ptr, IdxList, Name, /* IsInBounds */ true);
1875 }
1876
1877 Value *CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0,
1878 const Twine &Name = "") {
1880
1881 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idx, /*IsInBounds=*/false))
1882 return V;
1883
1885 }
1886
1888 const Twine &Name = "") {
1890
1891 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idx, /*IsInBounds=*/true))
1892 return V;
1893
1895 }
1896
1897 Value *CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1,
1898 const Twine &Name = "") {
1899 Value *Idxs[] = {
1902 };
1903
1904 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idxs, /*IsInBounds=*/false))
1905 return V;
1906
1907 return Insert(GetElementPtrInst::Create(Ty, Ptr, Idxs), Name);
1908 }
1909
1911 unsigned Idx1, const Twine &Name = "") {
1912 Value *Idxs[] = {
1915 };
1916
1917 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idxs, /*IsInBounds=*/true))
1918 return V;
1919
1921 }
1922
1924 const Twine &Name = "") {
1926
1927 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idx, /*IsInBounds=*/false))
1928 return V;
1929
1931 }
1932
1934 const Twine &Name = "") {
1936
1937 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idx, /*IsInBounds=*/true))
1938 return V;
1939
1941 }
1942
1944 const Twine &Name = "") {
1945 Value *Idxs[] = {
1948 };
1949
1950 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idxs, /*IsInBounds=*/false))
1951 return V;
1952
1953 return Insert(GetElementPtrInst::Create(Ty, Ptr, Idxs), Name);
1954 }
1955
1957 uint64_t Idx1, const Twine &Name = "") {
1958 Value *Idxs[] = {
1961 };
1962
1963 if (auto *V = Folder.FoldGEP(Ty, Ptr, Idxs, /*IsInBounds=*/true))
1964 return V;
1965
1967 }
1968
1970 const Twine &Name = "") {
1971 return CreateConstInBoundsGEP2_32(Ty, Ptr, 0, Idx, Name);
1972 }
1973
1974 /// Same as CreateGlobalString, but return a pointer with "i8*" type
1975 /// instead of a pointer to array of i8.
1976 ///
1977 /// If no module is given via \p M, it is take from the insertion point basic
1978 /// block.
1980 unsigned AddressSpace = 0,
1981 Module *M = nullptr) {
1984 Constant *Indices[] = {Zero, Zero};
1986 Indices);
1987 }
1988
1989 //===--------------------------------------------------------------------===//
1990 // Instruction creation methods: Cast/Conversion Operators
1991 //===--------------------------------------------------------------------===//
1992
1993 Value *CreateTrunc(Value *V, Type *DestTy, const Twine &Name = "") {
1994 return CreateCast(Instruction::Trunc, V, DestTy, Name);
1995 }
1996
1997 Value *CreateZExt(Value *V, Type *DestTy, const Twine &Name = "",
1998 bool IsNonNeg = false) {
1999 if (V->getType() == DestTy)
2000 return V;
2001 if (Value *Folded = Folder.FoldCast(Instruction::ZExt, V, DestTy))
2002 return Folded;
2003 Instruction *I = Insert(new ZExtInst(V, DestTy), Name);
2004 if (IsNonNeg)
2005 I->setNonNeg();
2006 return I;
2007 }
2008
2009 Value *CreateSExt(Value *V, Type *DestTy, const Twine &Name = "") {
2010 return CreateCast(Instruction::SExt, V, DestTy, Name);
2011 }
2012
2013 /// Create a ZExt or Trunc from the integer value V to DestTy. Return
2014 /// the value untouched if the type of V is already DestTy.
2016 const Twine &Name = "") {
2017 assert(V->getType()->isIntOrIntVectorTy() &&
2018 DestTy->isIntOrIntVectorTy() &&
2019 "Can only zero extend/truncate integers!");
2020 Type *VTy = V->getType();
2021 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2022 return CreateZExt(V, DestTy, Name);
2023 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2024 return CreateTrunc(V, DestTy, Name);
2025 return V;
2026 }
2027
2028 /// Create a SExt or Trunc from the integer value V to DestTy. Return
2029 /// the value untouched if the type of V is already DestTy.
2031 const Twine &Name = "") {
2032 assert(V->getType()->isIntOrIntVectorTy() &&
2033 DestTy->isIntOrIntVectorTy() &&
2034 "Can only sign extend/truncate integers!");
2035 Type *VTy = V->getType();
2036 if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
2037 return CreateSExt(V, DestTy, Name);
2038 if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
2039 return CreateTrunc(V, DestTy, Name);
2040 return V;
2041 }
2042
2043 Value *CreateFPToUI(Value *V, Type *DestTy, const Twine &Name = "") {
2044 if (IsFPConstrained)
2045 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptoui,
2046 V, DestTy, nullptr, Name);
2047 return CreateCast(Instruction::FPToUI, V, DestTy, Name);
2048 }
2049
2050 Value *CreateFPToSI(Value *V, Type *DestTy, const Twine &Name = "") {
2051 if (IsFPConstrained)
2052 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fptosi,
2053 V, DestTy, nullptr, Name);
2054 return CreateCast(Instruction::FPToSI, V, DestTy, Name);
2055 }
2056
2057 Value *CreateUIToFP(Value *V, Type *DestTy, const Twine &Name = ""){
2058 if (IsFPConstrained)
2059 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_uitofp,
2060 V, DestTy, nullptr, Name);
2061 return CreateCast(Instruction::UIToFP, V, DestTy, Name);
2062 }
2063
2064 Value *CreateSIToFP(Value *V, Type *DestTy, const Twine &Name = ""){
2065 if (IsFPConstrained)
2066 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_sitofp,
2067 V, DestTy, nullptr, Name);
2068 return CreateCast(Instruction::SIToFP, V, DestTy, Name);
2069 }
2070
2072 const Twine &Name = "") {
2073 if (IsFPConstrained)
2075 Intrinsic::experimental_constrained_fptrunc, V, DestTy, nullptr,
2076 Name);
2077 return CreateCast(Instruction::FPTrunc, V, DestTy, Name);
2078 }
2079
2080 Value *CreateFPExt(Value *V, Type *DestTy, const Twine &Name = "") {
2081 if (IsFPConstrained)
2082 return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fpext,
2083 V, DestTy, nullptr, Name);
2084 return CreateCast(Instruction::FPExt, V, DestTy, Name);
2085 }
2086
2088 const Twine &Name = "") {
2089 return CreateCast(Instruction::PtrToInt, V, DestTy, Name);
2090 }
2091
2093 const Twine &Name = "") {
2094 return CreateCast(Instruction::IntToPtr, V, DestTy, Name);
2095 }
2096
2098 const Twine &Name = "") {
2099 return CreateCast(Instruction::BitCast, V, DestTy, Name);
2100 }
2101
2103 const Twine &Name = "") {
2104 return CreateCast(Instruction::AddrSpaceCast, V, DestTy, Name);
2105 }
2106
2107 Value *CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2108 Instruction::CastOps CastOp =
2109 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2110 ? Instruction::BitCast
2111 : Instruction::ZExt;
2112 return CreateCast(CastOp, V, DestTy, Name);
2113 }
2114
2115 Value *CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2116 Instruction::CastOps CastOp =
2117 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2118 ? Instruction::BitCast
2119 : Instruction::SExt;
2120 return CreateCast(CastOp, V, DestTy, Name);
2121 }
2122
2123 Value *CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") {
2124 Instruction::CastOps CastOp =
2125 V->getType()->getScalarSizeInBits() == DestTy->getScalarSizeInBits()
2126 ? Instruction::BitCast
2127 : Instruction::Trunc;
2128 return CreateCast(CastOp, V, DestTy, Name);
2129 }
2130
2132 const Twine &Name = "") {
2133 if (V->getType() == DestTy)
2134 return V;
2135 if (Value *Folded = Folder.FoldCast(Op, V, DestTy))
2136 return Folded;
2137 return Insert(CastInst::Create(Op, V, DestTy), Name);
2138 }
2139
2141 const Twine &Name = "") {
2142 if (V->getType() == DestTy)
2143 return V;
2144 if (auto *VC = dyn_cast<Constant>(V))
2145 return Insert(Folder.CreatePointerCast(VC, DestTy), Name);
2146 return Insert(CastInst::CreatePointerCast(V, DestTy), Name);
2147 }
2148
2149 // With opaque pointers enabled, this can be substituted with
2150 // CreateAddrSpaceCast.
2151 // TODO: Replace uses of this method and remove the method itself.
2153 const Twine &Name = "") {
2154 if (V->getType() == DestTy)
2155 return V;
2156
2157 if (auto *VC = dyn_cast<Constant>(V)) {
2159 Name);
2160 }
2161
2163 Name);
2164 }
2165
2167 const Twine &Name = "") {
2168 Instruction::CastOps CastOp =
2169 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2170 ? Instruction::Trunc
2171 : (isSigned ? Instruction::SExt : Instruction::ZExt);
2172 return CreateCast(CastOp, V, DestTy, Name);
2173 }
2174
2176 const Twine &Name = "") {
2177 if (V->getType() == DestTy)
2178 return V;
2179 if (V->getType()->isPtrOrPtrVectorTy() && DestTy->isIntOrIntVectorTy())
2180 return CreatePtrToInt(V, DestTy, Name);
2181 if (V->getType()->isIntOrIntVectorTy() && DestTy->isPtrOrPtrVectorTy())
2182 return CreateIntToPtr(V, DestTy, Name);
2183
2184 return CreateBitCast(V, DestTy, Name);
2185 }
2186
2187 Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "") {
2188 Instruction::CastOps CastOp =
2189 V->getType()->getScalarSizeInBits() > DestTy->getScalarSizeInBits()
2190 ? Instruction::FPTrunc
2191 : Instruction::FPExt;
2192 return CreateCast(CastOp, V, DestTy, Name);
2193 }
2194
2196 Intrinsic::ID ID, Value *V, Type *DestTy,
2197 Instruction *FMFSource = nullptr, const Twine &Name = "",
2198 MDNode *FPMathTag = nullptr,
2199 std::optional<RoundingMode> Rounding = std::nullopt,
2200 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2201
2202 // Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
2203 // compile time error, instead of converting the string to bool for the
2204 // isSigned parameter.
2205 Value *CreateIntCast(Value *, Type *, const char *) = delete;
2206
2207 //===--------------------------------------------------------------------===//
2208 // Instruction creation methods: Compare Instructions
2209 //===--------------------------------------------------------------------===//
2210
2213 }
2214
2217 }
2218
2221 }
2222
2225 }
2226
2229 }
2230
2233 }
2234
2237 }
2238
2241 }
2242
2245 }
2246
2249 }
2250
2252 MDNode *FPMathTag = nullptr) {
2253 return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name, FPMathTag);
2254 }
2255
2257 MDNode *FPMathTag = nullptr) {
2258 return CreateFCmp(FCmpInst::FCMP_OGT, LHS, RHS, Name, FPMathTag);
2259 }
2260
2262 MDNode *FPMathTag = nullptr) {
2263 return CreateFCmp(FCmpInst::FCMP_OGE, LHS, RHS, Name, FPMathTag);
2264 }
2265
2267 MDNode *FPMathTag = nullptr) {
2268 return CreateFCmp(FCmpInst::FCMP_OLT, LHS, RHS, Name, FPMathTag);
2269 }
2270
2272 MDNode *FPMathTag = nullptr) {
2273 return CreateFCmp(FCmpInst::FCMP_OLE, LHS, RHS, Name, FPMathTag);
2274 }
2275
2277 MDNode *FPMathTag = nullptr) {
2278 return CreateFCmp(FCmpInst::FCMP_ONE, LHS, RHS, Name, FPMathTag);
2279 }
2280
2282 MDNode *FPMathTag = nullptr) {
2283 return CreateFCmp(FCmpInst::FCMP_ORD, LHS, RHS, Name, FPMathTag);
2284 }
2285
2287 MDNode *FPMathTag = nullptr) {
2288 return CreateFCmp(FCmpInst::FCMP_UNO, LHS, RHS, Name, FPMathTag);
2289 }
2290
2292 MDNode *FPMathTag = nullptr) {
2293 return CreateFCmp(FCmpInst::FCMP_UEQ, LHS, RHS, Name, FPMathTag);
2294 }
2295
2297 MDNode *FPMathTag = nullptr) {
2298 return CreateFCmp(FCmpInst::FCMP_UGT, LHS, RHS, Name, FPMathTag);
2299 }
2300
2302 MDNode *FPMathTag = nullptr) {
2303 return CreateFCmp(FCmpInst::FCMP_UGE, LHS, RHS, Name, FPMathTag);
2304 }
2305
2307 MDNode *FPMathTag = nullptr) {
2308 return CreateFCmp(FCmpInst::FCMP_ULT, LHS, RHS, Name, FPMathTag);
2309 }
2310
2312 MDNode *FPMathTag = nullptr) {
2313 return CreateFCmp(FCmpInst::FCMP_ULE, LHS, RHS, Name, FPMathTag);
2314 }
2315
2317 MDNode *FPMathTag = nullptr) {
2318 return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name, FPMathTag);
2319 }
2320
2322 const Twine &Name = "") {
2323 if (auto *V = Folder.FoldICmp(P, LHS, RHS))
2324 return V;
2325 return Insert(new ICmpInst(P, LHS, RHS), Name);
2326 }
2327
2328 // Create a quiet floating-point comparison (i.e. one that raises an FP
2329 // exception only in the case where an input is a signaling NaN).
2330 // Note that this differs from CreateFCmpS only if IsFPConstrained is true.
2332 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2333 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, false);
2334 }
2335
2337 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2338 return CmpInst::isFPPredicate(Pred)
2339 ? CreateFCmp(Pred, LHS, RHS, Name, FPMathTag)
2340 : CreateICmp(Pred, LHS, RHS, Name);
2341 }
2342
2343 // Create a signaling floating-point comparison (i.e. one that raises an FP
2344 // exception whenever an input is any NaN, signaling or quiet).
2345 // Note that this differs from CreateFCmp only if IsFPConstrained is true.
2347 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2348 return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag, true);
2349 }
2350
2351private:
2352 // Helper routine to create either a signaling or a quiet FP comparison.
2353 Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS,
2354 const Twine &Name, MDNode *FPMathTag,
2355 bool IsSignaling);
2356
2357public:
2360 const Twine &Name = "",
2361 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2362
2363 //===--------------------------------------------------------------------===//
2364 // Instruction creation methods: Other Instructions
2365 //===--------------------------------------------------------------------===//
2366
2367 PHINode *CreatePHI(Type *Ty, unsigned NumReservedValues,
2368 const Twine &Name = "") {
2369 PHINode *Phi = PHINode::Create(Ty, NumReservedValues);
2370 if (isa<FPMathOperator>(Phi))
2371 setFPAttrs(Phi, nullptr /* MDNode* */, FMF);
2372 return Insert(Phi, Name);
2373 }
2374
2375private:
2376 CallInst *createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
2377 const Twine &Name = "",
2378 Instruction *FMFSource = nullptr,
2379 ArrayRef<OperandBundleDef> OpBundles = {});
2380
2381public:
2383 ArrayRef<Value *> Args = std::nullopt,
2384 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2385 CallInst *CI = CallInst::Create(FTy, Callee, Args, DefaultOperandBundles);
2386 if (IsFPConstrained)
2388 if (isa<FPMathOperator>(CI))
2389 setFPAttrs(CI, FPMathTag, FMF);
2390 return Insert(CI, Name);
2391 }
2392
2395 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2396 CallInst *CI = CallInst::Create(FTy, Callee, Args, OpBundles);
2397 if (IsFPConstrained)
2399 if (isa<FPMathOperator>(CI))
2400 setFPAttrs(CI, FPMathTag, FMF);
2401 return Insert(CI, Name);
2402 }
2403
2405 ArrayRef<Value *> Args = std::nullopt,
2406 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2407 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args, Name,
2408 FPMathTag);
2409 }
2410
2413 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
2414 return CreateCall(Callee.getFunctionType(), Callee.getCallee(), Args,
2415 OpBundles, Name, FPMathTag);
2416 }
2417
2419 Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "",
2420 std::optional<RoundingMode> Rounding = std::nullopt,
2421 std::optional<fp::ExceptionBehavior> Except = std::nullopt);
2422
2423 Value *CreateSelect(Value *C, Value *True, Value *False,
2424 const Twine &Name = "", Instruction *MDFrom = nullptr);
2425
2427 return Insert(new VAArgInst(List, Ty), Name);
2428 }
2429
2431 const Twine &Name = "") {
2432 if (Value *V = Folder.FoldExtractElement(Vec, Idx))
2433 return V;
2435 }
2436
2438 const Twine &Name = "") {
2439 return CreateExtractElement(Vec, getInt64(Idx), Name);
2440 }
2441
2443 const Twine &Name = "") {
2444 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2445 }
2446
2448 const Twine &Name = "") {
2449 return CreateInsertElement(PoisonValue::get(VecTy), NewElt, Idx, Name);
2450 }
2451
2453 const Twine &Name = "") {
2454 if (Value *V = Folder.FoldInsertElement(Vec, NewElt, Idx))
2455 return V;
2456 return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
2457 }
2458
2460 const Twine &Name = "") {
2461 return CreateInsertElement(Vec, NewElt, getInt64(Idx), Name);
2462 }
2463
2465 const Twine &Name = "") {
2466 SmallVector<int, 16> IntMask;
2467 ShuffleVectorInst::getShuffleMask(cast<Constant>(Mask), IntMask);
2468 return CreateShuffleVector(V1, V2, IntMask, Name);
2469 }
2470
2471 /// See class ShuffleVectorInst for a description of the mask representation.
2473 const Twine &Name = "") {
2474 if (Value *V = Folder.FoldShuffleVector(V1, V2, Mask))
2475 return V;
2476 return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
2477 }
2478
2479 /// Create a unary shuffle. The second vector operand of the IR instruction
2480 /// is poison.
2482 const Twine &Name = "") {
2483 return CreateShuffleVector(V, PoisonValue::get(V->getType()), Mask, Name);
2484 }
2485
2487 const Twine &Name = "") {
2488 if (auto *V = Folder.FoldExtractValue(Agg, Idxs))
2489 return V;
2490 return Insert(ExtractValueInst::Create(Agg, Idxs), Name);
2491 }
2492
2494 const Twine &Name = "") {
2495 if (auto *V = Folder.FoldInsertValue(Agg, Val, Idxs))
2496 return V;
2497 return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name);
2498 }
2499
2500 LandingPadInst *CreateLandingPad(Type *Ty, unsigned NumClauses,
2501 const Twine &Name = "") {
2502 return Insert(LandingPadInst::Create(Ty, NumClauses), Name);
2503 }
2504
2505 Value *CreateFreeze(Value *V, const Twine &Name = "") {
2506 return Insert(new FreezeInst(V), Name);
2507 }
2508
2509 //===--------------------------------------------------------------------===//
2510 // Utility creation methods
2511 //===--------------------------------------------------------------------===//
2512
2513 /// Return a boolean value testing if \p Arg == 0.
2514 Value *CreateIsNull(Value *Arg, const Twine &Name = "") {
2515 return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()), Name);
2516 }
2517
2518 /// Return a boolean value testing if \p Arg != 0.
2519 Value *CreateIsNotNull(Value *Arg, const Twine &Name = "") {
2520 return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()), Name);
2521 }
2522
2523 /// Return a boolean value testing if \p Arg < 0.
2524 Value *CreateIsNeg(Value *Arg, const Twine &Name = "") {
2526 }
2527
2528 /// Return a boolean value testing if \p Arg > -1.
2529 Value *CreateIsNotNeg(Value *Arg, const Twine &Name = "") {
2531 Name);
2532 }
2533
2534 /// Return the i64 difference between two pointer values, dividing out
2535 /// the size of the pointed-to objects.
2536 ///
2537 /// This is intended to implement C-style pointer subtraction. As such, the
2538 /// pointers must be appropriately aligned for their element types and
2539 /// pointing into the same object.
2540 Value *CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS,
2541 const Twine &Name = "");
2542
2543 /// Create a launder.invariant.group intrinsic call. If Ptr type is
2544 /// different from pointer to i8, it's casted to pointer to i8 in the same
2545 /// address space before call and casted back to Ptr type after call.
2547
2548 /// \brief Create a strip.invariant.group intrinsic call. If Ptr type is
2549 /// different from pointer to i8, it's casted to pointer to i8 in the same
2550 /// address space before call and casted back to Ptr type after call.
2552
2553 /// Return a vector value that contains the vector V reversed
2554 Value *CreateVectorReverse(Value *V, const Twine &Name = "");
2555
2556 /// Return a vector splice intrinsic if using scalable vectors, otherwise
2557 /// return a shufflevector. If the immediate is positive, a vector is
2558 /// extracted from concat(V1, V2), starting at Imm. If the immediate
2559 /// is negative, we extract -Imm elements from V1 and the remaining
2560 /// elements from V2. Imm is a signed integer in the range
2561 /// -VL <= Imm < VL (where VL is the runtime vector length of the
2562 /// source/result vector)
2563 Value *CreateVectorSplice(Value *V1, Value *V2, int64_t Imm,
2564 const Twine &Name = "");
2565
2566 /// Return a vector value that contains \arg V broadcasted to \p
2567 /// NumElts elements.
2568 Value *CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name = "");
2569
2570 /// Return a vector value that contains \arg V broadcasted to \p
2571 /// EC elements.
2572 Value *CreateVectorSplat(ElementCount EC, Value *V, const Twine &Name = "");
2573
2575 unsigned Dimension, unsigned LastIndex,
2576 MDNode *DbgInfo);
2577
2578 Value *CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex,
2579 MDNode *DbgInfo);
2580
2582 unsigned Index, unsigned FieldIndex,
2583 MDNode *DbgInfo);
2584
2585 Value *createIsFPClass(Value *FPNum, unsigned Test);
2586
2587private:
2588 /// Helper function that creates an assume intrinsic call that
2589 /// represents an alignment assumption on the provided pointer \p PtrValue
2590 /// with offset \p OffsetValue and alignment value \p AlignValue.
2591 CallInst *CreateAlignmentAssumptionHelper(const DataLayout &DL,
2592 Value *PtrValue, Value *AlignValue,
2593 Value *OffsetValue);
2594
2595public:
2596 /// Create an assume intrinsic call that represents an alignment
2597 /// assumption on the provided pointer.
2598 ///
2599 /// An optional offset can be provided, and if it is provided, the offset
2600 /// must be subtracted from the provided pointer to get the pointer with the
2601 /// specified alignment.
2603 unsigned Alignment,
2604 Value *OffsetValue = nullptr);
2605
2606 /// Create an assume intrinsic call that represents an alignment
2607 /// assumption on the provided pointer.
2608 ///
2609 /// An optional offset can be provided, and if it is provided, the offset
2610 /// must be subtracted from the provided pointer to get the pointer with the
2611 /// specified alignment.
2612 ///
2613 /// This overload handles the condition where the Alignment is dependent
2614 /// on an existing value rather than a static value.
2616 Value *Alignment,
2617 Value *OffsetValue = nullptr);
2618};
2619
2620/// This provides a uniform API for creating instructions and inserting
2621/// them into a basic block: either at the end of a BasicBlock, or at a specific
2622/// iterator location in a block.
2623///
2624/// Note that the builder does not expose the full generality of LLVM
2625/// instructions. For access to extra instruction properties, use the mutators
2626/// (e.g. setVolatile) on the instructions after they have been
2627/// created. Convenience state exists to specify fast-math flags and fp-math
2628/// tags.
2629///
2630/// The first template argument specifies a class to use for creating constants.
2631/// This defaults to creating minimally folded constants. The second template
2632/// argument allows clients to specify custom insertion hooks that are called on
2633/// every newly created insertion.
2634template <typename FolderTy = ConstantFolder,
2635 typename InserterTy = IRBuilderDefaultInserter>
2636class IRBuilder : public IRBuilderBase {
2637private:
2638 FolderTy Folder;
2639 InserterTy Inserter;
2640
2641public:
2642 IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter = InserterTy(),
2643 MDNode *FPMathTag = nullptr,
2644 ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2645 : IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles),
2646 Folder(Folder), Inserter(Inserter) {}
2647
2648 explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr,
2649 ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2650 : IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles) {}
2651
2652 explicit IRBuilder(BasicBlock *TheBB, FolderTy Folder,
2653 MDNode *FPMathTag = nullptr,
2654 ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2655 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2656 FPMathTag, OpBundles),
2657 Folder(Folder) {
2658 SetInsertPoint(TheBB);
2659 }
2660
2661 explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr,
2662 ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2663 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2664 FPMathTag, OpBundles) {
2665 SetInsertPoint(TheBB);
2666 }
2667
2668 explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr,
2669 ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2670 : IRBuilderBase(IP->getContext(), this->Folder, this->Inserter, FPMathTag,
2671 OpBundles) {
2672 SetInsertPoint(IP);
2673 }
2674
2675 IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder,
2676 MDNode *FPMathTag = nullptr,
2677 ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2678 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2679 FPMathTag, OpBundles),
2680 Folder(Folder) {
2681 SetInsertPoint(TheBB, IP);
2682 }
2683
2685 MDNode *FPMathTag = nullptr,
2686 ArrayRef<OperandBundleDef> OpBundles = std::nullopt)
2687 : IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
2688 FPMathTag, OpBundles) {
2689 SetInsertPoint(TheBB, IP);
2690 }
2691
2692 /// Avoid copying the full IRBuilder. Prefer using InsertPointGuard
2693 /// or FastMathFlagGuard instead.
2694 IRBuilder(const IRBuilder &) = delete;
2695
2696 InserterTy &getInserter() { return Inserter; }
2697};
2698
2699template <typename FolderTy, typename InserterTy>
2700IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *,
2703template <typename FolderTy>
2708template <typename FolderTy>
2713
2714
2715// Create wrappers for C Binding types (see CBindingWrapping.h).
2717
2718} // end namespace llvm
2719
2720#endif // LLVM_IR_IRBUILDER_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
return RetTy
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint64_t Addr
std::string Name
uint64_t Size
static bool isSigned(unsigned int Opcode)
This file contains the declarations of entities that describe floating point environment and related ...
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
Module.h This file contains the declarations for the Module class.
#define P(N)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition: APInt.h:76
an instruction to allocate memory on the stack
Definition: Instructions.h:58
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:160
Value handle that asserts if the Value is deleted.
Definition: ValueHandle.h:264
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:513
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:718
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:730
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
iterator end()
Definition: BasicBlock.h:442
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:205
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:165
const_iterator getFirstNonPHIOrDbgOrAlloca() const
Returns an iterator to the first instruction in this block that is not a PHINode, a debug intrinsic,...
Definition: BasicBlock.cpp:460
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
Definition: BasicBlock.cpp:328
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
Conditional or Unconditional Branch instruction.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1227
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, Instruction *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="", Instruction *InsertBefore=nullptr)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast or an AddrSpaceCast cast instruction.
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore=nullptr)
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args=std::nullopt, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, Instruction *InsertBefore=nullptr)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:748
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
Definition: InstrTypes.h:751
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
Definition: InstrTypes.h:765
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:777
@ ICMP_SLE
signed less or equal
Definition: InstrTypes.h:778
@ FCMP_OLT
0 1 0 0 True if ordered and less than
Definition: InstrTypes.h:754
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
Definition: InstrTypes.h:763
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
Definition: InstrTypes.h:752
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
Definition: InstrTypes.h:753
@ ICMP_UGE
unsigned greater or equal
Definition: InstrTypes.h:772
@ ICMP_UGT
unsigned greater than
Definition: InstrTypes.h:771
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:775
@ FCMP_ULT
1 1 0 0 True if unordered or less than
Definition: InstrTypes.h:762
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
Definition: InstrTypes.h:756
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
Definition: InstrTypes.h:759
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:773
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
Definition: InstrTypes.h:760
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
Definition: InstrTypes.h:755
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
Definition: InstrTypes.h:757
@ ICMP_EQ
equal
Definition: InstrTypes.h:769
@ ICMP_NE
not equal
Definition: InstrTypes.h:770
@ ICMP_SGE
signed greater or equal
Definition: InstrTypes.h:776
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
Definition: InstrTypes.h:764
@ ICMP_ULE
unsigned less or equal
Definition: InstrTypes.h:774
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Definition: InstrTypes.h:761
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
Definition: InstrTypes.h:750
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition: InstrTypes.h:758
bool isFPPredicate() const
Definition: InstrTypes.h:855
static StringRef getPredicateName(Predicate P)
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition: Constants.h:1207
This is the shared class of boolean and integer constants.
Definition: Constants.h:78
static ConstantInt * getTrue(LLVMContext &Context)
Definition: Constants.cpp:833
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:888
static ConstantInt * getFalse(LLVMContext &Context)
Definition: Constants.cpp:840
This is an important base class in LLVM.
Definition: Constant.h:41
static Constant * getAllOnesValue(Type *Ty)
Definition: Constants.cpp:403
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Definition: Constants.cpp:356
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
A debug info location.
Definition: DebugLoc.h:33
static ExtractElementInst * Create(Value *Vec, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static ExtractValueInst * Create(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Convenience struct for specifying and reasoning about fast-math flags.
Definition: FMF.h:20
void clear()
Definition: FMF.h:61
An instruction for ordering other memory operations.
Definition: Instructions.h:436
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...
Definition: DerivedTypes.h:168
Class to represent function types.
Definition: DerivedTypes.h:103
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
Definition: Instructions.h:989
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Definition: Instructions.h:966
Type * getValueType() const
Definition: GlobalValue.h:292
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:243
InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
Creates a new insertion point at the given location.
Definition: IRBuilder.h:252
BasicBlock * getBlock() const
Definition: IRBuilder.h:258
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:256
BasicBlock::iterator getPoint() const
Definition: IRBuilder.h:259
OperandBundlesGuard(const OperandBundlesGuard &)=delete
OperandBundlesGuard & operator=(const OperandBundlesGuard &)=delete
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:94
Value * CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1391
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2107
CallInst * CreateElementUnorderedAtomicMemCpy(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memcpy between the specified pointers.
Definition: IRBuilder.cpp:256
Value * CreateFCmpONE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2276
Value * CreateFAddFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Definition: IRBuilder.h:1538
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Definition: IRBuilder.h:447
Value * CreateFCmpS(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2346
CallInst * CreateMaskedCompressStore(Value *Val, Value *Ptr, Value *Mask=nullptr)
Create a call to Masked Compress Store intrinsic.
Definition: IRBuilder.cpp:704
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="")
Definition: IRBuilder.h:1160
BasicBlock * BB
Definition: IRBuilder.h:119
Value * CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1365
CallInst * CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 1 operand which is mangled on its type.
Definition: IRBuilder.cpp:913
Value * CreatePtrDiff(Type *ElemTy, Value *LHS, Value *RHS, const Twine &Name="")
Return the i64 difference between two pointer values, dividing out the size of the pointed-to objects...
Definition: IRBuilder.cpp:1124
CallInst * CreateMulReduce(Value *Src)
Create a vector int mul reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:437
CallInst * CreateFAddReduce(Value *Acc, Value *Src)
Create a sequential vector fadd reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:417
CallInst * CreateMaskedExpandLoad(Type *Ty, Value *Ptr, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Expand Load intrinsic.
Definition: IRBuilder.cpp:686
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2227
Value * CreateConstGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition: IRBuilder.h:1923
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="")
Create a callbr instruction.
Definition: IRBuilder.h:1188
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="")
Definition: IRBuilder.h:1179
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:1993
Value * CreateVScale(Constant *Scaling, const Twine &Name="")
Create a call to llvm.vscale, multiplied by Scaling.
Definition: IRBuilder.cpp:88
RoundingMode DefaultConstrainedRounding
Definition: IRBuilder.h:130
Value * CreateLaunderInvariantGroup(Value *Ptr)
Create a launder.invariant.group intrinsic call.
Definition: IRBuilder.cpp:1135
CallInst * CreateExtractVector(Type *DstType, Value *SrcVec, Value *Idx, const Twine &Name="")
Create a call to the vector.extract intrinsic.
Definition: IRBuilder.h:1028
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1712
Value * CreateFCmpUGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2301
CallInst * CreateMinNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the minnum intrinsic.
Definition: IRBuilder.h:983
Value * CreateInsertElement(Type *VecTy, Value *NewElt, uint64_t Idx, const Twine &Name="")
Definition: IRBuilder.h:2447
Value * CreateFPCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2187
Value * CreateSRem(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1401
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const Twine &Name="")
Definition: IRBuilder.h:1808
Value * CreateFSub(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition: IRBuilder.h:1551
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2331
CatchPadInst * CreateCatchPad(Value *ParentPad, ArrayRef< Value * > Args, const Twine &Name="")
Definition: IRBuilder.h:1239
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2442
Value * CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1442
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID=SyncScope::System)
Definition: IRBuilder.h:1837
CallInst * CreateThreadLocalAddress(Value *Ptr)
Create a call to llvm.threadlocal.address intrinsic.
Definition: IRBuilder.cpp:538
Value * CreateConstGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition: IRBuilder.h:1877
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
Definition: IRBuilder.h:1769
void setDefaultOperandBundles(ArrayRef< OperandBundleDef > OpBundles)
Definition: IRBuilder.h:351
CallInst * CreateStackSave(const Twine &Name="")
Create a call to llvm.stacksave.
Definition: IRBuilder.h:1044
InvokeInst * CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition: IRBuilder.h:1171
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Definition: IRBuilder.h:497
Value * CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Definition: IRBuilder.h:1897
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:667
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition: IRBuilder.h:2493
Value * CreateAnd(ArrayRef< Value * > Ops)
Definition: IRBuilder.h:1480
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:1144
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, Instruction *MDSrc)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
Definition: IRBuilder.h:1120
Value * CreateAnd(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition: IRBuilder.h:1472
void setDefaultFPMathTag(MDNode *FPMathTag)
Set the floating point math metadata to be used.
Definition: IRBuilder.h:294
Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
Definition: IRBuilder.cpp:58
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2411
Value * CreateFMulFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Definition: IRBuilder.h:1592
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...
Definition: IRBuilder.cpp:895
Value * CreateFDiv(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition: IRBuilder.h:1605
CallInst * CreateInsertVector(Type *DstType, Value *SrcVec, Value *SubVec, Value *Idx, const Twine &Name="")
Create a call to the vector.insert intrinsic.
Definition: IRBuilder.h:1036
Value * CreateLShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1437
void clearFastMathFlags()
Clear the fast-math flags.
Definition: IRBuilder.h:291
Value * CreateFSubFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Definition: IRBuilder.h:1565
Value * CreateFDivFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Definition: IRBuilder.h:1619
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2064
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.
Definition: IRBuilder.cpp:783
LoadInst * CreateLoad(Type *Ty, Value *Ptr, bool isVolatile, const Twine &Name="")
Definition: IRBuilder.h:1794
Value * CreateLogicalOr(ArrayRef< Value * > Ops)
Definition: IRBuilder.h:1693
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2430
Value * CreateLogicalOp(Instruction::BinaryOps Opc, Value *Cond1, Value *Cond2, const Twine &Name="")
Definition: IRBuilder.h:1679
IntegerType * getIntNTy(unsigned N)
Fetch the type representing an N-bit integer.
Definition: IRBuilder.h:525
void setDefaultConstrainedExcept(fp::ExceptionBehavior NewExcept)
Set the exception handling to be used with constrained floating point.
Definition: IRBuilder.h:309
Value * CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2235
Value * CreateFPTrunc(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2071
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const char *Name)
Definition: IRBuilder.h:1803
Value * CreateFCmpORD(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2281
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
Definition: IRBuilder.h:545
Constant * CreateGlobalStringPtr(StringRef Str, const Twine &Name="", unsigned AddressSpace=0, Module *M=nullptr)
Same as CreateGlobalString, but return a pointer with "i8*" type instead of a pointer to array of i8.
Definition: IRBuilder.h:1979
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
Definition: IRBuilder.h:2015
Value * CreateFRemFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Definition: IRBuilder.h:1645
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition: IRBuilder.h:1524
UnreachableInst * CreateUnreachable()
Definition: IRBuilder.h:1254
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0, Module *M=nullptr)
Make a new global variable with initializer type i8*.
Definition: IRBuilder.cpp:43
CallInst * CreateLifetimeStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.start intrinsic.
Definition: IRBuilder.cpp:481
CallInst * CreateConstrainedFPCmp(Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R, const Twine &Name="", std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition: IRBuilder.cpp:1070
CallInst * CreateFree(Value *Source, ArrayRef< OperandBundleDef > Bundles=std::nullopt)
Generate the IR for a call to the builtin free function.
Definition: IRBuilder.cpp:353
CallInst * CreateAndReduce(Value *Src)
Create a vector int AND reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:441
Value * CreateVectorSplice(Value *V1, Value *V2, int64_t Imm, const Twine &Name="")
Return a vector splice intrinsic if using scalable vectors, otherwise return a shufflevector.
Definition: IRBuilder.cpp:1184
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2140
void setDefaultConstrainedRounding(RoundingMode NewRounding)
Set the rounding mode handling to be used with constrained floating point.
Definition: IRBuilder.h:319
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Definition: IRBuilder.cpp:1212
Value * CreateFRem(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition: IRBuilder.h:1632
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition: IRBuilder.h:2486
Value * CreateAnd(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition: IRBuilder.h:1476
ConstantInt * getTrue()
Get the constant value for i1 true.
Definition: IRBuilder.h:452
Value * Insert(Value *V, const Twine &Name="") const
Definition: IRBuilder.h:156
LandingPadInst * CreateLandingPad(Type *Ty, unsigned NumClauses, const Twine &Name="")
Definition: IRBuilder.h:2500
CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
Definition: IRBuilder.cpp:930
Value * CreateFNegFMF(Value *V, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Definition: IRBuilder.h:1736
Value * CreatePreserveStructAccessIndex(Type *ElTy, Value *Base, unsigned Index, unsigned FieldIndex, MDNode *DbgInfo)
Definition: IRBuilder.cpp:1280
CallInst * CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue, unsigned Alignment, Value *OffsetValue=nullptr)
Create an assume intrinsic call that represents an alignment assumption on the provided pointer.
Definition: IRBuilder.cpp:1326
CallInst * CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
Definition: IRBuilder.cpp:578
Value * CreateICmpSGE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2239
CallInst * CreateConstrainedFPCall(Function *Callee, ArrayRef< Value * > Args, const Twine &Name="", std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition: IRBuilder.cpp:1082
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.
Definition: IRBuilder.h:586
LLVMContext & Context
Definition: IRBuilder.h:121
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition: IRBuilder.cpp:1108
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:1149
RoundingMode getDefaultConstrainedRounding()
Get the rounding mode handling used with constrained floating point.
Definition: IRBuilder.h:334
Value * CreateFPToUI(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2043
Value * CreateConstGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition: IRBuilder.h:1943
Value * CreateFCmpUNE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2316
BasicBlock::iterator GetInsertPoint() const
Definition: IRBuilder.h:175
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
Definition: IRBuilder.h:1969
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
Definition: IRBuilder.h:1830
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:572
CallBrInst * CreateCallBr(FunctionCallee Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition: IRBuilder.h:1214
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 ...
Definition: IRBuilder.cpp:904
fp::ExceptionBehavior getDefaultConstrainedExcept()
Get the exception handling used with constrained floating point.
Definition: IRBuilder.h:329
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2009
Value * CreateSExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2115
Value * CreateFCmpUGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2296
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2092
Value * CreateTypeSize(Type *DstType, TypeSize Size)
Create an expression which evaluates to the number of units in Size at runtime.
Definition: IRBuilder.cpp:104
CallInst * CreateAddReduce(Value *Src)
Create a vector int add reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:433
Value * CreateFreeze(Value *V, const Twine &Name="")
Definition: IRBuilder.h:2505
BasicBlock::iterator InsertPt
Definition: IRBuilder.h:120
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1428
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:566
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition: IRBuilder.h:512
Value * CreateConstInBoundsGEP1_32(Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition: IRBuilder.h:1887
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
Definition: IRBuilder.h:462
Value * CreateIsNotNeg(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg > -1.
Definition: IRBuilder.h:2529
CatchReturnInst * CreateCatchRet(CatchPadInst *CatchPad, BasicBlock *BB)
Definition: IRBuilder.h:1250
CallInst * CreateConstrainedFPUnroundedBinOp(Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource=nullptr, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition: IRBuilder.cpp:986
CleanupReturnInst * CreateCleanupRet(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB=nullptr)
Definition: IRBuilder.h:1227
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
Definition: IRBuilder.h:1086
Value * CreateNSWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1327
bool getIsFPConstrained()
Query for the use of constrained floating point math.
Definition: IRBuilder.h:306
Value * CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1461
BasicBlock * GetInsertBlock() const
Definition: IRBuilder.h:174
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:711
Type * getHalfTy()
Fetch the type representing a 16-bit floating point value.
Definition: IRBuilder.h:530
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
Definition: IRBuilder.h:297
Value * CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2266
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Definition: IRBuilder.h:212
void SetInsertPointPastAllocas(Function *F)
This specifies that created instructions should inserted at the beginning end of the specified functi...
Definition: IRBuilder.h:206
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
Definition: IRBuilder.h:517
Value * CreateInBoundsGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Definition: IRBuilder.h:1872
CallInst * CreateMemTransferInst(Intrinsic::ID IntrID, Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.cpp:219
Value * CreateNSWMul(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1361
InsertPoint saveAndClearIP()
Returns the current insert point, clearing it in the process.
Definition: IRBuilder.h:268
Value * CreateOr(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition: IRBuilder.h:1494
CallInst * CreateCopySign(Value *LHS, Value *RHS, Instruction *FMFSource=nullptr, const Twine &Name="")
Create call to the copysign intrinsic.
Definition: IRBuilder.h:1013
Value * CreatePointerBitCastOrAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2152
Value * CreateUIToFP(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2057
Value * CreateVectorReverse(Value *V, const Twine &Name="")
Return a vector value that contains the vector V reversed.
Definition: IRBuilder.cpp:1168
Value * CreateShuffleVector(Value *V, ArrayRef< int > Mask, const Twine &Name="")
Create a unary shuffle.
Definition: IRBuilder.h:2481
CallInst * CreateXorReduce(Value *Src)
Create a vector int XOR reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:449
Value * CreateAShr(Value *LHS, const APInt &RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1456
Value * CreateUDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1369
Value * CreateFCmpULE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2311
FastMathFlags FMF
Definition: IRBuilder.h:126
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2215
Value * CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1331
IntegerType * getInt16Ty()
Fetch the type representing a 16-bit integer.
Definition: IRBuilder.h:507
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Definition: IRBuilder.h:477
CatchSwitchInst * CreateCatchSwitch(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, const Twine &Name="")
Definition: IRBuilder.h:1232
Value * getAllOnesMask(ElementCount NumElts)
Return an all true boolean vector (mask) with NumElts lanes.
Definition: IRBuilder.h:839
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1749
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const Twine &Name="")
Definition: IRBuilder.h:1790
CallInst * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:445
CallInst * CreateMalloc(Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize, ArrayRef< OperandBundleDef > OpB, Function *MallocF=nullptr, const Twine &Name="")
Definition: IRBuilder.cpp:301
InsertPoint saveIP() const
Returns the current insert point.
Definition: IRBuilder.h:263
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:219
CallInst * CreateFPMinReduce(Value *Src)
Create a vector float min reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:469
CallInst * CreateFPMaximumReduce(Value *Src)
Create a vector float maximum reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:473
Value * CreateInsertElement(Value *Vec, Value *NewElt, uint64_t Idx, const Twine &Name="")
Definition: IRBuilder.h:2459
Value * CreateShl(Value *LHS, uint64_t RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1422
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:2472
ReturnInst * CreateAggregateRet(Value *const *retVals, unsigned N)
Create a sequence of N insertvalue instructions, with one Value from the retVals array each,...
Definition: IRBuilder.h:1097
Value * createIsFPClass(Value *FPNum, unsigned Test)
Definition: IRBuilder.cpp:1307
Value * CreateFCmpOLE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2271
CallInst * CreateFPMaxReduce(Value *Src)
Create a vector float max reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:465
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:472
CallInst * CreateCall(FunctionCallee Callee, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2404
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2175
Value * CreateCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2336
const IRBuilderDefaultInserter & Inserter
Definition: IRBuilder.h:123
Value * CreateICmpSLE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2247
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Definition: IRBuilder.h:2367
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2393
Value * CreateNot(Value *V, const Twine &Name="")
Definition: IRBuilder.h:1745
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:1134
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2211
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Definition: IRBuilder.h:145
CallInst * CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maxnum intrinsic.
Definition: IRBuilder.h:993
CallInst * CreateConstrainedFPBinOp(Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource=nullptr, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition: IRBuilder.cpp:967
Value * CreateFCmpUEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2291
void setIsFPConstrained(bool IsCon)
Enable/Disable use of constrained floating point math.
Definition: IRBuilder.h:303
DebugLoc getCurrentDebugLocation() const
Get location information used by debugging information.
Definition: IRBuilder.cpp:63
IntegerType * getInt128Ty()
Fetch the type representing a 128-bit integer.
Definition: IRBuilder.h:522
Value * CreateIsNeg(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg < 0.
Definition: IRBuilder.h:2524
Constant * Insert(Constant *C, const Twine &="") const
No-op overload to handle constants.
Definition: IRBuilder.h:152
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1335
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2097
ConstantInt * getIntN(unsigned N, uint64_t C)
Get a constant N-bit value, zero extended or truncated from a 64-bit value.
Definition: IRBuilder.h:483
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
Definition: IRBuilder.h:1111
IRBuilderBase(LLVMContext &context, const IRBuilderFolder &Folder, const IRBuilderDefaultInserter &Inserter, MDNode *FPMathTag, ArrayRef< OperandBundleDef > OpBundles)
Definition: IRBuilder.h:135
void AddMetadataToInst(Instruction *I) const
Add all entries in MetadataToCopy to I.
Definition: IRBuilder.h:233
Value * CreateICmpUGT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2219
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:1786
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1407
FastMathFlags getFastMathFlags() const
Get the flags to be applied to created floating point ops.
Definition: IRBuilder.h:286
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
Definition: IRBuilder.h:560
Value * CreateNAryOp(unsigned Opc, ArrayRef< Value * > Ops, const Twine &Name="", MDNode *FPMathTag=nullptr)
Create either a UnaryOperator or BinaryOperator depending on Opc.
Definition: IRBuilder.cpp:1003
CallInst * CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Instruction *FMFSource=nullptr, const Twine &Name="")
Create a call to intrinsic ID with 2 operands which is mangled on the first type.
Definition: IRBuilder.cpp:921
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)
Definition: IRBuilder.h:1997
CallInst * CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, Value *Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:679
CallInst * CreateAssumption(Value *Cond, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
Definition: IRBuilder.cpp:551
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Definition: IRBuilder.h:2464
LLVMContext & getContext() const
Definition: IRBuilder.h:176
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2251
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1466
FastMathFlags & getFastMathFlags()
Definition: IRBuilder.h:288
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
Definition: IRBuilder.h:1081
Value * CreateNSWSub(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1344
Value * CreateConstInBoundsGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
Definition: IRBuilder.h:1910
Value * CreateConstInBoundsGEP2_64(Type *Ty, Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Definition: IRBuilder.h:1956
Value * CreatePreserveUnionAccessIndex(Value *Base, unsigned FieldIndex, MDNode *DbgInfo)
Definition: IRBuilder.cpp:1261
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Definition: IRBuilder.h:1799
CallInst * CreateIntMaxReduce(Value *Src, bool IsSigned=false)
Create a vector integer max reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:453
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, Value *Mask)
Create a call to Masked Store intrinsic.
Definition: IRBuilder.cpp:598
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1318
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2087
Value * CreateSDiv(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1382
ConstantInt * getFalse()
Get the constant value for i1 false.
Definition: IRBuilder.h:457
VAArgInst * CreateVAArg(Value *List, Type *Ty, const Twine &Name="")
Definition: IRBuilder.h:2426
Value * CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1378
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
Definition: IRBuilder.h:540
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg != 0.
Definition: IRBuilder.h:2519
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP)
This specifies that created instructions should be inserted at the specified point.
Definition: IRBuilder.h:196
Instruction * CreateNoAliasScopeDeclaration(MDNode *ScopeTag)
Definition: IRBuilder.h:855
Value * CreateShl(Value *LHS, const APInt &RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1416
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Definition: IRBuilder.h:1850
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 ...
Definition: IRBuilder.cpp:872
CleanupPadInst * CreateCleanupPad(Value *ParentPad, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="")
Definition: IRBuilder.h:1244
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.end intrinsic.
Definition: IRBuilder.cpp:496
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1488
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Definition: IRBuilder.h:555
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1657
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
Definition: IRBuilder.h:1105
Value * CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name="")
Definition: IRBuilder.h:1667
Value * CreateElementCount(Type *DstType, ElementCount EC)
Create an expression which evaluates to the number of elements in EC at runtime.
Definition: IRBuilder.cpp:99
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2452
Value * CreateConstInBoundsGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
Definition: IRBuilder.h:1933
fp::ExceptionBehavior DefaultConstrainedExcept
Definition: IRBuilder.h:129
CallInst * CreateConstrainedFPCast(Intrinsic::ID ID, Value *V, Type *DestTy, Instruction *FMFSource=nullptr, const Twine &Name="", MDNode *FPMathTag=nullptr, std::optional< RoundingMode > Rounding=std::nullopt, std::optional< fp::ExceptionBehavior > Except=std::nullopt)
Definition: IRBuilder.cpp:1018
void ClearInsertionPoint()
Clear the insertion point: created instructions will not be inserted into a block.
Definition: IRBuilder.h:169
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2243
ConstantInt * getInt16(uint16_t C)
Get a constant 16-bit value.
Definition: IRBuilder.h:467
MDNode * DefaultFPMathTag
Definition: IRBuilder.h:125
CallInst * CreateElementUnorderedAtomicMemMove(Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memmove between the specified pointers.
Definition: IRBuilder.cpp:372
ArrayRef< OperandBundleDef > DefaultOperandBundles
Definition: IRBuilder.h:132
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2131
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Definition: IRBuilder.h:1196
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2223
MDNode * getDefaultFPMathTag() const
Get the floating point math metadata being used.
Definition: IRBuilder.h:283
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
Definition: IRBuilder.h:2166
Value * CreateFCmpUNO(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2286
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
Definition: IRBuilder.h:275
Value * CreateIsNull(Value *Arg, const Twine &Name="")
Return a boolean value testing if Arg == 0.
Definition: IRBuilder.h:2514
Value * CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2256
CallInst * CreateStackRestore(Value *Ptr, const Twine &Name="")
Create a call to llvm.stackrestore.
Definition: IRBuilder.h:1051
CallInst * CreateIntMinReduce(Value *Src, bool IsSigned=false)
Create a vector integer min reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:459
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Definition: IRBuilder.h:180
Type * getVoidTy()
Fetch the type representing void.
Definition: IRBuilder.h:550
Value * CreateOr(ArrayRef< Value * > Ops)
Definition: IRBuilder.h:1502
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="")
Definition: IRBuilder.h:1776
Value * CreateExtractElement(Value *Vec, uint64_t Idx, const Twine &Name="")
Definition: IRBuilder.h:2437
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)
Definition: IRBuilder.h:1822
Value * CreateOr(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition: IRBuilder.h:1498
void setConstrainedFPCallAttr(CallBase *I)
Definition: IRBuilder.h:347
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.
Definition: IRBuilder.cpp:839
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2382
CallBrInst * CreateCallBr(FunctionCallee Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="")
Definition: IRBuilder.h:1207
const IRBuilderFolder & Folder
Definition: IRBuilder.h:122
Value * CreateIntCast(Value *, Type *, const char *)=delete
CallInst * CreateMinimum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the minimum intrinsic.
Definition: IRBuilder.h:1003
CallInst * CreateMemSetInline(Value *Dst, MaybeAlign DstAlign, Value *Val, Value *Size, bool IsVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.cpp:164
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
Definition: IRBuilder.h:1447
CallInst * CreateElementUnorderedAtomicMemSet(Value *Ptr, Value *Val, uint64_t Size, Align Alignment, uint32_t ElementSize, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert an element unordered-atomic memset of the region of memory starting at the given po...
Definition: IRBuilder.h:611
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2080
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1510
CallInst * CreateFMulReduce(Value *Acc, Value *Src)
Create a sequential vector fmul reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:425
Value * CreateTruncOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2123
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2231
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", bool IsInBounds=false)
Definition: IRBuilder.h:1862
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2321
Value * CreateLogicalOr(Value *Cond1, Value *Cond2, const Twine &Name="")
Definition: IRBuilder.h:1673
Value * CreateFMul(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Definition: IRBuilder.h:1578
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, bool isVolatile, const Twine &Name="")
Definition: IRBuilder.h:1813
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1726
void setConstrainedFPFunctionAttr()
Definition: IRBuilder.h:338
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
Definition: IRBuilder.cpp:70
void SetInsertPoint(Instruction *I)
This specifies that created instructions should be inserted before the specified instruction.
Definition: IRBuilder.h:187
CallInst * CreateMaximum(Value *LHS, Value *RHS, const Twine &Name="")
Create call to the maximum intrinsic.
Definition: IRBuilder.h:1008
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Definition: IRBuilder.h:502
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
Definition: IRBuilder.h:488
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...
Definition: IRBuilder.cpp:883
Value * CreateURem(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1395
Value * CreateStepVector(Type *DstType, const Twine &Name="")
Creates a vector of type DstType with the linear sequence <0, 1, ...>
Definition: IRBuilder.cpp:109
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
Definition: IRBuilder.h:650
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Definition: IRBuilder.h:702
Value * CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base, unsigned Dimension, unsigned LastIndex, MDNode *DbgInfo)
Definition: IRBuilder.cpp:1232
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
Definition: IRBuilder.h:2030
ResumeInst * CreateResume(Value *Exn)
Definition: IRBuilder.h:1223
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2102
Type * getBFloatTy()
Fetch the type representing a 16-bit brain floating point value.
Definition: IRBuilder.h:535
Value * CreateXor(Value *LHS, const APInt &RHS, const Twine &Name="")
Definition: IRBuilder.h:1516
CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
Definition: IRBuilder.cpp:511
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1352
Instruction * CreateNoAliasScopeDeclaration(Value *Scope)
Create a llvm.experimental.noalias.scope.decl intrinsic call.
Definition: IRBuilder.cpp:562
CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
Definition: IRBuilder.cpp:661
Value * CreateXor(Value *LHS, uint64_t RHS, const Twine &Name="")
Definition: IRBuilder.h:1520
Value * CreateNSWNeg(Value *V, const Twine &Name="")
Definition: IRBuilder.h:1718
CallInst * CreateFPMinimumReduce(Value *Src)
Create a vector float minimum reduction intrinsic of the source vector.
Definition: IRBuilder.cpp:477
Value * CreateFCmpOGE(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2261
Value * CreateStripInvariantGroup(Value *Ptr)
Create a strip.invariant.group intrinsic call.
Definition: IRBuilder.cpp:1151
CallInst * CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
Definition: IRBuilder.cpp:630
Value * CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:1348
Value * CreateFCmpULT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2306
CallInst * CreateArithmeticFence(Value *Val, Type *DstType, const Twine &Name="")
Create a call to the arithmetic_fence intrinsic.
Definition: IRBuilder.h:1021
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2050
Value * CreateNUWNeg(Value *V, const Twine &Name="")
Definition: IRBuilder.h:1722
Provides an 'InsertHelper' that calls a user-provided callback after performing the default insertion...
Definition: IRBuilder.h:76
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB, BasicBlock::iterator InsertPt) const override
Definition: IRBuilder.h:85
IRBuilderCallbackInserter(std::function< void(Instruction *)> Callback)
Definition: IRBuilder.h:82
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 *BB, BasicBlock::iterator InsertPt) const
Definition: IRBuilder.h:65
IRBuilderFolder - Interface for constant folding in IRBuilder.
virtual Value * FoldUnOpFMF(Instruction::UnaryOps Opc, Value *V, FastMathFlags FMF) const =0
virtual Value * FoldBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS) const =0
virtual Value * FoldBinOpFMF(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, FastMathFlags FMF) const =0
virtual Value * FoldICmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const =0
virtual Value * FoldShuffleVector(Value *V1, Value *V2, ArrayRef< int > Mask) const =0
virtual Value * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const =0
virtual Value * FoldInsertElement(Value *Vec, Value *NewElt, Value *Idx) const =0
virtual Value * CreatePointerCast(Constant *C, Type *DestTy) const =0
virtual Value * FoldCast(Instruction::CastOps Op, Value *V, Type *DestTy) const =0
virtual Value * FoldExtractElement(Value *Vec, Value *Idx) const =0
virtual Value * FoldExactBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool IsExact) const =0
virtual Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, bool IsInBounds=false) const =0
virtual Value * FoldInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > IdxList) const =0
virtual Value * FoldNoWrapBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool HasNUW, bool HasNSW) const =0
virtual Value * FoldExtractValue(Value *Agg, ArrayRef< unsigned > IdxList) const =0
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2636
IRBuilder(const IRBuilder &)=delete
Avoid copying the full IRBuilder.
IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter=InserterTy(), MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Definition: IRBuilder.h:2642
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Definition: IRBuilder.h:2675
IRBuilder(Instruction *IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Definition: IRBuilder.h:2668
IRBuilder(LLVMContext &C, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Definition: IRBuilder.h:2648
InserterTy & getInserter()
Definition: IRBuilder.h:2696
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Definition: IRBuilder.h:2684
IRBuilder(BasicBlock *TheBB, FolderTy Folder, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Definition: IRBuilder.h:2652
IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag=nullptr, ArrayRef< OperandBundleDef > OpBundles=std::nullopt)
Definition: IRBuilder.h:2661
Indirect Branch Instruction.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, Instruction *InsertBefore=nullptr)
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
FastMathFlags getFastMathFlags() const LLVM_READONLY
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
Class to represent integer types.
Definition: DerivedTypes.h:40
Invoke instruction.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
The landingpad instruction holds all of the information necessary to generate correct exception handl...
static LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
An instruction for reading from memory.
Definition: Instructions.h:177
Metadata node.
Definition: Metadata.h:1037
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:559
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:103
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.h:275
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Class to represent pointers.
Definition: DerivedTypes.h:646
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1743
Resume the propagation of an exception.
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=nullptr)
Return a value (possibly void), from a function.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *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.
Definition: SmallVector.h:1200
An instruction for storing to memory.
Definition: Instructions.h:301
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Multiway switch.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=nullptr)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
static Type * getBFloatTy(LLVMContext &C)