LLVM 24.0.0git
IntrinsicInst.h
Go to the documentation of this file.
1//===-- llvm/IntrinsicInst.h - Intrinsic Instruction Wrappers ---*- 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 classes that make it really easy to deal with intrinsic
10// functions with the isa/dyncast family of functions. In particular, this
11// allows you to do things like:
12//
13// if (MemCpyInst *MCI = dyn_cast<MemCpyInst>(Inst))
14// ... MCI->getDest() ... MCI->getSource() ...
15//
16// All intrinsic function calls are instances of the call instruction, so these
17// are all subclasses of the CallInst class. Note that none of these classes
18// has state or virtual methods, which is an important part of this gross/neat
19// hack working.
20//
21//===----------------------------------------------------------------------===//
22
23#ifndef LLVM_IR_INTRINSICINST_H
24#define LLVM_IR_INTRINSICINST_H
25
26#include "llvm/IR/Constants.h"
29#include "llvm/IR/FPEnv.h"
30#include "llvm/IR/Function.h"
33#include "llvm/IR/Intrinsics.h"
34#include "llvm/IR/Value.h"
38#include <cassert>
39#include <cstdint>
40#include <optional>
41
42namespace llvm {
43
44class Metadata;
45
46/// A wrapper class for inspecting calls to intrinsic functions.
47/// This allows the standard isa/dyncast/cast functionality to work with calls
48/// to intrinsic functions.
49class IntrinsicInst : public CallInst {
50public:
51 IntrinsicInst() = delete;
52 IntrinsicInst(const IntrinsicInst &) = delete;
54
55 /// Return the intrinsic ID of this intrinsic.
57 return cast<Function>(getCalledOperand())->getIntrinsicID();
58 }
59
60 bool isAssociative() const {
61 switch (getIntrinsicID()) {
62 case Intrinsic::smax:
63 case Intrinsic::smin:
64 case Intrinsic::umax:
65 case Intrinsic::umin:
66 return true;
67 default:
68 return false;
69 }
70 }
71
72 /// Return true if swapping the first two arguments to the intrinsic produces
73 /// the same result.
74 bool isCommutative() const {
75 switch (getIntrinsicID()) {
76 case Intrinsic::maxnum:
77 case Intrinsic::minnum:
78 case Intrinsic::maximum:
79 case Intrinsic::minimum:
80 case Intrinsic::maximumnum:
81 case Intrinsic::minimumnum:
82 case Intrinsic::smax:
83 case Intrinsic::smin:
84 case Intrinsic::umax:
85 case Intrinsic::umin:
86 case Intrinsic::sadd_sat:
87 case Intrinsic::uadd_sat:
88 case Intrinsic::sadd_with_overflow:
89 case Intrinsic::uadd_with_overflow:
90 case Intrinsic::smul_with_overflow:
91 case Intrinsic::umul_with_overflow:
92 case Intrinsic::smul_fix:
93 case Intrinsic::umul_fix:
94 case Intrinsic::smul_fix_sat:
95 case Intrinsic::umul_fix_sat:
96 case Intrinsic::smulh:
97 case Intrinsic::umulh:
98 case Intrinsic::fma:
99 case Intrinsic::fmuladd:
100 return true;
101 default:
102 return false;
103 }
104 }
105
106 /// Return true if the operand is commutable.
107 bool isCommutableOperand(unsigned Op) const {
108 constexpr unsigned NumCommutativeOps = 2;
109 return isCommutative() && Op < NumCommutativeOps;
110 }
111
112 /// Checks if the intrinsic is an annotation.
114 switch (getIntrinsicID()) {
115 default: break;
116 case Intrinsic::assume:
117 case Intrinsic::sideeffect:
118 case Intrinsic::pseudoprobe:
119 case Intrinsic::dbg_assign:
120 case Intrinsic::dbg_declare:
121 case Intrinsic::dbg_value:
122 case Intrinsic::dbg_label:
123 case Intrinsic::invariant_start:
124 case Intrinsic::invariant_end:
125 case Intrinsic::lifetime_start:
126 case Intrinsic::lifetime_end:
127 case Intrinsic::experimental_noalias_scope_decl:
128 case Intrinsic::objectsize:
129 case Intrinsic::ptr_annotation:
130 case Intrinsic::var_annotation:
131 return true;
132 }
133 return false;
134 }
135
136 /// Check if the intrinsic might lower into a regular function call in the
137 /// course of IR transformations
139
140 /// Methods for support type inquiry through isa, cast, and dyn_cast:
141 static bool classof(const CallInst *I) {
142 auto *F = dyn_cast_or_null<Function>(I->getCalledOperand());
143 return F && F->isIntrinsic();
144 }
145 static bool classof(const Value *V) {
146 return isa<CallInst>(V) && classof(cast<CallInst>(V));
147 }
148};
149
150/// Check if \p ID corresponds to a lifetime intrinsic.
151static inline bool isLifetimeIntrinsic(Intrinsic::ID ID) {
152 switch (ID) {
153 case Intrinsic::lifetime_start:
154 case Intrinsic::lifetime_end:
155 return true;
156 default:
157 return false;
158 }
159}
160
161/// This is the common base class for lifetime intrinsics.
163public:
164 /// \name Casting methods
165 /// @{
166 static bool classof(const IntrinsicInst *I) {
167 return isLifetimeIntrinsic(I->getIntrinsicID());
168 }
169 static bool classof(const Value *V) {
171 }
172 /// @}
173};
174
175/// Check if \p ID corresponds to a debug info intrinsic.
176static inline bool isDbgInfoIntrinsic(Intrinsic::ID ID) {
177 switch (ID) {
178 case Intrinsic::dbg_declare:
179 case Intrinsic::dbg_value:
180 case Intrinsic::dbg_label:
181 case Intrinsic::dbg_assign:
182 return true;
183 default:
184 return false;
185 }
186}
187
188/// This is the common base class for debug info intrinsics.
190public:
191 /// \name Casting methods
192 /// @{
193 static bool classof(const IntrinsicInst *I) {
194 return isDbgInfoIntrinsic(I->getIntrinsicID());
195 }
196 static bool classof(const Value *V) {
198 }
199 /// @}
200};
201
202// Iterator for ValueAsMetadata that internally uses direct pointer iteration
203// over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the
204// ValueAsMetadata .
206 : public iterator_facade_base<location_op_iterator,
207 std::bidirectional_iterator_tag, Value *> {
209
210public:
211 location_op_iterator(ValueAsMetadata *SingleIter) : I(SingleIter) {}
212 location_op_iterator(ValueAsMetadata **MultiIter) : I(MultiIter) {}
213
216 I = R.I;
217 return *this;
218 }
219 bool operator==(const location_op_iterator &RHS) const { return I == RHS.I; }
220 const Value *operator*() const {
224 return VAM->getValue();
225 };
234 I = cast<ValueAsMetadata *>(I) + 1;
235 else
236 I = cast<ValueAsMetadata **>(I) + 1;
237 return *this;
238 }
241 I = cast<ValueAsMetadata *>(I) - 1;
242 else
243 I = cast<ValueAsMetadata **>(I) - 1;
244 return *this;
245 }
246};
247
248/// Lightweight class that wraps the location operand metadata of a debug
249/// intrinsic. The raw location may be a ValueAsMetadata, an empty MDTuple,
250/// or a DIArgList.
252 Metadata *RawLocation = nullptr;
253
254public:
256 explicit RawLocationWrapper(Metadata *RawLocation)
257 : RawLocation(RawLocation) {
258 // Allow ValueAsMetadata, empty MDTuple, DIArgList.
259 assert(RawLocation && "unexpected null RawLocation");
260 assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
261 (isa<MDNode>(RawLocation) &&
262 !cast<MDNode>(RawLocation)->getNumOperands()));
263 }
264 Metadata *getRawLocation() const { return RawLocation; }
265 /// Get the locations corresponding to the variable referenced by the debug
266 /// info intrinsic. Depending on the intrinsic, this could be the
267 /// variable's value or its address.
269 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
270 unsigned getNumVariableLocationOps() const {
271 if (hasArgList())
272 return cast<DIArgList>(getRawLocation())->getArgs().size();
273 return 1;
274 }
275 bool hasArgList() const { return isa<DIArgList>(getRawLocation()); }
277 // Check for "kill" sentinel values.
278 // Non-variadic: empty metadata.
280 return true;
281 // Variadic: empty DIArgList with empty expression.
282 if (getNumVariableLocationOps() == 0 && !Expression->isComplex())
283 return true;
284 // Variadic and non-variadic: Interpret expressions using undef or poison
285 // values as kills.
286 return any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
287 }
288
289 friend bool operator==(const RawLocationWrapper &A,
290 const RawLocationWrapper &B) {
291 return A.RawLocation == B.RawLocation;
292 }
293 friend bool operator!=(const RawLocationWrapper &A,
294 const RawLocationWrapper &B) {
295 return !(A == B);
296 }
297 friend bool operator>(const RawLocationWrapper &A,
298 const RawLocationWrapper &B) {
299 return A.RawLocation > B.RawLocation;
300 }
301 friend bool operator>=(const RawLocationWrapper &A,
302 const RawLocationWrapper &B) {
303 return A.RawLocation >= B.RawLocation;
304 }
305 friend bool operator<(const RawLocationWrapper &A,
306 const RawLocationWrapper &B) {
307 return A.RawLocation < B.RawLocation;
308 }
309 friend bool operator<=(const RawLocationWrapper &A,
310 const RawLocationWrapper &B) {
311 return A.RawLocation <= B.RawLocation;
312 }
313};
314
315/// This is the common base class for debug info intrinsics for variables.
317public:
318 /// Get the locations corresponding to the variable referenced by the debug
319 /// info intrinsic. Depending on the intrinsic, this could be the
320 /// variable's value or its address.
322
323 LLVM_ABI Value *getVariableLocationOp(unsigned OpIdx) const;
324
325 LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue,
326 bool AllowEmpty = false);
327
331
335
336 bool hasArgList() const { return getWrappedLocation().hasArgList(); }
337
338 /// Determine if this describes the value of a local variable. It is true for
339 /// dbg.value, but false for dbg.declare, which describes its address, and
340 /// false for dbg.assign, which describes a combination of the variable's
341 /// value and address.
342 bool isValueOfVariable() const {
343 return getIntrinsicID() == Intrinsic::dbg_value;
344 }
345
346 bool isKillLocation() const {
348 }
349
353
357
359 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
360 }
361
365
367 return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
368 }
369
371 return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
372 }
373
374 /// Get the size (in bits) of the variable, or fragment of the variable that
375 /// is described.
376 LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
377
378 /// Get the FragmentInfo for the variable.
379 std::optional<DIExpression::FragmentInfo> getFragment() const {
380 return getExpression()->getFragmentInfo();
381 }
382
383 /// Get the FragmentInfo for the variable if it exists, otherwise return a
384 /// FragmentInfo that covers the entire variable if the variable size is
385 /// known, otherwise return a zero-sized fragment.
387 DIExpression::FragmentInfo VariableSlice(0, 0);
388 // Get the fragment or variable size, or zero.
389 if (auto Sz = getFragmentSizeInBits())
390 VariableSlice.SizeInBits = *Sz;
391 if (auto Frag = getExpression()->getFragmentInfo())
392 VariableSlice.OffsetInBits = Frag->OffsetInBits;
393 return VariableSlice;
394 }
395
396 /// \name Casting methods
397 /// @{
398 static bool classof(const IntrinsicInst *I) {
399 switch (I->getIntrinsicID()) {
400 case Intrinsic::dbg_declare:
401 case Intrinsic::dbg_value:
402 case Intrinsic::dbg_assign:
403 return true;
404 default:
405 return false;
406 }
407 }
408 static bool classof(const Value *V) {
410 }
411 /// @}
412protected:
413 void setArgOperand(unsigned i, Value *v) {
415 }
416 void setOperand(unsigned i, Value *v) { DbgInfoIntrinsic::setOperand(i, v); }
417};
418
419/// This represents the llvm.dbg.declare instruction.
421public:
422 Value *getAddress() const {
424 "dbg.declare must have exactly 1 location operand.");
425 return getVariableLocationOp(0);
426 }
427
428 /// \name Casting methods
429 /// @{
430 static bool classof(const IntrinsicInst *I) {
431 return I->getIntrinsicID() == Intrinsic::dbg_declare;
432 }
433 static bool classof(const Value *V) {
435 }
436 /// @}
437};
438
439/// This represents the llvm.dbg.value instruction.
441public:
442 // The default argument should only be used in ISel, and the default option
443 // should be removed once ISel support for multiple location ops is complete.
444 Value *getValue(unsigned OpIdx = 0) const {
445 return getVariableLocationOp(OpIdx);
446 }
450
451 /// \name Casting methods
452 /// @{
453 static bool classof(const IntrinsicInst *I) {
454 return I->getIntrinsicID() == Intrinsic::dbg_value ||
455 I->getIntrinsicID() == Intrinsic::dbg_assign;
456 }
457 static bool classof(const Value *V) {
459 }
460 /// @}
461};
462
463/// This represents the llvm.dbg.assign instruction.
465 enum Operands {
466 OpValue,
467 OpVar,
468 OpExpr,
469 OpAssignID,
470 OpAddress,
471 OpAddressExpr,
472 };
473
474public:
475 LLVM_ABI Value *getAddress() const;
477 return cast<MetadataAsValue>(getArgOperand(OpAddress))->getMetadata();
478 }
480 return cast<MetadataAsValue>(getArgOperand(OpAssignID))->getMetadata();
481 }
484 return cast<MetadataAsValue>(getArgOperand(OpAddressExpr))->getMetadata();
485 }
490 LLVM_ABI void setAddress(Value *V);
491 LLVM_ABI void setValue(Value *V);
492 /// \name Casting methods
493 /// @{
494 static bool classof(const IntrinsicInst *I) {
495 return I->getIntrinsicID() == Intrinsic::dbg_assign;
496 }
497 static bool classof(const Value *V) {
499 }
500 /// @}
501};
502
503/// This represents the llvm.dbg.label instruction.
505public:
507
509 return cast<MetadataAsValue>(getArgOperand(0))->getMetadata();
510 }
511
512 /// Methods for support type inquiry through isa, cast, and dyn_cast:
513 /// @{
514 static bool classof(const IntrinsicInst *I) {
515 return I->getIntrinsicID() == Intrinsic::dbg_label;
516 }
517 static bool classof(const Value *V) {
519 }
520 /// @}
521};
522
523/// This is the common base class for vector predication intrinsics.
525public:
526 /// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
527 /// \p Params. Additionally, the load and gather intrinsics require
528 /// \p ReturnType to be specified.
529 LLVM_ABI static Function *
531 ArrayRef<Value *> Params);
532
533 LLVM_ABI static std::optional<unsigned>
534 getMaskParamPos(Intrinsic::ID IntrinsicID);
535 LLVM_ABI static std::optional<unsigned>
537
538 // Whether \p ID is a VP intrinsic ID.
540
541 /// \return The mask parameter or nullptr.
542 LLVM_ABI Value *getMaskParam() const;
544
545 /// \return The vector length parameter or nullptr.
548
549 /// \return Whether the vector length param can be ignored.
551
552 /// \return The static element count (vector number of elements) the vector
553 /// length parameter applies to.
555
556 /// \return The alignment of the pointer used by this load/store/gather or
557 /// scatter.
559 // MaybeAlign setPointerAlignment(Align NewAlign); // TODO
560
561 /// \return The pointer operand of this load,store, gather or scatter.
563 LLVM_ABI static std::optional<unsigned>
565
566 /// \return The data (payload) operand of this store or scatter.
568 LLVM_ABI static std::optional<unsigned> getMemoryDataParamPos(Intrinsic::ID);
569
570 // Methods for support type inquiry through isa, cast, and dyn_cast:
571 static bool classof(const IntrinsicInst *I) {
572 return isVPIntrinsic(I->getIntrinsicID());
573 }
574 static bool classof(const Value *V) {
576 }
577
578 // Equivalent non-predicated opcode
579 std::optional<unsigned> getFunctionalOpcode() const {
581 }
582
583 // Equivalent non-predicated intrinsic ID
584 std::optional<unsigned> getFunctionalIntrinsicID() const {
586 }
587
588 // Equivalent non-predicated opcode
589 LLVM_ABI static std::optional<unsigned>
591
592 // Equivalent non-predicated intrinsic ID
593 LLVM_ABI static std::optional<Intrinsic::ID>
595};
596
597/// This represents vector predication reduction intrinsics.
599public:
600 LLVM_ABI static bool isVPReduction(Intrinsic::ID ID);
601
602 LLVM_ABI unsigned getStartParamPos() const;
603 LLVM_ABI unsigned getVectorParamPos() const;
604
605 LLVM_ABI static std::optional<unsigned> getStartParamPos(Intrinsic::ID ID);
606 LLVM_ABI static std::optional<unsigned> getVectorParamPos(Intrinsic::ID ID);
607
608 /// Methods for support type inquiry through isa, cast, and dyn_cast:
609 /// @{
610 static bool classof(const IntrinsicInst *I) {
611 return VPReductionIntrinsic::isVPReduction(I->getIntrinsicID());
612 }
613 static bool classof(const Value *V) {
615 }
616 /// @}
617};
618
619/// This is the common base class for constrained floating point intrinsics.
621public:
622 LLVM_ABI unsigned getNonMetadataArgCount() const;
623 LLVM_ABI std::optional<RoundingMode> getRoundingMode() const;
624 LLVM_ABI std::optional<fp::ExceptionBehavior> getExceptionBehavior() const;
625 LLVM_ABI bool isDefaultFPEnvironment() const;
626
627 // Methods for support type inquiry through isa, cast, and dyn_cast:
628 LLVM_ABI static bool classof(const IntrinsicInst *I);
629 static bool classof(const Value *V) {
631 }
632};
633
634/// Constrained floating point compare intrinsics.
636public:
638 bool isSignaling() const {
639 return getIntrinsicID() == Intrinsic::experimental_constrained_fcmps;
640 }
641
642 // Methods for support type inquiry through isa, cast, and dyn_cast:
643 static bool classof(const IntrinsicInst *I) {
644 switch (I->getIntrinsicID()) {
645 case Intrinsic::experimental_constrained_fcmp:
646 case Intrinsic::experimental_constrained_fcmps:
647 return true;
648 default:
649 return false;
650 }
651 }
652 static bool classof(const Value *V) {
654 }
655};
656
657/// This class represents min/max intrinsics.
659public:
660 static bool classof(const IntrinsicInst *I) {
661 switch (I->getIntrinsicID()) {
662 case Intrinsic::umin:
663 case Intrinsic::umax:
664 case Intrinsic::smin:
665 case Intrinsic::smax:
666 return true;
667 default:
668 return false;
669 }
670 }
671 static bool classof(const Value *V) {
673 }
674
675 Value *getLHS() const { return getArgOperand(0); }
676 Value *getRHS() const { return getArgOperand(1); }
677
678 /// Returns the comparison predicate underlying the intrinsic.
680 switch (ID) {
681 case Intrinsic::umin:
683 case Intrinsic::umax:
685 case Intrinsic::smin:
687 case Intrinsic::smax:
689 default:
690 llvm_unreachable("Invalid intrinsic");
691 }
692 }
693
694 /// Returns the comparison predicate underlying the intrinsic.
698
699 /// Whether the intrinsic is signed or unsigned.
700 static bool isSigned(Intrinsic::ID ID) {
702 };
703
704 /// Whether the intrinsic is signed or unsigned.
705 bool isSigned() const { return isSigned(getIntrinsicID()); };
706
707 /// Whether the intrinsic is a smin or umin.
708 static bool isMin(Intrinsic::ID ID) {
709 switch (ID) {
710 case Intrinsic::umin:
711 case Intrinsic::smin:
712 return true;
713 case Intrinsic::umax:
714 case Intrinsic::smax:
715 return false;
716 default:
717 llvm_unreachable("Invalid intrinsic");
718 }
719 }
720
721 /// Whether the intrinsic is a smin or a umin.
722 bool isMin() const { return isMin(getIntrinsicID()); }
723
724 /// Whether the intrinsic is a smax or a umax.
725 bool isMax() const { return !isMin(getIntrinsicID()); }
726
727 /// Returns the identity value for this min/max intrinsic, such
728 /// that minmax(X, Identity) == X.
729 static APInt getIdentity(Intrinsic::ID ID, unsigned NumBits) {
730 switch (ID) {
731 case Intrinsic::umin:
732 return APInt::getMaxValue(NumBits);
733 case Intrinsic::umax:
734 return APInt::getMinValue(NumBits);
735 case Intrinsic::smin:
736 return APInt::getSignedMaxValue(NumBits);
737 case Intrinsic::smax:
738 return APInt::getSignedMinValue(NumBits);
739 default:
740 llvm_unreachable("Invalid intrinsic");
741 }
742 }
743
744 /// Returns the identity value for this min/max intrinsic, such
745 /// that minmax(X, Identity) == X.
749
750 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
751 /// so there is a certain threshold value, upon reaching which,
752 /// their value can no longer change. Return said threshold.
753 static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits) {
754 switch (ID) {
755 case Intrinsic::umin:
756 return APInt::getMinValue(numBits);
757 case Intrinsic::umax:
758 return APInt::getMaxValue(numBits);
759 case Intrinsic::smin:
760 return APInt::getSignedMinValue(numBits);
761 case Intrinsic::smax:
762 return APInt::getSignedMaxValue(numBits);
763 default:
764 llvm_unreachable("Invalid intrinsic");
765 }
766 }
767
768 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
769 /// so there is a certain threshold value, upon reaching which,
770 /// their value can no longer change. Return said threshold.
771 APInt getSaturationPoint(unsigned numBits) const {
772 return getSaturationPoint(getIntrinsicID(), numBits);
773 }
774
775 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
776 /// so there is a certain threshold value, upon reaching which,
777 /// their value can no longer change. Return said threshold.
780 Ty, getSaturationPoint(ID, Ty->getScalarSizeInBits()));
781 }
782
783 /// Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values,
784 /// so there is a certain threshold value, upon reaching which,
785 /// their value can no longer change. Return said threshold.
788 }
789};
790
791/// This class represents a ucmp/scmp intrinsic
793public:
794 static bool classof(const IntrinsicInst *I) {
795 switch (I->getIntrinsicID()) {
796 case Intrinsic::scmp:
797 case Intrinsic::ucmp:
798 return true;
799 default:
800 return false;
801 }
802 }
803 static bool classof(const Value *V) {
805 }
806
807 Value *getLHS() const { return getArgOperand(0); }
808 Value *getRHS() const { return getArgOperand(1); }
809
810 static bool isSigned(Intrinsic::ID ID) { return ID == Intrinsic::scmp; }
811 bool isSigned() const { return isSigned(getIntrinsicID()); }
812
819
826};
827
828/// This class represents an intrinsic that is based on a binary operation.
829/// This includes op.with.overflow and saturating add/sub intrinsics.
831public:
832 static bool classof(const IntrinsicInst *I) {
833 switch (I->getIntrinsicID()) {
834 case Intrinsic::uadd_with_overflow:
835 case Intrinsic::sadd_with_overflow:
836 case Intrinsic::usub_with_overflow:
837 case Intrinsic::ssub_with_overflow:
838 case Intrinsic::umul_with_overflow:
839 case Intrinsic::smul_with_overflow:
840 case Intrinsic::uadd_sat:
841 case Intrinsic::sadd_sat:
842 case Intrinsic::usub_sat:
843 case Intrinsic::ssub_sat:
844 return true;
845 default:
846 return false;
847 }
848 }
849 static bool classof(const Value *V) {
851 }
852
853 Value *getLHS() const { return getArgOperand(0); }
854 Value *getRHS() const { return getArgOperand(1); }
855
856 /// Returns the binary operation underlying the intrinsic.
858
859 /// Whether the intrinsic is signed or unsigned.
860 LLVM_ABI bool isSigned() const;
861
862 /// Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
863 LLVM_ABI unsigned getNoWrapKind() const;
864};
865
866/// Represents an op.with.overflow intrinsic.
868public:
869 static bool classof(const IntrinsicInst *I) {
870 switch (I->getIntrinsicID()) {
871 case Intrinsic::uadd_with_overflow:
872 case Intrinsic::sadd_with_overflow:
873 case Intrinsic::usub_with_overflow:
874 case Intrinsic::ssub_with_overflow:
875 case Intrinsic::umul_with_overflow:
876 case Intrinsic::smul_with_overflow:
877 return true;
878 default:
879 return false;
880 }
881 }
882 static bool classof(const Value *V) {
884 }
885};
886
887/// Represents a saturating add/sub intrinsic.
889public:
890 static bool classof(const IntrinsicInst *I) {
891 switch (I->getIntrinsicID()) {
892 case Intrinsic::uadd_sat:
893 case Intrinsic::sadd_sat:
894 case Intrinsic::usub_sat:
895 case Intrinsic::ssub_sat:
896 return true;
897 default:
898 return false;
899 }
900 }
901 static bool classof(const Value *V) {
903 }
904};
905
906/// Common base class for all memory intrinsics. Simply provides
907/// common methods.
908/// Written as CRTP to avoid a common base class amongst the
909/// three atomicity hierarchies.
910template <typename Derived> class MemIntrinsicBase : public IntrinsicInst {
911private:
912 enum { ARG_DEST = 0, ARG_LENGTH = 2 };
913
914public:
915 Value *getRawDest() const {
916 return const_cast<Value *>(getArgOperand(ARG_DEST));
917 }
918 const Use &getRawDestUse() const { return getArgOperandUse(ARG_DEST); }
919 Use &getRawDestUse() { return getArgOperandUse(ARG_DEST); }
920
921 Value *getLength() const {
922 return const_cast<Value *>(getArgOperand(ARG_LENGTH));
923 }
924 const Use &getLengthUse() const { return getArgOperandUse(ARG_LENGTH); }
925 Use &getLengthUse() { return getArgOperandUse(ARG_LENGTH); }
926
927 std::optional<APInt> getLengthInBytes() const {
929 if (!C)
930 return std::nullopt;
931 return C->getValue();
932 }
933
934 /// This is just like getRawDest, but it strips off any cast
935 /// instructions (including addrspacecast) that feed it, giving the
936 /// original input. The returned value is guaranteed to be a pointer.
937 Value *getDest() const { return getRawDest()->stripPointerCasts(); }
938
939 unsigned getDestAddressSpace() const {
940 return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
941 }
942
943 MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
944
945 /// Set the specified arguments of the instruction.
946 void setDest(Value *Ptr) {
947 assert(getRawDest()->getType() == Ptr->getType() &&
948 "setDest called with pointer of wrong type!");
949 setArgOperand(ARG_DEST, Ptr);
950 }
951
952 void setDestAlignment(MaybeAlign Alignment) {
953 removeParamAttr(ARG_DEST, Attribute::Alignment);
954 if (Alignment)
955 addParamAttr(ARG_DEST,
957 }
958 void setDestAlignment(Align Alignment) {
959 removeParamAttr(ARG_DEST, Attribute::Alignment);
960 addParamAttr(ARG_DEST,
962 }
963
964 void setLength(Value *L) {
965 assert(getLength()->getType() == L->getType() &&
966 "setLength called with value of wrong type!");
967 setArgOperand(ARG_LENGTH, L);
968 }
969
971 setLength(ConstantInt::get(getLength()->getType(), L));
972 }
973};
974
975/// Common base class for all memory transfer intrinsics. Simply provides
976/// common methods.
977template <class BaseCL> class MemTransferBase : public BaseCL {
978private:
979 enum { ARG_SOURCE = 1 };
980
981public:
982 /// Return the arguments to the instruction.
984 return const_cast<Value *>(BaseCL::getArgOperand(ARG_SOURCE));
985 }
986 const Use &getRawSourceUse() const {
987 return BaseCL::getArgOperandUse(ARG_SOURCE);
988 }
989 Use &getRawSourceUse() { return BaseCL::getArgOperandUse(ARG_SOURCE); }
990
991 /// This is just like getRawSource, but it strips off any cast
992 /// instructions that feed it, giving the original input. The returned
993 /// value is guaranteed to be a pointer.
995
996 unsigned getSourceAddressSpace() const {
997 return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
998 }
999
1001 return BaseCL::getParamAlign(ARG_SOURCE);
1002 }
1003
1004 void setSource(Value *Ptr) {
1005 assert(getRawSource()->getType() == Ptr->getType() &&
1006 "setSource called with pointer of wrong type!");
1007 BaseCL::setArgOperand(ARG_SOURCE, Ptr);
1008 }
1009
1011 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1012 if (Alignment)
1013 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1014 BaseCL::getContext(), *Alignment));
1015 }
1016
1017 void setSourceAlignment(Align Alignment) {
1018 BaseCL::removeParamAttr(ARG_SOURCE, Attribute::Alignment);
1019 BaseCL::addParamAttr(ARG_SOURCE, Attribute::getWithAlignment(
1020 BaseCL::getContext(), Alignment));
1021 }
1022};
1023
1024/// Common base class for all memset intrinsics. Simply provides
1025/// common methods.
1026template <class BaseCL> class MemSetBase : public BaseCL {
1027private:
1028 enum { ARG_VALUE = 1 };
1029
1030public:
1031 Value *getValue() const {
1032 return const_cast<Value *>(BaseCL::getArgOperand(ARG_VALUE));
1033 }
1034 const Use &getValueUse() const { return BaseCL::getArgOperandUse(ARG_VALUE); }
1035 Use &getValueUse() { return BaseCL::getArgOperandUse(ARG_VALUE); }
1036
1037 void setValue(Value *Val) {
1038 assert(getValue()->getType() == Val->getType() &&
1039 "setValue called with value of wrong type!");
1040 BaseCL::setArgOperand(ARG_VALUE, Val);
1041 }
1042};
1043
1044/// This is the common base class for memset/memcpy/memmove.
1045class MemIntrinsic : public MemIntrinsicBase<MemIntrinsic> {
1046private:
1047 enum { ARG_VOLATILE = 3 };
1048
1049public:
1051 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1052 }
1053
1054 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1055
1056 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1057
1058 bool isForceInlined() const {
1059 switch (getIntrinsicID()) {
1060 case Intrinsic::memset_inline:
1061 case Intrinsic::memcpy_inline:
1062 return true;
1063 default:
1064 return false;
1065 }
1066 }
1067
1068 // Methods for support type inquiry through isa, cast, and dyn_cast:
1069 static bool classof(const IntrinsicInst *I) {
1070 switch (I->getIntrinsicID()) {
1071 case Intrinsic::memcpy:
1072 case Intrinsic::memmove:
1073 case Intrinsic::memset:
1074 case Intrinsic::memset_inline:
1075 case Intrinsic::memcpy_inline:
1076 return true;
1077 default:
1078 return false;
1079 }
1080 }
1081 static bool classof(const Value *V) {
1083 }
1084};
1085
1086/// This class wraps the llvm.memset and llvm.memset.inline intrinsics.
1087class MemSetInst : public MemSetBase<MemIntrinsic> {
1088public:
1089 // Methods for support type inquiry through isa, cast, and dyn_cast:
1090 static bool classof(const IntrinsicInst *I) {
1091 switch (I->getIntrinsicID()) {
1092 case Intrinsic::memset:
1093 case Intrinsic::memset_inline:
1094 return true;
1095 default:
1096 return false;
1097 }
1098 }
1099 static bool classof(const Value *V) {
1101 }
1102};
1103
1104/// This class wraps the llvm.experimental.memset.pattern intrinsic.
1105/// Note that despite the inheritance, this is not part of the
1106/// MemIntrinsic hierachy in terms of isa/cast.
1107class MemSetPatternInst : public MemSetBase<MemIntrinsic> {
1108private:
1109 enum { ARG_VOLATILE = 3 };
1110
1111public:
1113 return cast<ConstantInt>(getArgOperand(ARG_VOLATILE));
1114 }
1115
1116 bool isVolatile() const { return !getVolatileCst()->isZero(); }
1117
1118 void setVolatile(Constant *V) { setArgOperand(ARG_VOLATILE, V); }
1119
1120 // Methods for support type inquiry through isa, cast, and dyn_cast:
1121 static bool classof(const IntrinsicInst *I) {
1122 return I->getIntrinsicID() == Intrinsic::experimental_memset_pattern;
1123 }
1124 static bool classof(const Value *V) {
1126 }
1127};
1128
1129/// This class wraps the llvm.memcpy/memmove intrinsics.
1130class MemTransferInst : public MemTransferBase<MemIntrinsic> {
1131public:
1132 // Methods for support type inquiry through isa, cast, and dyn_cast:
1133 static bool classof(const IntrinsicInst *I) {
1134 switch (I->getIntrinsicID()) {
1135 case Intrinsic::memcpy:
1136 case Intrinsic::memmove:
1137 case Intrinsic::memcpy_inline:
1138 return true;
1139 default:
1140 return false;
1141 }
1142 }
1143 static bool classof(const Value *V) {
1145 }
1146};
1147
1148/// This class wraps the llvm.memcpy intrinsic.
1150public:
1151 // Methods for support type inquiry through isa, cast, and dyn_cast:
1152 static bool classof(const IntrinsicInst *I) {
1153 return I->getIntrinsicID() == Intrinsic::memcpy ||
1154 I->getIntrinsicID() == Intrinsic::memcpy_inline;
1155 }
1156 static bool classof(const Value *V) {
1158 }
1159};
1160
1161/// This class wraps the llvm.memmove intrinsic.
1163public:
1164 // Methods for support type inquiry through isa, cast, and dyn_cast:
1165 static bool classof(const IntrinsicInst *I) {
1166 return I->getIntrinsicID() == Intrinsic::memmove;
1167 }
1168 static bool classof(const Value *V) {
1170 }
1171};
1172
1173// The common base class for any memset/memmove/memcpy intrinsics;
1174// whether they be atomic or non-atomic.
1175// i.e. llvm.element.unordered.atomic.memset/memcpy/memmove
1176// and llvm.memset/memcpy/memmove
1177class AnyMemIntrinsic : public MemIntrinsicBase<AnyMemIntrinsic> {
1178private:
1179 enum { ARG_ELEMENTSIZE = 3 };
1180
1181public:
1182 bool isVolatile() const {
1183 // Only the non-atomic intrinsics can be volatile
1184 if (auto *MI = dyn_cast<MemIntrinsic>(this))
1185 return MI->isVolatile();
1186 return false;
1187 }
1188
1189 bool isAtomic() const {
1190 switch (getIntrinsicID()) {
1191 case Intrinsic::memcpy_element_unordered_atomic:
1192 case Intrinsic::memmove_element_unordered_atomic:
1193 case Intrinsic::memset_element_unordered_atomic:
1194 return true;
1195 default:
1196 return false;
1197 }
1198 }
1199
1200 static bool classof(const IntrinsicInst *I) {
1201 switch (I->getIntrinsicID()) {
1202 case Intrinsic::memcpy:
1203 case Intrinsic::memcpy_inline:
1204 case Intrinsic::memmove:
1205 case Intrinsic::memset:
1206 case Intrinsic::memset_inline:
1207 case Intrinsic::memcpy_element_unordered_atomic:
1208 case Intrinsic::memmove_element_unordered_atomic:
1209 case Intrinsic::memset_element_unordered_atomic:
1210 return true;
1211 default:
1212 return false;
1213 }
1214 }
1215 static bool classof(const Value *V) {
1217 }
1218
1220 assert(isAtomic());
1221 return getArgOperand(ARG_ELEMENTSIZE);
1222 }
1223
1225 assert(isAtomic());
1226 return cast<ConstantInt>(getRawElementSizeInBytes())->getZExtValue();
1227 }
1228};
1229
1230/// This class represents any memset intrinsic
1231// i.e. llvm.element.unordered.atomic.memset
1232// and llvm.memset
1233class AnyMemSetInst : public MemSetBase<AnyMemIntrinsic> {
1234public:
1235 static bool classof(const IntrinsicInst *I) {
1236 switch (I->getIntrinsicID()) {
1237 case Intrinsic::memset:
1238 case Intrinsic::memset_inline:
1239 case Intrinsic::memset_element_unordered_atomic:
1240 return true;
1241 default:
1242 return false;
1243 }
1244 }
1245 static bool classof(const Value *V) {
1247 }
1248};
1249
1250// This class wraps any memcpy/memmove intrinsics
1251// i.e. llvm.element.unordered.atomic.memcpy/memmove
1252// and llvm.memcpy/memmove
1253class AnyMemTransferInst : public MemTransferBase<AnyMemIntrinsic> {
1254public:
1255 static bool classof(const IntrinsicInst *I) {
1256 switch (I->getIntrinsicID()) {
1257 case Intrinsic::memcpy:
1258 case Intrinsic::memcpy_inline:
1259 case Intrinsic::memmove:
1260 case Intrinsic::memcpy_element_unordered_atomic:
1261 case Intrinsic::memmove_element_unordered_atomic:
1262 return true;
1263 default:
1264 return false;
1265 }
1266 }
1267 static bool classof(const Value *V) {
1269 }
1270};
1271
1272/// This class represents any memcpy intrinsic
1273/// i.e. llvm.element.unordered.atomic.memcpy
1274/// and llvm.memcpy
1276public:
1277 static bool classof(const IntrinsicInst *I) {
1278 switch (I->getIntrinsicID()) {
1279 case Intrinsic::memcpy:
1280 case Intrinsic::memcpy_inline:
1281 case Intrinsic::memcpy_element_unordered_atomic:
1282 return true;
1283 default:
1284 return false;
1285 }
1286 }
1287 static bool classof(const Value *V) {
1289 }
1290};
1291
1292/// This class represents any memmove intrinsic
1293/// i.e. llvm.element.unordered.atomic.memmove
1294/// and llvm.memmove
1296public:
1297 static bool classof(const IntrinsicInst *I) {
1298 switch (I->getIntrinsicID()) {
1299 case Intrinsic::memmove:
1300 case Intrinsic::memmove_element_unordered_atomic:
1301 return true;
1302 default:
1303 return false;
1304 }
1305 }
1306 static bool classof(const Value *V) {
1308 }
1309};
1310
1311/// This represents the llvm.va_start intrinsic.
1313public:
1314 static bool classof(const IntrinsicInst *I) {
1315 return I->getIntrinsicID() == Intrinsic::vastart;
1316 }
1317 static bool classof(const Value *V) {
1319 }
1320
1321 Value *getArgList() const { return getArgOperand(0); }
1322};
1323
1324/// This represents the llvm.va_end intrinsic.
1325class VAEndInst : public IntrinsicInst {
1326public:
1327 static bool classof(const IntrinsicInst *I) {
1328 return I->getIntrinsicID() == Intrinsic::vaend;
1329 }
1330 static bool classof(const Value *V) {
1332 }
1333
1334 Value *getArgList() const { return getArgOperand(0); }
1335};
1336
1337/// This represents the llvm.va_copy intrinsic.
1339public:
1340 static bool classof(const IntrinsicInst *I) {
1341 return I->getIntrinsicID() == Intrinsic::vacopy;
1342 }
1343 static bool classof(const Value *V) {
1345 }
1346
1347 Value *getDest() const { return getArgOperand(0); }
1348 Value *getSrc() const { return getArgOperand(1); }
1349};
1350
1351/// A base class for all instrprof intrinsics.
1353protected:
1354 static bool isCounterBase(const IntrinsicInst &I) {
1355 switch (I.getIntrinsicID()) {
1356 case Intrinsic::instrprof_cover:
1357 case Intrinsic::instrprof_increment:
1358 case Intrinsic::instrprof_increment_step:
1359 case Intrinsic::instrprof_callsite:
1360 case Intrinsic::instrprof_timestamp:
1361 case Intrinsic::instrprof_value_profile:
1362 return true;
1363 }
1364 return false;
1365 }
1366 static bool isMCDCBitmapBase(const IntrinsicInst &I) {
1367 switch (I.getIntrinsicID()) {
1368 case Intrinsic::instrprof_mcdc_parameters:
1369 case Intrinsic::instrprof_mcdc_tvbitmap_update:
1370 return true;
1371 }
1372 return false;
1373 }
1374
1375public:
1376 static bool classof(const Value *V) {
1377 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1378 return isCounterBase(*Instr) || isMCDCBitmapBase(*Instr);
1379 return false;
1380 }
1381
1382 // The name of the instrumented function, assuming it is a global variable.
1385 }
1386
1387 // The "name" operand of the profile instrumentation instruction - this is the
1388 // operand that can be used to relate the instruction to the function it
1389 // belonged to at instrumentation time.
1391
1393
1394 // The hash of the CFG for the instrumented function.
1396};
1397
1398/// A base class for all instrprof counter intrinsics.
1400public:
1401 static bool classof(const Value *V) {
1402 if (const auto *Instr = dyn_cast<IntrinsicInst>(V))
1403 return InstrProfInstBase::isCounterBase(*Instr);
1404 return false;
1405 }
1406
1407 // The number of counters for the instrumented function.
1409 // The index of the counter that this instruction acts on.
1410 LLVM_ABI ConstantInt *getIndex() const;
1411 LLVM_ABI void setIndex(uint32_t Idx);
1412};
1413
1414/// This represents the llvm.instrprof.cover intrinsic.
1416public:
1417 static bool classof(const IntrinsicInst *I) {
1418 return I->getIntrinsicID() == Intrinsic::instrprof_cover;
1419 }
1420 static bool classof(const Value *V) {
1422 }
1423};
1424
1425/// This represents the llvm.instrprof.increment intrinsic.
1427public:
1428 static bool classof(const IntrinsicInst *I) {
1429 return I->getIntrinsicID() == Intrinsic::instrprof_increment ||
1430 I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1431 }
1432 static bool classof(const Value *V) {
1434 }
1435 LLVM_ABI Value *getStep() const;
1436};
1437
1438/// This represents the llvm.instrprof.increment.step intrinsic.
1440public:
1441 static bool classof(const IntrinsicInst *I) {
1442 return I->getIntrinsicID() == Intrinsic::instrprof_increment_step;
1443 }
1444 static bool classof(const Value *V) {
1446 }
1447};
1448
1449/// This represents the llvm.instrprof.callsite intrinsic.
1450/// It is structurally like the increment or step counters, hence the
1451/// inheritance relationship, albeit somewhat tenuous (it's not 'counting' per
1452/// se)
1454public:
1455 static bool classof(const IntrinsicInst *I) {
1456 return I->getIntrinsicID() == Intrinsic::instrprof_callsite;
1457 }
1458 static bool classof(const Value *V) {
1460 }
1461 // We instrument direct calls (but not to intrinsics), or indirect calls.
1462 static bool canInstrumentCallsite(const CallBase &CB) {
1463 return !CB.isInlineAsm() &&
1464 (CB.isIndirectCall() ||
1466 }
1467 LLVM_ABI Value *getCallee() const;
1468 LLVM_ABI void setCallee(Value *Callee);
1469};
1470
1471/// This represents the llvm.instrprof.timestamp intrinsic.
1473public:
1474 static bool classof(const IntrinsicInst *I) {
1475 return I->getIntrinsicID() == Intrinsic::instrprof_timestamp;
1476 }
1477 static bool classof(const Value *V) {
1479 }
1480};
1481
1482/// This represents the llvm.instrprof.value.profile intrinsic.
1484public:
1485 static bool classof(const IntrinsicInst *I) {
1486 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
1487 }
1488 static bool classof(const Value *V) {
1490 }
1491
1493
1496 }
1497
1498 // Returns the value site index.
1500};
1501
1502/// A base class for instrprof mcdc intrinsics that require global bitmap bytes.
1504public:
1505 static bool classof(const IntrinsicInst *I) {
1507 }
1508 static bool classof(const Value *V) {
1510 }
1511
1512 /// \return The number of bits used for the MCDC bitmaps for the instrumented
1513 /// function.
1517
1518 /// \return The number of bytes used for the MCDC bitmaps for the instrumented
1519 /// function.
1520 auto getNumBitmapBytes() const {
1521 return alignTo(getNumBitmapBits()->getZExtValue(), CHAR_BIT) / CHAR_BIT;
1522 }
1523};
1524
1525/// This represents the llvm.instrprof.mcdc.parameters intrinsic.
1527public:
1528 static bool classof(const IntrinsicInst *I) {
1529 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_parameters;
1530 }
1531 static bool classof(const Value *V) {
1533 }
1534};
1535
1536/// This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
1538public:
1539 static bool classof(const IntrinsicInst *I) {
1540 return I->getIntrinsicID() == Intrinsic::instrprof_mcdc_tvbitmap_update;
1541 }
1542 static bool classof(const Value *V) {
1544 }
1545
1546 /// \return The index of the TestVector Bitmap upon which this intrinsic
1547 /// acts.
1550 }
1551
1552 /// \return The address of the corresponding condition bitmap containing
1553 /// the index of the TestVector to update within the TestVector Bitmap.
1555};
1556
1558public:
1559 static bool classof(const IntrinsicInst *I) {
1560 return I->getIntrinsicID() == Intrinsic::pseudoprobe;
1561 }
1562
1563 static bool classof(const Value *V) {
1565 }
1566
1569 }
1570
1572
1575 }
1576
1578};
1579
1581public:
1582 static bool classof(const IntrinsicInst *I) {
1583 return I->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl;
1584 }
1585
1586 static bool classof(const Value *V) {
1588 }
1589
1591 auto *MV =
1593 return cast<MDNode>(MV->getMetadata());
1594 }
1595
1600};
1601
1602/// Common base class for representing values projected from a statepoint.
1603/// Currently, the only projections available are gc.result and gc.relocate.
1605public:
1606 static bool classof(const IntrinsicInst *I) {
1607 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate ||
1608 I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1609 }
1610
1611 static bool classof(const Value *V) {
1613 }
1614
1615 /// Return true if this relocate is tied to the invoke statepoint.
1616 /// This includes relocates which are on the unwinding path.
1617 bool isTiedToInvoke() const {
1618 const Value *Token = getArgOperand(0);
1619
1620 return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1621 }
1622
1623 /// The statepoint with which this gc.relocate is associated.
1624 LLVM_ABI const Value *getStatepoint() const;
1625};
1626
1627/// Represents calls to the gc.relocate intrinsic.
1629public:
1630 static bool classof(const IntrinsicInst *I) {
1631 return I->getIntrinsicID() == Intrinsic::experimental_gc_relocate;
1632 }
1633
1634 static bool classof(const Value *V) {
1636 }
1637
1638 /// The index into the associate statepoint's argument list
1639 /// which contains the base pointer of the pointer whose
1640 /// relocation this gc.relocate describes.
1641 unsigned getBasePtrIndex() const {
1642 return cast<ConstantInt>(getArgOperand(1))->getZExtValue();
1643 }
1644
1645 /// The index into the associate statepoint's argument list which
1646 /// contains the pointer whose relocation this gc.relocate describes.
1647 unsigned getDerivedPtrIndex() const {
1648 return cast<ConstantInt>(getArgOperand(2))->getZExtValue();
1649 }
1650
1651 LLVM_ABI Value *getBasePtr() const;
1652 LLVM_ABI Value *getDerivedPtr() const;
1653};
1654
1655/// Represents calls to the gc.result intrinsic.
1657public:
1658 static bool classof(const IntrinsicInst *I) {
1659 return I->getIntrinsicID() == Intrinsic::experimental_gc_result;
1660 }
1661
1662 static bool classof(const Value *V) {
1664 }
1665};
1666
1667
1668/// This represents the llvm.assume intrinsic.
1670public:
1671 static bool classof(const IntrinsicInst *I) {
1672 return I->getIntrinsicID() == Intrinsic::assume;
1673 }
1674 static bool classof(const Value *V) {
1676 }
1677};
1678
1679/// Check if \p ID corresponds to a convergence control intrinsic.
1680static inline bool isConvergenceControlIntrinsic(unsigned IntrinsicID) {
1681 switch (IntrinsicID) {
1682 default:
1683 return false;
1684 case Intrinsic::experimental_convergence_anchor:
1685 case Intrinsic::experimental_convergence_entry:
1686 case Intrinsic::experimental_convergence_loop:
1687 return true;
1688 }
1689}
1690
1691/// Represents calls to the llvm.experimintal.convergence.* intrinsics.
1693public:
1694 static bool classof(const IntrinsicInst *I) {
1695 return isConvergenceControlIntrinsic(I->getIntrinsicID());
1696 }
1697
1698 static bool classof(const Value *V) {
1700 }
1701
1702 bool isAnchor() const {
1703 return getIntrinsicID() == Intrinsic::experimental_convergence_anchor;
1704 }
1705 bool isEntry() const {
1706 return getIntrinsicID() == Intrinsic::experimental_convergence_entry;
1707 }
1708 bool isLoop() const {
1709 return getIntrinsicID() == Intrinsic::experimental_convergence_loop;
1710 }
1711
1716};
1717
1719public:
1720 static bool classof(const IntrinsicInst *I) {
1721 return I->getIntrinsicID() == Intrinsic::structured_alloca;
1722 }
1723
1724 static bool classof(const Value *V) {
1726 }
1727
1729 return getRetAttr(Attribute::ElementType).getValueAsType();
1730 }
1731};
1732
1734public:
1735 static bool classof(const IntrinsicInst *I) {
1736 return I->getIntrinsicID() == Intrinsic::structured_gep;
1737 }
1738
1739 static bool classof(const Value *V) {
1741 }
1742
1743 static unsigned getPointerOperandIndex() { return 0; }
1744
1748
1750 return getParamAttr(0, Attribute::ElementType).getValueAsType();
1751 }
1752
1753 unsigned getNumIndices() const { return arg_size() - 1; }
1754
1755 Value *getIndexOperand(size_t Index) const {
1756 assert(Index < getNumIndices());
1757 return getOperand(Index + 1);
1758 }
1759
1761 return make_range(op_begin() + 1, op_begin() + 1 + getNumIndices());
1762 }
1763
1765 Type *CurrentType = getBaseType();
1766 for (unsigned I = 0; I < getNumIndices(); I++) {
1767 if (ArrayType *AT = dyn_cast<ArrayType>(CurrentType)) {
1768 CurrentType = AT->getElementType();
1769 } else if (VectorType *VT = dyn_cast<VectorType>(CurrentType)) {
1770 CurrentType = VT->getElementType();
1771 } else if (StructType *ST = dyn_cast<StructType>(CurrentType)) {
1773 CurrentType = ST->getElementType(CI->getZExtValue());
1774 } else {
1775 // FIXME(Keenuts): add testing reaching those places once initial
1776 // implementation has landed.
1777 llvm_unreachable("unimplemented");
1778 }
1779 }
1780
1781 return CurrentType;
1782 }
1783};
1784
1785} // end namespace llvm
1786
1787#endif // LLVM_IR_INTRINSICINST_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
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 LLVM_ABI
Definition Compiler.h:215
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file contains the declarations of entities that describe floating point environment and related ...
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static unsigned getScalarSizeInBits(Type *Ty)
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
Value * RHS
Class for arbitrary precision integers.
Definition APInt.h:78
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
Definition APInt.h:202
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
Definition APInt.h:205
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
Definition APInt.h:212
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Definition APInt.h:215
This class represents any memcpy intrinsic i.e.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
static bool classof(const Value *V)
Value * getRawElementSizeInBytes() const
uint32_t getElementSizeInBytes() const
static bool classof(const IntrinsicInst *I)
This class represents any memmove intrinsic i.e.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This class represents any memset intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Class to represent array types.
This represents the llvm.assume intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM_ABI Type * getValueAsType() const
Return the attribute's value as a Type.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
This class represents an intrinsic that is based on a binary operation.
static bool classof(const Value *V)
LLVM_ABI unsigned getNoWrapKind() const
Returns one of OBO::NoSignedWrap or OBO::NoUnsignedWrap.
LLVM_ABI bool isSigned() const
Whether the intrinsic is signed or unsigned.
static bool classof(const IntrinsicInst *I)
LLVM_ABI Instruction::BinaryOps getBinaryOp() const
Returns the binary operation underlying the intrinsic.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
bool isInlineAsm() const
Check if this call is an inline asm statement.
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Value * getCalledOperand() const
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Value * getArgOperand(unsigned i) const
void setArgOperand(unsigned i, Value *v)
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
unsigned arg_size() const
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
@ ICMP_SLT
signed less than
Definition InstrTypes.h:769
@ ICMP_UGT
unsigned greater than
Definition InstrTypes.h:763
@ ICMP_SGT
signed greater than
Definition InstrTypes.h:767
@ ICMP_ULT
unsigned less than
Definition InstrTypes.h:765
bool isSigned() const
Definition InstrTypes.h:993
This class represents a ucmp/scmp intrinsic.
static CmpInst::Predicate getGTPredicate(Intrinsic::ID ID)
Value * getRHS() const
CmpInst::Predicate getLTPredicate() const
static CmpInst::Predicate getLTPredicate(Intrinsic::ID ID)
static bool classof(const IntrinsicInst *I)
static bool isSigned(Intrinsic::ID ID)
bool isSigned() const
CmpInst::Predicate getGTPredicate() const
Value * getLHS() const
static bool classof(const Value *V)
This is the shared class of boolean and integer constants.
Definition Constants.h:87
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Definition Constants.h:219
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
Definition Constants.h:168
This is an important base class in LLVM.
Definition Constant.h:43
static LLVM_ABI Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
Constrained floating point compare intrinsics.
LLVM_ABI FCmpInst::Predicate getPredicate() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This is the common base class for constrained floating point intrinsics.
LLVM_ABI std::optional< fp::ExceptionBehavior > getExceptionBehavior() const
LLVM_ABI std::optional< RoundingMode > getRoundingMode() const
LLVM_ABI unsigned getNonMetadataArgCount() const
static LLVM_ABI bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
LLVM_ABI bool isDefaultFPEnvironment() const
Represents calls to the llvm.experimintal.convergence.* intrinsics.
static bool classof(const Value *V)
static LLVM_ABI ConvergenceControlInst * CreateAnchor(BasicBlock &BB)
static LLVM_ABI ConvergenceControlInst * CreateLoop(BasicBlock &BB, ConvergenceControlInst *Parent)
static LLVM_ABI ConvergenceControlInst * CreateEntry(BasicBlock &BB)
static bool classof(const IntrinsicInst *I)
DWARF expression.
DbgVariableFragmentInfo FragmentInfo
static LLVM_ABI std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
This represents the llvm.dbg.assign instruction.
DIAssignID * getAssignID() const
LLVM_ABI void setValue(Value *V)
static bool classof(const Value *V)
LLVM_ABI void setAssignId(DIAssignID *New)
Metadata * getRawAddress() const
DIExpression * getAddressExpression() const
LLVM_ABI Value * getAddress() const
static bool classof(const IntrinsicInst *I)
Metadata * getRawAddressExpression() const
Metadata * getRawAssignID() const
LLVM_ABI void setAddress(Value *V)
This represents the llvm.dbg.declare instruction.
static bool classof(const Value *V)
Value * getAddress() const
static bool classof(const IntrinsicInst *I)
This is the common base class for debug info intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.dbg.label instruction.
Metadata * getRawLabel() const
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
DILabel * getLabel() const
static bool classof(const Value *V)
This represents the llvm.dbg.value instruction.
iterator_range< location_op_iterator > getValues() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Value * getValue(unsigned OpIdx=0) const
This is the common base class for debug info intrinsics for variables.
DIExpression::FragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
bool isValueOfVariable() const
Determine if this describes the value of a local variable.
LLVM_ABI void replaceVariableLocationOp(Value *OldValue, Value *NewValue, bool AllowEmpty=false)
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
std::optional< DIExpression::FragmentInfo > getFragment() const
Get the FragmentInfo for the variable.
static bool classof(const Value *V)
void setExpression(DIExpression *NewExpr)
Metadata * getRawLocation() const
DILocalVariable * getVariable() const
unsigned getNumVariableLocationOps() const
void setOperand(unsigned i, Value *v)
Metadata * getRawVariable() const
static bool classof(const IntrinsicInst *I)
LLVM_ABI std::optional< uint64_t > getFragmentSizeInBits() const
Get the size (in bits) of the variable, or fragment of the variable that is described.
DIExpression * getExpression() const
void setArgOperand(unsigned i, Value *v)
Metadata * getRawExpression() const
RawLocationWrapper getWrappedLocation() const
Class representing an expression and its matching format.
Common base class for representing values projected from a statepoint.
LLVM_ABI const Value * getStatepoint() const
The statepoint with which this gc.relocate is associated.
bool isTiedToInvoke() const
Return true if this relocate is tied to the invoke statepoint.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Represents calls to the gc.relocate intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
LLVM_ABI Value * getBasePtr() const
unsigned getBasePtrIndex() const
The index into the associate statepoint's argument list which contains the base pointer of the pointe...
LLVM_ABI Value * getDerivedPtr() const
unsigned getDerivedPtrIndex() const
The index into the associate statepoint's argument list which contains the pointer whose relocation t...
Represents calls to the gc.result intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.callsite intrinsic.
LLVM_ABI void setCallee(Value *Callee)
LLVM_ABI Value * getCallee() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static bool canInstrumentCallsite(const CallBase &CB)
A base class for all instrprof counter intrinsics.
static bool classof(const Value *V)
LLVM_ABI ConstantInt * getIndex() const
LLVM_ABI void setIndex(uint32_t Idx)
LLVM_ABI ConstantInt * getNumCounters() const
This represents the llvm.instrprof.cover intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.instrprof.increment.step intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.increment intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
LLVM_ABI Value * getStep() const
A base class for all instrprof intrinsics.
static bool classof(const Value *V)
void setNameValue(Value *V)
GlobalVariable * getName() const
ConstantInt * getHash() const
Value * getNameValue() const
static bool isCounterBase(const IntrinsicInst &I)
static bool isMCDCBitmapBase(const IntrinsicInst &I)
A base class for instrprof mcdc intrinsics that require global bitmap bytes.
ConstantInt * getNumBitmapBits() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.mcdc.parameters intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.mcdc.tvbitmap.update intrinsic.
ConstantInt * getBitmapIndex() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.instrprof.timestamp intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
This represents the llvm.instrprof.value.profile intrinsic.
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
ConstantInt * getValueKind() const
static bool classof(const Value *V)
A wrapper class for inspecting calls to intrinsic functions.
bool isAssumeLikeIntrinsic() const
Checks if the intrinsic is an annotation.
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
IntrinsicInst(const IntrinsicInst &)=delete
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
bool isCommutative() const
Return true if swapping the first two arguments to the intrinsic produces the same result.
bool isCommutableOperand(unsigned Op) const
Return true if the operand is commutable.
static bool classof(const Value *V)
IntrinsicInst & operator=(const IntrinsicInst &)=delete
static bool classof(const CallInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
bool isAssociative() const
This is the common base class for lifetime intrinsics.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Metadata node.
Definition Metadata.h:1081
This class wraps the llvm.memcpy intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memory intrinsics.
const Use & getRawDestUse() const
Value * getLength() const
Value * getRawDest() const
void setDestAlignment(Align Alignment)
void setLength(Value *L)
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions (including addrspacecast) that ...
void setDestAlignment(MaybeAlign Alignment)
void setLength(uint64_t L)
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
MaybeAlign getDestAlign() const
const Use & getLengthUse() const
unsigned getDestAddressSpace() const
std::optional< APInt > getLengthInBytes() const
This is the common base class for memset/memcpy/memmove.
ConstantInt * getVolatileCst() const
void setVolatile(Constant *V)
bool isForceInlined() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
bool isVolatile() const
This class wraps the llvm.memmove intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Common base class for all memset intrinsics.
void setValue(Value *Val)
const Use & getValueUse() const
Value * getValue() const
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This class wraps the llvm.experimental.memset.pattern intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getVolatileCst() const
void setVolatile(Constant *V)
Common base class for all memory transfer intrinsics.
void setSource(Value *Ptr)
Value * getRawSource() const
Return the arguments to the instruction.
unsigned getSourceAddressSpace() const
MaybeAlign getSourceAlign() const
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it,...
void setSourceAlignment(MaybeAlign Alignment)
void setSourceAlignment(Align Alignment)
const Use & getRawSourceUse() const
This class wraps the llvm.memcpy/memmove intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:107
Root of the metadata hierarchy.
Definition Metadata.h:64
This class represents min/max intrinsics.
static bool classof(const Value *V)
static Constant * getSaturationPoint(Intrinsic::ID ID, Type *Ty)
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
APInt getSaturationPoint(unsigned numBits) const
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
static APInt getSaturationPoint(Intrinsic::ID ID, unsigned numBits)
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
Value * getLHS() const
APInt getIdentity() const
Returns the identity value for this min/max intrinsic, such that minmax(X, Identity) == X.
Value * getRHS() const
bool isMin() const
Whether the intrinsic is a smin or a umin.
static ICmpInst::Predicate getPredicate(Intrinsic::ID ID)
Returns the comparison predicate underlying the intrinsic.
ICmpInst::Predicate getPredicate() const
Returns the comparison predicate underlying the intrinsic.
static bool isMin(Intrinsic::ID ID)
Whether the intrinsic is a smin or umin.
static bool isSigned(Intrinsic::ID ID)
Whether the intrinsic is signed or unsigned.
static APInt getIdentity(Intrinsic::ID ID, unsigned NumBits)
Returns the identity value for this min/max intrinsic, such that minmax(X, Identity) == X.
bool isMax() const
Whether the intrinsic is a smax or a umax.
static bool classof(const IntrinsicInst *I)
bool isSigned() const
Whether the intrinsic is signed or unsigned.
Constant * getSaturationPoint(Type *Ty) const
Min/max intrinsics are monotonic, they operate on a fixed-bitwidth values, so there is a certain thre...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
static bool classof(const IntrinsicInst *I)
void setScopeList(MDNode *ScopeList)
static bool classof(const Value *V)
MDNode * getScopeList() const
A discriminated union of two or more pointer types, with the discriminator in the low bits of the poi...
ConstantInt * getAttributes() const
ConstantInt * getIndex() const
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
ConstantInt * getFactor() const
ConstantInt * getFuncGuid() const
Lightweight class that wraps the location operand metadata of a debug intrinsic.
friend bool operator<=(const RawLocationWrapper &A, const RawLocationWrapper &B)
Metadata * getRawLocation() const
friend bool operator>(const RawLocationWrapper &A, const RawLocationWrapper &B)
RawLocationWrapper(Metadata *RawLocation)
friend bool operator<(const RawLocationWrapper &A, const RawLocationWrapper &B)
friend bool operator==(const RawLocationWrapper &A, const RawLocationWrapper &B)
LLVM_ABI iterator_range< location_op_iterator > location_ops() const
Get the locations corresponding to the variable referenced by the debug info intrinsic.
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
bool isKillLocation(const DIExpression *Expression) const
friend bool operator!=(const RawLocationWrapper &A, const RawLocationWrapper &B)
unsigned getNumVariableLocationOps() const
friend bool operator>=(const RawLocationWrapper &A, const RawLocationWrapper &B)
Represents a saturating add/sub intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Class to represent struct types.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
iterator_range< op_iterator > indices()
unsigned getNumIndices() const
static unsigned getPointerOperandIndex()
static bool classof(const Value *V)
Value * getPointerOperand() const
Type * getResultElementType() const
Value * getIndexOperand(size_t Index) const
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
op_iterator op_begin()
Definition User.h:259
void setOperand(unsigned i, Value *Val)
Definition User.h:212
Value * getOperand(unsigned i) const
Definition User.h:207
This represents the llvm.va_copy intrinsic.
Value * getSrc() const
static bool classof(const Value *V)
Value * getDest() const
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_end intrinsic.
Value * getArgList() const
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
This represents the llvm.va_start intrinsic.
static bool classof(const IntrinsicInst *I)
static bool classof(const Value *V)
Value * getArgList() const
This is the common base class for vector predication intrinsics.
std::optional< unsigned > getFunctionalIntrinsicID() const
static bool classof(const Value *V)
static LLVM_ABI std::optional< unsigned > getMaskParamPos(Intrinsic::ID IntrinsicID)
LLVM_ABI bool canIgnoreVectorLengthParam() const
LLVM_ABI void setMaskParam(Value *)
static LLVM_ABI std::optional< unsigned > getFunctionalOpcodeForVP(Intrinsic::ID ID)
static LLVM_ABI std::optional< unsigned > getMemoryDataParamPos(Intrinsic::ID)
LLVM_ABI Value * getVectorLengthParam() const
static bool classof(const IntrinsicInst *I)
static LLVM_ABI std::optional< Intrinsic::ID > getFunctionalIntrinsicIDForVP(Intrinsic::ID ID)
LLVM_ABI void setVectorLengthParam(Value *)
static LLVM_ABI std::optional< unsigned > getVectorLengthParamPos(Intrinsic::ID IntrinsicID)
static LLVM_ABI Function * getOrInsertDeclarationForParams(Module *M, Intrinsic::ID, Type *ReturnType, ArrayRef< Value * > Params)
Declares a llvm.vp.
static LLVM_ABI std::optional< unsigned > getMemoryPointerParamPos(Intrinsic::ID)
static LLVM_ABI bool isVPIntrinsic(Intrinsic::ID)
LLVM_ABI Value * getMemoryDataParam() const
LLVM_ABI Value * getMemoryPointerParam() const
LLVM_ABI MaybeAlign getPointerAlignment() const
LLVM_ABI Value * getMaskParam() const
LLVM_ABI ElementCount getStaticVectorLength() const
std::optional< unsigned > getFunctionalOpcode() const
This represents vector predication reduction intrinsics.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static LLVM_ABI bool isVPReduction(Intrinsic::ID ID)
LLVM_ABI unsigned getStartParamPos() const
LLVM_ABI unsigned getVectorParamPos() const
Value wrapper in the Metadata hierarchy.
Definition Metadata.h:471
Value * getValue() const
Definition Metadata.h:510
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition Value.cpp:712
Base class of all SIMD vector types.
Represents an op.with.overflow intrinsic.
static bool classof(const Value *V)
static bool classof(const IntrinsicInst *I)
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterator.h:80
A range adaptor for a pair of iterators.
bool operator==(const location_op_iterator &RHS) const
location_op_iterator & operator=(const location_op_iterator &R)
location_op_iterator(ValueAsMetadata **MultiIter)
location_op_iterator(const location_op_iterator &R)
location_op_iterator & operator++()
location_op_iterator(ValueAsMetadata *SingleIter)
location_op_iterator & operator--()
const Value * operator*() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const int NoAliasScopeDeclScopeArg
Definition Intrinsics.h:44
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1762
static bool isLifetimeIntrinsic(Intrinsic::ID ID)
Check if ID corresponds to a lifetime intrinsic.
static bool isDbgInfoIntrinsic(Intrinsic::ID ID)
Check if ID corresponds to a debug info intrinsic.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:149
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
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
static bool isConvergenceControlIntrinsic(unsigned IntrinsicID)
Check if ID corresponds to a convergence control intrinsic.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:111