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